summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/FileSystemRuntimeException.java73
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java74
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java80
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java48
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java80
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java171
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java107
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java53
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java143
-rw-r--r--connectivity/com/sun/star/sdbcx/comp/hsqldb/makefile.mk65
-rw-r--r--connectivity/dbtools.pmk29
-rw-r--r--connectivity/inc/connectivity/BlobHelper.hxx51
-rw-r--r--connectivity/inc/connectivity/CommonTools.hxx216
-rw-r--r--connectivity/inc/connectivity/ConnectionWrapper.hxx98
-rw-r--r--connectivity/inc/connectivity/DateConversion.hxx94
-rwxr-xr-xconnectivity/inc/connectivity/DriversConfig.hxx87
-rw-r--r--connectivity/inc/connectivity/FValue.hxx467
-rw-r--r--connectivity/inc/connectivity/IParseContext.hxx108
-rw-r--r--connectivity/inc/connectivity/PColumn.hxx148
-rw-r--r--connectivity/inc/connectivity/ParameterCont.hxx59
-rw-r--r--connectivity/inc/connectivity/SQLStatementHelper.hxx54
-rw-r--r--connectivity/inc/connectivity/StdTypeDefs.hxx48
-rw-r--r--connectivity/inc/connectivity/TColumnsHelper.hxx70
-rw-r--r--connectivity/inc/connectivity/TIndex.hxx56
-rw-r--r--connectivity/inc/connectivity/TIndexColumns.hxx50
-rw-r--r--connectivity/inc/connectivity/TIndexes.hxx57
-rw-r--r--connectivity/inc/connectivity/TKey.hxx54
-rw-r--r--connectivity/inc/connectivity/TKeyColumns.hxx50
-rw-r--r--connectivity/inc/connectivity/TKeys.hxx66
-rw-r--r--connectivity/inc/connectivity/TTableHelper.hxx173
-rw-r--r--connectivity/inc/connectivity/conncleanup.hxx97
-rw-r--r--connectivity/inc/connectivity/dbcharset.hxx168
-rw-r--r--connectivity/inc/connectivity/dbconversion.hxx224
-rw-r--r--connectivity/inc/connectivity/dbexception.hxx377
-rw-r--r--connectivity/inc/connectivity/dbmetadata.hxx200
-rw-r--r--connectivity/inc/connectivity/dbtools.hxx825
-rw-r--r--connectivity/inc/connectivity/dbtoolsdllapi.hxx40
-rw-r--r--connectivity/inc/connectivity/filtermanager.hxx131
-rw-r--r--connectivity/inc/connectivity/formattedcolumnvalue.hxx119
-rw-r--r--connectivity/inc/connectivity/parameters.hxx426
-rw-r--r--connectivity/inc/connectivity/paramwrapper.hxx208
-rw-r--r--connectivity/inc/connectivity/predicateinput.hxx126
-rw-r--r--connectivity/inc/connectivity/sdbcx/IRefreshable.hxx57
-rw-r--r--connectivity/inc/connectivity/sdbcx/VCatalog.hxx132
-rw-r--r--connectivity/inc/connectivity/sdbcx/VCollection.hxx243
-rw-r--r--connectivity/inc/connectivity/sdbcx/VColumn.hxx118
-rw-r--r--connectivity/inc/connectivity/sdbcx/VDescriptor.hxx102
-rw-r--r--connectivity/inc/connectivity/sdbcx/VGroup.hxx113
-rw-r--r--connectivity/inc/connectivity/sdbcx/VIndex.hxx117
-rw-r--r--connectivity/inc/connectivity/sdbcx/VIndexColumn.hxx69
-rw-r--r--connectivity/inc/connectivity/sdbcx/VKey.hxx128
-rw-r--r--connectivity/inc/connectivity/sdbcx/VKeyColumn.hxx71
-rw-r--r--connectivity/inc/connectivity/sdbcx/VTable.hxx148
-rw-r--r--connectivity/inc/connectivity/sdbcx/VTypeDef.hxx47
-rw-r--r--connectivity/inc/connectivity/sdbcx/VUser.hxx107
-rw-r--r--connectivity/inc/connectivity/sdbcx/VView.hxx108
-rw-r--r--connectivity/inc/connectivity/sqlerror.hxx340
-rw-r--r--connectivity/inc/connectivity/sqliterator.hxx366
-rw-r--r--connectivity/inc/connectivity/sqlnode.hxx472
-rw-r--r--connectivity/inc/connectivity/sqlparse.hxx261
-rw-r--r--connectivity/inc/connectivity/standardsqlstate.hxx73
-rw-r--r--connectivity/inc/connectivity/statementcomposer.hxx111
-rw-r--r--connectivity/inc/connectivity/virtualdbtools.hxx358
-rw-r--r--connectivity/inc/connectivity/warningscontainer.hxx107
-rw-r--r--connectivity/inc/makefile.mk47
-rw-r--r--connectivity/inc/pch/precompiled_connectivity.cxx29
-rw-r--r--connectivity/inc/pch/precompiled_connectivity.hxx334
-rwxr-xr-xconnectivity/makefile.pmk62
-rw-r--r--connectivity/prj/build.lst32
-rw-r--r--connectivity/prj/d.lst33
-rw-r--r--connectivity/qa/connectivity/GeneralTest.java62
-rw-r--r--connectivity/qa/connectivity/makefile.mk65
-rwxr-xr-xconnectivity/qa/connectivity/tools/AbstractDatabase.java222
-rw-r--r--connectivity/qa/connectivity/tools/CRMDatabase.java292
-rw-r--r--connectivity/qa/connectivity/tools/DataSource.java145
-rwxr-xr-xconnectivity/qa/connectivity/tools/DatabaseAccess.java63
-rwxr-xr-xconnectivity/qa/connectivity/tools/DbaseDatabase.java98
-rw-r--r--connectivity/qa/connectivity/tools/HsqlColumnDescriptor.java84
-rw-r--r--connectivity/qa/connectivity/tools/HsqlDatabase.java213
-rw-r--r--connectivity/qa/connectivity/tools/HsqlTableDescriptor.java102
-rw-r--r--connectivity/qa/connectivity/tools/QueryDefinition.java74
-rw-r--r--connectivity/qa/connectivity/tools/RowSet.java292
-rw-r--r--connectivity/qa/connectivity/tools/makefile.mk65
-rw-r--r--connectivity/qa/connectivity/tools/sdb/Connection.java93
-rw-r--r--connectivity/qa/drivers/dbase/.nbattrs10
-rw-r--r--connectivity/qa/drivers/dbase/DBaseDateFunctions.java309
-rw-r--r--connectivity/qa/drivers/dbase/DBaseDriverTest.java94
-rw-r--r--connectivity/qa/drivers/dbase/DBaseNumericFunctions.java402
-rwxr-xr-xconnectivity/qa/drivers/dbase/DBaseSqlTests.java96
-rw-r--r--connectivity/qa/drivers/dbase/DBaseStringFunctions.java323
-rw-r--r--connectivity/qa/drivers/dbase/makefile.mk64
-rw-r--r--connectivity/qa/drivers/dbase/test.properties5
-rw-r--r--connectivity/qa/drivers/hsqldb/DatabaseMetaData.java152
-rw-r--r--connectivity/qa/drivers/hsqldb/DriverTest.java170
-rw-r--r--connectivity/qa/drivers/hsqldb/TestCacheSize.java617
-rw-r--r--connectivity/qa/drivers/jdbc/LongVarCharTest.java131
-rw-r--r--connectivity/qa/drivers/jdbc/makefile.mk66
-rw-r--r--connectivity/source/commontools/AutoRetrievingBase.cxx71
-rw-r--r--connectivity/source/commontools/BlobHelper.cxx69
-rw-r--r--connectivity/source/commontools/CommonTools.cxx369
-rw-r--r--connectivity/source/commontools/ConnectionWrapper.cxx267
-rw-r--r--connectivity/source/commontools/DateConversion.cxx520
-rwxr-xr-xconnectivity/source/commontools/DriversConfig.cxx262
-rw-r--r--connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx913
-rw-r--r--connectivity/source/commontools/FDatabaseMetaDataResultSetMetaData.cxx692
-rw-r--r--connectivity/source/commontools/FValue.cxx2333
-rw-r--r--connectivity/source/commontools/ParamterSubstitution.cxx132
-rw-r--r--connectivity/source/commontools/RowFunctionParser.cxx499
-rw-r--r--connectivity/source/commontools/TColumnsHelper.cxx225
-rw-r--r--connectivity/source/commontools/TConnection.cxx106
-rw-r--r--connectivity/source/commontools/TDatabaseMetaDataBase.cxx333
-rw-r--r--connectivity/source/commontools/TIndex.cxx110
-rw-r--r--connectivity/source/commontools/TIndexColumns.cxx127
-rw-r--r--connectivity/source/commontools/TIndexes.cxx262
-rw-r--r--connectivity/source/commontools/TKey.cxx119
-rw-r--r--connectivity/source/commontools/TKeyColumns.cxx145
-rw-r--r--connectivity/source/commontools/TKeys.cxx320
-rw-r--r--connectivity/source/commontools/TPrivilegesResultSet.cxx155
-rw-r--r--connectivity/source/commontools/TSkipDeletedSet.cxx278
-rw-r--r--connectivity/source/commontools/TSortIndex.cxx178
-rw-r--r--connectivity/source/commontools/TTableHelper.cxx630
-rw-r--r--connectivity/source/commontools/conncleanup.cxx247
-rw-r--r--connectivity/source/commontools/dbcharset.cxx232
-rw-r--r--connectivity/source/commontools/dbconversion.cxx490
-rw-r--r--connectivity/source/commontools/dbexception.cxx564
-rw-r--r--connectivity/source/commontools/dbmetadata.cxx448
-rw-r--r--connectivity/source/commontools/dbtools.cxx2173
-rw-r--r--connectivity/source/commontools/dbtools2.cxx974
-rw-r--r--connectivity/source/commontools/filtermanager.cxx198
-rw-r--r--connectivity/source/commontools/formattedcolumnvalue.cxx338
-rw-r--r--connectivity/source/commontools/makefile.mk103
-rw-r--r--connectivity/source/commontools/parameters.cxx1120
-rw-r--r--connectivity/source/commontools/paramwrapper.cxx364
-rw-r--r--connectivity/source/commontools/predicateinput.cxx391
-rw-r--r--connectivity/source/commontools/propertyids.cxx198
-rw-r--r--connectivity/source/commontools/sqlerror.cxx363
-rw-r--r--connectivity/source/commontools/statementcomposer.cxx315
-rw-r--r--connectivity/source/commontools/warningscontainer.cxx123
-rw-r--r--connectivity/source/cpool/ZConnectionPool.cxx336
-rw-r--r--connectivity/source/cpool/ZConnectionPool.hxx155
-rw-r--r--connectivity/source/cpool/ZConnectionWrapper.cxx258
-rw-r--r--connectivity/source/cpool/ZConnectionWrapper.hxx87
-rw-r--r--connectivity/source/cpool/ZDriverWrapper.cxx135
-rw-r--r--connectivity/source/cpool/ZDriverWrapper.hxx89
-rw-r--r--connectivity/source/cpool/ZPoolCollection.cxx581
-rw-r--r--connectivity/source/cpool/ZPoolCollection.hxx148
-rw-r--r--connectivity/source/cpool/ZPooledConnection.cxx88
-rw-r--r--connectivity/source/cpool/ZPooledConnection.hxx68
-rw-r--r--connectivity/source/cpool/Zregistration.cxx108
-rw-r--r--connectivity/source/cpool/dbpool.xml28
-rw-r--r--connectivity/source/cpool/exports.dxp3
-rw-r--r--connectivity/source/cpool/makefile.mk81
-rw-r--r--connectivity/source/dbtools/dbt.xml16
-rw-r--r--connectivity/source/dbtools/exports.dxp3
-rw-r--r--connectivity/source/dbtools/makefile.mk97
-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.cxx1173
-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.cxx1898
-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.cxx847
-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.cxx551
-rw-r--r--connectivity/source/drivers/hsqldb/HStorageMap.cxx362
-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.cxx51
-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.cxx429
-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.cxx62
-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
-rw-r--r--connectivity/source/inc/AutoRetrievingBase.hxx59
-rw-r--r--connectivity/source/inc/FDatabaseMetaDataResultSet.hxx279
-rw-r--r--connectivity/source/inc/FDatabaseMetaDataResultSetMetaData.hxx114
-rw-r--r--connectivity/source/inc/OColumn.hxx146
-rw-r--r--connectivity/source/inc/OSubComponent.hxx92
-rw-r--r--connectivity/source/inc/OTypeInfo.hxx92
-rw-r--r--connectivity/source/inc/ParameterSubstitution.hxx71
-rw-r--r--connectivity/source/inc/RowFunctionParser.hxx152
-rw-r--r--connectivity/source/inc/TConnection.hxx92
-rw-r--r--connectivity/source/inc/TDatabaseMetaDataBase.hxx142
-rw-r--r--connectivity/source/inc/TKeyValue.hxx82
-rw-r--r--connectivity/source/inc/TPrivilegesResultSet.hxx54
-rw-r--r--connectivity/source/inc/TResultSetHelper.hxx58
-rw-r--r--connectivity/source/inc/TSkipDeletedSet.hxx105
-rw-r--r--connectivity/source/inc/TSortIndex.hxx139
-rw-r--r--connectivity/source/inc/UStringDescription_Impl.hxx106
-rw-r--r--connectivity/source/inc/adabas/BCatalog.hxx77
-rw-r--r--connectivity/source/inc/adabas/BColumn.hxx54
-rw-r--r--connectivity/source/inc/adabas/BColumns.hxx61
-rw-r--r--connectivity/source/inc/adabas/BConnection.hxx78
-rw-r--r--connectivity/source/inc/adabas/BDatabaseMetaData.hxx55
-rw-r--r--connectivity/source/inc/adabas/BDriver.hxx177
-rw-r--r--connectivity/source/inc/adabas/BGroup.hxx50
-rw-r--r--connectivity/source/inc/adabas/BGroups.hxx66
-rw-r--r--connectivity/source/inc/adabas/BIndex.hxx58
-rw-r--r--connectivity/source/inc/adabas/BIndexColumn.hxx58
-rw-r--r--connectivity/source/inc/adabas/BIndexColumns.hxx58
-rw-r--r--connectivity/source/inc/adabas/BIndexes.hxx58
-rw-r--r--connectivity/source/inc/adabas/BKeys.hxx55
-rw-r--r--connectivity/source/inc/adabas/BPreparedStatement.hxx52
-rw-r--r--connectivity/source/inc/adabas/BResultSet.hxx60
-rw-r--r--connectivity/source/inc/adabas/BResultSetMetaData.hxx56
-rw-r--r--connectivity/source/inc/adabas/BStatement.hxx62
-rw-r--r--connectivity/source/inc/adabas/BTable.hxx110
-rw-r--r--connectivity/source/inc/adabas/BTables.hxx80
-rw-r--r--connectivity/source/inc/adabas/BUser.hxx82
-rw-r--r--connectivity/source/inc/adabas/BUsers.hxx66
-rw-r--r--connectivity/source/inc/adabas/BViews.hxx64
-rw-r--r--connectivity/source/inc/ado/ACallableStatement.hxx88
-rw-r--r--connectivity/source/inc/ado/ACatalog.hxx61
-rw-r--r--connectivity/source/inc/ado/ACollection.hxx231
-rw-r--r--connectivity/source/inc/ado/AColumn.hxx70
-rw-r--r--connectivity/source/inc/ado/AColumns.hxx68
-rw-r--r--connectivity/source/inc/ado/AConnection.hxx151
-rw-r--r--connectivity/source/inc/ado/ADatabaseMetaData.hxx230
-rw-r--r--connectivity/source/inc/ado/ADatabaseMetaDataResultSet.hxx227
-rw-r--r--connectivity/source/inc/ado/ADatabaseMetaDataResultSetMetaData.hxx115
-rw-r--r--connectivity/source/inc/ado/ADriver.hxx93
-rw-r--r--connectivity/source/inc/ado/AGroup.hxx76
-rw-r--r--connectivity/source/inc/ado/AGroups.hxx69
-rw-r--r--connectivity/source/inc/ado/AIndex.hxx65
-rw-r--r--connectivity/source/inc/ado/AIndexColumn.hxx58
-rw-r--r--connectivity/source/inc/ado/AIndexColumns.hxx55
-rw-r--r--connectivity/source/inc/ado/AIndexes.hxx66
-rw-r--r--connectivity/source/inc/ado/AKey.hxx73
-rw-r--r--connectivity/source/inc/ado/AKeyColumn.hxx58
-rw-r--r--connectivity/source/inc/ado/AKeyColumns.hxx55
-rw-r--r--connectivity/source/inc/ado/AKeys.hxx66
-rw-r--r--connectivity/source/inc/ado/APreparedStatement.hxx124
-rw-r--r--connectivity/source/inc/ado/AResultSet.hxx237
-rw-r--r--connectivity/source/inc/ado/AResultSetMetaData.hxx93
-rw-r--r--connectivity/source/inc/ado/AStatement.hxx201
-rw-r--r--connectivity/source/inc/ado/ATable.hxx88
-rw-r--r--connectivity/source/inc/ado/ATables.hxx65
-rw-r--r--connectivity/source/inc/ado/AUser.hxx102
-rw-r--r--connectivity/source/inc/ado/AUsers.hxx70
-rw-r--r--connectivity/source/inc/ado/AView.hxx66
-rw-r--r--connectivity/source/inc/ado/AViews.hxx64
-rw-r--r--connectivity/source/inc/ado/Aolevariant.hxx175
-rw-r--r--connectivity/source/inc/ado/Aolewrap.hxx245
-rw-r--r--connectivity/source/inc/ado/Awrapado.hxx419
-rw-r--r--connectivity/source/inc/ado/Awrapadox.hxx149
-rw-r--r--connectivity/source/inc/ado/WrapCatalog.hxx58
-rw-r--r--connectivity/source/inc/ado/WrapColumn.hxx72
-rw-r--r--connectivity/source/inc/ado/WrapIndex.hxx60
-rw-r--r--connectivity/source/inc/ado/WrapKey.hxx62
-rw-r--r--connectivity/source/inc/ado/WrapTable.hxx65
-rw-r--r--connectivity/source/inc/ado/WrapTypeDefs.hxx53
-rw-r--r--connectivity/source/inc/ado/adoimp.hxx112
-rw-r--r--connectivity/source/inc/calc/CCatalog.hxx50
-rw-r--r--connectivity/source/inc/calc/CColumns.hxx53
-rw-r--r--connectivity/source/inc/calc/CConnection.hxx97
-rw-r--r--connectivity/source/inc/calc/CDatabaseMetaData.hxx61
-rw-r--r--connectivity/source/inc/calc/CDriver.hxx65
-rw-r--r--connectivity/source/inc/calc/CPreparedStatement.hxx50
-rw-r--r--connectivity/source/inc/calc/CResultSet.hxx90
-rw-r--r--connectivity/source/inc/calc/CStatement.hxx50
-rw-r--r--connectivity/source/inc/calc/CTable.hxx107
-rw-r--r--connectivity/source/inc/calc/CTables.hxx52
-rw-r--r--connectivity/source/inc/dbase/DCatalog.hxx49
-rw-r--r--connectivity/source/inc/dbase/DCode.hxx69
-rw-r--r--connectivity/source/inc/dbase/DColumns.hxx55
-rw-r--r--connectivity/source/inc/dbase/DConnection.hxx58
-rw-r--r--connectivity/source/inc/dbase/DDatabaseMetaData.hxx68
-rw-r--r--connectivity/source/inc/dbase/DDatabaseMetaDataResultSet.hxx196
-rw-r--r--connectivity/source/inc/dbase/DDatabaseMetaDataResultSetMetaData.hxx108
-rw-r--r--connectivity/source/inc/dbase/DDriver.hxx61
-rw-r--r--connectivity/source/inc/dbase/DIndex.hxx160
-rw-r--r--connectivity/source/inc/dbase/DIndexColumns.hxx60
-rw-r--r--connectivity/source/inc/dbase/DIndexIter.hxx85
-rw-r--r--connectivity/source/inc/dbase/DIndexPage.hxx89
-rw-r--r--connectivity/source/inc/dbase/DIndexes.hxx61
-rw-r--r--connectivity/source/inc/dbase/DPreparedStatement.hxx50
-rw-r--r--connectivity/source/inc/dbase/DResultSet.hxx90
-rw-r--r--connectivity/source/inc/dbase/DStatement.hxx49
-rw-r--r--connectivity/source/inc/dbase/DTable.hxx185
-rw-r--r--connectivity/source/inc/dbase/DTables.hxx58
-rw-r--r--connectivity/source/inc/dbase/dindexnode.hxx347
-rw-r--r--connectivity/source/inc/diagnose_ex.h46
-rw-r--r--connectivity/source/inc/file/FCatalog.hxx71
-rw-r--r--connectivity/source/inc/file/FColumns.hxx59
-rw-r--r--connectivity/source/inc/file/FConnection.hxx160
-rw-r--r--connectivity/source/inc/file/FDatabaseMetaData.hxx197
-rw-r--r--connectivity/source/inc/file/FDateFunctions.hxx242
-rw-r--r--connectivity/source/inc/file/FDriver.hxx87
-rw-r--r--connectivity/source/inc/file/FNumericFunctions.hxx376
-rw-r--r--connectivity/source/inc/file/FPreparedStatement.hxx135
-rw-r--r--connectivity/source/inc/file/FResultSet.hxx357
-rw-r--r--connectivity/source/inc/file/FResultSetMetaData.hxx91
-rw-r--r--connectivity/source/inc/file/FStatement.hxx223
-rw-r--r--connectivity/source/inc/file/FStringFunctions.hxx283
-rw-r--r--connectivity/source/inc/file/FTable.hxx120
-rw-r--r--connectivity/source/inc/file/FTables.hxx61
-rw-r--r--connectivity/source/inc/file/fanalyzer.hxx96
-rw-r--r--connectivity/source/inc/file/fcode.hxx396
-rw-r--r--connectivity/source/inc/file/fcomp.hxx120
-rw-r--r--connectivity/source/inc/file/filedllapi.hxx40
-rw-r--r--connectivity/source/inc/file/quotedstring.hxx55
-rw-r--r--connectivity/source/inc/flat/ECatalog.hxx49
-rw-r--r--connectivity/source/inc/flat/EColumns.hxx52
-rw-r--r--connectivity/source/inc/flat/EConnection.hxx71
-rw-r--r--connectivity/source/inc/flat/EDatabaseMetaData.hxx55
-rw-r--r--connectivity/source/inc/flat/EDriver.hxx61
-rw-r--r--connectivity/source/inc/flat/EPreparedStatement.hxx50
-rw-r--r--connectivity/source/inc/flat/EResultSet.hxx81
-rw-r--r--connectivity/source/inc/flat/EStatement.hxx49
-rw-r--r--connectivity/source/inc/flat/ETable.hxx103
-rw-r--r--connectivity/source/inc/flat/ETables.hxx52
-rw-r--r--connectivity/source/inc/hsqldb/HCatalog.hxx72
-rw-r--r--connectivity/source/inc/hsqldb/HColumns.hxx70
-rw-r--r--connectivity/source/inc/hsqldb/HConnection.hxx186
-rw-r--r--connectivity/source/inc/hsqldb/HDriver.hxx144
-rw-r--r--connectivity/source/inc/hsqldb/HStorageAccess.h95
-rw-r--r--connectivity/source/inc/hsqldb/HStorageAccess.hxx43
-rw-r--r--connectivity/source/inc/hsqldb/HStorageMap.hxx94
-rw-r--r--connectivity/source/inc/hsqldb/HTable.hxx128
-rw-r--r--connectivity/source/inc/hsqldb/HTables.hxx78
-rw-r--r--connectivity/source/inc/hsqldb/HTools.hxx65
-rw-r--r--connectivity/source/inc/hsqldb/HUser.hxx82
-rw-r--r--connectivity/source/inc/hsqldb/HUsers.hxx62
-rw-r--r--connectivity/source/inc/hsqldb/HView.hxx97
-rw-r--r--connectivity/source/inc/hsqldb/HViews.hxx63
-rw-r--r--connectivity/source/inc/hsqldb/StorageFileAccess.h37
-rw-r--r--connectivity/source/inc/hsqldb/StorageNativeInputStream.h70
-rw-r--r--connectivity/source/inc/internalnode.hxx60
-rw-r--r--connectivity/source/inc/java/ContextClassLoader.hxx103
-rw-r--r--connectivity/source/inc/java/GlobalRef.hxx122
-rw-r--r--connectivity/source/inc/java/LocalRef.hxx106
-rw-r--r--connectivity/source/inc/java/io/InputStream.hxx60
-rw-r--r--connectivity/source/inc/java/io/Reader.hxx61
-rw-r--r--connectivity/source/inc/java/lang/Boolean.hxx53
-rw-r--r--connectivity/source/inc/java/lang/Class.hxx55
-rw-r--r--connectivity/source/inc/java/lang/Exception.hxx51
-rw-r--r--connectivity/source/inc/java/lang/Object.hxx175
-rw-r--r--connectivity/source/inc/java/lang/String.hxx53
-rw-r--r--connectivity/source/inc/java/lang/Throwable.hxx54
-rw-r--r--connectivity/source/inc/java/math/BigDecimal.hxx53
-rw-r--r--connectivity/source/inc/java/sql/Array.hxx63
-rw-r--r--connectivity/source/inc/java/sql/Blob.hxx63
-rw-r--r--connectivity/source/inc/java/sql/CallableStatement.hxx91
-rw-r--r--connectivity/source/inc/java/sql/Clob.hxx63
-rw-r--r--connectivity/source/inc/java/sql/Connection.hxx151
-rw-r--r--connectivity/source/inc/java/sql/ConnectionLog.hxx142
-rw-r--r--connectivity/source/inc/java/sql/DatabaseMetaData.hxx224
-rw-r--r--connectivity/source/inc/java/sql/Driver.hxx76
-rw-r--r--connectivity/source/inc/java/sql/DriverPropertyInfo.hxx61
-rw-r--r--connectivity/source/inc/java/sql/JStatement.hxx219
-rw-r--r--connectivity/source/inc/java/sql/PreparedStatement.hxx113
-rw-r--r--connectivity/source/inc/java/sql/Ref.hxx58
-rw-r--r--connectivity/source/inc/java/sql/ResultSet.hxx208
-rw-r--r--connectivity/source/inc/java/sql/ResultSetMetaData.hxx82
-rw-r--r--connectivity/source/inc/java/sql/SQLException.hxx68
-rw-r--r--connectivity/source/inc/java/sql/SQLWarning.hxx64
-rw-r--r--connectivity/source/inc/java/sql/Timestamp.hxx99
-rw-r--r--connectivity/source/inc/java/tools.hxx92
-rw-r--r--connectivity/source/inc/java/util/Date.hxx54
-rw-r--r--connectivity/source/inc/java/util/Property.hxx49
-rw-r--r--connectivity/source/inc/mysql/YCatalog.hxx73
-rw-r--r--connectivity/source/inc/mysql/YColumns.hxx70
-rw-r--r--connectivity/source/inc/mysql/YDriver.hxx126
-rw-r--r--connectivity/source/inc/mysql/YTable.hxx128
-rw-r--r--connectivity/source/inc/mysql/YTables.hxx88
-rw-r--r--connectivity/source/inc/mysql/YUser.hxx82
-rw-r--r--connectivity/source/inc/mysql/YUsers.hxx62
-rw-r--r--connectivity/source/inc/mysql/YViews.hxx64
-rw-r--r--connectivity/source/inc/odbc/OBoundParam.hxx222
-rw-r--r--connectivity/source/inc/odbc/OConnection.hxx160
-rw-r--r--connectivity/source/inc/odbc/ODatabaseMetaData.hxx224
-rw-r--r--connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx242
-rw-r--r--connectivity/source/inc/odbc/ODefs3.hxx92
-rw-r--r--connectivity/source/inc/odbc/ODriver.hxx90
-rw-r--r--connectivity/source/inc/odbc/OFunctiondefs.hxx175
-rw-r--r--connectivity/source/inc/odbc/OFunctions.hxx556
-rw-r--r--connectivity/source/inc/odbc/OPreparedStatement.hxx171
-rw-r--r--connectivity/source/inc/odbc/OResultSet.hxx327
-rw-r--r--connectivity/source/inc/odbc/OResultSetMetaData.hxx126
-rw-r--r--connectivity/source/inc/odbc/OStatement.hxx248
-rw-r--r--connectivity/source/inc/odbc/OTools.hxx276
-rw-r--r--connectivity/source/inc/odbc/odbcbasedllapi.hxx40
-rw-r--r--connectivity/source/inc/propertyids.hxx159
-rw-r--r--connectivity/source/inc/resource/adabas_res.hrc43
-rw-r--r--connectivity/source/inc/resource/ado_res.hrc50
-rw-r--r--connectivity/source/inc/resource/calc_res.hrc41
-rw-r--r--connectivity/source/inc/resource/common_res.hrc78
-rw-r--r--connectivity/source/inc/resource/conn_shared_res.hrc73
-rw-r--r--connectivity/source/inc/resource/dbase_res.hrc61
-rw-r--r--connectivity/source/inc/resource/evoab2_res.hrc42
-rw-r--r--connectivity/source/inc/resource/file_res.hrc48
-rw-r--r--connectivity/source/inc/resource/hsqldb_res.hrc47
-rw-r--r--connectivity/source/inc/resource/jdbc_log.hrc90
-rw-r--r--connectivity/source/inc/resource/kab_res.hrc43
-rw-r--r--connectivity/source/inc/resource/macab_res.hrc41
-rw-r--r--connectivity/source/inc/resource/mozab_res.hrc74
-rw-r--r--connectivity/source/inc/resource/sharedresources.hxx164
-rw-r--r--connectivity/source/inc/sqlscan.hxx90
-rw-r--r--connectivity/source/manager/exports.dxp3
-rw-r--r--connectivity/source/manager/makefile.mk79
-rw-r--r--connectivity/source/manager/mdrivermanager.cxx741
-rw-r--r--connectivity/source/manager/mdrivermanager.hxx146
-rw-r--r--connectivity/source/manager/mregistration.cxx112
-rw-r--r--connectivity/source/manager/sdbc.mxp.map53
-rw-r--r--connectivity/source/parse/PColumn.cxx249
-rw-r--r--connectivity/source/parse/internalnode.cxx85
-rw-r--r--connectivity/source/parse/makefile.mk67
-rw-r--r--connectivity/source/parse/sqlbison.y4381
-rw-r--r--connectivity/source/parse/sqlflex.l809
-rw-r--r--connectivity/source/parse/sqliterator.cxx2247
-rw-r--r--connectivity/source/parse/sqlnode.cxx2826
-rw-r--r--connectivity/source/parse/wrap_sqlbison.cxx31
-rw-r--r--connectivity/source/parse/wrap_sqlflex.cxx35
-rw-r--r--connectivity/source/resource/conn_error_message.src99
-rw-r--r--connectivity/source/resource/conn_log_res.src312
-rw-r--r--connectivity/source/resource/conn_shared_res.src649
-rw-r--r--connectivity/source/resource/makefile.mk108
-rw-r--r--connectivity/source/resource/sharedresources.cxx242
-rw-r--r--connectivity/source/sdbcx/VCatalog.cxx241
-rw-r--r--connectivity/source/sdbcx/VCollection.cxx603
-rw-r--r--connectivity/source/sdbcx/VColumn.cxx229
-rw-r--r--connectivity/source/sdbcx/VDescriptor.cxx155
-rw-r--r--connectivity/source/sdbcx/VGroup.cxx183
-rw-r--r--connectivity/source/sdbcx/VIndex.cxx223
-rw-r--r--connectivity/source/sdbcx/VIndexColumn.cxx120
-rw-r--r--connectivity/source/sdbcx/VKey.cxx228
-rw-r--r--connectivity/source/sdbcx/VKeyColumn.cxx125
-rw-r--r--connectivity/source/sdbcx/VTable.cxx336
-rw-r--r--connectivity/source/sdbcx/VUser.cxx194
-rw-r--r--connectivity/source/sdbcx/VView.cxx150
-rw-r--r--connectivity/source/sdbcx/makefile.mk63
-rw-r--r--connectivity/source/simpledbt/charset_s.cxx73
-rw-r--r--connectivity/source/simpledbt/charset_s.hxx68
-rw-r--r--connectivity/source/simpledbt/dbtfactory.cxx114
-rw-r--r--connectivity/source/simpledbt/dbtfactory.hxx81
-rw-r--r--connectivity/source/simpledbt/makefile.mk53
-rw-r--r--connectivity/source/simpledbt/parsenode_s.cxx93
-rw-r--r--connectivity/source/simpledbt/parsenode_s.hxx81
-rw-r--r--connectivity/source/simpledbt/parser_s.cxx86
-rw-r--r--connectivity/source/simpledbt/parser_s.hxx74
-rw-r--r--connectivity/source/simpledbt/refbase.cxx64
-rw-r--r--connectivity/source/simpledbt/refbase.hxx61
-rw-r--r--connectivity/source/simpledbt/staticdbtools_s.cxx212
-rw-r--r--connectivity/source/simpledbt/staticdbtools_s.hxx207
-rwxr-xr-xconnectivity/target.pmk36
-rwxr-xr-xconnectivity/util/makefile.mk62
-rw-r--r--connectivity/version.mk119
-rw-r--r--connectivity/workben/TT/StartTest.classbin0 -> 183 bytes
-rw-r--r--connectivity/workben/TT/StartTest.java293
-rw-r--r--connectivity/workben/iniParser/main.cxx189
-rw-r--r--connectivity/workben/iniParser/makefile.mk62
-rw-r--r--connectivity/workben/little/main.cxx117
-rw-r--r--connectivity/workben/little/makefile.mk60
-rw-r--r--connectivity/workben/skeleton/SResultSet.hxx246
-rw-r--r--connectivity/workben/skeleton/how_to_write_a_driver.txt51
-rw-r--r--connectivity/workben/testmoz/initUNO.cxx45
-rw-r--r--connectivity/workben/testmoz/main.cxx724
-rw-r--r--connectivity/workben/testmoz/makefile.mk70
-rw-r--r--connectivity/workben/testmoz/mozthread.cxx477
900 files changed, 193546 insertions, 0 deletions
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/FileSystemRuntimeException.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/FileSystemRuntimeException.java
new file mode 100644
index 000000000000..af8bced79837
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/FileSystemRuntimeException.java
@@ -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.
+ *
+ ************************************************************************/
+
+
+// NOTE:
+// This class does not yet exist before 1.8.0.8. When we move our shipped
+// version to 1.8.0.8 or higher, this file here can be removed from CVS.
+
+package org.hsqldb.lib;
+
+/** is a RuntimeException which indicates failure during basic IO
+ * operations in a FileAccess implementation.
+ *
+ * @author frank.schoenheit@sun.com
+ *
+ * @version 1.8.0.8
+ * @since 1.8.0.8
+ */
+public class FileSystemRuntimeException extends java.lang.RuntimeException {
+
+ public static final int fileAccessRemoveElementFailed = 1;
+ public static final int fileAccessRenameElementFailed = 2;
+
+ private final int errorCode;
+
+ public FileSystemRuntimeException(int _errorCode) {
+ super();
+ errorCode = _errorCode;
+ }
+
+ public FileSystemRuntimeException(String _message, int _errorCode) {
+ super(_message);
+ errorCode = _errorCode;
+ }
+
+ public FileSystemRuntimeException(String _message, java.lang.Throwable _cause, int _errorCode) {
+ super(_message, _cause);
+ errorCode = _errorCode;
+ }
+
+ public FileSystemRuntimeException(java.lang.Throwable _cause, int _errorCode) {
+ super(_cause);
+ errorCode = _errorCode;
+ }
+
+ public final int getErrorCode() {
+ return errorCode;
+ }
+} \ No newline at end of file
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java
new file mode 100644
index 000000000000..fa14c7f5649a
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java
@@ -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.
+ *
+ ************************************************************************/
+ /*
+ * NativeInputStreamHelper.java
+ *
+ * Created on 9. September 2004, 11:51
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+/**
+ *
+ * @author Ocke
+ */
+public class NativeInputStreamHelper extends java.io.InputStream{
+ private String key;
+ private String file;
+ private StorageNativeInputStream in;
+ /** Creates a new instance of NativeInputStreamHelper */
+ public NativeInputStreamHelper(String key,String _file) {
+ file = _file;
+ this.key = key;
+ in = new StorageNativeInputStream(key,file);
+ }
+
+ public int read() throws java.io.IOException {
+ return in.read(key,file);
+ }
+
+ public int read(byte[] b, int off, int len) throws java.io.IOException {
+ return in.read(key,file,b,off,len);
+ }
+
+ public void close() throws java.io.IOException {
+ in.close(key,file);
+ }
+
+ public long skip(long n) throws java.io.IOException {
+ return in.skip(key,file,n);
+ }
+
+ public int available() throws java.io.IOException {
+ return in.available(key,file);
+ }
+
+ public int read(byte[] b) throws java.io.IOException {
+ return in.read(key,file,b);
+ }
+
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java
new file mode 100644
index 000000000000..451dc6b1e325
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java
@@ -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.
+ *
+ ************************************************************************/
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+final class NativeLibraries {
+ public static void load() {
+ if (System.getProperty( "os.name" ).startsWith("Windows")) {
+ loadLibrary("msvcr71");
+ loadLibrary("uwinapi");
+ loadLibrary("sal3");
+ loadLibrary("dbtoolsmi");
+ }
+ loadLibrary("hsqldb");
+ }
+
+ private static void loadLibrary(String libname) {
+ // At least on Mac OS X Tiger, System.loadLibrary("hsqldb2") does not
+ // find the hsqldb2 library one directory above sdbc_hsqldb.jar, even
+ // though ".." is on the jar's Class-Path; however, the alternative
+ // code (needing Java 1.5, which is given for Mac OS X Tiger) works
+ // there:
+ try {
+ System.loadLibrary(libname);
+ } catch (UnsatisfiedLinkError e) {
+ ClassLoader cl = NativeLibraries.class.getClassLoader();
+ if (cl instanceof URLClassLoader) {
+ URL url = ((URLClassLoader) cl).findResource(
+ System.mapLibraryName(libname));
+ if (url != null) {
+ try {
+ System.load(
+ ((File) File.class.getConstructor(
+ new Class[] {
+ ClassLoader.getSystemClassLoader().
+ loadClass("java.net.URI") }).
+ newInstance(
+ new Object[] {
+ URL.class.getMethod("toURI", new Class[0]).
+ invoke(url, (java.lang.Object[])null) })).
+ getAbsolutePath());
+ } catch (Throwable t) {
+ throw new UnsatisfiedLinkError(
+ e.toString()+ " - " + t.toString());
+ }
+ }
+ }
+ }
+ }
+
+ private NativeLibraries() {}
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java
new file mode 100644
index 000000000000..cc4faaa3cedf
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java
@@ -0,0 +1,48 @@
+/*
+ * NativeOutputStreamHelper.java
+ *
+ * Created on 1. September 2004, 10:39
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+/**
+ *
+ * @author oj93728
+ */
+public class NativeOutputStreamHelper extends java.io.OutputStream{
+
+ private String key;
+ private String file;
+ private StorageNativeOutputStream out;
+ /** Creates a new instance of NativeOutputStreamHelper */
+ public NativeOutputStreamHelper(String key,String _file) {
+ file = _file;
+ this.key = key;
+ out = new StorageNativeOutputStream(file,key);
+ }
+
+ public void write(byte[] b, int off, int len) throws java.io.IOException{
+ out.write(key,file,b, off, len);
+ }
+
+ public void write(byte[] b) throws java.io.IOException{
+ out.write(key,file,b);
+ }
+
+ public void close() throws java.io.IOException{
+ out.close(key,file);
+ }
+
+ public void write(int b) throws java.io.IOException{
+ out.write(key,file,b);
+ }
+
+ public void flush() throws java.io.IOException{
+ out.flush(key,file);
+ }
+
+ public void sync() throws java.io.IOException{
+ out.sync(key,file);
+ }
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java
new file mode 100644
index 000000000000..276119e947b6
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java
@@ -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.
+ *
+ ************************************************************************/
+/*
+ * StorageAccess.java
+ *
+ * Created on 17. August 2004, 13:32
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+/**
+ *
+ * @author oj93728
+ */
+
+public class NativeStorageAccess {
+ static { NativeLibraries.load(); }
+
+ public static final int READ = 1;
+ public static final int SEEKABLE = 2;
+ public static final int SEEKABLEREAD = 3;
+ public static final int WRITE = 4;
+ public static final int READWRITE = 7;
+ public static final int TRUNCATE = 8;
+
+ /** Creates a new instance of StorageAccess */
+ public NativeStorageAccess(String name,String _mode,Object key) throws java.io.IOException{
+ try {
+ int mode = NativeStorageAccess.SEEKABLEREAD;
+ if ( _mode.equals("rw") )
+ mode = NativeStorageAccess.READWRITE | NativeStorageAccess.SEEKABLE;
+
+ openStream(name, (String)key, mode);
+ } catch(Exception e){
+ throw new java.io.IOException();
+ }
+ }
+ public native void openStream(String name,String key, int mode);
+ public native void close(String name,String key) throws java.io.IOException;
+
+ public native long getFilePointer(String name,String key) throws java.io.IOException;
+
+ public native long length(String name,String key) throws java.io.IOException;
+
+ public native int read(String name,String key) throws java.io.IOException;
+
+ public native int read(String name,String key,byte[] b, int off, int len) throws java.io.IOException;
+
+ public native int readInt(String name,String key) throws java.io.IOException;
+
+ public native void seek(String name,String key,long position) throws java.io.IOException;
+
+ public native void write(String name,String key,byte[] b, int offset, int length) throws java.io.IOException;
+
+ public native void writeInt(String name,String key,int v) throws java.io.IOException;
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java
new file mode 100644
index 000000000000..9471275e7e44
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java
@@ -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.
+ *
+ ************************************************************************/
+/*
+ * StorageAccess.java
+ *
+ * Created on 17. August 2004, 13:32
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+/**
+ *
+ * @author oj93728
+ */
+
+public class StorageAccess implements org.hsqldb.lib.Storage {
+ String key;
+ String name;
+ boolean readonly;
+ NativeStorageAccess access;
+// public SimpleLog appLog;
+ /** Creates a new instance of StorageAccess */
+ public StorageAccess(String name,Boolean readonly,Object key) throws java.io.IOException{
+ this.key = (String)key;
+ this.name = name;
+ this.readonly = readonly.booleanValue();
+ try {
+ access = new NativeStorageAccess(name,
+ this.readonly ? "r" : "rw"
+ ,key);
+ } catch(Exception e){
+ throw new java.io.IOException();
+ }
+ // appLog = new SimpleLog(name +".app3.log", true);
+ }
+ public void close() throws java.io.IOException{
+ //appLog.sendLine("NIOScaledRAFile.close() ");
+ //appLog.close();
+ access.close(name,key);
+ }
+
+ public long getFilePointer() throws java.io.IOException{
+ //appLog.sendLine("NIOScaledRAFile.getFilePointer() ");
+ return access.getFilePointer(name,key);
+ }
+
+ public long length() throws java.io.IOException{
+ //appLog.sendLine("NIOScaledRAFile.length() ");
+ return access.length(name,key);
+ }
+
+ public int read() throws java.io.IOException{
+ //appLog.sendLine("NIOScaledRAFile.read() ");
+ return access.read(name,key);
+ }
+
+ public void read(byte[] b, int off, int len) throws java.io.IOException{
+ //appLog.sendLine("NIOScaledRAFile.read(" + b + ","+ off +","+len + ") ");
+ access.read(name,key,b,off,len);
+ }
+
+ // fredt - this is based on the same code that reads an int from the .data file in HSQLDB
+ public int readInt() throws java.io.IOException{
+ //appLog.sendLine("NIOScaledRAFile.readInt() ");
+ byte [] tmp = new byte [4];
+
+ int count = access.read(name,key,tmp,0, 4);
+
+ if (count != 4){
+ throw new java.io.IOException();
+ }
+
+ count = 0;
+ int ch0 = tmp[count++] & 0xff;
+ int ch1 = tmp[count++] & 0xff;
+ int ch2 = tmp[count++] & 0xff;
+ int ch3 = tmp[count] & 0xff;
+
+ return ((ch0 << 24) + (ch1 << 16) + (ch2 << 8) + (ch3));
+
+/*
+ int ch [] = new int[4];
+ for(int i = 0;i < 4; ++i){
+ ch[i] = tmp[i];
+ if (ch[i] < 0 ){
+ ch[i] = 256 + ch[i];
+ }
+ }
+
+ if ((ch[0] | ch[1] | ch[2] | ch[3]) < 0)
+ throw new java.io.IOException();
+ return ((ch[0] << 24) + (ch[1] << 16) + (ch[2] << 8) + (ch[3] << 0));
+ //return access.readInt(name,key);
+*/
+ }
+
+ public void seek(long position) throws java.io.IOException{
+ //appLog.sendLine("NIOScaledRAFile.seek("+position +") ");
+ access.seek(name,key,position);
+ }
+
+ public void write(byte[] b, int offset, int length) throws java.io.IOException{
+ //appLog.sendLine("NIOScaledRAFile.write(" + b + "," + offset +","+length+") ");
+ access.write(name,key,b,offset,length);
+ }
+
+ public void writeInt(int v) throws java.io.IOException{
+ //appLog.sendLine("NIOScaledRAFile.writeInt(" +v+") ");
+ byte [] oneByte = new byte [4];
+ oneByte[0] = (byte) ((v >>> 24) & 0xFF);
+ oneByte[1] = (byte) ((v >>> 16) & 0xFF);
+ oneByte[2] = (byte) ((v >>> 8) & 0xFF);
+ oneByte[3] = (byte) ((v >>> 0) & 0xFF);
+
+ write(oneByte,0,4);
+ }
+
+ public boolean isReadOnly() {
+ return readonly;
+ }
+
+ // fredt - minor change of brackets
+ public long readLong() throws java.io.IOException {
+ // return ((long)(readInt()) << 32) + (readInt() & 0xFFFFFFFFL);
+ return (((long) readInt()) << 32) + (((long) readInt()) & 0xFFFFFFFFL);
+ }
+
+ public boolean wasNio() {
+ return false;
+ }
+
+ public void writeLong(long v) throws java.io.IOException {
+ //appLog.sendLine("NIOScaledRAFile.writeLong(" +v+") ");
+ byte [] oneByte = new byte [8];
+
+ oneByte[0] = (byte) ((v >>> 56) & 0xFF);
+ oneByte[1] = (byte) ((v >>> 48) & 0xFF);
+ oneByte[2] = (byte) ((v >>> 40) & 0xFF);
+ oneByte[3] = (byte) ((v >>> 32) & 0xFF);
+ oneByte[4] = (byte) ((v >>> 24) & 0xFF);
+ oneByte[5] = (byte) ((v >>> 16) & 0xFF);
+ oneByte[6] = (byte) ((v >>> 8) & 0xFF);
+ oneByte[7] = (byte) ((v >>> 0) & 0xFF);
+
+ write(oneByte,0,8);
+ }
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java
new file mode 100644
index 000000000000..4e24cd4c9385
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java
@@ -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.
+ *
+ ************************************************************************/
+/*
+ * StorageFileAccess.java
+ *
+ * Created on 31. August 2004, 11:56
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+import org.hsqldb.lib.FileAccess;
+import org.hsqldb.lib.FileSystemRuntimeException;
+
+/**
+ *
+ * @author oj93728
+ */
+public class StorageFileAccess implements org.hsqldb.lib.FileAccess{
+ static { NativeLibraries.load(); }
+
+ String ds_name;
+ String key;
+ /** Creates a new instance of StorageFileAccess */
+ public StorageFileAccess(Object key) throws java.lang.Exception{
+ this.key = (String)key;
+ }
+
+ public void createParentDirs(java.lang.String filename) {
+ }
+
+ public boolean isStreamElement(java.lang.String elementName) {
+ return isStreamElement(key,elementName);
+ }
+
+ public java.io.InputStream openInputStreamElement(java.lang.String streamName) throws java.io.IOException {
+ return new NativeInputStreamHelper(key,streamName);
+ }
+
+ public java.io.OutputStream openOutputStreamElement(java.lang.String streamName) throws java.io.IOException {
+ return new NativeOutputStreamHelper(key,streamName);
+ }
+
+ public void removeElement(java.lang.String filename) throws java.util.NoSuchElementException {
+ try {
+ if ( isStreamElement(key,filename) )
+ removeElement(key,filename);
+ } catch (java.io.IOException e) {
+ throw new FileSystemRuntimeException( e, FileSystemRuntimeException.fileAccessRemoveElementFailed );
+ }
+ }
+
+ public void renameElement(java.lang.String oldName, java.lang.String newName) throws java.util.NoSuchElementException {
+ try {
+ if ( isStreamElement(key,oldName) ){
+ removeElement(key,newName);
+ renameElement(key,oldName, newName);
+ }
+ } catch (java.io.IOException e) {
+ throw new FileSystemRuntimeException( e, FileSystemRuntimeException.fileAccessRenameElementFailed );
+ }
+ }
+
+ public class FileSync implements FileAccess.FileSync
+ {
+ NativeOutputStreamHelper os;
+ FileSync(NativeOutputStreamHelper _os) throws java.io.IOException
+ {
+ os = _os;
+ }
+ public void sync() throws java.io.IOException
+ {
+ os.sync();
+ }
+ }
+
+ public FileAccess.FileSync getFileSync(java.io.OutputStream os) throws java.io.IOException
+ {
+ return new FileSync((NativeOutputStreamHelper)os);
+ }
+
+ static native boolean isStreamElement(java.lang.String key,java.lang.String elementName);
+ static native void removeElement(java.lang.String key,java.lang.String filename) throws java.util.NoSuchElementException, java.io.IOException;
+ static native void renameElement(java.lang.String key,java.lang.String oldName, java.lang.String newName) throws java.util.NoSuchElementException, java.io.IOException;
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java
new file mode 100644
index 000000000000..2ac4d2dbede8
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java
@@ -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.
+ *
+ ************************************************************************/
+/*
+ * StorageNativeInputStream.java
+ *
+ * Created on 9. September 2004, 11:52
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+/**
+ *
+ * @author Ocke
+ */
+public class StorageNativeInputStream {
+ static { NativeLibraries.load(); }
+
+ /** Creates a new instance of StorageNativeInputStream */
+ public StorageNativeInputStream(String key,String _file) {
+ openStream(key,_file, NativeStorageAccess.READ);
+ }
+ public native void openStream(String key,String name, int mode);
+ public native int read(String key,String name) throws java.io.IOException;
+ public native int read(String key,String name,byte[] b, int off, int len) throws java.io.IOException;
+ public native void close(String key,String name) throws java.io.IOException;
+ public native long skip(String key,String name,long n) throws java.io.IOException;
+ public native int available(String key,String name) throws java.io.IOException;
+ public native int read(String key,String name,byte[] b) throws java.io.IOException;
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java
new file mode 100644
index 000000000000..6b9a4db50153
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java
@@ -0,0 +1,143 @@
+/*
+ * StorageNativeOutputStream.java
+ *
+ * Created on 1. September 2004, 10:20
+ */
+
+package com.sun.star.sdbcx.comp.hsqldb;
+
+/**
+ *
+ * @author oj93728
+ */
+public class StorageNativeOutputStream {
+ static { NativeLibraries.load(); }
+
+ String name;
+ Object key;
+
+ /** Creates a new instance of StorageNativeOutputStream */
+ public StorageNativeOutputStream(String _name,Object _key) {
+ name = _name;
+ key = _key;
+ openStream(name, (String)key, NativeStorageAccess.WRITE | NativeStorageAccess.TRUNCATE);
+ }
+
+ public native void openStream(String name,String key, int mode);
+ /**
+ * Writes <code>len</code> bytes from the specified byte array
+ * starting at offset <code>off</code> to this output stream.
+ * The general contract for <code>write(b, off, len)</code> is that
+ * some of the bytes in the array <code>b</code> are written to the
+ * output stream in order; element <code>b[off]</code> is the first
+ * byte written and <code>b[off+len-1]</code> is the last byte written
+ * by this operation.
+ * <p>
+ * The <code>write</code> method of <code>OutputStream</code> calls
+ * the write method of one argument on each of the bytes to be
+ * written out. Subclasses are encouraged to override this method and
+ * provide a more efficient implementation.
+ * <p>
+ * If <code>b</code> is <code>null</code>, a
+ * <code>NullPointerException</code> is thrown.
+ * <p>
+ * If <code>off</code> is negative, or <code>len</code> is negative, or
+ * <code>off+len</code> is greater than the length of the array
+ * <code>b</code>, then an <tt>IndexOutOfBoundsException</tt> is thrown.
+ * @param key The name of the data source.
+ * @param _file The name of the file to write to.
+ * @param b the data.
+ * @param off the start offset in the data.
+ * @param len the number of bytes to write.
+ * @exception IOException if an I/O error occurs. In particular,
+ * an <code>IOException</code> is thrown if the output
+ * stream is closed.
+ */
+ public native void write(String key,String _file,byte[] b, int off, int len) throws java.io.IOException;
+
+ /**
+ * Writes <code>b.length</code> bytes from the specified byte array
+ * to this output stream. The general contract for <code>write(b)</code>
+ * is that it should have exactly the same effect as the call
+ * <code>write(b, 0, b.length)</code>.
+ *
+ * @param b the data.
+ * @exception IOException if an I/O error occurs.
+ * @see java.io.OutputStream#write(byte[], int, int)
+ */
+ public native void write(String key,String _file,byte[] b) throws java.io.IOException;
+
+ /**
+ * Closes this output stream and releases any system resources
+ * associated with this stream. The general contract of <code>close</code>
+ * is that it closes the output stream. A closed stream cannot perform
+ * output operations and cannot be reopened.
+ * <p>
+ * The <code>close</code> method of <code>OutputStream</code> does nothing.
+ * @param key The name of the data source.
+ * @param _file The name of the file to write to.
+ *
+ * @exception IOException if an I/O error occurs.
+ */
+ public native void close(String key,String _file) throws java.io.IOException;
+
+ /**
+ * Writes the specified byte to this output stream. The general
+ * contract for <code>write</code> is that one byte is written
+ * to the output stream. The byte to be written is the eight
+ * low-order bits of the argument <code>b</code>. The 24
+ * high-order bits of <code>b</code> are ignored.
+ * <p>
+ * Subclasses of <code>OutputStream</code> must provide an
+ * implementation for this method.
+ *
+ * @param key The name of the data source.
+ * @param _file The name of the file to write to.
+ * @param b the <code>byte</code>.
+ * @exception IOException if an I/O error occurs. In particular,
+ * an <code>IOException</code> may be thrown if the
+ * output stream has been closed.
+ */
+ public native void write(String key,String _file,int b) throws java.io.IOException;
+
+ /**
+ * Flushes this output stream and forces any buffered output bytes
+ * to be written out. The general contract of <code>flush</code> is
+ * that calling it is an indication that, if any bytes previously
+ * written have been buffered by the implementation of the output
+ * stream, such bytes should immediately be written to their
+ * intended destination.
+ * <p>
+ * The <code>flush</code> method of <code>OutputStream</code> does nothing.
+ * @param key The name of the data source.
+ * @param _file The name of the file to write to.
+ *
+ * @exception IOException if an I/O error occurs.
+ */
+ public native void flush(String key,String _file) throws java.io.IOException;
+
+ /**
+ * Force all system buffers to synchronize with the underlying
+ * device. This method returns after all modified data and
+ * attributes have been written to the relevant device(s).
+ *
+ * sync is meant to be used by code that requires physical
+ * storage (such as a file) to be in a known state For
+ * example, a class that provided a simple transaction facility
+ * might use sync to ensure that all changes to a file caused
+ * by a given transaction were recorded on a storage medium.
+ *
+ * sync only affects buffers downstream. If
+ * any in-memory buffering is being done by the application (for
+ * example, by a BufferedOutputStream object), those buffers must
+ * be flushed (for example, by invoking
+ * OutputStream.flush) before that data will be affected by sync.
+ *
+ * @exception IOException
+ * Thrown when the buffers cannot be flushed,
+ * or because the system cannot guarantee that all the
+ * buffers have been synchronized with physical media.
+ */
+ public native void sync(String key,String _file) throws java.io.IOException;
+
+}
diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/makefile.mk b/connectivity/com/sun/star/sdbcx/comp/hsqldb/makefile.mk
new file mode 100644
index 000000000000..ce9581b93458
--- /dev/null
+++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/makefile.mk
@@ -0,0 +1,65 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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 = ..$/..$/..$/..$/..$/..
+PRJNAME = connectivity
+PACKAGE = com$/sun$/star$/sdbcx$/comp$/hsqldb
+TARGET = sdbc_hsqldb
+
+SECONDARY_PACKAGE = org$/hsqldb$/lib
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+# --- Files --------------------------------------------------------
+
+
+.IF "$(SYSTEM_HSQLDB)" == "YES"
+EXTRAJARFILES = $(HSQLDB_JAR)
+.ELSE
+JARFILES = hsqldb.jar
+.ENDIF
+
+JAVAFILES =\
+ NativeInputStreamHelper.java\
+ NativeOutputStreamHelper.java\
+ NativeStorageAccess.java\
+ StorageAccess.java\
+ StorageFileAccess.java\
+ StorageNativeInputStream.java\
+ StorageNativeOutputStream.java\
+ FileSystemRuntimeException.java\
+ NativeLibraries.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+JARCOMPRESS = TRUE
+JARCLASSDIRS = $(PACKAGE) $(SECONDARY_PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCLASSPATH = $(JARFILES) $(EXTRAJARFILES) ..
+
+# --- Targets ------------------------------------------------------
+.INCLUDE : target.mk
diff --git a/connectivity/dbtools.pmk b/connectivity/dbtools.pmk
new file mode 100644
index 000000000000..df102099323d
--- /dev/null
+++ b/connectivity/dbtools.pmk
@@ -0,0 +1,29 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+VISIBILITY_HIDDEN = TRUE
+CDEFS += -DOOO_DLLIMPLEMENTATION_DBTOOLS
diff --git a/connectivity/inc/connectivity/BlobHelper.hxx b/connectivity/inc/connectivity/BlobHelper.hxx
new file mode 100644
index 000000000000..3a16911524ab
--- /dev/null
+++ b/connectivity/inc/connectivity/BlobHelper.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_BLOBHELPER_HXX_
+#define _CONNECTIVITY_BLOBHELPER_HXX_
+
+#include "connectivity/dbtoolsdllapi.hxx"
+#include <com/sun/star/sdbc/XBlob.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+namespace connectivity
+{
+ class OOO_DLLPUBLIC_DBTOOLS BlobHelper : public ::cppu::WeakImplHelper1< com::sun::star::sdbc::XBlob >
+ {
+ ::com::sun::star::uno::Sequence< sal_Int8 > m_aValue;
+ public:
+ BlobHelper(const ::com::sun::star::uno::Sequence< sal_Int8 >& _val);
+ private:
+ virtual ::sal_Int64 SAL_CALL length( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getBytes( ::sal_Int64 pos, ::sal_Int32 length ) 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( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int64 SAL_CALL position( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& pattern, ::sal_Int64 start ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int64 SAL_CALL 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);
+ };
+}
+
+#endif //_CONNECTIVITY_BLOBHELPER_HXX_
+
diff --git a/connectivity/inc/connectivity/CommonTools.hxx b/connectivity/inc/connectivity/CommonTools.hxx
new file mode 100644
index 000000000000..c3409678f274
--- /dev/null
+++ b/connectivity/inc/connectivity/CommonTools.hxx
@@ -0,0 +1,216 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_COMMONTOOLS_HXX_
+#define _CONNECTIVITY_COMMONTOOLS_HXX_
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#ifndef _VECTOR_
+#include <vector>
+#endif
+#include <cppuhelper/weakref.hxx>
+#include <comphelper/stl_types.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <osl/interlck.h>
+#include <jvmaccess/virtualmachine.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace com { namespace sun { namespace star { namespace util {
+ struct Date;
+ struct DateTime;
+ struct Time;
+}
+}}}
+
+namespace connectivity
+{
+ //------------------------------------------------------------------------------
+ OOO_DLLPUBLIC_DBTOOLS sal_Bool match(const sal_Unicode* pWild, const sal_Unicode* pStr, const sal_Unicode cEscape);
+ //------------------------------------------------------------------------------
+ OOO_DLLPUBLIC_DBTOOLS rtl::OUString toString(const ::com::sun::star::uno::Any& rValue);
+ OOO_DLLPUBLIC_DBTOOLS rtl::OUString toDateString(const ::com::sun::star::util::Date& rDate);
+ OOO_DLLPUBLIC_DBTOOLS rtl::OUString toTimeString(const ::com::sun::star::util::Time& rTime);
+ OOO_DLLPUBLIC_DBTOOLS rtl::OUString toDateTimeString(const ::com::sun::star::util::DateTime& rDateTime);
+
+ // typedefs
+ typedef std::vector< ::com::sun::star::uno::WeakReferenceHelper > OWeakRefArray;
+ typedef ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier> OSQLTable;
+
+ DECLARE_STL_MAP(::rtl::OUString,OSQLTable,comphelper::UStringMixLess, OSQLTables);
+
+ // -------------------------------------------------------------------------
+ // class ORefVector allows reference counting on a std::vector
+ // -------------------------------------------------------------------------
+ template< class VectorVal > class ORefVector
+ {
+ std::vector< VectorVal > m_vector;
+ oslInterlockedCount m_refCount;
+ // ORefVector(const ORefVector&);
+ // ORefVector& operator=(const ORefVector&);
+
+ protected:
+ virtual ~ORefVector(){}
+ public:
+ typedef std::vector< VectorVal > Vector;
+
+ ORefVector() : m_refCount(0) {}
+ ORefVector(size_t _st) : m_vector(_st) , m_refCount(0) {}
+ ORefVector(const ORefVector& _rRH) : m_vector(_rRH.m_vector),m_refCount(0)
+ {
+ }
+ ORefVector& operator=(const ORefVector& _rRH)
+ {
+ if ( &_rRH != this )
+ {
+ m_vector = _rRH.m_vector;
+ }
+ return *this;
+ }
+
+ std::vector< VectorVal > & get() { return m_vector; }
+ std::vector< VectorVal > const & get() const { return m_vector; }
+
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () )
+ { return pMem; }
+ inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () )
+ {}
+
+ void acquire()
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ }
+ void release()
+ {
+ if (! osl_decrementInterlockedCount( &m_refCount ))
+ delete this;
+ }
+
+ };
+ // -------------------------------------------------------------------------
+ // class ORowVector incudes refcounting and initialze himself
+ // with at least one element. This first element is reserved for
+ // the bookmark
+ // -------------------------------------------------------------------------
+ template< class VectorVal > class ORowVector : public ORefVector< VectorVal >
+ {
+ public:
+ ORowVector() : ORefVector< VectorVal >(1){}
+ ORowVector(size_t _st) : ORefVector< VectorVal >(_st+1)
+ {}
+ };
+
+ typedef ORefVector< ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> > OSQLColumns;
+
+ // =======================================================================================
+ // search from __first to __last the column with the name _rVal
+ // when no such column exist __last is returned
+ OOO_DLLPUBLIC_DBTOOLS
+ OSQLColumns::Vector::const_iterator find( OSQLColumns::Vector::const_iterator __first,
+ OSQLColumns::Vector::const_iterator __last,
+ const ::rtl::OUString& _rVal,
+ const ::comphelper::UStringMixEqual& _rCase);
+ // =======================================================================================
+ // search from __first to __last the column with the realname _rVal
+ // when no such column exist __last is returned
+ OOO_DLLPUBLIC_DBTOOLS
+ OSQLColumns::Vector::const_iterator findRealName( OSQLColumns::Vector::const_iterator __first,
+ OSQLColumns::Vector::const_iterator __last,
+ const ::rtl::OUString& _rVal,
+ const ::comphelper::UStringMixEqual& _rCase);
+
+ // =======================================================================================
+ // the first two find methods are much faster than the one below
+ // =======================================================================================
+ // search from __first to __last the column with the property _rProp equals the value _rVal
+ // when no such column exist __last is returned
+ OOO_DLLPUBLIC_DBTOOLS
+ OSQLColumns::Vector::const_iterator find( OSQLColumns::Vector::const_iterator __first,
+ OSQLColumns::Vector::const_iterator __last,
+ const ::rtl::OUString& _rProp,
+ const ::rtl::OUString& _rVal,
+ const ::comphelper::UStringMixEqual& _rCase);
+
+ OOO_DLLPUBLIC_DBTOOLS void checkDisposed(sal_Bool _bThrow) throw ( ::com::sun::star::lang::DisposedException );
+
+
+ /** creates a java virtual machine
+ @param _rxFactory
+ The ORB.
+ @return
+ The JavaVM.
+ */
+ OOO_DLLPUBLIC_DBTOOLS ::rtl::Reference< jvmaccess::VirtualMachine > getJavaVM(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+
+ /** return <TRUE/> if the java class exists, otherwise <FALSE/>.
+ @param _pJVM
+ The JavaVM.
+ @param _sClassName
+ The class name to look for.
+ */
+ OOO_DLLPUBLIC_DBTOOLS sal_Bool existsJavaClassByName( const ::rtl::Reference< jvmaccess::VirtualMachine >& _pJVM,const ::rtl::OUString& _sClassName );
+}
+
+//==================================================================================
+
+#define DECLARE_SERVICE_INFO() \
+ 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) \
+
+#define IMPLEMENT_SERVICE_INFO(classname, implasciiname, serviceasciiname) \
+ ::rtl::OUString SAL_CALL classname::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ return ::rtl::OUString::createFromAscii(implasciiname); \
+ } \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL classname::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1); \
+ aSupported[0] = ::rtl::OUString::createFromAscii(serviceasciiname); \
+ return aSupported; \
+ } \
+ sal_Bool SAL_CALL classname::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; \
+ } \
+
+//==================================================================================
+
+#endif // _CONNECTIVITY_COMMONTOOLS_HXX_
+
diff --git a/connectivity/inc/connectivity/ConnectionWrapper.hxx b/connectivity/inc/connectivity/ConnectionWrapper.hxx
new file mode 100644
index 000000000000..56c61cb827f2
--- /dev/null
+++ b/connectivity/inc/connectivity/ConnectionWrapper.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_ZCONNECTIONWRAPPER_HXX_
+#define _CONNECTIVITY_ZCONNECTIONWRAPPER_HXX_
+
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <comphelper/broadcasthelper.hxx>
+#include "connectivity/CommonTools.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+
+ //==========================================================================
+ //= OConnectionWrapper - wraps all methods to the real connection from the driver
+ //= but when disposed it doesn't dispose the real connection
+ //==========================================================================
+ typedef ::cppu::ImplHelper2< ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::lang::XUnoTunnel
+ > OConnection_BASE;
+
+ class OOO_DLLPUBLIC_DBTOOLS OConnectionWrapper : public OConnection_BASE
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > m_xProxyConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider > m_xTypeProvider;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > m_xUnoTunnel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo > m_xServiceInfo;
+
+ virtual ~OConnectionWrapper();
+ void setDelegation(::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >& _rxProxyConnection,oslInterlockedCount& _rRefCount);
+ void setDelegation(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _xORB
+ ,oslInterlockedCount& _rRefCount);
+ // must be called from derived classes
+ void disposing();
+ public:
+ OConnectionWrapper( );
+
+ // XServiceInfo
+ 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 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // 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();
+ /** method to create unique ids
+ @param _rURL
+ The URL.
+ @param _rInfo
+ The info property of the datasource. It will be resorted if needed.
+ @param _pBuffer
+ Here we store the digest. Must not NULL.
+ @param _rUserName
+ The user name.
+ @param _rPassword
+ The password.
+ */
+ static void createUniqueId( const ::rtl::OUString& _rURL
+ ,::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo
+ ,sal_uInt8* _pBuffer
+ ,const ::rtl::OUString& _rUserName = ::rtl::OUString()
+ ,const ::rtl::OUString& _rPassword = ::rtl::OUString());
+ };
+}
+#endif // _CONNECTIVITY_ZCONNECTIONWRAPPER_HXX_
+
diff --git a/connectivity/inc/connectivity/DateConversion.hxx b/connectivity/inc/connectivity/DateConversion.hxx
new file mode 100644
index 000000000000..4c1f668fa107
--- /dev/null
+++ b/connectivity/inc/connectivity/DateConversion.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_DATECONVERSION_HXX_
+#define _CONNECTIVITY_DATECONVERSION_HXX_
+
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ class OOO_DLLPUBLIC_DBTOOLS DateConversion
+ {
+ public:
+ static sal_Int32 toINT32(const ::com::sun::star::util::Date&)
+ {
+ OSL_ENSURE(0,"Please use DBConversion instead!");
+ return 0;
+ }
+ static sal_Int32 toINT32(const ::com::sun::star::util::Time&)
+ {
+ OSL_ENSURE(0,"Please use DBConversion instead!");
+ return 0;
+ }
+ static sal_Int64 toINT64(const ::com::sun::star::util::DateTime&)
+ {
+ OSL_ENSURE(0,"Please use DBConversion instead!");
+ return 0;
+ }
+ static sal_Int32 getMsFromTime(const ::com::sun::star::util::Time&)
+ {
+ OSL_ENSURE(0,"Please use DBConversion instead!");
+ return 0;
+ }
+ static double toDouble(const ::com::sun::star::util::Date&)
+ {
+ OSL_ENSURE(0,"Please use DBConversion instead!");
+ return 0;
+ }
+ static double toDouble(const ::com::sun::star::util::Time&)
+ {
+ OSL_ENSURE(0,"Please use DBConversion instead!");
+ return 0;
+ }
+ static double toDouble(const ::com::sun::star::util::DateTime&)
+ {
+ OSL_ENSURE(0,"Please use DBConversion instead!");
+ return 0;
+ }
+ static ::com::sun::star::util::Date toDate(double,const ::com::sun::star::util::Date& =::com::sun::star::util::Date(01,01,1900))
+ {
+ OSL_ENSURE(0,"Please use DBConversion instead!");
+ return ::com::sun::star::util::Date();
+ }
+ static ::com::sun::star::util::Time toTime(double)
+ {
+ OSL_ENSURE(0,"Please use DBConversion instead!");
+ return ::com::sun::star::util::Time();
+ }
+ static ::com::sun::star::util::DateTime toDateTime(double,const ::com::sun::star::util::Date& =::com::sun::star::util::Date(01,01,1900))
+ {
+ OSL_ENSURE(0,"Please use DBConversion instead!");
+ return ::com::sun::star::util::DateTime();
+ }
+ };
+}
+#endif // _CONNECTIVITY_DATECONVERSION_HXX_
+
diff --git a/connectivity/inc/connectivity/DriversConfig.hxx b/connectivity/inc/connectivity/DriversConfig.hxx
new file mode 100755
index 000000000000..94ca201e5ad5
--- /dev/null
+++ b/connectivity/inc/connectivity/DriversConfig.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_DRIVERSCONFIG_HXX_INCLUDED
+#define CONNECTIVITY_DRIVERSCONFIG_HXX_INCLUDED
+
+#include <comphelper/stl_types.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/uno/Sequence.h>
+#include "connectivity/dbtoolsdllapi.hxx"
+#include <salhelper/singletonref.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <unotools/confignode.hxx>
+
+namespace connectivity
+{
+ typedef struct
+ {
+ ::comphelper::NamedValueCollection aProperties;
+ ::comphelper::NamedValueCollection aFeatures;
+ ::comphelper::NamedValueCollection aMetaData;
+ ::rtl::OUString sDriverFactory;
+ ::rtl::OUString sDriverTypeDisplayName;
+ } TInstalledDriver;
+ DECLARE_STL_USTRINGACCESS_MAP( TInstalledDriver, TInstalledDrivers);
+
+ class DriversConfigImpl
+ {
+ mutable ::utl::OConfigurationTreeRoot m_aInstalled;
+ mutable TInstalledDrivers m_aDrivers;
+ void Load(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB) const;
+ public:
+ DriversConfigImpl();
+
+ const TInstalledDrivers& getInstalledDrivers(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB) const { Load(_rxORB); return m_aDrivers; }
+ };
+ //
+ // Allows to access all driver which are located in the configuration
+ //
+ class OOO_DLLPUBLIC_DBTOOLS DriversConfig
+ {
+ typedef salhelper::SingletonRef<DriversConfigImpl> OSharedConfigNode;
+
+ const ::comphelper::NamedValueCollection& impl_get(const ::rtl::OUString& _sURL,sal_Int32 _nProps) const;
+ public:
+ DriversConfig(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+ ~DriversConfig();
+
+ DriversConfig( const DriversConfig& );
+ DriversConfig& operator=( const DriversConfig& );
+
+ ::rtl::OUString getDriverFactoryName(const ::rtl::OUString& _sUrl) const;
+ ::rtl::OUString getDriverTypeDisplayName(const ::rtl::OUString& _sUrl) const;
+ const ::comphelper::NamedValueCollection& getProperties(const ::rtl::OUString& _sURL) const;
+ const ::comphelper::NamedValueCollection& getFeatures(const ::rtl::OUString& _sURL) const;
+ const ::comphelper::NamedValueCollection& getMetaData(const ::rtl::OUString& _sURL) const;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > getURLs() const;
+ private:
+ OSharedConfigNode m_aNode;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
+ };
+}
+#endif // CONNECTIVITY_DRIVERSCONFIG_HXX_INCLUDED
diff --git a/connectivity/inc/connectivity/FValue.hxx b/connectivity/inc/connectivity/FValue.hxx
new file mode 100644
index 000000000000..e4fe1b64e626
--- /dev/null
+++ b/connectivity/inc/connectivity/FValue.hxx
@@ -0,0 +1,467 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_FILE_VALUE_HXX_
+#define _CONNECTIVITY_FILE_VALUE_HXX_
+
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <rtl/ustring.hxx>
+#include <osl/diagnose.h>
+#include <comphelper/stl_types.hxx>
+#include <vos/ref.hxx>
+#include "connectivity/dbtoolsdllapi.hxx"
+#include "connectivity/CommonTools.hxx"
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdb/XColumn.hpp>
+
+namespace connectivity
+{
+ namespace detail
+ {
+ class IValueSource;
+ }
+
+ class OOO_DLLPUBLIC_DBTOOLS ORowSetValue
+ {
+ union
+ {
+ sal_Bool m_bBool;
+ sal_Int8 m_nInt8;
+ sal_Int16 m_nInt16;
+ sal_Int32 m_nInt32;
+ rtl_uString* m_pString;
+
+ void* m_pValue; // can contains double, etc
+ } m_aValue;
+
+ sal_Int32 m_eTypeKind; // the database type
+ sal_Bool m_bNull : 1; // value is null
+ sal_Bool m_bBound : 1; // is bound
+ sal_Bool m_bModified : 1; // value was changed
+ sal_Bool m_bSigned : 1; // value is signed
+
+ void free();
+
+ public:
+ ORowSetValue()
+ :m_eTypeKind(::com::sun::star::sdbc::DataType::VARCHAR)
+ ,m_bNull(sal_True)
+ ,m_bBound(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bSigned(sal_True)
+ {
+ m_aValue.m_pString = NULL;
+ }
+
+ ORowSetValue(const ORowSetValue& _rRH)
+ :m_eTypeKind(::com::sun::star::sdbc::DataType::VARCHAR)
+ ,m_bNull(sal_True)
+ ,m_bBound(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bSigned(sal_True)
+ {
+ m_aValue.m_pString = NULL;
+ operator=(_rRH);
+ }
+
+ ORowSetValue(const ::rtl::OUString& _rRH)
+ :m_eTypeKind(::com::sun::star::sdbc::DataType::VARCHAR)
+ ,m_bNull(sal_True)
+ ,m_bBound(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bSigned(sal_True)
+ {
+ m_aValue.m_pString = NULL;
+ operator=(_rRH);
+ }
+
+ ORowSetValue(const double& _rRH)
+ :m_eTypeKind(::com::sun::star::sdbc::DataType::DOUBLE)
+ ,m_bNull(sal_True)
+ ,m_bBound(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bSigned(sal_True)
+ {
+ m_aValue.m_pString = NULL;
+ operator=(_rRH);
+ }
+
+ ORowSetValue(const float& _rRH)
+ :m_eTypeKind(::com::sun::star::sdbc::DataType::FLOAT)
+ ,m_bNull(sal_True)
+ ,m_bBound(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bSigned(sal_True)
+ {
+ m_aValue.m_pString = NULL;
+ operator=(_rRH);
+ }
+
+ ORowSetValue(const sal_Int8& _rRH)
+ :m_eTypeKind(::com::sun::star::sdbc::DataType::TINYINT)
+ ,m_bNull(sal_True)
+ ,m_bBound(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bSigned(sal_True)
+ {
+ m_aValue.m_pString = NULL;
+ operator=(_rRH);
+ }
+ ORowSetValue(const sal_Int16& _rRH)
+ :m_eTypeKind(::com::sun::star::sdbc::DataType::SMALLINT)
+ ,m_bNull(sal_True)
+ ,m_bBound(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bSigned(sal_True)
+ {
+ m_aValue.m_pString = NULL;
+ operator=(_rRH);
+ }
+ ORowSetValue(const sal_Int32& _rRH)
+ :m_eTypeKind(::com::sun::star::sdbc::DataType::INTEGER)
+ ,m_bNull(sal_True)
+ ,m_bBound(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bSigned(sal_True)
+ {
+ m_aValue.m_pString = NULL;
+ operator=(_rRH);
+ }
+ ORowSetValue(const sal_Int64& _rRH)
+ :m_eTypeKind(::com::sun::star::sdbc::DataType::BIGINT)
+ ,m_bNull(sal_True)
+ ,m_bBound(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bSigned(sal_True)
+ {
+ m_aValue.m_pString = NULL;
+ operator=(_rRH);
+ }
+
+ ORowSetValue(const sal_Bool& _rRH)
+ :m_eTypeKind(::com::sun::star::sdbc::DataType::BIT)
+ ,m_bNull(sal_True)
+ ,m_bBound(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bSigned(sal_True)
+ {
+ m_aValue.m_pString = NULL;
+ operator=(_rRH);
+ }
+
+ ORowSetValue(const ::com::sun::star::util::Date& _rRH)
+ :m_eTypeKind(::com::sun::star::sdbc::DataType::DATE)
+ ,m_bNull(sal_True)
+ ,m_bBound(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bSigned(sal_True)
+ {
+ m_aValue.m_pString = NULL;
+ operator=(_rRH);
+ }
+
+ ORowSetValue(const ::com::sun::star::util::Time& _rRH)
+ :m_eTypeKind(::com::sun::star::sdbc::DataType::TIME)
+ ,m_bNull(sal_True)
+ ,m_bBound(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bSigned(sal_True)
+ {
+ m_aValue.m_pString = NULL;
+ operator=(_rRH);
+ }
+
+ ORowSetValue(const ::com::sun::star::util::DateTime& _rRH)
+ :m_eTypeKind(::com::sun::star::sdbc::DataType::TIMESTAMP)
+ ,m_bNull(sal_True)
+ ,m_bBound(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bSigned(sal_True)
+ {
+ m_aValue.m_pString = NULL;
+ operator=(_rRH);
+ }
+
+ ORowSetValue(const ::com::sun::star::uno::Sequence<sal_Int8>& _rRH)
+ :m_eTypeKind(::com::sun::star::sdbc::DataType::LONGVARBINARY)
+ ,m_bNull(sal_True)
+ ,m_bBound(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bSigned(sal_True)
+ {
+ m_aValue.m_pString = NULL;
+ operator=(_rRH);
+ }
+
+ ~ORowSetValue()
+ {
+ free();
+ }
+
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void * SAL_CALL operator new( size_t,void* _pHint ) SAL_THROW( () )
+ { return _pHint; }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ inline static void SAL_CALL operator delete( void *,void* ) SAL_THROW( () )
+ { }
+
+ ORowSetValue& operator=(const ORowSetValue& _rRH);
+
+ // simple types
+ ORowSetValue& operator=(const sal_Bool _rRH);
+ ORowSetValue& operator=(const sal_Int8& _rRH);
+ ORowSetValue& operator=(const sal_Int16& _rRH);
+ ORowSetValue& operator=(const sal_Int32& _rRH);
+ ORowSetValue& operator=(const sal_Int64& _rRH);
+ ORowSetValue& operator=(const double& _rRH);
+ ORowSetValue& operator=(const float& _rRH);
+
+ // ADT's
+ ORowSetValue& operator=(const ::com::sun::star::util::Date& _rRH);
+ ORowSetValue& operator=(const ::com::sun::star::util::Time& _rRH);
+ ORowSetValue& operator=(const ::com::sun::star::util::DateTime& _rRH);
+
+ ORowSetValue& operator=(const ::rtl::OUString& _rRH);
+ // the type isn't set it will be set to VARCHAR if the type is different change it
+ ORowSetValue& operator=(const ::com::sun::star::uno::Sequence<sal_Int8>& _rRH);
+ // we the possiblity to save a any for bookmarks
+ ORowSetValue& operator=(const ::com::sun::star::uno::Any& _rAny);
+
+ operator sal_Bool() const { return isNull() ? sal_False : getBool(); }
+ operator sal_Int8() const { return isNull() ? static_cast<sal_Int8>(0) : getInt8(); }
+ operator sal_Int16() const { return isNull() ? static_cast<sal_Int16>(0) : getInt16(); }
+ operator sal_Int32() const { return isNull() ? 0 : getInt32(); }
+ operator sal_Int64() const { return isNull() ? 0 : getLong(); }
+ operator float() const { return isNull() ? (float)0.0: getFloat(); }
+ operator double() const { return isNull() ? 0.0 : getDouble(); }
+
+ operator ::rtl::OUString() const
+ {
+ return isNull() ? ::rtl::OUString() : getString();
+ }
+
+ operator ::com::sun::star::util::Date() const
+ {
+ return isNull() ? ::com::sun::star::util::Date() : getDate();
+ }
+
+ operator ::com::sun::star::util::Time() const
+ {
+ return isNull() ? ::com::sun::star::util::Time() : getTime();
+ }
+
+ operator ::com::sun::star::util::DateTime() const
+ {
+ return isNull() ? ::com::sun::star::util::DateTime() : getDateTime();
+ }
+
+ operator ::com::sun::star::uno::Sequence<sal_Int8>() const
+ {
+ return isNull() ? ::com::sun::star::uno::Sequence<sal_Int8>() : getSequence();
+ }
+
+ bool operator==(const ORowSetValue& _rRH) const;
+ bool operator!=(const ORowSetValue& _rRH) const
+ {
+ return !( *this == _rRH );
+ }
+
+ sal_Bool isNull() const
+ {
+ return m_bNull;
+ }
+ void setNull()
+ {
+ free();
+ m_bNull = sal_True;
+ m_aValue.m_pString = NULL;
+ }
+
+ sal_Bool isBound() const { return m_bBound; }
+ void setBound(sal_Bool _bBound) { m_bBound = _bBound ? true : false; }
+
+ sal_Bool isModified() const { return m_bModified; }
+ void setModified(sal_Bool _bMod=sal_True){ m_bModified = _bMod ? true : false; }
+
+ sal_Bool isSigned() const { return m_bSigned; }
+ void setSigned(sal_Bool _bMod=sal_True);
+
+ sal_Int32 getTypeKind() const { return m_eTypeKind; }
+ void setTypeKind(sal_Int32 _eType);
+
+ // before calling one of this methods, be sure that the value is not null
+ void* getValue() const { OSL_ENSURE(m_bBound,"Value is not bound!");return m_aValue.m_pValue; }
+ sal_Bool getBool() const;
+ sal_Int8 getInt8() const;
+ sal_Int16 getInt16() const;
+ sal_Int32 getInt32() const;
+ sal_Int64 getLong() const;
+ double getDouble() const;
+ float getFloat() const;
+ // convert the double to the type _nDataType
+ void setFromDouble(const double& _rVal,sal_Int32 _nDatatype);
+
+ ::rtl::OUString getString() const; // makes a automatic conversion if type isn't a string
+ ::com::sun::star::util::Date getDate() const;
+ ::com::sun::star::util::Time getTime() const;
+ ::com::sun::star::util::DateTime getDateTime() const;
+ ::com::sun::star::uno::Sequence<sal_Int8> getSequence() const;
+ // only use for anys
+ ::com::sun::star::uno::Any getAny() const { return *(::com::sun::star::uno::Any*)m_aValue.m_pValue; }
+ ::com::sun::star::uno::Any makeAny() const;
+
+ /**
+ fetches a single value out of the row
+ @param _nPos the current column position
+ @param _nType the type of the current column
+ @param _xRow the row where to fetch the data from
+ */
+ void fill(sal_Int32 _nPos,
+ sal_Int32 _nType,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow>& _xRow);
+
+ /**
+ fetches a single value out of the row
+ @param _nPos the current column position
+ @param _nType the type of the current column
+ @param _bNullable if true then it will be checked if the result could be NULL, otherwise not.
+ @param _xRow the row where to fetch the data from
+ */
+ void fill(sal_Int32 _nPos,
+ sal_Int32 _nType,
+ sal_Bool _bNullable,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow>& _xRow);
+
+ void fill(const ::com::sun::star::uno::Any& _rValue);
+
+ void fill( const sal_Int32 _nType,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxColumn );
+
+ private:
+ void impl_fill( const sal_Int32 _nType, sal_Bool _bNullable, const detail::IValueSource& _rValueSource );
+ };
+
+ /// ORowSetValueDecorator decorates a ORowSetValue so the value is "refcounted"
+ class OOO_DLLPUBLIC_DBTOOLS ORowSetValueDecorator : public ::vos::OReference
+ {
+ ORowSetValue m_aValue; // my own value
+ public:
+ ORowSetValueDecorator(){m_aValue.setBound(sal_True);}
+ ORowSetValueDecorator(const ORowSetValue& _aValue) : m_aValue(_aValue){m_aValue.setBound(sal_True);}
+ ORowSetValueDecorator& operator=(const ORowSetValue& _aValue);
+
+ inline operator const ORowSetValue&() const { return m_aValue; }
+ inline bool operator ==( const ORowSetValue & _rRH ) { return m_aValue == _rRH; }
+ inline const ORowSetValue& getValue() const { return m_aValue; }
+ inline ORowSetValue& get() { return m_aValue; }
+ inline void setValue(const ORowSetValue& _aValue) { m_aValue = _aValue; }
+ inline void setNull() { m_aValue.setNull(); }
+ inline void setBound(sal_Bool _bBound ) { m_aValue.setBound(_bBound);}
+ inline sal_Bool isBound( ) const { return m_aValue.isBound();}
+ inline void setTypeKind(sal_Int32 _nType) { m_aValue.setTypeKind(_nType); }
+ inline void setModified(sal_Bool _bModified) { m_aValue.setModified(_bModified); }
+
+ };
+ typedef ::vos::ORef<ORowSetValueDecorator> ORowSetValueDecoratorRef;
+
+ // -------------------------------------------------------------------------
+ /// TSetBound is a unary_function to set the bound value with e.q. for_each call
+ struct OOO_DLLPUBLIC_DBTOOLS TSetBound : ::std::unary_function<ORowSetValue,void>
+ {
+ sal_Bool m_bBound;
+ TSetBound(sal_Bool _bBound) : m_bBound(_bBound){}
+ void operator()(ORowSetValue& _rValue) const { _rValue.setBound(m_bBound); }
+
+ };
+
+ // -------------------------------------------------------------------------
+ /// TSetBound is a unary_function to set the bound value with e.q. for_each call
+ struct OOO_DLLPUBLIC_DBTOOLS TSetRefBound : ::std::unary_function<ORowSetValueDecoratorRef,void>
+ {
+ sal_Bool m_bBound;
+ TSetRefBound(sal_Bool _bBound) : m_bBound(_bBound){}
+ void operator()(ORowSetValueDecoratorRef& _rValue) const { _rValue->setBound(m_bBound); }
+
+ };
+
+ // ----------------------------------------------------------------------------
+ // Vector for file based rows
+ // ----------------------------------------------------------------------------
+ template< class VectorVal > class ODeleteVector : public connectivity::ORowVector< VectorVal >
+ {
+ sal_Bool m_bDeleted;
+ public:
+ ODeleteVector() : connectivity::ORowVector< VectorVal >() ,m_bDeleted(sal_False) {}
+ ODeleteVector(size_t _st) : connectivity::ORowVector< VectorVal >(_st) ,m_bDeleted(sal_False) {}
+
+ sal_Bool isDeleted() const { return m_bDeleted; }
+ void setDeleted(sal_Bool _bDeleted) { m_bDeleted = _bDeleted; }
+ };
+
+ typedef ODeleteVector< ORowSetValue > OValueVector;
+
+ class OOO_DLLPUBLIC_DBTOOLS OValueRefVector : public ODeleteVector< ORowSetValueDecoratorRef >
+ {
+ public:
+ OValueRefVector(){}
+ OValueRefVector(size_t _st) : ODeleteVector< ORowSetValueDecoratorRef >(_st)
+ {
+ for(OValueRefVector::Vector::iterator aIter = get().begin() ; aIter != get().end() ;++aIter)
+ *aIter = new ORowSetValueDecorator;
+ }
+ };
+
+#define SQL_NO_PARAMETER (SAL_MAX_UINT32)
+ class OAssignValues : public OValueRefVector
+ {
+ ::std::vector<sal_Int32> m_nParameterIndexes;
+ public:
+ OAssignValues() : m_nParameterIndexes(1,SQL_NO_PARAMETER){}
+ OAssignValues(Vector::size_type n) : OValueRefVector(n),m_nParameterIndexes(n+1,SQL_NO_PARAMETER){}
+
+ void setParameterIndex(sal_Int32 _nId,sal_Int32 _nParameterIndex) { m_nParameterIndexes[_nId] = _nParameterIndex;}
+ sal_Int32 getParameterIndex(sal_Int32 _nId) const { return m_nParameterIndexes[_nId]; }
+ };
+
+ typedef ::vos::ORef< OAssignValues > ORefAssignValues;
+
+
+
+ typedef ::vos::ORef< OValueVector > OValueRow;
+ typedef ::vos::ORef< OValueRefVector > OValueRefRow;
+}
+
+#endif // #ifndef _CONNECTIVITY_FILE_VALUE_HXX_
+
+
diff --git a/connectivity/inc/connectivity/IParseContext.hxx b/connectivity/inc/connectivity/IParseContext.hxx
new file mode 100644
index 000000000000..03de6e924154
--- /dev/null
+++ b/connectivity/inc/connectivity/IParseContext.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_IPARSECONTEXT_HXX
+#define CONNECTIVITY_IPARSECONTEXT_HXX
+
+namespace connectivity { class OSQLParseNode; }
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/lang/Locale.hpp>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ //==========================================================================
+ //= IParseContext
+ //==========================================================================
+ class IParseContext
+ {
+ public:
+ enum ErrorCode
+ {
+ ERROR_NONE = 0,
+ ERROR_GENERAL, // "Syntax error in SQL expression"
+ ERROR_VALUE_NO_LIKE, // "The value #1 can not be used with LIKE."
+ ERROR_FIELD_NO_LIKE, // "LIKE can not be used with this field."
+ ERROR_INVALID_COMPARE, // "The entered criterion can not be compared with this field."
+ ERROR_INVALID_INT_COMPARE, // "The field can not be compared with a number."
+ ERROR_INVALID_DATE_COMPARE, // "The field can not be compared with a date."
+ ERROR_INVALID_REAL_COMPARE, // "The field can not be compared with a floating point number."
+ ERROR_INVALID_TABLE, // "The database does not contain a table named \"#\"."
+ ERROR_INVALID_TABLE_OR_QUERY, // "The database does contain neither a table nor a query named \"#\"."
+ ERROR_INVALID_COLUMN, // "The column \"#1\" is unknown in the table \"#2\"."
+ ERROR_INVALID_TABLE_EXIST, // "The database already contains a table or view with name \"#\"."
+ ERROR_INVALID_QUERY_EXIST // "The database already contains a query with name \"#\".";
+ };
+
+ enum InternationalKeyCode
+ {
+ KEY_NONE = 0,
+ KEY_LIKE,
+ KEY_NOT,
+ KEY_NULL,
+ KEY_TRUE,
+ KEY_FALSE,
+ KEY_IS,
+ KEY_BETWEEN,
+ KEY_OR,
+ KEY_AND,
+ KEY_AVG,
+ KEY_COUNT,
+ KEY_MAX,
+ KEY_MIN,
+ KEY_SUM,
+ KEY_EVERY,
+ KEY_ANY,
+ KEY_SOME,
+ KEY_STDDEV_POP,
+ KEY_STDDEV_SAMP,
+ KEY_VAR_SAMP,
+ KEY_VAR_POP,
+ KEY_COLLECT,
+ KEY_FUSION,
+ KEY_INTERSECTION
+ };
+
+ public:
+ // retrieves language specific error messages
+ virtual ::rtl::OUString getErrorMessage(ErrorCode _eCodes) const = 0;
+
+ // retrieves language specific keyword strings (only ASCII allowed)
+ virtual ::rtl::OString getIntlKeywordAscii(InternationalKeyCode _eKey) const = 0;
+
+ // finds out, if we have an international keyword (only ASCII allowed)
+ virtual InternationalKeyCode getIntlKeyCode(const ::rtl::OString& rToken) const = 0;
+
+ /** get's a locale instance which should be used when parsing in the context specified by this instance
+ <p>if this is not overridden by derived classes, it returns the static default locale.</p>
+ */
+ virtual ::com::sun::star::lang::Locale getPreferredLocale( ) const = 0;
+ };
+}
+
+#endif // CONNECTIVITY_IPARSECONTEXT_HXX
+
diff --git a/connectivity/inc/connectivity/PColumn.hxx b/connectivity/inc/connectivity/PColumn.hxx
new file mode 100644
index 000000000000..547cc8fb9970
--- /dev/null
+++ b/connectivity/inc/connectivity/PColumn.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef _CONNECTIVITY_PCOLUMN_HXX_
+#define _CONNECTIVITY_PCOLUMN_HXX_
+
+#include "connectivity/dbtoolsdllapi.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include "connectivity/CommonTools.hxx"
+#include <vos/ref.hxx>
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <comphelper/proparrhlp.hxx>
+
+namespace connectivity
+{
+ namespace parse
+ {
+ class OParseColumn;
+
+ typedef sdbcx::OColumn OParseColumn_BASE;
+ typedef ::comphelper::OPropertyArrayUsageHelper<OParseColumn> OParseColumn_PROP;
+
+ class OOO_DLLPUBLIC_DBTOOLS OParseColumn :
+ public OParseColumn_BASE, public OParseColumn_PROP
+ {
+ ::rtl::OUString m_aRealName;
+ ::rtl::OUString m_aTableName;
+ ::rtl::OUString m_sLabel;
+ sal_Bool m_bFunction;
+ sal_Bool m_bDbasePrecisionChanged;
+ sal_Bool m_bAggregateFunction;
+ sal_Bool m_bIsSearchable;
+
+ protected:
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ virtual ~OParseColumn();
+ public:
+ OParseColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn,sal_Bool _bCase);
+ OParseColumn(const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _TypeName,
+ const ::rtl::OUString& _DefaultValue,
+ const ::rtl::OUString& _Description,
+ sal_Int32 _IsNullable,
+ sal_Int32 _Precision,
+ sal_Int32 _Scale,
+ sal_Int32 _Type,
+ sal_Bool _IsAutoIncrement,
+ sal_Bool _IsCurrency,
+ sal_Bool _bCase);
+
+ virtual void construct();
+
+ void setRealName(const ::rtl::OUString& _rName) { m_aRealName = _rName; }
+ void setLabel(const ::rtl::OUString& i_sLabel) { m_sLabel = i_sLabel; }
+ void setTableName(const ::rtl::OUString& _rName) { m_aTableName = _rName; }
+ void setFunction(sal_Bool _bFunction) { m_bFunction = _bFunction; }
+ void setAggregateFunction(sal_Bool _bFunction) { m_bAggregateFunction = _bFunction; }
+ void setIsSearchable( sal_Bool _bIsSearchable ) { m_bIsSearchable = _bIsSearchable; }
+ void setDbasePrecisionChanged(sal_Bool _bDbasePrecisionChanged) { m_bDbasePrecisionChanged = _bDbasePrecisionChanged; }
+
+ ::rtl::OUString getRealName() const { return m_aRealName; }
+ ::rtl::OUString getLabel() const { return m_sLabel; }
+ ::rtl::OUString getTableName() const { return m_aTableName; }
+ sal_Bool getFunction() const { return m_bFunction; }
+ sal_Bool getDbasePrecisionChanged() const { return m_bDbasePrecisionChanged; }
+
+ public:
+ /** creates a collection of OParseColumn, as described by a result set meta data instance.
+ */
+ static ::vos::ORef< OSQLColumns >
+ createColumnsForResultSet(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData >& _rxResMetaData,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMetaData,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& i_xQueryColumns
+ );
+
+ DECLARE_STL_USTRINGACCESS_MAP(int,StringMap);
+ /** creates a single OParseColumn, as described by a result set meta data instance.
+ The column names are unique.
+ */
+ static OParseColumn*
+ createColumnForResultSet(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData >& _rxResMetaData,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxDBMetaData,
+ sal_Int32 _nColumnPos,
+ StringMap& _rColumns
+ );
+
+ private:
+ using OParseColumn_BASE::createArrayHelper;
+ };
+
+ class OOrderColumn;
+
+ typedef sdbcx::OColumn OOrderColumn_BASE;
+ typedef ::comphelper::OPropertyArrayUsageHelper<OOrderColumn> OOrderColumn_PROP;
+
+ class OOO_DLLPUBLIC_DBTOOLS OOrderColumn :
+ public OOrderColumn_BASE, public OOrderColumn_PROP
+ {
+ sal_Bool m_bAscending;
+ sal_Bool m_bOrder;
+ protected:
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ virtual ~OOrderColumn();
+ public:
+ OOrderColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn,sal_Bool _bCase,sal_Bool _bAscending);
+
+ virtual void construct();
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+ private:
+ using OOrderColumn_BASE::createArrayHelper;
+ };
+ }
+}
+
+#endif //_CONNECTIVITY_PCOLUMN_HXX_
+
diff --git a/connectivity/inc/connectivity/ParameterCont.hxx b/connectivity/inc/connectivity/ParameterCont.hxx
new file mode 100644
index 000000000000..f096a9a1a747
--- /dev/null
+++ b/connectivity/inc/connectivity/ParameterCont.hxx
@@ -0,0 +1,59 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_PARAMETERCONTINUATION_HXX_INCLUDED
+#define CONNECTIVITY_PARAMETERCONTINUATION_HXX_INCLUDED
+
+#include <com/sun/star/sdb/XInteractionSupplyParameters.hpp>
+#include <comphelper/interaction.hxx>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace dbtools
+{
+//====================================================================
+ //= OParameterContinuation
+ //====================================================================
+ class OOO_DLLPUBLIC_DBTOOLS OParameterContinuation : public comphelper::OInteraction< ::com::sun::star::sdb::XInteractionSupplyParameters >
+ {
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aValues;
+
+ public:
+ OParameterContinuation() { }
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > getValues() const { return m_aValues; }
+
+ // XInteractionSupplyParameters
+ virtual void SAL_CALL setParameters( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rValues ) throw(::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual ~OParameterContinuation() { }
+ private:
+ OParameterContinuation(const OParameterContinuation&);
+ void operator =(const OParameterContinuation&);
+ };
+} // dbtools
+#endif //CONNECTIVITY_PARAMETERCONTINUATION_HXX_INCLUDED
+
diff --git a/connectivity/inc/connectivity/SQLStatementHelper.hxx b/connectivity/inc/connectivity/SQLStatementHelper.hxx
new file mode 100644
index 000000000000..0d1bb97c7b7f
--- /dev/null
+++ b/connectivity/inc/connectivity/SQLStatementHelper.hxx
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dbtools.hxx,v $
+ * $Revision: 1.37 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_SQLSTATEMENTHELPER_HXX_
+#define _CONNECTIVITY_SQLSTATEMENTHELPER_HXX_
+
+#include "connectivity/dbtoolsdllapi.hxx"
+#include <com/sun/star/beans/XPropertySet.hpp>
+namespace rtl
+{
+ class OUStringBuffer;
+}
+//.........................................................................
+namespace dbtools
+{
+ class OOO_DLLPUBLIC_DBTOOLS ISQLStatementHelper
+ {
+ public:
+ virtual void addComment(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor,::rtl::OUStringBuffer& _rOut) = 0;
+ };
+
+//.........................................................................
+} // namespace dbtools
+//.........................................................................
+
+#endif // _CONNECTIVITY_SQLSTATEMENTHELPER_HXX_
+
diff --git a/connectivity/inc/connectivity/StdTypeDefs.hxx b/connectivity/inc/connectivity/StdTypeDefs.hxx
new file mode 100644
index 000000000000..7b3afaab70d7
--- /dev/null
+++ b/connectivity/inc/connectivity/StdTypeDefs.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_STDTYPEDEFS_HXX
+#define CONNECTIVITY_STDTYPEDEFS_HXX
+
+#include "sal/config.h"
+
+#include <map>
+#include <vector>
+#include "sal/types.h"
+
+namespace rtl { class OUString; }
+
+namespace connectivity
+{
+ typedef ::std::vector< ::rtl::OUString> TStringVector;
+ typedef ::std::vector< sal_Int32> TIntVector;
+ typedef ::std::map<sal_Int32,sal_Int32> TInt2IntMap;
+ typedef ::std::map< ::rtl::OUString,sal_Int32> TString2IntMap;
+ typedef ::std::map< sal_Int32,::rtl::OUString> TInt2StringMap;
+}
+
+#endif // CONNECTIVITY_STDTYPEDEFS_HXX
+
diff --git a/connectivity/inc/connectivity/TColumnsHelper.hxx b/connectivity/inc/connectivity/TColumnsHelper.hxx
new file mode 100644
index 000000000000..1343ff633fd2
--- /dev/null
+++ b/connectivity/inc/connectivity/TColumnsHelper.hxx
@@ -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 CONNECTIVITY_COLUMNSHELPER_HXX
+#define CONNECTIVITY_COLUMNSHELPER_HXX
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ class OTableHelper;
+ class OColumnsHelperImpl;
+ /** contains generell column handling to creat default columns and default sql statements.
+ */
+ class OOO_DLLPUBLIC_DBTOOLS OColumnsHelper : public sdbcx::OCollection
+ {
+ OColumnsHelperImpl* m_pImpl;
+ protected:
+ OTableHelper* m_pTable;
+
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ OColumnsHelper( ::cppu::OWeakObject& _rParent
+ ,sal_Bool _bCase
+ ,::osl::Mutex& _rMutex
+ ,const TStringVector &_rVector
+ ,sal_Bool _bUseHardRef = sal_True
+ );
+ virtual ~OColumnsHelper();
+
+ /** set the parent of the columns. Can also be <NULL/>.
+ @param _pTable
+ The parent.
+ */
+ inline void setParent(OTableHelper* _pTable) { m_pTable = _pTable;}
+ };
+}
+#endif // CONNECTIVITY_COLUMNSHELPER_HXX
+
diff --git a/connectivity/inc/connectivity/TIndex.hxx b/connectivity/inc/connectivity/TIndex.hxx
new file mode 100644
index 000000000000..c6537d2855fd
--- /dev/null
+++ b/connectivity/inc/connectivity/TIndex.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_INDEXHELPER_HXX_
+#define CONNECTIVITY_INDEXHELPER_HXX_
+
+#include "connectivity/dbtoolsdllapi.hxx"
+#include "connectivity/sdbcx/VIndex.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+
+namespace connectivity
+{
+ class OTableHelper;
+ class OOO_DLLPUBLIC_DBTOOLS OIndexHelper : public connectivity::sdbcx::OIndex
+ {
+ OTableHelper* m_pTable;
+ public:
+ virtual void refreshColumns();
+ public:
+ OIndexHelper( OTableHelper* _pTable);
+ OIndexHelper( OTableHelper* _pTable,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Catalog,
+ sal_Bool _isUnique,
+ sal_Bool _isPrimaryKeyIndex,
+ sal_Bool _isClustered
+ );
+ inline OTableHelper* getTable() const { return m_pTable; }
+ };
+}
+#endif // CONNECTIVITY_INDEXHELPER_HXX_
+
diff --git a/connectivity/inc/connectivity/TIndexColumns.hxx b/connectivity/inc/connectivity/TIndexColumns.hxx
new file mode 100644
index 000000000000..466363d61e02
--- /dev/null
+++ b/connectivity/inc/connectivity/TIndexColumns.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_INDEXCOLUMNSHELPER_HXX
+#define CONNECTIVITY_INDEXCOLUMNSHELPER_HXX
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ class OIndexHelper;
+ class OOO_DLLPUBLIC_DBTOOLS OIndexColumns : public sdbcx::OCollection
+ {
+ OIndexHelper* m_pIndex;
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ public:
+ OIndexColumns( OIndexHelper* _pIndex,
+ ::osl::Mutex& _rMutex,
+ const ::std::vector< ::rtl::OUString> &_rVector);
+ };
+}
+#endif // CONNECTIVITY_INDEXCOLUMNSHELPER_HXX
diff --git a/connectivity/inc/connectivity/TIndexes.hxx b/connectivity/inc/connectivity/TIndexes.hxx
new file mode 100644
index 000000000000..d0a2eec83741
--- /dev/null
+++ b/connectivity/inc/connectivity/TIndexes.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_INDEXESHELPER_HXX
+#define CONNECTIVITY_INDEXESHELPER_HXX
+
+#include "connectivity/dbtoolsdllapi.hxx"
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+
+namespace connectivity
+{
+ class OTableHelper;
+ class OOO_DLLPUBLIC_DBTOOLS OIndexesHelper : public sdbcx::OCollection
+ {
+ OTableHelper* m_pTable;
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ OIndexesHelper(OTableHelper* _pTable,
+ ::osl::Mutex& _rMutex,
+ const ::std::vector< ::rtl::OUString> &_rVector
+ );
+
+ };
+}
+
+#endif // CONNECTIVITY_INDEXESHELPER_HXX
+
diff --git a/connectivity/inc/connectivity/TKey.hxx b/connectivity/inc/connectivity/TKey.hxx
new file mode 100644
index 000000000000..e586524dcca0
--- /dev/null
+++ b/connectivity/inc/connectivity/TKey.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_TKEY_HXX
+#define CONNECTIVITY_TKEY_HXX
+
+#include "connectivity/dbtoolsdllapi.hxx"
+#include <connectivity/sdbcx/VKey.hxx>
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+
+namespace connectivity
+{
+ class OTableHelper;
+ class OOO_DLLPUBLIC_DBTOOLS OTableKeyHelper : public connectivity::sdbcx::OKey
+ {
+ OTableHelper* m_pTable;
+ public:
+ virtual void refreshColumns();
+ public:
+ OTableKeyHelper( OTableHelper* _pTable);
+ OTableKeyHelper( OTableHelper* _pTable
+ ,const ::rtl::OUString& _Name
+ ,const sdbcx::TKeyProperties& _rProps
+ );
+ inline OTableHelper* getTable() const { return m_pTable; }
+ };
+}
+#endif // CONNECTIVITY_TKEY_HXX
+
+
diff --git a/connectivity/inc/connectivity/TKeyColumns.hxx b/connectivity/inc/connectivity/TKeyColumns.hxx
new file mode 100644
index 000000000000..9328fd5af04e
--- /dev/null
+++ b/connectivity/inc/connectivity/TKeyColumns.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_TKEYCOLUMNS_HXX
+#define CONNECTIVITY_TKEYCOLUMNS_HXX
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include "connectivity/TKey.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ class OOO_DLLPUBLIC_DBTOOLS OKeyColumnsHelper : public connectivity::sdbcx::OCollection
+ {
+ OTableKeyHelper* m_pKey;
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ public:
+ OKeyColumnsHelper( OTableKeyHelper* _pKey,
+ ::osl::Mutex& _rMutex,
+ const ::std::vector< ::rtl::OUString> &_rVector);
+ };
+}
+#endif // CONNECTIVITY_TKEYCOLUMNS_HXX
diff --git a/connectivity/inc/connectivity/TKeys.hxx b/connectivity/inc/connectivity/TKeys.hxx
new file mode 100644
index 000000000000..8142dbcbe9df
--- /dev/null
+++ b/connectivity/inc/connectivity/TKeys.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_TKEYS_HXX
+#define CONNECTIVITY_TKEYS_HXX
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "connectivity/TTableHelper.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ typedef sdbcx::OCollection OKeys_BASE;
+ class OOO_DLLPUBLIC_DBTOOLS OKeysHelper : public OKeys_BASE
+ {
+ OTableHelper* m_pTable;
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+
+ virtual ::rtl::OUString getDropForeignKey() const;
+
+ public:
+ OKeysHelper( OTableHelper* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector& _rVector
+ );
+ inline OTableHelper* getTable() const { return m_pTable; }
+
+ static void cloneDescriptorColumns(
+ const sdbcx::ObjectType& _rSourceDescriptor,
+ const sdbcx::ObjectType& _rDestDescriptor
+ );
+ };
+}
+
+#endif // CONNECTIVITY_TKEYS_HXX
+
diff --git a/connectivity/inc/connectivity/TTableHelper.hxx b/connectivity/inc/connectivity/TTableHelper.hxx
new file mode 100644
index 000000000000..f99a106bce37
--- /dev/null
+++ b/connectivity/inc/connectivity/TTableHelper.hxx
@@ -0,0 +1,173 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_TABLEHELPER_HXX
+#define CONNECTIVITY_TABLEHELPER_HXX
+
+#include "connectivity/dbtoolsdllapi.hxx"
+#include "connectivity/sdbcx/VTable.hxx"
+#include "connectivity/sdbcx/VKey.hxx"
+#include "connectivity/StdTypeDefs.hxx"
+#include <comphelper/stl_types.hxx>
+#include <com/sun/star/sdb/tools/XTableRename.hpp>
+#include <com/sun/star/sdb/tools/XTableAlteration.hpp>
+#include <com/sun/star/sdb/tools/XKeyAlteration.hpp>
+#include <com/sun/star/sdb/tools/XIndexAlteration.hpp>
+
+namespace connectivity
+{
+ typedef sal_Int32 OrdinalPosition;
+ struct ColumnDesc
+ {
+ ::rtl::OUString sName;
+ ::rtl::OUString aField6;
+ ::rtl::OUString sField12; // REMARKS
+ ::rtl::OUString sField13;
+ sal_Int32 nField5
+ , nField7
+ , nField9
+ , nField11;
+
+ OrdinalPosition nOrdinalPosition;
+
+ ColumnDesc() {}
+ ColumnDesc( const ::rtl::OUString& _rName
+ , sal_Int32 _nField5
+ , const ::rtl::OUString& _aField6
+ , sal_Int32 _nField7
+ , sal_Int32 _nField9
+ , sal_Int32 _nField11
+ , const ::rtl::OUString& _sField12
+ , const ::rtl::OUString& _sField13
+ ,OrdinalPosition _nPosition )
+ :sName( _rName )
+ ,aField6(_aField6)
+ ,sField12(_sField12)
+ ,sField13(_sField13)
+ ,nField5(_nField5)
+ ,nField7(_nField7)
+ ,nField9(_nField9)
+ ,nField11(_nField11)
+ ,nOrdinalPosition( _nPosition )
+ {
+ }
+ };
+ typedef connectivity::sdbcx::OTable OTable_TYPEDEF;
+
+ OOO_DLLPUBLIC_DBTOOLS ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xColProp);
+
+ DECLARE_STL_USTRINGACCESS_MAP( sdbcx::TKeyProperties , TKeyMap);
+
+ struct OTableHelperImpl;
+
+ class OOO_DLLPUBLIC_DBTOOLS OTableHelper : public OTable_TYPEDEF
+ {
+ ::std::auto_ptr<OTableHelperImpl> m_pImpl;
+
+ void refreshPrimaryKeys(TStringVector& _rKeys);
+ void refreshForgeinKeys(TStringVector& _rKeys);
+
+ protected:
+ /** creates the column collection for the table
+ @param _rNames
+ The column names.
+ */
+ virtual sdbcx::OCollection* createColumns(const TStringVector& _rNames) = 0;
+
+ /** creates the key collection for the table
+ @param _rNames
+ The key names.
+ */
+ virtual sdbcx::OCollection* createKeys(const TStringVector& _rNames) = 0;
+
+ /** creates the index collection for the table
+ @param _rNames
+ The index names.
+ */
+ virtual sdbcx::OCollection* createIndexes(const TStringVector& _rNames) = 0;
+
+ /** this function is called upon disposing the component
+ */
+ virtual void SAL_CALL disposing();
+
+ /** The default returns "RENAME TABLE " or "RENAME VIEW " depending on the type.
+ *
+ * \return The start of the rename statement.
+ */
+ virtual ::rtl::OUString getRenameStart() const;
+
+ virtual ~OTableHelper();
+
+ public:
+ virtual void refreshColumns();
+ virtual void refreshKeys();
+ virtual void refreshIndexes();
+
+ const ColumnDesc* getColumnDescription(const ::rtl::OUString& _sName) const;
+
+ public:
+ OTableHelper( sdbcx::OCollection* _pTables,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
+ sal_Bool _bCase);
+ OTableHelper( sdbcx::OCollection* _pTables,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
+ sal_Bool _bCase,
+ 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()
+ );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection() const;
+
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XRename
+ virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+
+ // XAlterTable
+ virtual void SAL_CALL alterColumnByIndex( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ // XNamed
+ virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+
+ // helper method to get key properties
+ sdbcx::TKeyProperties getKeyProperties(const ::rtl::OUString& _sName) const;
+ void addKey(const ::rtl::OUString& _sName,const sdbcx::TKeyProperties& _aKeyProperties);
+
+ virtual ::rtl::OUString getTypeCreatePattern() const;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XTableRename> getRenameService() const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XTableAlteration> getAlterService() const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XKeyAlteration> getKeyService() const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XIndexAlteration> getIndexService() const;
+ };
+}
+#endif // CONNECTIVITY_TABLEHELPER_HXX
+
diff --git a/connectivity/inc/connectivity/conncleanup.hxx b/connectivity/inc/connectivity/conncleanup.hxx
new file mode 100644
index 000000000000..ee940f02e66d
--- /dev/null
+++ b/connectivity/inc/connectivity/conncleanup.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_CONNCLEANUP_HXX_
+#define _CONNECTIVITY_CONNCLEANUP_HXX_
+
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+//.........................................................................
+namespace dbtools
+{
+//.........................................................................
+
+ //=====================================================================
+ //= OAutoConnectionDisposer
+ //=====================================================================
+ typedef ::cppu::WeakImplHelper2 < ::com::sun::star::beans::XPropertyChangeListener,
+ ::com::sun::star::sdbc::XRowSetListener
+ > OAutoConnectionDisposer_Base;
+
+ class OOO_DLLPUBLIC_DBTOOLS OAutoConnectionDisposer : public OAutoConnectionDisposer_Base
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ m_xOriginalConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > m_xRowSet; // needed to add as listener
+ sal_Bool m_bRSListening : 1; // true when we're listening on rowset
+ sal_Bool m_bPropertyListening : 1; // true when we're listening for property changes
+
+ public:
+ /** constructs an object
+ <p>The connection given will be set on the rowset (as ActiveConnection), and the object adds itself as property
+ change listener for the connection. Once somebody sets a new ActiveConnection, the old one (the one given
+ here) will be disposed.</p>
+ */
+ OAutoConnectionDisposer(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& _rxRowSet,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
+ );
+
+ protected:
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XRowSetListener
+ virtual void SAL_CALL cursorMoved( const ::com::sun::star::lang::EventObject& event ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL rowChanged( const ::com::sun::star::lang::EventObject& event ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL rowSetChanged( const ::com::sun::star::lang::EventObject& event ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ void clearConnection();
+
+ void startRowSetListening();
+ void stopRowSetListening();
+ sal_Bool isRowSetListening() const { return m_bRSListening; }
+
+ void startPropertyListening( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxProps );
+ void stopPropertyListening( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxEventSource );
+ sal_Bool isPropertyListening() const { return m_bPropertyListening; }
+ };
+
+//.........................................................................
+} // namespace dbtools
+//.........................................................................
+
+#endif // _CONNECTIVITY_CONNCLEANUP_HXX_
+
diff --git a/connectivity/inc/connectivity/dbcharset.hxx b/connectivity/inc/connectivity/dbcharset.hxx
new file mode 100644
index 000000000000..427cdcf1cf88
--- /dev/null
+++ b/connectivity/inc/connectivity/dbcharset.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _DBHELPER_DBCHARSET_HXX_
+#define _DBHELPER_DBCHARSET_HXX_
+
+#include <comphelper/stl_types.hxx>
+#include <rtl/textenc.h>
+#include <rtl/tencinfo.h>
+#include <rtl/ustring.hxx>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+//.........................................................................
+namespace dbtools
+{
+//.........................................................................
+
+ //=========================================================================
+ //= OCharsetMap
+ //=========================================================================
+ /** is a class which translates between different charset representations.
+
+ <p>The set of recognized charsets is very limited: only the ones which are database relevant are
+ implemented at the moment</p>
+
+ <p>Possible representations are:
+ <ul>
+ <li><b>IANA names.</b>
+ Have a look at <A href="http://www.iana.org/assignments/character-sets">this document</A> for
+ more details</li>
+ <li><b>rtl_TextEncoding</b></li>
+ </ul>
+ </p>
+ */
+ class OOO_DLLPUBLIC_DBTOOLS OCharsetMap
+ {
+ protected:
+ DECLARE_STL_STDKEY_SET( rtl_TextEncoding, TextEncBag );
+
+ TextEncBag m_aEncodings;
+
+ public:
+ class CharsetIterator;
+ friend class OCharsetMap::CharsetIterator;
+ typedef CharsetIterator iterator;
+ typedef CharsetIterator const_iterator;
+
+ OCharsetMap();
+ virtual ~OCharsetMap();
+
+ struct IANA { };
+
+ /** find the given text encoding in the map.
+ @return the <em>end</em> iterator if the encoding could not be found.
+ */
+ CharsetIterator find(const rtl_TextEncoding _eEncoding) const;
+ /** find the given IANA name in the map.
+ @return the <em>end</em> iterator if the IANA name could not be found.
+ */
+ CharsetIterator find(const ::rtl::OUString& _rIanaName, const IANA&) const;
+
+ sal_Int32 size() const { ensureConstructed( ); return m_aEncodings.size(); }
+
+ /// get access to the first element of the charset collection
+ CharsetIterator begin() const;
+ /// get access to the (last + 1st) element of the charset collection
+ CharsetIterator end() const;
+
+ protected:
+ // needed because we want to call a virtual method during construction
+ void lateConstruct();
+ inline void ensureConstructed( ) const { if ( m_aEncodings.empty() ) const_cast< OCharsetMap* >( this )->lateConstruct(); }
+
+ virtual sal_Bool approveEncoding( const rtl_TextEncoding _eEncoding, const rtl_TextEncodingInfo& _rInfo ) const;
+ };
+
+ //-------------------------------------------------------------------------
+ //- CharsetIteratorDerefHelper
+ //-------------------------------------------------------------------------
+ class OOO_DLLPUBLIC_DBTOOLS CharsetIteratorDerefHelper
+ {
+ friend class OCharsetMap::CharsetIterator;
+
+ rtl_TextEncoding m_eEncoding;
+ ::rtl::OUString m_aIanaName;
+
+ public:
+ CharsetIteratorDerefHelper(const CharsetIteratorDerefHelper& _rSource);
+
+ rtl_TextEncoding getEncoding() const { return m_eEncoding; }
+ ::rtl::OUString getIanaName() const { return m_aIanaName; }
+
+ protected:
+ CharsetIteratorDerefHelper();
+ CharsetIteratorDerefHelper( const rtl_TextEncoding _eEncoding, const ::rtl::OUString& _rIanaName );
+
+ };
+
+
+ //-------------------------------------------------------------------------
+ //- OCharsetMap::CharsetIterator
+ //-------------------------------------------------------------------------
+ class OOO_DLLPUBLIC_DBTOOLS OCharsetMap::CharsetIterator
+ {
+ friend class OCharsetMap;
+
+ friend OOO_DLLPUBLIC_DBTOOLS bool operator==(const CharsetIterator& lhs, const CharsetIterator& rhs);
+ friend bool operator!=(const CharsetIterator& lhs, const CharsetIterator& rhs) { return !(lhs == rhs); }
+
+// friend sal_Int32 operator-(const CharsetIterator& lhs, const CharsetIterator& rhs);
+
+ protected:
+ const OCharsetMap* m_pContainer;
+ OCharsetMap::TextEncBag::const_iterator m_aPos;
+
+ public:
+ CharsetIterator(const CharsetIterator& _rSource);
+ ~CharsetIterator();
+
+ CharsetIteratorDerefHelper operator*() const;
+ // no -> operator
+ // this would require us to a) store CharsetIteratorDerefHelper instances ourself so that we
+ // can return a pointer or b) introduce a -> operator on the CharsetIteratorDerefHelper, too.
+
+ /// prefix increment
+ const CharsetIterator& operator++();
+ /// postfix increment
+ const CharsetIterator operator++(int) { CharsetIterator hold(*this); ++*this; return hold; }
+
+ /// prefix decrement
+ const CharsetIterator& operator--();
+ /// postfix decrement
+ const CharsetIterator operator--(int) { CharsetIterator hold(*this); --*this; return hold; }
+
+ protected:
+ CharsetIterator(const OCharsetMap* _pContainer, OCharsetMap::TextEncBag::const_iterator _aPos );
+ };
+
+//.........................................................................
+} // namespace dbtools
+//.........................................................................
+
+#endif // _DBHELPER_DBCHARSET_HXX_
+
diff --git a/connectivity/inc/connectivity/dbconversion.hxx b/connectivity/inc/connectivity/dbconversion.hxx
new file mode 100644
index 000000000000..6a54a3e92d2d
--- /dev/null
+++ b/connectivity/inc/connectivity/dbconversion.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 _DBHELPER_DBCONVERSION_HXX_
+#define _DBHELPER_DBCONVERSION_HXX_
+
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+// forward declarations
+namespace rtl
+{
+ class OUString;
+}
+namespace com
+{
+ namespace sun
+ {
+ namespace star
+ {
+ namespace lang
+ {
+ struct Locale;
+ }
+ namespace sdb
+ {
+ class XColumn;
+ class XColumnUpdate;
+ }
+ namespace sdbc
+ {
+ class SQLException;
+ }
+ namespace beans
+ {
+ class XPropertySet;
+ }
+ namespace util
+ {
+ class XNumberFormatter;
+ class XNumberFormatsSupplier;
+ struct Time;
+ struct DateTime;
+ }
+ namespace script
+ {
+ class XTypeConverter;
+ }
+ }
+ }
+}
+
+//.........................................................................
+namespace dbtools
+{
+//.........................................................................
+
+ class OOO_DLLPUBLIC_DBTOOLS DBTypeConversion
+ {
+ public:
+ static ::com::sun::star::util::Date getStandardDate();
+ static void setValue(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumnUpdate>& xVariant,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter>& xFormatter,
+ const ::com::sun::star::util::Date& rNullDate,
+ const ::rtl::OUString& rString,
+ sal_Int32 nKey,
+ sal_Int16 nFieldType,
+ sal_Int16 nKeyType) throw(::com::sun::star::lang::IllegalArgumentException);
+
+ static void setValue(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumnUpdate>& xVariant,
+ const ::com::sun::star::util::Date& rNullDate,
+ const double& rValue,
+ sal_Int16 nKeyType) throw(::com::sun::star::lang::IllegalArgumentException);
+
+ static double getValue(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn>& xVariant, const ::com::sun::star::util::Date& rNullDate,
+ sal_Int16 nKeyType);
+
+ // get the columnvalue as string with a default format given by the column or a default format
+ // for the type
+ static ::rtl::OUString getValue(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter>& xFormatter,
+ const ::com::sun::star::lang::Locale& _rLocale,
+ const ::com::sun::star::util::Date& rNullDate);
+
+ static ::rtl::OUString getValue(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn>& _xColumn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter>& xFormatter,
+ const ::com::sun::star::util::Date& rNullDate,
+ sal_Int32 nKey,
+ sal_Int16 nKeyType);
+
+ static ::com::sun::star::util::Date toDate(double dVal, const ::com::sun::star::util::Date& _rNullDate = getStandardDate());
+ static ::com::sun::star::util::Date toDate(const ::rtl::OUString& _sSQLDate);
+ static ::com::sun::star::util::Time toTime(double dVal);
+ static ::com::sun::star::util::Time toTime(const ::rtl::OUString& _sSQLDate);
+ static ::com::sun::star::util::DateTime toDateTime(double dVal, const ::com::sun::star::util::Date& _rNullDate = getStandardDate());
+ static ::com::sun::star::util::DateTime toDateTime(const ::rtl::OUString& _sSQLDate);
+
+
+ /** return the given DateTime as JDBC compliant 64 bit value
+ */
+ static sal_Int64 toINT64(const ::com::sun::star::util::DateTime& rVal);
+ static sal_Int32 getMsFromTime(const ::com::sun::star::util::Time& rVal);
+
+ static sal_Int32 toDays(const ::com::sun::star::util::Date& _rVal, const ::com::sun::star::util::Date& _rNullDate = getStandardDate());
+
+ static double toDouble(const ::com::sun::star::util::Date& rVal, const ::com::sun::star::util::Date& _rNullDate = getStandardDate());
+ static double toDouble(const ::com::sun::star::util::Time& rVal);
+ static double toDouble(const ::com::sun::star::util::DateTime& rVal, const ::com::sun::star::util::Date& _rNullDate = getStandardDate());
+
+ static sal_Int32 toINT32(const ::com::sun::star::util::Date& rVal);
+ static sal_Int32 toINT32(const ::com::sun::star::util::Time& rVal);
+
+ static ::com::sun::star::util::Date toDate(sal_Int32 _nVal);
+ static ::com::sun::star::util::Time toTime(sal_Int32 _nVal);
+
+ /** convert a double which is a date value relative to a given fixed date into a date value relative
+ to the standard db null date.
+ */
+ static double toStandardDbDate(const ::com::sun::star::util::Date& _rNullDate, double _rVal) { return _rVal + toDays(_rNullDate); }
+ /** convert a double which is a date value relative to the standard db null date into a date value relative
+ to a given fixed date.
+ */
+ static double toNullDate(const ::com::sun::star::util::Date& _rNullDate, double _rVal) { return _rVal - toDays(_rNullDate); }
+
+ // return the date from the numberformatsupplier or the STANDARD_DATE (1900,1,1)
+ static ::com::sun::star::util::Date getNULLDate(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > &xSupplier);
+
+ // return the date in the format %04d-%02d-%02d
+ static ::rtl::OUString toDateString(const ::com::sun::star::util::Date& rDate);
+ // return the time in the format %02d:%02d:%02d
+ static ::rtl::OUString toTimeString(const ::com::sun::star::util::Time& rTime);
+ // return the DateTime in the format %04d-%02d-%02d %02d:%02d:%02d
+ static ::rtl::OUString toDateTimeString(const ::com::sun::star::util::DateTime& _rDateTime);
+ // return the any in an sql standard format
+ static ::rtl::OUString toSQLString(sal_Int32 eType, const ::com::sun::star::uno::Any& _rVal, sal_Bool bQuote,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter >& _rxTypeConverter);
+
+ /** converts a Unicode string into a 8-bit string, using the given encoding
+
+ @param _rSource
+ the source string to convert
+ @param _rDest
+ the destination string
+ @param _eEncoding
+ the encoding to use for the conversion
+
+ @throws com::sun::star::sdbc::SQLException
+ if the given string contains characters which are not convertible using the given encoding
+ The SQLState of the exception will be set to 22018 ("Invalid character value for cast specification")
+
+ @return
+ the length of the converted string
+ */
+ static sal_Int32 convertUnicodeString(
+ const ::rtl::OUString& _rSource,
+ ::rtl::OString& _rDest,
+ rtl_TextEncoding _eEncoding
+ )
+ SAL_THROW((::com::sun::star::sdbc::SQLException));
+
+ /** converts a Unicode string into a 8-bit string, using the given encoding
+
+ @param _rSource
+ the source string to convert
+
+ @param _rDest
+ the destination string
+
+ @param _nMaxLen
+ the maximum length of the destination string
+
+ @param _eEncoding
+ the encoding to use for the conversion
+
+ @throws com::sun::star::sdbc::SQLException
+ if convertUnicodeString, which is called internally, throws such an exception
+
+ @throws com::sun::star::sdbc::SQLException
+ if the conversion results in a string which is longer than _nMaxLen
+
+ @return
+ the length of the converted string
+ */
+ static sal_Int32 convertUnicodeStringToLength(
+ const ::rtl::OUString& _rSource,
+ ::rtl::OString& _rDest,
+ sal_Int32 _nMaxLen,
+ rtl_TextEncoding _eEncoding
+ )
+ SAL_THROW((::com::sun::star::sdbc::SQLException));
+ };
+
+//.........................................................................
+} // namespace dbtools
+//.........................................................................
+
+#endif // _DBHELPER_DBCONVERSION_HXX_
+
diff --git a/connectivity/inc/connectivity/dbexception.hxx b/connectivity/inc/connectivity/dbexception.hxx
new file mode 100644
index 000000000000..bd4077ccb9e2
--- /dev/null
+++ b/connectivity/inc/connectivity/dbexception.hxx
@@ -0,0 +1,377 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 _DBHELPER_DBEXCEPTION_HXX_
+#define _DBHELPER_DBEXCEPTION_HXX_
+
+#include <com/sun/star/sdbc/SQLException.hpp>
+#include "connectivity/standardsqlstate.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace com
+{
+ namespace sun
+ {
+ namespace star
+ {
+ namespace sdb
+ {
+ class SQLContext;
+ struct SQLErrorEvent;
+ }
+ namespace sdbc
+ {
+ class SQLWarning;
+ }
+ }
+ }
+}
+//.........................................................................
+namespace dbtools
+{
+//.........................................................................
+
+//==============================================================================
+//= Special exception if cancel is pressed in DBA UI
+//==============================================================================
+enum OOoBaseErrorCode
+{
+ ParameterInteractionCancelled = 1
+};
+
+//==============================================================================
+//= SQLExceptionInfo - encapsulating the type info of an SQLException-derived class
+//==============================================================================
+
+class OOO_DLLPUBLIC_DBTOOLS SQLExceptionInfo
+{
+public:
+ enum TYPE { SQL_EXCEPTION, SQL_WARNING, SQL_CONTEXT, UNDEFINED };
+
+private:
+ ::com::sun::star::uno::Any m_aContent;
+ TYPE m_eType; // redundant (could be derived from m_aContent.getValueType())
+
+public:
+ SQLExceptionInfo();
+ SQLExceptionInfo(const ::com::sun::star::sdbc::SQLException& _rError);
+ SQLExceptionInfo(const ::com::sun::star::sdbc::SQLWarning& _rError);
+ SQLExceptionInfo(const ::com::sun::star::sdb::SQLContext& _rError);
+
+ /** convenience constructor
+
+ If your error processing relies on SQLExceptions, and SQLExceptionInfos, you still may
+ need to display an error which consists of a simple message string only.
+ In those cases, you can use this constructor, which behaves as if you would have used
+ an SQLException containing exactly the given error message.
+ */
+ SQLExceptionInfo( const ::rtl::OUString& _rSimpleErrorMessage );
+
+ SQLExceptionInfo(const SQLExceptionInfo& _rCopySource);
+
+ SQLExceptionInfo(const ::com::sun::star::sdb::SQLErrorEvent& _rError);
+ // use for events got via XSQLErrorListener::errorOccured
+ SQLExceptionInfo(const ::com::sun::star::uno::Any& _rError);
+ // use with the Reason member of an SQLErrorEvent or with NextElement of an SQLException
+
+ /** prepends a plain error message to the chain of exceptions
+ @param _rSimpleErrorMessage
+ the error message to prepend
+ @param _pAsciiSQLState
+ the SQLState of the to-be-constructed SQLException, or NULL if this should be defaulted to HY000
+ @param _nErrorCode
+ the ErrorCode of the to-be-constructed SQLException
+ */
+ void prepend( const ::rtl::OUString& _rErrorMessage, const sal_Char* _pAsciiSQLState = NULL, const sal_Int32 _nErrorCode = 0 );
+
+ /** appends a plain message to the chain of exceptions
+ @param _eType
+ the type of exception to append. Must be SQL_EXCEPTION, SQL_WARNING, SQL_CONTEXT, for all other
+ values, the behavior is undefined.
+ @param _rErrorMessage
+ the message to append
+ @param _pAsciiSQLState
+ the SQLState of the exception to append
+ @param _nErrorCode
+ the error code of the exception to append
+ */
+ void append( TYPE _eType, const ::rtl::OUString& _rErrorMessage, const sal_Char* _pAsciiSQLState = NULL, const sal_Int32 _nErrorCode = 0 );
+
+ /** throws (properly typed) the exception contained in the object
+ @precond
+ isValid() returns <TRUE/>
+ @throws SQLException
+ @throws RuntimeException
+ if the instance does not contain an SQLException
+ */
+ void doThrow();
+
+ const SQLExceptionInfo& operator=(const ::com::sun::star::sdbc::SQLException& _rError);
+ const SQLExceptionInfo& operator=(const ::com::sun::star::sdbc::SQLWarning& _rError);
+ const SQLExceptionInfo& operator=(const ::com::sun::star::sdb::SQLContext& _rError);
+ const SQLExceptionInfo& operator=(const ::com::sun::star::sdb::SQLErrorEvent& _rErrorEvent);
+ const SQLExceptionInfo& operator=(const ::com::sun::star::uno::Any& _rCaughtSQLException);
+
+ sal_Bool isKindOf(TYPE _eType) const;
+ // not just a simple comparisation ! e.g. getType() == SQL_CONTEXT implies isKindOf(SQL_EXCEPTION) == sal_True !
+ sal_Bool isValid() const { return m_eType != UNDEFINED; }
+ TYPE getType() const { return m_eType; }
+
+ operator const ::com::sun::star::sdbc::SQLException* () const;
+ operator const ::com::sun::star::sdbc::SQLWarning* () const;
+ operator const ::com::sun::star::sdb::SQLContext* () const;
+
+ const ::com::sun::star::uno::Any& get() const { return m_aContent; }
+
+ void clear()
+ {
+ m_aContent.clear();
+ m_eType = UNDEFINED;
+ }
+
+protected:
+ void implDetermineType();
+};
+
+//==============================================================================
+//= SQLExceptionIteratorHelper - iterating through an SQLException chain
+//==============================================================================
+
+class OOO_DLLPUBLIC_DBTOOLS SQLExceptionIteratorHelper
+{
+protected:
+ const ::com::sun::star::sdbc::SQLException* m_pCurrent;
+ SQLExceptionInfo::TYPE m_eCurrentType;
+
+public:
+ /** constructs an iterator instance from an SQLException
+
+ @param _rChainStart
+ the start of the exception chain to iterate. Must live as long as the iterator
+ instances lives, at least.
+ */
+ SQLExceptionIteratorHelper( const ::com::sun::star::sdbc::SQLException& _rChainStart );
+
+ /** constructs an iterator instance from an SQLWarning
+
+ @param _rChainStart
+ the start of the exception chain to iterate. Must live as long as the iterator
+ instances lives, at least.
+ */
+ SQLExceptionIteratorHelper( const ::com::sun::star::sdbc::SQLWarning& _rChainStart );
+
+ /** constructs an iterator instance from an SQLContext
+
+ @param _rChainStart
+ the start of the exception chain to iterate. Must live as long as the iterator
+ instances lives, at least.
+ */
+ SQLExceptionIteratorHelper( const ::com::sun::star::sdb::SQLContext& _rChainStart );
+
+ /** constructs an iterator instance from an SQLExceptionInfo
+
+ @param _rErrorInfo
+ the start of the exception chain to iterate. Must live as long as the iterator
+ instances lives, at least.
+ */
+ SQLExceptionIteratorHelper( const SQLExceptionInfo& _rErrorInfo );
+
+ /** determines whether there are more elements in the exception chain
+ */
+ sal_Bool hasMoreElements() const { return ( m_pCurrent != NULL ); }
+
+ /** returns the type of the current element in the exception chain
+ */
+ SQLExceptionInfo::TYPE currentType() const { return m_eCurrentType; }
+
+ /** retrieves the current element in the chain, or <NULL/> if the chain has been completely
+ traveled.
+ */
+ const ::com::sun::star::sdbc::SQLException* current() const { return m_pCurrent; }
+
+ /** retrieves the current element in the chain, or <NULL/> if the chain has been completely
+ traveled.
+
+ In opposite to the second <member>current</member>, this version allows typed access to
+ the respective SQLException.
+ */
+ void current( SQLExceptionInfo& _out_rInfo ) const;
+
+ /** proceeds to the next element in the chain
+
+ @return the current element in the chain, as <b>before</em> the chain move.
+ */
+ const ::com::sun::star::sdbc::SQLException* next();
+
+ /** proceeds to the next element in the chain
+
+ In opposite to the second <member>current</member>, this version allows typed access to
+ the respective SQLException.
+ */
+ void next( SQLExceptionInfo& _out_rInfo );
+};
+
+//==================================================================================
+//= StandardExceptions
+//==================================================================================
+//----------------------------------------------------------------------------------
+/** returns a standard error string for a given SQLState
+
+ @param _eState
+ describes the state whose description is to retrieve. Must not be SQL_ERROR_UNSPECIFIED.
+ @raises RuntimeException
+ in case of an internal error
+*/
+OOO_DLLPUBLIC_DBTOOLS ::rtl::OUString getStandardSQLState( StandardSQLState _eState );
+
+//----------------------------------------------------------------------------------
+/** returns a standard ASCII string for a given SQLState
+
+ @param _eState
+ describes the state whose description is to retrieve. Must not be SQL_ERROR_UNSPECIFIED.
+ @return
+ a non-<NULL/> pointer to an ASCII character string denoting the requested SQLState
+ @raises RuntimeException
+ in case of an internal error
+*/
+OOO_DLLPUBLIC_DBTOOLS const sal_Char* getStandardSQLStateAscii( StandardSQLState _eState );
+
+//----------------------------------------------------------------------------------
+OOO_DLLPUBLIC_DBTOOLS void throwFunctionNotSupportedException(
+ const ::rtl::OUString& _rMsg,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _Context,
+ const ::com::sun::star::uno::Any& _Next = ::com::sun::star::uno::Any()
+ )
+ throw ( ::com::sun::star::sdbc::SQLException );
+
+//----------------------------------------------------------------------------------
+/** throws an exception with SQL state IM001, saying that a certain function is not supported
+*/
+OOO_DLLPUBLIC_DBTOOLS void throwFunctionNotSupportedException(
+ const sal_Char* _pAsciiFunctionName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext,
+ const ::com::sun::star::uno::Any* _pNextException = NULL
+ )
+ throw ( ::com::sun::star::sdbc::SQLException );
+
+//----------------------------------------------------------------------------------
+/** throws a function sequence (HY010) exception
+*/
+OOO_DLLPUBLIC_DBTOOLS void throwFunctionSequenceException(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _Context,
+ const ::com::sun::star::uno::Any& _Next = ::com::sun::star::uno::Any()
+ )
+ throw ( ::com::sun::star::sdbc::SQLException );
+
+//----------------------------------------------------------------------------------
+/** throw a invalid index sqlexception
+*/
+OOO_DLLPUBLIC_DBTOOLS void throwInvalidIndexException(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _Context,
+ const ::com::sun::star::uno::Any& _Next = ::com::sun::star::uno::Any()
+ )
+ throw ( ::com::sun::star::sdbc::SQLException );
+
+//----------------------------------------------------------------------------------
+/** throw a generic SQLException, i.e. one with an SQLState of HY000, an ErrorCode of 0 and no NextException
+*/
+OOO_DLLPUBLIC_DBTOOLS void throwGenericSQLException(
+ const ::rtl::OUString& _rMsg,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxSource
+ )
+ throw (::com::sun::star::sdbc::SQLException);
+
+//----------------------------------------------------------------------------------
+/** throw a generic SQLException, i.e. one with an SQLState of HY000, an ErrorCode of 0 and no NextException
+*/
+OOO_DLLPUBLIC_DBTOOLS void throwGenericSQLException(
+ const ::rtl::OUString& _rMsg,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxSource,
+ const ::com::sun::star::uno::Any& _rNextException
+ )
+ throw (::com::sun::star::sdbc::SQLException);
+
+//----------------------------------------------------------------------------------
+/** throw a SQLException with SQLState HYC00 (Optional feature not implemented)
+ @param _pAsciiFeatureName
+ an ASCII description of the feature which is not implemented. It's recommended that the feature
+ name is built from the name of the interface plus its method, for instance "XParameters::updateBinaryStream"
+ @param _rxContext
+ the context of the exception
+ @param _pNextException
+ the next exception to chain into the thrown exception, if any
+*/
+OOO_DLLPUBLIC_DBTOOLS void throwFeatureNotImplementedException(
+ const sal_Char* _pAsciiFeatureName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext,
+ const ::com::sun::star::uno::Any* _pNextException = NULL
+ )
+ throw (::com::sun::star::sdbc::SQLException);
+
+//----------------------------------------------------------------------------------
+/** throws an SQLException
+*/
+OOO_DLLPUBLIC_DBTOOLS void throwSQLException(
+ const sal_Char* _pAsciiMessage,
+ const sal_Char* _pAsciiState,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext,
+ const sal_Int32 _nErrorCode = 0,
+ const ::com::sun::star::uno::Any* _pNextException = NULL
+ )
+ throw (::com::sun::star::sdbc::SQLException);
+
+//----------------------------------------------------------------------------------
+/** throws an SQLException
+*/
+OOO_DLLPUBLIC_DBTOOLS void throwSQLException(
+ const sal_Char* _pAsciiMessage,
+ StandardSQLState _eSQLState,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext,
+ const sal_Int32 _nErrorCode = 0,
+ const ::com::sun::star::uno::Any* _pNextException = NULL
+ )
+ throw (::com::sun::star::sdbc::SQLException);
+
+//----------------------------------------------------------------------------------
+/** throws an SQLException
+*/
+OOO_DLLPUBLIC_DBTOOLS void throwSQLException(
+ const ::rtl::OUString& _rMessage,
+ StandardSQLState _eSQLState,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext,
+ const sal_Int32 _nErrorCode = 0,
+ const ::com::sun::star::uno::Any* _pNextException = NULL
+ )
+ throw (::com::sun::star::sdbc::SQLException);
+
+//.........................................................................
+} // namespace dbtools
+//.........................................................................
+
+#endif // _DBHELPER_DBEXCEPTION_HXX_
+
+
diff --git a/connectivity/inc/connectivity/dbmetadata.hxx b/connectivity/inc/connectivity/dbmetadata.hxx
new file mode 100644
index 000000000000..7ed7967bf4c5
--- /dev/null
+++ b/connectivity/inc/connectivity/dbmetadata.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_INC_CONNECTIVITY_DBMETADATA_HXX
+#define CONNECTIVITY_INC_CONNECTIVITY_DBMETADATA_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdbc/XConnection.hpp>
+/** === end UNO includes === **/
+
+#include <memory>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace comphelper
+{
+ class ComponentContext;
+}
+
+//........................................................................
+namespace dbtools
+{
+//........................................................................
+
+ //====================================================================
+ //= DatabaseMetaData
+ //====================================================================
+ struct DatabaseMetaData_Impl;
+ /** encapsulates meta data about a database/connection which cannot be obtained
+ from the usual XDatabaseMetaData result set.
+
+ Meta data perhaps isn't really the right term ... Some of the methods
+ in this class involved heuristics, some are just a convenient wrapper
+ around more complex ways to obtain the same information.
+
+ @todo
+ Once CWS dba30 is integrated, we could easily add all the meta data
+ which is part of the "Info" property of a data source.
+ */
+ class OOO_DLLPUBLIC_DBTOOLS DatabaseMetaData
+ {
+ private:
+ ::std::auto_ptr< DatabaseMetaData_Impl > m_pImpl;
+
+ public:
+ DatabaseMetaData();
+ /** constructs a DatabaseMetaData instance
+ @param _rxConnection
+ is the connection whose meta data you're interested in.
+ Note that some of the information provided by this class can only be obtained
+ if this connection denotes an application-level connection, i.e. supports
+ the com.sun.star.sdb.Connection service.
+
+ @throws ::com::sun::star::lang::IllegalArgumentException
+ if the given connection is not <NULL/>, but the XDatabaseMetaData provided by it
+ are <NULL/>
+ @throws ::com::sun::star::sdbc::SQLException
+ if obtaining the meta data from the connection throws an SQLException
+ @throws ::com::sun::star::uno::RuntimeException
+ if obtaining the meta data from the connection throws an RuntimeException
+ */
+ DatabaseMetaData(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _connection );
+ DatabaseMetaData( const DatabaseMetaData& _copyFrom );
+ DatabaseMetaData& operator=( const DatabaseMetaData& _copyFrom );
+
+ ~DatabaseMetaData();
+
+ public:
+ /** determines whether or not the instances is based on a valid connection
+
+ As long as this method returns true<TRUE/>, you should expect all other
+ methods throwing an SQLException when called.
+ */
+ bool isConnected() const;
+
+ /** resets the instance so that it's based on a new connection
+ */
+ inline void reset( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _connection )
+ {
+ *this = DatabaseMetaData( _connection );
+ }
+
+ /// wraps XDatabaseMetaData::getIdentifierQuoteString
+ const ::rtl::OUString& getIdentifierQuoteString() const;
+
+ /// wraps XDatabaseMetaData::getCatalogSeparator
+ const ::rtl::OUString& getCatalogSeparator() const;
+
+ /** determines whether the database supports sub queries in the FROM part
+ of a SELECT clause are supported.
+ @throws ::com::sun::star::sdbc::SQLException
+ with SQLState 08003 (connection does not exist) if the instances was
+ default-constructed and does not have a connection, yet.
+ */
+ bool supportsSubqueriesInFrom() const;
+
+ /** checks whether the database supports primary keys
+
+ Since there's no dedicated API to ask a database for this, a heuristics needs to be applied.
+ First, the <code>PrimaryKeySupport<code> settings of the data source is examined. If it is <TRUE/>
+ or <FALSE/>, then value is returned. If it is <NULL/>, then the database meta data are examined
+ for support of core SQL grammar, and the result is returned. The assumption is that a database/driver
+ which supports core SQL grammar usually also supports primary keys, and vice versa. At least, experience
+ shows this is true most of the time.
+ */
+ bool supportsPrimaryKeys() const;
+
+ /** determines whether names in the database should be restricted to SQL-92 identifiers
+
+ Effectively, this method checks the EnableSQL92Check property of the data source settings,
+ if present.
+ */
+ bool restrictIdentifiersToSQL92() const;
+
+ /** determines whether when generating SQL statements, an AS keyword should be generated
+ before a correlation name.
+
+ E.g., it determines whether <code>SELECT * FROM table AS correlation_name</code> or
+ <code>SELECT * FROM table correlation_name</code> is generated.
+ */
+ bool generateASBeforeCorrelationName() const;
+
+ /** should date time be escaped like '2001-01-01' => #2001-01-01#
+ */
+ bool shouldEscapeDateTime() const;
+
+ /** auto increment columns should be automaticly used as primary key.
+ */
+ bool isAutoIncrementPrimaryKey() const;
+
+ /** determines the syntax to use for boolean comparison predicates
+
+ @see ::com::sun::star::sdb::BooleanComparisonMode
+ */
+ sal_Int32
+ getBooleanComparisonMode() const;
+
+ /** determines in relations are supported.
+ *
+ * \return <TRUE/> when relations are supported, otherwise <FALSE/>
+ */
+ bool supportsRelations() const;
+
+ /** determines if column alias names can be used in the order by clause.
+ *
+ * \return <TRUE/> when relations are supported, otherwise <FALSE/>
+ */
+ bool supportsColumnAliasInOrderBy() const;
+
+ /** determines whether user administration is supported for the database
+
+ User administration support is controlled by the availability of the XUsersSupplier
+ interface, and it returning a non-NULL users container.
+
+ @param _rContext
+ the component context we operate in. Might be needed to create the
+ css.sdbc.DriverManager instance.
+ */
+ bool supportsUserAdministration( const ::comphelper::ComponentContext& _rContext ) const;
+
+ /** determines whether in the application UI, empty table folders (aka catalogs/schemas) should be displayed
+ */
+ bool displayEmptyTableFolders() const;
+
+ /** determines that threads are supported.
+ *
+ * \return <TRUE/> when threads are supported, otherwise <FALSE/>
+ */
+ bool supportsThreads() const;
+ };
+
+//........................................................................
+} // namespace dbtools
+//........................................................................
+
+#endif // CONNECTIVITY_INC_CONNECTIVITY_DBMETADATA_HXX
diff --git a/connectivity/inc/connectivity/dbtools.hxx b/connectivity/inc/connectivity/dbtools.hxx
new file mode 100644
index 000000000000..9b93830aeefe
--- /dev/null
+++ b/connectivity/inc/connectivity/dbtools.hxx
@@ -0,0 +1,825 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_DBTOOLS_HXX_
+#define _CONNECTIVITY_DBTOOLS_HXX_
+
+#include <connectivity/dbexception.hxx>
+#include <comphelper/types.hxx>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <comphelper/stl_types.hxx>
+#include <unotools/sharedunocomponent.hxx>
+#include "connectivity/dbtoolsdllapi.hxx"
+#include "connectivity/FValue.hxx"
+
+namespace com { namespace sun { namespace star {
+
+namespace sdb {
+ class XSingleSelectQueryComposer;
+ class SQLContext;
+}
+namespace sdbcx {
+ class XTablesSupplier;
+}
+namespace sdbc {
+ class XConnection;
+ class XDatabaseMetaData;
+ class XRowSet;
+ class XDataSource;
+ class SQLException;
+ class XParameters;
+ class XRowUpdate;
+}
+namespace beans {
+ class XPropertySet;
+}
+namespace awt {
+ class XWindow;
+}
+namespace lang {
+ struct Locale;
+ class XMultiServiceFactory;
+ class WrappedTargetException;
+}
+namespace container {
+ class XNameAccess;
+}
+
+namespace util {
+ class XNumberFormatTypes;
+ class XNumberFormatsSupplier;
+}
+namespace task {
+ class XInteractionHandler;
+}
+
+} } }
+
+namespace rtl
+{
+ class OUStringBuffer;
+}
+
+//.........................................................................
+namespace dbtools
+{
+ class ISQLStatementHelper;
+ typedef ::utl::SharedUNOComponent< ::com::sun::star::sdbc::XConnection > SharedConnection;
+
+ enum EComposeRule
+ {
+ eInTableDefinitions,
+ eInIndexDefinitions,
+ eInDataManipulation,
+ eInProcedureCalls,
+ eInPrivilegeDefinitions,
+ eComplete
+ };
+//=========================================================================
+ // date conversion
+
+ // calculates the default numberformat for a given datatype and a give language
+ OOO_DLLPUBLIC_DBTOOLS
+ sal_Int32 getDefaultNumberFormat(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xColumn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatTypes >& _xTypes,
+ const ::com::sun::star::lang::Locale& _rLocale);
+
+ // calculates the default numberformat for a given datatype and a give language
+ // @param _nDataType @see com.sun.star.sdbc.DataType
+ // @param _nScale can be zero
+ OOO_DLLPUBLIC_DBTOOLS
+ sal_Int32 getDefaultNumberFormat(sal_Int32 _nDataType,
+ sal_Int32 _nScale,
+ sal_Bool _bIsCurrency,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatTypes >& _xTypes,
+ const ::com::sun::star::lang::Locale& _rLocale);
+
+//=========================================================================
+
+ /** creates a connection which can be used for the rowset given
+
+ The function tries to obtain a connection for the row set with the following
+ steps (in this order):
+ <nl>
+ <li>If the rowset already has an ActiveConnection (means a non-<NULL/> value vor this property),
+ this one is used.</li>
+ <li>If row set is part of a database form document (see ->isEmbeddedInDatabase),
+ a connection for the respective database is used.</li>
+ <li>If in the parent hierarchy of the row set, there is an object supporting
+ the XConnection interface, this one is returned.</li>
+ <li>If the DataSourceName property of the row set is not empty, a connection for this
+ data source is retrieved.</li>
+ <li>If the URL property of the row set is not empty, an connection for this URL is
+ retrieved from the driver manager.
+ </nl>
+
+ @param _rxRowSet
+ the row set
+
+ @param _rxFactory
+ a service factory, which can be used to create data sources, interaction handler etc (the usual stuff)
+
+ @param _bSetAsActiveConnection
+ If <TRUE/>, the calculated connection is set as ActiveConnection property on the rowset.
+
+ If the connection was newly created by the method, and this parameter is <TRUE/>, then
+ the ownership of the connection is delivered to a temporary object, which observes the
+ row set: As soon as a connection-relevant property of the row set changes, or as soon
+ as somebody else sets another ActiveConnection at the row set, the original
+ connection (the one which this function calculated) is disposed and discarded. At this
+ very moment, also the temporary observer object dies. This way, it is ensured that
+ there's no resource leak from an un-owned connection object.
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> connectRowset(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory,
+ sal_Bool _bSetAsActiveConnection
+ ) SAL_THROW ( ( ::com::sun::star::sdbc::SQLException
+ , ::com::sun::star::lang::WrappedTargetException
+ , ::com::sun::star::uno::RuntimeException ) );
+
+ /** ensures that a row set has a valid ActiveConnection, if possible
+
+ This function does nearly the same as ->connectRowset. In fact, it is to be preferred over
+ ->connectRowset, if possible.
+
+ There are a few differences:
+ <ul><li>If a connection could be determined for the given RowSet, it is always
+ set as ActiveConnection.</li>
+ <li>Definition of the ownership of the created connection allows for more scenarios:
+ <ul><li>If the connection was not newly created, the returned ->SharedConnection
+ instance will not have the ownership, since in this case it's assumed
+ that there already is an instance which has the ownership.</li>
+ <li>If the connection was newly created, and ->_bUseAutoConnectionDisposer
+ is <TRUE/>, then the returned SharedConnection instance will <em>not</em>
+ be the owner of the connection. Instead, the ownership will be delivered
+ to a temporary object as described for connectRowset.</li>
+ <li>If the connection was newly created, and ->_bUseAutoConnectionDisposer
+ is <FALSE/>, then the returned SharedConnection instance will have the
+ ownership of the XConnection.</li>
+ </ul>
+ </li>
+ </ul>
+ */
+ OOO_DLLPUBLIC_DBTOOLS SharedConnection ensureRowSetConnection(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory,
+ bool _bUseAutoConnectionDisposer
+ ) SAL_THROW ( ( ::com::sun::star::sdbc::SQLException
+ , ::com::sun::star::lang::WrappedTargetException
+ , ::com::sun::star::uno::RuntimeException ) );
+
+ /** returns the connection the RowSet is currently working with (which is the ActiveConnection property)
+ */
+ OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet) throw (::com::sun::star::uno::RuntimeException);
+ OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection(
+ const ::rtl::OUString& _rsTitleOrPath,
+ const ::rtl::OUString& _rsUser,
+ const ::rtl::OUString& _rsPwd,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
+
+ OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection_withFeedback(
+ const ::rtl::OUString& _rDataSourceName,
+ const ::rtl::OUString& _rUser,
+ const ::rtl::OUString& _rPwd,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory)
+ SAL_THROW ( (::com::sun::star::sdbc::SQLException) );
+
+
+ /** determines whether the given component is part of a document which is an embedded database
+ document (such as a form)
+ */
+ OOO_DLLPUBLIC_DBTOOLS bool isEmbeddedInDatabase(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent,
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxActualConnection
+ );
+
+ /** returns the columns of the named table of the given connection
+ */
+ OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> getTableFields(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConn,
+ const ::rtl::OUString& _rName
+ );
+
+ /** returns the primary key columns of the table
+ */
+ OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> getPrimaryKeyColumns_throw(
+ const ::com::sun::star::uno::Any& i_aTable
+ );
+ OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> getPrimaryKeyColumns_throw(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& i_xTable
+ );
+
+ /** get fields for a result set given by a "command descriptor"
+
+ <p>A command descriptor here means:
+ <ul><li>a SDB-level connection (<type scope="com.sun.star.sdb">Connection</type></li>
+ <li>a string specifying the name of an object relative to the connection</li>
+ <li>a <type scope="com.sun.star.sdb">CommandType</type> value specifying the type
+ of the object</type></li>
+ </ul>
+ </p>
+
+ @param _rxConnection
+ the connection relative to which the to-be-examined object exists
+
+ @param _nCommandType
+ the type of the object
+
+ @param _rCommand
+ the object. This may be a table name, a query name, or an SQL statement, depending on the value
+ of <arg>_nCommandType</arg>
+
+ @param _rxCollectionOner
+ If (and only if) <arg>CommandType</arg> is CommandType.COMMAND, the fields collection which is returned
+ by this function here is a temporary object. It is kept alive by another object, which is to be
+ created temporarily, too. To ensure that the fields you get are valid as long as you need them,
+ the owner which controls their life time is transfered to this parameter upon return.<br/>
+
+ Your fields live as long as this component lives.<br/>
+
+ Additionally, you are encouraged to dispose this component as soon as you don't need the fields anymore.
+ It depends on the connection's implementation if this is necessary, but the is no guarantee, so to
+ be on the safe side with respect to resource leaks, you should dispose the component.
+
+ @param _pErrorInfo
+ If not <NULL/>, then upon return from the function the instance pointed to by this argument will
+ contain any available error information in case something went wrong.
+
+ @return
+ the container of the columns (aka fields) of the object
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ getFieldsByCommandDescriptor(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const sal_Int32 _nCommandType,
+ const ::rtl::OUString& _rCommand,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _rxKeepFieldsAlive,
+ SQLExceptionInfo* _pErrorInfo = NULL
+ ) SAL_THROW( ( ) );
+
+
+ /** get fields for a result set given by a "command descriptor"
+
+ <p>A command descriptor here means:
+ <ul><li>a SDB-level connection (<type scope="com.sun.star.sdb">Connection</type></li>
+ <li>a string specifying the name of an object relative to the connection</li>
+ <li>a <type scope="com.sun.star.sdb">CommandType</type> value specifying the type
+ of the object</type></li>
+ </ul>
+ </p>
+
+ @param _rxConnection
+ the connection relative to which the to-be-examined object exists
+
+ @param _nCommandType
+ the type of the object
+
+ @param _rCommand
+ the object. This may be a table name, a query name, or an SQL statement, depending on the value
+ of <arg>_nCommandType</arg>
+
+ @param _pErrorInfo
+ If not <NULL/>, then upon return from the function the instance pointed to by this argument will
+ contain any available error information in case something went wrong.
+
+ @return
+ an array of strings containing the names of the columns (aka fields) of the object
+ */
+ OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getFieldNamesByCommandDescriptor(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const sal_Int32 _nCommandType,
+ const ::rtl::OUString& _rCommand,
+ SQLExceptionInfo* _pErrorInfo = NULL
+ ) SAL_THROW( ( ) );
+
+
+ /** create a new ::com::sun::star::sdbc::SQLContext, fill it with the given descriptions and the given source,
+ and <i>append</i> _rException (i.e. put it into the NextException member of the SQLContext).
+ */
+ OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::sdb::SQLContext prependContextInfo(const ::com::sun::star::sdbc::SQLException& _rException, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext, const ::rtl::OUString& _rContextDescription, const ::rtl::OUString& _rContextDetails );
+
+ OOO_DLLPUBLIC_DBTOOLS
+ ::com::sun::star::sdbc::SQLException prependErrorInfo(
+ const ::com::sun::star::sdbc::SQLException& _rChainedException,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext,
+ const ::rtl::OUString& _rAdditionalError,
+ const StandardSQLState _eSQLState = SQL_ERROR_UNSPECIFIED,
+ const sal_Int32 _nErrorCode = 0);
+
+ /** search the parent hierachy for a data source.
+ */
+ OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> findDataSource(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParent);
+
+ /** determines the value of a booolean data source setting, given by ASCII name
+
+ @param _rxConnection
+ the connection belonging to the data source whose setting is to be retrieved
+ @param _pAsciiSettingName
+ the ASCII name of the setting
+ */
+ OOO_DLLPUBLIC_DBTOOLS bool getBooleanDataSourceSetting(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const sal_Char* _pAsciiSettingName
+ );
+
+ /** check if a specific property is enabled in the info sequence
+ @deprecated
+ Use getBooleanDataSourceSetting instead, which cares for the default of the property itself,
+ instead of spreading this knowledge through all callers.
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ sal_Bool isDataSourcePropertyEnabled(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _xProp
+ ,const ::rtl::OUString& _sProperty,
+ sal_Bool _bDefault = sal_False);
+
+ /** retrieves a particular indirect data source setting
+
+ @param _rxDataSource
+ a data source component
+ @param _pAsciiSettingsName
+ the ASCII name of the setting to obtain
+ @param _rSettingsValue
+ the value of the setting, upon successfull return
+
+ @return
+ <FALSE/> if the setting is not present in the <member scope="com::sun::star::sdb">DataSource::Info</member>
+ member of the data source
+ <TRUE/> otherwise
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ bool getDataSourceSetting(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDataSource,
+ const sal_Char* _pAsciiSettingsName,
+ ::com::sun::star::uno::Any& /* [out] */ _rSettingsValue
+ );
+ OOO_DLLPUBLIC_DBTOOLS
+ bool getDataSourceSetting(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDataSource,
+ const ::rtl::OUString& _sSettingsName,
+ ::com::sun::star::uno::Any& /* [out] */ _rSettingsValue
+ );
+
+ OOO_DLLPUBLIC_DBTOOLS ::rtl::OUString getDefaultReportEngineServiceName(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
+
+ /** quote the given name with the given quote string.
+ */
+ OOO_DLLPUBLIC_DBTOOLS ::rtl::OUString quoteName(const ::rtl::OUString& _rQuote, const ::rtl::OUString& _rName);
+
+ /** quote the given table name (which may contain a catalog and a schema) according to the rules provided by the meta data
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ ::rtl::OUString quoteTableName(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _rxMeta
+ , const ::rtl::OUString& _rName
+ ,EComposeRule _eComposeRule);
+
+ /** split a fully qualified table name (including catalog and schema, if appliable) into it's component parts.
+ @param _rxConnMetaData meta data describing the connection where you got the table name from
+ @param _rQualifiedName fully qualified table name
+ @param _rCatalog (out parameter) upon return, contains the catalog name
+ @param _rSchema (out parameter) upon return, contains the schema name
+ @param _rName (out parameter) upon return, contains the table name
+ @param _eComposeRule where do you need the name for
+ */
+ OOO_DLLPUBLIC_DBTOOLS void qualifiedNameComponents(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxConnMetaData,
+ const ::rtl::OUString& _rQualifiedName, ::rtl::OUString& _rCatalog, ::rtl::OUString& _rSchema, ::rtl::OUString& _rName,EComposeRule _eComposeRule);
+
+ /** calculate a NumberFormatsSupplier for use with an given connection
+ @param _rxConn the connection for which the formatter is requested
+ @param _bAllowDefault if the connection (and related components, such as it's parent) cannot supply
+ a formatter, we can ask the DatabaseEnvironment for a default one. This parameter
+ states if this is allowed.
+ @param _rxFactory required (only of _bAllowDefault is sal_True) for creating the DatabaseEnvironment.
+ @return the formatter all object related to the given connection should work with.
+ */
+ OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> getNumberFormats(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConn,
+ sal_Bool _bAllowDefault = sal_False,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>()
+ );
+
+ /** returns the statement which is composed from the current settings of a row set
+
+ If the row set is currently not connected, it is attempted to do so with it's current settings.
+ (TODO: isn't this a resource leak? Do we really need this behaviour?).
+
+ @param _rxRowSet
+ the row set whose settings should be examined. Must not be <NULL/>
+ @param _rxFactory
+ a service factory which may be needed to connect the row set
+ @param _bUseRowSetFilter
+ If <TRUE/>, the <b>Filter</b> property of the row set will also be examined. In case it is
+ not empty, and <b>ApplyFilter</b> is <TRUE/>, it will also be added to the composed statement.
+ @param _bUseRowSetOrder
+ If <TRUE/>, the <b>Order</b> property of the row set will also be examined. In case it is
+ not empty, it will also be added to the composed statement.
+ */
+ OOO_DLLPUBLIC_DBTOOLS ::rtl::OUString getComposedRowSetStatement(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxRowSet,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory,
+ sal_Bool _bUseRowSetFilter = sal_True,
+ sal_Bool _bUseRowSetOrder = sal_True
+ ) SAL_THROW( ( ::com::sun::star::sdbc::SQLException ) );
+
+ /** create an <type scope="com::sun::star::sdb">XSingleSelectQueryComposer</type> which represents
+ the current settings (Command/CommandType/Filter/Order) of the given rowset.
+
+ As such an instance can be obtained from a <type scope="com::sun::star::sdb">Connection</type>
+ only the function searches for the connection the RowSet is using via connectRowset.
+ This implies that a connection will be set on the RowSet if needed.
+ (need to changes this sometimes ...)
+ */
+ OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > getCurrentSettingsComposer(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxRowSetProps,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory
+ );
+
+ /** transfer and translate properties between two FormComponents
+ @param _rxOld the source property set
+ @param _rxNew the destination property set
+ @param _rLocale the locale for converting number related properties
+ */
+ OOO_DLLPUBLIC_DBTOOLS void TransferFormComponentProperties(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxOld,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxNew,
+ const ::com::sun::star::lang::Locale& _rLocale
+ );
+
+ /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::INSERT
+ @param _rxCursorSet the property set
+ */
+ OOO_DLLPUBLIC_DBTOOLS sal_Bool canInsert(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet);
+ /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::UPDATE
+ @param _rxCursorSet the property set
+ */
+ OOO_DLLPUBLIC_DBTOOLS sal_Bool canUpdate(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet);
+ /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::DELETE
+ @param _rxCursorSet the property set
+ */
+ OOO_DLLPUBLIC_DBTOOLS sal_Bool canDelete(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet);
+
+ //----------------------------------------------------------------------------------
+ /** compose a complete table name from it's up to three parts, regarding to the database meta data composing rules
+ */
+ OOO_DLLPUBLIC_DBTOOLS ::rtl::OUString composeTableName( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxMetaData,
+ const ::rtl::OUString& _rCatalog,
+ const ::rtl::OUString& _rSchema,
+ const ::rtl::OUString& _rName,
+ sal_Bool _bQuote,
+ EComposeRule _eComposeRule);
+
+ /** composes a table name for usage in a SELECT statement
+
+ This includes quoting of the table as indicated by the connection's meta data, plus respecting
+ the settings "UseCatalogInSelect" and "UseSchemaInSelect", which might be present
+ in the data source which the connection belongs to.
+ */
+ OOO_DLLPUBLIC_DBTOOLS ::rtl::OUString composeTableNameForSelect(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::rtl::OUString& _rCatalog,
+ const ::rtl::OUString& _rSchema,
+ const ::rtl::OUString& _rName );
+
+ /** composes a table name for usage in a SELECT statement
+
+ This includes quoting of the table as indicated by the connection's meta data, plus respecting
+ the settings "UseCatalogInSelect" and "UseSchemaInSelect", which might be present
+ in the data source which the connection belongs to.
+ */
+ OOO_DLLPUBLIC_DBTOOLS ::rtl::OUString composeTableNameForSelect(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable );
+ //----------------------------------------------------------------------------------
+ /** compose the table name out of the property set which must support the properties from the service <member scope= "com::sun::star::sdbcx">table</member>
+ @param _xMetaData
+ The metadata from the connection.
+ @param _xTable
+ The table.
+ */
+ OOO_DLLPUBLIC_DBTOOLS ::rtl::OUString composeTableName(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _xMetaData,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable,
+ EComposeRule _eComposeRule,
+ bool _bSuppressCatalogName,
+ bool _bSuppressSchemaName,
+ bool _bQuote);
+
+ //----------------------------------------------------------------------------------
+ OOO_DLLPUBLIC_DBTOOLS sal_Int32 getSearchColumnFlag( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConn,
+ sal_Int32 _nDataType);
+ // return the datasource for the given datasource name
+ OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> getDataSource(const ::rtl::OUString& _rsDataSourceName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
+
+ /** search for a name that is NOT in the NameAcces
+ @param _rxContainer
+ the NameAccess container to search in
+ @param _rBaseName
+ the base name that should be used to create the new name
+ @param _bStartWithNumber
+ When <TRUE/> the name ends with number even when the name itself doesn't occur in the collection.
+ @return
+ A name which doesn't exist in the collection.
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ ::rtl::OUString createUniqueName(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _rxContainer,
+ const ::rtl::OUString& _rBaseName,
+ sal_Bool _bStartWithNumber = sal_True);
+
+ /** creates a unique name which is not already used in the given name array
+ */
+ OOO_DLLPUBLIC_DBTOOLS ::rtl::OUString createUniqueName(
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rNames,
+ const ::rtl::OUString& _rBaseName,
+ sal_Bool _bStartWithNumber = sal_True
+ );
+
+ /** create a name which is a valid SQL 92 identifier name
+ @param _rName the string which should be converted
+ @param _rSpecials @see com.sun.star.sdbc.XDatabaseMetaData.getExtraNameCharacters
+
+ @see isValidSQLName
+ */
+ OOO_DLLPUBLIC_DBTOOLS ::rtl::OUString convertName2SQLName(const ::rtl::OUString& _rName,const ::rtl::OUString& _rSpecials);
+
+ /** checks whether the given name is a valid SQL name
+
+ @param _rName the string which should be converted
+ @param _rSpecials @see com.sun.star.sdbc.XDatabaseMetaData.getExtraNameCharacters
+
+ @see convertName2SQLName
+ */
+ OOO_DLLPUBLIC_DBTOOLS sal_Bool isValidSQLName( const ::rtl::OUString& _rName, const ::rtl::OUString& _rSpecials );
+
+ OOO_DLLPUBLIC_DBTOOLS
+ void showError( const SQLExceptionInfo& _rInfo,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow>& _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
+
+ /** implements <method scope="com.sun.star.sdb">XRowUpdate::updateObject</method>
+ <p>The object which is to be set is analyzed, and in case it is a simlpe scalar type for which there
+ is another updateXXX method, this other method is used.</p>
+ @param _rxUpdatedObject
+ the interface to forward all updateXXX calls to (except updateObject)
+ @param _nColumnIndex
+ the column index to update
+ @param _rValue
+ the value to update
+ @return
+ <TRUE/> if the update request was successfully re-routed to one of the other updateXXX methods
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ sal_Bool implUpdateObject( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate >& _rxUpdatedObject,
+ const sal_Int32 _nColumnIndex,
+ const ::com::sun::star::uno::Any& _rValue) SAL_THROW ( ( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) );
+
+
+
+ /** ask the user for parameters if the prepared statement needs some and sets them in the prepared statement
+ @param _xConnection the connection must be able to create <type scope="com::sun::star::sdb">SingleSelectQueryComposer</type>s
+ @param _xPreparedStmt the prepared statement where the parameters could be set when needed
+ @param _aParametersSet contains which parameters have to asked for and which already have set.
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ void askForParameters( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >& _xComposer,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters>& _xParameters,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxHandler,
+ const ::std::bit_vector& _aParametersSet = ::std::bit_vector());
+
+ /** call the appropiate set method for the specific sql type @see com::sun::star::sdbc::DataType
+ @param _xParams the parameters where to set the value
+ @param parameterIndex the index of the parameter, 1 based
+ @param x the value to set
+ @param sqlType the corresponding sql type @see com::sun::star::sdbc::DataType
+ @param scale the scale of the sql type can be 0
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ void setObjectWithInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters>& _xParameters,
+ sal_Int32 parameterIndex,
+ const ::com::sun::star::uno::Any& x,
+ sal_Int32 sqlType,
+ sal_Int32 scale=0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ /** call the appropiate set method for the specific sql type @see com::sun::star::sdbc::DataType
+ @param _xParams the parameters where to set the value
+ @param parameterIndex the index of the parameter, 1 based
+ @param x the value to set
+ @param sqlType the corresponding sql type @see com::sun::star::sdbc::DataType
+ @param scale the scale of the sql type can be 0
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ void setObjectWithInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters>& _xParameters,
+ sal_Int32 parameterIndex,
+ const ::connectivity::ORowSetValue& x,
+ sal_Int32 sqlType,
+ sal_Int32 scale=0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+
+ /** implements <method scope="com.sun.star.sdb">XParameters::setObject</method>
+ <p>The object which is to be set is analyzed, and in case it is a simlpe scalar type for which there
+ is another setXXX method, this other method is used.</p>
+ @param _rxParameters
+ the interface to forward all setXXX calls to (except setObject)
+ @param _nColumnIndex
+ the column index to update
+ @param _rValue
+ the value to update
+ @return
+ <TRUE/> if the update request was successfully re-routed to one of the other updateXXX methods
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ sal_Bool implSetObject( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters>& _rxParameters,
+ const sal_Int32 _nColumnIndex,
+ const ::com::sun::star::uno::Any& _rValue) SAL_THROW ( ( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException ) );
+
+ /** creates the standard sql create table statement without the key part.
+ @param descriptor
+ The descriptor of the new table.
+ @param _xConnection
+ The connection.
+ @param _bAddScale
+ The scale will also be added when the value is 0.
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ ::rtl::OUString createStandardCreateStatement( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
+ ISQLStatementHelper* _pHelper,
+ const ::rtl::OUString& _sCreatePattern = ::rtl::OUString());
+
+ /** creates the standard sql statement for the key part of a create table statement.
+ @param descriptor
+ The descriptor of the new table.
+ @param _xConnection
+ The connection.
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ ::rtl::OUString createStandardKeyStatement( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
+
+ /** creates the standard sql statement for the column part of a create table statement.
+ @param _pHelper
+ Allow to add special SQL constructs.
+ @param descriptor
+ The descriptor of the column.
+ @param _xConnection
+ The connection.
+ @param _pHelper
+ Allow to add special SQL constructs.
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ ::rtl::OUString createStandardColumnPart( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection
+ ,ISQLStatementHelper* _pHelper = NULL
+ ,const ::rtl::OUString& _sCreatePattern = ::rtl::OUString());
+
+ /** creates a SQL CREATE TABLE statement
+
+ @param descriptor
+ The descriptor of the new table.
+ @param _xConnection
+ The connection.
+ @param _pHelper
+ Allow to add special SQL constructs.
+ @param _sCreatePattern
+
+ @return
+ The CREATE TABLE statement.
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ ::rtl::OUString createSqlCreateTableStatement( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection
+ ,ISQLStatementHelper* _pHelper = NULL
+ ,const ::rtl::OUString& _sCreatePattern = ::rtl::OUString());
+
+ /** creates a SDBC column with the help of getColumns.
+ @param _xTable
+ The table.
+ @param _rName
+ The name of the column.
+ @param _bCase
+ Is the column case sensitive.
+ @param _bQueryForInfo
+ If <TRUE/> the autoincrement and currency field will be read from the meta data, otherwise the following parameters will be used instead
+ @param _bIsAutoIncrement
+ <TRUE/> if the column is an autoincrement.
+ @param _bIsCurrency
+ <TRUE/> if the column is a currency field.
+ @param _nDataType
+ The data type of the column.
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>
+ createSDBCXColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
+ const ::rtl::OUString& _rName,
+ sal_Bool _bCase,
+ sal_Bool _bQueryForInfo = sal_True,
+ sal_Bool _bIsAutoIncrement = sal_False,
+ sal_Bool _bIsCurrency = sal_False,
+ sal_Int32 _nDataType = com::sun::star::sdbc::DataType::OTHER);
+
+ /** tries to locate the corresponding DataDefinitionSupplier for the given url and connection
+ @param _rsUrl
+ The URL used to connect to the database.
+ @param _xConnection
+ The connection used to find the correct driver.
+ @param _rxFactory
+ Used to create the drivermanager.
+ @return
+ The datadefintion object.
+ */
+ OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier> getDataDefinitionByURLAndConnection(
+ const ::rtl::OUString& _rsUrl,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
+
+ /** returns the table privileges to the given parameters
+ @param _xMetaData
+ The meta data.
+ @param _sCatalog
+ contains the catalog name
+ @param _sSchema
+ contains the schema name
+ @param _sTable
+ contains the table name
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ sal_Int32 getTablePrivileges(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _xMetaData,
+ const ::rtl::OUString& _sCatalog,
+ const ::rtl::OUString& _sSchema,
+ const ::rtl::OUString& _sTable);
+
+ typedef ::std::pair<sal_Bool,sal_Bool> TBoolPair;
+ typedef ::std::pair< TBoolPair,sal_Int32 > ColumnInformation;
+ typedef ::std::multimap< ::rtl::OUString, ColumnInformation, ::comphelper::UStringMixLess> ColumnInformationMap;
+ /** collects the information about auto increment, currency and data type for the given column name.
+ The column must be quoted, * is also valid.
+ @param _xConnection
+ The connection.
+ @param _sComposedTableName
+ The quoted table name. ccc.sss.ttt
+ @param _sName
+ The name of the column, or *
+ @param _rInfo
+ The information about the column(s).
+ */
+ OOO_DLLPUBLIC_DBTOOLS
+ void collectColumnInformation( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
+ const ::rtl::OUString& _sComposedTableName,
+ const ::rtl::OUString& _rName,
+ ColumnInformationMap& _rInfo);
+
+
+ /** adds a boolean comparison clause to the given SQL predicate
+
+ @param _rExpression
+ the expression which is to be compared with a boolean value
+ @param _bValue
+ the boolean value which the expression is to be compared with
+ @param _nBooleanComparisonMode
+ the boolean comparison mode to be used. Usually obtained from
+ a css.sdb.DataSource's Settings member.
+ @param _out_rSQLPredicate
+ the buffer to which the comparison predicate will be appended
+ */
+ OOO_DLLPUBLIC_DBTOOLS void getBoleanComparisonPredicate(
+ const ::rtl::OUString& _rExpression,
+ const sal_Bool _bValue,
+ const sal_Int32 _nBooleanComparisonMode,
+ ::rtl::OUStringBuffer& _out_rSQLPredicate
+ );
+
+//.........................................................................
+} // namespace dbtools
+//.........................................................................
+
+#endif // _CONNECTIVITY_DBTOOLS_HXX_
+
diff --git a/connectivity/inc/connectivity/dbtoolsdllapi.hxx b/connectivity/inc/connectivity/dbtoolsdllapi.hxx
new file mode 100644
index 000000000000..6044a53e3328
--- /dev/null
+++ b/connectivity/inc/connectivity/dbtoolsdllapi.hxx
@@ -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.
+ *
+************************************************************************/
+
+#ifndef INCLUDED_CONNECTIVITY_DBTOOLSDLLAPI_HXX
+#define INCLUDED_CONNECTIVITY_DBTOOLSDLLAPI_HXX
+
+#include "sal/config.h"
+
+#include "sal/types.h"
+
+#if defined OOO_DLLIMPLEMENTATION_DBTOOLS
+#define OOO_DLLPUBLIC_DBTOOLS SAL_DLLPUBLIC_EXPORT
+#else
+#define OOO_DLLPUBLIC_DBTOOLS SAL_DLLPUBLIC_IMPORT
+#endif
+
+#endif
diff --git a/connectivity/inc/connectivity/filtermanager.hxx b/connectivity/inc/connectivity/filtermanager.hxx
new file mode 100644
index 000000000000..71494de67b38
--- /dev/null
+++ b/connectivity/inc/connectivity/filtermanager.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_FILTERMANAGER_HXX
+#define CONNECTIVITY_FILTERMANAGER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdb/XSQLQueryComposer.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+/** === end UNO includes === **/
+#include <rtl/ustring.hxx>
+
+#include <vector>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+//........................................................................
+namespace dbtools
+{
+//........................................................................
+
+ //====================================================================
+ //= FilterManager
+ //====================================================================
+ /** manages the filter of a database component with filter properties
+
+ The idea is that the filter which a database component actually really uses is composed of several single
+ filter components (which all are conjunctive).
+
+ First, there is a component which is visible to the clients of the database component itself - if they ask
+ the database component for the Filter property, they will get this public filter.
+
+ Second, there is an implicit filter, which is (to be) created from the MasterFields and DetailFields
+ property of the database component, if the latter denote columns.<br/>
+ For instance, if there is a link-pair CustomerID->cid, where |CustomerID| is a column of the master
+ database component, and |cid| is a column of the detail database component (the database component we're responsible for), then there will
+ be an implicit filter "cid = :param_cid_link" (or something like this), which is never visible
+ to the clients of the database component, but nevertheless needs to be propagated to the aggregated RowSet.<br/>
+ Actually, this implicit filter is maintained by the FormParameterManager.
+
+ Potentially, there could be more filter components (for instance, you could imagine database component
+ controls which act as live filter, which could be implemented with a third component), but
+ at the moment there are only these two.
+ */
+ class OOO_DLLPUBLIC_DBTOOLS FilterManager
+ {
+ public:
+ enum FilterComponent
+ {
+ fcPublicFilter = 0, // the filter which is to be published as "Filter" property of the database component
+ fcLinkFilter, // the filter part which is implicitly created for a database component when connecting
+ // master and detail database components via column names
+
+ FC_COMPONENT_COUNT // boundary delimiter, not to be used from outside
+ };
+
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xComponentAggregate;
+ ::std::vector< ::rtl::OUString > m_aFilterComponents;
+ sal_Bool m_bApplyPublicFilter;
+
+ public:
+ /// ctor
+ explicit FilterManager(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+
+ /// late ctor
+ void initialize(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxComponentAggregate );
+
+ /// makes the object forgetting the references to the database component
+ void dispose( );
+
+ const ::rtl::OUString& getFilterComponent( FilterComponent _eWhich ) const;
+ void setFilterComponent( FilterComponent _eWhich, const ::rtl::OUString& _rComponent );
+
+ inline sal_Bool isApplyPublicFilter( ) const { return m_bApplyPublicFilter; }
+ void setApplyPublicFilter( sal_Bool _bApply );
+
+ private:
+ /** retrieves a filter which is a conjunction of all single filter components
+ */
+ ::rtl::OUString getComposedFilter( ) const;
+
+ /** appends one filter component to the statement in our composer
+ */
+ void appendFilterComponent( ::rtl::OUString& /* [inout] */ _rAppendTo, const ::rtl::OUString& _rComponent ) const;
+
+ /// checks whether there is only one (or even no) non-empty filter component
+ bool isThereAtMostOneComponent( ::rtl::OUString& _rOnlyComponent ) const;
+
+ /// returns the index of the first filter component which should be considered when building the composed filter
+ inline sal_Int32 getFirstApplicableFilterIndex() const
+ {
+ return m_bApplyPublicFilter ? fcPublicFilter : fcPublicFilter + 1;
+ }
+ };
+
+//........................................................................
+} // namespacefrm
+//........................................................................
+
+#endif // CONNECTIVITY_FORMFILTERMANAGER_HXX
+
diff --git a/connectivity/inc/connectivity/formattedcolumnvalue.hxx b/connectivity/inc/connectivity/formattedcolumnvalue.hxx
new file mode 100644
index 000000000000..d9bb8b49973f
--- /dev/null
+++ b/connectivity/inc/connectivity/formattedcolumnvalue.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_FORMATTEDCOLUMNVALUE_HXX
+#define CONNECTIVITY_FORMATTEDCOLUMNVALUE_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdb/XColumn.hpp>
+#include <com/sun/star/sdb/XColumnUpdate.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+/** === end UNO includes === **/
+
+#include <boost/noncopyable.hpp>
+
+#include <memory>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace comphelper { class ComponentContext; }
+
+//........................................................................
+namespace dbtools
+{
+//........................................................................
+
+ struct FormattedColumnValue_Data;
+ //====================================================================
+ //= FormattedColumnValue
+ //====================================================================
+ /** a class which helps retrieving and setting the value of a database column
+ as formatted string.
+ */
+ class OOO_DLLPUBLIC_DBTOOLS FormattedColumnValue : public ::boost::noncopyable
+ {
+ public:
+ /** constructs an instance
+
+ The format key for the string value exchange is taken from the given column object.
+ If it has a non-<NULL/> property value <code>FormatKey</code>, this key is taken.
+ Otherwise, a default format matching the column type is determined.
+
+ The locale of this fallback format is the current system locale.
+
+ The number formats supplier is determined from the given <code>RowSet</code>, by
+ examining its <code>ActiveConnection</code>.
+ */
+ FormattedColumnValue(
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& _rxRowSet,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn
+ );
+
+ /** constructs an instance
+
+ The format key for the string value exchange is taken from the given column object.
+ If it has a non-<NULL/> property value <code>FormatKey</code>, this key is taken.
+ Otherwise, a default format matching the column type is determined.
+
+ The locale of this fallback format is the current system locale.
+ */
+ FormattedColumnValue(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& i_rNumberFormatter,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& i_rColumn
+ );
+
+ // note that all methods of this class need to be virtual, since it's
+ // used in a load-on-demand context in module SVX
+
+ virtual ~FormattedColumnValue();
+
+ virtual void clear();
+
+ // access to the details of the formatting we determined
+ virtual sal_Int32 getFormatKey() const;
+ virtual sal_Int32 getFieldType() const;
+ virtual sal_Int16 getKeyType() const;
+ virtual bool isNumericField() const;
+ virtual const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >&
+ getColumn() const;
+ virtual const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumnUpdate >&
+ getColumnUpdate() const;
+
+ virtual bool setFormattedValue( const ::rtl::OUString& _rFormattedStringValue ) const;
+ virtual ::rtl::OUString getFormattedValue() const;
+
+ private:
+ ::std::auto_ptr< FormattedColumnValue_Data > m_pData;
+ };
+
+//........................................................................
+} // namespace dbtools
+//........................................................................
+
+#endif // CONNECTIVITY_FORMATTEDCOLUMNVALUE_HXX
diff --git a/connectivity/inc/connectivity/parameters.hxx b/connectivity/inc/connectivity/parameters.hxx
new file mode 100644
index 000000000000..75b314e770f3
--- /dev/null
+++ b/connectivity/inc/connectivity/parameters.hxx
@@ -0,0 +1,426 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_PARAMETERS_HXX
+#define CONNECTIVITY_PARAMETERS_HXX
+
+#include <map>
+#include <vector>
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/XAggregation.hpp>
+#include <com/sun/star/form/XDatabaseParameterListener.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+/** === end UNO includes === **/
+
+#include "connectivity/dbtoolsdllapi.hxx"
+#include "connectivity/paramwrapper.hxx"
+#include <unotools/sharedunocomponent.hxx>
+#include <comphelper/implementationreference.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+
+//........................................................................
+namespace dbtools
+{
+//........................................................................
+
+ typedef ::utl::SharedUNOComponent< ::com::sun::star::sdb::XSingleSelectQueryComposer, ::utl::DisposableComponent >
+ SharedQueryComposer;
+
+ //====================================================================
+ //= ParameterManager
+ //====================================================================
+ class FilterManager;
+ class OOO_DLLPUBLIC_DBTOOLS ParameterManager
+ {
+ public:
+ /// classifies the origin of the data to fill a parameter
+ enum ParameterClassification
+ {
+ /** parameters which are filled from the master-detail relationship, where the detail
+ name is an explicit parameter name
+ */
+ eLinkedByParamName,
+ /** parameters which are filled from the master-detail relationship, where the detail
+ name is a column name, so an implicit parameter had to be generated for it
+ */
+ eLinkedByColumnName,
+ /** parameters which are filled externally (i.e. by XParamaters::setXXX, or by the parameter listeners)
+ */
+ eFilledExternally
+ };
+ /** meta data about an inner parameter
+ */
+ private:
+ struct ParameterMetaData
+ {
+ /// the type of the parameter
+ ParameterClassification eType;
+ /// the column object for this parameter, as returned by the query composer
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ xComposerColumn;
+ /// the indicies of inner parameters which need to be filled when this concrete parameter is set
+ ::std::vector< sal_Int32 > aInnerIndexes;
+
+ /// default ctor
+ ParameterMetaData()
+ :eType( eFilledExternally )
+ {
+ }
+
+ /// ctor with composer column
+ ParameterMetaData( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn )
+ :eType ( eFilledExternally )
+ ,xComposerColumn ( _rxColumn )
+ {
+ }
+ };
+
+ typedef ::std::map< ::rtl::OUString, ParameterMetaData > ParameterInformation;
+
+ private:
+ ::osl::Mutex& m_rMutex;
+ ::cppu::OInterfaceContainerHelper m_aParameterListeners;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::beans::XPropertySet >
+ m_xComponent; // the database component whose parameters we're handling
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >
+ m_xAggregatedRowSet; // the aggregated row set - necessary for unwrapped access to some interfaces
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters >
+ m_xInnerParamUpdate; // write access to the inner parameters
+ SharedQueryComposer m_xComposer; // query composer wrapping the statement which the *aggregate* is based on
+ SharedQueryComposer m_xParentComposer; // query composer wrapping the statement of our parent database component
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >
+ m_xInnerParamColumns; // index access to the parameter columns, as got from the query composer
+
+ ::dbtools::param::ParametersContainerRef
+ m_pOuterParameters; // the container of parameters which still need to be filled in by
+ // external instances
+ sal_Int32 m_nInnerCount; // overall number of parameters as required by the database component's aggregate
+
+ ParameterInformation m_aParameterInformation;
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aMasterFields;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aDetailFields;
+
+ ::rtl::OUString m_sIdentifierQuoteString;
+ ::rtl::OUString m_sSpecialCharacters;
+
+ ::std::vector< bool > m_aParametersVisited;
+
+ bool m_bUpToDate;
+
+ public:
+ /** ctor
+ */
+ explicit ParameterManager(
+ ::osl::Mutex& _rMutex,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+
+ /// late ctor
+ void initialize(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxComponent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >& _rxComponentAggregate
+ );
+
+ /// makes the object forgetting the references to the database component
+ void dispose( );
+
+ /// clears the instance data
+ void clearAllParameterInformation();
+
+ /// checks whether the parameter information are up-to-date
+ inline bool isUpToDate() const { return m_bUpToDate; }
+
+ /** updates all parameter information represented by the instance
+ */
+ void updateParameterInfo( FilterManager& _rFilterManager );
+
+ /** fills parameter values, as extensive as possible
+
+ <p>In particular, all values which can be filled from the master-detail relationship of
+ between our database component and it's parent are filled in.</p>
+
+ @param _rxCompletionHandler
+ an interaction handler which should be used to fill all parameters which
+ cannot be filled by other means. May be <NULL/>
+ @param _rClearForNotifies
+ the mutex guard to be (temporarily) cleared for notifications
+
+ @precond
+ the instance is alive, i.e. <member>isAlive</member> returns <TRUE/>
+
+ @return
+ <TRUE/> if and only if the parameter filling has <em>not</em> been cancelled by the user
+ */
+ bool fillParameterValues(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxCompletionHandler,
+ ::osl::ResettableMutexGuard& _rClearForNotifies
+ );
+
+ /** sets all parameter values to null (via <member>XParameters::setNull</member>)
+
+ @precond
+ the instance is alive, i.e. <member>isAlive</member> returns <TRUE/>
+ */
+ void setAllParametersNull() SAL_THROW( ( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException ) );
+
+ /** resets all detail columns which are, via a parameter, linked to a master column, to
+ the value of this master column.
+
+ For instance, if the database component is bound to a statement <code>SELECT * from invoice where inv_id = :cid</code>,
+ and there is <em>one</em> master-detail link from
+
+ @precond
+ the instance is alive, i.e. <member>isAlive</member> returns <TRUE/>
+ */
+ void resetParameterValues() SAL_THROW(());
+
+ /** tells the object that it's database component is being disposed
+
+ The object then fires the <member>XEventListener::disposing</member> notification to
+ the parameter listeners
+ */
+ void disposing( const ::com::sun::star::lang::EventObject& _rDisposingEvent );
+
+ /** adds the given listener to the list of parameter listeners
+ */
+ void addParameterListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener >& _rxListener
+ );
+
+ /** removes the given listener from the list of parameter listeners
+ */
+ void removeParameterListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener >& _rxListener
+ );
+
+ // XParameters equivalents
+ void setNull ( sal_Int32 _nIndex, sal_Int32 sqlType);
+ void setObjectNull ( sal_Int32 _nIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName);
+ void setBoolean ( sal_Int32 _nIndex, sal_Bool x);
+ void setByte ( sal_Int32 _nIndex, sal_Int8 x);
+ void setShort ( sal_Int32 _nIndex, sal_Int16 x);
+ void setInt ( sal_Int32 _nIndex, sal_Int32 x);
+ void setLong ( sal_Int32 _nIndex, sal_Int64 x);
+ void setFloat ( sal_Int32 _nIndex, float x);
+ void setDouble ( sal_Int32 _nIndex, double x);
+ void setString ( sal_Int32 _nIndex, const ::rtl::OUString& x);
+ void setBytes ( sal_Int32 _nIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x);
+ void setDate ( sal_Int32 _nIndex, const ::com::sun::star::util::Date& x);
+ void setTime ( sal_Int32 _nIndex, const ::com::sun::star::util::Time& x);
+ void setTimestamp ( sal_Int32 _nIndex, const ::com::sun::star::util::DateTime& x);
+ void setBinaryStream ( sal_Int32 _nIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& x, sal_Int32 length);
+ void setCharacterStream ( sal_Int32 _nIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& x, sal_Int32 length);
+ void setObject ( sal_Int32 _nIndex, const ::com::sun::star::uno::Any& x);
+ void setObjectWithInfo ( sal_Int32 _nIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale);
+ void setRef ( sal_Int32 _nIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef>& x);
+ void setBlob ( sal_Int32 _nIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob>& x);
+ void setClob ( sal_Int32 _nIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob>& x);
+ void setArray ( sal_Int32 _nIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray>& x);
+ void clearParameters();
+
+ private:
+ /// checkes whether the object is already initialized, and not yet disposed
+ inline bool isAlive() const { return m_xComponent.get().is() && m_xInnerParamUpdate.is(); }
+
+ /** creates a filter expression from a master-detail link where the detail denotes a column name
+ */
+ ::rtl::OUString
+ createFilterConditionFromColumnLink(
+ const ::rtl::OUString& /* [in] */ _rMasterColumn,
+ const ::rtl::OUString& /* [in] */ _rDetailColumn,
+ ::rtl::OUString& /* [out] */ _rNewParamName
+ );
+
+ /** initializes our query composer, and the collection of inner parameter columns
+
+ @param _rxComponent
+ the database component to initialize from. Must not be <NULL/>
+ @return
+ <TRUE/> if and only if the initialization was successfull
+
+ @postcond
+ if and only if <TRUE/> is returned, then <member>m_xInnerParamColumns</member> contains the collection of
+ inner parameters
+ */
+ bool initializeComposerByComponent(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxComponent
+ );
+
+ /** collects initial meta information about inner paramaters (i.e. it initially fills
+ <member>m_aParameterInformation</member>).
+
+ @param _bSecondRun
+ if <TRUE/>, this is the second run, because we ourself previously extended the filter of
+ the RowSet
+
+ @precond
+ <member>m_xInnerParamColumns</member> is not <NULL/>
+ */
+ void collectInnerParameters( bool _bSecondRun );
+
+ /** analyzes the master-detail links for our database component, and initializes m_aMasterFields and m_aDetailFields
+
+ @param _rFilterManager
+ the filter manager of the database component
+ @param _rColumnsInLinkDetails
+ will be set to <TRUE/> if and only if there were link pairs where the detail field denoted
+ a column name of our database component
+
+ @precond
+ the instance is alive, i.e. <member>isAlive</member> returns <TRUE/>
+ */
+ void analyzeFieldLinks( FilterManager& _rFilterManager, bool& /* [out] */ _rColumnsInLinkDetails );
+
+ /** classifies the link pairs
+
+ @param _rxParentColumns
+ the columns of the parent database component
+
+ @param _rxColumns
+ the columns of our own database component
+
+ @param _out_rAdditionalFilterComponents
+ the additional filter components which are required for master-detail relationships where
+ the detail part denotes a column name. In such a case, an additional filter needs to be created,
+ containing a new parameter.
+
+ @precond
+ <member>m_aMasterFields</member> and <member>m_aDetailFields</member> have the same length
+ */
+ void classifyLinks(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxParentColumns,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumns,
+ ::std::vector< ::rtl::OUString >& _out_rAdditionalFilterComponents
+ ) SAL_THROW(( ::com::sun::star::uno::Exception ));
+
+ /** finalizes our <member>m_pOuterParameters</member> so that it can be used for
+ external parameter listeners
+
+ @precond
+ <member>m_pOuterParameters</member> is <NULL/>
+ @precond
+ <member>m_xInnerParamUpdate</member> is not <NULL/>
+ */
+ void createOuterParameters();
+
+ /** fills in the parameters values which result from the master-detail relationship
+ between the database component and it's parent
+
+ @param _rxParentColumns
+ the columns of the parameter database component. Must not be <NULL/>
+ @precond
+ the instance is alive, i.e. <member>isAlive</member> returns <TRUE/>
+ */
+ void fillLinkedParameters(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxParentColumns
+ );
+
+ /** completes all missing parameters via an interaction handler
+
+ @precond
+ the instance is alive, i.e. <member>isAlive</member> returns <TRUE/>
+
+ @return
+ <TRUE/> if and only if the parameter filling has <em>not</em> been cancelled by the user
+ */
+ bool completeParameters(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxCompletionHandler,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > _rxConnection
+ );
+
+ /** asks the parameter listeners to fill in final values
+
+ @precond
+ the instance is alive, i.e. <member>isAlive</member> returns <TRUE/>
+
+ @return
+ <TRUE/> if and only if the parameter filling has <em>not</em> been cancelled by the user
+ */
+ bool consultParameterListeners( ::osl::ResettableMutexGuard& _rClearForNotifies );
+
+ /** mark an externally filled parameter asvisited
+ */
+ void externalParameterVisited( sal_Int32 _nIndex );
+
+ private:
+ /** retrieves the columns of the parent database component
+
+ @precond
+ the instance is alive, i.e. <member>isAlive</member> returns <TRUE/>
+ @return
+ <TRUE/> if and only if the columns could be successfully retrieved
+ */
+ bool getParentColumns(
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& /* [out] */ _out_rxParentColumns,
+ bool _bFromComposer
+ );
+
+ /** retrieves the columns of our database component
+
+ @param _bFromComposer
+ if <TRUE/>, the columns are obtained from the composer, else from the living database component itself
+ @return
+ <TRUE/> if and only if the columns could be successfully retrieved
+ */
+ bool getColumns(
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& /* [out] */ _rxColumns,
+ bool _bFromComposer
+ ) SAL_THROW(( ::com::sun::star::uno::Exception ));
+
+ /** retrieves the active connection of the database component
+ */
+ bool getConnection(
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& /* [out] */ _rxConnection
+ );
+
+ /** caches some info about the connection of our database component
+ */
+ void cacheConnectionInfo() SAL_THROW(( ));
+
+ private:
+ ParameterManager(); // never implemented
+ ParameterManager( const ParameterManager& ); // never implemented
+ ParameterManager& operator=( const ParameterManager& ); // never implemented
+ };
+
+//........................................................................
+} // namespacefrm
+//........................................................................
+
+#endif // CONNECTIVITY_PARAMETERS_HXX
+
diff --git a/connectivity/inc/connectivity/paramwrapper.hxx b/connectivity/inc/connectivity/paramwrapper.hxx
new file mode 100644
index 000000000000..34e2fef67bbc
--- /dev/null
+++ b/connectivity/inc/connectivity/paramwrapper.hxx
@@ -0,0 +1,208 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_PARAMWRAPPER_HXX
+#define CONNECTIVITY_PARAMWRAPPER_HXX
+
+#include "connectivity/dbtoolsdllapi.hxx"
+#include <connectivity/FValue.hxx>
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/uno3.hxx>
+#include <comphelper/broadcasthelper.hxx>
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/propshlp.hxx>
+#include <cppuhelper/compbase2.hxx>
+
+#include <memory>
+#include <vector>
+
+//........................................................................
+namespace dbtools
+{
+namespace param
+{
+//........................................................................
+
+ //====================================================================
+ //= ParameterWrapper
+ //====================================================================
+ /** wraps a parameter column as got from an SQLQueryComposer, so that it has an additional
+ property "Value", which is forwarded to an XParameters interface
+ */
+ class OOO_DLLPUBLIC_DBTOOLS ParameterWrapper :public ::cppu::OWeakObject
+ ,public ::comphelper::OMutexAndBroadcastHelper
+ ,public ::cppu::OPropertySetHelper
+ {
+ private:
+ typedef ::cppu::OWeakObject UnoBase;
+ typedef ::cppu::OPropertySetHelper PropertyBase;
+
+ private:
+ /// the most recently set value of the parameter
+ ::connectivity::ORowSetValue m_aValue;
+ /// the positions (in our m_xValueDestination) at which the value should be set (0-based!)
+ ::std::vector< sal_Int32 > m_aIndexes;
+
+ /// the "delegator" column to which standard property requests are forwarded
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xDelegator;
+ /// the property set info for our delegator
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > m_xDelegatorPSI;
+ /// the component taking the value
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters > m_xValueDestination;
+ /// helper for implementing XPropertySetInfo
+ ::std::auto_ptr< ::cppu::OPropertyArrayHelper > m_pInfoHelper;
+
+
+ public:
+ const ::connectivity::ORowSetValue& Value() const { return m_aValue; }
+ ::connectivity::ORowSetValue& Value() { return m_aValue; }
+
+ public:
+ ParameterWrapper(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn
+ );
+
+ ParameterWrapper(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters >& _rxAllParameters,
+ const ::std::vector< sal_Int32 >& _rIndexes
+ );
+
+ DECLARE_XINTERFACE()
+ DECLARE_XTYPEPROVIDER()
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertySetHelper
+ 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;
+
+ // pseudo-XComponent
+ virtual void SAL_CALL dispose();
+
+ protected:
+ virtual ~ParameterWrapper();
+
+ // disambiguations
+ using ::cppu::OPropertySetHelper::getFastPropertyValue;
+
+ private:
+ ::rtl::OUString impl_getPseudoAggregatePropertyName( sal_Int32 _nHandle ) const;
+
+ private:
+ ParameterWrapper(); // not implemented
+ };
+
+ //====================================================================
+ //= ParameterWrapperContainer
+ //====================================================================
+ typedef ::std::vector< ::rtl::Reference< ParameterWrapper > > Parameters;
+
+ //====================================================================
+ //= ParameterWrapperContainer
+ //====================================================================
+ typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::container::XIndexAccess
+ , ::com::sun::star::container::XEnumerationAccess
+ > ParameterWrapperContainer_Base;
+
+ /// class for the parameter event @see approveParameter
+ class OOO_DLLPUBLIC_DBTOOLS ParameterWrapperContainer :
+ public ParameterWrapperContainer_Base
+ {
+ private:
+ ::osl::Mutex m_aMutex;
+ Parameters m_aParameters;
+
+ protected:
+ virtual ~ParameterWrapperContainer();
+
+ public:
+ /** creates an empty container
+ */
+ ParameterWrapperContainer();
+
+ /** creates a container from a SingleSelectQuerAnalyzer's parameter columns
+
+ Note that here, the simple constructor of the ParameterWrapper will be used, which does not
+ use a XParameters instance to forward values to, but only remembers the values itself.
+ */
+ ParameterWrapperContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >& _rxComposer );
+
+ // ::com::sun::star::container::XElementAccess
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL hasElements() throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::container::XEnumerationAccess
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration() throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::container::XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount() throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 _rIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
+
+ public:
+ const Parameters& getParameters() { return m_aParameters; }
+
+ const ::connectivity::ORowSetValue& operator[]( size_t _index ) const { return m_aParameters[ _index ]->Value(); }
+ ::connectivity::ORowSetValue& operator[]( size_t _index ) { return m_aParameters[ _index ]->Value(); }
+
+ /** adds an ParameterWrapper to the end of the array
+ */
+ void push_back( ParameterWrapper* _pParameter )
+ {
+ m_aParameters.push_back( _pParameter );
+ }
+
+ size_t size() const { return m_aParameters.size(); }
+
+ protected:
+ // XComponent
+ virtual void SAL_CALL disposing();
+
+ private:
+ void impl_checkDisposed_throw();
+ };
+
+ //====================================================================
+ //= ParamatersContainer
+ //====================================================================
+ typedef ::rtl::Reference< ParameterWrapperContainer > ParametersContainerRef;
+
+//........................................................................
+} } // namespace dbtools::param
+//........................................................................
+
+#endif // CONNECTIVITY_PARAMWRAPPER_HXX
diff --git a/connectivity/inc/connectivity/predicateinput.hxx b/connectivity/inc/connectivity/predicateinput.hxx
new file mode 100644
index 000000000000..5041fd30c060
--- /dev/null
+++ b/connectivity/inc/connectivity/predicateinput.hxx
@@ -0,0 +1,126 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_PREDICATEINPUT_HXX
+#define CONNECTIVITY_PREDICATEINPUT_HXX
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/i18n/XLocaleData.hpp>
+#include <connectivity/sqlparse.hxx>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+//.........................................................................
+namespace dbtools
+{
+//.........................................................................
+
+ //=====================================================================
+ //= OPredicateInputController
+ //=====================================================================
+ /** A class which allows input of an SQL predicate for a row set column
+ into a edit field.
+ */
+ class OOO_DLLPUBLIC_DBTOOLS OPredicateInputController
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ m_xConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >
+ m_xFormatter;
+ ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData >
+ m_xLocaleData;
+
+ ::connectivity::OSQLParser
+ m_aParser;
+
+ public:
+ OPredicateInputController(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::connectivity::IParseContext* _pParseContext = NULL
+ );
+
+ /** transforms a "raw" predicate value (usually obtained from a user input) into a valid predicate for the given column
+ @param _rPredicateValue
+ The text to normalize.
+ @param _rxField
+ The field for which the text should be a predicate value.
+ @param _pErrorMessage
+ If not <NULL/>, and a parsing error occurs, the error message will be copied to the string the argument
+ points to.
+ */
+ sal_Bool normalizePredicateString(
+ ::rtl::OUString& _rPredicateValue,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField,
+ ::rtl::OUString* _pErrorMessage = NULL
+ ) const;
+
+ /** get's a value of the predicate which can be used in a WHERE clause.
+ @param _rPredicateValue
+ the value which has been normalized using normalizePredicateString
+ @param _rxField
+ is the field for which a predicate is to be entered
+ @param _bForStatementUse
+ If <TRUE/>, the returned value can be used in an SQL statement. If <FALSE/>, it can be used
+ for instance for setting parameter values.
+ @param _pErrorMessage
+ If not <NULL/>, and a parsing error occurs, the error message will be copied to the string the argument
+ points to.
+ @see normalizePredicateString
+ */
+ ::rtl::OUString getPredicateValue(
+ const ::rtl::OUString& _rPredicateValue,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & _rxField,
+ sal_Bool _bForStatementUse,
+ ::rtl::OUString* _pErrorMessage = NULL
+ ) const;
+
+ private:
+ ::connectivity::OSQLParseNode* implPredicateTree(
+ ::rtl::OUString& _rErrorMessage,
+ const ::rtl::OUString& _rStatement,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & _rxField
+ ) const;
+
+ sal_Bool getSeparatorChars(
+ const ::com::sun::star::lang::Locale& _rLocale,
+ sal_Unicode& _rDecSep,
+ sal_Unicode& _rThdSep
+ ) const;
+ };
+
+//.........................................................................
+} // namespace dbtools
+//.........................................................................
+
+#endif // CONNECTIVITY_PREDICATEINPUT_HXX
+
diff --git a/connectivity/inc/connectivity/sdbcx/IRefreshable.hxx b/connectivity/inc/connectivity/sdbcx/IRefreshable.hxx
new file mode 100644
index 000000000000..de3a2b28670c
--- /dev/null
+++ b/connectivity/inc/connectivity/sdbcx/IRefreshable.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_SDBCX_IREFRESHABLE_HXX_
+#define _CONNECTIVITY_SDBCX_IREFRESHABLE_HXX_
+
+#include "connectivity/CommonTools.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ namespace sdbcx
+ {
+ class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE IRefreshableGroups
+ {
+ public:
+ virtual void refreshGroups() = 0;
+ };
+
+ class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE IRefreshableUsers
+ {
+ public:
+ virtual void refreshUsers() = 0;
+ };
+
+ class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE IRefreshableColumns
+ {
+ public:
+ virtual void refreshColumns() = 0;
+ };
+ }
+}
+#endif //_CONNECTIVITY_SDBCX_IREFRESHABLE_HXX_
+
diff --git a/connectivity/inc/connectivity/sdbcx/VCatalog.hxx b/connectivity/inc/connectivity/sdbcx/VCatalog.hxx
new file mode 100644
index 000000000000..672b9f4cfea6
--- /dev/null
+++ b/connectivity/inc/connectivity/sdbcx/VCatalog.hxx
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_SDBCX_CATALOG_HXX_
+#define _CONNECTIVITY_SDBCX_CATALOG_HXX_
+
+#include <osl/diagnose.h>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#include <com/sun/star/sdbcx/XUsersSupplier.hpp>
+#include <com/sun/star/sdbcx/XGroupsSupplier.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <cppuhelper/compbase5.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include "connectivity/CommonTools.hxx"
+#include "OSubComponent.hxx"
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include "connectivity/StdTypeDefs.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ namespace sdbcx
+ {
+
+ class OCollection;
+ // OCatalog is a general catalog class
+ // other drivers can be derived their catalog from this class when they want to support sdbcx
+ // it holds already tables, views, groups and users
+
+ typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::sdbcx::XTablesSupplier,
+ ::com::sun::star::sdbcx::XViewsSupplier,
+ ::com::sun::star::sdbcx::XUsersSupplier,
+ ::com::sun::star::sdbcx::XGroupsSupplier,
+ ::com::sun::star::lang::XServiceInfo> OCatalog_BASE;
+
+
+ class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE OCatalog :
+ public OCatalog_BASE,
+ public IRefreshableGroups,
+ public IRefreshableUsers,
+ public connectivity::OSubComponent<OCatalog, OCatalog_BASE>
+ {
+ friend class connectivity::OSubComponent<OCatalog, OCatalog_BASE>;
+ protected:
+
+ ::osl::Mutex m_aMutex;
+
+ // this members are deleted when the dtor is called
+ // they are hold weak
+ OCollection* m_pTables;
+ OCollection* m_pViews;
+ OCollection* m_pGroups;
+ OCollection* m_pUsers;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; // just to make things easier
+
+ /** builds the name which should be used to access the object later on in the collection.
+ Will only be called in fillNames.
+ @param _xRow
+ The current row from the resultset given to fillNames.
+ */
+ virtual ::rtl::OUString buildName( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >& _xRow);
+
+ /** fills a vector with the nescessary names which can be used in combination with the collections.
+ For each row buildName will be called.
+ @param _xResult
+ The resultset which should be used to fill the names. Will be disposed after return and set to NULL.
+ @param _rNames
+ The vector who will be filled.
+ */
+ void fillNames(::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& _xResult,TStringVector& _rNames);
+
+ public:
+ OCatalog(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> &_xConnection);
+ virtual ~OCatalog();
+
+ DECLARE_SERVICE_INFO();
+
+ // refreshTables is called when the method getTables had been called
+ // the member m_pTables has to be created
+ virtual void refreshTables() = 0;
+ // refreshViews is called when the method getViews had been called
+ virtual void refreshViews() = 0;
+
+ // the other refresh methods come from base classes IRefreshableGroups and IRefreshableUsers
+
+ // ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XInterface
+ void SAL_CALL acquire() throw();
+ void SAL_CALL release() throw();
+ // XTablesSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables( ) throw(::com::sun::star::uno::RuntimeException);
+ // XViewsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getViews( ) throw(::com::sun::star::uno::RuntimeException);
+ // XUsersSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getUsers( ) throw(::com::sun::star::uno::RuntimeException);
+ // XGroupsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getGroups( ) throw(::com::sun::star::uno::RuntimeException);
+
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_SDBCX_CATALOG_HXX_
+
diff --git a/connectivity/inc/connectivity/sdbcx/VCollection.hxx b/connectivity/inc/connectivity/sdbcx/VCollection.hxx
new file mode 100644
index 000000000000..58fd6f8d0e2c
--- /dev/null
+++ b/connectivity/inc/connectivity/sdbcx/VCollection.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_SDBCX_COLLECTION_HXX_
+#define _CONNECTIVITY_SDBCX_COLLECTION_HXX_
+
+#include <cppuhelper/implbase10.hxx>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/container/XEnumeration.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/util/XRefreshable.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#include <comphelper/stl_types.hxx>
+#include <cppuhelper/interfacecontainer.h>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include "connectivity/CommonTools.hxx"
+#include <com/sun/star/container/XContainer.hpp>
+#include "connectivity/StdTypeDefs.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+#include <memory>
+
+
+namespace connectivity
+{
+ namespace sdbcx
+ {
+
+ // the class OCollection is base class for collections :-)
+ typedef ::cppu::ImplHelper10< ::com::sun::star::container::XNameAccess,
+ ::com::sun::star::container::XIndexAccess,
+ ::com::sun::star::container::XEnumerationAccess,
+ ::com::sun::star::container::XContainer,
+ ::com::sun::star::sdbc::XColumnLocate,
+ ::com::sun::star::util::XRefreshable,
+ ::com::sun::star::sdbcx::XDataDescriptorFactory,
+ ::com::sun::star::sdbcx::XAppend,
+ ::com::sun::star::sdbcx::XDrop,
+ ::com::sun::star::lang::XServiceInfo> OCollectionBase;
+
+ typedef ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > ObjectType;
+
+ class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE IObjectCollection
+ {
+ public:
+ virtual void reserve(size_t nLength) = 0;
+ virtual bool exists(const ::rtl::OUString& _sName ) = 0;
+ virtual bool empty() = 0;
+ virtual void swapAll() = 0;
+ virtual void swap() = 0;
+ virtual void clear() = 0;
+ virtual void reFill(const TStringVector &_rVector) = 0;
+ virtual void insert(const ::rtl::OUString& _sName,const ObjectType& _xObject) = 0;
+ virtual bool rename(const ::rtl::OUString _sOldName,const ::rtl::OUString _sNewName) = 0;
+ virtual sal_Int32 size() = 0;
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > getElementNames() = 0;
+ virtual ::rtl::OUString getName(sal_Int32 _nIndex) = 0;
+ virtual void disposeAndErase(sal_Int32 _nIndex) = 0;
+ virtual void disposeElements() = 0;
+ virtual sal_Int32 findColumn( const ::rtl::OUString& columnName ) = 0;
+ virtual ::rtl::OUString findColumnAtIndex( sal_Int32 _nIndex) = 0;
+ virtual ObjectType getObject(sal_Int32 _nIndex) = 0;
+ virtual ObjectType getObject(const ::rtl::OUString& columnName) = 0;
+ virtual void setObject(sal_Int32 _nIndex,const ObjectType& _xObject) = 0;
+ virtual sal_Bool isCaseSensitive() const = 0;
+ };
+ //************************************************************
+ // OCollection
+ //************************************************************
+ class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE OCollection :
+ public OCollectionBase
+ {
+ protected:
+ ::std::auto_ptr<IObjectCollection> m_pElements;
+
+ ::cppu::OInterfaceContainerHelper m_aContainerListeners;
+ ::cppu::OInterfaceContainerHelper m_aRefreshListeners;
+
+ protected:
+ ::cppu::OWeakObject& m_rParent; // parent of the collection
+ ::osl::Mutex& m_rMutex; // mutex of the parent
+ sal_Bool m_bUseIndexOnly; // is only TRUE when only an indexaccess is needed
+
+ // the implementing class should refresh their elements
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException) = 0;
+
+ // will be called when a object was requested by one of the accessing methods like getByIndex
+ virtual ObjectType createObject(const ::rtl::OUString& _rName) = 0;
+
+ // will be called when a new object should be generated by a call of createDataDescriptor
+ // the returned object is empty will be filled outside and added to the collection
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+
+ /** appends an object described by a descriptor, under a given name
+ @param _rForName
+ is the name under which the object should be appended. Guaranteed to not be empty.
+ This is passed for convenience only, since it's the result of a call of
+ getNameForObject for the given descriptor
+ @param descriptor
+ describes the object to append
+ @return
+ the new object which is to be inserted into the collection. This might be the result
+ of a call of <code>createObject( _rForName )</code>, or a clone of the descriptor.
+ */
+ virtual ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+
+ // called when XDrop was called
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+
+ /** returns the name for the object. The default implementation ask for the property NAME. If this doesn't satisfy, it has to be overloaded.
+ @param _xObject The object where the name should be extracted.
+ @return The name of the object.
+ */
+ virtual ::rtl::OUString getNameForObject(const ObjectType& _xObject);
+
+ /** clones the given descriptor
+
+ The method calls createDescriptor to create a new, empty descriptor, and then copies all properties from
+ _descriptor to the new object, which is returned.
+
+ This method might come handy in derived classes for implementing appendObject, when the object
+ is not actually appended to any backend (e.g. for the columns collection of a descriptor object itself,
+ where there is not yet a database backend to append the column to).
+ */
+ ObjectType cloneDescriptor( const ObjectType& _descriptor );
+
+ OCollection(::cppu::OWeakObject& _rParent,
+ sal_Bool _bCase,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector,
+ sal_Bool _bUseIndexOnly = sal_False,
+ sal_Bool _bUseHardRef = sal_True);
+
+ /** clear the name map
+ <p>Does <em>not</em> dispose the objects hold by the collection.</p>
+ */
+ void clear_NoDispose();
+
+ /** insert a new element into the collection
+ */
+ void insertElement(const ::rtl::OUString& _sElementName,const ObjectType& _xElement);
+
+ /** return the name of element at index _nIndex
+ */
+ inline ::rtl::OUString getElementName(sal_Int32 _nIndex)
+ {
+ return m_pElements->findColumnAtIndex(_nIndex);
+ }
+
+
+ /** return the object, if not existent it creates it.
+ @param _nIndex
+ The index of the object to create.
+ @return ObjectType
+ */
+ ObjectType getObject(sal_Int32 _nIndex);
+
+ public:
+ virtual ~OCollection();
+ DECLARE_SERVICE_INFO();
+
+ void reFill(const TStringVector &_rVector);
+ inline sal_Bool isCaseSensitive() const { return m_pElements->isCaseSensitive(); }
+ void renameObject(const ::rtl::OUString _sOldName,const ::rtl::OUString _sNewName);
+
+ // only the name is identical to ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // dispatch the refcounting to the parent
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::container::XElementAccess
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException);
+ // ::com::sun::star::container::XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::container::XNameAccess
+ virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
+ // XEnumerationAccess
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) throw(::com::sun::star::uno::RuntimeException);
+ // ::com::sun::star::util::XRefreshable
+ virtual void SAL_CALL refresh( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addRefreshListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener >& l ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeRefreshListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener >& l ) throw(::com::sun::star::uno::RuntimeException);
+ // XDataDescriptorFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( ) throw(::com::sun::star::uno::RuntimeException);
+ // XAppend
+ virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+ // XDrop
+ virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::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);
+ // ::com::sun::star::container::XContainer
+ virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
+ private:
+ void notifyElementRemoved(const ::rtl::OUString& _sName);
+ void disposeElements();
+ void dropImpl(sal_Int32 _nIndex,sal_Bool _bReallyDrop = sal_True);
+ };
+ }
+}
+#endif // _CONNECTIVITY_SDBCX_COLLECTION_HXX_
+
+
diff --git a/connectivity/inc/connectivity/sdbcx/VColumn.hxx b/connectivity/inc/connectivity/sdbcx/VColumn.hxx
new file mode 100644
index 000000000000..0a8c5498cf60
--- /dev/null
+++ b/connectivity/inc/connectivity/sdbcx/VColumn.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_SDBCX_COLUMN_HXX_
+#define _CONNECTIVITY_SDBCX_COLUMN_HXX_
+
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <comphelper/IdPropArrayHelper.hxx>
+#include <cppuhelper/compbase2.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include "connectivity/CommonTools.hxx"
+#include <comphelper/broadcasthelper.hxx>
+#include "connectivity/sdbcx/VDescriptor.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+namespace connectivity
+{
+ namespace sdbcx
+ {
+ class OColumn;
+ typedef ::comphelper::OIdPropertyArrayUsageHelper<OColumn> OColumn_PROP;
+
+ typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::container::XNamed,
+ ::com::sun::star::lang::XServiceInfo> OColumnDescriptor_BASE;
+ typedef ::cppu::ImplHelper1< ::com::sun::star::sdbcx::XDataDescriptorFactory > OColumn_BASE;
+
+
+ class OOO_DLLPUBLIC_DBTOOLS OColumn :
+ public comphelper::OBaseMutex,
+ public OColumn_BASE,
+ public OColumnDescriptor_BASE,
+ public OColumn_PROP,
+ public ODescriptor
+ {
+ protected:
+ ::rtl::OUString m_TypeName;
+ ::rtl::OUString m_Description;
+ ::rtl::OUString m_DefaultValue;
+
+ sal_Int32 m_IsNullable;
+ sal_Int32 m_Precision;
+ sal_Int32 m_Scale;
+ sal_Int32 m_Type;
+
+ sal_Bool m_IsAutoIncrement;
+ sal_Bool m_IsRowVersion;
+ sal_Bool m_IsCurrency;
+
+ using OColumnDescriptor_BASE::rBHelper;
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const;
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ virtual ~OColumn();
+ public:
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ OColumn( sal_Bool _bCase);
+ OColumn( const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _TypeName,
+ const ::rtl::OUString& _DefaultValue,
+ const ::rtl::OUString& _Description,
+ sal_Int32 _IsNullable,
+ sal_Int32 _Precision,
+ sal_Int32 _Scale,
+ sal_Int32 _Type,
+ sal_Bool _IsAutoIncrement,
+ sal_Bool _IsRowVersion,
+ sal_Bool _IsCurrency,
+ sal_Bool _bCase);
+
+ 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);
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ // ODescriptor
+ virtual void construct();
+ // ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+ // XNamed
+ virtual ::rtl::OUString SAL_CALL getName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
+ // XDataDescriptorFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( ) throw(::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_SDBCX_COLUMN_HXX_
+
diff --git a/connectivity/inc/connectivity/sdbcx/VDescriptor.hxx b/connectivity/inc/connectivity/sdbcx/VDescriptor.hxx
new file mode 100644
index 000000000000..99b251d17f42
--- /dev/null
+++ b/connectivity/inc/connectivity/sdbcx/VDescriptor.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_SDBCX_DESCRIPTOR_HXX_
+#define _CONNECTIVITY_SDBCX_DESCRIPTOR_HXX_
+
+#include <comphelper/propertycontainer.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <comphelper/stl_types.hxx>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ namespace sdbcx
+ {
+ // =========================================================================
+ // = ODescriptor
+ // =========================================================================
+ typedef ::comphelper::OPropertyContainer ODescriptor_PBASE;
+ class OOO_DLLPUBLIC_DBTOOLS ODescriptor
+ :public ODescriptor_PBASE
+ ,public ::com::sun::star::lang::XUnoTunnel
+ {
+ protected:
+ ::rtl::OUString m_Name;
+
+ /** helper for derived classes to implement OPropertyArrayUsageHelper::createArrayHelper
+
+ This method just calls describeProperties, and flags all properties as READONLY if and
+ only if we do *not* act as descriptor, but as final object.
+
+ @seealso isNew
+ */
+ ::cppu::IPropertyArrayHelper* doCreateArrayHelper() const;
+
+ private:
+ comphelper::UStringMixEqual m_aCase;
+ sal_Bool m_bNew;
+
+ public:
+ ODescriptor(::cppu::OBroadcastHelper& _rBHelper,sal_Bool _bCase, sal_Bool _bNew = sal_False);
+
+ virtual ~ODescriptor();
+
+ sal_Bool isNew() const { return m_bNew; }
+ sal_Bool getNew() const { return m_bNew; }
+ virtual void setNew(sal_Bool _bNew);
+
+ sal_Bool isCaseSensitive() const { return m_aCase.isCaseSensitive(); }
+
+ virtual void construct();
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // compare
+ inline sal_Bool operator == ( const ::rtl::OUString & _rRH )
+ {
+ return m_aCase(m_Name,_rRH);
+ }
+
+ // 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();
+
+ static ODescriptor* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxSomeComp );
+ // retrieves the ODescriptor implementation of a given UNO component, and returns its ->isNew flag
+ static sal_Bool isNew( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDescriptor );
+ };
+ }
+
+}
+#endif // _CONNECTIVITY_SDBCX_DESCRIPTOR_HXX_
+
diff --git a/connectivity/inc/connectivity/sdbcx/VGroup.hxx b/connectivity/inc/connectivity/sdbcx/VGroup.hxx
new file mode 100644
index 000000000000..b65b4cd2fda4
--- /dev/null
+++ b/connectivity/inc/connectivity/sdbcx/VGroup.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_SDBCX_GROUP_HXX_
+#define _CONNECTIVITY_SDBCX_GROUP_HXX_
+
+#include <osl/diagnose.h>
+
+
+#include <com/sun/star/sdbcx/XUsersSupplier.hpp>
+#include <com/sun/star/sdbcx/XAuthorizable.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <comphelper/proparrhlp.hxx>
+#include <cppuhelper/compbase4.hxx>
+//#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+//#include "connectivity/CommonTools.hxx"
+//#endif
+#include <comphelper/broadcasthelper.hxx>
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <comphelper/propertycontainer.hxx>
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include "connectivity/sdbcx/VDescriptor.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+namespace connectivity
+{
+ namespace sdbcx
+ {
+ typedef OCollection OUsers;
+
+ typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::sdbcx::XUsersSupplier,
+ ::com::sun::star::sdbcx::XAuthorizable,
+ ::com::sun::star::container::XNamed,
+ ::com::sun::star::lang::XServiceInfo> OGroup_BASE;
+
+ class OOO_DLLPUBLIC_DBTOOLS OGroup :
+ public comphelper::OBaseMutex,
+ public OGroup_BASE,
+ public IRefreshableUsers,
+ public ::comphelper::OPropertyArrayUsageHelper<OGroup>,
+ public ODescriptor
+ {
+ protected:
+ OUsers* m_pUsers;
+
+ using OGroup_BASE::rBHelper;
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ public:
+ OGroup(sal_Bool _bCase);
+ OGroup( const ::rtl::OUString& _Name,sal_Bool _bCase);
+ virtual ~OGroup();
+ DECLARE_SERVICE_INFO();
+
+ // XInterface
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() 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);
+
+ // ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+ // XUsersSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getUsers( ) throw(::com::sun::star::uno::RuntimeException);
+ // XAuthorizable
+ virtual sal_Int32 SAL_CALL getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XNamed
+ virtual ::rtl::OUString SAL_CALL getName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_SDBCX_GROUP_HXX_
+
+
diff --git a/connectivity/inc/connectivity/sdbcx/VIndex.hxx b/connectivity/inc/connectivity/sdbcx/VIndex.hxx
new file mode 100644
index 000000000000..b0669fdda540
--- /dev/null
+++ b/connectivity/inc/connectivity/sdbcx/VIndex.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_SDBCX_INDEX_HXX_
+#define _CONNECTIVITY_SDBCX_INDEX_HXX_
+
+//#ifndef _OSL_DIAGNOSE_H_
+//#include <osl/diagnose.h>
+//#endif
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <comphelper/IdPropArrayHelper.hxx>
+#include <cppuhelper/compbase2.hxx>
+#include "connectivity/CommonTools.hxx"
+#include <comphelper/broadcasthelper.hxx>
+#include "connectivity/sdbcx/VTypeDef.hxx"
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include "connectivity/sdbcx/VDescriptor.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+namespace connectivity
+{
+ namespace sdbcx
+ {
+ class OCollection;
+ class OIndex;
+ typedef ::cppu::ImplHelper1< ::com::sun::star::sdbcx::XDataDescriptorFactory > OIndex_BASE;
+ typedef ::comphelper::OIdPropertyArrayUsageHelper<OIndex> OIndex_PROP;
+
+ class OOO_DLLPUBLIC_DBTOOLS OIndex :
+ public comphelper::OBaseMutex,
+ public ODescriptor_BASE,
+ public IRefreshableColumns,
+ public OIndex_PROP,
+ public ODescriptor,
+ public OIndex_BASE
+ {
+ protected:
+ ::rtl::OUString m_Catalog;
+ sal_Bool m_IsUnique;
+ sal_Bool m_IsPrimaryKeyIndex;
+ sal_Bool m_IsClustered;
+
+ OCollection* m_pColumns;
+
+ using ODescriptor_BASE::rBHelper;
+ virtual void refreshColumns();
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const;
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ public:
+ OIndex(sal_Bool _bCase);
+ OIndex( const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Catalog,
+ sal_Bool _isUnique,
+ sal_Bool _isPrimaryKeyIndex,
+ sal_Bool _isClustered,
+ sal_Bool _bCase);
+
+ virtual ~OIndex( );
+
+ 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);
+ // ODescriptor
+ virtual void construct();
+ // ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+ // XColumnsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XNamed
+ virtual ::rtl::OUString SAL_CALL getName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
+ // XDataDescriptorFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( ) throw(::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_SDBCX_INDEX_HXX_
+
diff --git a/connectivity/inc/connectivity/sdbcx/VIndexColumn.hxx b/connectivity/inc/connectivity/sdbcx/VIndexColumn.hxx
new file mode 100644
index 000000000000..da836b772f30
--- /dev/null
+++ b/connectivity/inc/connectivity/sdbcx/VIndexColumn.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_SDBCX_INDEXCOLUMN_HXX_
+#define _CONNECTIVITY_SDBCX_INDEXCOLUMN_HXX_
+
+#include "connectivity/dbtoolsdllapi.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+
+namespace connectivity
+{
+ namespace sdbcx
+ {
+ class OIndexColumn;
+ typedef ::comphelper::OIdPropertyArrayUsageHelper<OIndexColumn> OIndexColumn_PROP;
+
+ class OOO_DLLPUBLIC_DBTOOLS OIndexColumn :
+ public OColumn, public OIndexColumn_PROP
+ {
+ protected:
+ sal_Bool m_IsAscending;
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const;
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ public:
+ OIndexColumn( sal_Bool _bCase);
+ OIndexColumn( sal_Bool _IsAscending,
+ 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,
+ sal_Bool _IsRowVersion,
+ sal_Bool _IsCurrency,
+ sal_Bool _bCase);
+
+ virtual void construct();
+ DECLARE_SERVICE_INFO();
+ };
+ }
+}
+#endif // _CONNECTIVITY_SDBCX_INDEXCOLUMN_HXX_
+
diff --git a/connectivity/inc/connectivity/sdbcx/VKey.hxx b/connectivity/inc/connectivity/sdbcx/VKey.hxx
new file mode 100644
index 000000000000..e4969cbced18
--- /dev/null
+++ b/connectivity/inc/connectivity/sdbcx/VKey.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_SDBCX_KEY_HXX_
+#define _CONNECTIVITY_SDBCX_KEY_HXX_
+
+
+#include <comphelper/IdPropArrayHelper.hxx>
+#include "connectivity/CommonTools.hxx"
+#include <comphelper/broadcasthelper.hxx>
+#include "connectivity/sdbcx/VTypeDef.hxx"
+#include <com/sun/star/container/XNamed.hpp>
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include "connectivity/sdbcx/VDescriptor.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <boost/shared_ptr.hpp>
+
+namespace connectivity
+{
+ namespace sdbcx
+ {
+
+ struct OOO_DLLPUBLIC_DBTOOLS KeyProperties
+ {
+ ::std::vector< ::rtl::OUString> m_aKeyColumnNames;
+ ::rtl::OUString m_ReferencedTable;
+ sal_Int32 m_Type;
+ sal_Int32 m_UpdateRule;
+ sal_Int32 m_DeleteRule;
+ KeyProperties(const ::rtl::OUString& _ReferencedTable,
+ sal_Int32 _Type,
+ sal_Int32 _UpdateRule,
+ sal_Int32 _DeleteRule)
+ :m_ReferencedTable(_ReferencedTable),
+ m_Type(_Type),
+ m_UpdateRule(_UpdateRule),
+ m_DeleteRule(_DeleteRule)
+ {}
+ KeyProperties():m_Type(0),m_UpdateRule(0),m_DeleteRule(0){}
+ };
+ typedef ::boost::shared_ptr< KeyProperties > TKeyProperties;
+ typedef ::cppu::ImplHelper1< ::com::sun::star::sdbcx::XDataDescriptorFactory > OKey_BASE;
+ class OCollection;
+
+ class OOO_DLLPUBLIC_DBTOOLS OKey :
+ public comphelper::OBaseMutex,
+ public ODescriptor_BASE,
+ public IRefreshableColumns,
+ public ::comphelper::OIdPropertyArrayUsageHelper<OKey>,
+ public ODescriptor,
+ public OKey_BASE
+ {
+ protected:
+ TKeyProperties m_aProps;
+ OCollection* m_pColumns;
+
+ using ODescriptor_BASE::rBHelper;
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ public:
+ OKey(sal_Bool _bCase);
+ OKey(const ::rtl::OUString& _Name,const TKeyProperties& _rProps,sal_Bool _bCase);
+ /*OKey( const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _ReferencedTable,
+ sal_Int32 _Type,
+ sal_Int32 _UpdateRule,
+ sal_Int32 _DeleteRule,
+ sal_Bool _bCase);*/
+
+ virtual ~OKey( );
+
+ 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);
+ // ODescriptor
+ virtual void construct();
+
+ // ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing();
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+ // XColumnsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XNamed
+ virtual ::rtl::OUString SAL_CALL getName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
+ // XDataDescriptorFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( ) throw(::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_SDBCX_KEY_HXX_
+
+
diff --git a/connectivity/inc/connectivity/sdbcx/VKeyColumn.hxx b/connectivity/inc/connectivity/sdbcx/VKeyColumn.hxx
new file mode 100644
index 000000000000..a3526cc68028
--- /dev/null
+++ b/connectivity/inc/connectivity/sdbcx/VKeyColumn.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_SDBCX_KEYCOLUMN_HXX_
+#define _CONNECTIVITY_SDBCX_KEYCOLUMN_HXX_
+
+#include "connectivity/dbtoolsdllapi.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+
+namespace connectivity
+{
+ namespace sdbcx
+ {
+ class OKeyColumn;
+ typedef ::comphelper::OIdPropertyArrayUsageHelper<OKeyColumn> OKeyColumn_PROP;
+
+ class OOO_DLLPUBLIC_DBTOOLS OKeyColumn :
+ public OColumn, public OKeyColumn_PROP
+ {
+ protected:
+ ::rtl::OUString m_ReferencedColumn;
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const;
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ public:
+ OKeyColumn(sal_Bool _bCase);
+ 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,
+ sal_Bool _IsRowVersion,
+ sal_Bool _IsCurrency,
+ sal_Bool _bCase);
+ // just to make it not inline
+ virtual ~OKeyColumn();
+
+ virtual void construct();
+ DECLARE_SERVICE_INFO();
+ };
+ }
+}
+#endif // _CONNECTIVITY_SDBCX_KEYCOLUMN_HXX_
+
diff --git a/connectivity/inc/connectivity/sdbcx/VTable.hxx b/connectivity/inc/connectivity/sdbcx/VTable.hxx
new file mode 100644
index 000000000000..c1ced96b4195
--- /dev/null
+++ b/connectivity/inc/connectivity/sdbcx/VTable.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_SDBCX_TABLE_HXX_
+#define _CONNECTIVITY_SDBCX_TABLE_HXX_
+
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
+#include <com/sun/star/sdbcx/XRename.hpp>
+#include <com/sun/star/sdbcx/XAlterTable.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <comphelper/IdPropArrayHelper.hxx>
+#include <cppuhelper/compbase4.hxx>
+#include <cppuhelper/implbase4.hxx>
+#include <comphelper/broadcasthelper.hxx>
+#include <com/sun/star/container/XNamed.hpp>
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include "connectivity/sdbcx/VDescriptor.hxx"
+#include "connectivity/CommonTools.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+
+namespace connectivity
+{
+ namespace sdbcx
+ {
+
+ class OTable;
+ class OCollection;
+
+ typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::sdbcx::XColumnsSupplier,
+ ::com::sun::star::sdbcx::XKeysSupplier,
+ ::com::sun::star::container::XNamed,
+ ::com::sun::star::lang::XServiceInfo> OTableDescriptor_BASE;
+
+ typedef ::cppu::ImplHelper4< ::com::sun::star::sdbcx::XDataDescriptorFactory,
+ ::com::sun::star::sdbcx::XIndexesSupplier,
+ ::com::sun::star::sdbcx::XRename,
+ ::com::sun::star::sdbcx::XAlterTable > OTable_BASE;
+
+ typedef ::comphelper::OIdPropertyArrayUsageHelper<OTable> OTable_PROP;
+
+
+ class OOO_DLLPUBLIC_DBTOOLS OTable :
+ public comphelper::OBaseMutex,
+ public OTable_BASE,
+ public OTableDescriptor_BASE,
+ public IRefreshableColumns,
+ public OTable_PROP,
+ public ODescriptor
+ {
+ protected:
+ ::rtl::OUString m_CatalogName;
+ ::rtl::OUString m_SchemaName;
+ ::rtl::OUString m_Description;
+ ::rtl::OUString m_Type;
+
+ OCollection* m_pKeys;
+ OCollection* m_pColumns;
+ OCollection* m_pIndexes;
+ OCollection* m_pTables; // must hold his own container to notify him when renaming
+
+ using OTableDescriptor_BASE::rBHelper;
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 _nId ) const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ public:
+ OTable( OCollection* _pTables,
+ sal_Bool _bCase);
+ OTable( OCollection* _pTables,
+ sal_Bool _bCase,
+ 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());
+
+ virtual ~OTable();
+
+ DECLARE_SERVICE_INFO();
+ //XInterface
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() 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);
+
+ // ODescriptor
+ virtual void construct();
+ virtual void refreshColumns();
+ virtual void refreshKeys();
+ virtual void refreshIndexes();
+ // ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+ // XColumnsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns( ) throw(::com::sun::star::uno::RuntimeException);
+ // XKeysSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getKeys( ) throw(::com::sun::star::uno::RuntimeException);
+ // XNamed
+ virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
+ // XDataDescriptorFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL createDataDescriptor( void ) throw(::com::sun::star::uno::RuntimeException);
+ // XIndexesSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getIndexes( ) throw(::com::sun::star::uno::RuntimeException);
+ // XRename
+ virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+ // XAlterTable
+ virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& colName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL alterColumnByIndex( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+
+ // helper method
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() const;
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_SDBCX_TABLE_HXX_
+
diff --git a/connectivity/inc/connectivity/sdbcx/VTypeDef.hxx b/connectivity/inc/connectivity/sdbcx/VTypeDef.hxx
new file mode 100644
index 000000000000..386cb254a69c
--- /dev/null
+++ b/connectivity/inc/connectivity/sdbcx/VTypeDef.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_SDBCX_TYPEDEF_HXX_
+#define _CONNECTIVITY_SDBCX_TYPEDEF_HXX_
+
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <cppuhelper/compbase3.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+
+namespace connectivity
+{
+ namespace sdbcx
+ {
+ typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbcx::XColumnsSupplier,
+ ::com::sun::star::container::XNamed,
+ ::com::sun::star::lang::XServiceInfo> ODescriptor_BASE;
+ }
+}
+
+#endif // _CONNECTIVITY_SDBCX_TYPEDEF_HXX_
+
diff --git a/connectivity/inc/connectivity/sdbcx/VUser.hxx b/connectivity/inc/connectivity/sdbcx/VUser.hxx
new file mode 100644
index 000000000000..529926bd0229
--- /dev/null
+++ b/connectivity/inc/connectivity/sdbcx/VUser.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_SDBCX_USER_HXX_
+#define _CONNECTIVITY_SDBCX_USER_HXX_
+
+#include <osl/diagnose.h>
+#include <com/sun/star/sdbcx/XUser.hpp>
+#include <com/sun/star/sdbcx/XGroupsSupplier.hpp>
+#include <comphelper/proparrhlp.hxx>
+#include <cppuhelper/compbase4.hxx>
+#include "connectivity/CommonTools.hxx"
+#include <comphelper/broadcasthelper.hxx>
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/container/XNamed.hpp>
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include "connectivity/sdbcx/VDescriptor.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ namespace sdbcx
+ {
+ typedef OCollection OGroups;
+
+ typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::sdbcx::XUser,
+ ::com::sun::star::sdbcx::XGroupsSupplier,
+ ::com::sun::star::container::XNamed,
+ ::com::sun::star::lang::XServiceInfo> OUser_BASE;
+
+ class OOO_DLLPUBLIC_DBTOOLS OUser :
+ public comphelper::OBaseMutex,
+ public OUser_BASE,
+ public IRefreshableGroups,
+ public ::comphelper::OPropertyArrayUsageHelper<OUser>,
+ public ODescriptor
+ {
+ protected:
+ OGroups* m_pGroups;
+
+ using OUser_BASE::rBHelper;
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ public:
+ OUser(sal_Bool _bCase);
+ OUser(const ::rtl::OUString& _Name,sal_Bool _bCase);
+
+ virtual ~OUser( );
+
+ DECLARE_SERVICE_INFO();
+
+ // ::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);
+ // XUser
+ virtual void SAL_CALL changePassword( const ::rtl::OUString& objPassword, const ::rtl::OUString& newPassword ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XAuthorizable
+ virtual sal_Int32 SAL_CALL getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XGroupsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getGroups( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XNamed
+ virtual ::rtl::OUString SAL_CALL getName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_SDBCX_USER_HXX_
+
diff --git a/connectivity/inc/connectivity/sdbcx/VView.hxx b/connectivity/inc/connectivity/sdbcx/VView.hxx
new file mode 100644
index 000000000000..ab386ad7c284
--- /dev/null
+++ b/connectivity/inc/connectivity/sdbcx/VView.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_SDBCX_VIEW_HXX_
+#define _CONNECTIVITY_SDBCX_VIEW_HXX_
+
+#include <osl/diagnose.h>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <comphelper/proparrhlp.hxx>
+#include <cppuhelper/compbase1.hxx>
+#include "connectivity/CommonTools.hxx"
+#include <cppuhelper/interfacecontainer.h>
+#include <com/sun/star/container/XNamed.hpp>
+#include "connectivity/sdbcx/VDescriptor.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+#include <comphelper/IdPropArrayHelper.hxx>
+#include <cppuhelper/implbase2.hxx>
+
+namespace connectivity
+{
+ namespace sdbcx
+ {
+
+ typedef ::cppu::WeakImplHelper2< ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::container::XNamed> OView_BASE;
+
+
+
+ class OOO_DLLPUBLIC_DBTOOLS OView :
+ public ::comphelper::OMutexAndBroadcastHelper,
+ public OView_BASE,
+ public ::comphelper::OIdPropertyArrayUsageHelper<OView>,
+ public ODescriptor
+ {
+ protected:
+ ::rtl::OUString m_CatalogName;
+ ::rtl::OUString m_SchemaName;
+ ::rtl::OUString m_Command;
+ sal_Int32 m_CheckOption;
+ // need for the getName method
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ public:
+ DECLARE_SERVICE_INFO();
+
+ OView(sal_Bool _bCase,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _xMetaData);
+ OView( sal_Bool _bCase,
+ const ::rtl::OUString& _rName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _xMetaData,
+ sal_Int32 _nCheckOption = 0,
+ const ::rtl::OUString& _rCommand = ::rtl::OUString(),
+ const ::rtl::OUString& _rSchemaName = ::rtl::OUString(),
+ const ::rtl::OUString& _rCatalogName = ::rtl::OUString());
+ virtual ~OView();
+
+ // ODescriptor
+ virtual void construct();
+
+ // ::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);
+ // XNamed
+ virtual ::rtl::OUString SAL_CALL getName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& ) throw(::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_SDBCX_VIEW_HXX_
+
diff --git a/connectivity/inc/connectivity/sqlerror.hxx b/connectivity/inc/connectivity/sqlerror.hxx
new file mode 100644
index 000000000000..3d6be7edf383
--- /dev/null
+++ b/connectivity/inc/connectivity/sqlerror.hxx
@@ -0,0 +1,340 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_SQLERROR_HXX
+#define CONNECTIVITY_SQLERROR_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdbc/SQLException.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/optional.hpp>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ //====================================================================
+ //= ErrorCondition
+ //====================================================================
+ /** the type of error codes to be used in SQLExceptions
+
+ @see com::sun::star::sdbc::SQLException::ErrorCode
+ */
+ typedef ::sal_Int32 ErrorCode;
+
+ /** error condition values as defined in <type scope="com::sun::star::sdb">ErrorCondition</type>
+ */
+ typedef ::sal_Int32 ErrorCondition;
+
+ //====================================================================
+ //= SQLError
+ //====================================================================
+ class SQLError_Impl;
+
+ /** a class which provides helpers for working with SQLErrors
+
+ In particular, this class provides vendor-specific error codes (where
+ the vendor is OpenOffice.org Base), which can be used in OOo's various
+ database drivers, and checked in application-level code, to properly
+ recognize highly specific error conditions.
+
+ @see ::com::sun::star::sdb::ErrorCondition
+ */
+ class OOO_DLLPUBLIC_DBTOOLS SQLError
+ {
+ public:
+ // --------------------------------------------------------------------
+ // - optional
+ // --------------------------------------------------------------------
+ /** convenience wrapper around boost::optional, allowing implicit construction
+ */
+ class ParamValue : public ::boost::optional< ::rtl::OUString >
+ {
+ typedef ::boost::optional< ::rtl::OUString > base_type;
+
+ public:
+ ParamValue( ) : base_type( ) { }
+ ParamValue( ::rtl::OUString const& val ) : base_type( val ) { }
+ ParamValue( ParamValue const& rhs ) : base_type( (base_type const&)rhs ) { }
+
+ bool is() const { return !base_type::operator!(); }
+ };
+
+
+ public:
+ explicit SQLError( const ::comphelper::ComponentContext& _rContext );
+ ~SQLError();
+
+ /** returns the message associated with a given error condition, after (optionally) replacing
+ a placeholder with a given string
+
+ Some error messages need to contain references to runtime-dependent data (say, the
+ name of a concrete table in the database), which in the resource file's strings are
+ represented by a placeholder, namely $1$, $2, and so on. This method allows to
+ retrieve such an error message, and replace upo to 3 placeholders with their concrete
+ values.
+
+ In a non-product build, assertions will fire if the number of placeholders in the
+ message's resource string does not match the number of passed parameter values.
+
+ As specified in the <type scope="com::sun::star::sdb">ErrorCondition</type> type,
+ error messages thrown by core components of OpenOffice.org Base will contain
+ a standardized prefix &quot;[OOoBase]&quot; in every message.
+
+ @param _rParamValue1
+ the value which the placeholder $1$ should be replaced with. If this value is
+ not present (see <code>::boost::optional::operator !</code>), then no replacement
+ will happen, and <code>_rParamValue2</code> and <code>_rParamValue3</code> will be
+ ignored.
+
+ @param _rParamValue2
+ the value which the placeholder $2$ should be replaced with. If this value is
+ not present (see <code>::boost::optional::operator !</code>), then no replacement
+ will happen, and <code>_rParamValue3</code> will be ignored.
+
+ @param _rParamValue1
+ the value which the placeholder $1$ should be replaced with. If this value is
+ not present (see <code>::boost::optional::operator !</code>), then no replacement
+ will happen.
+
+ @see ::com::sun::star::sdb::ErrorCondition
+ */
+ ::rtl::OUString getErrorMessage(
+ const ErrorCondition _eCondition,
+ const ParamValue& _rParamValue1 = ParamValue(),
+ const ParamValue& _rParamValue2 = ParamValue(),
+ const ParamValue& _rParamValue3 = ParamValue()
+ ) const;
+
+ /** returns the SQLState associated with a given error condition
+
+ @see getErrorMessage
+ @see getErrorCode
+ @see ::com::sun::star::sdb::ErrorCondition
+ @see ::com::sun::star::sdbc::SQLException::SQLState
+ */
+ ::rtl::OUString getSQLState( const ErrorCondition _eCondition ) const;
+
+ /** returns the error code associated with a given error condition
+
+ @see getErrorMessage
+ @see getSQLState
+ @see ::com::sun::star::sdb::ErrorCondition
+ @see ::com::sun::star::sdbc::SQLException::ErrorCode
+ */
+ static ErrorCode
+ getErrorCode( const ErrorCondition _eCondition );
+
+ /** returns the prefix which is used for OpenOffice.org Base's error messages
+
+ As specified in the <type scope="com::sun::star::sdb">ErrorCondition</type> type,
+ error messages thrown by core components of OpenOffice.org Base will
+ contain a standardized prefix in every message. <code>getBaseErrorMessagePrefix</code>
+ returns this prefix, so clients of such error messages might decide to strip this
+ prefix before presenting the message to the user, or use it to determine
+ whether a concrete error has been raised by a OpenOffice.org core component.
+ */
+ static const ::rtl::OUString&
+ getMessagePrefix();
+
+
+ /** throws an SQLException describing the given error condition
+
+ The thrown SQLException will contain the OOo-specific error code which derives
+ from the given error condition, and the error message associated with that condition.
+
+ @param _eCondition
+ the ErrorCondition which hit you
+
+ @param _rxContext
+ the context in which the error occured. This will be filled in as
+ <member scope="com::sun::star::uno">Exception::Context</member> member.
+
+ @param _rParamValue1
+ a runtime-dependent value which should be filled into the error message
+ which is associated with <arg>_eCondition</arg>, replacing the first placeholder
+ in this message.
+
+ @param _rParamValue2
+ a runtime-dependent value which should be filled into the error message
+ which is associated with <arg>_eCondition</arg>, replacing the second placeholder
+ in this message.
+
+ @param _rParamValue3
+ a runtime-dependent value which should be filled into the error message
+ which is associated with <arg>_eCondition</arg>, replacing the third placeholder
+ in this message.
+
+ @see getErrorMessage
+ @see getErrorCode
+ @see getSQLState
+ */
+ void raiseException(
+ const ErrorCondition _eCondition,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext,
+ const ParamValue& _rParamValue1 = ParamValue(),
+ const ParamValue& _rParamValue2 = ParamValue(),
+ const ParamValue& _rParamValue3 = ParamValue()
+ ) const;
+
+ /** throws an SQLException describing the given error condition
+
+ The thrown SQLException will contain the OOo-specific error code which derives
+ from the given error condition, and the error message associated with that condition.
+
+ Note: You should prefer the version of <type>raiseException</type> which takes
+ an additional <type>Context</type> parameter, since this allows clients of your
+ exception to examine where the error occured.
+
+ @param _eCondition
+ the ErrorCondition which hit you
+
+ @param _rParamValue1
+ a runtime-dependent value which should be filled into the error message
+ which is associated with <arg>_eCondition</arg>, replacing the first placeholder
+ in this message.
+
+ @param _rParamValue2
+ a runtime-dependent value which should be filled into the error message
+ which is associated with <arg>_eCondition</arg>, replacing the second placeholder
+ in this message.
+
+ @param _rParamValue3
+ a runtime-dependent value which should be filled into the error message
+ which is associated with <arg>_eCondition</arg>, replacing the third placeholder
+ in this message.
+
+ @see getErrorMessage
+ @see getErrorCode
+ @see getSQLState
+ */
+ void raiseException(
+ const ErrorCondition _eCondition,
+ const ParamValue& _rParamValue1 = ParamValue(),
+ const ParamValue& _rParamValue2 = ParamValue(),
+ const ParamValue& _rParamValue3 = ParamValue()
+ ) const;
+
+ /** raises a typed exception, that is, a UNO exception which is derived from
+ <type scope="com::sun::star::sdbc">SQLException</type>
+
+ @param _eCondition
+ the ErrorCondition which hit you
+
+ @param _rxContext
+ the context in which the error occured. This will be filled in as
+ <member scope="com::sun::star::uno">Exception::Context</member> member.
+
+ @param _rExceptionType
+ the type of the exception to throw. This type <em>must</em> specify
+ an exception class derived from <type scope="com::sun::star::sdbc">SQLException</type>.
+
+ @param _rParamValue1
+ a runtime-dependent value which should be filled into the error message
+ which is associated with <arg>_eCondition</arg>, replacing the first placeholder
+ in this message.
+
+ @param _rParamValue2
+ a runtime-dependent value which should be filled into the error message
+ which is associated with <arg>_eCondition</arg>, replacing the second placeholder
+ in this message.
+
+ @param _rParamValue3
+ a runtime-dependent value which should be filled into the error message
+ which is associated with <arg>_eCondition</arg>, replacing the third placeholder
+ in this message.
+
+ @throws ::std::bad_cast
+ if <arg>_rExceptionType</arg> does not specify an exception class derived from
+ <type scope="com::sun::star::sdbc">SQLException</type>.
+
+ @see getErrorMessage
+ @see getErrorCode
+ @see getSQLState
+ */
+ void raiseTypedException(
+ const ErrorCondition _eCondition,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext,
+ const ::com::sun::star::uno::Type& _rExceptionType,
+ const ParamValue& _rParamValue1 = ParamValue(),
+ const ParamValue& _rParamValue2 = ParamValue(),
+ const ParamValue& _rParamValue3 = ParamValue()
+ ) const;
+
+ /** retrieves an <code>SQLException</code> object which contains information about
+ the given error condition
+
+ @param _eCondition
+ the ErrorCondition which hit you
+
+ @param _rxContext
+ the context in which the error occured. This will be filled in as
+ <member scope="com::sun::star::uno">Exception::Context</member> member.
+
+ @param _rParamValue1
+ a runtime-dependent value which should be filled into the error message
+ which is associated with <arg>_eCondition</arg>, replacing the first placeholder
+ in this message.
+
+ @param _rParamValue2
+ a runtime-dependent value which should be filled into the error message
+ which is associated with <arg>_eCondition</arg>, replacing the second placeholder
+ in this message.
+
+ @param _rParamValue3
+ a runtime-dependent value which should be filled into the error message
+ which is associated with <arg>_eCondition</arg>, replacing the third placeholder
+ in this message.
+
+ @see getErrorMessage
+ @see getErrorCode
+ @see getSQLState
+ */
+ ::com::sun::star::sdbc::SQLException
+ getSQLException(
+ const ErrorCondition _eCondition,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext,
+ const ParamValue& _rParamValue1 = ParamValue(),
+ const ParamValue& _rParamValue2 = ParamValue(),
+ const ParamValue& _rParamValue3 = ParamValue()
+ ) const;
+
+ private:
+ ::boost::shared_ptr< SQLError_Impl > m_pImpl;
+ };
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
+#endif // CONNECTIVITY_SQLERROR_HXX
diff --git a/connectivity/inc/connectivity/sqliterator.hxx b/connectivity/inc/connectivity/sqliterator.hxx
new file mode 100644
index 000000000000..5152b7221f85
--- /dev/null
+++ b/connectivity/inc/connectivity/sqliterator.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_PARSE_SQLITERATOR_HXX_
+#define _CONNECTIVITY_PARSE_SQLITERATOR_HXX_
+
+#include "connectivity/dbtoolsdllapi.hxx"
+#include "connectivity/sqlnode.hxx"
+#include <connectivity/IParseContext.hxx>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "connectivity/CommonTools.hxx"
+#include <vos/ref.hxx>
+#include <cppuhelper/weak.hxx>
+
+#include <map>
+#include <memory>
+#include <vector>
+
+namespace connectivity
+{
+
+ class OSQLParseNode;
+ class OSQLParser;
+
+ typedef ::std::pair<const OSQLParseNode*,const OSQLParseNode* > TNodePair;
+
+ enum OSQLStatementType {
+ SQL_STATEMENT_UNKNOWN,
+ SQL_STATEMENT_SELECT,
+ SQL_STATEMENT_INSERT,
+ SQL_STATEMENT_UPDATE,
+ SQL_STATEMENT_DELETE,
+ SQL_STATEMENT_ODBC_CALL,
+ SQL_STATEMENT_CREATE_TABLE
+ };
+
+ struct OSQLParseTreeIteratorImpl;
+
+ class OOO_DLLPUBLIC_DBTOOLS OSQLParseTreeIterator
+ {
+ private:
+ ::com::sun::star::sdbc::SQLException m_aErrors; // conatins the error while iterating through the statement
+ const OSQLParseNode* m_pParseTree; // aktueller ParseTree
+ const OSQLParser& m_rParser; // if set used for general error messages from the context
+ OSQLStatementType m_eStatementType; // Art des Statements
+ ::vos::ORef<OSQLColumns> m_aSelectColumns; // alle Spalten aus dem Select-Clause
+ ::vos::ORef<OSQLColumns> m_aParameters; // all parameters
+ ::vos::ORef<OSQLColumns> m_aGroupColumns; // the group by columns
+ ::vos::ORef<OSQLColumns> m_aOrderColumns; // the order by columns
+ ::vos::ORef<OSQLColumns> m_aCreateColumns; // the columns for Create table clause
+
+ ::std::auto_ptr< OSQLParseTreeIteratorImpl > m_pImpl;
+
+ void traverseParameter(const OSQLParseNode* _pParseNode,const OSQLParseNode* _pColumnRef,const ::rtl::OUString& _aColumnName,const ::rtl::OUString& _aTableRange, const ::rtl::OUString& _rColumnAlias);
+ // F"ugt eine Tabelle in die Map ein
+ void traverseOneTableName( OSQLTables& _rTables,const OSQLParseNode * pTableName, const ::rtl::OUString & rTableRange );
+ void traverseORCriteria(OSQLParseNode * pSearchCondition);
+ void traverseANDCriteria(OSQLParseNode * pSearchCondition);
+ void traverseOnePredicate(
+ OSQLParseNode * pColumnRef,
+ ::rtl::OUString& aValue,
+ OSQLParseNode * pParameter);
+ void traverseByColumnNames(const OSQLParseNode* pSelectNode,sal_Bool _bOrder);
+ void traverseParameters(const OSQLParseNode* pSelectNode);
+
+ const OSQLParseNode* getTableNode( OSQLTables& _rTables, const OSQLParseNode* pTableRef, ::rtl::OUString& aTableRange );
+ void getQualified_join( OSQLTables& _rTables, const OSQLParseNode *pTableRef, ::rtl::OUString& aTableRange );
+ void getSelect_statement(OSQLTables& _rTables,const OSQLParseNode* pSelect);
+ ::rtl::OUString getUniqueColumnName(const ::rtl::OUString & rColumnName) const;
+
+ /** finds the column with a given name, belonging to a given table, in a given tables collection
+ @param _rTables
+ the tables collection to look in
+ @param rColumnName
+ the column name to look for
+ @param rTableRange
+ the table alias name
+ @return
+ the desired column object, or <NULL/> if no such column could be found
+ */
+ static ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > findColumn(
+ const OSQLTables& _rTables, const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange );
+
+ /** finds a column with a given name, belonging to a given table
+ @param rColumnName
+ the column name to look for
+ @param rTableRange
+ the table alias name
+ @param _bLookInSubTables
+ <TRUE/> if and only if not only our direct tables, but also our sub tables (from sub selects)
+ should be searched
+ @return
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > findColumn(
+ const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange, bool _bLookInSubTables );
+
+ protected:
+ void setSelectColumnName(::vos::ORef<OSQLColumns>& _rColumns,const ::rtl::OUString & rColumnName,const ::rtl::OUString & rColumnAlias, const ::rtl::OUString & rTableRange,sal_Bool bFkt=sal_False,sal_Int32 _nType = com::sun::star::sdbc::DataType::VARCHAR,sal_Bool bAggFkt=sal_False);
+ void appendColumns(::vos::ORef<OSQLColumns>& _rColumns,const ::rtl::OUString& _rTableAlias,const OSQLTable& _rTable);
+ // Weitere Member-Variable, die in den "set"-Funktionen zur
+ // Verfuegung stehen sollen, koennen in der abgeleiteten Klasse
+ // definiert werden und z. B. in deren Konstruktor initialisiert
+ // bzw. nach Benutzung der "traverse"-Routinen mit Hilfe weiterer
+ // Funktionen abgefragt werden.
+
+
+ private:
+ OSQLParseTreeIterator(); // never implemented
+ OSQLParseTreeIterator(const OSQLParseTreeIterator & rIter); // never implemented
+
+ public:
+ OSQLParseTreeIterator(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxTables,
+ const OSQLParser& _rParser,
+ const OSQLParseNode* pRoot = NULL );
+ ~OSQLParseTreeIterator();
+
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void * SAL_CALL operator new( size_t,void* _pHint ) SAL_THROW( () )
+ { return _pHint; }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ inline static void SAL_CALL operator delete( void *,void* ) SAL_THROW( () )
+ { }
+
+ void dispose();
+ bool isCaseSensitive() const;
+ // Der zu analysierende/zu traversierende Parse Tree:
+ // bei "Ubergabe von NULL wird der aktuelle Parsetree gel"oscht und der Fehlerstatus gecleared
+ void setParseTree(const OSQLParseNode * pNewParseTree);
+// void setParser(const OSQLParser* _pParser) { m_pParser = _pParser; }
+ const OSQLParseNode * getParseTree() const { return m_pParseTree; };
+
+ // Teilbaueme bei einem select statement
+ const OSQLParseNode* getWhereTree() const;
+ const OSQLParseNode* getOrderTree() const;
+ const OSQLParseNode* getGroupByTree() const;
+ const OSQLParseNode* getHavingTree() const;
+
+ const OSQLParseNode* getSimpleWhereTree() const;
+ const OSQLParseNode* getSimpleOrderTree() const;
+ const OSQLParseNode* getSimpleGroupByTree() const;
+ const OSQLParseNode* getSimpleHavingTree() const;
+
+ /** returns the errors which occured during parsing.
+
+ The returned object contains a chain (via SQLException::NextException) of SQLExceptions.
+ */
+ inline const ::com::sun::star::sdbc::SQLException& getErrors() const { return m_aErrors; }
+ inline bool hasErrors() const { return m_aErrors.Message.getLength() > 0; }
+
+ // Statement-Typ (wird bereits in setParseTree gesetzt):
+ OSQLStatementType getStatementType() const { return m_eStatementType; }
+
+ /** traverses the complete statement tree, and fills all our data with
+ the information obatined during traversal.
+
+ Implemented by calling the single traverse* methods in the proper
+ order (depending on the statement type).
+ */
+ void traverseAll();
+
+ enum TraversalParts
+ {
+ Parameters = 0x0001,
+ TableNames = 0x0002,
+ SelectColumns = 0x0006, // note that this includes TableNames. No SelectColumns without TableNames
+
+ // Those are not implemented currently
+ // GroupColumns = 0x0008,
+ // OrderColumns = 0x0010,
+ // SelectColumns = 0x0020,
+ // CreateColumns = 0x0040,
+
+ All = 0xFFFF
+ };
+ /** traverses selected parts of the statement tree, and fills our data with
+ the information obtained during traversal
+
+ @param _nIncludeMask
+ set of TraversalParts bits, specifying which information is to be collected.
+ Note TraversalParts is currently not
+ */
+ void traverseSome( sal_uInt32 _nIncludeMask );
+
+ // Die TableRangeMap enth"alt alle Tabellen unter dem zugeh"origen Rangenamen der zuerst gefunden wird
+ const OSQLTables& getTables() const;
+
+ ::vos::ORef<OSQLColumns> getSelectColumns() const { return m_aSelectColumns;}
+ ::vos::ORef<OSQLColumns> getGroupColumns() const { return m_aGroupColumns;}
+ ::vos::ORef<OSQLColumns> getOrderColumns() const { return m_aOrderColumns;}
+ ::vos::ORef<OSQLColumns> getParameters() const { return m_aParameters; }
+ ::vos::ORef<OSQLColumns> getCreateColumns() const { return m_aCreateColumns;}
+
+ /** return the columname and the table range
+ @param _pColumnRef
+ The column ref parse node.
+ @param _rColumnName
+ The column name to be set.
+ @param _rTableRange
+ The table range to be set.
+ */
+ void getColumnRange( const OSQLParseNode* _pColumnRef,
+ ::rtl::OUString &_rColumnName,
+ ::rtl::OUString& _rTableRange) const;
+
+ /** retrieves a column's name, table range, and alias
+
+ @param _pColumnRef
+ The column_ref parse node.
+ @param _out_rColumnName
+ The column name to be set.
+ @param _out_rTableRange
+ The table range to be set.
+ @param _out_rColumnAliasIfPresent
+ If the column specified by _pColumnRef is part of the select columns, and contains a column alias there,
+ this alias is returned here.
+ */
+ void getColumnRange( const OSQLParseNode* _pColumnRef,
+ ::rtl::OUString& _out_rColumnName,
+ ::rtl::OUString& _out_rTableRange,
+ ::rtl::OUString& _out_rColumnAliasIfPresent
+ ) const;
+
+ /** return the alias name of a column
+ @param _pDerivedColumn
+ The parse node where SQL_ISRULE(_pDerivedColumn,derived_column) must be true
+ @return
+ The alias name of the column or an empty string.
+ */
+ static ::rtl::OUString getColumnAlias(const OSQLParseNode* _pDerivedColumn);
+
+ /** return the columname and the table range
+ @param _pColumnRef
+ The column ref parse node.
+ @param _xMetaData
+ The database meta data.
+ @param _rColumnName
+ The column name to be set.
+ @param _rTableRange
+ The table range to be set.
+ */
+ static void getColumnRange( const OSQLParseNode* _pColumnRef,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ ::rtl::OUString &_rColumnName,
+ ::rtl::OUString& _rTableRange);
+
+ // Ermittelt fuer eine Funktion, Spalten den zugehoeren TableRange,
+ // wenn nicht eindeutig, dann leer
+ sal_Bool getColumnTableRange(const OSQLParseNode* pNode, ::rtl::OUString &rTableRange) const;
+
+ // return true when the tableNode is a rule like catalog_name, schema_name or table_name
+ sal_Bool isTableNode(const OSQLParseNode* _pTableNode) const;
+
+ // tries to find the correct type of the function
+ sal_Int32 getFunctionReturnType(const OSQLParseNode* _pNode );
+
+ // returns a lis of all joined columns
+ ::std::vector< TNodePair >& getJoinConditions() const;
+
+ private:
+ /** traverses the list of table names, and filles _rTables
+ */
+ bool traverseTableNames( OSQLTables& _rTables );
+
+ /// traverses columns in a SELECT statement
+ bool traverseSelectColumnNames(const OSQLParseNode* pSelectNode);
+ /// traverses columns in a CREATE TABLE statement
+ void traverseCreateColumns(const OSQLParseNode* pSelectNode);
+
+ bool traverseOrderByColumnNames(const OSQLParseNode* pSelectNode);
+ bool traverseGroupByColumnNames(const OSQLParseNode* pSelectNode);
+
+ bool traverseSelectionCriteria(const OSQLParseNode* pSelectNode);
+
+ private:
+ /** constructs a new iterator, which inherits some of the settings from a parent iterator
+ */
+ OSQLParseTreeIterator(
+ const OSQLParseTreeIterator& _rParentIterator,
+ const OSQLParser& _rParser,
+ const OSQLParseNode* pRoot );
+
+ /** creates a table object and inserts it into our tables collection
+
+ only used when we're iterating through a CREATE TABLE statement
+ */
+ OSQLTable impl_createTableObject(
+ const ::rtl::OUString& rTableName, const ::rtl::OUString& rCatalogName, const ::rtl::OUString& rSchemaName );
+
+ /** locates a record source (a table or query) with the given name
+ */
+ OSQLTable impl_locateRecordSource(
+ const ::rtl::OUString& _rComposedName
+ );
+
+ /** implementation for both traverseAll and traverseSome
+ */
+ void impl_traverse( sal_uInt32 _nIncludeMask );
+
+ /** retrieves the parameter columns of the given query
+ */
+ void impl_getQueryParameterColumns( const OSQLTable& _rQuery );
+
+ void setOrderByColumnName(const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange, sal_Bool bAscending);
+ void setGroupByColumnName(const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange);
+
+ private:
+ /** appends an SQLException corresponding to the given error code to our error collection
+
+ @param _eError
+ the code of the error which occured
+ @param _pReplaceToken1
+ if not <NULL/>, the first occurance of '#' in the error message will be replaced
+ with the given token
+ @param _pReplaceToken2
+ if not <NULL/>, and if _rReplaceToken1 is not <NULL/>, the second occurance of '#'
+ in the error message will be replaced with _rReplaceToken2
+ */
+ void impl_appendError( IParseContext::ErrorCode _eError,
+ const ::rtl::OUString* _pReplaceToken1 = NULL, const ::rtl::OUString* _pReplaceToken2 = NULL );
+
+ /** appends an SQLException corresponding to the given error code to our error collection
+ */
+ void impl_appendError( const ::com::sun::star::sdbc::SQLException& _rError );
+
+ /** resets our errors
+ */
+ inline void impl_resetErrors()
+ {
+ m_aErrors = ::com::sun::star::sdbc::SQLException();
+ }
+ void impl_fillJoinConditions(const OSQLParseNode* i_pJoinCondition);
+ };
+}
+
+#endif // _CONNECTIVITY_PARSE_SQLITERATOR_HXX_
+
diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx
new file mode 100644
index 000000000000..fa283cb5cf04
--- /dev/null
+++ b/connectivity/inc/connectivity/sqlnode.hxx
@@ -0,0 +1,472 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_SQLNODE_HXX
+#define _CONNECTIVITY_SQLNODE_HXX
+
+#include "connectivity/dbtoolsdllapi.hxx"
+#include "connectivity/dbmetadata.hxx"
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <vector>
+#include <functional>
+#include <set>
+#include <boost/shared_ptr.hpp>
+#include <rtl/ustrbuf.hxx>
+
+// forward declarations
+namespace com
+{
+ namespace sun
+ {
+ namespace star
+ {
+ namespace beans
+ {
+ class XPropertySet;
+ }
+ namespace util
+ {
+ class XNumberFormatter;
+ }
+ namespace container
+ {
+ class XNameAccess;
+ }
+ }
+ }
+}
+
+namespace rtl
+{
+ class OUStringBuffer;
+}
+
+namespace connectivity
+{
+ class OSQLParser;
+ class OSQLParseNode;
+ class IParseContext;
+
+ typedef ::std::vector< OSQLParseNode* > OSQLParseNodes;
+
+ enum SQLNodeType {SQL_NODE_RULE, SQL_NODE_LISTRULE, SQL_NODE_COMMALISTRULE,
+ SQL_NODE_KEYWORD, SQL_NODE_COMPARISON, SQL_NODE_NAME,
+ SQL_NODE_STRING, SQL_NODE_INTNUM, SQL_NODE_APPROXNUM,
+ SQL_NODE_EQUAL,SQL_NODE_LESS,SQL_NODE_GREAT,SQL_NODE_LESSEQ,SQL_NODE_GREATEQ,SQL_NODE_NOTEQUAL,
+ SQL_NODE_PUNCTUATION, SQL_NODE_AMMSC, SQL_NODE_ACCESS_DATE,SQL_NODE_DATE,SQL_NODE_CONCAT};
+
+ typedef ::std::set< ::rtl::OUString > QueryNameSet;
+ //==================================================================
+ //= SQLParseNodeParameter
+ //==================================================================
+ struct OOO_DLLPUBLIC_DBTOOLS SQLParseNodeParameter
+ {
+ const ::com::sun::star::lang::Locale& rLocale;
+ ::dbtools::DatabaseMetaData aMetaData;
+ OSQLParser* pParser;
+ ::boost::shared_ptr< QueryNameSet > pSubQueryHistory;
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > xFormatter;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xField;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > xQueries; // see bParseToSDBCLevel
+ const IParseContext& m_rContext;
+ sal_Char cDecSep;
+ bool bQuote : 1; /// should we quote identifiers?
+ bool bInternational : 1; /// should we internationalize keywords and placeholders?
+ bool bPredicate : 1; /// are we going to parse a mere predicate?
+ bool bParseToSDBCLevel : 1; /// should we create an SDBC-level statement (e.g. with substituted sub queries)?
+
+ SQLParseNodeParameter(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _xFormatter,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xField,
+ const ::com::sun::star::lang::Locale& _rLocale,
+ const IParseContext* _pContext,
+ bool _bIntl,
+ bool _bQuote,
+ sal_Char _cDecSep,
+ bool _bPredicate,
+ bool _bParseToSDBC
+ );
+ ~SQLParseNodeParameter();
+ };
+
+ //==========================================================================
+ //= OSQLParseNode
+ //==========================================================================
+ class OOO_DLLPUBLIC_DBTOOLS OSQLParseNode
+ {
+ friend class OSQLParser;
+
+ OSQLParseNodes m_aChildren;
+ OSQLParseNode* m_pParent; // pParent fuer Reuckverkettung im Baum
+ ::rtl::OUString m_aNodeValue; // Token-Name oder leer bei Regeln oder ::rtl::OUString bei
+ // ::rtl::OUString, INT, usw. -Werten
+ SQLNodeType m_eNodeType; // s. o.
+ sal_uInt32 m_nNodeID; // ::com::sun::star::chaos::Rule ID (bei IsRule()) oder Token ID (bei !IsRule())
+ // ::com::sun::star::chaos::Rule IDs und Token IDs koennen nicht anhand des Wertes
+ // unterschieden werden, dafuer ist IsRule() abzufragen!
+ public:
+ enum Rule
+ {
+ select_statement = 0,
+ table_exp,
+ table_ref_commalist,
+ table_ref,
+ catalog_name,
+ schema_name,
+ table_name,
+ opt_column_commalist,
+ column_commalist,
+ column_ref_commalist,
+ column_ref,
+ opt_order_by_clause,
+ ordering_spec_commalist,
+ ordering_spec,
+ opt_asc_desc,
+ where_clause,
+ opt_where_clause,
+ search_condition,
+ comparison_predicate,
+ between_predicate,
+ like_predicate,
+ opt_escape,
+ test_for_null,
+ scalar_exp_commalist,
+ scalar_exp,
+ parameter_ref,
+ parameter,
+ general_set_fct,
+ range_variable,
+ column,
+ delete_statement_positioned,
+ delete_statement_searched,
+ update_statement_positioned,
+ update_statement_searched,
+ assignment_commalist,
+ assignment,
+ values_or_query_spec,
+ insert_statement,
+ insert_atom_commalist,
+ insert_atom,
+ predicate_check,
+ from_clause,
+ qualified_join,
+ cross_union,
+ select_sublist,
+ derived_column,
+ column_val,
+ set_fct_spec,
+ boolean_term,
+ boolean_primary,
+ num_value_exp,
+ join_type,
+ position_exp,
+ extract_exp,
+ length_exp,
+ char_value_fct,
+ odbc_call_spec,
+ in_predicate,
+ existence_test,
+ unique_test,
+ all_or_any_predicate,
+ named_columns_join,
+ join_condition,
+ joined_table,
+ boolean_factor,
+ sql_not,
+ boolean_test,
+ manipulative_statement,
+ subquery,
+ value_exp_commalist,
+ odbc_fct_spec,
+ union_statement,
+ outer_join_type,
+ char_value_exp,
+ term,
+ value_exp_primary,
+ value_exp,
+ selection,
+ fold,
+ char_substring_fct,
+ factor,
+ base_table_def,
+ base_table_element_commalist,
+ data_type,
+ column_def,
+ table_node,
+ as,
+ op_column_commalist,
+ table_primary_as_range_column,
+ datetime_primary,
+ concatenation,
+ char_factor,
+ bit_value_fct,
+ comparison_predicate_part_2,
+ parenthesized_boolean_value_expression,
+ character_string_type,
+ other_like_predicate_part_2,
+ between_predicate_part_2,
+ rule_count, // letzter_wert
+ UNKNOWN_RULE // ID indicating that a node is no rule with a matching Rule-enum value (see getKnownRuleID)
+ };
+
+ // must be ascii encoding for the value
+ OSQLParseNode(const sal_Char* _pValueStr,
+ SQLNodeType _eNodeType,
+ sal_uInt32 _nNodeID = 0);
+
+ OSQLParseNode(const ::rtl::OString& _rValue,
+ SQLNodeType eNewNodeType,
+ sal_uInt32 nNewNodeID=0);
+
+ OSQLParseNode(const sal_Unicode* _pValue,
+ SQLNodeType _eNodeType,
+ sal_uInt32 _nNodeID = 0);
+
+ OSQLParseNode(const ::rtl::OUString& _rValue,
+ SQLNodeType _eNodeType,
+ sal_uInt32 _nNodeID = 0);
+
+ // Kopiert den entsprechenden ParseNode
+ OSQLParseNode(const OSQLParseNode& rParseNode);
+ OSQLParseNode& operator=(const OSQLParseNode& rParseNode);
+
+ sal_Bool operator==(OSQLParseNode& rParseNode) const;
+
+ // Destruktor raeumt rekursiv den Baum ab
+ virtual ~OSQLParseNode();
+
+ // Parent gibt den Zeiger auf den Parent zurueck
+ OSQLParseNode* getParent() const {return m_pParent;};
+
+ // SetParent setzt den Parent-Zeiger eines ParseNodes
+ void setParent(OSQLParseNode* pParseNode) {m_pParent = pParseNode;};
+
+ // ChildCount liefert die Anzahl der Kinder eines Knotens
+ sal_uInt32 count() const {return m_aChildren.size();};
+ inline OSQLParseNode* getChild(sal_uInt32 nPos) const;
+
+ void append(OSQLParseNode* pNewSubTree);
+ void insert(sal_uInt32 nPos, OSQLParseNode* pNewSubTree);
+
+ OSQLParseNode* replaceAt(sal_uInt32 nPos, OSQLParseNode* pNewSubTree);
+ OSQLParseNode* replace(OSQLParseNode* pOldSubTree, OSQLParseNode* pNewSubTree);
+
+ OSQLParseNode* removeAt(sal_uInt32 nPos);
+ OSQLParseNode* remove(OSQLParseNode* pSubTree);
+
+ void replaceNodeValue(const ::rtl::OUString& rTableAlias,const ::rtl::OUString& rColumnName);
+
+ /** parses the node to a string which can be passed to a driver's connection for execution
+
+ Any particles of the parse tree which represent application-level features - such
+ as queries appearing in the FROM part - are subsituted, so that the resulting statement can
+ be executed at an SDBC-level connection.
+
+ @param _out_rString
+ is an output parameter taking the resulting SQL statement
+
+ @param _rxConnection
+ the connection relative to which to parse. This must be an SDB-level connection (e.g.
+ support the XQueriesSupplier interface) for the method to be able to do all necessary
+ substitutions.
+
+ @param _rParser
+ the SQLParser used to create the node. This is needed in case we need to parse
+ sub queries which are present in the SQL statement - those sub queries need to be parsed,
+ too, to check whether they contain nested sub queries.
+
+ @param _pErrorHolder
+ takes the error which occured while generating the statement, if any. Might be <NULL/>,
+ in this case the error is not reported back, and can only be recognized by examing the
+ return value.
+
+ @return
+ <TRUE/> if and only if the parsing was successful.<br/>
+
+ Currently, there's only one condition how this method can fail: If it contains a nested
+ query which causes a cycle. E.g., consider a statement <code>SELECT * from "foo"</code>,
+ where <code>bar </code> is a query defined as <code>SELECT * FROM "bar"</code>, where
+ <code>bar</code> is defined as <code>SELECT * FROM "foo"</code>. This statement obviously
+ cannot be parsed to an executable statement.
+
+ If this method returns <FALSE/>, you're encouraged to check and handle the error in
+ <arg>_pErrorHolder</arg>.
+ */
+ bool parseNodeToExecutableStatement( ::rtl::OUString& _out_rString,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ OSQLParser& _rParser,
+ ::com::sun::star::sdbc::SQLException* _pErrorHolder ) const;
+
+ void parseNodeToStr(::rtl::OUString& rString,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const IParseContext* pContext = NULL,
+ sal_Bool _bIntl = sal_False,
+ sal_Bool _bQuote= sal_True) const;
+
+ // quoted und internationalisert
+ void parseNodeToPredicateStr(::rtl::OUString& rString,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter,
+ const ::com::sun::star::lang::Locale& rIntl,
+ sal_Char _cDec,
+ const IParseContext* pContext = NULL ) const;
+
+ void parseNodeToPredicateStr(::rtl::OUString& rString,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & _xField,
+ const ::com::sun::star::lang::Locale& rIntl,
+ sal_Char _cDec,
+ const IParseContext* pContext = NULL ) const;
+
+ OSQLParseNode* getByRule(OSQLParseNode::Rule eRule) const;
+
+#if OSL_DEBUG_LEVEL > 0
+ // zeigt den ParseTree mit tabs und linefeeds
+ void showParseTree( ::rtl::OUString& rString ) const;
+ void showParseTree( ::rtl::OUStringBuffer& _inout_rBuf, sal_uInt32 nLevel ) const;
+#endif
+
+ // GetNodeType gibt den Knotentyp zurueck
+ SQLNodeType getNodeType() const {return m_eNodeType;};
+
+ // RuleId liefert die RuleId der Regel des Knotens (nur bei IsRule())
+ sal_uInt32 getRuleID() const {return m_nNodeID;}
+
+ /** returns the ID of the rule represented by the node
+
+ If the node does not represent a rule, UNKNOWN_RULE is returned
+ */
+ Rule getKnownRuleID() const;
+
+ // RuleId liefert die TokenId des Tokens des Knotens (nur bei ! IsRule())
+ sal_uInt32 getTokenID() const {return m_nNodeID;}
+
+ // IsRule testet ob ein Node eine Regel (NonTerminal) ist
+ // Achtung : Regeln koenne auch Blaetter sein, z.B. leere Listen
+ sal_Bool isRule() const
+ { return (m_eNodeType == SQL_NODE_RULE) || (m_eNodeType == SQL_NODE_LISTRULE)
+ || (m_eNodeType == SQL_NODE_COMMALISTRULE);}
+
+ // IsToken testet ob ein Node ein Token (Terminal) ist
+ sal_Bool isToken() const {return !isRule();} // ein Token ist keine Regel
+
+ // TokenValue liefert den NodeValue eines Tokens
+ const ::rtl::OUString& getTokenValue() const {return m_aNodeValue;}
+
+ // SetTokenValue setzt den NodeValue
+ void setTokenValue(const ::rtl::OUString& rString) { if (isToken()) m_aNodeValue = rString;}
+
+ // IsLeaf testet ob ein Node ein Blatt ist
+ sal_Bool isLeaf() const {return m_aChildren.empty();}
+
+ // negate only a searchcondition, any other rule could cause a gpf
+ static void negateSearchCondition(OSQLParseNode*& pSearchCondition,sal_Bool bNegate=sal_False);
+
+ // normalize a logic form
+ // e.q. (a or b) and (c or d) <=> a and c or a and d or b and c or b and d
+ static void disjunctiveNormalForm(OSQLParseNode*& pSearchCondition);
+
+ // Simplies logic expressions
+ // a * a = a
+ // a + a = a
+ // a * ( a + b) = a
+ // a + a * b = a
+ static void absorptions(OSQLParseNode*& pSearchCondition);
+
+ // erase not nessary braces
+ static void eraseBraces(OSQLParseNode*& pSearchCondition);
+
+ // makes the logic formula a little more smaller
+ static void compress(OSQLParseNode*& pSearchCondition);
+ // return the catalog, schema and tablename form this node
+ // _pTableNode must be a rule of that above or a SQL_TOKEN_NAME
+ static sal_Bool getTableComponents(const OSQLParseNode* _pTableNode,
+ ::com::sun::star::uno::Any &_rCatalog,
+ ::rtl::OUString &_rSchema,
+ ::rtl::OUString &_rTable
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _xMetaData);
+
+ // susbtitute all occurences of :var or [name] into the dynamic parameter ?
+ // _pNode will be modified if parameters exists
+ static void substituteParameterNames(OSQLParseNode* _pNode);
+
+ /** return a table range when it exists.
+ */
+ static ::rtl::OUString getTableRange(const OSQLParseNode* _pTableRef);
+
+ protected:
+ // ParseNodeToStr konkateniert alle Token (Blaetter) des ParseNodes
+ void parseNodeToStr(::rtl::OUString& rString,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & _xField,
+ const ::com::sun::star::lang::Locale& rIntl,
+ const IParseContext* pContext,
+ bool _bIntl,
+ bool _bQuote,
+ sal_Char _cDecSep,
+ bool _bPredicate,
+ bool _bSubstitute) const;
+
+ private:
+ void impl_parseNodeToString_throw( ::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const;
+ void impl_parseLikeNodeToString_throw( ::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam ) const;
+ void impl_parseTableRangeNodeToString_throw( ::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam ) const;
+
+ /** parses a table_name node into a SQL statement particle.
+ @return
+ <TRUE/> if and only if parsing was successful, <FALSE/> if default handling should
+ be applied.
+ */
+ bool impl_parseTableNameNodeToString_throw( ::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam ) const;
+
+ sal_Bool addDateValue(::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const;
+ ::rtl::OUString convertDateTimeString(const SQLParseNodeParameter& rParam, const ::rtl::OUString& rString) const;
+ ::rtl::OUString convertDateString(const SQLParseNodeParameter& rParam, const ::rtl::OUString& rString) const;
+ ::rtl::OUString convertTimeString(const SQLParseNodeParameter& rParam, const ::rtl::OUString& rString) const;
+ void parseLeaf(::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const;
+ };
+
+ //-----------------------------------------------------------------------------
+ inline OSQLParseNode* OSQLParseNode::getChild(sal_uInt32 nPos) const
+ {
+ OSL_ENSURE(nPos < m_aChildren.size(), "Invalid Position");
+
+ // return m_aChildren[nPos];
+ return m_aChildren.at(nPos);
+ }
+
+ // Utility-Methoden zum Abfragen auf bestimmte Rules, Token oder Punctuation:
+ #define SQL_ISRULE(pParseNode, eRule) ((pParseNode)->isRule() && (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::eRule))
+ #define SQL_ISTOKEN(pParseNode, token) ((pParseNode)->isToken() && (pParseNode)->getTokenID() == SQL_TOKEN_##token)
+ #define SQL_ISPUNCTUATION(pParseNode, aString) ((pParseNode)->getNodeType() == SQL_NODE_PUNCTUATION && !(pParseNode)->getTokenValue().compareToAscii(aString))
+}
+
+#endif //_CONNECTIVITY_SQLNODE_HXX
diff --git a/connectivity/inc/connectivity/sqlparse.hxx b/connectivity/inc/connectivity/sqlparse.hxx
new file mode 100644
index 000000000000..03854e6c9faf
--- /dev/null
+++ b/connectivity/inc/connectivity/sqlparse.hxx
@@ -0,0 +1,261 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_SQLPARSE_HXX
+#define _CONNECTIVITY_SQLPARSE_HXX
+
+#include <com/sun/star/uno/Reference.h>
+#include <osl/mutex.hxx>
+#include <connectivity/sqlnode.hxx>
+#ifndef YYBISON
+#ifndef FLEX_SCANNER
+#ifndef BISON_INCLUDED
+#define BISON_INCLUDED
+#include "sqlbison.hxx"
+#endif
+#endif
+#endif
+#include <com/sun/star/i18n/XCharacterClassification.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/i18n/XLocaleData.hpp>
+#include "connectivity/IParseContext.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+#include <salhelper/singletonref.hxx>
+#include <osl/mutex.hxx>
+
+#include <map>
+
+// forward declarations
+namespace com
+{
+ namespace sun
+ {
+ namespace star
+ {
+ namespace beans
+ {
+ class XPropertySet;
+ }
+ namespace util
+ {
+ class XNumberFormatter;
+ }
+ namespace lang
+ {
+ struct Locale;
+ }
+ }
+ }
+}
+namespace connectivity
+{
+ class OSQLScanner;
+ class SQLError;
+
+ //==========================================================================
+ //= OParseContext
+ //==========================================================================
+ class OOO_DLLPUBLIC_DBTOOLS OParseContext : public IParseContext
+ {
+ public:
+ OParseContext();
+
+ virtual ~OParseContext();
+ // retrieves language specific error messages
+ virtual ::rtl::OUString getErrorMessage(ErrorCode _eCodes) const;
+
+ // retrieves language specific keyword strings (only ASCII allowed)
+ virtual ::rtl::OString getIntlKeywordAscii(InternationalKeyCode _eKey) const;
+
+ // finds out, if we have an international keyword (only ASCII allowed)
+ virtual InternationalKeyCode getIntlKeyCode(const ::rtl::OString& rToken) const;
+
+ // determines the default international setting
+ static const ::com::sun::star::lang::Locale& getDefaultLocale();
+
+ /** set's the default locale which should be used when analyzing strings
+ <p>If no locale is set, and any method which needs a locale is called, a default
+ (en-US) is used.</p>
+ <p>If, while parsing, the locale can be obtained from other sources (such as the number format
+ set for a table column), the preferred locale is ignored.</p>
+ */
+ static void setDefaultLocale( const ::com::sun::star::lang::Locale& _rLocale );
+
+ /** get's a locale instance which should be used when parsing in the context specified by this instance
+ <p>if this is not overridden by derived classes, it returns the static default locale.</p>
+ */
+ virtual ::com::sun::star::lang::Locale getPreferredLocale( ) const;
+ };
+
+ //==========================================================================
+ // OSQLParseNodesContainer
+ // grabage collection of nodes
+ //==========================================================================
+ class OSQLParseNodesContainer
+ {
+ ::osl::Mutex m_aMutex;
+ ::std::vector< OSQLParseNode* > m_aNodes;
+ public:
+ OSQLParseNodesContainer();
+ ~OSQLParseNodesContainer();
+
+ void push_back(OSQLParseNode* _pNode);
+ void erase(OSQLParseNode* _pNode);
+ bool empty() const;
+ void clear();
+ void clearAndDelete();
+ };
+
+ typedef salhelper::SingletonRef<OSQLParseNodesContainer> OSQLParseNodesGarbageCollector;
+
+ //==========================================================================
+ //= OSQLParser
+ //==========================================================================
+ struct OSQLParser_Data;
+ /** Parser for SQL92
+ */
+ class OOO_DLLPUBLIC_DBTOOLS OSQLParser
+ {
+ friend class OSQLParseNode;
+ friend class OSQLInternalNode;
+ friend struct SQLParseNodeParameter;
+
+ private:
+ typedef ::std::map< sal_uInt32, OSQLParseNode::Rule > RuleIDMap;
+ // static parts for parsers
+ static sal_uInt32 s_nRuleIDs[OSQLParseNode::rule_count + 1];
+ static RuleIDMap s_aReverseRuleIDLookup;
+ static OParseContext s_aDefaultContext;
+
+ static OSQLScanner* s_pScanner;
+ static OSQLParseNodesGarbageCollector* s_pGarbageCollector;
+ static sal_Int32 s_nRefCount;
+
+ // informations on the current parse action
+ const IParseContext* m_pContext;
+ OSQLParseNode* m_pParseTree; // result from parsing
+ ::std::auto_ptr< OSQLParser_Data >
+ m_pData;
+ ::rtl::OUString m_sFieldName; // current field name for a predicate
+ ::rtl::OUString m_sErrorMessage;// current error msg
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xField; // current field
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >
+ m_xFormatter; // current number formatter
+ sal_Int32 m_nFormatKey; // numberformat, which should be used
+ sal_Int32 m_nDateFormatKey;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceFactory;
+ ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCharacterClassification> m_xCharClass;
+ static ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData> s_xLocaleData;
+ ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData> xDummy; // can be deleted after 627
+
+ // convert a string into double trim it to scale of _nscale and than transform it back to string
+ ::rtl::OUString stringToDouble(const ::rtl::OUString& _rValue,sal_Int16 _nScale);
+ OSQLParseNode* buildDate(sal_Int32 _nType,OSQLParseNode*& pLiteral);
+ bool extractDate(OSQLParseNode* pLiteral,double& _rfValue);
+ void killThousandSeparator(OSQLParseNode* pLiteral);
+ OSQLParseNode* convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral);
+ // makes a string out of a number, pLiteral will be deleted
+ OSQLParseNode* buildNode_STR_NUM(OSQLParseNode*& pLiteral);
+ OSQLParseNode* buildNode_Date(const double& fValue, sal_Int32 nType);
+
+ static ::osl::Mutex& getMutex();
+
+ public:
+ // if NULL, a default context will be used
+ // the context must live as long as the parser
+ OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xServiceFactory,const IParseContext* _pContext = NULL);
+ ~OSQLParser();
+
+ // Parsing an SQLStatement
+ OSQLParseNode* parseTree(::rtl::OUString& rErrorMessage,
+ const ::rtl::OUString& rStatement,
+ sal_Bool bInternational = sal_False);
+
+ // Check a Predicate
+ OSQLParseNode* predicateTree(::rtl::OUString& rErrorMessage, const ::rtl::OUString& rStatement,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & xField);
+
+ // Access to the context
+ const IParseContext& getContext() const {return *m_pContext;}
+
+ /// access to the SQLError instance owned by this parser
+ const SQLError& getErrorHelper() const;
+
+ // TokenIDToStr: Token-Name zu einer Token-Nr.
+ static ::rtl::OString TokenIDToStr(sal_uInt32 nTokenID, const IParseContext* pContext = NULL);
+
+ // StrToTokenID: Token-Nr. zu einem Token-Namen.
+ // static sal_uInt32 StrToTokenID(const ::rtl::OString & rName);
+
+ // RuleIDToStr gibt den zu einer RuleID gehoerenden ::rtl::OUString zurueck
+ // (Leerstring, falls nicht gefunden)
+ static ::rtl::OUString RuleIDToStr(sal_uInt32 nRuleID);
+
+ // StrToRuleID berechnet zu einem ::rtl::OUString die RuleID (d.h. ::com::sun::star::sdbcx::Index in yytname)
+ // (0, falls nicht gefunden). Die Suche nach der ID aufgrund eines Strings ist
+ // extrem ineffizient (sequentielle Suche nach ::rtl::OUString)!
+ static sal_uInt32 StrToRuleID(const ::rtl::OString & rValue);
+
+ static OSQLParseNode::Rule RuleIDToRule( sal_uInt32 _nRule );
+
+ // RuleId mit enum, wesentlich effizienter
+ static sal_uInt32 RuleID(OSQLParseNode::Rule eRule);
+ // compares the _sFunctionName with all known function names and return the DataType of the return value
+ static sal_Int32 getFunctionReturnType(const ::rtl::OUString& _sFunctionName, const IParseContext* pContext = NULL);
+
+ // returns the type for a parameter in a given function name
+ static sal_Int32 getFunctionParameterType(sal_uInt32 _nTokenId,sal_uInt32 _nPos);
+
+ void error(sal_Char *fmt);
+ int SQLlex();
+#ifdef YYBISON
+ void setParseTree(OSQLParseNode * pNewParseTree);
+
+ // Is the parse in a special mode?
+ // Predicate chack is used to check a condition for a field
+ sal_Bool inPredicateCheck() const {return m_xField.is();}
+ const ::rtl::OUString& getFieldName() const {return m_sFieldName;}
+
+ void reduceLiteral(OSQLParseNode*& pLiteral, sal_Bool bAppendBlank);
+ // does not change the pLiteral argument
+ sal_Int16 buildNode(OSQLParseNode*& pAppend,OSQLParseNode* pCompare,OSQLParseNode* pLiteral,OSQLParseNode* pLiteral2);
+
+ sal_Int16 buildComparsionRule(OSQLParseNode*& pAppend,OSQLParseNode* pLiteral);
+ // pCompre will be deleted if it is not used
+ sal_Int16 buildPredicateRule(OSQLParseNode*& pAppend,OSQLParseNode* pLiteral,OSQLParseNode*& pCompare,OSQLParseNode* pLiteral2 = NULL);
+
+ sal_Int16 buildLikeRule(OSQLParseNode*& pAppend,OSQLParseNode*& pLiteral,const OSQLParseNode* pEscape);
+ sal_Int16 buildStringNodes(OSQLParseNode*& pLiteral);
+#else
+#endif
+ };
+}
+
+
+#endif //_CONNECTIVITY_SQLPARSE_HXX
diff --git a/connectivity/inc/connectivity/standardsqlstate.hxx b/connectivity/inc/connectivity/standardsqlstate.hxx
new file mode 100644
index 000000000000..5f855a890f5f
--- /dev/null
+++ b/connectivity/inc/connectivity/standardsqlstate.hxx
@@ -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.
+ *
+************************************************************************/
+
+#ifndef CONNECTIVITY_STANDARD_SQL_STATE_HXX
+#define CONNECTIVITY_STANDARD_SQL_STATE_HXX
+
+//.........................................................................
+namespace dbtools
+{
+//.........................................................................
+
+ //----------------------------------------------------------------------------------
+ /** standard SQLStates to be used with an SQLException
+
+ Extend this list whenever you need a new state ...
+
+ @see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcodbc_error_codes.asp
+ */
+ enum StandardSQLState
+ {
+ SQL_WRONG_PARAMETER_NUMBER, // 07001
+ SQL_INVALID_DESCRIPTOR_INDEX, // 07009
+ SQL_UNABLE_TO_CONNECT, // 08001
+ SQL_NUMERIC_OUT_OF_RANGE, // 22003
+ SQL_INVALID_DATE_TIME, // 22007
+ SQL_INVALID_CURSOR_STATE, // 24000
+ SQL_TABLE_OR_VIEW_EXISTS, // 42S01
+ SQL_TABLE_OR_VIEW_NOT_FOUND, // 42S02
+ SQL_INDEX_ESISTS, // 42S11
+ SQL_INDEX_NOT_FOUND, // 42S12
+ SQL_COLUMN_EXISTS, // 42S21
+ SQL_COLUMN_NOT_FOUND, // 42S22
+ SQL_GENERAL_ERROR, // HY000
+ SQL_INVALID_SQL_DATA_TYPE, // HY004
+ SQL_OPERATION_CANCELED, // HY008
+ SQL_FUNCTION_SEQUENCE_ERROR, // HY010
+ SQL_INVALID_CURSOR_POSITION, // HY109
+ SQL_INVALID_BOOKMARK_VALUE, // HY111
+ SQL_FEATURE_NOT_IMPLEMENTED, // HYC00
+ SQL_FUNCTION_NOT_SUPPORTED, // IM001
+ SQL_CONNECTION_DOES_NOT_EXIST, // 08003
+
+ SQL_ERROR_UNSPECIFIED = SAL_MAX_ENUM // special value indicating that an SQLState is not to be specified
+ };
+
+//.........................................................................
+} // namespace dbtools
+//.........................................................................
+
+#endif // CONNECTIVITY_STANDARD_SQL_STATE_HXX
diff --git a/connectivity/inc/connectivity/statementcomposer.hxx b/connectivity/inc/connectivity/statementcomposer.hxx
new file mode 100644
index 000000000000..3dde4d8e0b48
--- /dev/null
+++ b/connectivity/inc/connectivity/statementcomposer.hxx
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_STATEMENTCOMPOSER_HXX
+#define CONNECTIVITY_STATEMENTCOMPOSER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+/** === end UNO includes === **/
+
+#include <boost/noncopyable.hpp>
+
+#include <memory>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+//........................................................................
+namespace dbtools
+{
+//........................................................................
+
+ //====================================================================
+ //= StatementComposer
+ //====================================================================
+ struct StatementComposer_Data;
+ /** a class which is able to compose queries (SELECT statements) from a command and a command type
+ */
+ class OOO_DLLPUBLIC_DBTOOLS StatementComposer : public ::boost::noncopyable
+ {
+ ::std::auto_ptr< StatementComposer_Data > m_pData;
+
+ public:
+ /** constructs an instance
+
+ @param _rxConnection
+ the connection to work with. Must not be <NULL/>.
+ */
+ StatementComposer(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::rtl::OUString& _rCommand,
+ const sal_Int32 _nCommandType,
+ const sal_Bool _bEscapeProcessing
+ );
+
+ ~StatementComposer();
+
+ /** controls whether or not the instance disposes its XSingleSelectQueryComposer upon
+ destruction
+
+ Unless you explicitly call this method with the parameter being <TRUE/>,
+ the XSingleSelectQueryComposer will be disposed when the StatementComposer
+ instance is destroyed.
+ */
+ void setDisposeComposer( bool _bDoDispose );
+ bool getDisposeComposer() const;
+
+ void setFilter( const ::rtl::OUString& _rFilter );
+ void setOrder( const ::rtl::OUString& _rOrder );
+
+ /** returns the composer which has been fed with the current settings
+
+ @throws ::com::sun::star::sdbc::SQLException
+ if such an exception occurs while creating the composer
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >
+ getComposer();
+
+ /** returns the composer statement
+
+ Effectively, this is equivalent to calling getComposer, and asking the composer
+ for its Query attribute.
+
+ @throws ::com::sun::star::sdbc::SQLException
+ if such an exception occurs while creating the composer
+ */
+ ::rtl::OUString
+ getQuery();
+
+ private:
+ StatementComposer(); // not implemented
+ };
+
+//........................................................................
+} // namespace dbtools
+//........................................................................
+
+#endif // CONNECTIVITY_STATEMENTCOMPOSER_HXX
diff --git a/connectivity/inc/connectivity/virtualdbtools.hxx b/connectivity/inc/connectivity/virtualdbtools.hxx
new file mode 100644
index 000000000000..70b17dcb37c9
--- /dev/null
+++ b/connectivity/inc/connectivity/virtualdbtools.hxx
@@ -0,0 +1,358 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_VIRTUAL_DBTOOLS_HXX
+#define CONNECTIVITY_VIRTUAL_DBTOOLS_HXX
+
+#include <rtl/ref.hxx>
+#include <rtl/ustring.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/sdbc/SQLException.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <vector>
+#include <memory>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+//========================================================================
+//= forward declarations
+//========================================================================
+namespace com {
+ namespace sun {
+ namespace star {
+ namespace util {
+ class XNumberFormatter;
+ class XNumberFormatTypes;
+ class XNumberFormatsSupplier;
+ }
+ namespace beans {
+ class XPropertySet;
+ }
+ namespace lang {
+ class XMultiServiceFactory;
+ class XComponent;
+ class WrappedTargetException;
+ struct Locale;
+ }
+ namespace sdbc {
+ class XDatabaseMetaData;
+ class XConnection;
+ class XRowSet;
+ class XDataSource;
+ }
+ namespace sdb {
+ class XColumn;
+ class SQLContext;
+ }
+ namespace container {
+ class XNameAccess;
+ }
+ }
+ }
+}
+
+namespace dbtools {
+ class SQLExceptionInfo;
+ class FormattedColumnValue;
+}
+
+namespace comphelper {
+ class ComponentContext;
+}
+
+//========================================================================
+//= entry into this library
+//========================================================================
+/** this is the entry point for the load-on-call usage of the DBTOOLS
+ library.
+ <p>When you need one of the simple objects in this library, load the lib
+ and call this method. The returned pointer is a pointer to an IDataAccessToolsFactory
+ instance, which is acquired <em>once</em>.</p>
+ @return
+ a pointer to an object implementing the IDataAccessToolsFactory interface,
+ aquired exactly <em>once</em>.
+*/
+extern "C" OOO_DLLPUBLIC_DBTOOLS void* SAL_CALL createDataAccessToolsFactory();
+
+//========================================================================
+//=
+//========================================================================
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ class IParseContext;
+ //....................................................................
+ namespace simple
+ {
+ //....................................................................
+
+ typedef void* (SAL_CALL * createDataAccessToolsFactoryFunction)( );
+
+ //================================================================
+ //= IDataAccessTools
+ //================================================================
+ class OOO_DLLPUBLIC_DBTOOLS IDataAccessTools : public ::rtl::IReference
+ {
+ public:
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection_withFeedback(
+ const ::rtl::OUString& _rDataSourceName,
+ const ::rtl::OUString& _rUser,
+ const ::rtl::OUString& _rPwd,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory
+ ) const SAL_THROW ( (::com::sun::star::sdbc::SQLException) ) = 0;
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> connectRowset(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory,
+ sal_Bool _bSetAsActiveConnection
+ ) const SAL_THROW ( ( ::com::sun::star::sdbc::SQLException
+ , ::com::sun::star::lang::WrappedTargetException
+ , ::com::sun::star::uno::RuntimeException ) ) = 0;
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getRowSetConnection(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet)
+ const SAL_THROW ( (::com::sun::star::uno::RuntimeException) ) = 0;
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> getNumberFormats(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConn,
+ sal_Bool _bAllowDefault
+ ) const = 0;
+
+ virtual sal_Int32 getDefaultNumberFormat(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatTypes >& _rxTypes,
+ const ::com::sun::star::lang::Locale& _rLocale
+ ) const = 0;
+
+ virtual void TransferFormComponentProperties(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxOld,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxNew,
+ const ::com::sun::star::lang::Locale& _rLocale
+ ) const = 0;
+
+ virtual ::rtl::OUString quoteName(
+ const ::rtl::OUString& _rQuote,
+ const ::rtl::OUString& _rName
+ ) const = 0;
+
+ virtual ::rtl::OUString composeTableNameForSelect(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::rtl::OUString& _rCatalog,
+ const ::rtl::OUString& _rSchema,
+ const ::rtl::OUString& _rName
+ ) const = 0;
+
+ virtual ::rtl::OUString composeTableNameForSelect(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable
+ ) const = 0;
+
+ virtual ::com::sun::star::sdb::SQLContext prependContextInfo(
+ ::com::sun::star::sdbc::SQLException& _rException,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext,
+ const ::rtl::OUString& _rContextDescription,
+ const ::rtl::OUString& _rContextDetails
+ ) const = 0;
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource > getDataSource(
+ const ::rtl::OUString& _rsRegisteredName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory
+ ) const = 0;
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ getFieldsByCommandDescriptor(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const sal_Int32 _nCommandType,
+ const ::rtl::OUString& _rCommand,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _rxKeepFieldsAlive,
+ ::dbtools::SQLExceptionInfo* _pErrorInfo = NULL
+ ) SAL_THROW( ( ) ) = 0;
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getFieldNamesByCommandDescriptor(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const sal_Int32 _nCommandType,
+ const ::rtl::OUString& _rCommand,
+ ::dbtools::SQLExceptionInfo* _pErrorInfo = NULL
+ ) SAL_THROW( ( ) ) = 0;
+
+ /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::INSERT
+ @param _rxCursorSet the property set
+ */
+ virtual sal_Bool canInsert(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const = 0;
+
+ /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::UPDATE
+ @param _rxCursorSet the property set
+ */
+ virtual sal_Bool canUpdate(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const = 0;
+
+ /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::DELETE
+ @param _rxCursorSet the property set
+ */
+ virtual sal_Bool canDelete(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const = 0;
+
+ /** determines whether the given component is part of a document which is an embedded database
+ document (such as a form)
+ */
+ virtual bool isEmbeddedInDatabase(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent,
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxActualConnection
+ ) = 0;
+ };
+
+ //================================================================
+ //= IDataAccessCharSet
+ //================================================================
+ /** simple wrapper for the <type>OCharsetMap</type>
+ */
+ class OOO_DLLPUBLIC_DBTOOLS IDataAccessCharSet :
+ public ::rtl::IReference
+ {
+ // to be extended if necessary ....
+ public:
+ /** enumerates all supported char sets
+ @return the number of charsets supported
+ */
+ virtual sal_Int32 getSupportedTextEncodings(
+ ::std::vector< rtl_TextEncoding >& /* [out] */ _rEncs
+ ) const = 0;
+ };
+
+ //================================================================
+ //= IDataAccessTypeConversion
+ //================================================================
+ class OOO_DLLPUBLIC_DBTOOLS IDataAccessTypeConversion :
+ public ::rtl::IReference
+ {
+ public:
+ virtual ::com::sun::star::util::Date getStandardDate() const = 0;
+
+ virtual double getValue(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn>& _rxVariant,
+ const ::com::sun::star::util::Date& rNullDate,
+ sal_Int16 nKeyType) const = 0;
+
+ virtual ::rtl::OUString getValue(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxColumn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
+ const ::com::sun::star::util::Date& _rNullDate,
+ sal_Int32 _nKey,
+ sal_Int16 _nKeyType) const = 0;
+
+ virtual ::rtl::OUString getValue(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxColumn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter>& _rxFormatter,
+ const ::com::sun::star::lang::Locale& _rLocale,
+ const ::com::sun::star::util::Date& _rNullDate
+ ) const = 0;
+ };
+
+ //================================================================
+ //= ISQLParseNode
+ //================================================================
+ /** a simple version of the OSQLParseNode, with all methods beeing virtual
+ */
+ class OOO_DLLPUBLIC_DBTOOLS ISQLParseNode : public ::rtl::IReference
+ {
+ public:
+ virtual void parseNodeToStr(::rtl::OUString& _rString,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const IParseContext* _pContext
+ ) const = 0;
+
+ virtual void parseNodeToPredicateStr(::rtl::OUString& _rString,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField,
+ const ::com::sun::star::lang::Locale& _rIntl,
+ const sal_Char _cDecSeparator,
+ const IParseContext* _pContext
+ ) const = 0;
+ };
+
+ //================================================================
+ //= ISQLParser
+ //================================================================
+ /** a simple version of the OSQLParser, with all methods beeing virtual
+ */
+ class OOO_DLLPUBLIC_DBTOOLS ISQLParser : public ::rtl::IReference
+ {
+ public:
+ virtual ::rtl::Reference< ISQLParseNode > predicateTree(
+ ::rtl::OUString& rErrorMessage,
+ const ::rtl::OUString& rStatement,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField
+ ) const = 0;
+
+ virtual const IParseContext& getContext() const = 0;
+ };
+
+ //================================================================
+ //= IDataAccessToolsFactory
+ //================================================================
+ /** the main factory for runtime-loadable tools in the DBTOOLS library
+ */
+ class OOO_DLLPUBLIC_DBTOOLS IDataAccessToolsFactory :
+ public ::rtl::IReference
+ {
+ public:
+ /// creates a simple version of the class OSQLParser
+ virtual ::rtl::Reference< ISQLParser > createSQLParser(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxServiceFactory,
+ const IParseContext* _pContext
+ ) const = 0;
+
+ /// creates a helper for charset related functionality (<type>OCharsetMap</type>)
+ virtual ::rtl::Reference< IDataAccessCharSet > createCharsetHelper( ) const = 0;
+
+ /// creates a simple version of the DBTypeConversion helper
+ virtual ::rtl::Reference< IDataAccessTypeConversion > getTypeConversionHelper() = 0;
+
+ /// creates a helper which can be used to access the static methods in dbtools.hxx
+ virtual ::rtl::Reference< IDataAccessTools > getDataAccessTools() = 0;
+
+ virtual ::std::auto_ptr< ::dbtools::FormattedColumnValue > createFormattedColumnValue(
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& _rxRowSet,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn
+ ) = 0;
+ };
+
+ //....................................................................
+ } // namespace simple
+ //....................................................................
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
+#endif // CONNECTIVITY_VIRTUAL_DBTOOLS_HXX
+
diff --git a/connectivity/inc/connectivity/warningscontainer.hxx b/connectivity/inc/connectivity/warningscontainer.hxx
new file mode 100644
index 000000000000..feb631a2098e
--- /dev/null
+++ b/connectivity/inc/connectivity/warningscontainer.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef DBTOOLS_WARNINGSCONTAINER_HXX
+#define DBTOOLS_WARNINGSCONTAINER_HXX
+
+/** ==== begin UNO includes === **/
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+/** ==== end UNO includes === **/
+
+#include "connectivity/dbtoolsdllapi.hxx"
+
+//.........................................................................
+namespace dbtools
+{
+//.........................................................................
+
+ //=====================================================================
+ //= IWarningsContainer
+ //=====================================================================
+ class SAL_NO_VTABLE IWarningsContainer
+ {
+ public:
+ virtual void appendWarning(const ::com::sun::star::sdbc::SQLException& _rWarning) = 0;
+ virtual void appendWarning(const ::com::sun::star::sdbc::SQLWarning& _rWarning) = 0;
+ virtual void appendWarning(const ::com::sun::star::sdb::SQLContext& _rContext) = 0;
+ };
+
+ //====================================================================
+ //= WarningsContainer
+ //====================================================================
+ /** helper class for implementing XWarningsSupplier, which mixes own warnings with
+ warnings obtained from an external instance
+ */
+ class OOO_DLLPUBLIC_DBTOOLS WarningsContainer : public IWarningsContainer
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XWarningsSupplier > m_xExternalWarnings;
+ ::com::sun::star::uno::Any m_aOwnWarnings;
+
+ public:
+ WarningsContainer() { }
+ WarningsContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XWarningsSupplier >& _rxExternalWarnings )
+ :m_xExternalWarnings( _rxExternalWarnings )
+ {
+ }
+ virtual ~WarningsContainer();
+
+ void setExternalWarnings( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XWarningsSupplier >& _rxExternalWarnings )
+ {
+ m_xExternalWarnings = _rxExternalWarnings;
+ }
+
+ // convenience
+ /** appends an SQLWarning instance to the chain
+ @param _rWarning
+ the warning message
+ @param _pAsciiSQLState
+ the SQLState of the warning
+ @param _rxContext
+ the context of the warning
+ */
+ void appendWarning(
+ const ::rtl::OUString& _rWarning,
+ const sal_Char* _pAsciiSQLState,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext );
+
+ // IWarningsContainer
+ virtual void appendWarning(const ::com::sun::star::sdbc::SQLException& _rWarning);
+ virtual void appendWarning(const ::com::sun::star::sdbc::SQLWarning& _rWarning);
+ virtual void appendWarning(const ::com::sun::star::sdb::SQLContext& _rContext);
+
+ // XWarningsSupplier equivalents
+ ::com::sun::star::uno::Any SAL_CALL getWarnings( ) const;
+ void SAL_CALL clearWarnings( );
+ };
+
+//.........................................................................
+} // namespace dbtools
+//.........................................................................
+
+#endif // DBTOOLS_WARNINGSCONTAINER_HXX
diff --git a/connectivity/inc/makefile.mk b/connectivity/inc/makefile.mk
new file mode 100644
index 000000000000..51a3f225b30a
--- /dev/null
+++ b/connectivity/inc/makefile.mk
@@ -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.
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME=connectivity
+TARGET=inc
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+.IF "$(ENABLE_PCH)"!=""
+ALLTAR : \
+ $(SLO)$/precompiled.pch \
+ $(SLO)$/precompiled_ex.pch
+
+.ENDIF # "$(ENABLE_PCH)"!=""
+
diff --git a/connectivity/inc/pch/precompiled_connectivity.cxx b/connectivity/inc/pch/precompiled_connectivity.cxx
new file mode 100644
index 000000000000..edbfe3801613
--- /dev/null
+++ b/connectivity/inc/pch/precompiled_connectivity.cxx
@@ -0,0 +1,29 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "precompiled_connectivity.hxx"
+
diff --git a/connectivity/inc/pch/precompiled_connectivity.hxx b/connectivity/inc/pch/precompiled_connectivity.hxx
new file mode 100644
index 000000000000..41571202327a
--- /dev/null
+++ b/connectivity/inc/pch/precompiled_connectivity.hxx
@@ -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): Generated on 2006-09-01 17:49:36.436601
+
+#ifdef PRECOMPILED_HEADERS
+
+//---MARKER---
+#include "sal/config.h"
+#include "sal/types.h"
+
+#include "boost/shared_ptr.hpp"
+
+#include "com/sun/star/awt/XWindow.hpp"
+#include "com/sun/star/beans/NamedValue.hpp"
+#include "com/sun/star/beans/Property.hpp"
+#include "com/sun/star/beans/PropertyAttribute.hpp"
+#include "com/sun/star/beans/PropertyState.hpp"
+#include "com/sun/star/beans/PropertyValue.hpp"
+#include "com/sun/star/beans/XFastPropertySet.hpp"
+#include "com/sun/star/beans/XPropertyChangeListener.hpp"
+#include "com/sun/star/beans/XPropertySet.hpp"
+#include "com/sun/star/beans/XPropertySetInfo.hpp"
+#include "com/sun/star/connection/XConnection.hpp"
+#include "com/sun/star/container/ElementExistException.hpp"
+#include "com/sun/star/container/XChild.hpp"
+#include "com/sun/star/container/XContainer.hpp"
+#include "com/sun/star/container/XContentEnumerationAccess.hpp"
+#include "com/sun/star/container/XEnumeration.hpp"
+#include "com/sun/star/container/XEnumerationAccess.hpp"
+#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
+#include "com/sun/star/container/XIndexAccess.hpp"
+#include "com/sun/star/container/XNameAccess.hpp"
+#include "com/sun/star/container/XNamed.hpp"
+#include "com/sun/star/document/XDocumentSubStorageSupplier.hpp"
+#include "com/sun/star/embed/ElementModes.hpp"
+#include "com/sun/star/embed/XStorage.hpp"
+#include "com/sun/star/embed/XTransactedObject.hpp"
+#include "com/sun/star/embed/XTransactionBroadcaster.hpp"
+#include "com/sun/star/embed/XTransactionListener.hpp"
+#include "com/sun/star/form/FormComponentType.hpp"
+#include "com/sun/star/frame/XComponentLoader.hpp"
+#include "com/sun/star/frame/XDesktop.hpp"
+#include "com/sun/star/frame/XModel.hpp"
+#include "com/sun/star/frame/XTerminateListener.hpp"
+#include "com/sun/star/graphic/GraphicColorMode.hpp"
+#include "com/sun/star/graphic/XGraphicProvider.hpp"
+#include "com/sun/star/i18n/KParseTokens.hpp"
+#include "com/sun/star/i18n/KParseType.hpp"
+#include "com/sun/star/i18n/NumberFormatIndex.hpp"
+#include "com/sun/star/i18n/XCharacterClassification.hpp"
+#include "com/sun/star/i18n/XLocaleData.hpp"
+#include "com/sun/star/io/IOException.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/io/XStream.hpp"
+#include "com/sun/star/java/XJavaVM.hpp"
+#include "com/sun/star/lang/DisposedException.hpp"
+#include "com/sun/star/lang/IllegalArgumentException.hpp"
+#include "com/sun/star/lang/IndexOutOfBoundsException.hpp"
+#include "com/sun/star/lang/Locale.hpp"
+#include "com/sun/star/lang/NullPointerException.hpp"
+#include "com/sun/star/lang/ServiceNotRegisteredException.hpp"
+#include "com/sun/star/lang/XComponent.hpp"
+#include "com/sun/star/lang/XEventListener.hpp"
+#include "com/sun/star/lang/XInitialization.hpp"
+#include "com/sun/star/lang/XMultiServiceFactory.hpp"
+#include "com/sun/star/lang/XServiceInfo.hpp"
+#include "com/sun/star/lang/XSingleComponentFactory.hpp"
+#include "com/sun/star/lang/XSingleServiceFactory.hpp"
+#include "com/sun/star/lang/XUnoTunnel.hpp"
+#include "com/sun/star/mozilla/MozillaProductType.hpp"
+#include "com/sun/star/mozilla/XCodeProxy.hpp"
+#include "com/sun/star/mozilla/XMozillaBootstrap.hpp"
+#include "com/sun/star/mozilla/XProxyRunner.hdl"
+#include "com/sun/star/mozilla/XProxyRunner.hpp"
+#include "com/sun/star/reflection/XProxyFactory.hpp"
+#include "com/sun/star/registry/XImplementationRegistration.hpp"
+#include "com/sun/star/script/XTypeConverter.hpp"
+#include "com/sun/star/sdb/CommandType.hpp"
+#include "com/sun/star/sdb/ParametersRequest.hpp"
+#include "com/sun/star/sdb/RowSetVetoException.hpp"
+#include "com/sun/star/sdb/SQLContext.hpp"
+#include "com/sun/star/sdb/SQLErrorEvent.hpp"
+#include "com/sun/star/sdb/SQLFilterOperator.hpp"
+#include "com/sun/star/sdb/XColumn.hpp"
+#include "com/sun/star/sdb/XColumnUpdate.hpp"
+#include "com/sun/star/sdb/XCompletedConnection.hpp"
+#include "com/sun/star/sdb/XDatabaseEnvironment.hpp"
+#include "com/sun/star/sdb/XInteractionSupplyParameters.hpp"
+#include "com/sun/star/sdb/XParametersSupplier.hpp"
+#include "com/sun/star/sdb/XQueriesSupplier.hpp"
+#include "com/sun/star/sdb/XSingleSelectQueryComposer.hpp"
+#include "com/sun/star/sdb/application/XTableUIProvider.hpp"
+#include "com/sun/star/sdbc/ColumnSearch.hpp"
+#include "com/sun/star/sdbc/ColumnValue.hpp"
+#include "com/sun/star/sdbc/DataType.hpp"
+#include "com/sun/star/sdbc/DriverPropertyInfo.hpp"
+#include "com/sun/star/sdbc/FetchDirection.hpp"
+#include "com/sun/star/sdbc/IndexType.hpp"
+#include "com/sun/star/sdbc/KeyRule.hpp"
+#include "com/sun/star/sdbc/ProcedureResult.hpp"
+#include "com/sun/star/sdbc/ResultSetConcurrency.hpp"
+#include "com/sun/star/sdbc/ResultSetType.hpp"
+#include "com/sun/star/sdbc/SQLException.hpp"
+#include "com/sun/star/sdbc/SQLWarning.hpp"
+#include "com/sun/star/sdbc/TransactionIsolation.hpp"
+#include "com/sun/star/sdbc/XArray.hpp"
+#include "com/sun/star/sdbc/XBatchExecution.hpp"
+#include "com/sun/star/sdbc/XBlob.hpp"
+#include "com/sun/star/sdbc/XClob.hpp"
+#include "com/sun/star/sdbc/XCloseable.hpp"
+#include "com/sun/star/sdbc/XColumnLocate.hpp"
+#include "com/sun/star/sdbc/XConnection.hpp"
+#include "com/sun/star/sdbc/XDataSource.hpp"
+#include "com/sun/star/sdbc/XDatabaseMetaData.hpp"
+#include "com/sun/star/sdbc/XDriver.hpp"
+#include "com/sun/star/sdbc/XDriverAccess.hpp"
+#include "com/sun/star/sdbc/XDriverManager.hpp"
+#include "com/sun/star/sdbc/XGeneratedResultSet.hpp"
+#include "com/sun/star/sdbc/XMultipleResults.hpp"
+#include "com/sun/star/sdbc/XOutParameters.hpp"
+#include "com/sun/star/sdbc/XParameters.hpp"
+#include "com/sun/star/sdbc/XPooledConnection.hpp"
+#include "com/sun/star/sdbc/XPreparedBatchExecution.hpp"
+#include "com/sun/star/sdbc/XPreparedStatement.hpp"
+#include "com/sun/star/sdbc/XRef.hpp"
+#include "com/sun/star/sdbc/XResultSet.hpp"
+#include "com/sun/star/sdbc/XResultSetMetaData.hpp"
+#include "com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp"
+#include "com/sun/star/sdbc/XResultSetUpdate.hpp"
+#include "com/sun/star/sdbc/XRow.hpp"
+#include "com/sun/star/sdbc/XRowSet.hpp"
+#include "com/sun/star/sdbc/XRowUpdate.hpp"
+#include "com/sun/star/sdbc/XStatement.hpp"
+#include "com/sun/star/sdbc/XWarningsSupplier.hpp"
+#include "com/sun/star/sdbcx/CheckOption.hpp"
+#include "com/sun/star/sdbcx/CompareBookmark.hpp"
+#include "com/sun/star/sdbcx/KeyType.hpp"
+#include "com/sun/star/sdbcx/Privilege.hpp"
+#include "com/sun/star/sdbcx/PrivilegeObject.hpp"
+#include "com/sun/star/sdbcx/XAlterTable.hpp"
+#include "com/sun/star/sdbcx/XAppend.hpp"
+#include "com/sun/star/sdbcx/XAuthorizable.hpp"
+#include "com/sun/star/sdbcx/XColumnsSupplier.hpp"
+#include "com/sun/star/sdbcx/XCreateCatalog.hpp"
+#include "com/sun/star/sdbcx/XDataDefinitionSupplier.hpp"
+#include "com/sun/star/sdbcx/XDataDescriptorFactory.hpp"
+#include "com/sun/star/sdbcx/XDeleteRows.hpp"
+#include "com/sun/star/sdbcx/XDrop.hpp"
+#include "com/sun/star/sdbcx/XGroupsSupplier.hpp"
+#include "com/sun/star/sdbcx/XIndexesSupplier.hpp"
+#include "com/sun/star/sdbcx/XKeysSupplier.hpp"
+#include "com/sun/star/sdbcx/XRename.hpp"
+#include "com/sun/star/sdbcx/XRowLocate.hpp"
+#include "com/sun/star/sdbcx/XTablesSupplier.hpp"
+#include "com/sun/star/sdbcx/XUser.hpp"
+#include "com/sun/star/sdbcx/XUsersSupplier.hpp"
+#include "com/sun/star/sdbcx/XViewsSupplier.hpp"
+#include "com/sun/star/sheet/CellFlags.hpp"
+#include "com/sun/star/sheet/XCellRangeAddressable.hpp"
+#include "com/sun/star/sheet/XCellRangeReferrer.hpp"
+#include "com/sun/star/sheet/XCellRangesQuery.hpp"
+#include "com/sun/star/sheet/XDatabaseRange.hpp"
+#include "com/sun/star/sheet/XDatabaseRanges.hpp"
+#include "com/sun/star/sheet/XSpreadsheet.hpp"
+#include "com/sun/star/sheet/XSpreadsheetDocument.hpp"
+#include "com/sun/star/sheet/XUsedAreaCursor.hpp"
+#include "com/sun/star/task/XInteractionHandler.hpp"
+#include "com/sun/star/task/XInteractionRequest.hpp"
+#include "com/sun/star/text/XText.hpp"
+#include "com/sun/star/ucb/SearchCommandArgument.hpp"
+#include "com/sun/star/ucb/SearchRecursion.hpp"
+#include "com/sun/star/ucb/XCommandEnvironment.hpp"
+#include "com/sun/star/ucb/XContent.hpp"
+#include "com/sun/star/ucb/XContentAccess.hpp"
+#include "com/sun/star/ucb/XContentIdentifier.hpp"
+#include "com/sun/star/ucb/XContentProvider.hpp"
+#include "com/sun/star/ucb/XContentProviderManager.hpp"
+#include "com/sun/star/ucb/XDynamicResultSet.hpp"
+#include "com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp"
+#include "com/sun/star/ui/dialogs/XExecutableDialog.hpp"
+#include "com/sun/star/uno/Any.hxx"
+#include "com/sun/star/uno/Exception.hpp"
+#include "com/sun/star/uno/Reference.h"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "com/sun/star/uno/Sequence.h"
+#include "com/sun/star/uno/Sequence.hxx"
+#include "com/sun/star/uno/XAggregation.hpp"
+#include "com/sun/star/uno/XInterface.hpp"
+#include "com/sun/star/uno/XNamingService.hpp"
+#include "com/sun/star/util/Date.hpp"
+#include "com/sun/star/util/DateTime.hpp"
+#include "com/sun/star/util/NumberFormat.hpp"
+#include "com/sun/star/util/Time.hpp"
+#include "com/sun/star/util/XCancellable.hpp"
+#include "com/sun/star/util/XFlushable.hpp"
+#include "com/sun/star/util/XNumberFormatTypes.hpp"
+#include "com/sun/star/util/XNumberFormats.hpp"
+#include "com/sun/star/util/XNumberFormatsSupplier.hpp"
+#include "com/sun/star/util/XNumberFormatter.hpp"
+#include "com/sun/star/util/XRefreshable.hpp"
+
+#include "comphelper/broadcasthelper.hxx"
+#include "comphelper/componentcontext.hxx"
+#include "comphelper/container.hxx"
+#include "comphelper/enumhelper.hxx"
+#include "comphelper/evtlistenerhlp.hxx"
+#include "comphelper/interaction.hxx"
+#include "comphelper/listenernotification.hxx"
+#include "comphelper/numbers.hxx"
+#include "comphelper/officeresourcebundle.hxx"
+#include "comphelper/processfactory.hxx"
+#include "comphelper/propertycontainer.hxx"
+#include "comphelper/regpathhelper.hxx"
+#include "comphelper/seqstream.hxx"
+#include "comphelper/sequence.hxx"
+#include "comphelper/types.hxx"
+#include "comphelper/uno3.hxx"
+
+#include "cppuhelper/bootstrap.hxx"
+#include "cppuhelper/compbase1.hxx"
+#include "cppuhelper/compbase10.hxx"
+#include "cppuhelper/compbase12.hxx"
+#include "cppuhelper/compbase2.hxx"
+#include "cppuhelper/compbase3.hxx"
+#include "cppuhelper/compbase4.hxx"
+#include "cppuhelper/compbase5.hxx"
+#include "cppuhelper/compbase6.hxx"
+#include "cppuhelper/compbase7.hxx"
+#include "cppuhelper/compbase8.hxx"
+#include "cppuhelper/component.hxx"
+#include "cppuhelper/component_context.hxx"
+#include "cppuhelper/exc_hlp.hxx"
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implbase1.hxx"
+#include "cppuhelper/implbase10.hxx"
+#include "cppuhelper/implbase2.hxx"
+#include "cppuhelper/implbase3.hxx"
+#include "cppuhelper/implbase4.hxx"
+#include "cppuhelper/implbase5.hxx"
+#include "cppuhelper/interfacecontainer.h"
+#include "cppuhelper/interfacecontainer.hxx"
+#include "cppuhelper/propshlp.hxx"
+#include "cppuhelper/queryinterface.hxx"
+#include "cppuhelper/servicefactory.hxx"
+#include "cppuhelper/typeprovider.hxx"
+#include "cppuhelper/weak.hxx"
+#include "cppuhelper/weakref.hxx"
+
+#include "i18npool/mslangid.hxx"
+
+#include "jvmaccess/virtualmachine.hxx"
+
+#include "jvmfwk/framework.h"
+
+#include "osl/conditn.hxx"
+#include "osl/diagnose.h"
+#include "osl/file.h"
+#include "osl/file.hxx"
+#include "osl/interlck.h"
+#include "osl/module.h"
+#include "osl/mutex.hxx"
+#include "osl/nlsupport.h"
+#include "osl/process.h"
+#include "osl/security.hxx"
+#include "osl/thread.h"
+#include "osl/thread.hxx"
+
+#include "rtl/alloc.h"
+#include "rtl/bootstrap.hxx"
+#include "rtl/byteseq.hxx"
+#include "rtl/digest.h"
+#include "rtl/logfile.hxx"
+#include "rtl/math.hxx"
+#include "rtl/process.h"
+#include "rtl/ref.hxx"
+#include "rtl/string.h"
+#include "rtl/string.hxx"
+#include "rtl/tencinfo.h"
+#include "rtl/textenc.h"
+#include "rtl/ustrbuf.hxx"
+#include "rtl/ustring.hxx"
+
+#include "sys/types.h"
+
+#include "tools/diagnose_ex.h"
+
+#include "ucbhelper/content.hxx"
+#include "ucbhelper/contentbroker.hxx"
+
+#include "uno/environment.hxx"
+#include "uno/mapping.hxx"
+
+#include "unotools/configmgr.hxx"
+#include "unotools/confignode.hxx"
+#include "unotools/processfactory.hxx"
+#include "unotools/sharedunocomponent.hxx"
+
+#include "vos/mutex.hxx"
+#include "vos/process.hxx"
+#include "vos/ref.hxx"
+#include "vos/ref.hxx"
+#include "vos/refernce.hxx"
+#include "vos/timer.hxx"
+//---MARKER---
+
+#endif
diff --git a/connectivity/makefile.pmk b/connectivity/makefile.pmk
new file mode 100755
index 000000000000..fe56884dba94
--- /dev/null
+++ b/connectivity/makefile.pmk
@@ -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.
+#
+#*************************************************************************
+
+XSLDIR=$(SOLARXMLDIR)$/processing
+ABSXCSROOT=$(PWD)$/$(MISC)
+# ABSXCSROOT=$(MISC)
+XCSROOT=..
+# XCSROOT=$(SOLARXMLDIR)
+# ABSXCSROOT=$(SOLARXMLDIR)
+DTDDIR=$(SOLARXMLDIR)
+PROCESSOUT=$(MISC)
+PROCESSORDIR=$(SOLARBINDIR)
+
+
+# no validation by inspector class
+NO_INSPECTION=TRUE
+
+JAVAPREPRO=
+.IF "$(JDK_VERSION)" == "110"
+JAVAPREPRO=-jdk11
+.ENDIF
+.IF "$(PRODUCT)" != ""
+JAVAPREPRO=$(JAVAPREPRO) + " -product"
+.ENDIF
+
+# --- Settings -----------------------------------------------------
+PACKAGE=org.openoffice.Office.DataAccess
+.INCLUDE : settings.mk
+
+COMPONENT_CONFIG_DATA*=$(TARGET).xcu
+
+LOCALIZEDFILES= \
+ $(COMPONENT_CONFIG_DATA)
+
+XCUFILES= \
+ $(LOCALIZEDFILES) \
+
+
diff --git a/connectivity/prj/build.lst b/connectivity/prj/build.lst
new file mode 100644
index 000000000000..0b15c06acf15
--- /dev/null
+++ b/connectivity/prj/build.lst
@@ -0,0 +1,32 @@
+cn connectivity : shell l10n comphelper MOZ:moz SO:moz_prebuilt svl UNIXODBC:unixODBC unoil javaunohelper HSQLDB:hsqldb qadevOOo officecfg NSS:nss NULL
+cn connectivity usr1 - all cn_mkout NULL
+cn connectivity\inc nmake - all cn_inc NULL
+cn connectivity\com\sun\star\sdbcx\comp\hsqldb nmake - all cn_jhsqldbdb cn_hsqldb cn_inc NULL
+cn connectivity\source\commontools nmake - all cn_cmtools cn_parse cn_inc NULL
+cn connectivity\source\manager nmake - all cn_manager cn_dbtools cn_inc NULL
+cn connectivity\source\cpool nmake - all cn_cpool cn_dbtools cn_inc NULL
+cn connectivity\source\resource nmake - all cn_res cn_inc NULL
+cn connectivity\source\sdbcx nmake - all cn_sdbcx cn_inc NULL
+cn connectivity\source\drivers\ado nmake - all cn_ado cn_dbtools cn_inc NULL
+cn connectivity\source\drivers\mozab\mozillasrc nmake - all cn_mozab_mozillasrc cn_file cn_inc NULL
+cn connectivity\source\drivers\mozab\bootstrap nmake - all cn_mozab_bootstrap cn_mozab_mozillasrc cn_inc NULL
+cn connectivity\source\drivers\mozab nmake - all cn_mozab cn_mozab_bootstrap cn_dbtools cn_inc NULL
+cn connectivity\source\drivers\kab nmake - all cn_kab cn_dbtools cn_inc NULL
+cn connectivity\source\drivers\macab nmake - all cn_macab cn_dbtools cn_inc NULL
+cn connectivity\source\drivers\evoab2 nmake - all cn_evoab2 cn_dbtools cn_file cn_inc NULL
+cn connectivity\source\drivers\calc nmake - all cn_calc cn_file cn_inc NULL
+cn connectivity\source\drivers\odbcbase nmake - all cn_odbcbase cn_dbtools cn_inc NULL
+cn connectivity\source\drivers\odbc nmake - all cn_odbc cn_odbcbase cn_inc NULL
+cn connectivity\source\drivers\mysql nmake - all cn_mysql cn_dbtools cn_inc NULL
+cn connectivity\source\drivers\jdbc nmake - all cn_jdbc cn_dbtools cn_inc NULL
+cn connectivity\source\drivers\adabas nmake - all cn_adabas cn_dbtools cn_odbcbase cn_inc NULL
+cn connectivity\source\drivers\file nmake - all cn_file cn_dbtools cn_inc NULL
+cn connectivity\source\drivers\flat nmake - all cn_flat cn_dbtools cn_file cn_inc NULL
+cn connectivity\source\drivers\dbase nmake - all cn_dbase cn_dbtools cn_file cn_inc NULL
+cn connectivity\source\drivers\hsqldb nmake - all cn_hsqldb cn_dbtools cn_inc NULL
+cn connectivity\source\parse nmake - all cn_parse cn_inc NULL
+cn connectivity\source\simpledbt nmake - all cn_simpledbt cn_cmtools cn_inc NULL
+cn connectivity\source\dbtools nmake - all cn_dbtools cn_simpledbt cn_cmtools cn_parse cn_res cn_sdbcx cn_inc cn_res NULL
+cn connectivity\qa\connectivity\tools nmake - all cn_qa_tools cn_inc NULL
+cn connectivity\util nmake - all cn_util cn_ado cn_mozab cn_kab cn_evoab2 cn_calc cn_odbc cn_mysql cn_jdbc cn_adabas cn_flat cn_dbase cn_hsqldb cn_macab NULL
+
diff --git a/connectivity/prj/d.lst b/connectivity/prj/d.lst
new file mode 100644
index 000000000000..e116ee5740ac
--- /dev/null
+++ b/connectivity/prj/d.lst
@@ -0,0 +1,33 @@
+..\%__SRC%\bin\*.dll %_DEST%\bin%_EXT%\*.dll
+..\%__SRC%\bin\*.res %_DEST%\bin%_EXT%\*.res
+..\%__SRC%\lib\lib*.so %_DEST%\lib%_EXT%\lib*.so
+..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib
+..\%__SRC%\slb\connectivity*.* %_DEST%\lib%_EXT%\connectivity*.*
+..\%__SRC%\lib\idbt* %_DEST%\lib%_EXT%\idbt*
+..\source\cpool\*.xml %_DEST%\xml%_EXT%\*.xml
+..\source\drivers\adabas\*.xml %_DEST%\xml%_EXT%\*.xml
+..\source\drivers\ado\*.xml %_DEST%\xml%_EXT%\*.xml
+..\source\drivers\kab\*.xml %_DEST%\xml%_EXT%\*.xml
+..\source\drivers\macab\*.xml %_DEST%\xml%_EXT%\*.xml
+..\source\drivers\file\*.xml %_DEST%\xml%_EXT%\*.xml
+..\source\drivers\flat\*.xml %_DEST%\xml%_EXT%\*.xml
+..\source\drivers\dbase\*.xml %_DEST%\xml%_EXT%\*.xml
+..\source\drivers\jdbc\*.xml %_DEST%\xml%_EXT%\*.xml
+..\source\drivers\odbc\*.xml %_DEST%\xml%_EXT%\*.xml
+..\source\drivers\mozab\*.xml %_DEST%\xml%_EXT%\*.xml
+..\source\drivers\evoab2\*.xml %_DEST%\xml%_EXT%\*.xml
+..\source\drivers\calc\*.xml %_DEST%\xml%_EXT%\*.xml
+..\source\drivers\mysql\*.xml %_DEST%\xml%_EXT%\*.xml
+..\%__SRC%\class\*.jar %_DEST%\bin%_EXT%\*.jar
+
+mkdir: %_DEST%\inc%_EXT%\connectivity
+mkdir: %_DEST%\inc%_EXT%\connectivity\sdbcx
+mkdir: %_DEST%\xml%_EXT%\registry\spool\DataAccess
+
+..\inc\connectivity\*.hxx %_DEST%\inc%_EXT%\connectivity\*.hxx
+..\%__SRC%\inc\sqlbison.hxx %_DEST%\inc%_EXT%\connectivity\sqlbison.hxx
+..\inc\connectivity\sdbcx\*.hxx %_DEST%\inc%_EXT%\connectivity\sdbcx\*.hxx
+#..\version.mk %_DEST%\inc%_EXT%\connectivity\version.mk
+..\%__SRC%\misc\registry\data\org\openoffice\Office\DataAccess\*.xcu %_DEST%\xml%_EXT%\registry\spool\DataAccess\*.xcu
+..\%COMMON_OUTDIR%\bin\fcfg_drivers_*.zip %_DEST%\pck%_EXT%\fcfg_drivers_*.zip
+..\%__SRC%\bin\fcfg_drivers_*.zip %_DEST%\pck%_EXT%\fcfg_drivers_*.zip
diff --git a/connectivity/qa/connectivity/GeneralTest.java b/connectivity/qa/connectivity/GeneralTest.java
new file mode 100644
index 000000000000..a69ac5c1048f
--- /dev/null
+++ b/connectivity/qa/connectivity/GeneralTest.java
@@ -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.
+ *
+ ************************************************************************/
+package complex.connectivity;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.sdbc.*;
+
+import com.sun.star.lang.XMultiServiceFactory;
+
+import complexlib.ComplexTestCase;
+
+
+//import complex.connectivity.DBaseStringFunctions;
+
+public class GeneralTest extends ComplexTestCase {
+
+ public String[] getTestMethodNames() {
+ return new String[] { "test" };
+ }
+
+ public String getTestObjectName() {
+ return "GeneralTest";
+ }
+ public void assure2(String s,boolean b){
+ assure(s,b);
+ }
+
+ public void test() throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException {
+ try
+ {
+ XDriverManager driverManager = UnoRuntime.queryInterface( XDriverManager.class, ((XMultiServiceFactory)param.getMSF()).createInstance( "com.sun.star.sdbc.DriverManager" ) );
+ String databaseURL = "sdbc:calc:singin' in the rain" ;
+ XConnection catalogConnection = driverManager.getConnection(databaseURL);
+ failed();
+ }
+ catch(SQLException e){}
+ }
+}
diff --git a/connectivity/qa/connectivity/makefile.mk b/connectivity/qa/connectivity/makefile.mk
new file mode 100644
index 000000000000..785f20692da3
--- /dev/null
+++ b/connectivity/qa/connectivity/makefile.mk
@@ -0,0 +1,65 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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 = ..$/..
+TARGET = GeneralTest
+PRJNAME = connectivity
+PACKAGE = complex$/connectivity
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
+JAVAFILES =\
+ $(TARGET).java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+ALL : ALLTAR
+.ELSE
+ALL: ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+
+run:
+ java -cp $(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/OOoRunner.jar org.openoffice.Runner -TestBase java_complex -o complex.connectivity.$(TARGET)
+
diff --git a/connectivity/qa/connectivity/tools/AbstractDatabase.java b/connectivity/qa/connectivity/tools/AbstractDatabase.java
new file mode 100755
index 000000000000..b47c7c7961da
--- /dev/null
+++ b/connectivity/qa/connectivity/tools/AbstractDatabase.java
@@ -0,0 +1,222 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package connectivity.tools;
+
+import com.sun.star.container.XNameAccess;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XStorable;
+import com.sun.star.io.IOException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XDocumentDataSource;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XCloseable;
+import com.sun.star.sdbc.XStatement;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.CloseVetoException;
+import connectivity.tools.sdb.Connection;
+import java.io.File;
+
+/**
+ *
+ * @author oj93728
+ */
+public abstract class AbstractDatabase implements DatabaseAccess
+{
+ // the service factory
+
+ protected final XMultiServiceFactory m_orb;
+ // the URL of the temporary file used for the database document
+ protected String m_databaseDocumentFile;
+ // the database document
+ protected XOfficeDatabaseDocument m_databaseDocument;
+ // the data source belonging to the database document
+ protected DataSource m_dataSource;
+ // the default connection
+ protected Connection m_connection;
+
+ public AbstractDatabase(final XMultiServiceFactory orb) throws Exception
+ {
+ m_orb = orb;
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ public AbstractDatabase(final XMultiServiceFactory orb, final String _existingDocumentURL ) throws Exception
+ {
+ m_orb = orb;
+ createDBDocument( _existingDocumentURL );
+ }
+
+ /** returns a connection to the database
+ *
+ * Multiple calls to this method return the same connection. The DbaseDatabase object keeps
+ * the ownership of the connection, so you don't need to (and should not) dispose/close it.
+ *
+ */
+ public Connection defaultConnection() throws SQLException
+ {
+ if ( m_connection == null )
+ m_connection = new Connection( m_databaseDocument.getDataSource().getConnection("", "") );
+
+ return m_connection;
+ }
+
+ /** executes the given SQL statement via the defaultConnection
+ */
+ public void executeSQL(final String statementString) throws SQLException
+ {
+ final XStatement statement = defaultConnection().createStatement();
+ statement.execute(statementString);
+ }
+
+ /** stores the database document
+ */
+ public void store() throws IOException
+ {
+ if (m_databaseDocument != null)
+ {
+ final XStorable storeDoc = UnoRuntime.queryInterface(XStorable.class, m_databaseDocument);
+ storeDoc.store();
+ }
+ }
+
+ /** closes the database document
+ *
+ * Any CloseVetoExceptions fired by third parties are ignored, and any reference to the
+ * database document is released.
+ */
+ public void close()
+ {
+ // close connection
+ final XCloseable closeConn = UnoRuntime.queryInterface( XCloseable.class,
+ m_connection != null ? m_connection.getXConnection() : null );
+ if (closeConn != null)
+ {
+ try
+ {
+ closeConn.close();
+ }
+ catch (SQLException e)
+ {
+ }
+ }
+ m_connection = null;
+
+ // close document
+ final com.sun.star.util.XCloseable closeDoc = UnoRuntime.queryInterface( com.sun.star.util.XCloseable.class, m_databaseDocument );
+ if (closeDoc != null)
+ {
+ try
+ {
+ closeDoc.close(true);
+ }
+ catch (CloseVetoException e)
+ {
+ }
+ }
+ m_databaseDocument = null;
+ }
+
+ /** closes the document, and deletes the underlying file
+ */
+ public void closeAndDelete()
+ {
+ close();
+
+ if (m_databaseDocumentFile != null)
+ {
+ try
+ {
+ final File file = new File(m_databaseDocumentFile);
+ file.delete();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+
+ /** returns the underlying database document
+ */
+ public XOfficeDatabaseDocument getDatabaseDocument()
+ {
+ return m_databaseDocument;
+ }
+
+ /** returns the model interface of the underlying database document
+ */
+ public XModel getModel()
+ {
+ return UnoRuntime.queryInterface( XModel.class, m_databaseDocument );
+ }
+
+ public XMultiServiceFactory getORB()
+ {
+ return m_orb;
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ final protected void createDBDocument(final String _docURL) throws Exception
+ {
+ m_databaseDocumentFile = _docURL;
+
+ final XNameAccess dbContext = UnoRuntime.queryInterface( XNameAccess.class,
+ m_orb.createInstance( "com.sun.star.sdb.DatabaseContext" ) );
+ final XDocumentDataSource dataSource = UnoRuntime.queryInterface( XDocumentDataSource.class, dbContext.getByName( _docURL ) );
+
+ m_databaseDocument = dataSource.getDatabaseDocument();
+ m_dataSource = new DataSource(m_orb, m_databaseDocument.getDataSource());
+ }
+
+ /** returns the URL of the ODB document represented by this instance
+ */
+ public String getDocumentURL()
+ {
+ return m_databaseDocumentFile;
+ }
+
+ /** returns the data source belonging to this database
+ */
+ public DataSource getDataSource()
+ {
+ return m_dataSource;
+ }
+
+ /** creates a row set operating the database, with a given command/type
+ */
+ public RowSet createRowSet(final int _commandType, final String _command)
+ {
+ return new RowSet(m_orb, getDocumentURL(), _commandType, _command);
+ }
+
+ @Override
+ protected void finalize() throws Throwable
+ {
+ closeAndDelete();
+ super.finalize();
+ }
+}
diff --git a/connectivity/qa/connectivity/tools/CRMDatabase.java b/connectivity/qa/connectivity/tools/CRMDatabase.java
new file mode 100644
index 000000000000..a1b457884948
--- /dev/null
+++ b/connectivity/qa/connectivity/tools/CRMDatabase.java
@@ -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.
+ *
+ ************************************************************************/
+package connectivity.tools;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.PropertyState;
+import com.sun.star.container.ElementExistException;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XModel;
+import com.sun.star.io.IOException;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XSingleSelectQueryComposer;
+import com.sun.star.sdb.application.XDatabaseDocumentUI;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbcx.XTablesSupplier;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.XRefreshable;
+import connectivity.tools.sdb.Connection;
+
+/** implements a small Customer Relationship Management database
+ *
+ * Not finished, by far. Feel free to add features as you need them.
+ */
+public class CRMDatabase
+{
+ private static final String INTEGER = "INTEGER";
+ private static final String VARCHAR50 = "VARCHAR(50)";
+ private final XMultiServiceFactory m_orb;
+ private final HsqlDatabase m_database;
+ private final DataSource m_dataSource;
+ private final Connection m_connection;
+
+ /** constructs the CRM database
+ */
+ public CRMDatabase( XMultiServiceFactory _orb, boolean _withUI ) throws Exception
+ {
+ m_orb = _orb;
+
+ m_database = new HsqlDatabase( m_orb );
+ m_dataSource = m_database.getDataSource();
+
+ if ( _withUI )
+ {
+ final XComponentLoader loader = UnoRuntime.queryInterface( XComponentLoader.class,
+ m_orb.createInstance( "com.sun.star.frame.Desktop" ) );
+ PropertyValue[] loadArgs = new PropertyValue[] {
+ new PropertyValue( "PickListEntry", 0, false, PropertyState.DIRECT_VALUE )
+ };
+ loader.loadComponentFromURL( m_database.getDocumentURL(), "_blank", 0, loadArgs );
+ getDocumentUI().connect();
+ m_connection = new Connection( getDocumentUI().getActiveConnection() );
+ }
+ else
+ {
+ m_connection = m_database.defaultConnection();
+ }
+
+ createTables();
+ createQueries();
+ }
+
+ /**
+ * creates a CRMDatabase from an existing document, given by URL
+ * @param _orb
+ * @param _existingDocumentURL
+ * @throws Exceptio
+ */
+ public CRMDatabase( XMultiServiceFactory _orb, final String _existingDocumentURL ) throws Exception
+ {
+ m_orb = _orb;
+
+ m_database = new HsqlDatabase( m_orb, _existingDocumentURL );
+ m_dataSource = m_database.getDataSource();
+ m_connection = m_database.defaultConnection();
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ /** returns the database document underlying the CRM database
+ */
+ public final HsqlDatabase getDatabase()
+ {
+ return m_database;
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ /** returns the default connection to the database
+ */
+ public final Connection getConnection()
+ {
+ return m_connection;
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ public void saveAndClose() throws SQLException, IOException
+ {
+ XDatabaseDocumentUI ui = getDocumentUI();
+ if ( ui != null )
+ ui.closeSubComponents();
+ m_database.store();
+ m_database.closeAndDelete();
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ public XDatabaseDocumentUI getDocumentUI()
+ {
+ XModel docModel = UnoRuntime.queryInterface( XModel.class, m_database.getDatabaseDocument() );
+ return UnoRuntime.queryInterface( XDatabaseDocumentUI.class, docModel.getCurrentController() );
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ public XController loadSubComponent( final int _objectType, final String _name ) throws IllegalArgumentException, SQLException, NoSuchElementException
+ {
+ XDatabaseDocumentUI docUI = getDocumentUI();
+ if ( !docUI.isConnected() )
+ docUI.connect();
+
+ XComponent subComponent = docUI.loadComponent( _objectType, _name, false );
+ XController controller = UnoRuntime.queryInterface( XController.class, subComponent );
+ if ( controller != null )
+ return controller;
+ XModel document = UnoRuntime.queryInterface( XModel.class, subComponent );
+ return document.getCurrentController();
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ private void createTables() throws SQLException
+ {
+ HsqlTableDescriptor table = new HsqlTableDescriptor( "categories",
+ new HsqlColumnDescriptor[] {
+ new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ),
+ new HsqlColumnDescriptor( "Name",VARCHAR50),
+ new HsqlColumnDescriptor( "Description", "VARCHAR(1024)" ),
+ new HsqlColumnDescriptor( "Image", "LONGVARBINARY" ) } );
+ m_database.createTable( table, true );
+
+ m_database.executeSQL( "INSERT INTO \"categories\" ( \"ID\", \"Name\" ) VALUES ( 1, 'Food' )" );
+ m_database.executeSQL( "INSERT INTO \"categories\" ( \"ID\", \"Name\" ) VALUES ( 2, 'Furniture' )" );
+
+ table = new HsqlTableDescriptor( "products",
+ new HsqlColumnDescriptor[] {
+ new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ),
+ new HsqlColumnDescriptor( "Name",VARCHAR50),
+ new HsqlColumnDescriptor( "CategoryID",INTEGER, HsqlColumnDescriptor.REQUIRED, "categories", "ID" ) } );
+ m_database.createTable( table, true );
+
+ m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 1, 'Oranges', 1 )" );
+ m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 2, 'Apples', 1 )" );
+ m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 3, 'Pears', 1 )" );
+ m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 4, 'Strawberries', 1 )" );
+
+ table = new HsqlTableDescriptor( "customers",
+ new HsqlColumnDescriptor[] {
+ new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ),
+ new HsqlColumnDescriptor( "Name",VARCHAR50),
+ new HsqlColumnDescriptor( "Address",VARCHAR50),
+ new HsqlColumnDescriptor( "City",VARCHAR50),
+ new HsqlColumnDescriptor( "Postal",VARCHAR50),
+ new HsqlColumnDescriptor( "Comment","LONGVARCHAR")} );
+ m_database.createTable( table, true );
+
+ m_database.executeSQL( "INSERT INTO \"customers\" VALUES(1,'Food, Inc.','Down Under','Melbourne','509','Prefered') " );
+ m_database.executeSQL( "INSERT INTO \"customers\" VALUES(2,'Simply Delicious','Down Under','Melbourne','518',null) " );
+ m_database.executeSQL( "INSERT INTO \"customers\" VALUES(3,'Pure Health','10 Fish St.','San Francisco','94107',null) " );
+ m_database.executeSQL( "INSERT INTO \"customers\" VALUES(4,'Milk And More','Arlington Road 21','Dublin','31021','Good one.') " );
+
+ table = new HsqlTableDescriptor( "orders",
+ new HsqlColumnDescriptor[] {
+ new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ),
+ new HsqlColumnDescriptor( "CustomerID",INTEGER, HsqlColumnDescriptor.REQUIRED, "customers", "ID" ),
+ new HsqlColumnDescriptor( "OrderDate", "DATE" ),
+ new HsqlColumnDescriptor( "ShipDate", "DATE" ) } );
+ m_database.createTable( table, true );
+
+ m_database.executeSQL( "INSERT INTO \"orders\" (\"ID\", \"CustomerID\", \"OrderDate\") VALUES(1, 1, {D '2009-01-01'})" );
+ m_database.executeSQL( "INSERT INTO \"orders\" VALUES(2, 2, {D '2009-01-01'}, {D '2009-01-23'})" );
+
+ table = new HsqlTableDescriptor( "orders_details",
+ new HsqlColumnDescriptor[] {
+ new HsqlColumnDescriptor( "OrderID",INTEGER, HsqlColumnDescriptor.PRIMARY, "orders", "ID" ),
+ new HsqlColumnDescriptor( "ProductID",INTEGER, HsqlColumnDescriptor.PRIMARY, "products", "ID" ),
+ new HsqlColumnDescriptor( "Quantity",INTEGER) } );
+ m_database.createTable( table, true );
+
+ m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(1, 1, 100)" );
+ m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(1, 2, 100)" );
+ m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(2, 2, 2000)" );
+ m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(2, 3, 2000)" );
+ m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(2, 4, 2000)" );
+
+ // since we created the tables by directly executing the SQL statements, we need to refresh
+ // the tables container
+ m_connection.refreshTables();
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ private void validateUnparseable()
+ {
+ // The "unparseable" query should be indeed be unparseable by OOo (though a valid HSQL query)
+ XSingleSelectQueryComposer composer;
+ QueryDefinition unparseableQuery;
+ try
+ {
+ final XMultiServiceFactory factory = UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, m_database.defaultConnection().getXConnection() );
+ composer = UnoRuntime.queryInterface(
+ XSingleSelectQueryComposer.class, factory.createInstance( "com.sun.star.sdb.SingleSelectQueryComposer" ) );
+ unparseableQuery = m_dataSource.getQueryDefinition( "unparseable" );
+ }
+ catch( Exception e )
+ {
+ throw new RuntimeException( "caught an unexpected exception: " + e.getMessage() );
+ }
+
+ boolean caughtExpected = false;
+ try
+ {
+ composer.setQuery( unparseableQuery.getCommand() );
+ }
+ catch (WrappedTargetException e) { }
+ catch( SQLException e )
+ {
+ caughtExpected = true;
+ }
+
+ if ( !caughtExpected )
+ throw new RuntimeException( "Somebody improved the parser! This is bad :), since we need an unparsable query here!" );
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ private void createQueries() throws ElementExistException, WrappedTargetException, com.sun.star.lang.IllegalArgumentException
+ {
+ m_database.getDataSource().createQuery(
+ "all orders",
+ "SELECT \"orders\".\"ID\" AS \"Order No.\", " +
+ "\"customers\".\"Name\" AS \"Customer Name\", " +
+ "\"orders\".\"OrderDate\" AS \"Order Date\", " +
+ "\"orders\".\"ShipDate\" AS \"Ship Date\", " +
+ "\"orders_details\".\"Quantity\", " +
+ "\"products\".\"Name\" AS \"Product Name\" " +
+ "FROM \"orders_details\" AS \"orders_details\", " +
+ "\"orders\" AS \"orders\", " +
+ "\"products\" AS \"products\", " +
+ "\"customers\" AS \"customers\" " +
+ "WHERE ( \"orders_details\".\"OrderID\" = \"orders\".\"ID\" " +
+ "AND \"orders_details\".\"ProductID\" = \"products\".\"ID\" " +
+ "AND \"orders\".\"CustomerID\" = \"customers\".\"ID\" )"
+ );
+
+ m_database.getDataSource().createQuery(
+ "unshipped orders",
+ "SELECT * " +
+ "FROM \"all orders\"" +
+ "WHERE ( \"ShipDate\" IS NULL )"
+ );
+
+ m_database.getDataSource().createQuery( "parseable", "SELECT * FROM \"customers\"" );
+ m_database.getDataSource().createQuery( "parseable native", "SELECT * FROM INFORMATION_SCHEMA.SYSTEM_VIEWS", false );
+ m_database.getDataSource().createQuery( "unparseable",
+ "SELECT {fn DAYOFMONTH ('2001-01-01')} AS \"ID_VARCHAR\" FROM \"products\"", false );
+
+ validateUnparseable();
+ }
+}
diff --git a/connectivity/qa/connectivity/tools/DataSource.java b/connectivity/qa/connectivity/tools/DataSource.java
new file mode 100644
index 000000000000..221ada3cb487
--- /dev/null
+++ b/connectivity/qa/connectivity/tools/DataSource.java
@@ -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.
+ *
+ ************************************************************************/
+package connectivity.tools;
+
+import com.sun.star.container.ElementExistException;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.sdb.XQueryDefinitionsSupplier;
+import com.sun.star.sdbc.XDataSource;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class DataSource
+{
+ // the service factory
+
+ private final XMultiServiceFactory m_orb;
+ private XDataSource m_dataSource;
+
+ public DataSource(final XMultiServiceFactory _orb, final String _registeredName) throws Exception
+ {
+ m_orb = _orb;
+
+ final XNameAccess dbContext = UnoRuntime.queryInterface(
+ XNameAccess.class, _orb.createInstance( "com.sun.star.sdb.DatabaseContext" ) );
+
+ m_dataSource = UnoRuntime.queryInterface( XDataSource.class, dbContext.getByName( _registeredName ) );
+ }
+
+ public DataSource(final XMultiServiceFactory _orb,final XDataSource _dataSource)
+ {
+ m_orb = _orb;
+ m_dataSource = _dataSource;
+ }
+
+ final public XDataSource getXDataSource()
+ {
+ return m_dataSource;
+ }
+
+ /** creates a query with a given name and SQL command
+ */
+ public void createQuery(final String _name, final String _sqlCommand) throws ElementExistException, WrappedTargetException, com.sun.star.lang.IllegalArgumentException
+ {
+ createQuery(_name, _sqlCommand, true);
+ }
+
+ /** creates a query with a given name, SQL command, and EscapeProcessing flag
+ */
+ public void createQuery(final String _name, final String _sqlCommand, final boolean _escapeProcessing) throws ElementExistException, WrappedTargetException, com.sun.star.lang.IllegalArgumentException
+ {
+ final XSingleServiceFactory queryDefsFac = UnoRuntime.queryInterface( XSingleServiceFactory.class, getQueryDefinitions() );
+ XPropertySet queryDef = null;
+ try
+ {
+ queryDef = UnoRuntime.queryInterface( XPropertySet.class, queryDefsFac.createInstance() );
+ queryDef.setPropertyValue("Command", _sqlCommand);
+ queryDef.setPropertyValue("EscapeProcessing", Boolean.valueOf(_escapeProcessing));
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ e.printStackTrace(System.err);
+ }
+
+ final XNameContainer queryDefsContainer = UnoRuntime.queryInterface( XNameContainer.class, getQueryDefinitions() );
+ queryDefsContainer.insertByName(_name, queryDef);
+ }
+
+ /** provides the query definition with the given name
+ */
+ public QueryDefinition getQueryDefinition(final String _name) throws NoSuchElementException
+ {
+ final XNameAccess allDefs = getQueryDefinitions();
+ try
+ {
+ return new QueryDefinition( UnoRuntime.queryInterface( XPropertySet.class, allDefs.getByName( _name) ) );
+ }
+ catch (WrappedTargetException e)
+ {
+ }
+ throw new NoSuchElementException();
+ }
+
+ /** provides the container of query definitions of the data source
+ */
+ public XNameAccess getQueryDefinitions()
+ {
+ final XQueryDefinitionsSupplier suppQueries = UnoRuntime.queryInterface(
+ XQueryDefinitionsSupplier.class, m_dataSource);
+ return suppQueries.getQueryDefinitions();
+ }
+
+ /** returns the name of the data source
+ *
+ * If a data source is registered at the database context, the name is the registration
+ * name. Otherwise, its the URL which the respective database document is based on.
+ *
+ * Note that the above definition is from the UNO API, not from this wrapper here.
+ */
+ public String getName()
+ {
+ String name = null;
+ try
+ {
+ final XPropertySet dataSourceProps = UnoRuntime.queryInterface( XPropertySet.class, m_dataSource );
+ name = (String) dataSourceProps.getPropertyValue("Name");
+ }
+ catch (Exception ex)
+ {
+ Logger.getLogger(DataSource.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ return name;
+ }
+};
diff --git a/connectivity/qa/connectivity/tools/DatabaseAccess.java b/connectivity/qa/connectivity/tools/DatabaseAccess.java
new file mode 100755
index 000000000000..c099a44d1fb9
--- /dev/null
+++ b/connectivity/qa/connectivity/tools/DatabaseAccess.java
@@ -0,0 +1,63 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package connectivity.tools;
+
+import com.sun.star.frame.XModel;
+import com.sun.star.io.IOException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.sdbc.SQLException;
+import connectivity.tools.sdb.Connection;
+
+/**
+ *
+ * @author oj93728
+ */
+public interface DatabaseAccess
+{
+ Connection defaultConnection() throws SQLException;
+
+ void executeSQL(final String statementString) throws SQLException;
+
+ void store() throws IOException;
+
+ void close();
+
+ void closeAndDelete();
+
+ XOfficeDatabaseDocument getDatabaseDocument();
+
+ XModel getModel();
+
+ String getDocumentURL();
+
+ DataSource getDataSource();
+
+ RowSet createRowSet(final int _commandType, final String _command);
+
+ XMultiServiceFactory getORB();
+}
diff --git a/connectivity/qa/connectivity/tools/DbaseDatabase.java b/connectivity/qa/connectivity/tools/DbaseDatabase.java
new file mode 100755
index 000000000000..ae40be4222aa
--- /dev/null
+++ b/connectivity/qa/connectivity/tools/DbaseDatabase.java
@@ -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.
+ *
+ ************************************************************************/
+package connectivity.tools;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.frame.XStorable;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.uno.UnoRuntime;
+
+import helper.URLHelper;
+import java.io.File;
+
+/**
+ *
+ * @author Ocke
+ */
+public class DbaseDatabase extends AbstractDatabase
+{
+ // --------------------------------------------------------------------------------------------------------
+
+ public DbaseDatabase(final XMultiServiceFactory orb) throws Exception
+ {
+ super(orb);
+ createDBDocument();
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ public DbaseDatabase(final XMultiServiceFactory orb, final String _existingDocumentURL) throws Exception
+ {
+ super(orb, _existingDocumentURL);
+ }
+
+ /** creates an empty database document in a temporary location
+ */
+ private void createDBDocument() throws Exception
+ {
+ final File documentFile = File.createTempFile("dbase", ".odb");
+ if ( documentFile.exists() )
+ documentFile.delete();
+ final File subPath = new File(documentFile.getParent() + File.separator + documentFile.getName().replaceAll(".odb", "") + File.separator );
+ subPath.mkdir();
+ //subPath.deleteOnExit();
+ m_databaseDocumentFile = URLHelper.getFileURLFromSystemPath(documentFile);
+ final String path = URLHelper.getFileURLFromSystemPath(subPath.getPath());
+
+ m_databaseDocument = (XOfficeDatabaseDocument) UnoRuntime.queryInterface(
+ XOfficeDatabaseDocument.class, m_orb.createInstance("com.sun.star.sdb.OfficeDatabaseDocument"));
+ m_dataSource = new DataSource(m_orb, m_databaseDocument.getDataSource());
+
+ final XPropertySet dsProperties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, m_databaseDocument.getDataSource());
+ dsProperties.setPropertyValue("URL", "sdbc:dbase:" + path);
+
+ final XStorable storable = (XStorable) UnoRuntime.queryInterface(XStorable.class, m_databaseDocument);
+ storable.storeAsURL(m_databaseDocumentFile, new PropertyValue[]
+ {
+ });
+ }
+
+ /** drops the table with a given name
+
+ @param _name
+ the name of the table to drop
+ @param _ifExists
+ TRUE if it should be dropped only when it exists.
+ */
+ public void dropTable(final String _name,final boolean _ifExists) throws SQLException
+ {
+ String dropStatement = "DROP TABLE \"" + _name;
+ executeSQL(dropStatement);
+ }
+}
diff --git a/connectivity/qa/connectivity/tools/HsqlColumnDescriptor.java b/connectivity/qa/connectivity/tools/HsqlColumnDescriptor.java
new file mode 100644
index 000000000000..c0c46d07149f
--- /dev/null
+++ b/connectivity/qa/connectivity/tools/HsqlColumnDescriptor.java
@@ -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.
+ *
+ ************************************************************************/
+
+package connectivity.tools;
+
+/** is a very simply and rudimentary descriptor of table columns, for creating HSQLDB tables
+ */
+public class HsqlColumnDescriptor
+{
+ private String Name;
+ private String TypeName;
+ private boolean Required;
+ private boolean PrimaryKey;
+ private String ForeignTable;
+ private String ForeignColumn;
+
+ public final String getName() { return Name; }
+ public final String getTypeName() { return TypeName; }
+ public final boolean isRequired() { return Required; }
+ public final boolean isPrimaryKey() { return PrimaryKey; }
+
+ public final boolean isForeignKey() { return ( ForeignTable.length() != 0 ) && ( ForeignColumn.length() != 0 ); }
+ public final String getForeignTable() { return ForeignTable; }
+ public final String getForeignColumn() { return ForeignColumn; }
+
+ /// determines that a column is required, i.e. not nullable
+ public final static int REQUIRED = 1;
+ /// determines that a column is part of the primary key of its table
+ public final static int PRIMARY = 2;
+
+ public HsqlColumnDescriptor( String _Name, String _TypeName )
+ {
+ Name = _Name;
+ TypeName = _TypeName;
+ Required = false;
+ PrimaryKey = false;
+ ForeignTable = "";
+ ForeignColumn = "";
+ }
+
+ public HsqlColumnDescriptor( String _Name, String _TypeName, int _Flags )
+ {
+ Name = _Name;
+ TypeName = _TypeName;
+ Required = ( _Flags & REQUIRED ) != 0;
+ PrimaryKey = ( _Flags & PRIMARY ) != 0;
+ ForeignTable = "";
+ ForeignColumn = "";
+ }
+
+ public HsqlColumnDescriptor( String _Name, String _TypeName, int _Flags, String _ForeignTable, String _ForeignColumn )
+ {
+ Name = _Name;
+ TypeName = _TypeName;
+ Required = ( _Flags & REQUIRED ) != 0;
+ PrimaryKey = ( _Flags & PRIMARY ) != 0;
+ ForeignTable = _ForeignTable;
+ ForeignColumn = _ForeignColumn;
+ }
+};
diff --git a/connectivity/qa/connectivity/tools/HsqlDatabase.java b/connectivity/qa/connectivity/tools/HsqlDatabase.java
new file mode 100644
index 000000000000..058c61e1afaa
--- /dev/null
+++ b/connectivity/qa/connectivity/tools/HsqlDatabase.java
@@ -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.
+ *
+ ************************************************************************/
+package connectivity.tools;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.PropertyState;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ElementExistException;
+import com.sun.star.frame.XStorable;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbcx.XAppend;
+import com.sun.star.sdbcx.XTablesSupplier;
+import com.sun.star.uno.UnoRuntime;
+
+import helper.URLHelper;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+import java.io.File;
+
+/**
+ *
+ * @author fs93730
+ */
+public class HsqlDatabase extends AbstractDatabase
+{
+
+ // --------------------------------------------------------------------------------------------------------
+ public HsqlDatabase(final XMultiServiceFactory orb) throws Exception
+ {
+ super(orb);
+ createDBDocument();
+ }
+
+ // --------------------------------------------------------------------------------------------------------
+ public HsqlDatabase(final XMultiServiceFactory orb, final String _existingDocumentURL) throws Exception
+ {
+ super(orb, _existingDocumentURL);
+ }
+
+ /** creates an empty database document in a temporary location
+ */
+ private void createDBDocument() throws Exception
+ {
+ final File documentFile = File.createTempFile("testdb", ".odb");
+ if ( documentFile.exists() )
+ documentFile.delete();
+ m_databaseDocumentFile = URLHelper.getFileURLFromSystemPath(documentFile);
+
+ m_databaseDocument = (XOfficeDatabaseDocument) UnoRuntime.queryInterface(
+ XOfficeDatabaseDocument.class, m_orb.createInstance("com.sun.star.sdb.OfficeDatabaseDocument"));
+ m_dataSource = new DataSource(m_orb, m_databaseDocument.getDataSource());
+
+ final XPropertySet dsProperties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, m_databaseDocument.getDataSource());
+ dsProperties.setPropertyValue("URL", "sdbc:embedded:hsqldb");
+
+ final XStorable storable = (XStorable) UnoRuntime.queryInterface(XStorable.class, m_databaseDocument);
+ storable.storeAsURL( m_databaseDocumentFile, new PropertyValue[]
+ { new PropertyValue( "PickListEntry", 0, false, PropertyState.DIRECT_VALUE )
+ } );
+ }
+
+ /** drops the table with a given name
+
+ @param _name
+ the name of the table to drop
+ @param _ifExists
+ TRUE if it should be dropped only when it exists.
+ */
+ public void dropTable(final String _name, final boolean _ifExists) throws SQLException
+ {
+ final StringBuffer dropStatement = new StringBuffer("DROP TABLE \"");
+ dropStatement.append(_name);
+ if (_ifExists)
+ {
+ dropStatement.append("\" IF EXISTS");
+ }
+ executeSQL(dropStatement.toString());
+ }
+
+ public void createTable(final HsqlTableDescriptor _tableDesc, final boolean _dropIfExists) throws SQLException
+ {
+ if (_dropIfExists)
+ {
+ dropTable(_tableDesc.getName(), true);
+ }
+ createTable(_tableDesc);
+ }
+
+ /** creates a table
+ */
+ public void createTable(final HsqlTableDescriptor _tableDesc) throws SQLException
+ {
+ StringBuffer createStatement = new StringBuffer("CREATE CACHED TABLE \"");
+ createStatement.append(_tableDesc.getName());
+ createStatement.append("\" ( ");
+
+ String primaryKeyList = "";
+
+ final HashMap foreignKeys = new HashMap();
+ final HashMap foreignKeyRefs = new HashMap();
+
+ final HsqlColumnDescriptor[] columns = _tableDesc.getColumns();
+ for (int i = 0; i < columns.length; ++i)
+ {
+ if (i > 0)
+ {
+ createStatement.append(", ");
+ }
+
+ createStatement.append("\"" + columns[i].getName());
+ createStatement.append("\" " + columns[i].getTypeName());
+
+ if (columns[i].isRequired())
+ {
+ createStatement.append(" NOT NULL");
+ }
+
+ if (columns[i].isPrimaryKey())
+ {
+ if (primaryKeyList.length() > 0)
+ {
+ primaryKeyList += ", ";
+ }
+ primaryKeyList += "\"" + columns[i].getName() + "\"";
+ }
+
+ if (columns[i].isForeignKey())
+ {
+ final String foreignTable = columns[i].getForeignTable();
+
+ String foreignKeysForTable = foreignKeys.containsKey(foreignTable) ? (String) foreignKeys.get(foreignTable) : "";
+ if (foreignKeysForTable.length() > 0)
+ {
+ foreignKeysForTable += ", ";
+ }
+ foreignKeysForTable += "\"" + columns[i].getName() + "\"";
+ foreignKeys.put(foreignTable, foreignKeysForTable);
+
+ final StringBuffer foreignKeyRefsForTable = new StringBuffer(foreignKeyRefs.containsKey(foreignTable) ? (String) foreignKeyRefs.get(foreignTable) : "");
+ if (foreignKeyRefsForTable.length() > 0)
+ {
+ foreignKeyRefsForTable.append(", ");
+ }
+ foreignKeyRefsForTable.append("\"" + columns[i].getForeignColumn() + "\"");
+ foreignKeyRefs.put(foreignTable, foreignKeyRefsForTable.toString());
+ }
+ }
+
+ if (primaryKeyList.length() > 0)
+ {
+ createStatement.append(", PRIMARY KEY (");
+ createStatement.append(primaryKeyList);
+ createStatement.append(')');
+ }
+
+ final Set foreignKeyTables = foreignKeys.keySet();
+ for (final Iterator foreignKey = foreignKeyTables.iterator();
+ foreignKey.hasNext();)
+ {
+ final String foreignTable = (String) foreignKey.next();
+
+ createStatement.append(", FOREIGN KEY (");
+ createStatement.append((String) foreignKeys.get(foreignTable));
+ createStatement.append(") REFERENCES \"");
+ createStatement.append(foreignTable);
+ createStatement.append("\"(");
+ createStatement.append((String) foreignKeyRefs.get(foreignTable));
+ createStatement.append(')');
+ }
+
+ createStatement.append(')');
+
+ //System.err.println( createStatement );
+ executeSQL(createStatement.toString());
+ }
+
+ /** creates a table in the database. using the SDBCX-API
+ */
+ public void createTableInSDBCX(final HsqlTableDescriptor _tableDesc) throws SQLException, ElementExistException
+ {
+ final XPropertySet sdbcxDescriptor = _tableDesc.createSdbcxDescriptor(defaultConnection());
+ final XTablesSupplier suppTables = UnoRuntime.queryInterface( XTablesSupplier.class, defaultConnection().getXConnection() );
+ final XAppend appendTable = UnoRuntime.queryInterface( XAppend.class, suppTables.getTables() );
+ appendTable.appendByDescriptor(sdbcxDescriptor);
+ }
+}
diff --git a/connectivity/qa/connectivity/tools/HsqlTableDescriptor.java b/connectivity/qa/connectivity/tools/HsqlTableDescriptor.java
new file mode 100644
index 000000000000..dcda754f8b8c
--- /dev/null
+++ b/connectivity/qa/connectivity/tools/HsqlTableDescriptor.java
@@ -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.
+ *
+ ************************************************************************/
+
+package connectivity.tools;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.sdbc.ColumnValue;
+import com.sun.star.sdbcx.XColumnsSupplier;
+import com.sun.star.sdbcx.XDataDescriptorFactory;
+import com.sun.star.sdbcx.XTablesSupplier;
+import com.sun.star.uno.UnoRuntime;
+import connectivity.tools.sdb.Connection;
+
+/** is a very simply descriptor of a HSQL table, to be used with a HsqlDatabase.createTable method
+ */
+public class HsqlTableDescriptor
+{
+ private String m_name;
+ private HsqlColumnDescriptor[] m_columns;
+
+ /** Creates a new instance of HsqlTableDescriptor */
+ public HsqlTableDescriptor( String _name, HsqlColumnDescriptor[] _columns )
+ {
+ m_name = _name;
+ m_columns = _columns;
+ }
+
+ /** returns the name of the table
+ */
+ public String getName()
+ {
+ return m_name;
+ }
+
+ /** returns the set of column descriptors for the table
+ */
+ public HsqlColumnDescriptor[] getColumns()
+ {
+ return m_columns;
+ }
+
+ public XPropertySet createSdbcxDescriptor( Connection _forConnection )
+ {
+ XTablesSupplier suppTables = UnoRuntime.queryInterface( XTablesSupplier.class, _forConnection.getXConnection() );
+ XDataDescriptorFactory tableDescFac = UnoRuntime.queryInterface( XDataDescriptorFactory.class, suppTables.getTables() );
+ XPropertySet tableDesc = tableDescFac.createDataDescriptor();
+
+ try
+ {
+ tableDesc.setPropertyValue( "Name", getName() );
+ }
+ catch ( Exception e ) { e.printStackTrace( System.err ); }
+
+ XColumnsSupplier suppDescCols = UnoRuntime.queryInterface( XColumnsSupplier.class, tableDesc );
+
+ XNameAccess descColumns = suppDescCols.getColumns();
+ XDataDescriptorFactory columnDescFac = UnoRuntime.queryInterface( XDataDescriptorFactory.class, descColumns );
+
+ HsqlColumnDescriptor[] myColumns = getColumns();
+ for ( int i = 0; i < myColumns.length; ++i )
+ {
+ XPropertySet columnDesc = columnDescFac.createDataDescriptor();
+ try
+ {
+ columnDesc.setPropertyValue( "Name", myColumns[i].getName() );
+ columnDesc.setPropertyValue( "IsNullable", new Integer( myColumns[i].isRequired() ? ColumnValue.NO_NULLS : ColumnValue.NULLABLE) );
+ columnDesc.setPropertyValue( "TypeName", myColumns[i].getTypeName() );
+ if ( myColumns[i].isPrimaryKey() || myColumns[i].isForeignKey() )
+ // not yet implemented
+ throw new java.lang.UnsupportedOperationException("creating a primary or foreign key via SDBCX not yet implemented" );
+ }
+ catch( com.sun.star.uno.Exception e ) { e.printStackTrace( System.err ); }
+ }
+
+ return tableDesc;
+ }
+}
diff --git a/connectivity/qa/connectivity/tools/QueryDefinition.java b/connectivity/qa/connectivity/tools/QueryDefinition.java
new file mode 100644
index 000000000000..ebc9d1a25cfe
--- /dev/null
+++ b/connectivity/qa/connectivity/tools/QueryDefinition.java
@@ -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.
+ *
+ ************************************************************************/
+
+package connectivity.tools;
+
+import com.sun.star.beans.PropertyVetoException;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.IllegalArgumentException;
+
+public class QueryDefinition
+{
+ XPropertySet m_queryDef;
+
+ public QueryDefinition( XPropertySet _queryDef )
+ {
+ m_queryDef = _queryDef;
+ }
+
+ /** retrieves the command underlying the query definition
+ *
+ * This method is a mere wrapped around the <code>getPropertyValue( "Command" )</code> call
+ */
+ public final String getCommand() throws WrappedTargetException
+ {
+ String command = null;
+ try {
+ command = (String)m_queryDef.getPropertyValue( "Command" );
+ }
+ catch (UnknownPropertyException e) { }
+
+ return command;
+ }
+
+ /** retrieves the command underlying the query definition
+ *
+ * This method is a mere wrapped around the <code>getPropertyValue( "Command" )</code> call
+ */
+ public void setCommand( String _command ) throws WrappedTargetException
+ {
+ try
+ {
+ m_queryDef.setPropertyValue( "Command", _command );
+ }
+ catch (UnknownPropertyException e) { }
+ catch (PropertyVetoException e) { }
+ catch (IllegalArgumentException e) { }
+ }
+};
diff --git a/connectivity/qa/connectivity/tools/RowSet.java b/connectivity/qa/connectivity/tools/RowSet.java
new file mode 100644
index 000000000000..a26456dcc746
--- /dev/null
+++ b/connectivity/qa/connectivity/tools/RowSet.java
@@ -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.
+ *
+ ************************************************************************/
+
+package connectivity.tools;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.io.XInputStream;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XArray;
+import com.sun.star.sdbc.XBlob;
+import com.sun.star.sdbc.XClob;
+import com.sun.star.sdbc.XRef;
+import com.sun.star.sdbc.XRow;
+import com.sun.star.sdbc.XRowSet;
+import com.sun.star.sdbc.XRowSetListener;
+import com.sun.star.sdbcx.XColumnsSupplier;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.Date;
+import com.sun.star.util.DateTime;
+import com.sun.star.util.Time;
+
+public class RowSet implements XRowSet, XRow
+{
+ private XMultiServiceFactory m_orb;
+ private XRowSet m_rowSet;
+ private XRow m_row;
+ private XPropertySet m_rowSetProps;
+
+ public RowSet( XMultiServiceFactory _orb, String _dataSource, int _commandType, String _command )
+ {
+ try
+ {
+ m_rowSetProps = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, _orb.createInstance("com.sun.star.sdb.RowSet") );
+ m_rowSetProps.setPropertyValue( "DataSourceName", _dataSource );
+ m_rowSetProps.setPropertyValue( "CommandType", new Integer( _commandType ) );
+ m_rowSetProps.setPropertyValue( "Command", _command );
+
+ m_rowSet = (XRowSet)UnoRuntime.queryInterface( XRowSet.class, m_rowSetProps );
+ m_row = (XRow)UnoRuntime.queryInterface( XRow.class, m_rowSetProps );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace(System.err);
+ throw new java.lang.InstantiationError();
+ }
+ }
+
+ // misc
+ public int getColumnCount()
+ {
+ XColumnsSupplier suppCols = (XColumnsSupplier)UnoRuntime.queryInterface(
+ XColumnsSupplier.class, m_rowSet );
+ XIndexAccess columns = (XIndexAccess)UnoRuntime.queryInterface(
+ XIndexAccess.class, suppCols.getColumns() );
+ return columns.getCount();
+ }
+
+ // XRowSet
+ public void execute() throws SQLException
+ {
+ m_rowSet.execute();
+ }
+
+ public void addRowSetListener( XRowSetListener _listener )
+ {
+ m_rowSet.addRowSetListener( _listener );
+ }
+
+ public void removeRowSetListener( XRowSetListener _listener )
+ {
+ m_rowSet.removeRowSetListener( _listener );
+ }
+
+ public boolean next() throws SQLException
+ {
+ return m_rowSet.next();
+ }
+
+ public boolean isBeforeFirst() throws SQLException
+ {
+ return m_rowSet.isBeforeFirst();
+ }
+
+ public boolean isAfterLast() throws SQLException
+ {
+ return m_rowSet.isAfterLast();
+ }
+
+ public boolean isFirst() throws SQLException
+ {
+ return m_rowSet.isFirst();
+ }
+
+ public boolean isLast() throws SQLException
+ {
+ return m_rowSet.isLast();
+ }
+
+ public void beforeFirst() throws SQLException
+ {
+ m_rowSet.beforeFirst();
+ }
+
+ public void afterLast() throws SQLException
+ {
+ m_rowSet.afterLast();
+ }
+
+ public boolean first() throws SQLException
+ {
+ return m_rowSet.first();
+ }
+
+ public boolean last() throws SQLException
+ {
+ return m_rowSet.last();
+ }
+
+ public int getRow() throws SQLException
+ {
+ return m_rowSet.getRow();
+ }
+
+ public boolean absolute(int i) throws SQLException
+ {
+ return m_rowSet.absolute(i);
+ }
+
+ public boolean relative(int i) throws SQLException
+ {
+ return m_rowSet.relative(i);
+ }
+
+ public boolean previous() throws SQLException
+ {
+ return m_rowSet.previous();
+ }
+
+ public void refreshRow() throws SQLException
+ {
+ m_rowSet.refreshRow();
+ }
+
+ public boolean rowUpdated() throws SQLException
+ {
+ return m_rowSet.rowUpdated();
+ }
+
+ public boolean rowInserted() throws SQLException
+ {
+ return m_rowSet.rowInserted();
+ }
+
+ public boolean rowDeleted() throws SQLException
+ {
+ return m_rowSet.rowDeleted();
+ }
+
+ // XRow
+ public Object getStatement() throws SQLException
+ {
+ return m_rowSet.getStatement();
+ }
+
+ public boolean wasNull() throws SQLException
+ {
+ return m_row.wasNull();
+ }
+
+ public String getString(int i) throws SQLException
+ {
+ return m_row.getString(i);
+ }
+
+ public boolean getBoolean(int i) throws SQLException
+ {
+ return m_row.getBoolean(i);
+ }
+
+ public byte getByte(int i) throws SQLException
+ {
+ return m_row.getByte(i);
+ }
+
+ public short getShort(int i) throws SQLException
+ {
+ return m_row.getShort(i);
+ }
+
+ public int getInt(int i) throws SQLException
+ {
+ return m_row.getInt(i);
+ }
+
+ public long getLong(int i) throws SQLException
+ {
+ return m_row.getLong(i);
+ }
+
+ public float getFloat(int i) throws SQLException
+ {
+ return m_row.getFloat(i);
+ }
+
+ public double getDouble(int i) throws SQLException
+ {
+ return m_row.getDouble(i);
+ }
+
+ public byte[] getBytes(int i) throws SQLException
+ {
+ return m_row.getBytes(i);
+ }
+
+ public Date getDate(int i) throws SQLException
+ {
+ return m_row.getDate(i);
+ }
+
+ public Time getTime(int i) throws SQLException
+ {
+ return m_row.getTime(i);
+ }
+
+ public DateTime getTimestamp(int i) throws SQLException
+ {
+ return m_row.getTimestamp(i);
+ }
+
+ public XInputStream getBinaryStream(int i) throws SQLException
+ {
+ return m_row.getBinaryStream(i);
+ }
+
+ public XInputStream getCharacterStream(int i) throws SQLException
+ {
+ return m_row.getCharacterStream(i);
+ }
+
+ public Object getObject(int i, XNameAccess xNameAccess) throws SQLException
+ {
+ return m_row.getObject(i, xNameAccess);
+ }
+
+ public XRef getRef(int i) throws SQLException
+ {
+ return m_row.getRef(i);
+ }
+
+ public XBlob getBlob(int i) throws SQLException
+ {
+ return m_row.getBlob(i);
+ }
+
+ public XClob getClob(int i) throws SQLException
+ {
+ return m_row.getClob(i);
+ }
+
+ public XArray getArray(int i) throws SQLException
+ {
+ return m_row.getArray(i);
+ }
+};
diff --git a/connectivity/qa/connectivity/tools/makefile.mk b/connectivity/qa/connectivity/tools/makefile.mk
new file mode 100644
index 000000000000..07490532a1b1
--- /dev/null
+++ b/connectivity/qa/connectivity/tools/makefile.mk
@@ -0,0 +1,65 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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 = ../../..
+TARGET = ConnectivityTools
+PRJNAME = connectivity
+PACKAGE = connectivity/tools
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+.IF "$(SOLAR_JAVA)" == ""
+all:
+ @echo "Java not available. Build skipped"
+.ELSE
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunnerLight.jar
+JAVAFILES := $(shell @$(FIND) . -name "*.java")
+JAVACLASSFILES := $(foreach,i,$(JAVAFILES) $(CLASSDIR)/$(PACKAGE)/$(i:d)$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+ALL : ALLTAR
+.ELSE
+ALL: ALLDEP
+.ENDIF
+
+.ENDIF # "$(SOLAR_JAVA)" == ""
+
+.INCLUDE : target.mk
diff --git a/connectivity/qa/connectivity/tools/sdb/Connection.java b/connectivity/qa/connectivity/tools/sdb/Connection.java
new file mode 100644
index 000000000000..aac120fb1e73
--- /dev/null
+++ b/connectivity/qa/connectivity/tools/sdb/Connection.java
@@ -0,0 +1,93 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package connectivity.tools.sdb;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XSingleSelectQueryComposer;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XConnection;
+import com.sun.star.sdbc.XDatabaseMetaData;
+import com.sun.star.sdbc.XPreparedStatement;
+import com.sun.star.sdbc.XResultSet;
+import com.sun.star.sdbc.XStatement;
+import com.sun.star.sdbcx.XTablesSupplier;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.XRefreshable;
+
+/**
+ * is a convenience wrapper around a SDB-level connection object
+ */
+public class Connection
+{
+ private final XConnection m_connection;
+
+ public Connection( final XConnection _connection )
+ {
+ m_connection = _connection;
+ }
+
+ public XConnection getXConnection()
+ {
+ return m_connection;
+ }
+
+ public boolean execute( final String _sql ) throws SQLException
+ {
+ XStatement statement = createStatement();
+ return statement.execute( _sql );
+ }
+
+ public XResultSet executeQuery( final String _sql ) throws SQLException
+ {
+ XStatement statement = createStatement();
+ return statement.executeQuery( _sql );
+ }
+
+ public int executeUpdate( final String _sql ) throws SQLException
+ {
+ XStatement statement = createStatement();
+ return statement.executeUpdate( _sql );
+ }
+
+ public void refreshTables()
+ {
+ final XTablesSupplier suppTables = UnoRuntime.queryInterface(XTablesSupplier.class, m_connection);
+ final XRefreshable refresh = UnoRuntime.queryInterface( XRefreshable.class, suppTables.getTables() );
+ refresh.refresh();
+ }
+
+ public XSingleSelectQueryComposer createSingleSelectQueryComposer() throws Exception
+ {
+ final XMultiServiceFactory connectionFactory = UnoRuntime.queryInterface( XMultiServiceFactory.class, m_connection );
+ return UnoRuntime.queryInterface(
+ XSingleSelectQueryComposer.class, connectionFactory.createInstance( "com.sun.star.sdb.SingleSelectQueryComposer" ) );
+ }
+
+ public
+ XStatement createStatement() throws SQLException
+ {
+ return m_connection.createStatement();
+ }
+
+ public
+ XPreparedStatement prepareStatement( String _sql ) throws SQLException
+ {
+ return m_connection.prepareStatement( _sql );
+ }
+
+ public
+ XDatabaseMetaData getMetaData() throws SQLException
+ {
+ return m_connection.getMetaData();
+ }
+
+ public
+ void close() throws SQLException
+ {
+ m_connection.close();
+ }
+}
diff --git a/connectivity/qa/drivers/dbase/.nbattrs b/connectivity/qa/drivers/dbase/.nbattrs
new file mode 100644
index 000000000000..1ea7ed0bd8e6
--- /dev/null
+++ b/connectivity/qa/drivers/dbase/.nbattrs
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE attributes PUBLIC "-//NetBeans//DTD DefaultAttributes 1.0//EN" "http://www.netbeans.org/dtds/attributes-1_0.dtd">
+<attributes version="1.0">
+ <fileobject name="DBaseDriverTest.java">
+ <attr name="class_dependency_complexlib.ComplexTestCase" stringvalue="DBaseDriverTest"/>
+ </fileobject>
+ <fileobject name="makefile.mk">
+ <attr name="org.netbeans.modules.text.IsTextFile" boolvalue="true"/>
+ </fileobject>
+</attributes>
diff --git a/connectivity/qa/drivers/dbase/DBaseDateFunctions.java b/connectivity/qa/drivers/dbase/DBaseDateFunctions.java
new file mode 100644
index 000000000000..b48ae2158359
--- /dev/null
+++ b/connectivity/qa/drivers/dbase/DBaseDateFunctions.java
@@ -0,0 +1,309 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package qa.drivers.dbase;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.sdbc.*;
+import com.sun.star.beans.XPropertySet;
+
+import com.sun.star.lang.XMultiServiceFactory;
+
+public class DBaseDateFunctions
+{
+
+ private final String where = "FROM \"biblio\" \"biblio\" where \"Identifier\" = 'BOR00'";
+ private final XMultiServiceFactory m_xORB;
+ private final DBaseDriverTest testcase;
+
+ public DBaseDateFunctions(final XMultiServiceFactory _xORB, final DBaseDriverTest _testcase)
+ {
+ m_xORB = _xORB;
+ testcase = _testcase;
+ }
+
+ private void assure(final String s, final boolean b)
+ {
+ testcase.assure2(s, b);
+ }
+
+ public void testFunctions() throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRowSet xRowRes = (XRowSet) UnoRuntime.queryInterface(XRowSet.class,
+ m_xORB.createInstance("com.sun.star.sdb.RowSet"));
+
+ testcase.getLog().println("starting DateTime function test!");
+ // set the properties needed to connect to a database
+ final XPropertySet xProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xRowRes);
+ xProp.setPropertyValue("DataSourceName", "Bibliography");
+
+ xProp.setPropertyValue("CommandType", Integer.valueOf(com.sun.star.sdb.CommandType.COMMAND));
+
+ try
+ {
+ curdate(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("upper " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ curtime(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("lower " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ dayname(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("ascii " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ dayofmonth(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("char_len " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ dayofweek(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("concat " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ dayofyear(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("locate " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ hour(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("substr " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ minute(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("ltrim " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ month(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("rtrim " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ monthname(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("space " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ now(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("replace " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ quarter(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("repeat " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ second(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("insert " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ week(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("left " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ year(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("right " + ex.getMessage(), false);
+ throw ex;
+ }
+ }
+
+ private XRow execute(final XRowSet xRowRes, final String sql) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XPropertySet xProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xRowRes);
+ xProp.setPropertyValue("Command", "SELECT " + sql + where);
+ xRowRes.execute();
+ final XResultSet xRes = (XResultSet) UnoRuntime.queryInterface(XResultSet.class, xRowRes);
+ assure("No valid row! ", xRes.next());
+
+ return (XRow) UnoRuntime.queryInterface(XRow.class, xRes);
+ }
+
+ private void dayofweek(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "DAYOFWEEK('1998-02-03') ");
+ assure("DAYOFWEEK('1998-02-03') failed!", row.getInt(1) == 3);
+ }
+
+ private void dayofmonth(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "DAYOFMONTH('1998-02-03') ");
+ assure("DAYOFMONTH('1998-02-03') failed!", row.getInt(1) == 3);
+ }
+
+ private void dayofyear(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "DAYOFYEAR('1998-02-03') ");
+ assure("DAYOFYEAR('1998-02-03') failed!", row.getInt(1) == 34);
+ }
+
+ private void month(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "month('1998-02-03') ");
+ assure("month('1998-02-03') failed!", row.getInt(1) == 2);
+ }
+
+ private void dayname(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "DAYNAME('1998-02-05') ");
+ assure("DAYNAME('1998-02-05') failed!", row.getString(1).equals("Thursday"));
+ }
+
+ private void monthname(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "MONTHNAME('1998-02-05') ");
+ assure("MONTHNAME('1998-02-05') failed!", row.getString(1).equals("February"));
+ }
+
+ private void quarter(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "QUARTER('98-01-01'),QUARTER('98-04-01'),QUARTER('98-07-01'),QUARTER('98-10-01') ");
+ assure("QUARTER('98-01-01') failed!", row.getInt(1) == 1);
+ assure("QUARTER('98-04-01') failed!", row.getInt(2) == 2);
+ assure("QUARTER('98-07-01') failed!", row.getInt(3) == 3);
+ assure("QUARTER('98-10-01') failed!", row.getInt(4) == 4);
+ }
+
+ private void week(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "WEEK('1998-02-20') ");
+ assure("WEEK('1998-02-20') failed!", row.getInt(1) == 7);
+ }
+
+ private void year(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "YEAR('98-02-03') ");
+ assure("YEAR('98-02-03') failed!", row.getInt(1) == 98);
+ }
+
+ private void hour(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "HOUR('10:05:03') ");
+ assure("HOUR('10:05:03') failed!", row.getInt(1) == 10);
+ }
+
+ private void minute(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "MINUTE('98-02-03 10:05:03') ");
+ assure("MINUTE('98-02-03 10:05:03') failed!", row.getInt(1) == 5);
+ }
+
+ private void second(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "SECOND('10:05:03') ");
+ assure("SECOND('10:05:03') failed!", row.getInt(1) == 3);
+ }
+
+ private void curdate(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "CURDATE() ");
+ final com.sun.star.util.Date aDate = row.getDate(1);
+ testcase.getLog().println("CURDATE() is '" + aDate.Year + "-" + aDate.Month + "-" + aDate.Day + "'");
+ }
+
+ private void curtime(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "CURTIME() ");
+ final com.sun.star.util.Time aTime = row.getTime(1);
+ testcase.getLog().println("CURTIME() is '" + aTime.Hours + ":" + aTime.Minutes + ":" + aTime.Seconds + "'");
+ }
+
+ private void now(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "NOW() ");
+ final com.sun.star.util.DateTime aTime = row.getTimestamp(1);
+ testcase.getLog().println("NOW() is '" + aTime.Year + "-" + aTime.Month + "-" + aTime.Day + "'");
+ testcase.getLog().println("'" + aTime.Hours + ":" + aTime.Minutes + ":" + aTime.Seconds + "'");
+ }
+}
diff --git a/connectivity/qa/drivers/dbase/DBaseDriverTest.java b/connectivity/qa/drivers/dbase/DBaseDriverTest.java
new file mode 100644
index 000000000000..2e2920b4145b
--- /dev/null
+++ b/connectivity/qa/drivers/dbase/DBaseDriverTest.java
@@ -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.
+ *
+ ************************************************************************/
+package qa.drivers.dbase;
+
+import com.sun.star.sdbc.*;
+import com.sun.star.lang.XMultiServiceFactory;
+import complexlib.ComplexTestCase;
+import java.util.*;
+import java.io.*;
+import share.LogWriter;
+//import complex.connectivity.DBaseStringFunctions;
+
+public class DBaseDriverTest extends ComplexTestCase
+{
+
+ private static Properties props = new Properties();
+ private XDriver m_xDiver;
+ private String where = "FROM \"biblio\" \"biblio\" where \"Identifier\" = 'BOR00'";
+
+ static
+ {
+ try
+ {
+ String propsFile = "test.properties";
+ props.load(new FileInputStream(propsFile));
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public String[] getTestMethodNames()
+ {
+ return new String[]
+ {
+ "Functions"
+ };
+ }
+
+ public String getTestObjectName()
+ {
+ return "DBaseDriverTest";
+ }
+
+ public void assure2(String s, boolean b)
+ {
+ assure(s, b);
+ }
+
+ public LogWriter getLog()
+ {
+ return log;
+ }
+
+ public void Functions() throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ DBaseStringFunctions aStringTest = new DBaseStringFunctions(((XMultiServiceFactory) param.getMSF()), this);
+ aStringTest.testFunctions();
+
+ DBaseNumericFunctions aNumericTest = new DBaseNumericFunctions(((XMultiServiceFactory) param.getMSF()), this);
+ aNumericTest.testFunctions();
+
+ DBaseDateFunctions aDateTest = new DBaseDateFunctions(((XMultiServiceFactory) param.getMSF()), this);
+ aDateTest.testFunctions();
+
+ DBaseSqlTests aSqlTest = new DBaseSqlTests(((XMultiServiceFactory) param.getMSF()), this);
+ aSqlTest.testFunctions();
+ }
+}
diff --git a/connectivity/qa/drivers/dbase/DBaseNumericFunctions.java b/connectivity/qa/drivers/dbase/DBaseNumericFunctions.java
new file mode 100644
index 000000000000..b3c8ff014a2f
--- /dev/null
+++ b/connectivity/qa/drivers/dbase/DBaseNumericFunctions.java
@@ -0,0 +1,402 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package qa.drivers.dbase;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.sdbc.*;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.XMultiServiceFactory;
+
+
+public class DBaseNumericFunctions
+{
+
+ private final String where = "FROM \"biblio\" \"biblio\" where \"Identifier\" = 'BOR00'";
+ private final XMultiServiceFactory m_xORB;
+ private final DBaseDriverTest testcase;
+
+ public DBaseNumericFunctions(final XMultiServiceFactory _xORB, final DBaseDriverTest _testcase)
+ {
+ m_xORB = _xORB;
+ testcase = _testcase;
+ }
+
+ private void assure(final String s, final boolean b)
+ {
+ testcase.assure2(s, b);
+ }
+
+ public void testFunctions() throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRowSet xRowRes = (XRowSet) UnoRuntime.queryInterface(XRowSet.class,
+ m_xORB.createInstance("com.sun.star.sdb.RowSet"));
+
+ testcase.getLog().println("starting Numeric function test");
+ // set the properties needed to connect to a database
+ final XPropertySet xProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xRowRes);
+ xProp.setPropertyValue("DataSourceName", "Bibliography");
+
+ xProp.setPropertyValue("CommandType", Integer.valueOf(com.sun.star.sdb.CommandType.COMMAND));
+
+ try
+ {
+ abs(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("abs " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ acos(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("acos " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ asin(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("asin " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ atan(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("atan " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ atan2(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("atan2 " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ ceiling(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("ceiling " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ cos(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("cos " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ degrees(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("degrees " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ exp(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("exp " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ floor(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("floor " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ log(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("log " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ log10(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("log10 " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ mod(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("mod " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ pi(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("pi " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ pow(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("pow " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ radians(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("radians " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ round(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("round " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ sign(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("sign " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ sin(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("sin " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ sqrt(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("sqrt " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ tan(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("tan " + ex.getMessage(), false);
+ throw ex;
+ }
+
+ }
+
+ private XRow execute(final XRowSet xRowRes,final String sql) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XPropertySet xProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xRowRes);
+ xProp.setPropertyValue("Command", "SELECT " + sql + where);
+ xRowRes.execute();
+ final XResultSet xRes = (XResultSet) UnoRuntime.queryInterface(XResultSet.class, xRowRes);
+ assure("No valid row! ", xRes.next());
+
+ return (XRow) UnoRuntime.queryInterface(XRow.class, xRes);
+ }
+
+ private void abs(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "ABS(2),ABS(-32) ");
+ assure("ABS(2) failed!", row.getInt(1) == 2);
+ assure("ABS(-32) failed!", row.getInt(2) == 32);
+ }
+
+ private void sign(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "SIGN(-32),SIGN(0),SIGN(234) ");
+ assure("SIGN(-32)failed!", row.getInt(1) == -1);
+ assure("SIGN(0) failed!", row.getInt(2) == 0);
+ assure("SIGN(234) failed!", row.getInt(3) == 1);
+ }
+
+ private void mod(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "MOD(234, 10) ");
+ assure("MOD(234, 10) failed!", row.getInt(1) == 4);
+ }
+
+ private void floor(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "FLOOR(1.23),FLOOR(-1.23) ");
+ assure("FLOOR(1.23) failed!", row.getInt(1) == 1);
+ assure("FLOOR(-1.23) failed!", row.getInt(2) == -2);
+ }
+
+ private void ceiling(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "CEILING(1.23),CEILING(-1.23) ");
+ assure("CEILING(1.23) failed!", row.getInt(1) == 2);
+ assure("CEILING(-1.23) failed!", row.getInt(2) == -1);
+ }
+
+ private void round(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "ROUND(-1.23),ROUND(1.298, 1) ");
+ assure("ROUND(-1.23) failed!", row.getInt(1) == -1);
+ assure("ROUND(1.298, 1) failed!", row.getDouble(2) == 1.3);
+ }
+
+ private void exp(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "EXP(2),EXP(-2) ");
+ assure("EXP(2) failed!", (float) row.getDouble(1) == (float) java.lang.Math.exp(2));
+ assure("EXP(-2) failed!", (float) row.getDouble(2) == (float) java.lang.Math.exp(-2));
+ }
+
+ private void log(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "LOG(2),LOG(-2) ");
+ assure("LOG(2) failed!", (float) row.getDouble(1) == (float) java.lang.Math.log(2));
+ row.getDouble(2);
+ assure("LOG(-2) failed!", row.wasNull());
+ }
+
+ private void log10(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "LOG10(100) ");
+ assure("LOG10(100) failed!", row.getDouble(1) == 2.0);
+ }
+
+ private void pow(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "POWER(2,2) ");
+ assure("POWER(2,2) failed!", row.getDouble(1) == 4.0);
+ }
+
+ private void sqrt(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "SQRT(4) ");
+ assure("SQRT(4) failed!", row.getDouble(1) == 2.0);
+ }
+
+ private void pi(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "PI() ");
+ assure("PI() failed!", (float) row.getDouble(1) == (float) java.lang.Math.PI);
+ }
+
+ private void cos(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "COS(PI()) ");
+ assure("COS(PI()) failed!", row.getDouble(1) == -1.0);
+ }
+
+ private void sin(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "SIN(2) ");
+ assure("SIN(PI()) failed!", (float) row.getDouble(1) == (float) java.lang.Math.sin(2));
+ }
+
+ private void tan(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "TAN(PI()+1) ");
+ assure("TAN(PI()+1) failed!", (float) row.getDouble(1) == (float) java.lang.Math.tan(java.lang.Math.PI + 1.0));
+ }
+
+ private void acos(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "ACOS(1) ");
+ assure("ACOS(1) failed!", (float) row.getDouble(1) == 0.0);
+ }
+
+ private void asin(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "ASIN(0) ");
+ assure("ASIN(0) failed!", (float) row.getDouble(1) == (float) java.lang.Math.asin(0.0));
+ }
+
+ private void atan(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "ATAN(0) ");
+ assure("ATAN(0) failed!", row.getDouble(1) == 0.0);
+ }
+
+ private void atan2(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "ATAN2(0,2) ");
+ assure("ATAN2(0,2) failed!", (float) row.getDouble(1) == 0.0);
+ }
+
+ private void degrees(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "DEGREES(PI()) ");
+ assure("DEGREES(PI()) failed!", row.getDouble(1) == 180.0);
+ }
+
+ private void radians(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "RADIANS(90) ");
+ assure("RADIANS(90) failed!", (float) row.getDouble(1) == (float) (java.lang.Math.PI / 2.0));
+ }
+}
diff --git a/connectivity/qa/drivers/dbase/DBaseSqlTests.java b/connectivity/qa/drivers/dbase/DBaseSqlTests.java
new file mode 100755
index 000000000000..c393c5a48356
--- /dev/null
+++ b/connectivity/qa/drivers/dbase/DBaseSqlTests.java
@@ -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.
+ *
+ ************************************************************************/
+package qa.drivers.dbase;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.sdbc.*;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.XMultiServiceFactory;
+
+public class DBaseSqlTests
+{
+ private final XMultiServiceFactory m_xORB;
+ private final DBaseDriverTest testcase;
+
+ public DBaseSqlTests(final XMultiServiceFactory _xORB,final DBaseDriverTest _testcase)
+ {
+ m_xORB = _xORB;
+ testcase = _testcase;
+ }
+
+ private void assure(final String s,final boolean b)
+ {
+ testcase.assure2(s, b);
+ }
+
+ public void testFunctions() throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRowSet xRowRes = (XRowSet) UnoRuntime.queryInterface(XRowSet.class,
+ m_xORB.createInstance("com.sun.star.sdb.RowSet"));
+
+ testcase.getLog().println("starting SQL test");
+ // set the properties needed to connect to a database
+ final XPropertySet xProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xRowRes);
+ xProp.setPropertyValue("DataSourceName", "Bibliography");
+ xProp.setPropertyValue("CommandType", Integer.valueOf(com.sun.star.sdb.CommandType.COMMAND));
+
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where \"Identifier\" like 'B%'");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where not \"Identifier\" like 'B%'");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where not \"Identifier\" not like 'B%'");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where not(0 = 1)");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where 0 = 0");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where (0 = 0)");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where 0 <> 1");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where 0 < 1");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where 2 > 1");
+ execute(xRowRes,"1,1+1,'a' + 'b' FROM \"biblio\" \"biblio\" where 2 > 1");
+ // execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where (0 = 0) is true");
+ // execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where not (0 = 0) is not true");
+ // execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where 1 between 0 and 2");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where not \"Identifier\" is NULL");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where \"Identifier\" is not NULL");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where \"Identifier\" = \"Identifier\"");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where not(not(\"Identifier\" = \"Identifier\"))");
+ execute(xRowRes,"1 FROM \"biblio\" \"biblio\" where (1 = 1 and 2 = 1) or 3 = 33 or 4 = 44 or ('a' = 'a' and 'b' = 'b')");
+ }
+
+ private void execute(final XRowSet xRowRes, String sql) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ try
+ {
+ final XPropertySet xProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xRowRes);
+ xProp.setPropertyValue("Command", "SELECT " + sql);
+ xRowRes.execute();
+ }
+ catch(SQLException e)
+ {
+ testcase.getLog().println(sql + " Error: " + e.getMessage());
+ }
+ }
+
+
+}
diff --git a/connectivity/qa/drivers/dbase/DBaseStringFunctions.java b/connectivity/qa/drivers/dbase/DBaseStringFunctions.java
new file mode 100644
index 000000000000..1d4ccf0a9b26
--- /dev/null
+++ b/connectivity/qa/drivers/dbase/DBaseStringFunctions.java
@@ -0,0 +1,323 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package qa.drivers.dbase;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.sdbc.*;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.XMultiServiceFactory;
+
+public class DBaseStringFunctions
+{
+ private String where = "FROM \"biblio\" \"biblio\" where \"Identifier\" = 'BOR00'";
+ private final XMultiServiceFactory m_xORB;
+ private final DBaseDriverTest testcase;
+
+ public DBaseStringFunctions(final XMultiServiceFactory _xORB,final DBaseDriverTest _testcase)
+ {
+ m_xORB = _xORB;
+ testcase = _testcase;
+ }
+
+ private void assure(final String s,final boolean b)
+ {
+ testcase.assure2(s, b);
+ }
+
+ public void testFunctions() throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRowSet xRowRes = (XRowSet) UnoRuntime.queryInterface(XRowSet.class,
+ m_xORB.createInstance("com.sun.star.sdb.RowSet"));
+
+ testcase.getLog().println("starting String function test");
+ // set the properties needed to connect to a database
+ final XPropertySet xProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xRowRes);
+ xProp.setPropertyValue("DataSourceName", "Bibliography");
+
+ xProp.setPropertyValue("CommandType", Integer.valueOf(com.sun.star.sdb.CommandType.COMMAND));
+
+ try
+ {
+ upper(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("upper " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ lower(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("lower " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ acsii(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("ascii " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ char_length(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("char_len " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ concat(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("concat " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ chartest(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("char " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ locate(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("locate " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ substring(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("substr " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ ltrim(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("ltrim " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ rtrim(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("rtrim " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ space(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("space " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ replace(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("replace " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ repeat(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("repeat " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ insert(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("insert " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ left(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("left " + ex.getMessage(), false);
+ throw ex;
+ }
+ try
+ {
+ right(xRowRes);
+ }
+ catch (SQLException ex)
+ {
+ assure("right " + ex.getMessage(), false);
+ throw ex;
+ }
+ }
+
+ private XRow execute(final XRowSet xRowRes, String sql) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XPropertySet xProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xRowRes);
+ xProp.setPropertyValue("Command", "SELECT " + sql + where);
+ xRowRes.execute();
+ final XResultSet xRes = (XResultSet) UnoRuntime.queryInterface(XResultSet.class, xRowRes);
+ assure("No valid row! ", xRes.next());
+
+ return (XRow) UnoRuntime.queryInterface(XRow.class, xRes);
+ }
+
+ private void upper(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "upper('test'),UCASE('test') ");
+ assure("upper('test') failed!", row.getString(1).equals("TEST"));
+ assure("ucase('test') failed!", row.getString(2).equals("TEST"));
+ }
+
+ private void lower(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "lower('TEST'),LCASE('TEST') ");
+ assure("lower('TEST') failed!", row.getString(1).equals("test"));
+ assure("lcase('TEST') failed!", row.getString(2).equals("test"));
+ final String temp = where;
+ where = "FROM \"biblio\" \"biblio\" where LOWER(\"Identifier\") like 'bor%'";
+ execute(xRowRes, "lower('TEST'),LCASE('TEST') ");
+ where = temp;
+ }
+
+ private void acsii(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "ASCII('2') ");
+ assure("acsii('2') failed!", row.getInt(1) == 50);
+ }
+
+ private void char_length(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "char_length('test'),character_length('test'),OCTET_LENGTH('test') ");
+ assure("char_length('test') failed!", row.getInt(1) == 4);
+ assure("character_length('test') failed!", row.getInt(2) == 4);
+ assure("OCTET_LENGTH('test') failed!", row.getInt(3) == 4);
+ }
+
+ private void concat(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "CONCAT('Hello',' ','World') ");
+ assure("CONCAT('Hello',' ',,'World') failed!", row.getString(1).equals("Hello World"));
+ }
+
+ private void locate(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "LOCATE('bar', 'foobarbar') ");
+ assure("LOCATE('bar', 'foobarbar') failed!", row.getInt(1) == 4);
+ }
+
+ private void substring(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "SUBSTRING('Quadratically',5) ");
+ assure("SUBSTRING('Quadratically',5) failed!", row.getString(1).equals("ratically"));
+ }
+
+ private void ltrim(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "LTRIM(' barbar') ");
+ assure("LTRIM(' barbar') failed!", row.getString(1).equals("barbar"));
+ }
+
+ private void rtrim(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "RTRIM('barbar ') ");
+ assure("RTRIM('barbar ') failed!", row.getString(1).equals("barbar"));
+ }
+
+ private void space(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "space(6) ");
+ assure("space(6) failed!", row.getString(1).equals(" "));
+ }
+
+ private void replace(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "REPLACE('www.OOo.com', 'w', 'Ww') ");
+ assure("REPLACE('www.OOo.com', 'w', 'Ww') failed!", row.getString(1).equals("WwWwWw.OOo.com"));
+ }
+
+ private void repeat(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "REPEAT('OOo', 3) ");
+ assure("REPEAT('OOo', 3) failed!", row.getString(1).equals("OOoOOoOOo"));
+ }
+
+ private void insert(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "INSERT('Quadratic', 3, 4, 'What') ");
+ assure("INSERT('Quadratic', 3, 4, 'What') failed!", row.getString(1).equals("QuWhattic"));
+ }
+
+ private void left(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "LEFT('foobarbar', 5) ");
+ assure("LEFT('foobarbar', 5) failed!", row.getString(1).equals("fooba"));
+ }
+
+ private void right(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "RIGHT('foobarbar', 4) ");
+ assure("RIGHT('foobarbar', 4) failed!", row.getString(1).equals("rbar"));
+ }
+
+ private void chartest(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+ final XRow row = execute(xRowRes, "CHAR(ascii('t'),ascii('e'),ascii('s'),ascii('t')) ");
+ assure("CHAR(ascii('t'),ascii('e'),ascii('s'),ascii('t')) failed!", row.getString(1).equals("test"));
+ }
+}
diff --git a/connectivity/qa/drivers/dbase/makefile.mk b/connectivity/qa/drivers/dbase/makefile.mk
new file mode 100644
index 000000000000..d71670d67458
--- /dev/null
+++ b/connectivity/qa/drivers/dbase/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..
+TARGET = DBaseDriverTest
+PRJNAME = connectivity
+PACKAGE = qa$/drivers$/dbase
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
+JAVAFILES =\
+ DBaseDateFunctions.java\
+ DBaseDriverTest.java\
+ DBaseNumericFunctions.java\
+ DBaseStringFunctions.java\
+ DBaseSqlTests.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
+run: $(CLASSDIR)$/$(JARTARGET)
+ java -cp "$(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/OOoRunner.jar" org.openoffice.Runner -TestBase java_complex -o qa.drivers.dbase.$(TARGET)
+
diff --git a/connectivity/qa/drivers/dbase/test.properties b/connectivity/qa/drivers/dbase/test.properties
new file mode 100644
index 000000000000..c26879f480f3
--- /dev/null
+++ b/connectivity/qa/drivers/dbase/test.properties
@@ -0,0 +1,5 @@
+# x-no-translate
+Driver=org.openoffice.comp.drivers.MySQL.Driver
+user=testuser
+password=
+URL=sdbc:mysql:odbc:MYSQL fs-11110 TESTUSER
diff --git a/connectivity/qa/drivers/hsqldb/DatabaseMetaData.java b/connectivity/qa/drivers/hsqldb/DatabaseMetaData.java
new file mode 100644
index 000000000000..ddc45a4e0ca1
--- /dev/null
+++ b/connectivity/qa/drivers/hsqldb/DatabaseMetaData.java
@@ -0,0 +1,152 @@
+/*
+ * Class.java
+ *
+ * Created on June 23, 2003, 3:19 PM
+ */
+
+/**
+ *
+ * @author oj93728
+ */
+package qa.drivers.hsqldb;
+import java.sql.*;
+import com.sun.star.uno.UnoRuntime;
+import complexlib.ComplexTestCase;
+import java.lang.reflect.Method;
+import qa.drivers.hsqldb.DriverTest;
+
+
+public class DatabaseMetaData {
+
+ private java.sql.DatabaseMetaData m_xMD;
+ private DriverTest m_TestCase;
+
+ /** Creates a new instance of DatabaseMetaData */
+ public DatabaseMetaData(DriverTest _testCase,java.sql.DatabaseMetaData _xmd) {
+ m_TestCase = _testCase;
+ m_xMD = _xmd;
+ }
+
+ protected void assure(String _sText,boolean btest){
+ m_TestCase.assurePublic(_sText,btest);
+ }
+
+ protected void testMethod(String sName,Class[] params,Object[] objParams,int nCount){
+ try {
+ System.out.println("test method " + sName);
+
+ Method aGet = ((Object)m_xMD).getClass().getDeclaredMethod(sName, params);
+ if ( aGet != null ){
+ ResultSet rs = (ResultSet)aGet.invoke(m_xMD, objParams);
+ ResultSetMetaData rsMD = rs.getMetaData();
+
+ assure( sName + " returns wrong column count" , rsMD.getColumnCount() == nCount);
+ }
+ else
+ assure( sName + " returns wrong column count" , false);
+ } catch( java.lang.NoSuchMethodException ex ) {
+ assure("Method " + sName + " could not be found!",false);
+ } catch( java.lang.IllegalAccessException ex ) {
+ assure("IllegalAccessException!",false);
+ } catch( SQLException ex ) {
+ assure("SQLException occured: " + ex.getMessage() ,false);
+ } catch( java.lang.reflect.InvocationTargetException ex ) {
+ assure("IllegalAccessException!",false);
+ } finally {
+
+ }
+ }
+
+ public void test(){
+
+ // try {
+
+ try{
+ ResultSet rs = m_xMD.getTables(null,null,"TESTCASE",null);
+ while ( rs.next() )
+ {
+ String catalog = rs.getString( 1 );
+ if ( rs.wasNull() )
+ catalog = null;
+
+ String schema = rs.getString( 2 );
+ if ( rs.wasNull() )
+ schema = null;
+
+ String table = rs.getString( 3 );
+ String type = rs.getString( 4 );
+ System.out.println("Catalog: " + catalog + " Schema: " + schema + " Table: " + table + " Type: " + type);
+ System.out.println("------------------ Columns ------------------");
+ ResultSet rsColumns = m_xMD.getColumns(catalog,schema,table,"%");
+ while ( rsColumns.next() )
+ {
+ System.out.println("Column: " + rsColumns.getString( 4 ) + " Type: " + rsColumns.getInt( 5 ) + " TypeName: " + rsColumns.getString( 6 ) );
+ }
+
+ }
+ } catch(Exception e){
+
+ }
+ //testMethod("getTypeInfo", zclass,empty,17);
+/*
+ Class[] zclass = new Class[]{};
+ Object[] empty = new Object[]{};
+ testMethod("getCatalogs", zclass,empty,1);
+
+ testMethod("getSchemas", zclass,empty,2);
+ testMethod("getTableTypes", zclass,empty,1);
+ Class[] a4 = new Class[4];
+ Object[] o4 = new Object[4];
+ a4[0] = Class.forName("java.lang.Object");
+ a4[1] = Class.forName("java.lang.String");
+ a4[2] = Class.forName("java.lang.String");
+ a4[3] = Class.forName("java.lang.String");
+
+ o4[0] = null;
+ o4[1] = null;
+ o4[2] = null;
+ o4[3] = "%";
+ testMethod("getColumnPrivileges", a4,o4,7);
+ testMethod("getColumns", a4,o4,18);
+ testMethod("getProcedureColumns", a4,o4,13);
+ testMethod("getColumns", a4,o4,18);
+
+ Class[] a3 = new Class[3];
+ Object[] o3 = new Object[3];
+ a3[0] = Class.forName("java.lang.Object");
+ a3[1] = Class.forName("java.lang.String");
+ a3[2] = Class.forName("java.lang.String");
+
+ o3[0] = null;
+ o3[1] = null;
+ o3[2] = "%";
+
+ testMethod("getExportedKeys", a3,o3,14);
+ testMethod("getImportedKeys", a3,o3,14);
+ testMethod("getPrimaryKeys", a3,o3,14);
+ testMethod("getProcedures", a3,o3,5);
+ testMethod("getTablePrivileges", a3,o3,6);
+ testMethod("getVersionColumns", a3,o3,7);
+ // testMethod("getCrossReference", a3,o3,14);
+
+ } catch( java.lang.ClassNotFoundException ex) {
+ assure("ClassNotFoundException: " + ex.getMessage() ,false);
+ }
+ */
+ }
+/*
+ public com.sun.star.sdbc.XResultSet getCrossReference(Object obj, String str, String str2, Object obj3, String str4, String str5) {
+ }
+ public com.sun.star.sdbc.XResultSet getIndexInfo(Object obj, String str, String str2, boolean param, boolean param4) {
+ }
+
+ public com.sun.star.sdbc.XResultSet getTables(Object obj, String str, String str2, String[] str3) {
+ }
+
+ public com.sun.star.sdbc.XResultSet getUDTs(Object obj, String str, String str2, int[] values) {
+ }
+
+ public com.sun.star.sdbc.XResultSet getBestRowIdentifier(Object obj, String str, String str2, int param, boolean param4) throws com.sun.star.sdbc.SQLException {
+ }
+ */
+}
diff --git a/connectivity/qa/drivers/hsqldb/DriverTest.java b/connectivity/qa/drivers/hsqldb/DriverTest.java
new file mode 100644
index 000000000000..d343a1309a05
--- /dev/null
+++ b/connectivity/qa/drivers/hsqldb/DriverTest.java
@@ -0,0 +1,170 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package qa.drivers.hsqldb;
+
+import com.sun.star.awt.XWindow;
+import com.sun.star.frame.XModel;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.XCloseable;
+import com.sun.star.sdbc.*;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.sdbc.XDataSource;
+import com.sun.star.frame.XStorable;
+
+import com.sun.star.lang.*;
+import com.sun.star.document.XDocumentSubStorageSupplier;
+import complexlib.ComplexTestCase;
+
+import java.io.PrintWriter;
+
+import util.utils;
+import java.util.*;
+import java.io.*;
+import org.hsqldb.jdbcDriver;
+import qa.drivers.hsqldb.DatabaseMetaData;
+import org.hsqldb.lib.StopWatch;
+import com.sun.star.sdbc.*;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.PropertyState;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.embed.XStorage;
+
+public class DriverTest extends ComplexTestCase {
+
+
+ public String[] getTestMethodNames() {
+ return new String[] { "test" };
+ }
+
+ public String getTestObjectName() {
+ return "DriverTest";
+ }
+
+ public void assurePublic(String sMessage,boolean check){
+ addResult(sMessage,check);
+ }
+
+ public void test(){
+ mThreadTimeOut = 10000000;
+ XDataSource ds = null;
+ System.gc();
+ try {
+ XNameAccess xNameAccess = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class,((XMultiServiceFactory)param.getMSF()).createInstance("com.sun.star.sdb.DatabaseContext"));
+ ds = (XDataSource)UnoRuntime.queryInterface(XDataSource.class,xNameAccess.getByName("file:///g:/test.odb"));
+ } catch(Exception ex) {
+ throw new RuntimeException("factory: unable to construct data source" );
+ }
+
+ try{
+ XDocumentSubStorageSupplier doc = (XDocumentSubStorageSupplier)UnoRuntime.queryInterface(XDocumentSubStorageSupplier.class,ds);
+ XStorage stor = doc.getDocumentSubStorage("database",4);
+ try{
+ if ( stor.isStreamElement("db.log") )
+ stor.removeElement("db.log");
+ } catch(Exception e){}
+ try{
+ if ( stor.isStreamElement("db.properties") )
+ stor.removeElement("db.properties");
+ } catch(Exception e){}
+ try{
+ if ( stor.isStreamElement("db.script") )
+ stor.removeElement("db.script");
+ } catch(Exception e){}
+ try{
+ if ( stor.isStreamElement("db.script.new") )
+ stor.removeElement("db.script.new");
+ } catch(Exception e){}
+ XStorable mod = (XStorable)UnoRuntime.queryInterface(XStorable.class,ds);
+ mod.store();
+ XComponent xComp = (XComponent)UnoRuntime.queryInterface(XComponent.class,stor);
+ if ( xComp != null )
+ xComp.dispose();
+ } catch(Exception e){}
+
+ com.sun.star.beans.PropertyValue[] info = null;
+ XDriver drv = null;
+ try{
+ XDocumentSubStorageSupplier doc = (XDocumentSubStorageSupplier)UnoRuntime.queryInterface(XDocumentSubStorageSupplier.class,ds);
+ XModel mod = (XModel)UnoRuntime.queryInterface(XModel.class,ds);
+ XStorage stor = doc.getDocumentSubStorage("database",4);
+ info = new com.sun.star.beans.PropertyValue[]{
+ new com.sun.star.beans.PropertyValue("Storage",0,stor,PropertyState.DIRECT_VALUE)
+ ,new com.sun.star.beans.PropertyValue("URL",0,mod.getURL(),PropertyState.DIRECT_VALUE)
+ };
+ drv = (XDriver)UnoRuntime.queryInterface(XDriver.class,((XMultiServiceFactory)param.getMSF()).createInstance("com.sun.star.sdbcx.comp.hsqldb.Driver"));
+
+
+ TestCacheSize test = new TestCacheSize(((XMultiServiceFactory)param.getMSF()),info,drv);
+
+ StopWatch sw = new StopWatch();
+
+ try{
+ test.setUp();
+ test.testFillUp();
+ test.checkResults();
+ test.tearDown();
+ System.out.println("Total Test Time: " + sw.elapsedTime());
+ } catch(Exception e){}
+
+ try{
+ XStorable mod2 = (XStorable)UnoRuntime.queryInterface(XStorable.class,ds);
+ mod2.store();
+ } catch(Exception e){}
+ }catch(Exception e){}
+ }
+ public void test2(){
+ mThreadTimeOut = 10000000;
+ System.gc();
+
+ com.sun.star.beans.PropertyValue[] info = null;
+ XDriver drv = null;
+ try{
+ info = new com.sun.star.beans.PropertyValue[]{
+ new com.sun.star.beans.PropertyValue("JavaDriverClass",0,"org.hsqldb.jdbcDriver",PropertyState.DIRECT_VALUE)
+ ,new com.sun.star.beans.PropertyValue("ParameterNameSubstitution",0,new Boolean(false),PropertyState.DIRECT_VALUE)
+ };
+ drv = (XDriver)UnoRuntime.queryInterface(XDriver.class,((XMultiServiceFactory)param.getMSF()).createInstance("com.sun.star.comp.sdbc.JDBCDriver"));
+ TestCacheSize test = new TestCacheSize(((XMultiServiceFactory)param.getMSF()),info,drv);
+ test.setURL("jdbc:hsqldb:g:\\hsql\\db");
+
+
+ StopWatch sw = new StopWatch();
+
+ try{
+ test.setUp();
+ test.testFillUp();
+ test.checkResults();
+ test.tearDown();
+ System.out.println("Total Test Time: " + sw.elapsedTime());
+ } catch(Exception e){}
+ }catch(Exception e){}
+ }
+}
diff --git a/connectivity/qa/drivers/hsqldb/TestCacheSize.java b/connectivity/qa/drivers/hsqldb/TestCacheSize.java
new file mode 100644
index 000000000000..4701905772b8
--- /dev/null
+++ b/connectivity/qa/drivers/hsqldb/TestCacheSize.java
@@ -0,0 +1,617 @@
+/* Copyright (c) 2001-2004, The HSQL Development Group
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of the HSQL Development Group nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+package qa.drivers.hsqldb;
+
+import java.io.*;
+
+
+import org.hsqldb.lib.StopWatch;
+import org.hsqldb.lib.FileAccess;
+
+import java.util.Random;
+import com.sun.star.lang.*;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.PropertyState;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.sdbc.*;
+import com.sun.star.document.XDocumentSubStorageSupplier;
+import com.sun.star.embed.XStorage;
+import com.sun.star.frame.XStorable;
+
+/**
+ * Test large cached tables by setting up a cached table of 100000 records
+ * or more and a much smaller memory table with about 1/100th rows used.
+ * Populate both tables so that an indexed column of the cached table has a
+ * foreign key reference to the main table.
+ *
+ * This database can be used to demonstrate efficient queries to retrieve
+ * the data from the cached table.
+ *
+ * 1.7.1 insert timings for 100000 rows, cache scale 12:
+ * simple table, no extra index: 52 s
+ * with index on lastname only: 56 s
+ * with index on zip only: 211 s
+ * foreign key, referential_integrity true: 216 s
+ *
+ * The above have improved a lot in 1.7.2
+ *
+ * This test now incorporates the defunct TestTextTables
+ *
+ * @author fredt@users
+ * @version 1.7.2
+ * @since 1.7.0
+ */
+public class TestCacheSize {
+
+ // program can edit the *.properties file to set cache_size
+ protected boolean filedb = true;
+
+ // shutdown performed mid operation - not for mem: or hsql: URL's
+ protected boolean shutdown = true;
+
+ // fixed
+ protected String url = "sdbc:embedded:hsqldb";
+
+ // frequent reporting of progress
+ boolean reportProgress = false;
+
+ XMultiServiceFactory servicefactory = null;
+
+ // type of the big table {MEMORY | CACHED | TEXT}
+ String tableType = "CACHED";
+ int cacheScale = 17;
+ int cacheSizeScale = 8;
+
+ // script format {TEXT, BINARY, COMPRESSED}
+ String logType = "TEXT";
+ int writeDelay = 60;
+ boolean indexZip = true;
+ boolean indexLastName = false;
+ boolean addForeignKey = false;
+ boolean refIntegrity = true;
+
+ // speeds up inserts when tableType=="CACHED"
+ boolean createTempTable = false;
+
+ // introduces fragmentation to the .data file during insert
+ boolean deleteWhileInsert = false;
+ int deleteWhileInsertInterval = 10000;
+
+ // size of the tables used in test
+ int bigrows = 10000;
+ int smallrows = 0xfff;
+
+ // if the extra table needs to be created and filled up
+ boolean multikeytable = false;
+
+ //
+ String user;
+ String password;
+ XStatement sStatement;
+ XConnection cConnection;
+ XDataSource ds;
+ XDriver drv;
+ com.sun.star.beans.PropertyValue[] info;
+
+ TestCacheSize(XMultiServiceFactory _xmulti,com.sun.star.beans.PropertyValue[] _info,XDriver _drv){
+ servicefactory = _xmulti;
+ drv = _drv;
+ info = _info;
+ }
+
+ void setURL(String _url){
+ url = _url;
+ }
+
+ protected void setUp() {
+
+ user = "sa";
+ password = "";
+
+ try {
+ sStatement = null;
+ cConnection = null;
+
+ //Class.forName("org.hsqldb.jdbcDriver");
+
+ if (filedb) {
+
+ cConnection = drv.connect(url,info);
+ sStatement = cConnection.createStatement();
+
+ sStatement.execute("SET SCRIPTFORMAT " + logType);
+ sStatement.execute("SET LOGSIZE " + 0);
+ sStatement.execute("SHUTDOWN");
+ cConnection.close();
+// props.setProperty("hsqldb.cache_scale", "" + cacheScale);
+// props.setProperty("hsqldb.cache_size_scale",
+ //"" + cacheSizeScale);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("TestSql.setUp() error: " + e.getMessage());
+ }
+ }
+
+ /**
+ * Fill up the cache
+ *
+ *
+ */
+ public void testFillUp() {
+
+ StopWatch sw = new StopWatch();
+ String ddl1 = "DROP TABLE test IF EXISTS;"
+ + "DROP TABLE zip IF EXISTS;";
+ String ddl2 = "CREATE CACHED TABLE zip( zip INT IDENTITY );";
+ String ddl3 = "CREATE " + tableType + " TABLE test( id INT IDENTITY,"
+ + " firstname VARCHAR, " + " lastname VARCHAR, "
+ + " zip INTEGER, " + " filler VARCHAR); ";
+ String ddl31 = "SET TABLE test SOURCE \"test.csv;cache_scale="
+ + cacheScale + "\";";
+
+ // adding extra index will slow down inserts a bit
+ String ddl4 = "CREATE INDEX idx1 ON TEST (lastname);";
+
+ // adding this index will slow down inserts a lot
+ String ddl5 = "CREATE INDEX idx2 ON TEST (zip);";
+
+ // referential integrity checks will slow down inserts a bit
+ String ddl6 =
+ "ALTER TABLE test add constraint c1 FOREIGN KEY (zip) REFERENCES zip(zip);";
+ String ddl7 = "CREATE TEMP TABLE temptest( id INT,"
+ + " firstname VARCHAR, " + " lastname VARCHAR, "
+ + " zip INTEGER, " + " filler VARCHAR); ";
+ String filler =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ + "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ String mddl1 = "DROP TABLE test2 IF EXISTS;";
+ String mddl2 = "CREATE " + tableType
+ + " TABLE test2( id1 INT, id2 INT,"
+ + " firstname VARCHAR, " + " lastname VARCHAR, "
+ + " zip INTEGER, " + " filler VARCHAR, "
+ + " PRIMARY KEY (id1,id2) ); ";
+ String mdd13 = "SET TABLE test2 SOURCE \"test2.csv;cache_scale="
+ + cacheScale + "\";";
+
+ try {
+ System.out.println("Connecting");
+ sw.zero();
+
+ cConnection = null;
+ sStatement = null;
+ cConnection = drv.connect(url,info);
+
+ System.out.println("connected: " + sw.elapsedTime());
+ sw.zero();
+
+ sStatement = cConnection.createStatement();
+
+ java.util.Random randomgen = new java.util.Random();
+
+ sStatement.execute("SET WRITE_DELAY " + writeDelay);
+ sStatement.execute(ddl1);
+ sStatement.execute(ddl2);
+ sStatement.execute(ddl3);
+
+ if (tableType.equals("TEXT")) {
+ sStatement.execute(ddl31);
+ }
+
+ System.out.println("test table with no index");
+
+ if (indexLastName) {
+ sStatement.execute(ddl4);
+ System.out.println("create index on lastname");
+ }
+
+ if (indexZip) {
+ sStatement.execute(ddl5);
+ System.out.println("create index on zip");
+ }
+
+ if (addForeignKey) {
+ sStatement.execute(ddl6);
+ System.out.println("add foreign key");
+ }
+
+ if (createTempTable) {
+ sStatement.execute(ddl7);
+ System.out.println("temp table");
+ }
+
+ if (multikeytable) {
+ sStatement.execute(mddl1);
+ sStatement.execute(mddl2);
+
+ if (tableType.equals("TEXT")) {
+ sStatement.execute(mdd13);
+ }
+
+ System.out.println("multi key table");
+ }
+
+// sStatement.execute("CREATE INDEX idx3 ON tempTEST (zip);");
+ System.out.println("Setup time: " + sw.elapsedTime());
+ fillUpBigTable(filler, randomgen);
+
+ if (multikeytable) {
+ fillUpMultiTable(filler, randomgen);
+ }
+
+ sw.zero();
+
+ if (shutdown) {
+ sStatement.execute("SHUTDOWN");
+ System.out.println("Shutdown Time: " + sw.elapsedTime());
+ }
+
+ cConnection.close();
+ } catch (SQLException e) {
+ System.out.println(e.getMessage());
+ }
+ }
+
+ private void fillUpBigTable(String filler,
+ Random randomgen) throws SQLException {
+
+ StopWatch sw = new StopWatch();
+ int i;
+
+ for (i = 0; i <= smallrows; i++) {
+ sStatement.execute("INSERT INTO zip VALUES(null);");
+ }
+
+ sStatement.execute("SET REFERENTIAL_INTEGRITY " + this.refIntegrity
+ + ";");
+
+ XPreparedStatement ps = cConnection.prepareStatement(
+ "INSERT INTO test (firstname,lastname,zip,filler) VALUES (?,?,?,?)");
+
+ XParameters para = (XParameters)UnoRuntime.queryInterface(XParameters.class,ps);
+ para.setString(1, "Julia");
+ para.setString(2, "Clancy");
+
+ for (i = 0; i < bigrows; i++) {
+ para.setInt(3, randomgen.nextInt(smallrows));
+
+ long nextrandom = randomgen.nextLong();
+ int randomlength = (int) nextrandom & 0x7f;
+
+ if (randomlength > filler.length()) {
+ randomlength = filler.length();
+ }
+
+ String varfiller = filler.substring(0, randomlength);
+
+ para.setString(4, nextrandom + varfiller);
+ ps.execute();
+
+ if (reportProgress && (i + 1) % 10000 == 0) {
+ System.out.println("Insert " + (i + 1) + " : "
+ + sw.elapsedTime());
+ }
+
+ // delete and add 4000 rows to introduce fragmentation
+ if (deleteWhileInsert && i != 0
+ && i % deleteWhileInsertInterval == 0) {
+ sStatement.execute("CALL IDENTITY();");
+
+ XMultipleResults mrs = (XMultipleResults)UnoRuntime.queryInterface(XMultipleResults.class,sStatement);
+ XResultSet rs = mrs.getResultSet();
+
+ rs.next();
+
+ XRow row = (XRow)UnoRuntime.queryInterface(XRow.class,rs);
+ int lastId = row.getInt(1);
+
+ sStatement.execute(
+ "SELECT * INTO TEMP tempt FROM test WHERE id > "
+ + (lastId - 4000) + " ;");
+ sStatement.execute("DELETE FROM test WHERE id > "
+ + (lastId - 4000) + " ;");
+ sStatement.execute("INSERT INTO test SELECT * FROM tempt;");
+ sStatement.execute("DROP TABLE tempt;");
+ }
+ }
+
+// sStatement.execute("INSERT INTO test SELECT * FROM temptest;");
+// sStatement.execute("DROP TABLE temptest;");
+// sStatement.execute(ddl7);
+ System.out.println("Total insert: " + i);
+ System.out.println("Insert time: " + sw.elapsedTime() + " rps: "
+ + (i * 1000 / (sw.elapsedTime() + 1)));
+ }
+
+ private void fillUpMultiTable(String filler,
+ Random randomgen) throws SQLException {
+
+ StopWatch sw = new StopWatch();
+ int i;
+ XPreparedStatement ps = cConnection.prepareStatement(
+ "INSERT INTO test2 (id1, id2, firstname,lastname,zip,filler) VALUES (?,?,?,?,?,?)");
+
+ XParameters para = (XParameters)UnoRuntime.queryInterface(XParameters.class,ps);
+ para.setString(3, "Julia");
+ para.setString(4, "Clancy");
+
+ int id1 = 0;
+
+ for (i = 0; i < bigrows; i++) {
+ int id2 = randomgen.nextInt(Integer.MAX_VALUE);
+
+ if (i % 1000 == 0) {
+ id1 = randomgen.nextInt(Integer.MAX_VALUE);
+ }
+
+ para.setInt(1, id1);
+ para.setInt(2, id2);
+ para.setInt(5, randomgen.nextInt(smallrows));
+
+ long nextrandom = randomgen.nextLong();
+ int randomlength = (int) nextrandom & 0x7f;
+
+ if (randomlength > filler.length()) {
+ randomlength = filler.length();
+ }
+
+ String varfiller = filler.substring(0, randomlength);
+
+ para.setString(6, nextrandom + varfiller);
+
+ try {
+ ps.execute();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ if (reportProgress && (i + 1) % 10000 == 0) {
+ System.out.println("Insert " + (i + 1) + " : "
+ + sw.elapsedTime());
+ }
+ }
+
+ System.out.println("Multi Key Total insert: " + i);
+ System.out.println("Insert time: " + sw.elapsedTime() + " rps: "
+ + (i * 1000 / (sw.elapsedTime() + 1)));
+ }
+
+ protected void tearDown() {}
+
+ protected void checkResults() {
+
+ try {
+ StopWatch sw = new StopWatch();
+ XResultSet rs;
+
+ cConnection = drv.connect(url,info);
+
+ System.out.println("Reopened database: " + sw.elapsedTime());
+ sw.zero();
+
+ sStatement = cConnection.createStatement();
+
+ sStatement.execute("SET WRITE_DELAY " + writeDelay);
+
+ // the tests use different indexes
+ // use primary index
+ sStatement.execute("SELECT count(*) from TEST");
+
+ XMultipleResults mrs = (XMultipleResults)UnoRuntime.queryInterface(XMultipleResults.class,sStatement);
+ rs = mrs.getResultSet();
+ XRow row = (XRow)UnoRuntime.queryInterface(XRow.class,rs);
+
+ rs.next();
+ System.out.println("Row Count: " + row.getInt(1));
+ System.out.println("Time to count: " + sw.elapsedTime());
+
+ // use index on zip
+ sw.zero();
+ sStatement.execute("SELECT count(*) from TEST where zip > -1");
+
+ rs = mrs.getResultSet();
+
+ rs.next();
+ System.out.println("Row Count: " + row.getInt(1));
+ System.out.println("Time to count: " + sw.elapsedTime());
+ checkSelects();
+ checkUpdates();
+ checkSelects();
+ sw.zero();
+ sStatement.execute("SELECT count(*) from TEST where zip > -1");
+
+ rs = mrs.getResultSet();
+
+ rs.next();
+ System.out.println("Row Count: " + row.getInt(1));
+ System.out.println("Time to count: " + sw.elapsedTime());
+ sw.zero();
+
+ if (shutdown) {
+ sStatement.execute("SHUTDOWN");
+ System.out.println("Shutdown Time: " + sw.elapsedTime());
+ }
+
+ cConnection.close();
+ System.out.println("Closed database: " + sw.elapsedTime());
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void checkSelects() {
+
+ StopWatch sw = new StopWatch();
+ java.util.Random randomgen = new java.util.Random();
+ int i = 0;
+ boolean slow = false;
+
+ try {
+ XPreparedStatement ps = cConnection.prepareStatement(
+ "SELECT TOP 1 firstname,lastname,zip,filler FROM test WHERE zip = ?");
+ XParameters para = (XParameters)UnoRuntime.queryInterface(XParameters.class,ps);
+
+ for (; i < bigrows; i++) {
+ para.setInt(1, randomgen.nextInt(smallrows));
+ ps.execute();
+
+ if ((i + 1) == 100 && sw.elapsedTime() > 5000) {
+ slow = true;
+ }
+
+ if (reportProgress && (i + 1) % 10000 == 0
+ || (slow && (i + 1) % 100 == 0)) {
+ System.out.println("Select " + (i + 1) + " : "
+ + sw.elapsedTime() + " rps: "
+ + (i * 1000 / (sw.elapsedTime() + 1)));
+ }
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("Select random zip " + i + " rows : "
+ + sw.elapsedTime() + " rps: "
+ + (i * 1000 / (sw.elapsedTime() + 1)));
+ sw.zero();
+
+ try {
+ XPreparedStatement ps = cConnection.prepareStatement(
+ "SELECT firstname,lastname,zip,filler FROM test WHERE id = ?");
+ XParameters para = (XParameters)UnoRuntime.queryInterface(XParameters.class,ps);
+
+ for (i = 0; i < bigrows; i++) {
+ para.setInt(1, randomgen.nextInt(bigrows - 1));
+ ps.execute();
+
+ if (reportProgress && (i + 1) % 10000 == 0
+ || (slow && (i + 1) % 100 == 0)) {
+ System.out.println("Select " + (i + 1) + " : "
+ + (sw.elapsedTime() + 1));
+ }
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("Select random id " + i + " rows : "
+ + sw.elapsedTime() + " rps: "
+ + (i * 1000 / (sw.elapsedTime() + 1)));
+ sw.zero();
+
+ try {
+ XPreparedStatement ps = cConnection.prepareStatement(
+ "SELECT zip FROM zip WHERE zip = ?");
+ XParameters para = (XParameters)UnoRuntime.queryInterface(XParameters.class,ps);
+
+ for (i = 0; i < bigrows; i++) {
+ para.setInt(1, randomgen.nextInt(smallrows - 1));
+ ps.execute();
+
+ if (reportProgress && (i + 1) % 10000 == 0
+ || (slow && (i + 1) % 100 == 0)) {
+ System.out.println("Select " + (i + 1) + " : "
+ + (sw.elapsedTime() + 1));
+ }
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("Select random zip from zip table " + i
+ + " rows : " + sw.elapsedTime() + " rps: "
+ + (i * 1000 / (sw.elapsedTime() + 1)));
+ }
+
+ private void checkUpdates() {
+
+ StopWatch sw = new StopWatch();
+ java.util.Random randomgen = new java.util.Random();
+ int i = 0;
+ boolean slow = false;
+ int count = 0;
+
+ try {
+ XPreparedStatement ps = cConnection.prepareStatement(
+ "UPDATE test SET filler = filler || zip WHERE zip = ?");
+ XParameters para = (XParameters)UnoRuntime.queryInterface(XParameters.class,ps);
+
+ for (; i < smallrows; i++) {
+ int random = randomgen.nextInt(smallrows - 1);
+
+ para.setInt(1, random);
+
+ count += ps.executeUpdate();
+
+ if (reportProgress && count % 10000 < 20) {
+ System.out.println("Update " + count + " : "
+ + (sw.elapsedTime() + 1));
+ }
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("Update with random zip " + i
+ + " UPDATE commands, " + count + " rows : "
+ + sw.elapsedTime() + " rps: "
+ + (count * 1000 / (sw.elapsedTime() + 1)));
+ sw.zero();
+
+ try {
+ XPreparedStatement ps = cConnection.prepareStatement(
+ "UPDATE test SET zip = zip + 1 WHERE id = ?");
+ XParameters para = (XParameters)UnoRuntime.queryInterface(XParameters.class,ps);
+
+ for (i = 0; i < bigrows; i++) {
+ int random = randomgen.nextInt(bigrows - 1);
+
+ para.setInt(1, random);
+ ps.execute();
+
+ if (reportProgress && (i + 1) % 10000 == 0
+ || (slow && (i + 1) % 100 == 0)) {
+ System.out.println("Update " + (i + 1) + " : "
+ + sw.elapsedTime() + " rps: "
+ + (i * 1000 / (sw.elapsedTime() + 1)));
+ }
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("Update with random id " + i + " rows : "
+ + sw.elapsedTime() + " rps: "
+ + (i * 1000 / (sw.elapsedTime() + 1)));
+ }
+}
diff --git a/connectivity/qa/drivers/jdbc/LongVarCharTest.java b/connectivity/qa/drivers/jdbc/LongVarCharTest.java
new file mode 100644
index 000000000000..a5797b223b61
--- /dev/null
+++ b/connectivity/qa/drivers/jdbc/LongVarCharTest.java
@@ -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.
+ *
+ ************************************************************************/
+package complex.connectivity;
+
+import com.sun.star.beans.PropertyState;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdbc.XResultSet;
+import com.sun.star.sdbc.XClob;
+import com.sun.star.sdbc.XDriverAccess;
+import com.sun.star.sdbc.XParameters;
+import com.sun.star.sdbc.XPreparedStatement;
+import com.sun.star.sdbc.XResultSetMetaData;
+import com.sun.star.sdbc.XResultSetMetaDataSupplier;
+import com.sun.star.sdbc.XRow;
+import com.sun.star.uno.UnoRuntime;
+import complexlib.ComplexTestCase;
+
+public class LongVarCharTest extends ComplexTestCase
+{
+
+ public String[] getTestMethodNames()
+ {
+ return new String[]
+ {
+ "testLongVarChar"
+ };
+ }
+
+ public String getTestObjectName()
+ {
+ return "LongVarCharTest";
+ }
+
+ public void testLongVarChar() throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException
+ {
+
+ try
+ {
+ System.out.println("== Start testing ==");
+
+ String url = "jdbc:mysql://localhost:3306/mysql?user=root";
+ //String url = "jdbc:ingres://localhost:II7/demodb;AUTO=multi";
+ com.sun.star.sdbc.XConnection xConnection = null;
+ com.sun.star.beans.PropertyValue prop[] = new PropertyValue[1];
+ prop[0] = new PropertyValue("JavaDriverClass", 0, "com.mysql.jdbc.Driver", PropertyState.DIRECT_VALUE);
+ //prop[0] = new PropertyValue("JavaDriverClass", 0, "com.ingres.jdbc.IngresDriver", PropertyState.DIRECT_VALUE);
+
+ // get the remote office component context
+ XMultiServiceFactory xServiceManager = (XMultiServiceFactory) param.getMSF();
+ Object x = xServiceManager.createInstance("com.sun.star.sdbc.DriverManager");
+ com.sun.star.sdbc.XDriverAccess xDriverAccess = (XDriverAccess) UnoRuntime.queryInterface(XDriverAccess.class, x);
+ com.sun.star.sdbc.XDriver xDriver = xDriverAccess.getDriverByURL(url);
+ xConnection = xDriver.connect(url, prop);
+
+ //Object prepStmnt = xConnection.prepareStatement("SELECT * FROM t1 WHERE t1.c1 = ?");
+ Object prepStmnt = xConnection.prepareStatement("SELECT * FROM i90114 WHERE i90114.c1 = ?");
+ ((XParameters) UnoRuntime.queryInterface(XParameters.class, prepStmnt)).clearParameters();
+ ((XParameters) UnoRuntime.queryInterface(XParameters.class, prepStmnt)).setInt(1, 1);
+ XResultSet xResultSet = ((XPreparedStatement) prepStmnt).executeQuery();
+ XRow xRow = (XRow) UnoRuntime.queryInterface(XRow.class, xResultSet);
+
+ XResultSetMetaDataSupplier xRsMetaSup = (XResultSetMetaDataSupplier) UnoRuntime.queryInterface(XResultSetMetaDataSupplier.class, xResultSet);
+ XResultSetMetaData xRsMetaData = xRsMetaSup.getMetaData();
+ int nColumnCount = xRsMetaData.getColumnCount();
+
+ System.out.println("== MetaData ==");
+ for (int i = 1; i <= nColumnCount; ++i)
+ {
+ System.out.println("Name: " + xRsMetaData.getColumnName(i) + " Type: " +
+ xRsMetaData.getColumnType(i));
+ }
+
+ System.out.println("== Result ==");
+ while (xResultSet.next())
+ {
+ String str = "not set";
+
+ XClob xClob = null;
+ xClob = xRow.getClob(2);
+ if (xClob != null)
+ {
+ System.out.println("xClob != null");
+ int len = (int) xClob.length();
+ str = xClob.getSubString(1, len);
+ }
+ else
+ {
+ System.out.println("xClob == null");
+ }
+
+ System.out.println("c1 (Int): " + xRow.getInt(1) + " c2 (String): " + xRow.getString(2) + " c3 (Clob): " + str);
+ }
+
+ xConnection.close();
+ }
+ catch (java.lang.Exception e)
+ {
+ System.out.println("== Exception occured while testing ==");
+ e.printStackTrace();
+ } finally
+ {
+ System.out.println("== End testing ==");
+ System.exit(0);
+ }
+ }
+} \ No newline at end of file
diff --git a/connectivity/qa/drivers/jdbc/makefile.mk b/connectivity/qa/drivers/jdbc/makefile.mk
new file mode 100644
index 000000000000..e9f03ce1be3c
--- /dev/null
+++ b/connectivity/qa/drivers/jdbc/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..
+TARGET = LongVarCharTest
+PRJNAME = connectivity
+PACKAGE = complex$/connectivity
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
+JAVAFILES =\
+ LongVarCharTest.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+ALL : ALLTAR
+.ELSE
+ALL: ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+
+run:
+ java -cp $(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/OOoRunner.jar org.openoffice.Runner -TestBase java_complex -o complex.connectivity.$(TARGET)
+
diff --git a/connectivity/source/commontools/AutoRetrievingBase.cxx b/connectivity/source/commontools/AutoRetrievingBase.cxx
new file mode 100644
index 000000000000..5f84bc5f0e93
--- /dev/null
+++ b/connectivity/source/commontools/AutoRetrievingBase.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"
+#include "AutoRetrievingBase.hxx"
+
+namespace connectivity
+{
+ ::rtl::OUString OAutoRetrievingBase::getTransformedGeneratedStatement(const ::rtl::OUString& _sInsertStatement) const
+ {
+ ::rtl::OUString sStmt = _sInsertStatement;
+ OSL_ENSURE( m_bAutoRetrievingEnabled,"Illegal call here. isAutoRetrievingEnabled is false!");
+ sStmt = sStmt.toAsciiUpperCase();
+ ::rtl::OUString sStatement;
+ if ( sStmt.compareToAscii("INSERT",6) == 0 )
+ {
+ sStatement = m_sGeneratedValueStatement;
+ static const ::rtl::OUString sColumn(RTL_CONSTASCII_USTRINGPARAM("$column"));
+ static const ::rtl::OUString sTable(RTL_CONSTASCII_USTRINGPARAM("$table"));
+ sal_Int32 nIndex = 0;
+ nIndex = sStatement.indexOf(sColumn,nIndex);
+ if ( -1 != nIndex )
+ { // we need a column
+ }
+ nIndex = 0;
+ nIndex = sStatement.indexOf(sTable,nIndex);
+ if ( -1 != nIndex )
+ { // we need a table name
+ sal_Int32 nIntoIndex = sStmt.indexOf(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INTO ")));
+ sStmt = sStmt.copy(nIntoIndex+5);
+ do
+ {
+ if ( sStmt.indexOf(' ') == 0 )
+ sStmt = sStmt.copy(1);
+ }
+ while (sStmt.indexOf(' ') == 0 );
+
+ nIntoIndex = 0;
+ ::rtl::OUString sTableName = sStmt.getToken(0,' ',nIntoIndex);
+ sStatement = sStatement.replaceAt(nIndex,sTable.getLength(),sTableName);
+ }
+ }
+ return sStatement;
+ }
+}
+
diff --git a/connectivity/source/commontools/BlobHelper.cxx b/connectivity/source/commontools/BlobHelper.cxx
new file mode 100644
index 000000000000..1b7ad15ca394
--- /dev/null
+++ b/connectivity/source/commontools/BlobHelper.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 "connectivity/BlobHelper.hxx"
+#include <comphelper/seqstream.hxx>
+#include "connectivity/dbexception.hxx"
+
+using namespace connectivity;
+using namespace dbtools;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+
+BlobHelper::BlobHelper(const ::com::sun::star::uno::Sequence< sal_Int8 >& _val) : m_aValue(_val)
+{
+}
+// -----------------------------------------------------------------------------
+::sal_Int64 SAL_CALL BlobHelper::length( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return m_aValue.getLength();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL BlobHelper::getBytes( ::sal_Int64 pos, ::sal_Int32 _length ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ if ( sal_Int32(pos + _length) > m_aValue.getLength() )
+ throw ::com::sun::star::sdbc::SQLException();
+ return ::com::sun::star::uno::Sequence< ::sal_Int8 >(m_aValue.getConstArray() + sal_Int32(pos),_length);
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL BlobHelper::getBinaryStream( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return new ::comphelper::SequenceInputStream(m_aValue);
+}
+// -----------------------------------------------------------------------------
+::sal_Int64 SAL_CALL BlobHelper::position( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& /*pattern*/, ::sal_Int64 /*start*/ ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XBlob::position", *this );
+ return 0;
+}
+// -----------------------------------------------------------------------------
+::sal_Int64 SAL_CALL BlobHelper::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 );
+ return 0;
+}
diff --git a/connectivity/source/commontools/CommonTools.cxx b/connectivity/source/commontools/CommonTools.cxx
new file mode 100644
index 000000000000..b9d3e8bec1b5
--- /dev/null
+++ b/connectivity/source/commontools/CommonTools.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 <stdio.h>
+#include "connectivity/CommonTools.hxx"
+#include "connectivity/dbtools.hxx"
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <comphelper/extract.hxx>
+#include <cppuhelper/interfacecontainer.h>
+#include "TConnection.hxx"
+#include <comphelper/types.hxx>
+#include <com/sun/star/java/XJavaVM.hpp>
+#include <rtl/process.h>
+
+using namespace ::comphelper;
+inline sal_Unicode rtl_ascii_toUpperCase( sal_Unicode ch )
+{
+ return ch >= 0x0061 && ch <= 0x007a ? ch + 0x20 : ch;
+}
+
+namespace connectivity
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace dbtools;
+ namespace starjava = com::sun::star::java;
+ //------------------------------------------------------------------------------
+ const sal_Unicode CHAR_PLACE = '_';
+ const sal_Unicode CHAR_WILD = '%';
+ // -------------------------------------------------------------------------
+ sal_Bool match(const sal_Unicode* pWild, const sal_Unicode* pStr, const sal_Unicode cEscape)
+ {
+ int pos=0;
+ int flag=0;
+
+ while ( *pWild || flag )
+ {
+ switch (*pWild)
+ {
+ case CHAR_PLACE:
+ if ( *pStr == 0 )
+ return sal_False;
+ break;
+ default:
+ if (*pWild && (*pWild == cEscape) && ((*(pWild+1)== CHAR_PLACE) || (*(pWild+1) == CHAR_WILD)) )
+ pWild++;
+ if ( rtl_ascii_toUpperCase(*pWild) != rtl_ascii_toUpperCase(*pStr) )
+ if ( !pos )
+ return sal_False;
+ else
+ pWild += pos;
+ else
+ break; // ACHTUNG laeuft unter bestimmten
+ // Umstaenden in den nachsten case rein!!
+ case CHAR_WILD:
+ while ( *pWild == CHAR_WILD )
+ pWild++;
+ if ( *pWild == 0 )
+ return sal_True;
+ flag = 1;
+ pos = 0;
+ if ( *pStr == 0 )
+ return ( *pWild == 0 );
+ while ( *pStr && *pStr != *pWild )
+ {
+ if ( *pWild == CHAR_PLACE ) {
+ pWild++;
+ while ( *pWild == CHAR_WILD )
+ pWild++;
+ }
+ pStr++;
+ if ( *pStr == 0 )
+ return ( *pWild == 0 );
+ }
+ break;
+ }
+ if ( *pWild != 0 )
+ pWild++;
+ if ( *pStr != 0 )
+ pStr++;
+ else
+ flag = 0;
+ if ( flag )
+ pos--;
+ }
+ return ( *pStr == 0 ) && ( *pWild == 0 );
+ }
+ //------------------------------------------------------------------
+ rtl::OUString toDateString(const ::com::sun::star::util::Date& rDate)
+ {
+ sal_Char s[11];
+ snprintf(s,
+ sizeof(s),
+ "%04d-%02d-%02d",
+ (int)rDate.Year,
+ (int)rDate.Month,
+ (int)rDate.Day);
+ s[10] = 0;
+ return rtl::OUString::createFromAscii(s);
+ }
+
+ //------------------------------------------------------------------
+ rtl::OUString toTimeString(const ::com::sun::star::util::Time& rTime)
+ {
+ sal_Char s[9];
+ snprintf(s,
+ sizeof(s),
+ "%02d:%02d:%02d",
+ (int)rTime.Hours,
+ (int)rTime.Minutes,
+ (int)rTime.Seconds);
+ s[8] = 0;
+ return rtl::OUString::createFromAscii(s);
+ }
+
+ //------------------------------------------------------------------
+ rtl::OUString toDateTimeString(const ::com::sun::star::util::DateTime& rDateTime)
+ {
+ sal_Char s[21];
+ snprintf(s,
+ sizeof(s),
+ "%04d-%02d-%02d %02d:%02d:%02d",
+ (int)rDateTime.Year,
+ (int)rDateTime.Month,
+ (int)rDateTime.Day,
+ (int)rDateTime.Hours,
+ (int)rDateTime.Minutes,
+ (int)rDateTime.Seconds);
+ s[20] = 0;
+ return rtl::OUString::createFromAscii(s);
+ }
+
+
+ //--------------------------------------------------------------------------------------------------
+ rtl::OUString toString(const Any& rValue)
+ {
+ rtl::OUString aRes;
+ TypeClass aDestinationClass = rValue.getValueType().getTypeClass();
+
+ switch (aDestinationClass)
+ {
+ case TypeClass_CHAR:
+ aRes = ::rtl::OUString::valueOf(*(sal_Unicode*)rValue.getValue());
+ break;
+ case TypeClass_FLOAT:
+ aRes = ::rtl::OUString::valueOf(*(float*)rValue.getValue());
+ break;
+ case TypeClass_DOUBLE:
+ aRes = ::rtl::OUString::valueOf(*(double*)rValue.getValue());
+ break;
+ case TypeClass_BOOLEAN:
+ aRes = ::rtl::OUString::valueOf((sal_Int32)*(sal_Bool*)rValue.getValue());
+ break;
+ case TypeClass_BYTE:
+ case TypeClass_SHORT:
+ case TypeClass_LONG:
+ aRes = ::rtl::OUString::valueOf(*(sal_Int32*)rValue.getValue());
+ break;
+ case TypeClass_HYPER:
+ {
+ sal_Int64 nValue = 0;
+ OSL_VERIFY( rValue >>= nValue );
+ aRes = ::rtl::OUString::valueOf(nValue);
+ }
+ case TypeClass_STRING:
+ rValue >>= aRes;
+ break;
+ case TypeClass_STRUCT:
+ if (rValue.getValueType() == ::getCppuType((const ::com::sun::star::util::Date*)0))
+ {
+ ::com::sun::star::util::Date aDate;
+ rValue >>= aDate;
+ aRes = toDateString(aDate);
+ }
+ else if (rValue.getValueType() == ::getCppuType((const ::com::sun::star::util::DateTime*)0))
+ {
+ ::com::sun::star::util::DateTime aDT;
+ rValue >>= aDT;
+ aRes = toDateTimeString(aDT);
+ }
+ else if (rValue.getValueType() == ::getCppuType((const ::com::sun::star::util::Time*)0))
+ {
+ ::com::sun::star::util::Time aTime;
+ rValue >>= aTime;
+ aRes = toTimeString(aTime);
+ }
+
+ break;
+ default:
+ ;
+ }
+ return aRes;
+ }
+
+ // -----------------------------------------------------------------------------
+ ::rtl::Reference< jvmaccess::VirtualMachine > getJavaVM(const Reference<XMultiServiceFactory >& _rxFactory)
+ {
+ ::rtl::Reference< jvmaccess::VirtualMachine > aRet;
+ OSL_ENSURE(_rxFactory.is(),"No XMultiServiceFactory a.v.!");
+ if(!_rxFactory.is())
+ return aRet;
+
+ try
+ {
+ Reference< starjava::XJavaVM > xVM(_rxFactory->createInstance(
+ rtl::OUString::createFromAscii("com.sun.star.java.JavaVirtualMachine")), UNO_QUERY);
+
+ OSL_ENSURE(_rxFactory.is(),"InitJava: I have no factory!");
+ if (!xVM.is() || !_rxFactory.is())
+ throw Exception(); // -2;
+
+ Sequence<sal_Int8> processID(16);
+ rtl_getGlobalProcessId( (sal_uInt8*) processID.getArray() );
+ processID.realloc(17);
+ processID[16] = 0;
+
+ Any uaJVM = xVM->getJavaVM( processID );
+
+ if (!uaJVM.hasValue())
+ throw Exception(); // -5
+ else
+ {
+ sal_Int32 nValue = 0;
+ jvmaccess::VirtualMachine* pJVM = NULL;
+ if ( uaJVM >>= nValue )
+ pJVM = reinterpret_cast< jvmaccess::VirtualMachine* > (nValue);
+ else
+ {
+ sal_Int64 nTemp = 0;
+ uaJVM >>= nTemp;
+ pJVM = reinterpret_cast< jvmaccess::VirtualMachine* > (nTemp);
+ }
+ aRet = pJVM;
+ }
+ }
+ catch (Exception&)
+ {
+ }
+
+ return aRet;
+ }
+ //------------------------------------------------------------------------------
+ sal_Bool existsJavaClassByName( const ::rtl::Reference< jvmaccess::VirtualMachine >& _pJVM,const ::rtl::OUString& _sClassName )
+ {
+ sal_Bool bRet = sal_False;
+#ifdef SOLAR_JAVA
+ if ( _pJVM.is() )
+ {
+ jvmaccess::VirtualMachine::AttachGuard aGuard(_pJVM);
+ JNIEnv* pEnv = aGuard.getEnvironment();
+ if( pEnv )
+ {
+ ::rtl::OString sClassName = ::rtl::OUStringToOString(_sClassName, RTL_TEXTENCODING_ASCII_US);
+ sClassName = sClassName.replace('.','/');
+ jobject out = pEnv->FindClass(sClassName);
+ bRet = out != NULL;
+ pEnv->DeleteLocalRef( out );
+ }
+ }
+#endif
+ return bRet;
+ }
+
+}
+
+#include <ctype.h> //isdigit
+namespace dbtools
+{
+//------------------------------------------------------------------
+sal_Bool isCharOk(sal_Unicode c,const ::rtl::OUString& _rSpecials)
+{
+
+ return ( ((c >= 97) && (c <= 122)) || ((c >= 65) && (c <= 90)) || ((c >= 48) && (c <= 57)) ||
+ c == '_' || _rSpecials.indexOf(c) != -1);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool isValidSQLName(const ::rtl::OUString& rName,const ::rtl::OUString& _rSpecials)
+{
+ // Ueberpruefung auf korrekte Namensgebung im SQL Sinne
+ // Dieses ist wichtig fuer Tabellennamen beispielsweise
+ const sal_Unicode* pStr = rName.getStr();
+ if (*pStr > 127 || isdigit(*pStr))
+ return sal_False;
+
+ for (; *pStr; ++pStr )
+ if(!isCharOk(*pStr,_rSpecials))
+ return sal_False;
+
+ if ( rName.getLength()
+ && ( (rName.toChar() == '_')
+ || ( (rName.toChar() >= '0')
+ && (rName.toChar() <= '9')
+ )
+ )
+ )
+ return sal_False;
+ // the SQL-Standard requires the first character to be an alphabetic character, which
+ // isn't easy to decide in UniCode ...
+ // So we just prohibit the characters which already lead to problems ....
+ // 11.04.00 - 74902 - FS
+
+ return sal_True;
+}
+//------------------------------------------------------------------
+// Erzeugt einen neuen Namen falls noetig
+::rtl::OUString convertName2SQLName(const ::rtl::OUString& rName,const ::rtl::OUString& _rSpecials)
+{
+ if(isValidSQLName(rName,_rSpecials))
+ return rName;
+ ::rtl::OUString aNewName(rName);
+ const sal_Unicode* pStr = rName.getStr();
+ sal_Int32 nLength = rName.getLength();
+ sal_Bool bValid(*pStr < 128 && !isdigit(*pStr));
+ for (sal_Int32 i=0; bValid && i < nLength; ++pStr,++i )
+ if(!isCharOk(*pStr,_rSpecials))
+ {
+ aNewName = aNewName.replace(*pStr,'_');
+ pStr = aNewName.getStr() + i;
+ }
+
+ if ( !bValid )
+ aNewName = ::rtl::OUString();
+
+ return aNewName;
+}
+//------------------------------------------------------------------------------
+::rtl::OUString quoteName(const ::rtl::OUString& _rQuote, const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString sName = _rName;
+ if(_rQuote.getLength() && _rQuote.toChar() != ' ')
+ sName = _rQuote + _rName + _rQuote;
+ return sName;
+}
+
+
+}
diff --git a/connectivity/source/commontools/ConnectionWrapper.cxx b/connectivity/source/commontools/ConnectionWrapper.cxx
new file mode 100644
index 000000000000..61d3b06cb25d
--- /dev/null
+++ b/connectivity/source/commontools/ConnectionWrapper.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"
+#ifndef _CONNECTIVITY_CONNECTIONWRAPPER_HXX_
+#include "connectivity/ConnectionWrapper.hxx"
+#endif
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/uno3.hxx>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <com/sun/star/reflection/XProxyFactory.hpp>
+#include <rtl/digest.h>
+#include <algorithm>
+
+#include <algorithm>
+
+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::reflection;
+// --------------------------------------------------------------------------------
+OConnectionWrapper::OConnectionWrapper()
+{
+
+}
+// -----------------------------------------------------------------------------
+void OConnectionWrapper::setDelegation(Reference< XAggregation >& _rxProxyConnection,oslInterlockedCount& _rRefCount)
+{
+ OSL_ENSURE(_rxProxyConnection.is(),"OConnectionWrapper: Connection must be valid!");
+ osl_incrementInterlockedCount( &_rRefCount );
+ if (_rxProxyConnection.is())
+ {
+ // transfer the (one and only) real ref to the aggregate to our member
+ m_xProxyConnection = _rxProxyConnection;
+ _rxProxyConnection = NULL;
+ ::comphelper::query_aggregation(m_xProxyConnection,m_xConnection);
+ m_xTypeProvider.set(m_xConnection,UNO_QUERY);
+ m_xUnoTunnel.set(m_xConnection,UNO_QUERY);
+ m_xServiceInfo.set(m_xConnection,UNO_QUERY);
+
+ // set ourself as delegator
+ Reference<XInterface> xIf = static_cast< XUnoTunnel* >( this );
+ m_xProxyConnection->setDelegator( xIf );
+
+ }
+ osl_decrementInterlockedCount( &_rRefCount );
+}
+// -----------------------------------------------------------------------------
+void OConnectionWrapper::setDelegation(const Reference< XConnection >& _xConnection
+ ,const Reference< XMultiServiceFactory>& _xORB
+ ,oslInterlockedCount& _rRefCount)
+{
+ OSL_ENSURE(_xConnection.is(),"OConnectionWrapper: Connection must be valid!");
+ osl_incrementInterlockedCount( &_rRefCount );
+
+ m_xConnection = _xConnection;
+ m_xTypeProvider.set(m_xConnection,UNO_QUERY);
+ m_xUnoTunnel.set(m_xConnection,UNO_QUERY);
+ m_xServiceInfo.set(m_xConnection,UNO_QUERY);
+
+ Reference< XProxyFactory > xProxyFactory(_xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.ProxyFactory"))),UNO_QUERY);
+ Reference< XAggregation > xConProxy = xProxyFactory->createProxy(_xConnection);
+ if (xConProxy.is())
+ {
+ // transfer the (one and only) real ref to the aggregate to our member
+ m_xProxyConnection = xConProxy;
+
+ // set ourself as delegator
+ Reference<XInterface> xIf = static_cast< XUnoTunnel* >( this );
+ m_xProxyConnection->setDelegator( xIf );
+
+ }
+ osl_decrementInterlockedCount( &_rRefCount );
+}
+// -----------------------------------------------------------------------------
+void OConnectionWrapper::disposing()
+{
+m_xConnection.clear();
+}
+//-----------------------------------------------------------------------------
+OConnectionWrapper::~OConnectionWrapper()
+{
+ if (m_xProxyConnection.is())
+ m_xProxyConnection->setDelegator(NULL);
+}
+
+// XServiceInfo
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConnectionWrapper::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdbc.drivers.OConnectionWrapper" ) );
+}
+
+// --------------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OConnectionWrapper::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ // first collect the services which are supported by our aggregate
+ Sequence< ::rtl::OUString > aSupported;
+ if ( m_xServiceInfo.is() )
+ aSupported = m_xServiceInfo->getSupportedServiceNames();
+
+ // append our own service, if necessary
+ ::rtl::OUString sConnectionService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdbc.Connection" ) );
+ if ( 0 == ::comphelper::findValue( aSupported, sConnectionService, sal_True ).getLength() )
+ {
+ sal_Int32 nLen = aSupported.getLength();
+ aSupported.realloc( nLen + 1 );
+ aSupported[ nLen ] = sConnectionService;
+ }
+
+ // outta here
+ return aSupported;
+}
+
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnectionWrapper::supportsService( const ::rtl::OUString& _rServiceName ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::comphelper::findValue( getSupportedServiceNames(), _rServiceName, sal_True ).getLength() != 0;
+}
+
+// --------------------------------------------------------------------------------
+Any SAL_CALL OConnectionWrapper::queryInterface( const Type& _rType ) throw (RuntimeException)
+{
+ Any aReturn = OConnection_BASE::queryInterface(_rType);
+ return aReturn.hasValue() ? aReturn : (m_xProxyConnection.is() ? m_xProxyConnection->queryAggregation(_rType) : aReturn);
+}
+// --------------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OConnectionWrapper::getTypes( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return ::comphelper::concatSequences(
+ OConnection_BASE::getTypes(),
+ m_xTypeProvider->getTypes()
+ );
+}
+// -----------------------------------------------------------------------------
+// com::sun::star::lang::XUnoTunnel
+sal_Int64 SAL_CALL OConnectionWrapper::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException)
+{
+ if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ return reinterpret_cast< sal_Int64 >( this );
+
+ if(m_xUnoTunnel.is())
+ return m_xUnoTunnel->getSomething(rId);
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+Sequence< sal_Int8 > OConnectionWrapper::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();
+}
+// -----------------------------------------------------------------------------
+namespace
+{
+ class TPropertyValueLessFunctor : public ::std::binary_function< ::com::sun::star::beans::PropertyValue,::com::sun::star::beans::PropertyValue,bool>
+ {
+ public:
+ TPropertyValueLessFunctor()
+ {}
+ bool operator() (const ::com::sun::star::beans::PropertyValue& lhs, const ::com::sun::star::beans::PropertyValue& rhs) const
+ {
+ return !!(lhs.Name.equalsIgnoreAsciiCase( rhs.Name ));
+ }
+ };
+
+}
+
+// -----------------------------------------------------------------------------
+// creates a unique id out of the url and sequence of properties
+void OConnectionWrapper::createUniqueId( const ::rtl::OUString& _rURL
+ ,Sequence< PropertyValue >& _rInfo
+ ,sal_uInt8* _pBuffer
+ ,const ::rtl::OUString& _rUserName
+ ,const ::rtl::OUString& _rPassword)
+{
+ // first we create the digest we want to have
+ rtlDigest aDigest = rtl_digest_create( rtl_Digest_AlgorithmSHA1 );
+ rtlDigestError aError = rtl_digest_update(aDigest,_rURL.getStr(),_rURL.getLength()*sizeof(sal_Unicode));
+ if ( _rUserName.getLength() )
+ aError = rtl_digest_update(aDigest,_rUserName.getStr(),_rUserName.getLength()*sizeof(sal_Unicode));
+ if ( _rPassword.getLength() )
+ aError = rtl_digest_update(aDigest,_rPassword.getStr(),_rPassword.getLength()*sizeof(sal_Unicode));
+ // now we need to sort the properties
+ PropertyValue* pBegin = _rInfo.getArray();
+ PropertyValue* pEnd = pBegin + _rInfo.getLength();
+ ::std::sort(pBegin,pEnd,TPropertyValueLessFunctor());
+
+ pBegin = _rInfo.getArray();
+ pEnd = pBegin + _rInfo.getLength();
+ for (; pBegin != pEnd; ++pBegin)
+ {
+ // we only include strings an integer values
+ ::rtl::OUString sValue;
+ if ( pBegin->Value >>= sValue )
+ ;
+ else
+ {
+ sal_Int32 nValue = 0;
+ if ( pBegin->Value >>= nValue )
+ sValue = ::rtl::OUString::valueOf(nValue);
+ else
+ {
+ Sequence< ::rtl::OUString> aSeq;
+ if ( pBegin->Value >>= aSeq )
+ {
+ const ::rtl::OUString* pSBegin = aSeq.getConstArray();
+ const ::rtl::OUString* pSEnd = pSBegin + aSeq.getLength();
+ for(;pSBegin != pSEnd;++pSBegin)
+ aError = rtl_digest_update(aDigest,pSBegin->getStr(),pSBegin->getLength()*sizeof(sal_Unicode));
+ }
+ }
+ }
+ if ( sValue.getLength() > 0 )
+ {
+ // we don't have to convert this into UTF8 because we don't store on a file system
+ aError = rtl_digest_update(aDigest,sValue.getStr(),sValue.getLength()*sizeof(sal_Unicode));
+ }
+ }
+
+ aError = rtl_digest_get(aDigest,_pBuffer,RTL_DIGEST_LENGTH_SHA1);
+ // we have to destroy the digest
+ rtl_digest_destroy(aDigest);
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/commontools/DateConversion.cxx b/connectivity/source/commontools/DateConversion.cxx
new file mode 100644
index 000000000000..9f5be37f208f
--- /dev/null
+++ b/connectivity/source/commontools/DateConversion.cxx
@@ -0,0 +1,520 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/dbconversion.hxx"
+#include <connectivity/dbtools.hxx>
+#include <com/sun/star/script/XTypeConverter.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <com/sun/star/sdb/XColumnUpdate.hpp>
+#include <com/sun/star/sdb/XColumn.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <comphelper/extract.hxx>
+#include "TConnection.hxx"
+#include "diagnose_ex.h"
+#include <comphelper/numbers.hxx>
+#include <rtl/ustrbuf.hxx>
+
+
+using namespace ::connectivity;
+using namespace ::comphelper;
+using namespace ::com::sun::star::script;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::dbtools;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::beans;
+// -----------------------------------------------------------------------------
+::rtl::OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal, sal_Bool bQuote,
+ const Reference< XTypeConverter >& _rxTypeConverter)
+{
+ ::rtl::OUStringBuffer aRet;
+ if (_rVal.hasValue())
+ {
+ try
+ {
+ switch (eType)
+ {
+ case DataType::INTEGER:
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_BOOLEAN)
+ {
+ if (::cppu::any2bool(_rVal))
+ aRet.appendAscii("1");
+ else
+ aRet.appendAscii("0");
+ }
+ else
+ {
+ ::rtl::OUString sTemp;
+ _rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= sTemp;
+ aRet.append(sTemp);
+ }
+ break;
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ if (bQuote)
+ aRet.appendAscii("'");
+ {
+ ::rtl::OUString aTemp;
+ _rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= aTemp;
+ sal_Int32 nIndex = (sal_Int32)-1;
+ const ::rtl::OUString sQuot(RTL_CONSTASCII_USTRINGPARAM("\'"));
+ const ::rtl::OUString sQuotToReplace(RTL_CONSTASCII_USTRINGPARAM("\'\'"));
+ do
+ {
+ nIndex += 2;
+ nIndex = aTemp.indexOf(sQuot,nIndex);
+ if(nIndex != -1)
+ aTemp = aTemp.replaceAt(nIndex,sQuot.getLength(),sQuotToReplace);
+ } while (nIndex != -1);
+
+ aRet.append(aTemp);
+ }
+ if (bQuote)
+ aRet.appendAscii("'");
+ break;
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::BIGINT:
+ default:
+ {
+ ::rtl::OUString sTemp;
+ _rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= sTemp;
+ aRet.append(sTemp);
+ }
+ break;
+ case DataType::TIMESTAMP:
+ {
+ DateTime aDateTime;
+ bool bOk = false;
+ if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_DOUBLE)
+ {
+ double nValue = 0.0;
+ _rVal >>= nValue;
+ aDateTime = DBTypeConversion::toDateTime(nValue);
+ bOk = true;
+ }
+ else if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_STRING)
+ {
+ ::rtl::OUString sValue;
+ _rVal >>= sValue;
+ aDateTime = DBTypeConversion::toDateTime(sValue);
+ bOk = true;
+ }
+ else
+ bOk = _rVal >>= aDateTime;
+
+ OSL_VERIFY_RES( bOk, "DBTypeConversion::toSQLString: _rVal is not datetime!");
+ // check if this is really a timestamp or only a date
+ if ( bOk )
+ {
+ if (bQuote)
+ aRet.appendAscii("{TS '");
+ aRet.append(DBTypeConversion::toDateTimeString(aDateTime));
+ if (bQuote)
+ aRet.appendAscii("'}");
+ break;
+ }
+ break;
+ }
+ case DataType::DATE:
+ {
+ Date aDate;
+ bool bOk = false;
+ if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_DOUBLE)
+ {
+ double nValue = 0.0;
+ _rVal >>= nValue;
+ aDate = DBTypeConversion::toDate(nValue);
+ bOk = true;
+ }
+ else if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_STRING)
+ {
+ ::rtl::OUString sValue;
+ _rVal >>= sValue;
+ aDate = DBTypeConversion::toDate(sValue);
+ bOk = true;
+ }
+ else
+ bOk = _rVal >>= aDate;
+ OSL_VERIFY_RES( bOk, "DBTypeConversion::toSQLString: _rVal is not date!");
+ if (bQuote)
+ aRet.appendAscii("{D '");
+ aRet.append(DBTypeConversion::toDateString(aDate));
+ if (bQuote)
+ aRet.appendAscii("'}");
+ } break;
+ case DataType::TIME:
+ {
+ Time aTime;
+ bool bOk = false;
+ if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_DOUBLE)
+ {
+ double nValue = 0.0;
+ _rVal >>= nValue;
+ aTime = DBTypeConversion::toTime(nValue);
+ bOk = true;
+ }
+ else if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_STRING)
+ {
+ ::rtl::OUString sValue;
+ _rVal >>= sValue;
+ aTime = DBTypeConversion::toTime(sValue);
+ bOk = true;
+ }
+ else
+ bOk = _rVal >>= aTime;
+ OSL_VERIFY_RES( bOk,"DBTypeConversion::toSQLString: _rVal is not time!");
+ if (bQuote)
+ aRet.appendAscii("{T '");
+ aRet.append(DBTypeConversion::toTimeString(aTime));
+ if (bQuote)
+ aRet.appendAscii("'}");
+ } break;
+ }
+ }
+ catch ( const Exception& )
+ {
+ OSL_ENSURE(0,"TypeConversion Error");
+ }
+ }
+ else
+ aRet.appendAscii(" NULL ");
+ return aRet.makeStringAndClear();
+}
+// -----------------------------------------------------------------------------
+Date DBTypeConversion::getNULLDate(const Reference< XNumberFormatsSupplier > &xSupplier)
+{
+ OSL_ENSURE(xSupplier.is(), "getNULLDate : the formatter doesn't implement a supplier !");
+ if (xSupplier.is())
+ {
+ try
+ {
+ // get the null date
+ Date aDate;
+ xSupplier->getNumberFormatSettings()->getPropertyValue(::rtl::OUString::createFromAscii("NullDate")) >>= aDate;
+ return aDate;
+ }
+ catch ( const Exception& )
+ {
+ }
+ }
+
+ return getStandardDate();
+}
+// -----------------------------------------------------------------------------
+void DBTypeConversion::setValue(const Reference<XColumnUpdate>& xVariant,
+ const Reference<XNumberFormatter>& xFormatter,
+ const Date& rNullDate,
+ const ::rtl::OUString& rString,
+ sal_Int32 nKey,
+ sal_Int16 nFieldType,
+ sal_Int16 nKeyType) throw(::com::sun::star::lang::IllegalArgumentException)
+{
+ double fValue = 0;
+ if (rString.getLength())
+ {
+ // Muss der String formatiert werden?
+ sal_Int16 nTypeClass = nKeyType & ~NumberFormat::DEFINED;
+ sal_Bool bTextFormat = nTypeClass == NumberFormat::TEXT;
+ sal_Int32 nKeyToUse = bTextFormat ? 0 : nKey;
+ sal_Int16 nRealUsedTypeClass = nTypeClass;
+ // bei einem Text-Format muessen wir dem Formatter etwas mehr Freiheiten einraeumen, sonst
+ // wirft convertStringToNumber eine NotNumericException
+ try
+ {
+ fValue = xFormatter->convertStringToNumber(nKeyToUse, rString);
+ sal_Int32 nRealUsedKey = xFormatter->detectNumberFormat(0, rString);
+ if (nRealUsedKey != nKeyToUse)
+ nRealUsedTypeClass = getNumberFormatType(xFormatter, nRealUsedKey) & ~NumberFormat::DEFINED;
+
+ // und noch eine Sonderbehandlung, diesmal fuer Prozent-Formate
+ if ((NumberFormat::NUMBER == nRealUsedTypeClass) && (NumberFormat::PERCENT == nTypeClass))
+ { // die Formatierung soll eigentlich als Prozent erfolgen, aber der String stellt nur eine
+ // einfache Nummer dar -> anpassen
+ ::rtl::OUString sExpanded(rString);
+ static ::rtl::OUString s_sPercentSymbol = ::rtl::OUString::createFromAscii("%");
+ // need a method to add a sal_Unicode to a string, 'til then we use a static string
+ sExpanded += s_sPercentSymbol;
+ fValue = xFormatter->convertStringToNumber(nKeyToUse, sExpanded);
+ }
+
+ switch (nRealUsedTypeClass)
+ {
+ case NumberFormat::DATE:
+ case NumberFormat::DATETIME:
+ case NumberFormat::TIME:
+ DBTypeConversion::setValue(xVariant,rNullDate,fValue,nRealUsedTypeClass);
+ // xVariant->updateDouble(toStandardDbDate(rNullDate, fValue));
+ break;
+ case NumberFormat::CURRENCY:
+ case NumberFormat::NUMBER:
+ case NumberFormat::SCIENTIFIC:
+ case NumberFormat::FRACTION:
+ case NumberFormat::PERCENT:
+ xVariant->updateDouble(fValue);
+ break;
+ default:
+ xVariant->updateString(rString);
+ }
+ }
+ catch(const Exception& )
+ {
+ xVariant->updateString(rString);
+ }
+ }
+ else
+ {
+ switch (nFieldType)
+ {
+ case ::com::sun::star::sdbc::DataType::CHAR:
+ case ::com::sun::star::sdbc::DataType::VARCHAR:
+ case ::com::sun::star::sdbc::DataType::LONGVARCHAR:
+ xVariant->updateString(rString);
+ break;
+ default:
+ xVariant->updateNull();
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void DBTypeConversion::setValue(const Reference<XColumnUpdate>& xVariant,
+ const Date& rNullDate,
+ const double& rValue,
+ sal_Int16 nKeyType) throw(::com::sun::star::lang::IllegalArgumentException)
+{
+ switch (nKeyType & ~NumberFormat::DEFINED)
+ {
+ case NumberFormat::DATE:
+ xVariant->updateDate(toDate( rValue, rNullDate));
+ break;
+ case NumberFormat::DATETIME:
+ xVariant->updateTimestamp(toDateTime(rValue,rNullDate));
+ break;
+ case NumberFormat::TIME:
+ xVariant->updateTime(toTime(rValue));
+ break;
+ default:
+ {
+ double nValue = rValue;
+// Reference<XPropertySet> xProp(xVariant,UNO_QUERY);
+// if ( xProp.is()
+// && xProp->getPropertySetInfo()->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISSIGNED))
+// && !::comphelper::getBOOL(xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISSIGNED))) )
+// {
+// switch (::comphelper::getINT32(xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))))
+// {
+// case DataType::TINYINT:
+// nValue = static_cast<sal_uInt8>(rValue);
+// break;
+// case DataType::SMALLINT:
+// nValue = static_cast<sal_uInt16>(rValue);
+// break;
+// case DataType::INTEGER:
+// nValue = static_cast<sal_uInt32>(rValue);
+// break;
+// case DataType::BIGINT:
+// nValue = static_cast<sal_uInt64>(rValue);
+// break;
+// }
+// }
+ xVariant->updateDouble(nValue);
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+double DBTypeConversion::getValue(const Reference<XColumn>& xVariant,
+ const Date& rNullDate,
+ sal_Int16 nKeyType)
+{
+ try
+ {
+ switch (nKeyType & ~NumberFormat::DEFINED)
+ {
+ case NumberFormat::DATE:
+ return toDouble( xVariant->getDate(), rNullDate);
+ case NumberFormat::DATETIME:
+ return toDouble(xVariant->getTimestamp(),rNullDate);
+ case NumberFormat::TIME:
+ return toDouble(xVariant->getTime());
+ default:
+ {
+ Reference<XPropertySet> xProp(xVariant,UNO_QUERY);
+ if ( xProp.is()
+ && xProp->getPropertySetInfo()->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISSIGNED))
+ && !::comphelper::getBOOL(xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISSIGNED))) )
+ {
+ switch (::comphelper::getINT32(xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))))
+ {
+ case DataType::TINYINT:
+ return static_cast<double>(static_cast<sal_uInt8>(xVariant->getByte()));
+ case DataType::SMALLINT:
+ return static_cast<double>(static_cast<sal_uInt16>(xVariant->getShort()));
+ case DataType::INTEGER:
+ return static_cast<double>(static_cast<sal_uInt32>(xVariant->getInt()));
+ case DataType::BIGINT:
+ return static_cast<double>(static_cast<sal_uInt64>(xVariant->getLong()));
+ }
+ }
+
+ return xVariant->getDouble();
+ }
+ }
+ }
+ catch(const Exception& )
+ {
+ return 0.0;
+ }
+}
+//------------------------------------------------------------------------------
+::rtl::OUString DBTypeConversion::getValue(const Reference< XPropertySet>& _xColumn,
+ const Reference<XNumberFormatter>& _xFormatter,
+ const ::com::sun::star::lang::Locale& _rLocale,
+ const Date& _rNullDate)
+{
+ OSL_ENSURE(_xColumn.is() && _xFormatter.is(), "DBTypeConversion::getValue: invalid arg !");
+ if (!_xColumn.is() || !_xFormatter.is())
+ return ::rtl::OUString();
+
+ sal_Int32 nKey(0);
+ try
+ {
+ _xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FORMATKEY)) >>= nKey;
+ }
+ catch (const Exception& )
+ {
+ OSL_ENSURE(false, "DBTypeConversion::getValue: caught an exception while asking for the format key!");
+ }
+
+ if (!nKey)
+ {
+ Reference<XNumberFormats> xFormats( _xFormatter->getNumberFormatsSupplier()->getNumberFormats() );
+ Reference<XNumberFormatTypes> xTypeList(_xFormatter->getNumberFormatsSupplier()->getNumberFormats(), UNO_QUERY);
+
+ nKey = ::dbtools::getDefaultNumberFormat(_xColumn,
+ Reference< XNumberFormatTypes > (xFormats, UNO_QUERY),
+ _rLocale);
+
+ }
+
+ sal_Int16 nKeyType = getNumberFormatType(_xFormatter, nKey) & ~NumberFormat::DEFINED;
+
+ return DBTypeConversion::getValue(Reference< XColumn > (_xColumn, UNO_QUERY), _xFormatter, _rNullDate, nKey, nKeyType);
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString DBTypeConversion::getValue(const Reference<XColumn>& xVariant,
+ const Reference<XNumberFormatter>& xFormatter,
+ const Date& rNullDate,
+ sal_Int32 nKey,
+ sal_Int16 nKeyType)
+{
+ ::rtl::OUString aString;
+ if (xVariant.is())
+ {
+ try
+ {
+ switch (nKeyType & ~NumberFormat::DEFINED)
+ {
+ case NumberFormat::DATE:
+ case NumberFormat::DATETIME:
+ {
+ // get a value which represents the given date, relative to the given null date
+ double fValue = getValue(xVariant, rNullDate, nKeyType);
+ if ( !xVariant->wasNull() )
+ {
+ // get the null date of the formatter
+ Date aFormatterNullDate( rNullDate );
+ try
+ {
+ Reference< XPropertySet > xFormatterSettings;
+ Reference< XNumberFormatsSupplier > xSupplier( xFormatter->getNumberFormatsSupplier( ) );
+ if ( xSupplier.is() )
+ xFormatterSettings = xSupplier->getNumberFormatSettings();
+ if ( xFormatterSettings.is() )
+ xFormatterSettings->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NullDate" ) ) ) >>= aFormatterNullDate;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "DBTypeConversion::getValue: caught an exception while retrieving the formatter's NullDate!" );
+ }
+ // get a value which represents the given date, relative to the null date of the formatter
+ fValue -= toDays( rNullDate, aFormatterNullDate );
+ // format this value
+ aString = xFormatter->convertNumberToString( nKey, fValue );
+ }
+ }
+ break;
+ case NumberFormat::TIME:
+ case NumberFormat::NUMBER:
+ case NumberFormat::SCIENTIFIC:
+ case NumberFormat::FRACTION:
+ case NumberFormat::PERCENT:
+ {
+ double fValue = xVariant->getDouble();
+ if (!xVariant->wasNull())
+ aString = xFormatter->convertNumberToString(nKey, fValue);
+ } break;
+ case NumberFormat::CURRENCY:
+ {
+ double fValue = xVariant->getDouble();
+ if (!xVariant->wasNull())
+ aString = xFormatter->getInputString(nKey, fValue);
+ } break;
+ case NumberFormat::TEXT:
+ aString = xFormatter->formatString(nKey, xVariant->getString());
+ break;
+ default:
+ aString = xVariant->getString();
+ }
+ }
+ catch(const Exception& )
+ {
+ aString = xVariant->getString();
+ }
+ }
+ return aString;
+}
+//------------------------------------------------------------------
diff --git a/connectivity/source/commontools/DriversConfig.cxx b/connectivity/source/commontools/DriversConfig.cxx
new file mode 100755
index 000000000000..48c2736cd05a
--- /dev/null
+++ b/connectivity/source/commontools/DriversConfig.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.
+ *
+ ************************************************************************/
+#include "connectivity/DriversConfig.hxx"
+#include <tools/wldcrd.hxx>
+
+using namespace connectivity;
+using namespace utl;
+using namespace ::com::sun::star;
+
+namespace
+{
+ void lcl_convert(const uno::Sequence< ::rtl::OUString >& _aSource,uno::Any& _rDest)
+ {
+ uno::Sequence<uno::Any> aRet(_aSource.getLength());
+ uno::Any* pAny = aRet.getArray();
+ const ::rtl::OUString* pIter = _aSource.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + _aSource.getLength();
+ for (;pIter != pEnd ; ++pIter,++pAny)
+ {
+ *pAny <<= *pIter;
+ }
+ _rDest <<= aRet;
+ }
+ void lcl_fillValues(const ::utl::OConfigurationNode& _aURLPatternNode,const ::rtl::OUString& _sNode,::comphelper::NamedValueCollection& _rValues)
+ {
+ const ::utl::OConfigurationNode aPropertiesNode = _aURLPatternNode.openNode(_sNode);
+ if ( aPropertiesNode.isValid() )
+ {
+ uno::Sequence< ::rtl::OUString > aStringSeq;
+ static const ::rtl::OUString s_sValue(RTL_CONSTASCII_USTRINGPARAM("/Value"));
+ const uno::Sequence< ::rtl::OUString > aProperties = aPropertiesNode.getNodeNames();
+ const ::rtl::OUString* pPropertiesIter = aProperties.getConstArray();
+ const ::rtl::OUString* pPropertiesEnd = pPropertiesIter + aProperties.getLength();
+ for (;pPropertiesIter != pPropertiesEnd ; ++pPropertiesIter)
+ {
+ uno::Any aValue = aPropertiesNode.getNodeValue(*pPropertiesIter + s_sValue);
+ if ( aValue >>= aStringSeq )
+ {
+ lcl_convert(aStringSeq,aValue);
+ }
+ _rValues.put(*pPropertiesIter,aValue);
+ } // for (;pPropertiesIter != pPropertiesEnd ; ++pPropertiesIter,++pNamedIter)
+ } // if ( aPropertiesNode.isValid() )
+ }
+ void lcl_readURLPatternNode(const ::utl::OConfigurationTreeRoot& _aInstalled,const ::rtl::OUString& _sEntry,TInstalledDriver& _rInstalledDriver)
+ {
+ const ::utl::OConfigurationNode aURLPatternNode = _aInstalled.openNode(_sEntry);
+ if ( aURLPatternNode.isValid() )
+ {
+ static const ::rtl::OUString s_sParentURLPattern(RTL_CONSTASCII_USTRINGPARAM("ParentURLPattern"));
+ static const ::rtl::OUString s_sDriver(RTL_CONSTASCII_USTRINGPARAM("Driver"));
+ static const ::rtl::OUString s_sDriverTypeDisplayName(RTL_CONSTASCII_USTRINGPARAM("DriverTypeDisplayName"));
+ static const ::rtl::OUString s_sProperties(RTL_CONSTASCII_USTRINGPARAM("Properties"));
+ static const ::rtl::OUString s_sFeatures(RTL_CONSTASCII_USTRINGPARAM("Features"));
+ static const ::rtl::OUString s_sMetaData(RTL_CONSTASCII_USTRINGPARAM("MetaData"));
+ ::rtl::OUString sParentURLPattern;
+ aURLPatternNode.getNodeValue(s_sParentURLPattern) >>= sParentURLPattern;
+ if ( sParentURLPattern.getLength() )
+ lcl_readURLPatternNode(_aInstalled,sParentURLPattern,_rInstalledDriver);
+
+ ::rtl::OUString sDriverFactory;
+ aURLPatternNode.getNodeValue(s_sDriver) >>= sDriverFactory;
+ if ( sDriverFactory.getLength() )
+ _rInstalledDriver.sDriverFactory = sDriverFactory;
+
+ ::rtl::OUString sDriverTypeDisplayName;
+ aURLPatternNode.getNodeValue(s_sDriverTypeDisplayName) >>= sDriverTypeDisplayName;
+ OSL_ENSURE(sDriverTypeDisplayName.getLength(),"No valid DriverTypeDisplayName property!");
+ if ( sDriverTypeDisplayName.getLength() )
+ _rInstalledDriver.sDriverTypeDisplayName = sDriverTypeDisplayName;
+
+ lcl_fillValues(aURLPatternNode,s_sProperties,_rInstalledDriver.aProperties);
+ lcl_fillValues(aURLPatternNode,s_sFeatures,_rInstalledDriver.aFeatures);
+ lcl_fillValues(aURLPatternNode,s_sMetaData,_rInstalledDriver.aMetaData);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+DriversConfigImpl::DriversConfigImpl()
+{
+}
+// -----------------------------------------------------------------------------
+void DriversConfigImpl::Load(const uno::Reference< lang::XMultiServiceFactory >& _rxORB) const
+{
+ if ( m_aDrivers.empty() )
+ {
+ if ( !m_aInstalled.isValid() )
+ {
+ static const ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.DataAccess.Drivers/Installed")); ///Installed
+ m_aInstalled = ::utl::OConfigurationTreeRoot::createWithServiceFactory(_rxORB, s_sNodeName, -1, ::utl::OConfigurationTreeRoot::CM_READONLY);
+ }
+
+ if ( m_aInstalled.isValid() )
+ {
+ const uno::Sequence< ::rtl::OUString > aURLPatterns = m_aInstalled.getNodeNames();
+ const ::rtl::OUString* pPatternIter = aURLPatterns.getConstArray();
+ const ::rtl::OUString* pPatternEnd = pPatternIter + aURLPatterns.getLength();
+ for (;pPatternIter != pPatternEnd ; ++pPatternIter)
+ {
+ TInstalledDriver aInstalledDriver;
+ lcl_readURLPatternNode(m_aInstalled,*pPatternIter,aInstalledDriver);
+ if ( aInstalledDriver.sDriverFactory.getLength() )
+ m_aDrivers.insert(TInstalledDrivers::value_type(*pPatternIter,aInstalledDriver));
+ }
+ } // if ( m_aInstalled.isValid() )
+ }
+}
+// -----------------------------------------------------------------------------
+DriversConfig::DriversConfig(const uno::Reference< lang::XMultiServiceFactory >& _rxORB)
+:m_xORB(_rxORB)
+{
+}
+
+// -----------------------------------------------------------------------------
+DriversConfig::~DriversConfig()
+{
+}
+
+// -----------------------------------------------------------------------------
+DriversConfig::DriversConfig( const DriversConfig& _rhs )
+{
+ *this = _rhs;
+}
+
+// -----------------------------------------------------------------------------
+DriversConfig& DriversConfig::operator=( const DriversConfig& _rhs )
+{
+ if ( this != &_rhs )
+ {
+ m_aNode = _rhs.m_aNode;
+ }
+ return *this;
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString DriversConfig::getDriverFactoryName(const ::rtl::OUString& _sURL) const
+{
+ const TInstalledDrivers& rDrivers = m_aNode->getInstalledDrivers(m_xORB);
+ ::rtl::OUString sRet;
+ ::rtl::OUString sOldPattern;
+ TInstalledDrivers::const_iterator aIter = rDrivers.begin();
+ TInstalledDrivers::const_iterator aEnd = rDrivers.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ WildCard aWildCard(aIter->first);
+ if ( sOldPattern.getLength() < aIter->first.getLength() && aWildCard.Matches(_sURL) )
+ {
+ sRet = aIter->second.sDriverFactory;
+ sOldPattern = aIter->first;
+ }
+ }
+
+ return sRet;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString DriversConfig::getDriverTypeDisplayName(const ::rtl::OUString& _sURL) const
+{
+ const TInstalledDrivers& rDrivers = m_aNode->getInstalledDrivers(m_xORB);
+ ::rtl::OUString sRet;
+ ::rtl::OUString sOldPattern;
+ TInstalledDrivers::const_iterator aIter = rDrivers.begin();
+ TInstalledDrivers::const_iterator aEnd = rDrivers.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ WildCard aWildCard(aIter->first);
+ if ( sOldPattern.getLength() < aIter->first.getLength() && aWildCard.Matches(_sURL) )
+ {
+ sRet = aIter->second.sDriverTypeDisplayName;
+ sOldPattern = aIter->first;
+ }
+ }
+
+ return sRet;
+}
+// -----------------------------------------------------------------------------
+const ::comphelper::NamedValueCollection& DriversConfig::getProperties(const ::rtl::OUString& _sURL) const
+{
+ return impl_get(_sURL,1);
+}
+// -----------------------------------------------------------------------------
+const ::comphelper::NamedValueCollection& DriversConfig::getFeatures(const ::rtl::OUString& _sURL) const
+{
+ return impl_get(_sURL,0);
+}
+// -----------------------------------------------------------------------------
+const ::comphelper::NamedValueCollection& DriversConfig::getMetaData(const ::rtl::OUString& _sURL) const
+{
+ return impl_get(_sURL,2);
+}
+// -----------------------------------------------------------------------------
+const ::comphelper::NamedValueCollection& DriversConfig::impl_get(const ::rtl::OUString& _sURL,sal_Int32 _nProps) const
+{
+ const TInstalledDrivers& rDrivers = m_aNode->getInstalledDrivers(m_xORB);
+ const ::comphelper::NamedValueCollection* pRet = NULL;
+ ::rtl::OUString sOldPattern;
+ TInstalledDrivers::const_iterator aIter = rDrivers.begin();
+ TInstalledDrivers::const_iterator aEnd = rDrivers.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ WildCard aWildCard(aIter->first);
+ if ( sOldPattern.getLength() < aIter->first.getLength() && aWildCard.Matches(_sURL) )
+ {
+ switch(_nProps)
+ {
+ case 0:
+ pRet = &aIter->second.aFeatures;
+ break;
+ case 1:
+ pRet = &aIter->second.aProperties;
+ break;
+ case 2:
+ pRet = &aIter->second.aMetaData;
+ break;
+ }
+ sOldPattern = aIter->first;
+ }
+ } // for(;aIter != aEnd;++aIter)
+ if ( pRet == NULL )
+ {
+ static const ::comphelper::NamedValueCollection s_sEmpty;
+ pRet = &s_sEmpty;
+ }
+ return *pRet;
+}
+// -----------------------------------------------------------------------------
+uno::Sequence< ::rtl::OUString > DriversConfig::getURLs() const
+{
+ const TInstalledDrivers& rDrivers = m_aNode->getInstalledDrivers(m_xORB);
+ uno::Sequence< ::rtl::OUString > aRet(rDrivers.size());
+ ::rtl::OUString* pIter = aRet.getArray();
+ TInstalledDrivers::const_iterator aIter = rDrivers.begin();
+ TInstalledDrivers::const_iterator aEnd = rDrivers.end();
+ for(;aIter != aEnd;++aIter,++pIter)
+ {
+ *pIter = aIter->first;
+ }
+ return aRet;
+}
diff --git a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx
new file mode 100644
index 000000000000..52e76f834ab5
--- /dev/null
+++ b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx
@@ -0,0 +1,913 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "ParameterSubstitution.hxx"
+#include "FDatabaseMetaDataResultSet.hxx"
+#include "FDatabaseMetaDataResultSetMetaData.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnSearch.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 <com/sun/star/beans/PropertyAttribute.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implementationentry.hxx>
+#include "connectivity/dbexception.hxx"
+#include "TConnection.hxx"
+
+using namespace connectivity;
+using namespace dbtools;
+using namespace cppu;
+//------------------------------------------------------------------------------
+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;
+// -------------------------------------------------------------------------
+ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet()
+ :ODatabaseMetaDataResultSet_BASE(m_aMutex)
+ ,::comphelper::OPropertyContainer(ODatabaseMetaDataResultSet_BASE::rBHelper)
+ ,m_aStatement(NULL)
+ ,m_xMetaData(NULL)
+ ,m_bBOF(sal_True)
+ ,m_bEOF(sal_True)
+{
+ construct();
+}
+
+// -------------------------------------------------------------------------
+ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet( MetaDataResultSetType _eType )
+ :ODatabaseMetaDataResultSet_BASE(m_aMutex)
+ ,::comphelper::OPropertyContainer(ODatabaseMetaDataResultSet_BASE::rBHelper)
+ ,m_aStatement(NULL)
+ ,m_xMetaData(NULL)
+ ,m_bBOF(sal_True)
+ ,m_bEOF(sal_True)
+{
+ construct();
+
+ setType(_eType);
+}
+
+// -------------------------------------------------------------------------
+ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
+{
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::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 ODatabaseMetaDataResultSet::setType(MetaDataResultSetType _eType)
+{
+ switch( _eType )
+ {
+ case eCatalogs: setCatalogsMap(); break;
+ case eSchemas: setSchemasMap(); break;
+ case eColumnPrivileges: setColumnPrivilegesMap(); break;
+ case eColumns: setColumnsMap(); break;
+ case eTables: setTablesMap(); break;
+ case eTableTypes: setTableTypes(); break;
+ case eProcedureColumns: setProcedureColumnsMap(); break;
+ case eProcedures: setProceduresMap(); break;
+ case eExportedKeys: setExportedKeysMap(); break;
+ case eImportedKeys: setImportedKeysMap(); break;
+ case ePrimaryKeys: setPrimaryKeysMap(); break;
+ case eIndexInfo: setIndexInfoMap(); break;
+ case eTablePrivileges: setTablePrivilegesMap(); break;
+ case eCrossReference: setCrossReferenceMap(); break;
+ case eTypeInfo: setTypeInfoMap(); break;
+ case eBestRowIdentifier: setBestRowIdentifierMap(); break;
+ case eVersionColumns: setVersionColumnsMap(); break;
+ default:
+ OSL_ENSURE(0,"Wrong type!");
+ }
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::disposing(void)
+{
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ m_aStatement = NULL;
+m_xMetaData.clear();
+ m_aRowsIter = m_aRows.end();
+ m_aRows.clear();
+ m_aRowsIter = m_aRows.end();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::acquire() throw()
+{
+ ODatabaseMetaDataResultSet_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::release() throw()
+{
+ ODatabaseMetaDataResultSet_BASE::release();
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OPropertySetHelper::queryInterface(rType);
+ return aRet.hasValue() ? aRet : ODatabaseMetaDataResultSet_BASE::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL ODatabaseMetaDataResultSet::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 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes());
+}
+// -----------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setRows(const ORows& _rRows)
+{
+ m_aRows = _rRows;
+ m_bBOF = sal_True;
+ m_bEOF = m_aRows.empty();
+}
+// -------------------------------------------------------------------------
+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;
+}
+// -----------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException)
+{
+ if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1)
+ ::dbtools::throwInvalidIndexException(*this);
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+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)
+{
+ return getValue(columnIndex);
+}
+
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow( ) throw(SQLException, RuntimeException)
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
+
+
+ if(!m_xMetaData.is())
+ m_xMetaData = new ODatabaseMetaDataResultSetMetaData();
+
+ return m_xMetaData;
+}
+// -------------------------------------------------------------------------
+Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex).makeAny();
+}
+// -------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+
+// -------------------------------------------------------------------------
+
+
+::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)
+{
+ return m_bEOF;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst( ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionSequenceException(*this);
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast( ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionSequenceException(*this);
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst( ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionSequenceException(*this);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::afterLast( ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionSequenceException(*this);
+}
+// -------------------------------------------------------------------------
+
+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)
+{
+ ::dbtools::throwFunctionSequenceException(*this);
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last( ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionSequenceException(*this);
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 /*row*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionSequenceException(*this);
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 /*row*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionSequenceException(*this);
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous( ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionSequenceException(*this);
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement( ) throw(SQLException, RuntimeException)
+{
+ return m_aStatement.get();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted( ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionSequenceException(*this);
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted( ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionSequenceException(*this);
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated( ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionSequenceException(*this);
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
+{
+ return m_bBOF;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
+
+ if ( m_bBOF )
+ {
+ m_aRowsIter = m_aRows.begin();
+ m_bBOF = sal_False;
+ }
+ else
+ {
+ if ( m_bEOF )
+ throwFunctionSequenceException( *this );
+ else
+ if ( m_aRowsIter != m_aRows.end() )
+ ++m_aRowsIter;
+ }
+
+ bool bSuccess = m_aRowsIter != m_aRows.end();
+ if ( !bSuccess )
+ {
+ m_bEOF = sal_True;
+ m_bBOF = m_aRows.empty();
+ }
+ return bSuccess;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
+
+
+ if(m_aRowsIter == m_aRows.end() || !(*m_aRowsIter)[m_nColPos].isValid())
+ return sal_True;
+
+ return (*m_aRowsIter)[m_nColPos]->getValue().isNull();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::refreshRow( ) throw(SQLException, RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL ODatabaseMetaDataResultSet::cancel( ) throw(RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL ODatabaseMetaDataResultSet::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ return Any();
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* ODatabaseMetaDataResultSet::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & ODatabaseMetaDataResultSet::getInfoHelper()
+{
+ return *const_cast<ODatabaseMetaDataResultSet*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setProceduresMap()
+{
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
+ pMetaData->setProceduresMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setCatalogsMap()
+{
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
+ pMetaData->setCatalogsMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setSchemasMap()
+{
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
+ pMetaData->setSchemasMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setColumnPrivilegesMap()
+{
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
+ pMetaData->setColumnPrivilegesMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setColumnsMap()
+{
+
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
+ pMetaData->setColumnsMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setTablesMap()
+{
+
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
+ pMetaData->setTablesMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setProcedureColumnsMap()
+{
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
+ pMetaData->setProcedureColumnsMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setPrimaryKeysMap()
+{
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
+ pMetaData->setPrimaryKeysMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setIndexInfoMap()
+{
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
+ pMetaData->setIndexInfoMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setTablePrivilegesMap()
+{
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
+ pMetaData->setTablePrivilegesMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setCrossReferenceMap()
+{
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
+ pMetaData->setCrossReferenceMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setVersionColumnsMap()
+{
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
+ pMetaData->setVersionColumnsMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setBestRowIdentifierMap()
+{
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
+ pMetaData->setBestRowIdentifierMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setTypeInfoMap()
+{
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
+ pMetaData->setTypeInfoMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setTableTypes()
+{
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
+ pMetaData->setTableTypes();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setExportedKeysMap()
+{
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
+ pMetaData->setExportedKeysMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setImportedKeysMap()
+{
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData();
+ pMetaData->setImportedKeysMap();
+ m_xMetaData = pMetaData;
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL ODatabaseMetaDataResultSet::getPropertySetInfo( ) throw(RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+ORowSetValueDecorator& ORowSetValueDecorator::operator=(const ORowSetValue& _aValue)
+{
+ m_aValue = _aValue;
+ return *this;
+}
+// -----------------------------------------------------------------------------
+const ORowSetValue& ODatabaseMetaDataResultSet::getValue(sal_Int32 columnIndex)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
+
+ if ( isBeforeFirst() || isAfterLast() )
+ ::dbtools::throwFunctionSequenceException( *this );
+
+ checkIndex(columnIndex );
+ m_nColPos = columnIndex;
+
+ if(m_aRowsIter != m_aRows.end() && (*m_aRowsIter)[columnIndex].isValid())
+ return *(*m_aRowsIter)[columnIndex];
+ return m_aEmptyValue;
+}
+// -----------------------------------------------------------------------------
+/// return an empty ORowSetValueDecorator
+ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getEmptyValue()
+{
+ static ORowSetValueDecoratorRef aEmptyValueRef = new ORowSetValueDecorator();
+ return aEmptyValueRef;
+}
+// -----------------------------------------------------------------------------
+/// return an ORowSetValueDecorator with 0 as value
+ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::get0Value()
+{
+ static ORowSetValueDecoratorRef a0ValueRef = new ORowSetValueDecorator((sal_Int32)0);
+ return a0ValueRef;
+}
+// -----------------------------------------------------------------------------
+/// return an ORowSetValueDecorator with 1 as value
+ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::get1Value()
+{
+ static ORowSetValueDecoratorRef a1ValueRef = new ORowSetValueDecorator((sal_Int32)1);
+ return a1ValueRef;
+}
+// -----------------------------------------------------------------------------
+/// return an ORowSetValueDecorator with ColumnSearch::BASIC as value
+ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getBasicValue()
+{
+ static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(ColumnSearch::BASIC);
+ return aValueRef;
+}
+// -----------------------------------------------------------------------------
+ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getSelectValue()
+{
+ static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("SELECT"));
+ return aValueRef;
+}
+// -----------------------------------------------------------------------------
+ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getInsertValue()
+{
+ static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("INSERT"));
+ return aValueRef;
+}
+// -----------------------------------------------------------------------------
+ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getDeleteValue()
+{
+ static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DELETE"));
+ return aValueRef;
+}
+// -----------------------------------------------------------------------------
+ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getUpdateValue()
+{
+ static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("UPDATE"));
+ return aValueRef;
+}
+// -----------------------------------------------------------------------------
+ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getCreateValue()
+{
+ static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CREATE"));
+ return aValueRef;
+}
+// -----------------------------------------------------------------------------
+ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getReadValue()
+{
+ static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("READ"));
+ return aValueRef;
+}
+// -----------------------------------------------------------------------------
+ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getAlterValue()
+{
+ static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("ALTER"));
+ return aValueRef;
+}
+// -----------------------------------------------------------------------------
+ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getDropValue()
+{
+ static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DROP"));
+ return aValueRef;
+}
+// -----------------------------------------------------------------------------
+ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getQuoteValue()
+{
+ static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("'"));
+ return aValueRef;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::initialize( const Sequence< Any >& _aArguments ) throw (Exception, RuntimeException)
+{
+ if ( _aArguments.getLength() == 2 )
+ {
+ sal_Int32 nResultSetType = 0;
+ if ( _aArguments[0] >>= nResultSetType)
+ {
+ setType(static_cast<MetaDataResultSetType>(nResultSetType));
+ Sequence< Sequence<Any> > aRows;
+ if ( _aArguments[1] >>= aRows )
+ {
+ ORows aRowsToSet;
+ const Sequence<Any>* pRowsIter = aRows.getConstArray();
+ const Sequence<Any>* pRowsEnd = pRowsIter + aRows.getLength();
+ for (; pRowsIter != pRowsEnd;++pRowsIter)
+ {
+ ORow aRowToSet;
+ const Any* pRowIter = pRowsIter->getConstArray();
+ const Any* pRowEnd = pRowIter + pRowsIter->getLength();
+ for (; pRowIter != pRowEnd;++pRowIter)
+ {
+ ORowSetValueDecoratorRef aValue;
+ switch( pRowIter->getValueTypeClass() )
+ {
+ case TypeClass_BOOLEAN:
+ {
+ sal_Bool bValue = sal_False;
+ *pRowIter >>= bValue;
+ aValue = new ORowSetValueDecorator(ORowSetValue(bValue));
+ }
+ break;
+ case TypeClass_BYTE:
+ {
+ sal_Int8 nValue(0);
+ *pRowIter >>= nValue;
+ aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
+ }
+ break;
+ case TypeClass_SHORT:
+ case TypeClass_UNSIGNED_SHORT:
+ {
+ sal_Int16 nValue(0);
+ *pRowIter >>= nValue;
+ aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
+ }
+ break;
+ case TypeClass_LONG:
+ case TypeClass_UNSIGNED_LONG:
+ {
+ sal_Int32 nValue(0);
+ *pRowIter >>= nValue;
+ aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
+ }
+ break;
+ case TypeClass_HYPER:
+ case TypeClass_UNSIGNED_HYPER:
+ {
+ sal_Int64 nValue(0);
+ *pRowIter >>= nValue;
+ aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
+ }
+ break;
+ case TypeClass_FLOAT:
+ {
+ float nValue(0.0);
+ *pRowIter >>= nValue;
+ aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
+ }
+ break;
+ case TypeClass_DOUBLE:
+ {
+ double nValue(0.0);
+ *pRowIter >>= nValue;
+ aValue = new ORowSetValueDecorator(ORowSetValue(nValue));
+ }
+ break;
+ case TypeClass_STRING:
+ {
+ ::rtl::OUString sValue;
+ *pRowIter >>= sValue;
+ aValue = new ORowSetValueDecorator(ORowSetValue(sValue));
+ }
+ break;
+ default:
+ break;
+ }
+ aRowToSet.push_back(aValue);
+ }
+ aRowsToSet.push_back(aRowToSet);
+ } // for (; pRowsIter != pRowsEnd;++pRowsIter
+ setRows(aRowsToSet);
+ }
+ }
+ }
+}
+// XServiceInfo
+ // --------------------------------------------------------------------------------
+ //------------------------------------------------------------------------------
+ rtl::OUString ODatabaseMetaDataResultSet::getImplementationName_Static( ) throw(RuntimeException)
+ {
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.helper.DatabaseMetaDataResultSet"));
+ }
+ //------------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > ODatabaseMetaDataResultSet::getSupportedServiceNames_Static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet");
+ return aSNS;
+ }
+ //------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ODatabaseMetaDataResultSet::getImplementationName( ) throw(RuntimeException)
+ {
+ return getImplementationName_Static();
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::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 ODatabaseMetaDataResultSet::getSupportedServiceNames( ) throw(RuntimeException)
+ {
+ return getSupportedServiceNames_Static();
+ }
+ // -------------------------------------------------------------------------
+ namespace connectivity
+ {
+ Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet_CreateInstance(const Reference< XComponentContext >& ) throw( Exception )
+ {
+ return *(new ODatabaseMetaDataResultSet());
+ }
+ }
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ cppu::ImplementationEntry entries[] = {
+ { &ODatabaseMetaDataResultSet_CreateInstance, &ODatabaseMetaDataResultSet::getImplementationName_Static, &ODatabaseMetaDataResultSet::getSupportedServiceNames_Static,
+ &cppu::createSingleComponentFactory, 0, 0 },
+ { &ParameterSubstitution::create, &ParameterSubstitution::getImplementationName_Static, &ParameterSubstitution::getSupportedServiceNames_Static,
+ &cppu::createSingleComponentFactory, 0, 0 },
+ { 0, 0, 0, 0, 0, 0 }
+ };
+}
+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::registry::InvalidRegistryException;
+using ::com::sun::star::registry::InvalidValueException;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+//==========================================================================
+//= registration
+//==========================================================================
+extern "C"
+{
+
+//---------------------------------------------------------------------------------------
+SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(const sal_Char** _ppEnvTypeName, uno_Environment** /*_ppEnv*/)
+{
+ *_ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(void* serviceManager, com::sun::star::registry::XRegistryKey* registryKey)
+{
+ return cppu::component_writeInfoHelper(serviceManager, registryKey, entries);
+}
+//---------------------------------------------------------------------------------------
+SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(const sal_Char* implName, ::com::sun::star::lang::XMultiServiceFactory* serviceManager, void* registryKey)
+{
+ return cppu::component_getFactoryHelper(implName, serviceManager, registryKey, entries);
+}
+
+} // extern "C"
diff --git a/connectivity/source/commontools/FDatabaseMetaDataResultSetMetaData.cxx b/connectivity/source/commontools/FDatabaseMetaDataResultSetMetaData.cxx
new file mode 100644
index 000000000000..97e7201a53ff
--- /dev/null
+++ b/connectivity/source/commontools/FDatabaseMetaDataResultSetMetaData.cxx
@@ -0,0 +1,692 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "FDatabaseMetaDataResultSetMetaData.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ProcedureResult.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+
+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;
+
+// -------------------------------------------------------------------------
+ODatabaseMetaDataResultSetMetaData::~ODatabaseMetaDataResultSetMetaData()
+{
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.getColumnDisplaySize();
+
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.getColumnType();
+ return 1;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException)
+{
+ return m_mColumns.size();
+}
+// -------------------------------------------------------------------------
+
+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)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+
+::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();
+ 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)
+{
+ 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();
+}
+// -------------------------------------------------------------------------
+::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);
+}
+// -------------------------------------------------------------------------
+::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();
+}
+// -------------------------------------------------------------------------
+
+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();
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+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;
+}
+// -------------------------------------------------------------------------
+
+
+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();
+ 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();
+ 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();
+
+ 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();
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+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::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();
+
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+
+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();
+
+ 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);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setColumnPrivilegesMap()
+{
+ setColumnMap();
+ m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("GRANTOR"),
+ ColumnValue::NULLABLE,
+ 3,3,0,
+ DataType::VARCHAR);
+ m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("GRANTEE"),
+ ColumnValue::NULLABLE,
+ 3,3,0,
+ DataType::VARCHAR);
+ m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PRIVILEGE"),
+ ColumnValue::NULLABLE,
+ 3,3,0,
+ DataType::VARCHAR);
+ m_mColumns[8] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("IS_GRANTABLE"),
+ ColumnValue::NULLABLE,
+ 3,3,0,
+ DataType::VARCHAR);
+}
+// -----------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setTableNameMap()
+{
+ m_mColumns[1] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("TABLE_CAT"),
+ ColumnValue::NULLABLE,
+ 3,3,0,
+ DataType::VARCHAR);
+ m_mColumns[2] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("TABLE_SCHEM"),
+ ColumnValue::NULLABLE,
+ 3,3,0,
+ DataType::VARCHAR);
+ m_mColumns[3] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("TABLE_NAME"),
+ ColumnValue::NO_NULLS,
+ 3,3,0,
+ DataType::VARCHAR);
+}
+// -----------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setColumnMap()
+{
+ setTableNameMap();
+ m_mColumns[4] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("COLUMN_NAME"),
+ ColumnValue::NO_NULLS,
+ 3,3,0,
+ DataType::VARCHAR);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setColumnsMap()
+{
+ setColumnMap();
+
+ m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("DATA_TYPE"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("TYPE_NAME"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("COLUMN_SIZE"),
+ ColumnValue::NO_NULLS,
+ 3,3,0,
+ DataType::INTEGER);
+ m_mColumns[8] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("BUFFER_LENGTH"),
+ ColumnValue::NULLABLE,
+ 3,3,0,
+ DataType::INTEGER);
+ m_mColumns[9] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("DECIMAL_DIGITS"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[10] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NUM_PREC_RADIX"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ 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);
+ m_mColumns[17] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("ORDINAL_POSITION"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+ m_mColumns[18] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("IS_NULLABLE"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::VARCHAR);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setTablesMap()
+{
+ setTableNameMap();
+ m_mColumns[4] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("TABLE_TYPE"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setProcedureNameMap()
+{
+ m_mColumns[1] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PROCEDURE_CAT"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[2] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PROCEDURE_SCHEM"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[3] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PROCEDURE_NAME"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::VARCHAR);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setProcedureColumnsMap()
+{
+ setProcedureNameMap();
+ m_mColumns[4] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("COLUMN_NAME"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("COLUMN_TYPE"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("DATA_TYPE"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("TYPE_NAME"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[8] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PRECISION"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[9] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("LENGTH"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[10] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SCALE"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[11] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("RADIX"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[13] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setPrimaryKeysMap()
+{
+ setColumnMap();
+ 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()
+{
+ setTableNameMap();
+ 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[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("INDEX_NAME"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("TYPE"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[8] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("ORDINAL_POSITION"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[9] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("COLUMN_NAME"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[10] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("ASC_OR_DESC"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[11] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("CARDINALITY"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PAGES"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[13] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("FILTER_CONDITION"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setTablePrivilegesMap()
+{
+ setTableNameMap();
+ m_mColumns[4] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("GRANTOR"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("GRANTEE"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::VARCHAR);
+ 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[1] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PKTABLE_CAT"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[2] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PKTABLE_SCHEM"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[3] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PKTABLE_NAME"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[4] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PKCOLUMN_NAME"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("FKTABLE_CAT"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("FKTABLE_SCHEM"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("FKTABLE_NAME"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[8] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("FKCOLUMN_NAME"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::VARCHAR);
+
+ m_mColumns[9] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("KEY_SEQ"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+ m_mColumns[10] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("UPDATE_RULE"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+ m_mColumns[11] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("DELETE_RULE"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+ m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("FK_NAME"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[13] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PK_NAME"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[14] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("DEFERRABILITY"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setTypeInfoMap()
+{
+ m_mColumns[1] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("TYPE_NAME"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[2] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("DATA_TYPE"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+ m_mColumns[3] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PRECISION"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+ m_mColumns[4] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("LITERAL_PREFIX"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("LITERAL_SUFFIX"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("CREATE_PARAMS"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+ m_mColumns[8] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("CASE_SENSITIVE"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::BIT);
+ m_mColumns[9] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SEARCHABLE"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+ m_mColumns[10] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("UNSIGNED_ATTRIBUTE"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::BIT);
+ m_mColumns[11] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("FIXED_PREC_SCALE"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::BIT);
+ m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("AUTO_INCREMENT"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::BIT);
+ m_mColumns[13] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("LOCAL_TYPE_NAME"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[14] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("MINIMUM_SCALE"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[15] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("MAXIMUM_SCALE"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ 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()
+{
+ setProcedureNameMap();
+ m_mColumns[4] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("RESERVED1"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("RESERVED2"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("RESERVED3"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[8] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PROCEDURE_TYPE"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setTableTypes()
+{
+ m_mColumns[1] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("TABLE_TYPE"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setCatalogsMap()
+{
+ m_mColumns[1] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("TABLE_CAT"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setSchemasMap()
+{
+ m_mColumns[1] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("TABLE_SCHEM"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setVersionColumnsMap()
+{
+ m_mColumns[1] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SCOPE"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[2] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("COLUMN_NAME"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[3] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("DATA_TYPE"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[4] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("TYPE_NAME"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("COLUMN_SIZE"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("BUFFER_LENGTH"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("DECIMAL_DIGITS"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::INTEGER);
+ m_mColumns[8] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PSEUDO_COLUMN"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::INTEGER);
+}
+
+
diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx
new file mode 100644
index 000000000000..aca181916b47
--- /dev/null
+++ b/connectivity/source/commontools/FValue.cxx
@@ -0,0 +1,2333 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/FValue.hxx"
+#include "connectivity/CommonTools.hxx"
+#include <connectivity/dbconversion.hxx>
+#include <cppuhelper/extract.hxx>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <rtl/ustrbuf.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace ::dbtools;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::io;
+
+namespace connectivity
+{
+
+namespace {
+ static sal_Bool isStorageCompatible(sal_Int32 _eType1, sal_Int32 _eType2)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::isStorageCompatible" );
+ sal_Bool bIsCompatible = sal_True;
+
+ if (_eType1 != _eType2)
+ {
+ RTL_LOGFILE_CONTEXT_TRACE( aLogger, "ORowSetValue::isStorageCompatible _eType1 != _eType2" );
+ switch (_eType1)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::LONGVARCHAR:
+ bIsCompatible = (DataType::CHAR == _eType2)
+ || (DataType::VARCHAR == _eType2)
+ || (DataType::DECIMAL == _eType2)
+ || (DataType::NUMERIC == _eType2)
+ || (DataType::LONGVARCHAR == _eType2);
+ break;
+
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ bIsCompatible = (DataType::DOUBLE == _eType2)
+ || (DataType::REAL == _eType2);
+ break;
+
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ bIsCompatible = (DataType::BINARY == _eType2)
+ || (DataType::VARBINARY == _eType2)
+ || (DataType::LONGVARBINARY == _eType2);
+ break;
+
+ case DataType::INTEGER:
+ bIsCompatible = (DataType::SMALLINT == _eType2)
+ || (DataType::TINYINT == _eType2)
+ || (DataType::BIT == _eType2)
+ || (DataType::BOOLEAN == _eType2);
+ break;
+ case DataType::SMALLINT:
+ bIsCompatible = (DataType::TINYINT == _eType2)
+ || (DataType::BIT == _eType2)
+ || (DataType::BOOLEAN == _eType2);
+ break;
+ case DataType::TINYINT:
+ bIsCompatible = (DataType::BIT == _eType2)
+ || (DataType::BOOLEAN == _eType2);
+ break;
+
+ case DataType::BLOB:
+ case DataType::CLOB:
+ case DataType::OBJECT:
+ bIsCompatible = (DataType::BLOB == _eType2)
+ || (DataType::CLOB == _eType2)
+ || (DataType::OBJECT == _eType2);
+ break;
+
+ default:
+ bIsCompatible = sal_False;
+ }
+ }
+ return bIsCompatible;
+ }
+}
+
+// -----------------------------------------------------------------------------
+#ifdef DBG_UTIL
+
+#include <vector>
+#include <rtl/string.h>
+
+namespace tracing
+{
+ struct AllocationType
+ {
+ const sal_Char* pName;
+ sal_Int32 nAllocatedUnits;
+
+ AllocationType( ) : pName( NULL ), nAllocatedUnits( 0 ) { }
+ };
+
+ // =============================================================================
+ class AllocationTracer
+ {
+ public:
+ typedef ::std::vector< AllocationType > AllocationState;
+ static AllocationState s_aAllocated;
+ static ::osl::Mutex s_aMutex;
+
+ public:
+ static void registerUnit( const sal_Char* _pName );
+ static void revokeUnit( const sal_Char* _pName );
+
+ private:
+ static AllocationState::iterator getLocation( const sal_Char* _pName );
+ };
+
+ // =============================================================================
+ AllocationTracer::AllocationState::iterator AllocationTracer::getLocation( const sal_Char* _pName )
+ {
+ AllocationState::iterator aLookFor = s_aAllocated.begin();
+ for ( ;
+ aLookFor != s_aAllocated.end();
+ ++aLookFor
+ )
+ {
+ if ( 0 == rtl_str_compare( aLookFor->pName, _pName ) )
+ // found
+ return aLookFor;
+ }
+ // not found
+ s_aAllocated.push_back( AllocationType() );
+ aLookFor = s_aAllocated.end(); --aLookFor;
+ aLookFor->pName = _pName; // note that this assumes that _pName is a constant string ....
+ return aLookFor;
+ }
+
+ // =============================================================================
+ AllocationTracer::AllocationState AllocationTracer::s_aAllocated;
+ ::osl::Mutex AllocationTracer::s_aMutex;
+
+ // =============================================================================
+ void AllocationTracer::registerUnit( const sal_Char* _pName )
+ {
+ ::osl::MutexGuard aGuard( s_aMutex );
+
+ AllocationState::iterator aPos = getLocation( _pName );
+ ++aPos->nAllocatedUnits;
+ }
+
+ // =============================================================================
+ void AllocationTracer::revokeUnit( const sal_Char* _pName )
+ {
+ ::osl::MutexGuard aGuard( s_aMutex );
+
+ AllocationState::iterator aPos = getLocation( _pName );
+ --aPos->nAllocatedUnits;
+ }
+
+#define TRACE_ALLOC( type ) tracing::AllocationTracer::registerUnit( #type );
+#define TRACE_FREE( type ) tracing::AllocationTracer::revokeUnit( #type );
+}
+#else
+#define TRACE_ALLOC( type )
+#define TRACE_FREE( type )
+#endif
+
+// -----------------------------------------------------------------------------
+void ORowSetValue::setTypeKind(sal_Int32 _eType)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::setTypeKind" );
+ if ( !m_bNull && !isStorageCompatible(_eType, m_eTypeKind) )
+ {
+ switch(_eType)
+ {
+ case DataType::VARCHAR:
+ case DataType::CHAR:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::LONGVARCHAR:
+ (*this) = getString();
+ break;
+ case DataType::BIGINT:
+ (*this) = getLong();
+ break;
+
+ case DataType::FLOAT:
+ (*this) = getFloat();
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ (*this) = getDouble();
+ break;
+ case DataType::TINYINT:
+ (*this) = getInt8();
+ break;
+ case DataType::SMALLINT:
+ (*this) = getInt16();
+ break;
+ case DataType::INTEGER:
+ (*this) = getInt32();
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ (*this) = getBool();
+ break;
+ case DataType::DATE:
+ (*this) = getDate();
+ break;
+ case DataType::TIME:
+ (*this) = getTime();
+ break;
+ case DataType::TIMESTAMP:
+ (*this) = getDateTime();
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ (*this) = getSequence();
+ break;
+ case DataType::BLOB:
+ case DataType::CLOB:
+ case DataType::OBJECT:
+ case DataType::OTHER:
+ (*this) = getAny();
+ break;
+ default:
+ (*this) = getAny();
+ OSL_ENSURE(0,"ORowSetValue:operator==(): UNSPUPPORTED TYPE!");
+ }
+ }
+
+ m_eTypeKind = _eType;
+}
+
+// -----------------------------------------------------------------------------
+void ORowSetValue::free()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::free" );
+ if(!m_bNull)
+ {
+ switch(m_eTypeKind)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::LONGVARCHAR:
+ OSL_ENSURE(m_aValue.m_pString,"String pointer is null!");
+ rtl_uString_release(m_aValue.m_pString);
+ m_aValue.m_pString = NULL;
+ break;
+ case DataType::INTEGER:
+ if ( !m_bSigned )
+ {
+ delete (sal_Int64*)m_aValue.m_pValue;
+ TRACE_FREE( sal_Int64 )
+ m_aValue.m_pValue = NULL;
+ }
+ break;
+ case DataType::BIGINT:
+ if ( m_bSigned )
+ {
+ delete (sal_Int64*)m_aValue.m_pValue;
+ TRACE_FREE( sal_Int64 )
+ m_aValue.m_pValue = NULL;
+ }
+ else
+ {
+ OSL_ENSURE(m_aValue.m_pString,"String pointer is null!");
+ rtl_uString_release(m_aValue.m_pString);
+ m_aValue.m_pString = NULL;
+ }
+ break;
+ case DataType::FLOAT:
+ delete (float*)m_aValue.m_pValue;
+ TRACE_FREE( float )
+ m_aValue.m_pValue = NULL;
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ delete (double*)m_aValue.m_pValue;
+ TRACE_FREE( double )
+ m_aValue.m_pValue = NULL;
+ break;
+ case DataType::DATE:
+ delete (::com::sun::star::util::Date*)m_aValue.m_pValue;
+ TRACE_FREE( Date )
+ m_aValue.m_pValue = NULL;
+ break;
+ case DataType::TIME:
+ delete (::com::sun::star::util::Time*)m_aValue.m_pValue;
+ TRACE_FREE( Time )
+ m_aValue.m_pValue = NULL;
+ break;
+ case DataType::TIMESTAMP:
+ delete (::com::sun::star::util::DateTime*)m_aValue.m_pValue;
+ TRACE_FREE( DateTime )
+ m_aValue.m_pValue = NULL;
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ delete (Sequence<sal_Int8>*)m_aValue.m_pValue;
+ TRACE_FREE( Sequence_sal_Int8 )
+ m_aValue.m_pValue = NULL;
+ break;
+ case DataType::BLOB:
+ case DataType::CLOB:
+ case DataType::OBJECT:
+ delete (Any*)m_aValue.m_pValue;
+ TRACE_FREE( Any )
+ m_aValue.m_pValue = NULL;
+ break;
+ case DataType::BIT:
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::BOOLEAN:
+ break;
+ default:
+ if ( m_aValue.m_pValue )
+ {
+ delete (Any*)m_aValue.m_pValue;
+ TRACE_FREE( Any )
+ m_aValue.m_pValue = NULL;
+ }
+ break;
+
+ }
+ m_bNull = sal_True;
+ }
+}
+// -----------------------------------------------------------------------------
+ORowSetValue& ORowSetValue::operator=(const ORowSetValue& _rRH)
+{
+ if(&_rRH == this)
+ return *this;
+
+ if ( m_eTypeKind != _rRH.m_eTypeKind || (_rRH.m_bNull && !m_bNull) || m_bSigned != _rRH.m_bSigned)
+ free();
+
+ m_bBound = _rRH.m_bBound;
+ m_eTypeKind = _rRH.m_eTypeKind;
+ m_bSigned = _rRH.m_bSigned;
+
+ if(m_bNull && !_rRH.m_bNull)
+ {
+ switch(_rRH.m_eTypeKind)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::LONGVARCHAR:
+ rtl_uString_acquire(_rRH.m_aValue.m_pString);
+ m_aValue.m_pString = _rRH.m_aValue.m_pString;
+ break;
+ case DataType::BIGINT:
+ if ( _rRH.m_bSigned )
+ {
+ m_aValue.m_pValue = new sal_Int64(*(sal_Int64*)_rRH.m_aValue.m_pValue);
+ TRACE_ALLOC( sal_Int64 )
+ }
+ else
+ {
+ rtl_uString_acquire(_rRH.m_aValue.m_pString);
+ m_aValue.m_pString = _rRH.m_aValue.m_pString;
+ }
+ break;
+ case DataType::FLOAT:
+ m_aValue.m_pValue = new float(*(float*)_rRH.m_aValue.m_pValue);
+ TRACE_ALLOC( float )
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ m_aValue.m_pValue = new double(*(double*)_rRH.m_aValue.m_pValue);
+ TRACE_ALLOC( double )
+ break;
+ case DataType::DATE:
+ m_aValue.m_pValue = new Date(*(Date*)_rRH.m_aValue.m_pValue);
+ TRACE_ALLOC( Date )
+ break;
+ case DataType::TIME:
+ m_aValue.m_pValue = new Time(*(Time*)_rRH.m_aValue.m_pValue);
+ TRACE_ALLOC( Time )
+ break;
+ case DataType::TIMESTAMP:
+ m_aValue.m_pValue = new DateTime(*(DateTime*)_rRH.m_aValue.m_pValue);
+ TRACE_ALLOC( DateTime )
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ m_aValue.m_pValue = new Sequence<sal_Int8>(*(Sequence<sal_Int8>*)_rRH.m_aValue.m_pValue);
+ TRACE_ALLOC( Sequence_sal_Int8 )
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ m_aValue.m_bBool = _rRH.m_aValue.m_bBool;
+ break;
+ case DataType::TINYINT:
+ if ( _rRH.m_bSigned )
+ m_aValue.m_nInt8 = _rRH.m_aValue.m_nInt8;
+ else
+ m_aValue.m_nInt16 = _rRH.m_aValue.m_nInt16;
+ break;
+ case DataType::SMALLINT:
+ if ( _rRH.m_bSigned )
+ m_aValue.m_nInt16 = _rRH.m_aValue.m_nInt16;
+ else
+ m_aValue.m_nInt32 = _rRH.m_aValue.m_nInt32;
+ break;
+ case DataType::INTEGER:
+ if ( _rRH.m_bSigned )
+ m_aValue.m_nInt32 = _rRH.m_aValue.m_nInt32;
+ else
+ {
+ m_aValue.m_pValue = new sal_Int64(*(sal_Int64*)_rRH.m_aValue.m_pValue);
+ TRACE_ALLOC( sal_Int64 )
+ }
+ break;
+ default:
+ m_aValue.m_pValue = new Any(*(Any*)_rRH.m_aValue.m_pValue);
+ TRACE_ALLOC( Any )
+ }
+ }
+ else if(!_rRH.m_bNull)
+ {
+ switch(_rRH.m_eTypeKind)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::LONGVARCHAR:
+ (*this) = ::rtl::OUString(_rRH.m_aValue.m_pString);
+ break;
+ case DataType::BIGINT:
+ if ( _rRH.m_bSigned )
+ (*this) = *(sal_Int64*)_rRH.m_aValue.m_pValue;
+ else
+ (*this) = ::rtl::OUString(_rRH.m_aValue.m_pString);
+ break;
+ case DataType::FLOAT:
+ (*this) = *(float*)_rRH.m_aValue.m_pValue;
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ (*this) = *(double*)_rRH.m_aValue.m_pValue;
+ break;
+ case DataType::DATE:
+ (*this) = *(Date*)_rRH.m_aValue.m_pValue;
+ break;
+ case DataType::TIME:
+ (*this) = *(Time*)_rRH.m_aValue.m_pValue;
+ break;
+ case DataType::TIMESTAMP:
+ (*this) = *(DateTime*)_rRH.m_aValue.m_pValue;
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ (*this) = *(Sequence<sal_Int8>*)_rRH.m_aValue.m_pValue;
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ m_aValue.m_bBool = _rRH.m_aValue.m_bBool;
+ break;
+ case DataType::TINYINT:
+ if ( _rRH.m_bSigned )
+ m_aValue.m_nInt8 = _rRH.m_aValue.m_nInt8;
+ else
+ m_aValue.m_nInt16 = _rRH.m_aValue.m_nInt16;
+ break;
+ case DataType::SMALLINT:
+ if ( _rRH.m_bSigned )
+ m_aValue.m_nInt16 = _rRH.m_aValue.m_nInt16;
+ else
+ m_aValue.m_nInt32 = _rRH.m_aValue.m_nInt32;
+ break;
+ case DataType::INTEGER:
+ if ( _rRH.m_bSigned )
+ m_aValue.m_nInt32 = _rRH.m_aValue.m_nInt32;
+ else
+ *static_cast<sal_Int64*>(m_aValue.m_pValue) = *(sal_Int64*)_rRH.m_aValue.m_pValue;
+ break;
+ default:
+ (*(Any*)m_aValue.m_pValue) = (*(Any*)_rRH.m_aValue.m_pValue);
+ }
+ }
+
+ m_bNull = _rRH.m_bNull;
+ // OJ: BUGID: 96277
+ m_eTypeKind = _rRH.m_eTypeKind;
+
+ return *this;
+}
+// -------------------------------------------------------------------------
+
+ORowSetValue& ORowSetValue::operator=(const Date& _rRH)
+{
+ if(m_eTypeKind != DataType::DATE)
+ free();
+
+ if(m_bNull)
+ {
+ m_aValue.m_pValue = new Date(_rRH);
+ TRACE_ALLOC( Date )
+ m_eTypeKind = DataType::DATE;
+ m_bNull = sal_False;
+ }
+ else
+ *(Date*)m_aValue.m_pValue = _rRH;
+
+ return *this;
+}
+// -------------------------------------------------------------------------
+ORowSetValue& ORowSetValue::operator=(const Time& _rRH)
+{
+ if(m_eTypeKind != DataType::TIME)
+ free();
+
+ if(m_bNull)
+ {
+ m_aValue.m_pValue = new Time(_rRH);
+ TRACE_ALLOC( Time )
+ m_eTypeKind = DataType::TIME;
+ m_bNull = sal_False;
+ }
+ else
+ *(Time*)m_aValue.m_pValue = _rRH;
+
+ return *this;
+}
+// -------------------------------------------------------------------------
+ORowSetValue& ORowSetValue::operator=(const DateTime& _rRH)
+{
+ if(m_eTypeKind != DataType::TIMESTAMP)
+ free();
+ if(m_bNull)
+ {
+ m_aValue.m_pValue = new DateTime(_rRH);
+ TRACE_ALLOC( DateTime )
+ m_eTypeKind = DataType::TIMESTAMP;
+ m_bNull = sal_False;
+ }
+ else
+ *(DateTime*)m_aValue.m_pValue = _rRH;
+
+ return *this;
+}
+// -------------------------------------------------------------------------
+
+ORowSetValue& ORowSetValue::operator=(const ::rtl::OUString& _rRH)
+{
+ if(m_eTypeKind != DataType::VARCHAR || m_aValue.m_pString != _rRH.pData)
+ {
+ free();
+ m_bNull = sal_False;
+
+ m_aValue.m_pString = _rRH.pData;
+ rtl_uString_acquire(m_aValue.m_pString);
+ m_eTypeKind = DataType::VARCHAR;
+ }
+
+ return *this;
+}
+// -------------------------------------------------------------------------
+
+ORowSetValue& ORowSetValue::operator=(const double& _rRH)
+{
+ if( !isStorageCompatible(m_eTypeKind,DataType::DOUBLE) )
+ free();
+
+ if(m_bNull)
+ {
+ m_aValue.m_pValue = new double(_rRH);
+ TRACE_ALLOC( double )
+ m_eTypeKind = DataType::DOUBLE;
+ m_bNull = sal_False;
+ }
+ else
+ *(double*)m_aValue.m_pValue = _rRH;
+
+ return *this;
+}
+// -----------------------------------------------------------------------------
+ORowSetValue& ORowSetValue::operator=(const float& _rRH)
+{
+ if(m_eTypeKind != DataType::FLOAT)
+ free();
+
+ if(m_bNull)
+ {
+ m_aValue.m_pValue = new float(_rRH);
+ TRACE_ALLOC( float )
+ m_eTypeKind = DataType::FLOAT;
+ m_bNull = sal_False;
+ }
+ else
+ *(float*)m_aValue.m_pValue = _rRH;
+
+ return *this;
+}
+// -------------------------------------------------------------------------
+
+ORowSetValue& ORowSetValue::operator=(const sal_Int8& _rRH)
+{
+ if(m_eTypeKind != DataType::TINYINT )
+ free();
+
+ m_aValue.m_nInt8 = _rRH;
+ m_eTypeKind = DataType::TINYINT;
+ m_bNull = sal_False;
+ return *this;
+}
+// -------------------------------------------------------------------------
+
+ORowSetValue& ORowSetValue::operator=(const sal_Int16& _rRH)
+{
+ if(m_eTypeKind != DataType::SMALLINT )
+ free();
+
+ m_aValue.m_nInt16 = _rRH;
+ m_eTypeKind = DataType::SMALLINT;
+ m_bNull = sal_False;
+
+ return *this;
+}
+// -------------------------------------------------------------------------
+
+ORowSetValue& ORowSetValue::operator=(const sal_Int32& _rRH)
+{
+ if(m_eTypeKind != DataType::INTEGER )
+ free();
+
+ if ( m_bSigned )
+ m_aValue.m_nInt32 = _rRH;
+ else
+ {
+ if ( m_bNull )
+ {
+ m_aValue.m_pValue = new sal_Int64(_rRH);
+ TRACE_ALLOC( sal_Int64 )
+ }
+ else
+ *static_cast<sal_Int64*>(m_aValue.m_pValue) = static_cast<sal_Int64>(_rRH);
+ }
+
+ m_eTypeKind = DataType::INTEGER;
+ m_bNull = sal_False;
+
+ return *this;
+}
+// -------------------------------------------------------------------------
+
+ORowSetValue& ORowSetValue::operator=(const sal_Bool _rRH)
+{
+ if(m_eTypeKind != DataType::BIT && DataType::BOOLEAN != m_eTypeKind )
+ free();
+
+ m_aValue.m_bBool = _rRH;
+ m_eTypeKind = DataType::BIT;
+ m_bNull = sal_False;
+
+ return *this;
+}
+// -------------------------------------------------------------------------
+ORowSetValue& ORowSetValue::operator=(const sal_Int64& _rRH)
+{
+ if ( DataType::BIGINT != m_eTypeKind || !m_bSigned )
+ free();
+
+ if ( m_bSigned )
+ {
+ if(m_bNull)
+ {
+ m_aValue.m_pValue = new sal_Int64(_rRH);
+ TRACE_ALLOC( sal_Int64 )
+ }
+ else
+ *static_cast<sal_Int64*>(m_aValue.m_pValue) = _rRH;
+ }
+ else
+ {
+ ::rtl::OUString aVal = ::rtl::OUString::valueOf(_rRH);
+ m_aValue.m_pString = aVal.pData;
+ rtl_uString_acquire(m_aValue.m_pString);
+ }
+
+ m_eTypeKind = DataType::BIGINT;
+ m_bNull = sal_False;
+
+ return *this;
+}
+// -------------------------------------------------------------------------
+ORowSetValue& ORowSetValue::operator=(const Sequence<sal_Int8>& _rRH)
+{
+ if (!isStorageCompatible(DataType::LONGVARBINARY,m_eTypeKind))
+ free();
+
+ if (m_bNull)
+ {
+ m_aValue.m_pValue = new Sequence<sal_Int8>(_rRH);
+ TRACE_ALLOC( Sequence_sal_Int8 )
+ }
+ else
+ *static_cast< Sequence< sal_Int8 >* >(m_aValue.m_pValue) = _rRH;
+
+ m_eTypeKind = DataType::LONGVARBINARY;
+ m_bNull = sal_False;
+
+ return *this;
+}
+// -------------------------------------------------------------------------
+ORowSetValue& ORowSetValue::operator=(const Any& _rAny)
+{
+ if (!isStorageCompatible(DataType::OBJECT,m_eTypeKind))
+ free();
+
+ if ( m_bNull )
+ {
+ m_aValue.m_pValue = new Any(_rAny);
+ TRACE_ALLOC( Any )
+ }
+ else
+ *static_cast<Any*>(m_aValue.m_pValue) = _rAny;
+
+ m_eTypeKind = DataType::OBJECT;
+ m_bNull = sal_False;
+
+ return *this;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool operator==(const Date& _rLH,const Date& _rRH)
+{
+ return _rLH.Day == _rRH.Day && _rLH.Month == _rRH.Month && _rLH.Year == _rRH.Year;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool operator==(const Time& _rLH,const Time& _rRH)
+{
+ return _rLH.Minutes == _rRH.Minutes && _rLH.Hours == _rRH.Hours && _rLH.Seconds == _rRH.Seconds && _rLH.HundredthSeconds == _rRH.HundredthSeconds;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool operator==(const DateTime& _rLH,const DateTime& _rRH)
+{
+ return _rLH.Day == _rRH.Day && _rLH.Month == _rRH.Month && _rLH.Year == _rRH.Year &&
+ _rLH.Minutes == _rRH.Minutes && _rLH.Hours == _rRH.Hours && _rLH.Seconds == _rRH.Seconds && _rLH.HundredthSeconds == _rRH.HundredthSeconds;
+}
+// -------------------------------------------------------------------------
+
+bool ORowSetValue::operator==(const ORowSetValue& _rRH) const
+{
+ if(m_eTypeKind != _rRH.m_eTypeKind)
+ return false;
+ if ( m_bSigned != _rRH.m_bSigned )
+ return false;
+ if(m_bNull != _rRH.isNull())
+ return false;
+ if(m_bNull && _rRH.isNull())
+ return true;
+
+ bool bRet = false;
+ OSL_ENSURE(!m_bNull,"SHould not be null!");
+ switch(m_eTypeKind)
+ {
+ case DataType::VARCHAR:
+ case DataType::CHAR:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::LONGVARCHAR:
+ {
+ ::rtl::OUString aVal1(m_aValue.m_pString);
+ ::rtl::OUString aVal2(_rRH.m_aValue.m_pString);
+ bRet = aVal1 == aVal2;
+ break;
+ }
+
+ case DataType::FLOAT:
+ bRet = *(float*)m_aValue.m_pValue == *(float*)_rRH.m_aValue.m_pValue;
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ bRet = *(double*)m_aValue.m_pValue == *(double*)_rRH.m_aValue.m_pValue;
+ break;
+ case DataType::TINYINT:
+ bRet = m_bSigned ? ( m_aValue.m_nInt8 == _rRH.m_aValue.m_nInt8 ) : (m_aValue.m_nInt16 == _rRH.m_aValue.m_nInt16);
+ break;
+ case DataType::SMALLINT:
+ bRet = m_bSigned ? ( m_aValue.m_nInt16 == _rRH.m_aValue.m_nInt16 ) : (m_aValue.m_nInt32 == _rRH.m_aValue.m_nInt32);
+ break;
+ case DataType::INTEGER:
+ bRet = m_bSigned ? ( m_aValue.m_nInt32 == _rRH.m_aValue.m_nInt32 ) : (*(sal_Int64*)m_aValue.m_pValue == *(sal_Int64*)_rRH.m_aValue.m_pValue);
+ break;
+ case DataType::BIGINT:
+ if ( m_bSigned )
+ bRet = *(sal_Int64*)m_aValue.m_pValue == *(sal_Int64*)_rRH.m_aValue.m_pValue;
+ else
+ {
+ ::rtl::OUString aVal1(m_aValue.m_pString);
+ ::rtl::OUString aVal2(_rRH.m_aValue.m_pString);
+ bRet = aVal1 == aVal2;
+ }
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ bRet = m_aValue.m_bBool == _rRH.m_aValue.m_bBool;
+ break;
+ case DataType::DATE:
+ bRet = *(Date*)m_aValue.m_pValue == *(Date*)_rRH.m_aValue.m_pValue;
+ break;
+ case DataType::TIME:
+ bRet = *(Time*)m_aValue.m_pValue == *(Time*)_rRH.m_aValue.m_pValue;
+ break;
+ case DataType::TIMESTAMP:
+ bRet = *(DateTime*)m_aValue.m_pValue == *(DateTime*)_rRH.m_aValue.m_pValue;
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ bRet = false;
+ break;
+ case DataType::BLOB:
+ case DataType::CLOB:
+ case DataType::OBJECT:
+ case DataType::OTHER:
+ bRet = false;
+ break;
+ default:
+ bRet = false;
+ OSL_ENSURE(0,"ORowSetValue::operator==(): UNSPUPPORTED TYPE!");
+ break;
+ }
+ return bRet;
+}
+// -------------------------------------------------------------------------
+Any ORowSetValue::makeAny() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::makeAny" );
+ Any rValue;
+ if(isBound() && !isNull())
+ {
+ switch(getTypeKind())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::LONGVARCHAR:
+ OSL_ENSURE(m_aValue.m_pString,"Value is null!");
+ rValue <<= (::rtl::OUString)m_aValue.m_pString;
+ break;
+ case DataType::BIGINT:
+ if ( m_bSigned )
+ {
+ OSL_ENSURE(m_aValue.m_pValue,"Value is null!");
+ rValue <<= *(sal_Int64*)m_aValue.m_pValue;
+ }
+ else
+ {
+ OSL_ENSURE(m_aValue.m_pString,"Value is null!");
+ rValue <<= (::rtl::OUString)m_aValue.m_pString;
+ }
+ break;
+ case DataType::FLOAT:
+ OSL_ENSURE(m_aValue.m_pValue,"Value is null!");
+ rValue <<= *(float*)m_aValue.m_pValue;
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ OSL_ENSURE(m_aValue.m_pValue,"Value is null!");
+ rValue <<= *(double*)m_aValue.m_pValue;
+ break;
+ case DataType::DATE:
+ OSL_ENSURE(m_aValue.m_pValue,"Value is null!");
+ rValue <<= *(Date*)m_aValue.m_pValue;
+ break;
+ case DataType::TIME:
+ OSL_ENSURE(m_aValue.m_pValue,"Value is null!");
+ rValue <<= *(Time*)m_aValue.m_pValue;
+ break;
+ case DataType::TIMESTAMP:
+ OSL_ENSURE(m_aValue.m_pValue,"Value is null!");
+ rValue <<= *(DateTime*)m_aValue.m_pValue;
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ OSL_ENSURE(m_aValue.m_pValue,"Value is null!");
+ rValue <<= *(Sequence<sal_Int8>*)m_aValue.m_pValue;
+ break;
+ case DataType::BLOB:
+ case DataType::CLOB:
+ case DataType::OBJECT:
+ case DataType::OTHER:
+ rValue = getAny();
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ rValue.setValue( &m_aValue.m_bBool, ::getCppuBooleanType() );
+ break;
+ case DataType::TINYINT:
+ if ( m_bSigned )
+ rValue <<= m_aValue.m_nInt8;
+ else
+ rValue <<= m_aValue.m_nInt16;
+ break;
+ case DataType::SMALLINT:
+ if ( m_bSigned )
+ rValue <<= m_aValue.m_nInt16;
+ else
+ rValue <<= m_aValue.m_nInt32;
+ break;
+ case DataType::INTEGER:
+ if ( m_bSigned )
+ rValue <<= m_aValue.m_nInt32;
+ else
+ {
+ OSL_ENSURE(m_aValue.m_pValue,"Value is null!");
+ rValue <<= *(sal_Int64*)m_aValue.m_pValue;
+ }
+ break;
+ default:
+ OSL_ENSURE(0,"ORowSetValue::makeAny(): UNSPUPPORTED TYPE!");
+ rValue = getAny();
+ break;
+ }
+ }
+ return rValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString ORowSetValue::getString( ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getString" );
+ ::rtl::OUString aRet;
+ if(!m_bNull)
+ {
+ switch(getTypeKind())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::LONGVARCHAR:
+ aRet = m_aValue.m_pString;
+ break;
+ case DataType::BIGINT:
+ if ( m_bSigned )
+ aRet = ::rtl::OUString::valueOf((sal_Int64)*this);
+ else
+ aRet = m_aValue.m_pString;
+ break;
+ case DataType::FLOAT:
+ aRet = ::rtl::OUString::valueOf((float)*this);
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ aRet = ::rtl::OUString::valueOf((double)*this);
+ break;
+ case DataType::DATE:
+ aRet = connectivity::toDateString(*this);
+ break;
+ case DataType::TIME:
+ aRet = connectivity::toTimeString(*this);
+ break;
+ case DataType::TIMESTAMP:
+ aRet = connectivity::toDateTimeString(*this);
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ {
+ ::rtl::OUStringBuffer sVal = ::rtl::OUString::createFromAscii("0x");
+ Sequence<sal_Int8> aSeq(getSequence());
+ const sal_Int8* pBegin = aSeq.getConstArray();
+ const sal_Int8* pEnd = pBegin + aSeq.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ sVal.append((sal_Int32)*pBegin,16);
+ aRet = sVal.makeStringAndClear();
+ }
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ aRet = ::rtl::OUString::valueOf((sal_Int32)(sal_Bool)*this);
+ break;
+ case DataType::TINYINT:
+ if ( m_bSigned )
+ aRet = ::rtl::OUString::valueOf((sal_Int32)(sal_Int8)*this);
+ else
+ aRet = ::rtl::OUString::valueOf((sal_Int32)(sal_Int16)*this);
+ break;
+ case DataType::SMALLINT:
+ if ( m_bSigned )
+ aRet = ::rtl::OUString::valueOf((sal_Int32)(sal_Int16)*this);
+ else
+ aRet = ::rtl::OUString::valueOf((sal_Int32)*this);
+ break;
+ case DataType::INTEGER:
+ if ( m_bSigned )
+ aRet = ::rtl::OUString::valueOf((sal_Int32)*this);
+ else
+ aRet = ::rtl::OUString::valueOf((sal_Int64)*this);
+ break;
+ case DataType::CLOB:
+ {
+ Any aValue( getAny() );
+ Reference< XClob > xClob;
+ if ( aValue >>= xClob )
+ {
+ if ( xClob.is() )
+ {
+ aRet = xClob->getSubString(1,(sal_Int32)xClob->length() );
+ }
+ }
+ }
+ break;
+ default:
+ {
+ Any aValue = getAny();
+ aValue >>= aRet;
+ break;
+ }
+ }
+ }
+ return aRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool ORowSetValue::getBool() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getBool" );
+ sal_Bool bRet = sal_False;
+ if(!m_bNull)
+ {
+ switch(getTypeKind())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ {
+ const ::rtl::OUString sValue(m_aValue.m_pString);
+ const static ::rtl::OUString s_sTrue(RTL_CONSTASCII_USTRINGPARAM("true"));
+ const static ::rtl::OUString s_sFalse(RTL_CONSTASCII_USTRINGPARAM("false"));
+ if ( sValue.equalsIgnoreAsciiCase(s_sTrue) )
+ {
+ bRet = sal_True;
+ break;
+ }
+ else if ( sValue.equalsIgnoreAsciiCase(s_sFalse) )
+ {
+ bRet = sal_False;
+ break;
+ }
+ }
+ // run through
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+
+ bRet = ::rtl::OUString(m_aValue.m_pString).toInt32() != 0;
+ break;
+ case DataType::BIGINT:
+ if ( m_bSigned )
+ bRet = *(sal_Int64*)m_aValue.m_pValue != 0;
+ else
+ bRet = ::rtl::OUString(m_aValue.m_pString).toInt64() != 0;
+ break;
+ case DataType::FLOAT:
+ bRet = *(float*)m_aValue.m_pValue != 0.0;
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ bRet = *(double*)m_aValue.m_pValue != 0.0;
+ break;
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ OSL_ASSERT(!"getBool() for this type is not allowed!");
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ bRet = m_aValue.m_bBool;
+ break;
+ case DataType::TINYINT:
+ bRet = m_bSigned ? (m_aValue.m_nInt8 != 0) : (m_aValue.m_nInt16 != 0);
+ break;
+ case DataType::SMALLINT:
+ bRet = m_bSigned ? (m_aValue.m_nInt16 != 0) : (m_aValue.m_nInt32 != 0);
+ break;
+ case DataType::INTEGER:
+ bRet = m_bSigned ? (m_aValue.m_nInt32 != 0) : (*static_cast<sal_Int64*>(m_aValue.m_pValue) != sal_Int64(0));
+ break;
+ default:
+ {
+ Any aValue = getAny();
+ aValue >>= bRet;
+ break;
+ }
+ }
+ }
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Int8 ORowSetValue::getInt8() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getInt8" );
+
+
+ sal_Int8 nRet = 0;
+ if(!m_bNull)
+ {
+ switch(getTypeKind())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::LONGVARCHAR:
+ nRet = sal_Int8(::rtl::OUString(m_aValue.m_pString).toInt32());
+ break;
+ case DataType::BIGINT:
+ if ( m_bSigned )
+ nRet = sal_Int8(*(sal_Int64*)m_aValue.m_pValue);
+ else
+ nRet = sal_Int8(::rtl::OUString(m_aValue.m_pString).toInt32());
+ break;
+ case DataType::FLOAT:
+ nRet = sal_Int8(*(float*)m_aValue.m_pValue);
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ nRet = sal_Int8(*(double*)m_aValue.m_pValue);
+ break;
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
+ OSL_ASSERT(!"getInt8() for this type is not allowed!");
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ nRet = m_aValue.m_bBool;
+ break;
+ case DataType::TINYINT:
+ if ( m_bSigned )
+ nRet = m_aValue.m_nInt8;
+ else
+ nRet = static_cast<sal_Int8>(m_aValue.m_nInt16);
+ break;
+ case DataType::SMALLINT:
+ if ( m_bSigned )
+ nRet = static_cast<sal_Int8>(m_aValue.m_nInt16);
+ else
+ nRet = static_cast<sal_Int8>(m_aValue.m_nInt32);
+ break;
+ case DataType::INTEGER:
+ if ( m_bSigned )
+ nRet = static_cast<sal_Int8>(m_aValue.m_nInt32);
+ else
+ nRet = static_cast<sal_Int8>(*static_cast<sal_Int64*>(m_aValue.m_pValue));
+ break;
+ default:
+ {
+ Any aValue = getAny();
+ aValue >>= nRet;
+ break;
+ }
+ }
+ }
+ return nRet;
+}
+// -------------------------------------------------------------------------
+sal_Int16 ORowSetValue::getInt16() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getInt16" );
+
+
+ sal_Int16 nRet = 0;
+ if(!m_bNull)
+ {
+ switch(getTypeKind())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::LONGVARCHAR:
+ nRet = sal_Int16(::rtl::OUString(m_aValue.m_pString).toInt32());
+ break;
+ case DataType::BIGINT:
+ if ( m_bSigned )
+ nRet = sal_Int16(*(sal_Int64*)m_aValue.m_pValue);
+ else
+ nRet = sal_Int16(::rtl::OUString(m_aValue.m_pString).toInt32());
+ break;
+ case DataType::FLOAT:
+ nRet = sal_Int16(*(float*)m_aValue.m_pValue);
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ nRet = sal_Int16(*(double*)m_aValue.m_pValue);
+ break;
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
+ OSL_ASSERT(!"getInt16() for this type is not allowed!");
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ nRet = m_aValue.m_bBool;
+ break;
+ case DataType::TINYINT:
+ if ( m_bSigned )
+ nRet = m_aValue.m_nInt8;
+ else
+ nRet = m_aValue.m_nInt16;
+ break;
+ case DataType::SMALLINT:
+ if ( m_bSigned )
+ nRet = m_aValue.m_nInt16;
+ else
+ nRet = static_cast<sal_Int16>(m_aValue.m_nInt32);
+ break;
+ case DataType::INTEGER:
+ if ( m_bSigned )
+ nRet = static_cast<sal_Int16>(m_aValue.m_nInt32);
+ else
+ nRet = static_cast<sal_Int16>(*static_cast<sal_Int64*>(m_aValue.m_pValue));
+ break;
+ default:
+ {
+ Any aValue = getAny();
+ aValue >>= nRet;
+ break;
+ }
+ }
+ }
+ return nRet;
+}
+// -------------------------------------------------------------------------
+sal_Int32 ORowSetValue::getInt32() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getInt32" );
+ sal_Int32 nRet = 0;
+ if(!m_bNull)
+ {
+ switch(getTypeKind())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::LONGVARCHAR:
+ nRet = ::rtl::OUString(m_aValue.m_pString).toInt32();
+ break;
+ case DataType::BIGINT:
+ if ( m_bSigned )
+ nRet = sal_Int32(*(sal_Int64*)m_aValue.m_pValue);
+ else
+ nRet = ::rtl::OUString(m_aValue.m_pString).toInt32();
+ break;
+ case DataType::FLOAT:
+ nRet = sal_Int32(*(float*)m_aValue.m_pValue);
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ nRet = sal_Int32(*(double*)m_aValue.m_pValue);
+ break;
+ case DataType::DATE:
+ nRet = dbtools::DBTypeConversion::toDays(*(::com::sun::star::util::Date*)m_aValue.m_pValue);
+ break;
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
+ OSL_ASSERT(!"getInt32() for this type is not allowed!");
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ nRet = m_aValue.m_bBool;
+ break;
+ case DataType::TINYINT:
+ if ( m_bSigned )
+ nRet = m_aValue.m_nInt8;
+ else
+ nRet = m_aValue.m_nInt16;
+ break;
+ case DataType::SMALLINT:
+ if ( m_bSigned )
+ nRet = m_aValue.m_nInt16;
+ else
+ nRet = m_aValue.m_nInt32;
+ break;
+ case DataType::INTEGER:
+ if ( m_bSigned )
+ nRet = m_aValue.m_nInt32;
+ else
+ nRet = static_cast<sal_Int32>(*static_cast<sal_Int64*>(m_aValue.m_pValue));
+ break;
+ default:
+ {
+ Any aValue = getAny();
+ aValue >>= nRet;
+ break;
+ }
+ }
+ }
+ return nRet;
+}
+// -------------------------------------------------------------------------
+sal_Int64 ORowSetValue::getLong() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getLong" );
+ sal_Int64 nRet = 0;
+ if(!m_bNull)
+ {
+ switch(getTypeKind())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::LONGVARCHAR:
+ nRet = ::rtl::OUString(m_aValue.m_pString).toInt64();
+ break;
+ case DataType::BIGINT:
+ if ( m_bSigned )
+ nRet = *(sal_Int64*)m_aValue.m_pValue;
+ else
+ nRet = ::rtl::OUString(m_aValue.m_pString).toInt64();
+ break;
+ case DataType::FLOAT:
+ nRet = sal_Int64(*(float*)m_aValue.m_pValue);
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ nRet = sal_Int64(*(double*)m_aValue.m_pValue);
+ break;
+ case DataType::DATE:
+ nRet = dbtools::DBTypeConversion::toDays(*(::com::sun::star::util::Date*)m_aValue.m_pValue);
+ break;
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
+ OSL_ASSERT(!"getInt32() for this type is not allowed!");
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ nRet = m_aValue.m_bBool;
+ break;
+ case DataType::TINYINT:
+ if ( m_bSigned )
+ nRet = m_aValue.m_nInt8;
+ else
+ nRet = m_aValue.m_nInt16;
+ break;
+ case DataType::SMALLINT:
+ if ( m_bSigned )
+ nRet = m_aValue.m_nInt16;
+ else
+ nRet = m_aValue.m_nInt32;
+ break;
+ case DataType::INTEGER:
+ if ( m_bSigned )
+ nRet = m_aValue.m_nInt32;
+ else
+ nRet = *(sal_Int64*)m_aValue.m_pValue;
+ break;
+ default:
+ {
+ Any aValue = getAny();
+ aValue >>= nRet;
+ break;
+ }
+ }
+ }
+ return nRet;
+}
+// -------------------------------------------------------------------------
+float ORowSetValue::getFloat() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getFloat" );
+ float nRet = 0;
+ if(!m_bNull)
+ {
+ switch(getTypeKind())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::LONGVARCHAR:
+ nRet = ::rtl::OUString(m_aValue.m_pString).toFloat();
+ break;
+ case DataType::BIGINT:
+ if ( m_bSigned )
+ nRet = float(*(sal_Int64*)m_aValue.m_pValue);
+ else
+ nRet = ::rtl::OUString(m_aValue.m_pString).toFloat();
+ break;
+ case DataType::FLOAT:
+ nRet = *(float*)m_aValue.m_pValue;
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ nRet = (float)*(double*)m_aValue.m_pValue;
+ break;
+ case DataType::DATE:
+ nRet = (float)dbtools::DBTypeConversion::toDouble(*(::com::sun::star::util::Date*)m_aValue.m_pValue);
+ break;
+ case DataType::TIME:
+ nRet = (float)dbtools::DBTypeConversion::toDouble(*(::com::sun::star::util::Time*)m_aValue.m_pValue);
+ break;
+ case DataType::TIMESTAMP:
+ nRet = (float)dbtools::DBTypeConversion::toDouble(*(::com::sun::star::util::DateTime*)m_aValue.m_pValue);
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
+ OSL_ASSERT(!"getDouble() for this type is not allowed!");
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ nRet = m_aValue.m_bBool;
+ break;
+ case DataType::TINYINT:
+ if ( m_bSigned )
+ nRet = m_aValue.m_nInt8;
+ else
+ nRet = m_aValue.m_nInt16;
+ break;
+ case DataType::SMALLINT:
+ if ( m_bSigned )
+ nRet = m_aValue.m_nInt16;
+ else
+ nRet = (float)m_aValue.m_nInt32;
+ break;
+ case DataType::INTEGER:
+ if ( m_bSigned )
+ nRet = (float)m_aValue.m_nInt32;
+ else
+ nRet = float(*(sal_Int64*)m_aValue.m_pValue);
+ break;
+ default:
+ {
+ Any aValue = getAny();
+ aValue >>= nRet;
+ break;
+ }
+ }
+ }
+ return nRet;
+}
+// -------------------------------------------------------------------------
+double ORowSetValue::getDouble() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getDouble" );
+
+
+ double nRet = 0;
+ if(!m_bNull)
+ {
+ switch(getTypeKind())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::LONGVARCHAR:
+ nRet = ::rtl::OUString(m_aValue.m_pString).toDouble();
+ break;
+ case DataType::BIGINT:
+ if ( m_bSigned )
+ nRet = double(*(sal_Int64*)m_aValue.m_pValue);
+ else
+ nRet = ::rtl::OUString(m_aValue.m_pString).toDouble();
+ break;
+ case DataType::FLOAT:
+ nRet = *(float*)m_aValue.m_pValue;
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ nRet = *(double*)m_aValue.m_pValue;
+ break;
+ case DataType::DATE:
+ nRet = dbtools::DBTypeConversion::toDouble(*(::com::sun::star::util::Date*)m_aValue.m_pValue);
+ break;
+ case DataType::TIME:
+ nRet = dbtools::DBTypeConversion::toDouble(*(::com::sun::star::util::Time*)m_aValue.m_pValue);
+ break;
+ case DataType::TIMESTAMP:
+ nRet = dbtools::DBTypeConversion::toDouble(*(::com::sun::star::util::DateTime*)m_aValue.m_pValue);
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
+ OSL_ASSERT(!"getDouble() for this type is not allowed!");
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ nRet = m_aValue.m_bBool;
+ break;
+ case DataType::TINYINT:
+ if ( m_bSigned )
+ nRet = m_aValue.m_nInt8;
+ else
+ nRet = m_aValue.m_nInt16;
+ break;
+ case DataType::SMALLINT:
+ if ( m_bSigned )
+ nRet = m_aValue.m_nInt16;
+ else
+ nRet = m_aValue.m_nInt32;
+ break;
+ case DataType::INTEGER:
+ if ( m_bSigned )
+ nRet = m_aValue.m_nInt32;
+ else
+ nRet = double(*(sal_Int64*)m_aValue.m_pValue);
+ break;
+ default:
+ {
+ Any aValue = getAny();
+ aValue >>= nRet;
+ break;
+ }
+ }
+ }
+ return nRet;
+}
+// -------------------------------------------------------------------------
+void ORowSetValue::setFromDouble(const double& _rVal,sal_Int32 _nDatatype)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::setFromDouble" );
+ free();
+
+ m_bNull = sal_False;
+ switch(_nDatatype)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::LONGVARCHAR:
+ {
+ ::rtl::OUString aVal = ::rtl::OUString::valueOf(_rVal);
+ m_aValue.m_pString = aVal.pData;
+ rtl_uString_acquire(m_aValue.m_pString);
+ }
+ break;
+ case DataType::BIGINT:
+ if ( m_bSigned )
+ {
+ m_aValue.m_pValue = new sal_Int64((sal_Int64)_rVal);
+ TRACE_ALLOC( sal_Int64 )
+ }
+ else
+ {
+ ::rtl::OUString aVal = ::rtl::OUString::valueOf(_rVal);
+ m_aValue.m_pString = aVal.pData;
+ rtl_uString_acquire(m_aValue.m_pString);
+ }
+ break;
+ case DataType::FLOAT:
+ m_aValue.m_pValue = new float((float)_rVal);
+ TRACE_ALLOC( float )
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ m_aValue.m_pValue = new double(_rVal);
+ TRACE_ALLOC( double )
+ break;
+ case DataType::DATE:
+ m_aValue.m_pValue = new Date(dbtools::DBTypeConversion::toDate(_rVal));
+ TRACE_ALLOC( Date )
+ break;
+ case DataType::TIME:
+ m_aValue.m_pValue = new Time(dbtools::DBTypeConversion::toTime(_rVal));
+ TRACE_ALLOC( Time )
+ break;
+ case DataType::TIMESTAMP:
+ m_aValue.m_pValue = new DateTime(dbtools::DBTypeConversion::toDateTime(_rVal));
+ TRACE_ALLOC( DateTime )
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ case DataType::CLOB:
+ OSL_ASSERT(!"setFromDouble() for this type is not allowed!");
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ m_aValue.m_bBool = _rVal != 0.0;
+ break;
+ case DataType::TINYINT:
+ if ( m_bSigned )
+ m_aValue.m_nInt8 = sal_Int8(_rVal);
+ else
+ m_aValue.m_nInt16 = sal_Int16(_rVal);
+ break;
+ case DataType::SMALLINT:
+ if ( m_bSigned )
+ m_aValue.m_nInt16 = sal_Int16(_rVal);
+ else
+ m_aValue.m_nInt32 = sal_Int32(_rVal);
+ break;
+ case DataType::INTEGER:
+ if ( m_bSigned )
+ m_aValue.m_nInt32 = sal_Int32(_rVal);
+ else
+ {
+ m_aValue.m_pValue = new sal_Int64((sal_Int64)_rVal);
+ TRACE_ALLOC( sal_Int64 )
+ }
+ break;
+ default:
+ {
+ m_aValue.m_pValue = new Any(_rVal);
+ break;
+ }
+ }
+ m_eTypeKind = _nDatatype;
+}
+// -----------------------------------------------------------------------------
+Sequence<sal_Int8> ORowSetValue::getSequence() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getSequence" );
+ Sequence<sal_Int8> aSeq;
+ if (!m_bNull)
+ {
+ switch(m_eTypeKind)
+ {
+ case DataType::OBJECT:
+ case DataType::CLOB:
+ case DataType::BLOB:
+ {
+ Reference<XInputStream> xStream;
+ const Any aValue = makeAny();
+ if(aValue.hasValue())
+ {
+ Reference<XBlob> xBlob(aValue,UNO_QUERY);
+ if ( xBlob.is() )
+ xStream = xBlob->getBinaryStream();
+ else
+ {
+ Reference<XClob> xClob(aValue,UNO_QUERY);
+ if ( xClob.is() )
+ xStream = xClob->getCharacterStream();
+ }
+ if(xStream.is())
+ {
+ const sal_uInt32 nBytesToRead = 65535;
+ sal_uInt32 nRead;
+
+ do
+ {
+ ::com::sun::star::uno::Sequence< sal_Int8 > aReadSeq;
+
+ nRead = xStream->readSomeBytes( aReadSeq, nBytesToRead );
+
+ if( nRead )
+ {
+ const sal_uInt32 nOldLength = aSeq.getLength();
+ aSeq.realloc( nOldLength + nRead );
+ rtl_copyMemory( aSeq.getArray() + nOldLength, aReadSeq.getConstArray(), aReadSeq.getLength() );
+ }
+ }
+ while( nBytesToRead == nRead );
+ xStream->closeInput();
+ }
+ }
+ }
+ break;
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ {
+ ::rtl::OUString sVal(m_aValue.m_pString);
+ aSeq = Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(sVal.getStr()),sizeof(sal_Unicode)*sVal.getLength());
+ }
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ aSeq = *static_cast< Sequence<sal_Int8>*>(m_aValue.m_pValue);
+ break;
+ default:
+ {
+ Any aValue = getAny();
+ aValue >>= aSeq;
+ break;
+ }
+ }
+ }
+ return aSeq;
+
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::util::Date ORowSetValue::getDate() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getDate" );
+ ::com::sun::star::util::Date aValue;
+ if(!m_bNull)
+ {
+ switch(m_eTypeKind)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ aValue = DBTypeConversion::toDate(getString());
+ break;
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ aValue = DBTypeConversion::toDate((double)*this);
+ break;
+ case DataType::FLOAT:
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ aValue = DBTypeConversion::toDate((double)*this);
+ break;
+
+ case DataType::DATE:
+ aValue = *static_cast< ::com::sun::star::util::Date*>(m_aValue.m_pValue);
+ break;
+ case DataType::TIMESTAMP:
+ {
+ ::com::sun::star::util::DateTime* pDateTime = static_cast< ::com::sun::star::util::DateTime*>(m_aValue.m_pValue);
+ aValue.Day = pDateTime->Day;
+ aValue.Month = pDateTime->Month;
+ aValue.Year = pDateTime->Year;
+ }
+ break;
+ default:
+ {
+ Any aAnyValue = getAny();
+ aAnyValue >>= aValue;
+ break;
+ }
+ }
+ }
+ return aValue;
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::util::Time ORowSetValue::getTime() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getTime" );
+ ::com::sun::star::util::Time aValue;
+ if(!m_bNull)
+ {
+ switch(m_eTypeKind)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ aValue = DBTypeConversion::toTime(getString());
+ break;
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ aValue = DBTypeConversion::toTime((double)*this);
+ break;
+ case DataType::FLOAT:
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ aValue = DBTypeConversion::toTime((double)*this);
+ break;
+ case DataType::TIMESTAMP:
+ {
+ ::com::sun::star::util::DateTime* pDateTime = static_cast< ::com::sun::star::util::DateTime*>(m_aValue.m_pValue);
+ aValue.HundredthSeconds = pDateTime->HundredthSeconds;
+ aValue.Seconds = pDateTime->Seconds;
+ aValue.Minutes = pDateTime->Minutes;
+ aValue.Hours = pDateTime->Hours;
+ }
+ break;
+ case DataType::TIME:
+ aValue = *static_cast< ::com::sun::star::util::Time*>(m_aValue.m_pValue);
+ break;
+ default:
+ {
+ Any aAnyValue = getAny();
+ aAnyValue >>= aValue;
+ break;
+ }
+ }
+ }
+ return aValue;
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::util::DateTime ORowSetValue::getDateTime() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getDateTime" );
+ ::com::sun::star::util::DateTime aValue;
+ if(!m_bNull)
+ {
+ switch(m_eTypeKind)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ aValue = DBTypeConversion::toDateTime(getString());
+ break;
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ aValue = DBTypeConversion::toDateTime((double)*this);
+ break;
+ case DataType::FLOAT:
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ aValue = DBTypeConversion::toDateTime((double)*this);
+ break;
+ case DataType::DATE:
+ {
+ ::com::sun::star::util::Date* pDate = static_cast< ::com::sun::star::util::Date*>(m_aValue.m_pValue);
+ aValue.Day = pDate->Day;
+ aValue.Month = pDate->Month;
+ aValue.Year = pDate->Year;
+ }
+ break;
+ case DataType::TIME:
+ {
+ ::com::sun::star::util::Time* pTime = static_cast< ::com::sun::star::util::Time*>(m_aValue.m_pValue);
+ aValue.HundredthSeconds = pTime->HundredthSeconds;
+ aValue.Seconds = pTime->Seconds;
+ aValue.Minutes = pTime->Minutes;
+ aValue.Hours = pTime->Hours;
+ }
+ break;
+ case DataType::TIMESTAMP:
+ aValue = *static_cast< ::com::sun::star::util::DateTime*>(m_aValue.m_pValue);
+ break;
+ default:
+ {
+ Any aAnyValue = getAny();
+ aAnyValue >>= aValue;
+ break;
+ }
+ }
+ }
+ return aValue;
+}
+// -----------------------------------------------------------------------------
+void ORowSetValue::setSigned(sal_Bool _bMod)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::setSigned" );
+ if ( m_bSigned != _bMod )
+ {
+ m_bSigned = _bMod;
+ if ( !m_bNull )
+ {
+ sal_Int32 nType = m_eTypeKind;
+ switch(m_eTypeKind)
+ {
+ case DataType::BIGINT:
+ if ( m_bSigned ) // now we are signed, so we were unsigned and need to call getString()
+ {
+ m_bSigned = !m_bSigned;
+ const ::rtl::OUString sValue = getString();
+ free();
+ m_bSigned = !m_bSigned;
+ (*this) = sValue;
+ }
+ else
+ {
+ m_bSigned = !m_bSigned;
+ const sal_Int64 nValue = getLong();
+ free();
+ m_bSigned = !m_bSigned;
+ (*this) = nValue;
+ }
+ break;
+ case DataType::TINYINT:
+ if ( m_bSigned )
+ (*this) = getInt8();
+ else
+ {
+ m_bSigned = !m_bSigned;
+ (*this) = getInt16();
+ m_bSigned = !m_bSigned;
+ }
+ break;
+ case DataType::SMALLINT:
+ if ( m_bSigned )
+ (*this) = getInt16();
+ else
+ {
+ m_bSigned = !m_bSigned;
+ (*this) = getInt32();
+ m_bSigned = !m_bSigned;
+ }
+ break;
+ case DataType::INTEGER:
+ if ( m_bSigned )
+ (*this) = getInt32();
+ else
+ {
+ m_bSigned = !m_bSigned;
+ (*this) = getLong();
+ m_bSigned = !m_bSigned;
+ }
+ break;
+ }
+ m_eTypeKind = nType;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+namespace detail
+{
+ class SAL_NO_VTABLE IValueSource
+ {
+ public:
+ virtual ::rtl::OUString getString() const = 0;
+ virtual sal_Bool getBoolean() const = 0;
+ virtual sal_Int8 getByte() const = 0;
+ virtual sal_Int16 getShort() const = 0;
+ virtual sal_Int32 getInt() const = 0;
+ virtual sal_Int64 getLong() const = 0;
+ virtual float getFloat() const = 0;
+ virtual double getDouble() const = 0;
+ virtual Date getDate() const = 0;
+ virtual Time getTime() const = 0;
+ virtual DateTime getTimestamp() const = 0;
+ virtual Sequence< sal_Int8 > getBytes() const = 0;
+ virtual Reference< XInputStream > getBinaryStream() const = 0;
+ virtual Reference< XInputStream > getCharacterStream() const = 0;
+ virtual Reference< XBlob > getBlob() const = 0;
+ virtual Reference< XClob > getClob() const = 0;
+ virtual Any getObject() const = 0;
+ virtual sal_Bool wasNull() const = 0;
+
+ virtual ~IValueSource() { }
+ };
+
+ class RowValue : public IValueSource
+ {
+ public:
+ RowValue( const Reference< XRow >& _xRow, const sal_Int32 _nPos )
+ :m_xRow( _xRow )
+ ,m_nPos( _nPos )
+ {
+ }
+
+ // IValueSource
+ virtual ::rtl::OUString getString() const { return m_xRow->getString( m_nPos ); };
+ virtual sal_Bool getBoolean() const { return m_xRow->getBoolean( m_nPos ); };
+ virtual sal_Int8 getByte() const { return m_xRow->getByte( m_nPos ); };
+ virtual sal_Int16 getShort() const { return m_xRow->getShort( m_nPos ); }
+ virtual sal_Int32 getInt() const { return m_xRow->getInt( m_nPos ); }
+ virtual sal_Int64 getLong() const { return m_xRow->getLong( m_nPos ); }
+ virtual float getFloat() const { return m_xRow->getFloat( m_nPos ); };
+ virtual double getDouble() const { return m_xRow->getDouble( m_nPos ); };
+ virtual Date getDate() const { return m_xRow->getDate( m_nPos ); };
+ virtual Time getTime() const { return m_xRow->getTime( m_nPos ); };
+ virtual DateTime getTimestamp() const { return m_xRow->getTimestamp( m_nPos ); };
+ virtual Sequence< sal_Int8 > getBytes() const { return m_xRow->getBytes( m_nPos ); };
+ virtual Reference< XInputStream > getBinaryStream() const { return m_xRow->getBinaryStream( m_nPos ); };
+ virtual Reference< XInputStream > getCharacterStream() const { return m_xRow->getCharacterStream( m_nPos ); };
+ virtual Reference< XBlob > getBlob() const { return m_xRow->getBlob( m_nPos ); };
+ virtual Reference< XClob > getClob() const { return m_xRow->getClob( m_nPos ); };
+ virtual Any getObject() const { return m_xRow->getObject( m_nPos ,NULL); };
+ virtual sal_Bool wasNull() const { return m_xRow->wasNull( ); };
+
+ private:
+ const Reference< XRow > m_xRow;
+ const sal_Int32 m_nPos;
+ };
+
+ class ColumnValue : public IValueSource
+ {
+ public:
+ ColumnValue( const Reference< XColumn >& _rxColumn )
+ :m_xColumn( _rxColumn )
+ {
+ }
+
+ // IValueSource
+ virtual ::rtl::OUString getString() const { return m_xColumn->getString(); };
+ virtual sal_Bool getBoolean() const { return m_xColumn->getBoolean(); };
+ virtual sal_Int8 getByte() const { return m_xColumn->getByte(); };
+ virtual sal_Int16 getShort() const { return m_xColumn->getShort(); }
+ virtual sal_Int32 getInt() const { return m_xColumn->getInt(); }
+ virtual sal_Int64 getLong() const { return m_xColumn->getLong(); }
+ virtual float getFloat() const { return m_xColumn->getFloat(); };
+ virtual double getDouble() const { return m_xColumn->getDouble(); };
+ virtual Date getDate() const { return m_xColumn->getDate(); };
+ virtual Time getTime() const { return m_xColumn->getTime(); };
+ virtual DateTime getTimestamp() const { return m_xColumn->getTimestamp(); };
+ virtual Sequence< sal_Int8 > getBytes() const { return m_xColumn->getBytes(); };
+ virtual Reference< XInputStream > getBinaryStream() const { return m_xColumn->getBinaryStream(); };
+ virtual Reference< XInputStream > getCharacterStream() const { return m_xColumn->getCharacterStream(); };
+ virtual Reference< XBlob > getBlob() const { return m_xColumn->getBlob(); };
+ virtual Reference< XClob > getClob() const { return m_xColumn->getClob(); };
+ virtual Any getObject() const { return m_xColumn->getObject( NULL ); };
+ virtual sal_Bool wasNull() const { return m_xColumn->wasNull( ); };
+
+ private:
+ const Reference< XColumn > m_xColumn;
+ };
+}
+
+// -----------------------------------------------------------------------------
+void ORowSetValue::fill( const sal_Int32 _nType, const Reference< XColumn >& _rxColumn )
+{
+ detail::ColumnValue aColumnValue( _rxColumn );
+ impl_fill( _nType, sal_True, aColumnValue );
+}
+
+// -----------------------------------------------------------------------------
+void ORowSetValue::fill( sal_Int32 _nPos, sal_Int32 _nType, sal_Bool _bNullable, const Reference< XRow>& _xRow )
+{
+ detail::RowValue aRowValue( _xRow, _nPos );
+ impl_fill( _nType, _bNullable, aRowValue );
+}
+
+// -----------------------------------------------------------------------------
+void ORowSetValue::fill(sal_Int32 _nPos,
+ sal_Int32 _nType,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow>& _xRow)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::fill (1)" );
+ fill(_nPos,_nType,sal_True,_xRow);
+}
+
+// -----------------------------------------------------------------------------
+void ORowSetValue::impl_fill( const sal_Int32 _nType, sal_Bool _bNullable, const detail::IValueSource& _rValueSource )
+
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::fill (2)" );
+ sal_Bool bReadData = sal_True;
+ switch(_nType)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::LONGVARCHAR:
+ (*this) = _rValueSource.getString();
+ break;
+ case DataType::BIGINT:
+ if ( isSigned() )
+ (*this) = _rValueSource.getLong();
+ else
+ (*this) = _rValueSource.getString();
+ break;
+ case DataType::FLOAT:
+ (*this) = _rValueSource.getFloat();
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ (*this) = _rValueSource.getDouble();
+ break;
+ case DataType::DATE:
+ (*this) = _rValueSource.getDate();
+ break;
+ case DataType::TIME:
+ (*this) = _rValueSource.getTime();
+ break;
+ case DataType::TIMESTAMP:
+ (*this) = _rValueSource.getTimestamp();
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ (*this) = _rValueSource.getBytes();
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ (*this) = _rValueSource.getBoolean();
+ break;
+ case DataType::TINYINT:
+ if ( isSigned() )
+ (*this) = _rValueSource.getByte();
+ else
+ (*this) = _rValueSource.getShort();
+ break;
+ case DataType::SMALLINT:
+ if ( isSigned() )
+ (*this) = _rValueSource.getShort();
+ else
+ (*this) = _rValueSource.getInt();
+ break;
+ case DataType::INTEGER:
+ if ( isSigned() )
+ (*this) = _rValueSource.getInt();
+ else
+ (*this) = _rValueSource.getLong();
+ break;
+ case DataType::CLOB:
+ (*this) = ::com::sun::star::uno::makeAny(_rValueSource.getClob());
+ setTypeKind(DataType::CLOB);
+ break;
+ case DataType::BLOB:
+ (*this) = ::com::sun::star::uno::makeAny(_rValueSource.getBlob());
+ setTypeKind(DataType::BLOB);
+ break;
+ case DataType::OTHER:
+ (*this) = _rValueSource.getObject();
+ setTypeKind(DataType::OTHER);
+ break;
+ default:
+ OSL_ENSURE( false, "ORowSetValue::fill: unsupported type!" );
+ (*this) = _rValueSource.getObject();
+ break;
+ }
+ if ( bReadData && _bNullable && _rValueSource.wasNull() )
+ setNull();
+ setTypeKind(_nType);
+}
+// -----------------------------------------------------------------------------
+void ORowSetValue::fill(const Any& _rValue)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::fill (3)" );
+ switch (_rValue.getValueType().getTypeClass())
+ {
+ case TypeClass_VOID:
+ setNull();
+ break;
+ case TypeClass_BOOLEAN:
+ {
+ sal_Bool bValue( sal_False );
+ _rValue >>= bValue;
+ (*this) = bValue;
+ break;
+ }
+ case TypeClass_CHAR:
+ {
+ sal_Unicode aDummy(0);
+ _rValue >>= aDummy;
+ (*this) = ::rtl::OUString(aDummy);
+ break;
+ }
+ case TypeClass_STRING:
+ {
+ ::rtl::OUString sDummy;
+ _rValue >>= sDummy;
+ (*this) = sDummy;
+ break;
+ }
+ case TypeClass_FLOAT:
+ {
+ float aDummy(0.0);
+ _rValue >>= aDummy;
+ (*this) = aDummy;
+ break;
+ }
+ case TypeClass_DOUBLE:
+ {
+ double aDummy(0.0);
+ _rValue >>= aDummy;
+ (*this) = aDummy;
+ break;
+ }
+ case TypeClass_BYTE:
+ {
+ sal_Int8 aDummy(0);
+ _rValue >>= aDummy;
+ (*this) = aDummy;
+ break;
+ }
+ case TypeClass_SHORT:
+ {
+ sal_Int16 aDummy(0);
+ _rValue >>= aDummy;
+ (*this) = aDummy;
+ break;
+ }
+ case TypeClass_LONG:
+ {
+ sal_Int32 aDummy(0);
+ _rValue >>= aDummy;
+ (*this) = aDummy;
+ break;
+ }
+ case TypeClass_UNSIGNED_SHORT:
+ {
+ sal_uInt16 nValue(0);
+ _rValue >>= nValue;
+ (*this) = static_cast<sal_Int32>(nValue);
+ setSigned(sal_False);
+ break;
+ }
+ case TypeClass_HYPER:
+ {
+ sal_Int64 nValue(0);
+ _rValue >>= nValue;
+ (*this) = nValue;
+ break;
+ }
+ case TypeClass_UNSIGNED_HYPER:
+ {
+ sal_uInt64 nValue(0);
+ _rValue >>= nValue;
+ (*this) = static_cast<sal_Int64>(nValue);
+ setSigned(sal_False);
+ break;
+ }
+ case TypeClass_UNSIGNED_LONG:
+ {
+ sal_uInt32 nValue(0);
+ _rValue >>= nValue;
+ (*this) = static_cast<sal_Int64>(nValue);
+ setSigned(sal_False);
+ break;
+ }
+ case TypeClass_ENUM:
+ {
+ sal_Int32 enumValue( 0 );
+ ::cppu::enum2int( enumValue, _rValue );
+ (*this) = enumValue;
+ }
+ break;
+
+ case TypeClass_SEQUENCE:
+ {
+ Sequence<sal_Int8> aDummy;
+ if ( _rValue >>= aDummy )
+ (*this) = aDummy;
+ else
+ OSL_ENSURE( false, "ORowSetValue::fill: unsupported sequence type!" );
+ break;
+ }
+
+ case TypeClass_STRUCT:
+ {
+ ::com::sun::star::util::Date aDate;
+ ::com::sun::star::util::Time aTime;
+ ::com::sun::star::util::DateTime aDateTime;
+ if ( _rValue >>= aDate )
+ {
+ (*this) = aDate;
+ }
+ else if ( _rValue >>= aTime )
+ {
+ (*this) = aTime;
+ }
+ else if ( _rValue >>= aDateTime )
+ {
+ (*this) = aDateTime;
+ }
+ else
+ OSL_ENSURE( false, "ORowSetValue::fill: unsupported structure!" );
+
+ break;
+ }
+ case TypeClass_INTERFACE:
+ {
+ Reference< XClob > xClob;
+ if ( _rValue >>= xClob )
+ {
+ (*this) = _rValue;
+ setTypeKind(DataType::CLOB);
+ }
+ else
+ {
+ Reference< XBlob > xBlob;
+ if ( _rValue >>= xBlob )
+ {
+ (*this) = _rValue;
+ setTypeKind(DataType::BLOB);
+ }
+ else
+ {
+ (*this) = _rValue;
+ }
+ }
+ }
+ break;
+
+ default:
+ OSL_ENSURE(0,"Unknown type");
+ break;
+ }
+}
+
+} // namespace connectivity
diff --git a/connectivity/source/commontools/ParamterSubstitution.cxx b/connectivity/source/commontools/ParamterSubstitution.cxx
new file mode 100644
index 000000000000..df76724aa008
--- /dev/null
+++ b/connectivity/source/commontools/ParamterSubstitution.cxx
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "precompiled_connectivity.hxx"
+#include "ParameterSubstitution.hxx"
+#include "connectivity/sqlparse.hxx"
+#include <comphelper/sequenceashashmap.hxx>
+
+namespace connectivity
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star;
+
+ ParameterSubstitution::ParameterSubstitution(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext ) : m_xContext(_rxContext)
+ {
+ }
+ void SAL_CALL ParameterSubstitution::initialize( const uno::Sequence< uno::Any >& _aArguments ) throw (uno::Exception, uno::RuntimeException)
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+ comphelper::SequenceAsHashMap aArgs(_aArguments);
+ uno::Reference< sdbc::XConnection > xConnection;
+ xConnection = aArgs.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ActiveConnection")),xConnection);
+ m_xConnection = xConnection;
+ }
+ //------------------------------------------------------------------------------
+ rtl::OUString ParameterSubstitution::getImplementationName_Static( ) throw(RuntimeException)
+ {
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.helper.ParameterSubstitution"));
+ }
+ //------------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ParameterSubstitution::getImplementationName( ) throw(RuntimeException)
+ {
+ return getImplementationName_Static();
+ }
+ //------------------------------------------------------------------
+ sal_Bool SAL_CALL ParameterSubstitution::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 ParameterSubstitution::getSupportedServiceNames( ) throw(RuntimeException)
+ {
+ return getSupportedServiceNames_Static();
+ }
+ //------------------------------------------------------------------
+ Sequence< ::rtl::OUString > ParameterSubstitution::getSupportedServiceNames_Static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.ParameterSubstitution");
+ return aSNS;
+ }
+
+ //------------------------------------------------------------------
+ Reference< XInterface > ParameterSubstitution::create(const Reference< XComponentContext >& _xContext)
+ {
+ return *(new ParameterSubstitution(_xContext));
+ }
+ //------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ParameterSubstitution::substituteVariables( const ::rtl::OUString& _sText, ::sal_Bool /*bSubstRequired*/ ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException)
+ {
+ ::rtl::OUString sRet = _sText;
+ uno::Reference< sdbc::XConnection > xConnection = m_xConnection;
+ if ( xConnection.is() )
+ {
+ try
+ {
+ uno::Reference< XMultiServiceFactory> xFac(m_xContext->getServiceManager(),uno::UNO_QUERY_THROW);
+ OSQLParser aParser( xFac );
+ ::rtl::OUString sErrorMessage;
+ ::rtl::OUString sNewSql;
+ OSQLParseNode* pNode = aParser.parseTree(sErrorMessage,_sText);
+ if(pNode)
+ { // special handling for parameters
+ OSQLParseNode::substituteParameterNames(pNode);
+ pNode->parseNodeToStr( sNewSql, xConnection );
+ delete pNode;
+ sRet = sNewSql;
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+ return sRet;
+ }
+ //------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ParameterSubstitution::reSubstituteVariables( const ::rtl::OUString& _sText ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ return _sText;
+ }
+ //------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ParameterSubstitution::getSubstituteVariableValue( const ::rtl::OUString& /*variable*/ ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException)
+ {
+ throw container::NoSuchElementException();
+ }
+ //------------------------------------------------------------------
+
+
+// ==================================
+} // connectivity
+// ==================================
diff --git a/connectivity/source/commontools/RowFunctionParser.cxx b/connectivity/source/commontools/RowFunctionParser.cxx
new file mode 100644
index 000000000000..3804ddfb259f
--- /dev/null
+++ b/connectivity/source/commontools/RowFunctionParser.cxx
@@ -0,0 +1,499 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+// Makes parser a static resource,
+// we're synchronized externally.
+// But watch out, the parser might have
+// state not visible to this code!
+#define BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE
+#if defined(VERBOSE) && defined(DBG_UTIL)
+#include <typeinfo>
+#define BOOST_SPIRIT_DEBUG
+#endif
+#include <boost/spirit/include/classic_core.hpp>
+#include "RowFunctionParser.hxx"
+#include <rtl/ustring.hxx>
+#include <tools/fract.hxx>
+
+
+
+#if (OSL_DEBUG_LEVEL > 0)
+#include <iostream>
+#endif
+#include <functional>
+#include <algorithm>
+#include <stack>
+
+namespace connectivity
+{
+using namespace com::sun::star;
+
+namespace
+{
+//////////////////////
+//////////////////////
+// EXPRESSION NODES
+//////////////////////
+//////////////////////
+class ConstantValueExpression : public ExpressionNode
+{
+ ORowSetValueDecoratorRef maValue;
+
+public:
+
+ ConstantValueExpression( ORowSetValueDecoratorRef rValue ) :
+ maValue( rValue )
+ {
+ }
+ virtual ORowSetValueDecoratorRef evaluate(const ODatabaseMetaDataResultSet::ORow& /*_aRow*/ ) const
+ {
+ return maValue;
+ }
+ virtual void fill(const ODatabaseMetaDataResultSet::ORow& /*_aRow*/ ) const
+ {
+ }
+ virtual ExpressionFunct getType() const
+ {
+ return FUNC_CONST;
+ }
+ virtual ODatabaseMetaDataResultSet::ORow fillNode( std::vector< RowEquation >& /*rEquations*/, ExpressionNode* /* pOptionalArg */, sal_uInt32 /* nFlags */ )
+ {
+ ODatabaseMetaDataResultSet::ORow aRet;
+ return aRet;
+ }
+};
+
+
+/** ExpressionNode implementation for unary
+ function over two ExpressionNodes
+ */
+class BinaryFunctionExpression : public ExpressionNode
+{
+ const ExpressionFunct meFunct;
+ ExpressionNodeSharedPtr mpFirstArg;
+ ExpressionNodeSharedPtr mpSecondArg;
+
+public:
+
+ BinaryFunctionExpression( const ExpressionFunct eFunct, const ExpressionNodeSharedPtr& rFirstArg, const ExpressionNodeSharedPtr& rSecondArg ) :
+ meFunct( eFunct ),
+ mpFirstArg( rFirstArg ),
+ mpSecondArg( rSecondArg )
+ {
+ }
+ virtual ORowSetValueDecoratorRef evaluate(const ODatabaseMetaDataResultSet::ORow& _aRow ) const
+ {
+ ORowSetValueDecoratorRef aRet;
+ switch(meFunct)
+ {
+ case ENUM_FUNC_EQUATION:
+ aRet = new ORowSetValueDecorator(sal_Bool(mpFirstArg->evaluate(_aRow )->getValue() == mpSecondArg->evaluate(_aRow )->getValue()) );
+ break;
+ case ENUM_FUNC_AND:
+ aRet = new ORowSetValueDecorator( sal_Bool(mpFirstArg->evaluate(_aRow )->getValue().getBool() && mpSecondArg->evaluate(_aRow )->getValue().getBool()) );
+ break;
+ case ENUM_FUNC_OR:
+ aRet = new ORowSetValueDecorator( sal_Bool(mpFirstArg->evaluate(_aRow )->getValue().getBool() || mpSecondArg->evaluate(_aRow )->getValue().getBool()) );
+ break;
+ default:
+ break;
+ }
+ return aRet;
+ }
+ virtual void fill(const ODatabaseMetaDataResultSet::ORow& _aRow ) const
+ {
+ switch(meFunct)
+ {
+ case ENUM_FUNC_EQUATION:
+ (*mpFirstArg->evaluate(_aRow )) = mpSecondArg->evaluate(_aRow )->getValue();
+ break;
+ default:
+ break;
+ }
+ }
+ virtual ExpressionFunct getType() const
+ {
+ return meFunct;
+ }
+ virtual ODatabaseMetaDataResultSet::ORow fillNode( std::vector< RowEquation >& /*rEquations*/, ExpressionNode* /*pOptionalArg*/, sal_uInt32 /*nFlags*/ )
+ {
+ ODatabaseMetaDataResultSet::ORow aRet;
+ return aRet;
+ }
+};
+
+
+////////////////////////
+////////////////////////
+// FUNCTION PARSER
+////////////////////////
+////////////////////////
+
+typedef const sal_Char* StringIteratorT;
+
+struct ParserContext
+{
+ typedef ::std::stack< ExpressionNodeSharedPtr > OperandStack;
+
+ // stores a stack of not-yet-evaluated operands. This is used
+ // by the operators (i.e. '+', '*', 'sin' etc.) to pop their
+ // arguments from. If all arguments to an operator are constant,
+ // the operator pushes a precalculated result on the stack, and
+ // a composite ExpressionNode otherwise.
+ OperandStack maOperandStack;
+};
+
+typedef ::boost::shared_ptr< ParserContext > ParserContextSharedPtr;
+
+/** Generate apriori constant value
+ */
+
+class ConstantFunctor
+{
+ ParserContextSharedPtr mpContext;
+
+public:
+
+ ConstantFunctor( const ParserContextSharedPtr& rContext ) :
+ mpContext( rContext )
+ {
+ }
+ void operator()( StringIteratorT rFirst,StringIteratorT rSecond) const
+ {
+ rtl::OUString sVal( rFirst, rSecond - rFirst, RTL_TEXTENCODING_UTF8 );
+ mpContext->maOperandStack.push( ExpressionNodeSharedPtr( new ConstantValueExpression( new ORowSetValueDecorator( sVal ) ) ) );
+ }
+};
+
+/** Generate parse-dependent-but-then-constant value
+ */
+class IntConstantFunctor
+{
+ ParserContextSharedPtr mpContext;
+
+public:
+ IntConstantFunctor( const ParserContextSharedPtr& rContext ) :
+ mpContext( rContext )
+ {
+ }
+ void operator()( sal_Int32 n ) const
+ {
+ mpContext->maOperandStack.push( ExpressionNodeSharedPtr( new ConstantValueExpression( new ORowSetValueDecorator( n ) ) ) );
+ }
+ void operator()( StringIteratorT rFirst,StringIteratorT rSecond) const
+ {
+ rtl::OUString sVal( rFirst, rSecond - rFirst, RTL_TEXTENCODING_UTF8 );
+ (void)sVal;
+ }
+};
+
+/** Implements a binary function over two ExpressionNodes
+
+ @tpl Generator
+ Generator functor, to generate an ExpressionNode of
+ appropriate type
+
+ */
+class BinaryFunctionFunctor
+{
+ const ExpressionFunct meFunct;
+ ParserContextSharedPtr mpContext;
+
+public:
+
+ BinaryFunctionFunctor( const ExpressionFunct eFunct, const ParserContextSharedPtr& rContext ) :
+ meFunct( eFunct ),
+ mpContext( rContext )
+ {
+ }
+
+ void operator()( StringIteratorT, StringIteratorT ) const
+ {
+ ParserContext::OperandStack& rNodeStack( mpContext->maOperandStack );
+
+ if( rNodeStack.size() < 2 )
+ throw ParseError( "Not enough arguments for binary operator" );
+
+ // retrieve arguments
+ ExpressionNodeSharedPtr pSecondArg( rNodeStack.top() );
+ rNodeStack.pop();
+ ExpressionNodeSharedPtr pFirstArg( rNodeStack.top() );
+ rNodeStack.pop();
+
+ // create combined ExpressionNode
+ ExpressionNodeSharedPtr pNode = ExpressionNodeSharedPtr( new BinaryFunctionExpression( meFunct, pFirstArg, pSecondArg ) );
+ // check for constness
+ rNodeStack.push( pNode );
+ }
+};
+/** ExpressionNode implementation for unary
+ function over one ExpressionNode
+ */
+class UnaryFunctionExpression : public ExpressionNode
+{
+ const ExpressionFunct meFunct;
+ ExpressionNodeSharedPtr mpArg;
+
+public:
+ UnaryFunctionExpression( const ExpressionFunct eFunct, const ExpressionNodeSharedPtr& rArg ) :
+ meFunct( eFunct ),
+ mpArg( rArg )
+ {
+ }
+ virtual ORowSetValueDecoratorRef evaluate(const ODatabaseMetaDataResultSet::ORow& _aRow ) const
+ {
+ return _aRow[mpArg->evaluate(_aRow )->getValue().getInt32()];
+ }
+ virtual void fill(const ODatabaseMetaDataResultSet::ORow& /*_aRow*/ ) const
+ {
+ }
+ virtual ExpressionFunct getType() const
+ {
+ return meFunct;
+ }
+ virtual ODatabaseMetaDataResultSet::ORow fillNode( std::vector< RowEquation >& /*rEquations*/, ExpressionNode* /* pOptionalArg */, sal_uInt32 /* nFlags */ )
+ {
+ ODatabaseMetaDataResultSet::ORow aRet;
+ return aRet;
+ }
+};
+
+class UnaryFunctionFunctor
+{
+ const ExpressionFunct meFunct;
+ ParserContextSharedPtr mpContext;
+
+public :
+
+ UnaryFunctionFunctor( const ExpressionFunct eFunct, const ParserContextSharedPtr& rContext ) :
+ meFunct( eFunct ),
+ mpContext( rContext )
+ {
+ }
+ void operator()( StringIteratorT, StringIteratorT ) const
+ {
+
+ ParserContext::OperandStack& rNodeStack( mpContext->maOperandStack );
+
+ if( rNodeStack.size() < 1 )
+ throw ParseError( "Not enough arguments for unary operator" );
+
+ // retrieve arguments
+ ExpressionNodeSharedPtr pArg( rNodeStack.top() );
+ rNodeStack.pop();
+
+ rNodeStack.push( ExpressionNodeSharedPtr( new UnaryFunctionExpression( meFunct, pArg ) ) );
+ }
+};
+
+/* This class implements the following grammar (more or
+ less literally written down below, only slightly
+ obfuscated by the parser actions):
+
+ basic_expression =
+ number |
+ '(' additive_expression ')'
+
+ unary_expression =
+ basic_expression
+
+ multiplicative_expression =
+ unary_expression ( ( '*' unary_expression )* |
+ ( '/' unary_expression )* )
+
+ additive_expression =
+ multiplicative_expression ( ( '+' multiplicative_expression )* |
+ ( '-' multiplicative_expression )* )
+
+ */
+class ExpressionGrammar : public ::boost::spirit::grammar< ExpressionGrammar >
+{
+public:
+ /** Create an arithmetic expression grammar
+
+ @param rParserContext
+ Contains context info for the parser
+ */
+ ExpressionGrammar( const ParserContextSharedPtr& rParserContext ) :
+ mpParserContext( rParserContext )
+ {
+ }
+
+ template< typename ScannerT > class definition
+ {
+ public:
+ // grammar definition
+ definition( const ExpressionGrammar& self )
+ {
+ using ::boost::spirit::str_p;
+ using ::boost::spirit::space_p;
+ using ::boost::spirit::range_p;
+ using ::boost::spirit::lexeme_d;
+ using ::boost::spirit::real_parser;
+ using ::boost::spirit::chseq_p;
+ using ::boost::spirit::ch_p;
+ using ::boost::spirit::int_p;
+ using ::boost::spirit::as_lower_d;
+ using ::boost::spirit::strlit;
+ using ::boost::spirit::inhibit_case;
+
+
+ typedef inhibit_case<strlit<> > token_t;
+ token_t COLUMN = as_lower_d[ "column" ];
+ token_t OR_ = as_lower_d[ "or" ];
+ token_t AND_ = as_lower_d[ "and" ];
+
+ integer =
+ int_p
+ [IntConstantFunctor(self.getContext())];
+
+ argument =
+ integer
+ | lexeme_d[ +( range_p('a','z') | range_p('A','Z') | range_p('0','9') ) ]
+ [ ConstantFunctor(self.getContext()) ]
+ ;
+
+ unaryFunction =
+ (COLUMN >> '(' >> integer >> ')' )
+ [ UnaryFunctionFunctor( UNARY_FUNC_COLUMN, self.getContext()) ]
+ ;
+
+ assignment =
+ unaryFunction >> ch_p('=') >> argument
+ [ BinaryFunctionFunctor( ENUM_FUNC_EQUATION, self.getContext()) ]
+ ;
+
+ andExpression =
+ assignment
+ | ( '(' >> orExpression >> ')' )
+ | ( assignment >> AND_ >> assignment ) [ BinaryFunctionFunctor( ENUM_FUNC_AND, self.getContext()) ]
+ ;
+
+ orExpression =
+ andExpression
+ | ( orExpression >> OR_ >> andExpression ) [ BinaryFunctionFunctor( ENUM_FUNC_OR, self.getContext()) ]
+ ;
+
+ basicExpression =
+ orExpression
+ ;
+
+ BOOST_SPIRIT_DEBUG_RULE(basicExpression);
+ BOOST_SPIRIT_DEBUG_RULE(unaryFunction);
+ BOOST_SPIRIT_DEBUG_RULE(assignment);
+ BOOST_SPIRIT_DEBUG_RULE(argument);
+ BOOST_SPIRIT_DEBUG_RULE(integer);
+ BOOST_SPIRIT_DEBUG_RULE(orExpression);
+ BOOST_SPIRIT_DEBUG_RULE(andExpression);
+ }
+
+ const ::boost::spirit::rule< ScannerT >& start() const
+ {
+ return basicExpression;
+ }
+
+ private:
+ // the constituents of the Spirit arithmetic expression grammar.
+ // For the sake of readability, without 'ma' prefix.
+ ::boost::spirit::rule< ScannerT > basicExpression;
+ ::boost::spirit::rule< ScannerT > unaryFunction;
+ ::boost::spirit::rule< ScannerT > assignment;
+ ::boost::spirit::rule< ScannerT > integer,argument;
+ ::boost::spirit::rule< ScannerT > orExpression,andExpression;
+ };
+
+ const ParserContextSharedPtr& getContext() const
+ {
+ return mpParserContext;
+ }
+
+private:
+ ParserContextSharedPtr mpParserContext; // might get modified during parsing
+};
+
+#ifdef BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE
+const ParserContextSharedPtr& getParserContext()
+{
+ static ParserContextSharedPtr lcl_parserContext( new ParserContext() );
+
+ // clear node stack (since we reuse the static object, that's
+ // the whole point here)
+ while( !lcl_parserContext->maOperandStack.empty() )
+ lcl_parserContext->maOperandStack.pop();
+
+ return lcl_parserContext;
+}
+#endif
+}
+
+ExpressionNodeSharedPtr FunctionParser::parseFunction( const ::rtl::OUString& _sFunction)
+{
+ // TODO(Q1): Check if a combination of the RTL_UNICODETOTEXT_FLAGS_*
+ // gives better conversion robustness here (we might want to map space
+ // etc. to ASCII space here)
+ const ::rtl::OString& rAsciiFunction(
+ rtl::OUStringToOString( _sFunction, RTL_TEXTENCODING_ASCII_US ) );
+
+ StringIteratorT aStart( rAsciiFunction.getStr() );
+ StringIteratorT aEnd( rAsciiFunction.getStr()+rAsciiFunction.getLength() );
+
+ ParserContextSharedPtr pContext;
+
+#ifdef BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE
+ // static parser context, because the actual
+ // Spirit parser is also a static object
+ pContext = getParserContext();
+#else
+ pContext.reset( new ParserContext() );
+#endif
+
+ ExpressionGrammar aExpressionGrammer( pContext );
+
+ const ::boost::spirit::parse_info<StringIteratorT> aParseInfo(
+ ::boost::spirit::parse( aStart,
+ aEnd,
+ aExpressionGrammer,
+ ::boost::spirit::space_p ) );
+
+ OSL_DEBUG_ONLY(::std::cout.flush()); // needed to keep stdout and cout in sync
+
+ // input fully congested by the parser?
+ if( !aParseInfo.full )
+ throw ParseError( "RowFunctionParser::parseFunction(): string not fully parseable" );
+
+ // parser's state stack now must contain exactly _one_ ExpressionNode,
+ // which represents our formula.
+ if( pContext->maOperandStack.size() != 1 )
+ throw ParseError( "RowFunctionParser::parseFunction(): incomplete or empty expression" );
+
+ return pContext->maOperandStack.top();
+}
+}
+
diff --git a/connectivity/source/commontools/TColumnsHelper.cxx b/connectivity/source/commontools/TColumnsHelper.cxx
new file mode 100644
index 000000000000..325fcfbd0f42
--- /dev/null
+++ b/connectivity/source/commontools/TColumnsHelper.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 "connectivity/TColumnsHelper.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 <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <comphelper/types.hxx>
+#include "connectivity/dbtools.hxx"
+#include "TConnection.hxx"
+#include "connectivity/TTableHelper.hxx"
+#include <comphelper/property.hxx>
+
+using namespace ::comphelper;
+
+
+using namespace connectivity::sdbcx;
+using namespace connectivity;
+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;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+namespace connectivity
+{
+ class OColumnsHelperImpl
+ {
+ public:
+ OColumnsHelperImpl(sal_Bool _bCase)
+ : m_aColumnInfo(_bCase)
+ {
+ }
+ ColumnInformationMap m_aColumnInfo;
+ };
+}
+
+OColumnsHelper::OColumnsHelper( ::cppu::OWeakObject& _rParent
+ ,sal_Bool _bCase
+ ,::osl::Mutex& _rMutex
+ ,const TStringVector &_rVector
+ ,sal_Bool _bUseHardRef
+ ) : OCollection(_rParent,_bCase,_rMutex,_rVector,sal_False,_bUseHardRef)
+ ,m_pImpl(NULL)
+ ,m_pTable(NULL)
+{
+}
+// -----------------------------------------------------------------------------
+OColumnsHelper::~OColumnsHelper()
+{
+ delete m_pImpl;
+ m_pImpl = NULL;
+}
+// -----------------------------------------------------------------------------
+
+sdbcx::ObjectType OColumnsHelper::createObject(const ::rtl::OUString& _rName)
+{
+ OSL_ENSURE(m_pTable,"NO Table set. Error!");
+ Reference<XConnection> xConnection = m_pTable->getConnection();
+
+ if ( !m_pImpl )
+ m_pImpl = new OColumnsHelperImpl(isCaseSensitive());
+
+ sal_Bool bQueryInfo = sal_True;
+ sal_Bool bAutoIncrement = sal_False;
+ sal_Bool bIsCurrency = sal_False;
+ sal_Int32 nDataType = DataType::OTHER;
+
+ ColumnInformationMap::iterator aFind = m_pImpl->m_aColumnInfo.find(_rName);
+ if ( aFind == m_pImpl->m_aColumnInfo.end() ) // we have to fill it
+ {
+ ::rtl::OUString sComposedName = ::dbtools::composeTableNameForSelect( xConnection, m_pTable );
+ collectColumnInformation(xConnection,sComposedName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*")) ,m_pImpl->m_aColumnInfo);
+ aFind = m_pImpl->m_aColumnInfo.find(_rName);
+ }
+ if ( aFind != m_pImpl->m_aColumnInfo.end() )
+ {
+ bQueryInfo = sal_False;
+ bAutoIncrement = aFind->second.first.first;
+ bIsCurrency = aFind->second.first.second;
+ nDataType = aFind->second.second;
+ } // if ( aFind != m_pImpl->m_aColumnInfo.end() )
+
+ sdbcx::ObjectType xRet;
+ const ColumnDesc* pColDesc = m_pTable->getColumnDescription(_rName);
+ if ( pColDesc )
+ {
+ Reference<XPropertySet> xPr = m_pTable;
+ const Reference<XNameAccess> xPrimaryKeyColumns = getPrimaryKeyColumns_throw(xPr);
+ sal_Int32 nField11 = pColDesc->nField11;
+ if ( nField11 != ColumnValue::NO_NULLS && xPrimaryKeyColumns.is() && xPrimaryKeyColumns->hasByName(_rName) )
+ {
+ nField11 = ColumnValue::NO_NULLS;
+ } // if ( xKeys.is() )
+ connectivity::sdbcx::OColumn* pRet = new connectivity::sdbcx::OColumn(_rName,
+ pColDesc->aField6,
+ pColDesc->sField13,
+ pColDesc->sField12,
+ nField11,
+ pColDesc->nField7,
+ pColDesc->nField9,
+ pColDesc->nField5,
+ bAutoIncrement,
+ sal_False,
+ bIsCurrency,
+ isCaseSensitive());
+
+ xRet = pRet;
+ }
+ else
+ {
+
+ xRet.set(::dbtools::createSDBCXColumn( m_pTable,
+ xConnection,
+ _rName,
+ isCaseSensitive(),
+ bQueryInfo,
+ bAutoIncrement,
+ bIsCurrency,
+ nDataType),UNO_QUERY);
+ }
+ return xRet;
+}
+
+// -------------------------------------------------------------------------
+void OColumnsHelper::impl_refresh() throw(RuntimeException)
+{
+ if ( m_pTable )
+ {
+ m_pImpl->m_aColumnInfo.clear();
+ m_pTable->refreshColumns();
+ }
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OColumnsHelper::createDescriptor()
+{
+ return new OColumn(sal_True);
+}
+// -----------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OColumnsHelper::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+ OSL_ENSURE(m_pTable,"OColumnsHelper::appendByDescriptor: Table is null!");
+ if ( !m_pTable || m_pTable->isNew() )
+ return cloneDescriptor( descriptor );
+
+ Reference<XDatabaseMetaData> xMetaData = m_pTable->getConnection()->getMetaData();
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("ALTER TABLE ");
+ ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString( );
+
+ aSql += ::dbtools::composeTableName( xMetaData, m_pTable, ::dbtools::eInTableDefinitions, false, false, true );
+ aSql += ::rtl::OUString::createFromAscii(" ADD ");
+ aSql += ::dbtools::createStandardColumnPart(descriptor,m_pTable->getConnection(),NULL,m_pTable->getTypeCreatePattern());
+
+ Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
+ if ( xStmt.is() )
+ {
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OColumnsHelper::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
+{
+ OSL_ENSURE(m_pTable,"OColumnsHelper::dropByName: Table is null!");
+ if ( m_pTable && !m_pTable->isNew() )
+ {
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("ALTER TABLE ");
+ Reference<XDatabaseMetaData> xMetaData = m_pTable->getConnection()->getMetaData();
+ ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString( );
+
+ aSql += ::dbtools::composeTableName( xMetaData, m_pTable, ::dbtools::eInTableDefinitions, false, false, true );
+ aSql += ::rtl::OUString::createFromAscii(" DROP ");
+ aSql += ::dbtools::quoteName( aQuote,_sElementName);
+
+ Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
+ if ( xStmt.is() )
+ {
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/commontools/TConnection.cxx b/connectivity/source/commontools/TConnection.cxx
new file mode 100644
index 000000000000..7f471d739186
--- /dev/null
+++ b/connectivity/source/commontools/TConnection.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 "TConnection.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/types.hxx>
+#include <comphelper/officeresourcebundle.hxx>
+#include <connectivity/dbexception.hxx>
+
+using namespace connectivity;
+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 ::osl;
+
+//------------------------------------------------------------------------------
+OMetaConnection::OMetaConnection()
+ : OMetaConnection_BASE(m_aMutex)
+ , m_nTextEncoding(RTL_TEXTENCODING_MS_1252)
+{
+}
+//------------------------------------------------------------------------------
+void OMetaConnection::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ m_xMetaData = WeakReference< XDatabaseMetaData>();
+ for (OWeakRefArray::iterator i = m_aStatements.begin(); m_aStatements.end() != i; ++i)
+ {
+ try
+ {
+ Reference< XInterface > xStatement( i->get() );
+ ::comphelper::disposeComponent( xStatement );
+ }
+ catch (DisposedException)
+ {
+ }
+ }
+ m_aStatements.clear();
+}
+//XUnoTunnel
+sal_Int64 SAL_CALL OMetaConnection::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 )
+ : (sal_Int64)0;
+}
+// -----------------------------------------------------------------------------
+Sequence< sal_Int8 > OMetaConnection::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();
+}
+// -----------------------------------------------------------------------------
+::dbtools::OPropertyMap& OMetaConnection::getPropMap()
+{
+ static ::dbtools::OPropertyMap s_aPropertyNameMap;
+ return s_aPropertyNameMap;
+}
+// -----------------------------------------------------------------------------
+void OMetaConnection::throwGenericSQLException( sal_uInt16 _nErrorResourceId,const Reference< XInterface>& _xContext )
+{
+ ::rtl::OUString sErrorMessage;
+ if ( _nErrorResourceId )
+ sErrorMessage = m_aResources.getResourceString( _nErrorResourceId );
+ Reference< XInterface> xContext = _xContext;
+ if ( !xContext.is() )
+ xContext = *this;
+ ::dbtools::throwGenericSQLException( sErrorMessage, xContext);
+}
+
diff --git a/connectivity/source/commontools/TDatabaseMetaDataBase.cxx b/connectivity/source/commontools/TDatabaseMetaDataBase.cxx
new file mode 100644
index 000000000000..c0b2520b6cfb
--- /dev/null
+++ b/connectivity/source/commontools/TDatabaseMetaDataBase.cxx
@@ -0,0 +1,333 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "TDatabaseMetaDataBase.hxx"
+#include "RowFunctionParser.hxx"
+
+#include <comphelper/sequenceashashmap.hxx>
+#include <comphelper/evtlistenerhlp.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+#include "resource/sharedresources.hxx"
+#include "resource/common_res.hrc"
+#include <connectivity/dbexception.hxx>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace comphelper;
+using namespace connectivity;
+
+
+ODatabaseMetaDataBase::ODatabaseMetaDataBase(const Reference< XConnection >& _rxConnection,const Sequence< PropertyValue >& _rInfo)
+ : m_aConnectionInfo(_rInfo)
+ ,m_isCatalogAtStart(false,sal_False)
+ ,m_sCatalogSeparator(false,::rtl::OUString())
+ ,m_sIdentifierQuoteString(false,::rtl::OUString())
+ ,m_supportsCatalogsInTableDefinitions(false,sal_False)
+ ,m_supportsSchemasInTableDefinitions(false,sal_False)
+ ,m_supportsCatalogsInDataManipulation(false,sal_False)
+ ,m_supportsSchemasInDataManipulation(false,sal_False)
+ ,m_supportsMixedCaseQuotedIdentifiers(false,sal_False)
+ ,m_supportsAlterTableWithAddColumn(false,sal_False)
+ ,m_supportsAlterTableWithDropColumn(false,sal_False)
+ ,m_MaxStatements(false,0)
+ ,m_MaxTablesInSelect(false,0)
+ ,m_storesMixedCaseQuotedIdentifiers(false,sal_False)
+ , m_xConnection(_rxConnection)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ m_xListenerHelper = new OEventListenerHelper(this);
+ Reference<XComponent> xCom(m_xConnection,UNO_QUERY);
+ if(xCom.is())
+ xCom->addEventListener(m_xListenerHelper);
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// -------------------------------------------------------------------------
+ODatabaseMetaDataBase::~ODatabaseMetaDataBase()
+{
+}
+
+// -----------------------------------------------------------------------------
+Sequence< PropertyValue > SAL_CALL ODatabaseMetaDataBase::getConnectionInfo( ) throw (RuntimeException)
+{
+ return m_aConnectionInfo;
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataBase::disposing( const EventObject& /*Source*/ ) throw(RuntimeException)
+{
+ // cut off all references to the connection
+m_xConnection.clear();
+m_xListenerHelper.clear();
+}
+// -----------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getTypeInfo( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_aTypeInfoRows.empty() )
+ {
+ Reference< XResultSet > xRet = impl_getTypeInfo_throw();
+ Reference< XRow > xRow(xRet,UNO_QUERY);
+ ::comphelper::SequenceAsHashMap aMap(m_aConnectionInfo);
+ Sequence< Any > aTypeInfoSettings;
+ aTypeInfoSettings = aMap.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TypeInfoSettings")),aTypeInfoSettings);
+
+ if ( xRow.is() )
+ {
+ static sal_Int32 pTypes[] = {
+ DataType::VARCHAR
+ ,DataType::INTEGER
+ ,DataType::INTEGER
+ ,DataType::VARCHAR
+ ,DataType::VARCHAR
+ ,DataType::VARCHAR
+ ,DataType::INTEGER
+ ,DataType::BOOLEAN
+ ,DataType::INTEGER
+ ,DataType::BOOLEAN
+ ,DataType::BOOLEAN
+ ,DataType::BOOLEAN
+ ,DataType::VARCHAR
+ ,DataType::INTEGER
+ ,DataType::INTEGER
+ ,DataType::INTEGER
+ ,DataType::INTEGER
+ ,DataType::INTEGER
+ };
+ ::std::vector<ExpressionNodeSharedPtr> aConditions;
+ if ( aTypeInfoSettings.getLength() > 1 && ((aTypeInfoSettings.getLength() % 2) == 0) )
+ {
+ const Any* pIter = aTypeInfoSettings.getConstArray();
+ const Any* pEnd = pIter + aTypeInfoSettings.getLength();
+ try
+ {
+ for(;pIter != pEnd;++pIter)
+ aConditions.push_back(FunctionParser::parseFunction(::comphelper::getString(*pIter)));
+ }
+ catch(ParseError&)
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(STR_FORMULA_WRONG));
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+ }
+
+ ::connectivity::ODatabaseMetaDataResultSet::ORows aTypeInfoRows;
+ while( xRet->next() )
+ {
+ ::connectivity::ODatabaseMetaDataResultSet::ORow aRow;
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ sal_Int32* pType = pTypes;
+ for (sal_Int32 i = 1; i <= sal_Int32(sizeof(pTypes)/sizeof(pTypes[0])); ++i,++pType)
+ {
+ ORowSetValue aValue;
+ aValue.fill(i,*pType,xRow);
+ aRow.push_back(new ORowSetValueDecorator(aValue));
+ }
+
+ ::std::vector<ExpressionNodeSharedPtr>::iterator aIter = aConditions.begin();
+ ::std::vector<ExpressionNodeSharedPtr>::iterator aEnd = aConditions.end();
+ for (; aIter != aEnd; ++aIter)
+ {
+ if ( (*aIter)->evaluate(aRow)->getValue().getBool() )
+ {
+ ++aIter;
+ (*aIter)->fill(aRow);
+ }
+ else
+ ++aIter;
+ }
+ aTypeInfoRows.push_back(aRow);
+ }
+ m_aTypeInfoRows = aTypeInfoRows;
+ }
+ }
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo);
+ Reference< XResultSet > xRet = pResult;
+ pResult->setRows(m_aTypeInfoRows);
+ return xRet;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getExportedKeys(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schema*/, const ::rtl::OUString& /*table*/ ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eExportedKeys );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getImportedKeys(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schema*/, const ::rtl::OUString& /*table*/ ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eImportedKeys );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getPrimaryKeys(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schema*/, const ::rtl::OUString& /*table*/ ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::ePrimaryKeys );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getIndexInfo(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schema*/, const ::rtl::OUString& /*table*/,
+ sal_Bool /*unique*/, sal_Bool /*approximate*/ ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eIndexInfo );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getBestRowIdentifier(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schema*/, const ::rtl::OUString& /*table*/, sal_Int32 /*scope*/,
+ sal_Bool /*nullable*/ ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eBestRowIdentifier );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::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)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCrossReference );
+}
+// -------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL ODatabaseMetaDataBase::getConnection( ) throw(SQLException, RuntimeException)
+{
+ return m_xConnection;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getProcedureColumns(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/,
+ const ::rtl::OUString& /*procedureNamePattern*/, const ::rtl::OUString& /*columnNamePattern*/ ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedureColumns );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getProcedures(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/,
+ const ::rtl::OUString& /*procedureNamePattern*/ ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedures );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getVersionColumns(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schema*/, const ::rtl::OUString& /*table*/ ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eVersionColumns );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getSchemas( ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eSchemas );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getColumnPrivileges(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schema*/, const ::rtl::OUString& /*table*/,
+ const ::rtl::OUString& /*columnNamePattern*/ ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumnPrivileges );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getTablePrivileges(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schema*/, const ::rtl::OUString& /*table*/) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getCatalogs( ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCatalogs );
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaDataBase::getIdentifierQuoteString( ) throw(SQLException, RuntimeException)
+{
+ return callImplMethod(m_sIdentifierQuoteString,::std::mem_fun_t< ::rtl::OUString ,ODatabaseMetaDataBase>(&ODatabaseMetaDataBase::impl_getIdentifierQuoteString_throw));
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataBase::isCatalogAtStart( ) throw(SQLException, RuntimeException)
+{
+ return callImplMethod(m_isCatalogAtStart,::std::mem_fun_t< sal_Bool,ODatabaseMetaDataBase>(&ODatabaseMetaDataBase::impl_isCatalogAtStart_throw));
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaDataBase::getCatalogSeparator( ) throw(SQLException, RuntimeException)
+{
+ return callImplMethod(m_sCatalogSeparator,::std::mem_fun_t< ::rtl::OUString,ODatabaseMetaDataBase>(&ODatabaseMetaDataBase::impl_getCatalogSeparator_throw));
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataBase::supportsCatalogsInTableDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return callImplMethod(m_supportsCatalogsInTableDefinitions,::std::mem_fun_t< sal_Bool,ODatabaseMetaDataBase>(&ODatabaseMetaDataBase::impl_supportsCatalogsInTableDefinitions_throw));
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataBase::supportsSchemasInTableDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return callImplMethod(m_supportsSchemasInTableDefinitions,::std::mem_fun_t< sal_Bool,ODatabaseMetaDataBase>(&ODatabaseMetaDataBase::impl_supportsSchemasInTableDefinitions_throw));
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataBase::supportsCatalogsInDataManipulation( ) throw(SQLException, RuntimeException)
+{
+ return callImplMethod(m_supportsCatalogsInDataManipulation,::std::mem_fun_t< sal_Bool,ODatabaseMetaDataBase>(&ODatabaseMetaDataBase::impl_supportsCatalogsInDataManipulation_throw));
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataBase::supportsSchemasInDataManipulation( ) throw(SQLException, RuntimeException)
+{
+ return callImplMethod(m_supportsSchemasInDataManipulation,::std::mem_fun_t< sal_Bool,ODatabaseMetaDataBase>(&ODatabaseMetaDataBase::impl_supportsSchemasInDataManipulation_throw));
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataBase::supportsMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return callImplMethod(m_supportsMixedCaseQuotedIdentifiers,::std::mem_fun_t< sal_Bool,ODatabaseMetaDataBase>(&ODatabaseMetaDataBase::impl_supportsMixedCaseQuotedIdentifiers_throw));
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataBase::supportsAlterTableWithAddColumn( ) throw(SQLException, RuntimeException)
+{
+ return callImplMethod(m_supportsAlterTableWithAddColumn,::std::mem_fun_t< sal_Bool,ODatabaseMetaDataBase>(&ODatabaseMetaDataBase::impl_supportsAlterTableWithAddColumn_throw));
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataBase::supportsAlterTableWithDropColumn( ) throw(SQLException, RuntimeException)
+{
+ return callImplMethod(m_supportsAlterTableWithDropColumn,::std::mem_fun_t< sal_Bool,ODatabaseMetaDataBase>(&ODatabaseMetaDataBase::impl_supportsAlterTableWithDropColumn_throw));
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaDataBase::getMaxStatements( ) throw(SQLException, RuntimeException)
+{
+ return callImplMethod(m_MaxStatements,::std::mem_fun_t< sal_Int32,ODatabaseMetaDataBase>(&ODatabaseMetaDataBase::impl_getMaxStatements_throw));
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaDataBase::getMaxTablesInSelect( ) throw(SQLException, RuntimeException)
+{
+ return callImplMethod(m_MaxTablesInSelect,::std::mem_fun_t< sal_Int32,ODatabaseMetaDataBase>(&ODatabaseMetaDataBase::impl_getMaxTablesInSelect_throw));
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataBase::storesMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return callImplMethod(m_storesMixedCaseQuotedIdentifiers,::std::mem_fun_t< sal_Bool,ODatabaseMetaDataBase>(&ODatabaseMetaDataBase::impl_storesMixedCaseQuotedIdentifiers_throw));
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/commontools/TIndex.cxx b/connectivity/source/commontools/TIndex.cxx
new file mode 100644
index 000000000000..0987ba124777
--- /dev/null
+++ b/connectivity/source/commontools/TIndex.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 "connectivity/TIndex.hxx"
+#include "connectivity/TIndexColumns.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include "connectivity/TTableHelper.hxx"
+#include "TConnection.hxx"
+
+using namespace connectivity;
+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;
+// -------------------------------------------------------------------------
+OIndexHelper::OIndexHelper( OTableHelper* _pTable) : connectivity::sdbcx::OIndex(sal_True)
+ , m_pTable(_pTable)
+{
+ construct();
+ ::std::vector< ::rtl::OUString> aVector;
+ m_pColumns = new OIndexColumns(this,m_aMutex,aVector);
+}
+// -------------------------------------------------------------------------
+OIndexHelper::OIndexHelper( OTableHelper* _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();
+}
+// -------------------------------------------------------------------------
+
+void OIndexHelper::refreshColumns()
+{
+ if ( !m_pTable )
+ return;
+
+ ::std::vector< ::rtl::OUString> aVector;
+ if ( !isNew() )
+ {
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ ::rtl::OUString aSchema,aTable;
+ m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
+ m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable;
+
+ Reference< XResultSet > xResult = m_pTable->getMetaData()->getIndexInfo(
+ m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
+ aSchema,aTable,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);
+ }
+ }
+ }
+ }
+ if(m_pColumns)
+ m_pColumns->reFill(aVector);
+ else
+ m_pColumns = new OIndexColumns(this,m_aMutex,aVector);
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/commontools/TIndexColumns.cxx b/connectivity/source/commontools/TIndexColumns.cxx
new file mode 100644
index 000000000000..3c9ac59112f6
--- /dev/null
+++ b/connectivity/source/commontools/TIndexColumns.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 "connectivity/TIndexColumns.hxx"
+#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 <comphelper/property.hxx>
+#include "connectivity/TIndex.hxx"
+#include "connectivity/TTableHelper.hxx"
+#include "TConnection.hxx"
+
+using namespace connectivity;
+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;
+// -------------------------------------------------------------------------
+OIndexColumns::OIndexColumns( OIndexHelper* _pIndex,
+ ::osl::Mutex& _rMutex,
+ const ::std::vector< ::rtl::OUString> &_rVector)
+ : connectivity::sdbcx::OCollection(*_pIndex,sal_True,_rMutex,_rVector)
+ ,m_pIndex(_pIndex)
+{
+}
+// -------------------------------------------------------------------------
+sdbcx::ObjectType OIndexColumns::createObject(const ::rtl::OUString& _rName)
+{
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ ::rtl::OUString aSchema,aTable;
+ m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
+ m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable;
+
+ Reference< XResultSet > xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getIndexInfo(
+ m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
+ aSchema,aTable,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;
+ }
+ }
+
+ xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getColumns(
+ m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
+ aSchema,aTable,_rName);
+
+ sdbcx::ObjectType xRet;
+ if ( xResult.is() )
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while( xResult->next() )
+ {
+ if ( xRow->getString(4) == _rName )
+ {
+ sal_Int32 nDataType = xRow->getInt(5);
+ ::rtl::OUString aTypeName(xRow->getString(6));
+ sal_Int32 nSize = xRow->getInt(7);
+ sal_Int32 nDec = xRow->getInt(9);
+ sal_Int32 nNull = xRow->getInt(11);
+ ::rtl::OUString aColumnDef(xRow->getString(13));
+
+ OIndexColumn* pRet = new OIndexColumn(bAsc,
+ _rName,
+ aTypeName,
+ aColumnDef,
+ nNull,
+ nSize,
+ nDec,
+ nDataType,
+ sal_False,sal_False,sal_False,sal_True);
+ xRet = pRet;
+ break;
+ }
+ }
+ }
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OIndexColumns::createDescriptor()
+{
+ return new OIndexColumn(sal_True);
+}
+// -------------------------------------------------------------------------
+void OIndexColumns::impl_refresh() throw(RuntimeException)
+{
+ m_pIndex->refreshColumns();
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/commontools/TIndexes.cxx b/connectivity/source/commontools/TIndexes.cxx
new file mode 100644
index 000000000000..1f77d51929d0
--- /dev/null
+++ b/connectivity/source/commontools/TIndexes.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 "connectivity/TIndexes.hxx"
+#include "connectivity/TIndex.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/IndexType.hpp>
+#include <connectivity/dbtools.hxx>
+#include "connectivity/TTableHelper.hxx"
+#include "TConnection.hxx"
+#include <comphelper/extract.hxx>
+#include <rtl/ustrbuf.hxx>
+using namespace connectivity;
+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 cppu;
+
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+// -----------------------------------------------------------------------------
+OIndexesHelper::OIndexesHelper(OTableHelper* _pTable,
+ ::osl::Mutex& _rMutex,
+ const ::std::vector< ::rtl::OUString> &_rVector
+ )
+ : OCollection(*_pTable,sal_True,_rMutex,_rVector)
+ ,m_pTable(_pTable)
+{
+}
+// -----------------------------------------------------------------------------
+
+sdbcx::ObjectType OIndexesHelper::createObject(const ::rtl::OUString& _rName)
+{
+ Reference< XConnection> xConnection = m_pTable->getConnection();
+ if ( !xConnection.is() )
+ return NULL;
+
+ sdbcx::ObjectType xRet;
+ ::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;
+
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ ::rtl::OUString aSchema,aTable;
+ m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
+ m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable;
+
+ Any aCatalog = m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME));
+ Reference< XResultSet > xResult = m_pTable->getMetaData()->getIndexInfo(aCatalog,aSchema,aTable,sal_False,sal_False);
+
+ if ( xResult.is() )
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while( xResult->next() )
+ {
+ sal_Bool bUnique = !xRow->getBoolean(4);
+ if((!aQualifier.getLength() || xRow->getString(5) == aQualifier ) && xRow->getString(6) == aName)
+ {
+ sal_Int32 nClustered = xRow->getShort(7);
+ sal_Bool bPrimarKeyIndex = sal_False;
+ xRow.clear();
+ xResult.clear();
+ try
+ {
+ xResult = m_pTable->getMetaData()->getPrimaryKeys(aCatalog,aSchema,aTable);
+ xRow.set(xResult,UNO_QUERY);
+
+ if ( xRow.is() && xResult->next() ) // there can be only one primary key
+ {
+ bPrimarKeyIndex = xRow->getString(6) == aName;
+ }
+ }
+ catch(Exception)
+ {
+ }
+ OIndexHelper* pRet = new OIndexHelper(m_pTable,aName,aQualifier,bUnique,
+ bPrimarKeyIndex,
+ nClustered == IndexType::CLUSTERED);
+ xRet = pRet;
+ break;
+ }
+ }
+ }
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void OIndexesHelper::impl_refresh() throw(RuntimeException)
+{
+ m_pTable->refreshIndexes();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OIndexesHelper::createDescriptor()
+{
+ return new OIndexHelper(m_pTable);
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OIndexesHelper::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ Reference< XConnection> xConnection = m_pTable->getConnection();
+ if ( !xConnection.is() )
+ return NULL;
+ if ( m_pTable->isNew() )
+ return cloneDescriptor( descriptor );
+
+ if ( m_pTable->getIndexService().is() )
+ {
+ m_pTable->getIndexService()->addIndex(m_pTable,descriptor);
+ }
+ else
+ {
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ ::rtl::OUStringBuffer aSql( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CREATE ")));
+ ::rtl::OUString aQuote = m_pTable->getMetaData()->getIdentifierQuoteString( );
+ ::rtl::OUString aDot = ::rtl::OUString::createFromAscii(".");
+
+ if(comphelper::getBOOL(descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISUNIQUE))))
+ aSql.appendAscii("UNIQUE ");
+ aSql.appendAscii("INDEX ");
+
+
+ ::rtl::OUString aCatalog,aSchema,aTable;
+ dbtools::qualifiedNameComponents(m_pTable->getMetaData(),m_pTable->getName(),aCatalog,aSchema,aTable,::dbtools::eInDataManipulation);
+ ::rtl::OUString aComposedName;
+
+ aComposedName = dbtools::composeTableName(m_pTable->getMetaData(),aCatalog,aSchema,aTable,sal_True,::dbtools::eInIndexDefinitions);
+ if ( _rForName.getLength() )
+ {
+ aSql.append( ::dbtools::quoteName( aQuote, _rForName ) );
+ aSql.appendAscii(" ON ");
+ aSql.append(aComposedName);
+ aSql.appendAscii(" ( ");
+
+ Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
+ Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
+ Reference< XPropertySet > xColProp;
+ sal_Bool bAddIndexAppendix = ::dbtools::getBooleanDataSourceSetting( m_pTable->getConnection(), "AddIndexAppendix" );
+ sal_Int32 nCount = xColumns->getCount();
+ for(sal_Int32 i = 0 ; i < nCount; ++i)
+ {
+ xColProp.set(xColumns->getByIndex(i),UNO_QUERY);
+ aSql.append(::dbtools::quoteName( aQuote,comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))));
+
+ if ( bAddIndexAppendix )
+ {
+
+ aSql.appendAscii(any2bool(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISASCENDING)))
+ ?
+ " ASC"
+ :
+ " DESC");
+ }
+ aSql.appendAscii(",");
+ }
+ aSql.setCharAt(aSql.getLength()-1,')');
+ }
+ else
+ {
+ aSql.append(aComposedName);
+
+ 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.append(aDot);
+ aSql.append(::dbtools::quoteName( aQuote,comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))));
+ }
+
+ Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
+ if ( xStmt.is() )
+ {
+ ::rtl::OUString sSql = aSql.makeStringAndClear();
+ xStmt->execute(sSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OIndexesHelper::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
+{
+ Reference< XConnection> xConnection = m_pTable->getConnection();
+ if( xConnection.is() && !m_pTable->isNew())
+ {
+ if ( m_pTable->getIndexService().is() )
+ {
+ m_pTable->getIndexService()->dropIndex(m_pTable,_sElementName);
+ }
+ else
+ {
+ ::rtl::OUString aName,aSchema;
+ sal_Int32 nLen = _sElementName.indexOf('.');
+ if(nLen != -1)
+ aSchema = _sElementName.copy(0,nLen);
+ aName = _sElementName.copy(nLen+1);
+
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP INDEX ");
+
+ ::rtl::OUString aComposedName = dbtools::composeTableName( m_pTable->getMetaData(), m_pTable, ::dbtools::eInIndexDefinitions, false, false, true );
+ ::rtl::OUString sIndexName,sTemp;
+ sIndexName = dbtools::composeTableName( m_pTable->getMetaData(), sTemp, aSchema, aName, sal_True, ::dbtools::eInIndexDefinitions );
+
+ aSql += sIndexName
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ON "))
+ + aComposedName;
+
+ Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
+ if ( xStmt.is() )
+ {
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/commontools/TKey.cxx b/connectivity/source/commontools/TKey.cxx
new file mode 100644
index 000000000000..464335aa7b44
--- /dev/null
+++ b/connectivity/source/commontools/TKey.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+
+#include "connectivity/TKey.hxx"
+#include "connectivity/TKeyColumns.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include "TConnection.hxx"
+#include "connectivity/TTableHelper.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;
+// -------------------------------------------------------------------------
+OTableKeyHelper::OTableKeyHelper(OTableHelper* _pTable) : connectivity::sdbcx::OKey(sal_True)
+ ,m_pTable(_pTable)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+OTableKeyHelper::OTableKeyHelper( OTableHelper* _pTable
+ ,const ::rtl::OUString& _Name
+ ,const sdbcx::TKeyProperties& _rProps
+ ) : connectivity::sdbcx::OKey(_Name,_rProps,sal_True)
+ ,m_pTable(_pTable)
+{
+ construct();
+ refreshColumns();
+}
+// -------------------------------------------------------------------------
+void OTableKeyHelper::refreshColumns()
+{
+ if ( !m_pTable )
+ return;
+
+ ::std::vector< ::rtl::OUString> aVector;
+ if ( !isNew() )
+ {
+ aVector = m_aProps->m_aKeyColumnNames;
+ if ( aVector.empty() )
+ {
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ ::rtl::OUString aSchema,aTable;
+ m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
+ m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable;
+
+ if ( m_Name.getLength() ) // foreign key
+ {
+
+ Reference< XResultSet > xResult = m_pTable->getMetaData()->getImportedKeys(m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
+ aSchema,aTable);
+
+ if ( xResult.is() )
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while( xResult->next() )
+ {
+ ::rtl::OUString aForeignKeyColumn = xRow->getString(8);
+ if(xRow->getString(12) == m_Name)
+ aVector.push_back(aForeignKeyColumn);
+ }
+ }
+ }
+
+ if ( aVector.empty() )
+ {
+ const Reference< XResultSet > xResult = m_pTable->getMetaData()->getPrimaryKeys(m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
+ aSchema,aTable);
+
+ if ( xResult.is() )
+ {
+ const Reference< XRow > xRow(xResult,UNO_QUERY);
+ while( xResult->next() )
+ aVector.push_back(xRow->getString(4));
+ } // if ( xResult.is() )
+ }
+ }
+ }
+
+
+ if ( m_pColumns )
+ m_pColumns ->reFill(aVector);
+ else
+ m_pColumns = new OKeyColumnsHelper(this,m_aMutex,aVector);
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/commontools/TKeyColumns.cxx b/connectivity/source/commontools/TKeyColumns.cxx
new file mode 100644
index 000000000000..18cb7cef14dd
--- /dev/null
+++ b/connectivity/source/commontools/TKeyColumns.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 "connectivity/TKeyColumns.hxx"
+#include "connectivity/sdbcx/VKeyColumn.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/extract.hxx>
+#include <comphelper/property.hxx>
+#include "TConnection.hxx"
+#include "connectivity/TTableHelper.hxx"
+
+using namespace connectivity;
+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;
+
+// -------------------------------------------------------------------------
+OKeyColumnsHelper::OKeyColumnsHelper( OTableKeyHelper* _pKey,
+ ::osl::Mutex& _rMutex,
+ const ::std::vector< ::rtl::OUString> &_rVector)
+ : connectivity::sdbcx::OCollection(*_pKey,sal_True,_rMutex,_rVector)
+ ,m_pKey(_pKey)
+{
+}
+// -------------------------------------------------------------------------
+sdbcx::ObjectType OKeyColumnsHelper::createObject(const ::rtl::OUString& _rName)
+{
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ ::rtl::OUString aSchema,aTable;
+ m_pKey->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
+ m_pKey->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable;
+
+ // frist get the related column to _rName
+ Reference< XResultSet > xResult = m_pKey->getTable()->getMetaData()->getImportedKeys(
+ m_pKey->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),aSchema,aTable);
+
+ ::rtl::OUString aRefColumnName;
+ if ( xResult.is() )
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ ::rtl::OUString aTemp;
+ while(xResult->next())
+ {
+ aTemp = xRow->getString(4);
+ if(xRow->getString(8) == _rName && m_pKey->getName() == xRow->getString(12))
+ {
+ aRefColumnName = aTemp;
+ break;
+ }
+ }
+ }
+
+ sdbcx::ObjectType xRet;
+
+ // now describe the column _rName and set his related column
+ xResult = m_pKey->getTable()->getMetaData()->getColumns(
+ m_pKey->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),aSchema,aTable,_rName);
+
+ if ( xResult.is() )
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ if ( xResult->next() )
+ {
+ if ( xRow->getString(4) == _rName )
+ {
+ sal_Int32 nDataType = xRow->getInt(5);
+ ::rtl::OUString aTypeName(xRow->getString(6));
+ sal_Int32 nSize = xRow->getInt(7);
+ sal_Int32 nDec = xRow->getInt(9);
+ sal_Int32 nNull = xRow->getInt(11);
+ ::rtl::OUString sColumnDef;
+ try
+ {
+ sColumnDef = xRow->getString(13);
+ }
+ catch(const SQLException&)
+ {
+ // somethimes we get an error when asking for this param
+ }
+
+ OKeyColumn* pRet = new OKeyColumn(aRefColumnName,
+ _rName,
+ aTypeName,
+ sColumnDef,
+ nNull,
+ nSize,
+ nDec,
+ nDataType,
+ sal_False,
+ sal_False,
+ sal_False,
+ isCaseSensitive());
+ xRet = pRet;
+ }
+ }
+ }
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OKeyColumnsHelper::createDescriptor()
+{
+ return new OKeyColumn(isCaseSensitive());
+}
+// -------------------------------------------------------------------------
+void OKeyColumnsHelper::impl_refresh() throw(::com::sun::star::uno::RuntimeException)
+{
+ m_pKey->refreshColumns();
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/commontools/TKeys.cxx b/connectivity/source/commontools/TKeys.cxx
new file mode 100644
index 000000000000..c4d5dfbf20e0
--- /dev/null
+++ b/connectivity/source/commontools/TKeys.cxx
@@ -0,0 +1,320 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/TKeys.hxx"
+#include "connectivity/TKey.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 "connectivity/dbtools.hxx"
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include <comphelper/property.hxx>
+#include "TConnection.hxx"
+
+namespace connectivity
+{
+using namespace comphelper;
+using namespace connectivity::sdbcx;
+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;
+
+
+
+OKeysHelper::OKeysHelper( OTableHelper* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector& _rVector
+ ) : OKeys_BASE(*_pTable,sal_True,_rMutex,_rVector,sal_True)
+ ,m_pTable(_pTable)
+{
+}
+// -------------------------------------------------------------------------
+sdbcx::ObjectType OKeysHelper::createObject(const ::rtl::OUString& _rName)
+{
+ sdbcx::ObjectType xRet = NULL;
+
+ if(_rName.getLength())
+ {
+ OTableKeyHelper* pRet = new OTableKeyHelper(m_pTable,_rName,m_pTable->getKeyProperties(_rName));
+ xRet = pRet;
+ }
+
+ if(!xRet.is()) // we have a primary key with a system name
+ {
+ OTableKeyHelper* pRet = new OTableKeyHelper(m_pTable,_rName,m_pTable->getKeyProperties(_rName));
+ xRet = pRet;
+ }
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void OKeysHelper::impl_refresh() throw(RuntimeException)
+{
+ m_pTable->refreshKeys();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OKeysHelper::createDescriptor()
+{
+ return new OTableKeyHelper(m_pTable);
+}
+// -----------------------------------------------------------------------------
+/** returns the keyrule string for the primary key
+*/
+::rtl::OUString getKeyRuleString(sal_Bool _bUpdate,sal_Int32 _nKeyRule)
+{
+ const char* pKeyRule = NULL;
+ switch ( _nKeyRule )
+ {
+ case KeyRule::CASCADE:
+ pKeyRule = _bUpdate ? " ON UPDATE CASCADE " : " ON DELETE CASCADE ";
+ break;
+ case KeyRule::RESTRICT:
+ pKeyRule = _bUpdate ? " ON UPDATE RESTRICT " : " ON DELETE RESTRICT ";
+ break;
+ case KeyRule::SET_NULL:
+ pKeyRule = _bUpdate ? " ON UPDATE SET NULL " : " ON DELETE SET NULL ";
+ break;
+ case KeyRule::SET_DEFAULT:
+ pKeyRule = _bUpdate ? " ON UPDATE SET DEFAULT " : " ON DELETE SET DEFAULT ";
+ break;
+ default:
+ ;
+ }
+ ::rtl::OUString sRet;
+ if ( pKeyRule )
+ sRet = ::rtl::OUString::createFromAscii(pKeyRule);
+ return sRet;
+}
+// -------------------------------------------------------------------------
+void OKeysHelper::cloneDescriptorColumns( const sdbcx::ObjectType& _rSourceDescriptor, const sdbcx::ObjectType& _rDestDescriptor )
+{
+ Reference< XColumnsSupplier > xColSupp( _rSourceDescriptor, UNO_QUERY_THROW );
+ Reference< XIndexAccess > xSourceCols( xColSupp->getColumns(), UNO_QUERY_THROW );
+
+ xColSupp.set( _rDestDescriptor, UNO_QUERY_THROW );
+ Reference< XAppend > xDestAppend( xColSupp->getColumns(), UNO_QUERY_THROW );
+
+ sal_Int32 nCount = xSourceCols->getCount();
+ for ( sal_Int32 i=0; i< nCount; ++i )
+ {
+ Reference< XPropertySet > xColProp( xSourceCols->getByIndex(i), UNO_QUERY );
+ xDestAppend->appendByDescriptor( xColProp );
+ }
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OKeysHelper::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ Reference< XConnection> xConnection = m_pTable->getConnection();
+ if ( !xConnection.is() )
+ return NULL;
+ if ( m_pTable->isNew() )
+ {
+ Reference< XPropertySet > xNewDescriptor( cloneDescriptor( descriptor ) );
+ cloneDescriptorColumns( descriptor, xNewDescriptor );
+ return xNewDescriptor;
+ }
+
+ const ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ sal_Int32 nKeyType = getINT32(descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPE)));
+ sal_Int32 nUpdateRule = 0, nDeleteRule = 0;
+ ::rtl::OUString sReferencedName;
+
+ if ( nKeyType == KeyType::FOREIGN )
+ {
+ descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_REFERENCEDTABLE)) >>= sReferencedName;
+ descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_UPDATERULE)) >>= nUpdateRule;
+ descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_DELETERULE)) >>= nDeleteRule;
+ }
+
+ if ( m_pTable->getKeyService().is() )
+ {
+ m_pTable->getKeyService()->addKey(m_pTable,descriptor);
+ }
+ else
+ {
+ // if we're here, we belong to a table which is not new, i.e. already exists in the database.
+ // In this case, really append the new index.
+ ::rtl::OUStringBuffer aSql;
+ aSql.appendAscii("ALTER TABLE ");
+ ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( );
+ ::rtl::OUString aDot = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("."));
+
+ aSql.append(composeTableName( m_pTable->getConnection()->getMetaData(), m_pTable, ::dbtools::eInTableDefinitions, false, false, true ));
+ aSql.appendAscii(" ADD ");
+
+ if ( nKeyType == KeyType::PRIMARY )
+ {
+ aSql.appendAscii(" PRIMARY KEY (");
+ }
+ else if ( nKeyType == KeyType::FOREIGN )
+ {
+ aSql.appendAscii(" FOREIGN KEY (");
+ }
+ else
+ throw SQLException();
+
+ Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
+ Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
+ Reference< XPropertySet > xColProp;
+ for(sal_Int32 i = 0 ; i < xColumns->getCount() ; ++i)
+ {
+ if ( i > 0 )
+ aSql.appendAscii(",");
+ ::cppu::extractInterface(xColProp,xColumns->getByIndex(i));
+ aSql.append( ::dbtools::quoteName( aQuote,getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))) );
+
+ }
+ aSql.appendAscii(")");
+
+ if ( nKeyType == KeyType::FOREIGN )
+ {
+ aSql.appendAscii(" REFERENCES ");
+ aSql.append(::dbtools::quoteTableName(m_pTable->getConnection()->getMetaData(),sReferencedName,::dbtools::eInTableDefinitions));
+ aSql.appendAscii(" (");
+
+ for(sal_Int32 i=0;i<xColumns->getCount();++i)
+ {
+ if ( i > 0 )
+ aSql.appendAscii(",");
+ xColumns->getByIndex(i) >>= xColProp;
+ aSql.append(::dbtools::quoteName( aQuote,getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_RELATEDCOLUMN)))));
+
+ }
+ aSql.appendAscii(")");
+ aSql.append(getKeyRuleString(sal_True ,nUpdateRule));
+ aSql.append(getKeyRuleString(sal_False ,nDeleteRule));
+ }
+
+ Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
+ xStmt->execute(aSql.makeStringAndClear());
+ }
+ // find the name which the database gave the new key
+ ::rtl::OUString sNewName( _rForName );
+ try
+ {
+ ::rtl::OUString aSchema,aTable;
+ m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
+ m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable;
+ Reference< XResultSet > xResult;
+ sal_Int32 nColumn = 12;
+ if ( nKeyType == KeyType::FOREIGN )
+ xResult = m_pTable->getMetaData()->getImportedKeys( m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME))
+ ,aSchema
+ ,aTable);
+ else
+ {
+ xResult = m_pTable->getMetaData()->getPrimaryKeys( m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME))
+ ,aSchema
+ ,aTable);
+ nColumn = 6;
+ }
+ if ( xResult.is() )
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while( xResult->next() )
+ {
+ ::rtl::OUString sName = xRow->getString(nColumn);
+ if ( !m_pElements->exists(sName) ) // this name wasn't inserted yet so it must be te new one
+ {
+ descriptor->setPropertyValue( rPropMap.getNameByIndex( PROPERTY_ID_NAME ), makeAny( sName ) );
+ sNewName = sName;
+ break;
+ }
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+ }
+ catch(const SQLException&)
+ {
+ }
+
+ m_pTable->addKey(sNewName,sdbcx::TKeyProperties(new sdbcx::KeyProperties(sReferencedName,nKeyType,nUpdateRule,nDeleteRule)));
+
+ return createObject( sNewName );
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OKeysHelper::getDropForeignKey() const
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" DROP CONSTRAINT "));
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OKeysHelper::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
+{
+ Reference< XConnection> xConnection = m_pTable->getConnection();
+ if ( xConnection.is() && !m_pTable->isNew() )
+ {
+ Reference<XPropertySet> xKey(getObject(_nPos),UNO_QUERY);
+ if ( m_pTable->getKeyService().is() )
+ {
+ m_pTable->getKeyService()->dropKey(m_pTable,xKey);
+ }
+ else
+ {
+ ::rtl::OUStringBuffer aSql;
+ aSql.appendAscii("ALTER TABLE ");
+
+ aSql.append( composeTableName( m_pTable->getConnection()->getMetaData(), m_pTable,::dbtools::eInTableDefinitions, false, false, true ));
+
+ sal_Int32 nKeyType = KeyType::PRIMARY;
+ if ( xKey.is() )
+ {
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ xKey->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPE)) >>= nKeyType;
+ }
+ if ( KeyType::PRIMARY == nKeyType )
+ {
+ aSql.appendAscii(" DROP PRIMARY KEY");
+ }
+ else
+ {
+ aSql.append(getDropForeignKey());
+ const ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString();
+ aSql.append( ::dbtools::quoteName( aQuote,_sElementName) );
+ }
+
+ Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
+ if ( xStmt.is() )
+ {
+ xStmt->execute(aSql.makeStringAndClear());
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+} // namespace connectivity
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/commontools/TPrivilegesResultSet.cxx b/connectivity/source/commontools/TPrivilegesResultSet.cxx
new file mode 100644
index 000000000000..a7e76f643bfe
--- /dev/null
+++ b/connectivity/source/commontools/TPrivilegesResultSet.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 "TPrivilegesResultSet.hxx"
+
+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;
+//------------------------------------------------------------------------------
+OResultSetPrivileges::OResultSetPrivileges( const Reference< XDatabaseMetaData>& _rxMeta
+ , const Any& catalog
+ , const ::rtl::OUString& schemaPattern
+ , const ::rtl::OUString& tableNamePattern)
+ : ODatabaseMetaDataResultSet(eTablePrivileges)
+ , m_bResetValues(sal_True)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ ::rtl::OUString sUserWorkingFor;
+ static Sequence< ::rtl::OUString > sTableTypes;
+ if ( sTableTypes.getLength() == 0 )
+ {
+ // we want all catalogues, all schemas, all tables
+ sTableTypes.realloc(3);
+ sTableTypes[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW"));
+ sTableTypes[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TABLE"));
+ sTableTypes[2] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")); // just to be sure to include anything else ....
+ }
+ try
+ {
+ m_xTables = _rxMeta->getTables(catalog,schemaPattern,tableNamePattern,sTableTypes);
+ m_xRow = Reference< XRow>(m_xTables,UNO_QUERY);
+
+ sUserWorkingFor = _rxMeta->getUserName();
+ }
+ catch(Exception&)
+ {
+ }
+
+ ODatabaseMetaDataResultSet::ORows aRows;
+ static ODatabaseMetaDataResultSet::ORow aRow(8);
+ aRow[5] = new ORowSetValueDecorator(sUserWorkingFor);
+ aRow[6] = ODatabaseMetaDataResultSet::getSelectValue();
+ aRow[7] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("YES")));
+ aRows.push_back(aRow);
+ aRow[6] = ODatabaseMetaDataResultSet::getInsertValue();
+ aRows.push_back(aRow);
+ 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);
+ aRow[6] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("REFERENCE")));
+ aRows.push_back(aRow);
+
+ setRows(aRows);
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+}
+//------------------------------------------------------------------------------
+const ORowSetValue& OResultSetPrivileges::getValue(sal_Int32 columnIndex)
+{
+ switch(columnIndex)
+ {
+ case 1:
+ case 2:
+ case 3:
+ if ( m_xRow.is() && m_bResetValues )
+ {
+ (*m_aRowsIter)[1] = new ORowSetValueDecorator(m_xRow->getString(1));
+ if ( m_xRow->wasNull() )
+ (*m_aRowsIter)[1]->setNull();
+ (*m_aRowsIter)[2] = new ORowSetValueDecorator(m_xRow->getString(2));
+ if ( m_xRow->wasNull() )
+ (*m_aRowsIter)[2]->setNull();
+ (*m_aRowsIter)[3] = new ORowSetValueDecorator(m_xRow->getString(3));
+ if ( m_xRow->wasNull() )
+ (*m_aRowsIter)[3]->setNull();
+
+ m_bResetValues = sal_False;
+ }
+ }
+ return ODatabaseMetaDataResultSet::getValue(columnIndex);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSetPrivileges::disposing(void)
+{
+ ODatabaseMetaDataResultSet::disposing();
+m_xTables.clear();
+m_xRow.clear();
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSetPrivileges::next( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
+
+ sal_Bool bReturn = sal_False;
+ if ( m_xTables.is() )
+ {
+ if ( m_bBOF )
+ {
+ m_bResetValues = sal_True;
+ if ( !m_xTables->next() )
+ return sal_False;
+ }
+
+ bReturn = ODatabaseMetaDataResultSet::next();
+ if ( !bReturn )
+ {
+ m_bBOF = sal_False;
+ m_bResetValues = bReturn = m_xTables->next();
+ }
+ }
+ return bReturn;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/commontools/TSkipDeletedSet.cxx b/connectivity/source/commontools/TSkipDeletedSet.cxx
new file mode 100644
index 000000000000..2d144ab72941
--- /dev/null
+++ b/connectivity/source/commontools/TSkipDeletedSet.cxx
@@ -0,0 +1,278 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "TSkipDeletedSet.hxx"
+#include <osl/diagnose.h>
+#include <rtl/logfile.hxx>
+
+using namespace connectivity;
+// -----------------------------------------------------------------------------
+OSkipDeletedSet::OSkipDeletedSet(IResultSetHelper* _pHelper)
+ : m_pHelper(_pHelper)
+ ,m_bDeletedVisible(false)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "commontools", "Ocke.Janssen@sun.com", "OSkipDeletedSet::OSkipDeletedSet" );
+ m_aBookmarksPositions.reserve(256);
+}
+// -----------------------------------------------------------------------------
+OSkipDeletedSet::~OSkipDeletedSet()
+{
+ m_aBookmarksPositions.clear();
+ //m_aBookmarks.clear();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OSkipDeletedSet::skipDeleted(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool _bRetrieveData)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "commontools", "Ocke.Janssen@sun.com", "OSkipDeletedSet::skipDeleted" );
+ OSL_ENSURE(_eCursorPosition != IResultSetHelper::BOOKMARK,"OSkipDeletedSet::SkipDeleted can't be called for BOOKMARK");
+
+ IResultSetHelper::Movement eDelPosition = _eCursorPosition;
+ sal_Int32 nDelOffset = abs(_nOffset);
+
+ switch (_eCursorPosition)
+ {
+ case IResultSetHelper::ABSOLUTE:
+ return moveAbsolute(_nOffset,_bRetrieveData);
+ case IResultSetHelper::FIRST: // set the movement when positioning failed
+ eDelPosition = IResultSetHelper::NEXT;
+ nDelOffset = 1;
+ break;
+ case IResultSetHelper::LAST:
+ eDelPosition = IResultSetHelper::PRIOR; // lsat row is invalid so position before
+ nDelOffset = 1;
+ break;
+ case IResultSetHelper::RELATIVE:
+ eDelPosition = (_nOffset >= 0) ? IResultSetHelper::NEXT : IResultSetHelper::PRIOR;
+ break;
+ default:
+ break;
+ }
+
+ sal_Bool bDone = sal_True;
+ sal_Bool bDataFound = sal_False;
+
+ if (_eCursorPosition == IResultSetHelper::LAST)
+ {
+ RTL_LOGFILE_CONTEXT_TRACE( aLogger, "OSkipDeletedSet::skipDeleted: last" );
+ sal_Int32 nBookmark = 0;
+ // first position on the last known row
+ if ( m_aBookmarksPositions.empty() )
+ {
+ bDataFound = m_pHelper->move(IResultSetHelper::FIRST, 0, _bRetrieveData);
+ if(bDataFound && (m_bDeletedVisible || !m_pHelper->isRowDeleted()))
+ //m_aBookmarksPositions.push_back(m_aBookmarks.insert(TInt2IntMap::value_type(m_pHelper->getDriverPos(),m_aBookmarksPositions.size()+1)).first);
+ m_aBookmarksPositions.push_back(m_pHelper->getDriverPos());
+ }
+ else
+ {
+ // I already have a bookmark so we can positioned on that and look if it is the last one
+ nBookmark = (*m_aBookmarksPositions.rbegin())/*->first*/;
+
+ bDataFound = m_pHelper->move(IResultSetHelper::BOOKMARK, nBookmark, _bRetrieveData);
+ OSL_ENSURE((m_bDeletedVisible || !m_pHelper->isRowDeleted()),"A bookmark should not be deleted!");
+ }
+
+
+ // and than move forward until we are after the last row
+ while(bDataFound)
+ {
+ bDataFound = m_pHelper->move(IResultSetHelper::NEXT, 1, sal_False); // we don't need the data here
+ if( bDataFound && ( m_bDeletedVisible || !m_pHelper->isRowDeleted()) )
+ { // we weren't on the last row we remember it and move on
+ m_aBookmarksPositions.push_back(m_pHelper->getDriverPos());
+ //m_aBookmarksPositions.push_back(m_aBookmarks.insert(TInt2IntMap::value_type(m_pHelper->getDriverPos(),m_aBookmarksPositions.size()+1)).first);
+ }
+ else if(!bDataFound && !m_aBookmarksPositions.empty() )
+ {
+ // i already know the last bookmark :-)
+ // now we only have to repositioning us to the last row
+ nBookmark = (*m_aBookmarksPositions.rbegin())/*->first*/;
+ bDataFound = m_pHelper->move(IResultSetHelper::BOOKMARK, nBookmark, _bRetrieveData);
+ break;
+ }
+ }
+ return bDataFound;
+ }
+ else if (_eCursorPosition != IResultSetHelper::RELATIVE)
+ {
+ bDataFound = m_pHelper->move(_eCursorPosition, _nOffset, _bRetrieveData);
+ bDone = bDataFound && (m_bDeletedVisible || !m_pHelper->isRowDeleted());
+ }
+ else
+ {
+ bDataFound = m_pHelper->move(eDelPosition, 1, _bRetrieveData);
+ if (bDataFound && (m_bDeletedVisible || !m_pHelper->isRowDeleted()))
+ {
+ bDone = (--nDelOffset) == 0;
+ if ( !bDone )
+ m_aBookmarksPositions.push_back(m_pHelper->getDriverPos());
+ //m_aBookmarksPositions.push_back(m_aBookmarks.insert(TInt2IntMap::value_type(m_pHelper->getDriverPos(),m_aBookmarksPositions.size()+1)).first);
+ }
+ else
+ bDone = sal_False;
+ }
+
+ while (bDataFound && !bDone) // solange iterieren bis man auf einem gueltigen Satz ist
+ {
+ bDataFound = m_pHelper->move(eDelPosition, 1, _bRetrieveData);
+ if (_eCursorPosition != IResultSetHelper::RELATIVE)
+ bDone = bDataFound && (m_bDeletedVisible || !m_pHelper->isRowDeleted());
+ else if (bDataFound && (m_bDeletedVisible || !m_pHelper->isRowDeleted()))
+ {
+ bDone = (--nDelOffset) == 0;
+ if ( !bDone )
+ m_aBookmarksPositions.push_back(m_pHelper->getDriverPos());
+ //m_aBookmarksPositions.push_back(m_aBookmarks.insert(TInt2IntMap::value_type(m_pHelper->getDriverPos(),m_aBookmarksPositions.size()+1)).first);
+ }
+ else
+ bDone = sal_False;
+ }
+
+ if(bDataFound && bDone )
+ {
+ const sal_Int32 nDriverPos = m_pHelper->getDriverPos();
+ if ( ::std::find(m_aBookmarksPositions.begin(),m_aBookmarksPositions.end(),nDriverPos) == m_aBookmarksPositions.end() )
+ m_aBookmarksPositions.push_back(nDriverPos);
+ /*sal_Int32 nDriverPos = m_pHelper->getDriverPos();
+ if(m_aBookmarks.find(nDriverPos) == m_aBookmarks.end())
+ m_aBookmarksPositions.push_back(m_aBookmarks.insert(TInt2IntMap::value_type(nDriverPos,m_aBookmarksPositions.size()+1)).first);*/
+ }
+
+ return bDataFound;
+}
+// -------------------------------------------------------------------------
+sal_Bool OSkipDeletedSet::moveAbsolute(sal_Int32 _nPos,sal_Bool _bRetrieveData)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "commontools", "Ocke.Janssen@sun.com", "OSkipDeletedSet::moveAbsolute" );
+ sal_Bool bDataFound = sal_False;
+ sal_Int32 nNewPos = _nPos;
+ if(nNewPos > 0)
+ {
+ if((sal_Int32)m_aBookmarksPositions.size() < nNewPos)
+ {
+ // bookmark isn't known yet
+ // start at the last known position
+ sal_Int32 nCurPos = 0,nLastBookmark = 1;
+ if ( m_aBookmarksPositions.empty() )
+ {
+ bDataFound = m_pHelper->move(IResultSetHelper::FIRST, 0, _bRetrieveData );
+ if(bDataFound && (m_bDeletedVisible || !m_pHelper->isRowDeleted()))
+ {
+ ++nCurPos;
+ m_aBookmarksPositions.push_back(m_pHelper->getDriverPos());
+ //m_aBookmarksPositions.push_back(m_aBookmarks.insert(TInt2IntMap::value_type(m_pHelper->getDriverPos(),m_aBookmarksPositions.size()+1)).first);
+ --nNewPos;
+ }
+ } // if ( m_aBookmarksPositions.empty() )
+ else
+ {
+ nLastBookmark = (*m_aBookmarksPositions.rbegin())/*->first*/;
+ nCurPos = /*(**/m_aBookmarksPositions.size()/*->second*/;
+ nNewPos = nNewPos - nCurPos;
+ bDataFound = m_pHelper->move(IResultSetHelper::BOOKMARK, nLastBookmark, _bRetrieveData);
+ }
+
+ // now move to that row we need and don't count deleted rows
+ while (bDataFound && nNewPos)
+ {
+ bDataFound = m_pHelper->move(IResultSetHelper::NEXT, 1, _bRetrieveData);
+ if(bDataFound && (m_bDeletedVisible || !m_pHelper->isRowDeleted()))
+ {
+ ++nCurPos;
+ m_aBookmarksPositions.push_back(m_pHelper->getDriverPos());
+ //m_aBookmarksPositions.push_back(m_aBookmarks.insert(TInt2IntMap::value_type(m_pHelper->getDriverPos(),m_aBookmarksPositions.size()+1)).first);
+ --nNewPos;
+ }
+ }
+ }
+ else
+ {
+ const sal_Int32 nBookmark = m_aBookmarksPositions[nNewPos-1]/*->first*/;
+ bDataFound = m_pHelper->move(IResultSetHelper::BOOKMARK,nBookmark, _bRetrieveData);
+ OSL_ENSURE((m_bDeletedVisible || !m_pHelper->isRowDeleted()),"moveAbsolute: row can't be deleted!");
+ }
+ }
+ else
+ {
+ ++nNewPos;
+ bDataFound = skipDeleted(IResultSetHelper::LAST,0,nNewPos == 0);
+
+ for(sal_Int32 i=nNewPos+1;bDataFound && i <= 0;++i)
+ bDataFound = skipDeleted(IResultSetHelper::PRIOR,1,i == 0);
+
+ }
+ return bDataFound;
+}
+// -----------------------------------------------------------------------------
+void OSkipDeletedSet::clear()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "commontools", "Ocke.Janssen@sun.com", "OSkipDeletedSet::clear" );
+ ::std::vector<sal_Int32>().swap(m_aBookmarksPositions);
+ //TInt2IntMap().swap(m_aBookmarks);
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OSkipDeletedSet::getMappedPosition(sal_Int32 _nPos) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "commontools", "Ocke.Janssen@sun.com", "OSkipDeletedSet::getMappedPosition" );
+ ::std::vector<sal_Int32>::const_iterator aFind = ::std::find(m_aBookmarksPositions.begin(),m_aBookmarksPositions.end(),_nPos);
+ if ( aFind != m_aBookmarksPositions.end() )
+ return (aFind - m_aBookmarksPositions.begin()) + 1;
+ /*TInt2IntMap::const_iterator aFind = m_aBookmarks.find(_nPos);
+ OSL_ENSURE(aFind != m_aBookmarks.end(),"OSkipDeletedSet::getMappedPosition() invalid bookmark!");
+ return aFind->second;*/
+ OSL_ENSURE(0,"Why!");
+ return -1;
+}
+// -----------------------------------------------------------------------------
+void OSkipDeletedSet::insertNewPosition(sal_Int32 _nPos)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "commontools", "Ocke.Janssen@sun.com", "OSkipDeletedSet::insertNewPosition" );
+ //OSL_ENSURE(m_aBookmarks.find(_nPos) == m_aBookmarks.end(),"OSkipDeletedSet::insertNewPosition: Invalid position");
+ //m_aBookmarksPositions.push_back(m_aBookmarks.insert(TInt2IntMap::value_type(_nPos,m_aBookmarksPositions.size()+1)).first);
+ //OSL_ENSURE(::std::find(m_aBookmarksPositions.begin(),m_aBookmarksPositions.end(),_nPos) == m_aBookmarksPositions.end(),"Invalid driver pos");
+ m_aBookmarksPositions.push_back(_nPos);
+}
+// -----------------------------------------------------------------------------
+void OSkipDeletedSet::deletePosition(sal_Int32 _nBookmark)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "commontools", "Ocke.Janssen@sun.com", "OSkipDeletedSet::deletePosition" );
+ ::std::vector<sal_Int32>::iterator aFind = ::std::find(m_aBookmarksPositions.begin(),m_aBookmarksPositions.end(),_nBookmark);
+ if ( aFind != m_aBookmarksPositions.end() )
+ {
+ //TInt2IntMap::iterator aFind = m_aBookmarks.find(_nPos);
+ //OSL_ENSURE(aFind != m_aBookmarks.end(),"OSkipDeletedSet::deletePosition() bookmark not found!");
+ //TInt2IntMap::iterator aIter = aFind;
+ m_aBookmarksPositions.erase(aFind);
+ //for (; aFind != m_aBookmarksPositions.end() ; ++aIter)
+ // --(aFind->second);
+ } // if ( aFind != m_aBookmarksPositions.end() )
+ //m_aBookmarksPositions.erase(m_aBookmarksPositions.begin() + aFind->second-1);
+ //m_aBookmarks.erase(_nPos);
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/commontools/TSortIndex.cxx b/connectivity/source/commontools/TSortIndex.cxx
new file mode 100644
index 000000000000..c69ff0b89de1
--- /dev/null
+++ b/connectivity/source/commontools/TSortIndex.cxx
@@ -0,0 +1,178 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "TSortIndex.hxx"
+#include <algorithm>
+#include <functional>
+
+using namespace connectivity;
+//------------------------------------------------------------------
+/// binary_function Functor object for class OSortIndex::TIntValuePairVector::value_type returntype is bool
+struct TKeyValueFunc : ::std::binary_function<OSortIndex::TIntValuePairVector::value_type,OSortIndex::TIntValuePairVector::value_type,bool>
+{
+ OSortIndex* pIndex;
+
+ TKeyValueFunc(OSortIndex* _pIndex) : pIndex(_pIndex)
+ {
+ }
+ // return false if compared values are equal otherwise true
+ inline bool operator()(const OSortIndex::TIntValuePairVector::value_type& lhs,const OSortIndex::TIntValuePairVector::value_type& rhs) const
+ {
+ const ::std::vector<OKeyType>& aKeyType = pIndex->getKeyType();
+ ::std::vector<OKeyType>::const_iterator aIter = aKeyType.begin();
+ for (::std::vector<sal_Int16>::size_type i=0;aIter != aKeyType.end(); ++aIter,++i)
+ {
+ const bool nGreater = (pIndex->getAscending(i) == SQL_ASC) ? false : true;
+ const bool nLess = !nGreater;
+
+ // compare depending for type
+ switch (*aIter)
+ {
+ case SQL_ORDERBYKEY_STRING:
+ {
+ sal_Int32 nRes = lhs.second->getKeyString(i).compareTo(rhs.second->getKeyString(i));
+ if (nRes < 0)
+ return nLess;
+ else if (nRes > 0)
+ return nGreater;
+ }
+ break;
+ case SQL_ORDERBYKEY_DOUBLE:
+ {
+ double d1 = lhs.second->getKeyDouble(i);
+ double d2 = rhs.second->getKeyDouble(i);
+
+ if (d1 < d2)
+ return nLess;
+ else if (d1 > d2)
+ return nGreater;
+ }
+ break;
+ case SQL_ORDERBYKEY_NONE:
+ break;
+ }
+ }
+
+ // know we know that the values are equal
+ return false;
+ }
+};
+
+// -----------------------------------------------------------------------------
+::vos::ORef<OKeySet> OSortIndex::CreateKeySet()
+{
+ Freeze();
+
+ ::vos::ORef<OKeySet> pKeySet = new OKeySet();
+ pKeySet->get().reserve(m_aKeyValues.size());
+ ::std::transform(m_aKeyValues.begin()
+ ,m_aKeyValues.end()
+ ,::std::back_inserter(pKeySet->get())
+ ,::std::select1st<TIntValuePairVector::value_type>());
+ pKeySet->setFrozen();
+ return pKeySet;
+}
+// -----------------------------------------------------------------------------
+OSortIndex::OSortIndex( const ::std::vector<OKeyType>& _aKeyType,
+ const ::std::vector<TAscendingOrder>& _aAscending)
+ :m_aKeyType(_aKeyType)
+ ,m_aAscending(_aAscending)
+ ,m_bFrozen(sal_False)
+{
+}
+//------------------------------------------------------------------
+OSortIndex::~OSortIndex()
+{
+}
+//------------------------------------------------------------------
+void OSortIndex::AddKeyValue(OKeyValue * pKeyValue)
+{
+ OSL_ENSURE(pKeyValue,"Can not be null here!");
+ if(m_bFrozen)
+ {
+ m_aKeyValues.push_back(TIntValuePairVector::value_type(pKeyValue->getValue(),NULL));
+ delete pKeyValue;
+ }
+ else
+ m_aKeyValues.push_back(TIntValuePairVector::value_type(pKeyValue->getValue(),pKeyValue));
+}
+
+
+//------------------------------------------------------------------
+void OSortIndex::Freeze()
+{
+ OSL_ENSURE(! m_bFrozen,"OSortIndex::Freeze: already frozen!");
+ // Sortierung:
+ if (m_aKeyType[0] != SQL_ORDERBYKEY_NONE)
+ // we will sort ourself when the first keyType say so
+ ::std::sort(m_aKeyValues.begin(),m_aKeyValues.end(),TKeyValueFunc(this));
+
+ TIntValuePairVector::iterator aIter = m_aKeyValues.begin();
+ for(;aIter != m_aKeyValues.end();++aIter)
+ {
+ delete aIter->second;
+ aIter->second = NULL;
+ }
+
+ m_bFrozen = sal_True;
+}
+
+//------------------------------------------------------------------
+sal_Int32 OSortIndex::GetValue(sal_Int32 nPos) const
+{
+ OSL_ENSURE(nPos > 0,"OSortIndex::GetValue: nPos == 0");
+ OSL_ENSURE((size_t)nPos <= m_aKeyValues.size(),"OSortIndex::GetValue: Zugriff ausserhalb der Array-Grenzen");
+
+ if (!m_bFrozen && m_aKeyType[0] != SQL_ORDERBYKEY_NONE)
+ {
+ OSL_ASSERT("OSortIndex::GetValue: Invalid use of index!");
+ return 0;
+ }
+ return m_aKeyValues[nPos-1].first;
+}
+// -----------------------------------------------------------------------------
+OKeyValue::OKeyValue()
+{
+}
+// -----------------------------------------------------------------------------
+OKeyValue::OKeyValue(sal_Int32 nVal)
+: m_nValue(nVal)
+{
+}
+// -----------------------------------------------------------------------------
+OKeyValue::~OKeyValue()
+{
+}
+// -----------------------------------------------------------------------------
+OKeyValue* OKeyValue::createKeyValue(sal_Int32 _nVal)
+{
+ return new OKeyValue(_nVal);
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/commontools/TTableHelper.cxx b/connectivity/source/commontools/TTableHelper.cxx
new file mode 100644
index 000000000000..7d020e9fc4a6
--- /dev/null
+++ b/connectivity/source/commontools/TTableHelper.cxx
@@ -0,0 +1,630 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/TTableHelper.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/implementationreference.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <unotools/sharedunocomponent.hxx>
+#include "TConnection.hxx"
+
+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;
+namespace
+{
+ /// helper class for column property change events which holds the OComponentDefinition weak
+typedef ::cppu::WeakImplHelper1 < XContainerListener > OTableContainerListener_BASE;
+class OTableContainerListener : public OTableContainerListener_BASE
+{
+ OTableHelper* m_pComponent;
+ ::std::map< ::rtl::OUString,bool> m_aRefNames;
+
+ OTableContainerListener(const OTableContainerListener&);
+ void operator =(const OTableContainerListener&);
+protected:
+ virtual ~OTableContainerListener(){}
+public:
+ OTableContainerListener(OTableHelper* _pComponent) : m_pComponent(_pComponent){}
+ virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& /*Event*/ ) throw (RuntimeException)
+ {
+ }
+ virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (RuntimeException)
+ {
+ ::rtl::OUString sName;
+ Event.Accessor >>= sName;
+ if ( m_aRefNames.find(sName) != m_aRefNames.end() )
+ m_pComponent->refreshKeys();
+ }
+ virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (RuntimeException)
+ {
+ ::rtl::OUString sOldComposedName,sNewComposedName;
+ Event.ReplacedElement >>= sOldComposedName;
+ Event.Accessor >>= sNewComposedName;
+ if ( sOldComposedName != sNewComposedName && m_aRefNames.find(sOldComposedName) != m_aRefNames.end() )
+ m_pComponent->refreshKeys();
+ }
+ // XEventListener
+ virtual void SAL_CALL disposing( const EventObject& /*_rSource*/ ) throw (RuntimeException)
+ {
+ }
+ void clear() { m_pComponent = NULL; }
+ inline void add(const ::rtl::OUString& _sRefName) { m_aRefNames.insert(::std::map< ::rtl::OUString,bool>::value_type(_sRefName,true)); }
+};
+}
+namespace connectivity
+{
+ ::rtl::OUString lcl_getServiceNameForSetting(const Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,const ::rtl::OUString& i_sSetting)
+ {
+ ::rtl::OUString sSupportService;
+ Any aValue;
+ if ( ::dbtools::getDataSourceSetting(_xConnection,i_sSetting,aValue) )
+ {
+ aValue >>= sSupportService;
+ }
+ return sSupportService;
+ }
+ struct OTableHelperImpl
+ {
+ TKeyMap m_aKeys;
+ // helper services which can be provided by extensions
+ Reference< ::com::sun::star::sdb::tools::XTableRename> m_xRename;
+ Reference< ::com::sun::star::sdb::tools::XTableAlteration> m_xAlter;
+ Reference< ::com::sun::star::sdb::tools::XKeyAlteration> m_xKeyAlter;
+ Reference< ::com::sun::star::sdb::tools::XIndexAlteration> m_xIndexAlter;
+
+ Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+ Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+ ::comphelper::ImplementationReference< OTableContainerListener,XContainerListener>
+ m_xTablePropertyListener;
+ ::std::vector< ColumnDesc > m_aColumnDesc;
+ OTableHelperImpl(const Reference< ::com::sun::star::sdbc::XConnection >& _xConnection)
+ : m_xConnection(_xConnection)
+ {
+ try
+ {
+ m_xMetaData = m_xConnection->getMetaData();
+ Reference<XMultiServiceFactory> xFac(_xConnection,UNO_QUERY);
+ if ( xFac.is() )
+ {
+ static const ::rtl::OUString s_sTableRename(RTL_CONSTASCII_USTRINGPARAM("TableRenameServiceName"));
+ m_xRename.set(xFac->createInstance(lcl_getServiceNameForSetting(m_xConnection,s_sTableRename)),UNO_QUERY);
+ static const ::rtl::OUString s_sTableAlteration(RTL_CONSTASCII_USTRINGPARAM("TableAlterationServiceName"));
+ m_xAlter.set(xFac->createInstance(lcl_getServiceNameForSetting(m_xConnection,s_sTableAlteration)),UNO_QUERY);
+ static const ::rtl::OUString s_sKeyAlteration(RTL_CONSTASCII_USTRINGPARAM("KeyAlterationServiceName"));
+ m_xKeyAlter.set(xFac->createInstance(lcl_getServiceNameForSetting(m_xConnection,s_sKeyAlteration)),UNO_QUERY);
+ static const ::rtl::OUString s_sIndexAlteration(RTL_CONSTASCII_USTRINGPARAM("IndexAlterationServiceName"));
+ m_xIndexAlter.set(xFac->createInstance(lcl_getServiceNameForSetting(m_xConnection,s_sIndexAlteration)),UNO_QUERY);
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+ };
+}
+
+OTableHelper::OTableHelper( sdbcx::OCollection* _pTables,
+ const Reference< XConnection >& _xConnection,
+ sal_Bool _bCase)
+ :OTable_TYPEDEF(_pTables,_bCase)
+ ,m_pImpl(new OTableHelperImpl(_xConnection))
+{
+}
+// -------------------------------------------------------------------------
+OTableHelper::OTableHelper( sdbcx::OCollection* _pTables,
+ const Reference< XConnection >& _xConnection,
+ sal_Bool _bCase,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description ,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _CatalogName
+ ) : OTable_TYPEDEF(_pTables,
+ _bCase,
+ _Name,
+ _Type,
+ _Description,
+ _SchemaName,
+ _CatalogName)
+ ,m_pImpl(new OTableHelperImpl(_xConnection))
+{
+}
+// -----------------------------------------------------------------------------
+OTableHelper::~OTableHelper()
+{
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OTableHelper::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ if ( m_pImpl->m_xTablePropertyListener.is() )
+ {
+ m_pTables->removeContainerListener(m_pImpl->m_xTablePropertyListener.getRef());
+ m_pImpl->m_xTablePropertyListener->clear();
+ m_pImpl->m_xTablePropertyListener.dispose();
+ }
+ OTable_TYPEDEF::disposing();
+
+ m_pImpl->m_xConnection = NULL;
+ m_pImpl->m_xMetaData = NULL;
+
+}
+
+// -------------------------------------------------------------------------
+namespace
+{
+ /** collects ColumnDesc's from a resultset produced by XDatabaseMetaData::getColumns
+ */
+ void lcl_collectColumnDescs_throw( const Reference< XResultSet >& _rxResult, ::std::vector< ColumnDesc >& _out_rColumns )
+ {
+ Reference< XRow > xRow( _rxResult, UNO_QUERY_THROW );
+ ::rtl::OUString sName;
+ OrdinalPosition nOrdinalPosition( 0 );
+ while ( _rxResult->next() )
+ {
+ sName = xRow->getString( 4 ); // COLUMN_NAME
+ sal_Int32 nField5 = xRow->getInt(5);
+ ::rtl::OUString aField6 = xRow->getString(6);
+ sal_Int32 nField7 = xRow->getInt(7)
+ , nField9 = xRow->getInt(9)
+ , nField11= xRow->getInt(11);
+ ::rtl::OUString sField12 = xRow->getString(12)
+ ,sField13 = xRow->getString(13);
+ nOrdinalPosition = xRow->getInt( 17 ); // ORDINAL_POSITION
+ _out_rColumns.push_back( ColumnDesc( sName,nField5,aField6,nField7,nField9,nField11,sField12,sField13, nOrdinalPosition ) );
+ }
+ }
+
+ /** checks a given array of ColumnDesc's whether it has reasonable ordinal positions. If not,
+ they will be normalized to be the array index.
+ */
+ void lcl_sanitizeColumnDescs( ::std::vector< ColumnDesc >& _rColumns )
+ {
+ if ( _rColumns.empty() )
+ return;
+
+ // collect all used ordinals
+ ::std::set< OrdinalPosition > aUsedOrdinals;
+ for ( ::std::vector< ColumnDesc >::iterator collect = _rColumns.begin();
+ collect != _rColumns.end();
+ ++collect
+ )
+ aUsedOrdinals.insert( collect->nOrdinalPosition );
+
+ // we need to have as much different ordinals as we have different columns
+ bool bDuplicates = aUsedOrdinals.size() != _rColumns.size();
+ // and it needs to be a continuous range
+ size_t nOrdinalsRange = *aUsedOrdinals.rbegin() - *aUsedOrdinals.begin() + 1;
+ bool bGaps = nOrdinalsRange != _rColumns.size();
+
+ // if that's not the case, normalize it
+ if ( bGaps || bDuplicates )
+ {
+ OSL_ENSURE( false, "lcl_sanitizeColumnDescs: database did provide invalid ORDINAL_POSITION values!" );
+
+ OrdinalPosition nNormalizedPosition = 1;
+ for ( ::std::vector< ColumnDesc >::iterator normalize = _rColumns.begin();
+ normalize != _rColumns.end();
+ ++normalize
+ )
+ normalize->nOrdinalPosition = nNormalizedPosition++;
+ return;
+ }
+
+ // what's left is that the range might not be from 1 to <column count>, but for instance
+ // 0 to <column count>-1.
+ size_t nOffset = *aUsedOrdinals.begin() - 1;
+ for ( ::std::vector< ColumnDesc >::iterator offset = _rColumns.begin();
+ offset != _rColumns.end();
+ ++offset
+ )
+ offset->nOrdinalPosition -= nOffset;
+ }
+}
+
+// -------------------------------------------------------------------------
+void OTableHelper::refreshColumns()
+{
+ TStringVector aVector;
+ if(!isNew())
+ {
+ Any aCatalog;
+ if ( m_CatalogName.getLength() )
+ aCatalog <<= m_CatalogName;
+
+ ::utl::SharedUNOComponent< XResultSet > xResult( getMetaData()->getColumns(
+ aCatalog,
+ m_SchemaName,
+ m_Name,
+ ::rtl::OUString::createFromAscii("%")
+ ) );
+
+ // collect the column names, together with their ordinal position
+ m_pImpl->m_aColumnDesc.clear();
+ lcl_collectColumnDescs_throw( xResult, m_pImpl->m_aColumnDesc );
+
+ // ensure that the ordinal positions as obtained from the meta data do make sense
+ lcl_sanitizeColumnDescs( m_pImpl->m_aColumnDesc );
+
+ // sort by ordinal position
+ ::std::map< OrdinalPosition, ::rtl::OUString > aSortedColumns;
+ for ( ::std::vector< ColumnDesc >::const_iterator copy = m_pImpl->m_aColumnDesc.begin();
+ copy != m_pImpl->m_aColumnDesc.end();
+ ++copy
+ )
+ aSortedColumns[ copy->nOrdinalPosition ] = copy->sName;
+
+ // copy them to aVector, now that we have the proper ordering
+ ::std::transform(
+ aSortedColumns.begin(),
+ aSortedColumns.end(),
+ ::std::insert_iterator< TStringVector >( aVector, aVector.begin() ),
+ ::std::select2nd< ::std::map< OrdinalPosition, ::rtl::OUString >::value_type >()
+ );
+ }
+
+ if(m_pColumns)
+ m_pColumns->reFill(aVector);
+ else
+ m_pColumns = createColumns(aVector);
+}
+// -----------------------------------------------------------------------------
+const ColumnDesc* OTableHelper::getColumnDescription(const ::rtl::OUString& _sName) const
+{
+ const ColumnDesc* pRet = NULL;
+ ::std::vector< ColumnDesc >::const_iterator aEnd = m_pImpl->m_aColumnDesc.end();
+ for (::std::vector< ColumnDesc >::const_iterator aIter = m_pImpl->m_aColumnDesc.begin();aIter != aEnd;++aIter)
+ {
+ if ( aIter->sName == _sName )
+ {
+ pRet = &*aIter;
+ break;
+ }
+ } // for (::std::vector< ColumnDesc >::const_iterator aIter = m_pImpl->m_aColumnDesc.begin();aIter != aEnd;++aIter)
+ return pRet;
+}
+// -------------------------------------------------------------------------
+void OTableHelper::refreshPrimaryKeys(TStringVector& _rNames)
+{
+ Any aCatalog;
+ if ( m_CatalogName.getLength() )
+ aCatalog <<= m_CatalogName;
+ Reference< XResultSet > xResult = getMetaData()->getPrimaryKeys(aCatalog,m_SchemaName,m_Name);
+
+ if ( xResult.is() )
+ {
+ sdbcx::TKeyProperties pKeyProps(new sdbcx::KeyProperties(::rtl::OUString(),KeyType::PRIMARY,0,0));
+ ::rtl::OUString aPkName;
+ bool bAlreadyFetched = false;
+ const Reference< XRow > xRow(xResult,UNO_QUERY);
+ while ( xResult->next() )
+ {
+ pKeyProps->m_aKeyColumnNames.push_back(xRow->getString(4));
+ if ( !bAlreadyFetched )
+ {
+ aPkName = xRow->getString(6);
+ bAlreadyFetched = true;
+ }
+ }
+
+ m_pImpl->m_aKeys.insert(TKeyMap::value_type(aPkName,pKeyProps));
+ _rNames.push_back(aPkName);
+ } // if ( xResult.is() && xResult->next() )
+ ::comphelper::disposeComponent(xResult);
+}
+// -------------------------------------------------------------------------
+void OTableHelper::refreshForgeinKeys(TStringVector& _rNames)
+{
+ Any aCatalog;
+ if ( m_CatalogName.getLength() )
+ aCatalog <<= m_CatalogName;
+ Reference< XResultSet > xResult = getMetaData()->getImportedKeys(aCatalog,m_SchemaName,m_Name);
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+
+ if ( xRow.is() )
+ {
+ sdbcx::TKeyProperties pKeyProps;
+ ::rtl::OUString aName,sCatalog,aSchema,sOldFKName;
+ while( xResult->next() )
+ {
+ // this must be outsid the "if" because we have to call in a right order
+ sCatalog = xRow->getString(1);
+ if ( xRow->wasNull() )
+ sCatalog = ::rtl::OUString();
+ aSchema = xRow->getString(2);
+ aName = xRow->getString(3);
+
+ const ::rtl::OUString sForeignKeyColumn = xRow->getString(8);
+ const sal_Int32 nUpdateRule = xRow->getInt(10);
+ const sal_Int32 nDeleteRule = xRow->getInt(11);
+ const ::rtl::OUString sFkName = xRow->getString(12);
+
+ if ( pKeyProps.get() )
+ {
+ }
+
+
+ if ( sFkName.getLength() && !xRow->wasNull() )
+ {
+ if ( sOldFKName != sFkName )
+ {
+ if ( pKeyProps.get() )
+ m_pImpl->m_aKeys.insert(TKeyMap::value_type(sOldFKName,pKeyProps));
+
+ const ::rtl::OUString sReferencedName = ::dbtools::composeTableName(getMetaData(),sCatalog,aSchema,aName,sal_False,::dbtools::eInDataManipulation);
+ pKeyProps.reset(new sdbcx::KeyProperties(sReferencedName,KeyType::FOREIGN,nUpdateRule,nDeleteRule));
+ pKeyProps->m_aKeyColumnNames.push_back(sForeignKeyColumn);
+ _rNames.push_back(sFkName);
+ if ( m_pTables->hasByName(sReferencedName) )
+ {
+ if ( !m_pImpl->m_xTablePropertyListener.is() )
+ m_pImpl->m_xTablePropertyListener = ::comphelper::ImplementationReference< OTableContainerListener,XContainerListener>( new OTableContainerListener(this) );
+ m_pTables->addContainerListener(m_pImpl->m_xTablePropertyListener.getRef());
+ m_pImpl->m_xTablePropertyListener->add(sReferencedName);
+ } // if ( m_pTables->hasByName(sReferencedName) )
+ sOldFKName = sFkName;
+ } // if ( sOldFKName != sFkName )
+ else if ( pKeyProps.get() )
+ {
+ pKeyProps->m_aKeyColumnNames.push_back(sForeignKeyColumn);
+ }
+ }
+ } // while( xResult->next() )
+ if ( pKeyProps.get() )
+ m_pImpl->m_aKeys.insert(TKeyMap::value_type(sOldFKName,pKeyProps));
+ ::comphelper::disposeComponent(xResult);
+ }
+}
+// -------------------------------------------------------------------------
+void OTableHelper::refreshKeys()
+{
+ m_pImpl->m_aKeys.clear();
+
+ TStringVector aNames;
+
+ if(!isNew())
+ {
+ refreshPrimaryKeys(aNames);
+ refreshForgeinKeys(aNames);
+ m_pKeys = createKeys(aNames);
+ } // if(!isNew())
+ else if (!m_pKeys )
+ m_pKeys = createKeys(aNames);
+ /*if(m_pKeys)
+ m_pKeys->reFill(aVector);
+ else*/
+
+}
+// -------------------------------------------------------------------------
+void OTableHelper::refreshIndexes()
+{
+ TStringVector aVector;
+ if(!isNew())
+ {
+ // fill indexes
+ Any aCatalog;
+ if ( m_CatalogName.getLength() )
+ aCatalog <<= m_CatalogName;
+ Reference< XResultSet > xResult = getMetaData()->getIndexInfo(aCatalog,m_SchemaName,m_Name,sal_False,sal_False);
+
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ ::rtl::OUString aName;
+ ::rtl::OUString sCatalogSep = getMetaData()->getCatalogSeparator();
+ ::rtl::OUString sPreviousRoundName;
+ while( xResult->next() )
+ {
+ aName = xRow->getString(5);
+ if(aName.getLength())
+ aName += sCatalogSep;
+ aName += xRow->getString(6);
+ if ( aName.getLength() )
+ {
+ // don't insert the name if the last one we inserted was the same
+ if (sPreviousRoundName != aName)
+ aVector.push_back(aName);
+ }
+ sPreviousRoundName = aName;
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+ }
+
+ if(m_pIndexes)
+ m_pIndexes->reFill(aVector);
+ else
+ m_pIndexes = createIndexes(aVector);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OTableHelper::getRenameStart() const
+{
+ ::rtl::OUString sSql(RTL_CONSTASCII_USTRINGPARAM("RENAME "));
+ if ( m_Type == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW")) )
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" VIEW "));
+ else
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" TABLE "));
+
+ return sSql;
+}
+// -------------------------------------------------------------------------
+// XRename
+void SAL_CALL OTableHelper::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())
+ {
+ if ( m_pImpl->m_xRename.is() )
+ {
+ m_pImpl->m_xRename->rename(this,newName);
+ }
+ else
+ {
+ ::rtl::OUString sSql = getRenameStart();
+ ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( );
+
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(getMetaData(),newName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+
+ ::rtl::OUString sComposedName;
+ sComposedName = ::dbtools::composeTableName(getMetaData(),m_CatalogName,m_SchemaName,m_Name,sal_True,::dbtools::eInDataManipulation);
+ sSql += sComposedName
+ + ::rtl::OUString::createFromAscii(" TO ");
+ sComposedName = ::dbtools::composeTableName(getMetaData(),sCatalog,sSchema,sTable,sal_True,::dbtools::eInDataManipulation);
+ sSql += sComposedName;
+
+ Reference< XStatement > xStmt = m_pImpl->m_xConnection->createStatement( );
+ if ( xStmt.is() )
+ {
+ xStmt->execute(sSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+
+ OTable_TYPEDEF::rename(newName);
+ }
+ else
+ ::dbtools::qualifiedNameComponents(getMetaData(),newName,m_CatalogName,m_SchemaName,m_Name,::dbtools::eInTableDefinitions);
+}
+// -----------------------------------------------------------------------------
+Reference< XDatabaseMetaData> OTableHelper::getMetaData() const
+{
+ return m_pImpl->m_xMetaData;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OTableHelper::alterColumnByIndex( sal_Int32 index, const Reference< XPropertySet >& descriptor ) throw(SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(
+#ifdef GCC
+ ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed
+#else
+ rBHelper.bDisposed
+#endif
+ );
+
+ Reference< XPropertySet > xOld;
+ if(::cppu::extractInterface(xOld,m_pColumns->getByIndex(index)) && xOld.is())
+ alterColumnByName(getString(xOld->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))),descriptor);
+}
+
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OTableHelper::getName() throw(RuntimeException)
+{
+ ::rtl::OUString sComposedName;
+ sComposedName = ::dbtools::composeTableName(getMetaData(),m_CatalogName,m_SchemaName,m_Name,sal_False,::dbtools::eInDataManipulation);
+ return sComposedName;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OTableHelper::acquire() throw()
+{
+ OTable_TYPEDEF::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OTableHelper::release() throw()
+{
+ OTable_TYPEDEF::release();
+}
+// -----------------------------------------------------------------------------
+sdbcx::TKeyProperties OTableHelper::getKeyProperties(const ::rtl::OUString& _sName) const
+{
+ sdbcx::TKeyProperties pKeyProps;
+ TKeyMap::const_iterator aFind = m_pImpl->m_aKeys.find(_sName);
+ if ( aFind != m_pImpl->m_aKeys.end() )
+ {
+ pKeyProps = aFind->second;
+ }
+ else // only a fall back
+ {
+ OSL_ENSURE(0,"No key with the given name found");
+ pKeyProps.reset(new sdbcx::KeyProperties());
+ }
+
+ return pKeyProps;
+}
+// -----------------------------------------------------------------------------
+void OTableHelper::addKey(const ::rtl::OUString& _sName,const sdbcx::TKeyProperties& _aKeyProperties)
+{
+ m_pImpl->m_aKeys.insert(TKeyMap::value_type(_sName,_aKeyProperties));
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OTableHelper::getTypeCreatePattern() const
+{
+ return ::rtl::OUString();
+}
+// -----------------------------------------------------------------------------
+Reference< XConnection> OTableHelper::getConnection() const
+{
+ return m_pImpl->m_xConnection;
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::sdb::tools::XTableRename> OTableHelper::getRenameService() const
+{
+ return m_pImpl->m_xRename;
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::sdb::tools::XTableAlteration> OTableHelper::getAlterService() const
+{
+ return m_pImpl->m_xAlter;
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::sdb::tools::XKeyAlteration> OTableHelper::getKeyService() const
+{
+ return m_pImpl->m_xKeyAlter;
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::sdb::tools::XIndexAlteration> OTableHelper::getIndexService() const
+{
+ return m_pImpl->m_xIndexAlter;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/commontools/conncleanup.cxx b/connectivity/source/commontools/conncleanup.cxx
new file mode 100644
index 000000000000..0d8547923e87
--- /dev/null
+++ b/connectivity/source/commontools/conncleanup.cxx
@@ -0,0 +1,247 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/conncleanup.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <osl/diagnose.h>
+
+//.........................................................................
+namespace dbtools
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::lang;
+
+ //=====================================================================
+ static const ::rtl::OUString& getActiveConnectionPropertyName()
+ {
+ static const ::rtl::OUString s_sActiveConnectionPropertyName = ::rtl::OUString::createFromAscii("ActiveConnection");
+ return s_sActiveConnectionPropertyName;
+ }
+
+ //=====================================================================
+ //= OAutoConnectionDisposer
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OAutoConnectionDisposer::OAutoConnectionDisposer(const Reference< XRowSet >& _rxRowSet, const Reference< XConnection >& _rxConnection)
+ :m_xRowSet( _rxRowSet )
+ ,m_bRSListening( sal_False )
+ ,m_bPropertyListening( sal_False )
+ {
+ Reference< XPropertySet > xProps(_rxRowSet, UNO_QUERY);
+ OSL_ENSURE(xProps.is(), "OAutoConnectionDisposer::OAutoConnectionDisposer: invalid rowset (no XPropertySet)!");
+
+ if (!xProps.is())
+ return;
+
+ try
+ {
+ xProps->setPropertyValue( getActiveConnectionPropertyName(), makeAny( _rxConnection ) );
+ m_xOriginalConnection = _rxConnection;
+ startPropertyListening( xProps );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OAutoConnectionDisposer::OAutoConnectionDisposer: caught an exception!" );
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void OAutoConnectionDisposer::startPropertyListening( const Reference< XPropertySet >& _rxRowSet )
+ {
+ try
+ {
+ _rxRowSet->addPropertyChangeListener( getActiveConnectionPropertyName(), this );
+ m_bPropertyListening = sal_True;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OAutoConnectionDisposer::startPropertyListening: caught an exception!" );
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void OAutoConnectionDisposer::stopPropertyListening( const Reference< XPropertySet >& _rxEventSource )
+ {
+ // prevent deletion of ourself while we're herein
+ Reference< XInterface > xKeepAlive(static_cast< XWeak* >(this));
+
+ try
+ { // remove ourself as property change listener
+ OSL_ENSURE( _rxEventSource.is(), "OAutoConnectionDisposer::stopPropertyListening: invalid event source (no XPropertySet)!" );
+ if ( _rxEventSource.is() )
+ {
+ _rxEventSource->removePropertyChangeListener( getActiveConnectionPropertyName(), this );
+ m_bPropertyListening = sal_False;
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OAutoConnectionDisposer::stopPropertyListening: caught an exception!" );
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void OAutoConnectionDisposer::startRowSetListening()
+ {
+ OSL_ENSURE( !m_bRSListening, "OAutoConnectionDisposer::startRowSetListening: already listening!" );
+ try
+ {
+ if ( !m_bRSListening )
+ m_xRowSet->addRowSetListener( this );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OAutoConnectionDisposer::startRowSetListening: caught an exception!" );
+ }
+ m_bRSListening = sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ void OAutoConnectionDisposer::stopRowSetListening()
+ {
+ OSL_ENSURE( m_bRSListening, "OAutoConnectionDisposer::stopRowSetListening: not listening!" );
+ try
+ {
+ m_xRowSet->removeRowSetListener( this );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OAutoConnectionDisposer::stopRowSetListening: caught an exception!" );
+ }
+ m_bRSListening = sal_False;
+ }
+
+ //---------------------------------------------------------------------
+ void SAL_CALL OAutoConnectionDisposer::propertyChange( const PropertyChangeEvent& _rEvent ) throw (RuntimeException)
+ {
+ if ( _rEvent.PropertyName.equals( getActiveConnectionPropertyName() ) )
+ { // somebody set a new ActiveConnection
+
+ Reference< XConnection > xNewConnection;
+ _rEvent.NewValue >>= xNewConnection;
+
+ if ( isRowSetListening() )
+ {
+ // we're listening at the row set, this means that the row set does not have our
+ // m_xOriginalConnection as active connection anymore
+ // So there are two possibilities
+ // a. somebody sets a new connection which is not our original one
+ // b. somebody sets a new connection, which is exactly the original one
+ // a. we're not interested in a, but in b: In this case, we simply need to move to the state
+ // we had originally: listen for property changes, do not listen for row set changes, and
+ // do not dispose the connection until the row set does not need it anymore
+ if ( xNewConnection.get() == m_xOriginalConnection.get() )
+ {
+ stopRowSetListening();
+ }
+ }
+ else
+ {
+ // start listening at the row set. We're allowed to dispose the old connection as soon
+ // as the RowSet changed
+
+ // Unfortunately, the our database form implementations sometimes fire the change of their
+ // ActiveConnection twice. This is a error in forms/source/component/DatabaseForm.cxx, but
+ // changing this would require incompatible changes we can't do for a while.
+ // So for the moment, we have to live with it here.
+ //
+ // The only scenario where this doubled notification causes problems is when the connection
+ // of the form is reset to the one we're responsible for (m_xOriginalConnection), so we
+ // check this here.
+ //
+ // Yes, this is a HACK :(
+ //
+ // 94407 - 08.11.2001 - fs@openoffice.org
+ if ( xNewConnection.get() != m_xOriginalConnection.get() )
+ {
+#if OSL_DEBUG_LEVEL > 0
+ Reference< XConnection > xOldConnection;
+ _rEvent.OldValue >>= xOldConnection;
+ OSL_ENSURE( xOldConnection.get() == m_xOriginalConnection.get(), "OAutoConnectionDisposer::propertyChange: unexpected (original) property value!" );
+#endif
+ startRowSetListening();
+ }
+ }
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void SAL_CALL OAutoConnectionDisposer::disposing( const EventObject& _rSource ) throw (RuntimeException)
+ {
+ // the rowset is beeing disposed, and nobody has set a new ActiveConnection in the meantime
+ if ( isRowSetListening() )
+ stopRowSetListening();
+
+ clearConnection();
+
+ if ( isPropertyListening() )
+ stopPropertyListening( Reference< XPropertySet >( _rSource.Source, UNO_QUERY ) );
+ }
+ //---------------------------------------------------------------------
+ void OAutoConnectionDisposer::clearConnection()
+ {
+ try
+ {
+ // dispose the old connection
+ Reference< XComponent > xComp(m_xOriginalConnection, UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ m_xOriginalConnection.clear();
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(sal_False, "OAutoConnectionDisposer::clearConnection: caught an exception!");
+ }
+ }
+ //---------------------------------------------------------------------
+ void SAL_CALL OAutoConnectionDisposer::cursorMoved( const ::com::sun::star::lang::EventObject& /*event*/ ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ }
+ //---------------------------------------------------------------------
+ void SAL_CALL OAutoConnectionDisposer::rowChanged( const ::com::sun::star::lang::EventObject& /*event*/ ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ }
+ //---------------------------------------------------------------------
+ void SAL_CALL OAutoConnectionDisposer::rowSetChanged( const ::com::sun::star::lang::EventObject& /*event*/ ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ stopRowSetListening();
+ clearConnection();
+
+ }
+ //---------------------------------------------------------------------
+
+//.........................................................................
+} // namespace dbtools
+//.........................................................................
+
diff --git a/connectivity/source/commontools/dbcharset.cxx b/connectivity/source/commontools/dbcharset.cxx
new file mode 100644
index 000000000000..7cd722781cda
--- /dev/null
+++ b/connectivity/source/commontools/dbcharset.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 <connectivity/dbcharset.hxx>
+#include "diagnose_ex.h"
+#include <osl/diagnose.h>
+#include <rtl/tencinfo.h>
+
+//.........................................................................
+namespace dbtools
+{
+//.........................................................................
+
+ //=========================================================================
+ //= OCharsetMap
+ //=========================================================================
+ //-------------------------------------------------------------------------
+ OCharsetMap::OCharsetMap()
+ {
+ }
+
+ //-------------------------------------------------------------------------
+ void OCharsetMap::lateConstruct()
+ {
+ const rtl_TextEncoding eFirstEncoding = RTL_TEXTENCODING_DONTKNOW;
+ const rtl_TextEncoding eLastEncoding = 100; // TODO: a define in rtl/textenc.h would be fine here ...
+ OSL_ENSURE( 0 == eFirstEncoding, "OCharsetMap::OCharsetMap: somebody changed the numbers!" );
+
+ rtl_TextEncodingInfo aInfo; aInfo.StructSize = sizeof( rtl_TextEncodingInfo );
+ for ( rtl_TextEncoding eEncoding = eFirstEncoding; eEncoding < eLastEncoding; ++eEncoding )
+ {
+ if ( ( RTL_TEXTENCODING_DONTKNOW == eEncoding ) // this is always allowed - it has the special meaning "system encoding"
+ || ( rtl_getTextEncodingInfo( eEncoding, &aInfo )
+ && approveEncoding( eEncoding, aInfo )
+ )
+ )
+ {
+ m_aEncodings.insert( eEncoding );
+ }
+ }
+
+ OSL_ENSURE( find( RTL_TEXTENCODING_MS_1252 ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding ANSI!" );
+ OSL_ENSURE( find( RTL_TEXTENCODING_APPLE_ROMAN ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding macintosh!" );
+ OSL_ENSURE( find( RTL_TEXTENCODING_IBM_437 ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding IBM437!" );
+ OSL_ENSURE( find( RTL_TEXTENCODING_IBM_850) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding IBM850!" );
+ OSL_ENSURE( find( RTL_TEXTENCODING_IBM_860 ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding IBM860!" );
+ OSL_ENSURE( find( RTL_TEXTENCODING_IBM_861 ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding IBM861!" );
+ OSL_ENSURE( find( RTL_TEXTENCODING_IBM_863 ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding IBM863!" );
+ OSL_ENSURE( find( RTL_TEXTENCODING_IBM_865 ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding IBM865!" );
+ OSL_ENSURE( find( RTL_TEXTENCODING_IBM_866 ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding IBM866!" );
+ OSL_ENSURE( find( RTL_TEXTENCODING_DONTKNOW ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding SYSTEM!" );
+ OSL_ENSURE( find( RTL_TEXTENCODING_UTF8 ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding UTF-8!" );
+ OSL_ENSURE( find( RTL_TEXTENCODING_BIG5_HKSCS ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding Big5-HKSCS!" );
+ }
+
+ //-------------------------------------------------------------------------
+ sal_Bool OCharsetMap::approveEncoding( const rtl_TextEncoding _eEncoding, const rtl_TextEncodingInfo& _rInfo ) const
+ {
+ sal_Bool bIsMimeEncoding = 0 != ( _rInfo.Flags & RTL_TEXTENCODING_INFO_MIME );
+ OSL_ENSURE( !bIsMimeEncoding || rtl_getMimeCharsetFromTextEncoding( _eEncoding ),
+ "OCharsetMap::OCharsetMap: inconsistence in rtl!" );
+ OSL_UNUSED( _eEncoding );
+ return bIsMimeEncoding;
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetMap::~OCharsetMap()
+ {
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetMap::CharsetIterator OCharsetMap::begin() const
+ {
+ ensureConstructed( );
+ return CharsetIterator(this, m_aEncodings.begin() );
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetMap::CharsetIterator OCharsetMap::find(const rtl_TextEncoding _eEncoding) const
+ {
+ ensureConstructed( );
+ return CharsetIterator( this, m_aEncodings.find( _eEncoding ) );
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetMap::CharsetIterator OCharsetMap::find(const ::rtl::OUString& _rIanaName, const IANA&) const
+ {
+ ensureConstructed( );
+
+ rtl_TextEncoding eEncoding = RTL_TEXTENCODING_DONTKNOW;
+ if ( _rIanaName.getLength() )
+ {
+ // byte string conversion
+ ::rtl::OString sMimeByteString( _rIanaName.getStr(), _rIanaName.getLength(), RTL_TEXTENCODING_ASCII_US );
+ // look up
+ eEncoding = rtl_getTextEncodingFromMimeCharset( sMimeByteString.getStr() );
+
+ if ( RTL_TEXTENCODING_DONTKNOW == eEncoding )
+ { // if we're here, the name is not empty, but unknown -> this is an invalid name
+ return end();
+ }
+ }
+
+ return find( eEncoding );
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetMap::CharsetIterator OCharsetMap::end() const
+ {
+ ensureConstructed( );
+
+ return CharsetIterator( this, m_aEncodings.end() );
+ }
+
+ //=========================================================================
+ //= CharsetIteratorDerefHelper
+ //=========================================================================
+ //-------------------------------------------------------------------------
+ CharsetIteratorDerefHelper::CharsetIteratorDerefHelper( const CharsetIteratorDerefHelper& _rSource )
+ :m_eEncoding( _rSource.m_eEncoding )
+ ,m_aIanaName( _rSource.m_aIanaName )
+ {
+ }
+
+ //-------------------------------------------------------------------------
+ CharsetIteratorDerefHelper:: CharsetIteratorDerefHelper(const rtl_TextEncoding _eEncoding, const ::rtl::OUString& _rIanaName )
+ :m_eEncoding( _eEncoding )
+ ,m_aIanaName( _rIanaName )
+ {
+ }
+
+ //-------------------------------------------------------------------------
+ CharsetIteratorDerefHelper::CharsetIteratorDerefHelper()
+ :m_eEncoding(RTL_TEXTENCODING_DONTKNOW)
+ {
+ }
+
+ //=========================================================================
+ //= OCharsetMap::CharsetIterator
+ //=========================================================================
+ //-------------------------------------------------------------------------
+ OCharsetMap::CharsetIterator::CharsetIterator(const OCharsetMap* _pContainer, OCharsetMap::TextEncBag::const_iterator _aPos )
+ :m_pContainer( _pContainer )
+ ,m_aPos( _aPos )
+ {
+ OSL_ENSURE( m_pContainer, "OCharsetMap::CharsetIterator::CharsetIterator : invalid container!" );
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetMap::CharsetIterator::CharsetIterator(const CharsetIterator& _rSource)
+ :m_pContainer( _rSource.m_pContainer )
+ ,m_aPos( _rSource.m_aPos )
+ {
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetMap::CharsetIterator::~CharsetIterator()
+ {
+ }
+
+ //-------------------------------------------------------------------------
+ CharsetIteratorDerefHelper OCharsetMap::CharsetIterator::operator*() const
+ {
+ OSL_ENSURE( m_aPos != m_pContainer->m_aEncodings.end(), "OCharsetMap::CharsetIterator::operator*: invalid position!");
+
+ rtl_TextEncoding eEncoding = *m_aPos;
+ ::rtl::OUString sIanaName;
+
+ if ( RTL_TEXTENCODING_DONTKNOW != eEncoding )
+ { // it's not the virtual "system charset"
+ const char* pIanaName = rtl_getMimeCharsetFromTextEncoding( eEncoding );
+ OSL_ENSURE( pIanaName, "OCharsetMap::CharsetIterator: invalid mime name!" );
+ if ( pIanaName )
+ sIanaName = ::rtl::OUString::createFromAscii( pIanaName );
+ }
+ return CharsetIteratorDerefHelper( eEncoding, sIanaName );
+ }
+
+ //-------------------------------------------------------------------------
+ const OCharsetMap::CharsetIterator& OCharsetMap::CharsetIterator::operator++()
+ {
+ OSL_ENSURE( m_aPos != m_pContainer->m_aEncodings.end(), "OCharsetMap::CharsetIterator::operator++ : invalid position!" );
+ if ( m_aPos != m_pContainer->m_aEncodings.end())
+ ++m_aPos;
+ return *this;
+ }
+
+ //-------------------------------------------------------------------------
+ const OCharsetMap::CharsetIterator& OCharsetMap::CharsetIterator::operator--()
+ {
+ OSL_ENSURE( m_aPos != m_pContainer->m_aEncodings.begin(), "OCharsetMap::CharsetIterator::operator-- : invalid position!" );
+ if ( m_aPos != m_pContainer->m_aEncodings.begin() )
+ --m_aPos;
+ return *this;
+ }
+
+ //-------------------------------------------------------------------------
+ bool operator==(const OCharsetMap::CharsetIterator& lhs, const OCharsetMap::CharsetIterator& rhs)
+ {
+ return ( lhs.m_pContainer == rhs.m_pContainer ) && ( lhs.m_aPos == rhs.m_aPos );
+ }
+
+//.........................................................................
+} // namespace dbtools
+//.........................................................................
+
diff --git a/connectivity/source/commontools/dbconversion.cxx b/connectivity/source/commontools/dbconversion.cxx
new file mode 100644
index 000000000000..6149b4748c30
--- /dev/null
+++ b/connectivity/source/commontools/dbconversion.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 <connectivity/dbconversion.hxx>
+#include <connectivity/dbcharset.hxx>
+#include <osl/diagnose.h>
+#ifndef _INC_STDIO
+#include <stdio.h>
+#endif
+#include <com/sun/star/sdbc/SQLException.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include <rtl/ustrbuf.hxx>
+
+#define MAX_DAYS 3636532
+
+//.........................................................................
+namespace dbtools
+{
+//.........................................................................
+
+
+ using namespace ::comphelper;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+
+
+ //------------------------------------------------------------------------------
+ ::com::sun::star::util::Date DBTypeConversion::getStandardDate()
+ {
+ static ::com::sun::star::util::Date STANDARD_DB_DATE(1,1,1900);
+ return STANDARD_DB_DATE;
+ }
+ //------------------------------------------------------------------------------
+ ::rtl::OUString DBTypeConversion::toDateString(const Date& rDate)
+ {
+ sal_Char s[11];
+ snprintf(s,
+ sizeof(s),
+ "%04d-%02d-%02d",
+ (int)rDate.Year,
+ (int)rDate.Month,
+ (int)rDate.Day);
+ s[10] = 0;
+ return ::rtl::OUString::createFromAscii(s);
+ }
+ //------------------------------------------------------------------
+ ::rtl::OUString DBTypeConversion::toTimeString(const Time& rTime)
+ {
+ sal_Char s[9];
+ snprintf(s,
+ sizeof(s),
+ "%02d:%02d:%02d",
+ (int)rTime.Hours,
+ (int)rTime.Minutes,
+ (int)rTime.Seconds);
+ s[8] = 0;
+ return ::rtl::OUString::createFromAscii(s);
+ }
+
+ //------------------------------------------------------------------
+ ::rtl::OUString DBTypeConversion::toDateTimeString(const DateTime& _rDateTime)
+ {
+ Date aDate(_rDateTime.Day,_rDateTime.Month,_rDateTime.Year);
+ ::rtl::OUStringBuffer aTemp(toDateString(aDate));
+ aTemp.appendAscii(" ");
+ Time aTime(0,_rDateTime.Seconds,_rDateTime.Minutes,_rDateTime.Hours);
+ aTemp.append( toTimeString(aTime) );
+ aTemp.appendAscii(".");
+ aTemp.append( static_cast<sal_Int32>(_rDateTime.HundredthSeconds));
+ return aTemp.makeStringAndClear();
+ }
+ //------------------------------------------------------------------------------
+ Date DBTypeConversion::toDate(sal_Int32 _nVal)
+ {
+ Date aReturn;
+ aReturn.Day = (sal_uInt16)(_nVal % 100);
+ aReturn.Month = (sal_uInt16)((_nVal / 100) % 100);
+ aReturn.Year = (sal_uInt16)(_nVal / 10000);
+ return aReturn;
+ }
+
+ //------------------------------------------------------------------------------
+ Time DBTypeConversion::toTime(sal_Int32 _nVal)
+ {
+ Time aReturn;
+ aReturn.Hours = (sal_uInt16)(((sal_uInt32)(_nVal >= 0 ? _nVal : _nVal*-1)) / 1000000);
+ aReturn.Minutes = (sal_uInt16)((((sal_uInt32)(_nVal >= 0 ? _nVal : _nVal*-1)) / 10000) % 100);
+ aReturn.Seconds = (sal_uInt16)((((sal_uInt32)(_nVal >= 0 ? _nVal : _nVal*-1)) / 100) % 100);
+ aReturn.HundredthSeconds = (sal_uInt16)(((sal_uInt32)(_nVal >= 0 ? _nVal : _nVal*-1)) % 100);
+ return aReturn;
+ }
+
+ const double fMilliSecondsPerDay = 86400000.0;
+ //------------------------------------------------------------------------------
+ sal_Int32 DBTypeConversion::toINT32(const Date& rVal)
+ {
+ return ((sal_Int32)(rVal.Day%100)) +
+ (((sal_Int32)(rVal.Month%100))*100) +
+ (((sal_Int32) rVal.Year%10000)*10000);
+ }
+
+ //------------------------------------------------------------------------------
+ sal_Int32 DBTypeConversion::toINT32(const Time& rVal)
+ {
+ // Zeit normalisieren
+ sal_Int32 nSeconds = rVal.Seconds + rVal.HundredthSeconds / 100;
+ sal_Int32 nHundredthSeconds = rVal.HundredthSeconds % 100;
+ sal_Int32 nMinutes = rVal.Minutes + nSeconds / 60;
+ nSeconds = nSeconds % 60;
+ sal_Int32 nHours = rVal.Hours + nMinutes / 60;
+ nMinutes = nMinutes % 60;
+
+ // Zeit zusammenbauen
+ return (sal_Int32)(nHundredthSeconds + (nSeconds*100) + (nMinutes*10000) + (nHours*1000000));
+ }
+
+ //------------------------------------------------------------------------------
+ sal_Int64 DBTypeConversion::toINT64(const DateTime& rVal)
+ {
+ // Zeit normalisieren
+ sal_Int32 nSeconds = rVal.Seconds + rVal.HundredthSeconds / 100;
+ sal_Int32 nHundredthSeconds = rVal.HundredthSeconds % 100;
+ sal_Int32 nMinutes = rVal.Minutes + nSeconds / 60;
+ nSeconds = nSeconds % 60;
+ sal_Int32 nHours = rVal.Hours + nMinutes / 60;
+ nMinutes = nMinutes % 60;
+
+ // Zeit zusammenbauen
+ sal_Int32 nTime = (sal_Int32)(nHundredthSeconds + (nSeconds*100) + (nMinutes*10000) + (nHours*1000000));
+ sal_Int32 nDate = ((sal_Int32)(rVal.Day%100)) + (((sal_Int32)(rVal.Month%100))*100) + (((sal_Int32) rVal.Year%10000)*10000);
+ sal_Int64 nRet;
+
+ nRet = (sal_Int64) nTime;
+ nRet <<= 32;
+ nRet += nDate;
+
+ return nRet;
+ }
+
+ //------------------------------------------------------------------------------
+ sal_Int32 DBTypeConversion::getMsFromTime(const Time& rVal)
+ {
+ sal_Int32 nHour = rVal.Hours;
+ sal_Int32 nMin = rVal.Minutes;
+ sal_Int32 nSec = rVal.Seconds;
+ sal_Int32 n100Sec = rVal.HundredthSeconds;
+
+ return ((nHour*3600000)+(nMin*60000)+(nSec*1000)+(n100Sec*10));
+ }
+
+ //------------------------------------------------------------------------------
+ static sal_Int32 aDaysInMonth[12] = { 31, 28, 31, 30, 31, 30,
+ 31, 31, 30, 31, 30, 31 };
+
+ //------------------------------------------------------------------------------
+ static sal_Bool implIsLeapYear(sal_Int32 _nYear)
+ {
+ return ( ( ((_nYear % 4) == 0)
+ && ((_nYear % 100) != 0)
+ )
+ )
+ || ((_nYear % 400) == 0)
+ ;
+ }
+
+ //------------------------------------------------------------------------------
+ static sal_Int32 implDaysInMonth(sal_Int32 _nMonth, sal_Int32 _nYear)
+ {
+ OSL_ENSURE(_nMonth > 0 && _nMonth < 13,"Month as invalid value!");
+ if (_nMonth != 2)
+ return aDaysInMonth[_nMonth-1];
+ else
+ {
+ if (implIsLeapYear(_nYear))
+ return aDaysInMonth[_nMonth-1] + 1;
+ else
+ return aDaysInMonth[_nMonth-1];
+ }
+ }
+
+ //------------------------------------------------------------------------------
+ static sal_Int32 implRelativeToAbsoluteNull(const Date& _rDate)
+ {
+ sal_Int32 nDays = 0;
+
+ // ripped this code from the implementation of tools::Date
+ sal_Int32 nNormalizedYear = _rDate.Year - 1;
+ nDays = nNormalizedYear * 365;
+ // leap years
+ nDays += (nNormalizedYear / 4) - (nNormalizedYear / 100) + (nNormalizedYear / 400);
+
+ for (sal_Int32 i = 1; i < _rDate.Month; ++i)
+ nDays += implDaysInMonth(i, _rDate.Year);
+
+ nDays += _rDate.Day;
+ return nDays;
+ }
+ //------------------------------------------------------------------------------
+ static void implBuildFromRelative( sal_Int32 nDays, sal_uInt16& rDay, sal_uInt16& rMonth, sal_uInt16& rYear)
+ {
+ sal_Int32 nTempDays;
+ sal_Int32 i = 0;
+ sal_Bool bCalc;
+
+ do
+ {
+ nTempDays = nDays;
+ rYear = (sal_uInt16)((nTempDays / 365) - i);
+ nTempDays -= (rYear-1) * 365;
+ nTempDays -= ((rYear-1) / 4) - ((rYear-1) / 100) + ((rYear-1) / 400);
+ bCalc = sal_False;
+ if ( nTempDays < 1 )
+ {
+ i++;
+ bCalc = sal_True;
+ }
+ else
+ {
+ if ( nTempDays > 365 )
+ {
+ if ( (nTempDays != 366) || !implIsLeapYear( rYear ) )
+ {
+ i--;
+ bCalc = sal_True;
+ }
+ }
+ }
+ }
+ while ( bCalc );
+
+ rMonth = 1;
+ while ( nTempDays > implDaysInMonth( rMonth, rYear ) )
+ {
+ nTempDays -= implDaysInMonth( rMonth, rYear );
+ rMonth++;
+ }
+ rDay = (sal_uInt16)nTempDays;
+ }
+ //------------------------------------------------------------------------------
+ sal_Int32 DBTypeConversion::toDays(const Date& _rVal, const Date& _rNullDate)
+ {
+ return implRelativeToAbsoluteNull(_rVal) - implRelativeToAbsoluteNull(_rNullDate);
+ }
+
+ //------------------------------------------------------------------------------
+ double DBTypeConversion::toDouble(const Date& rVal, const Date& _rNullDate)
+ {
+ return (double)toDays(rVal, _rNullDate);
+ }
+
+ //------------------------------------------------------------------------------
+ double DBTypeConversion::toDouble(const Time& rVal)
+ {
+ return (double)getMsFromTime(rVal) / fMilliSecondsPerDay;
+ }
+
+ //------------------------------------------------------------------------------
+ double DBTypeConversion::toDouble(const DateTime& _rVal, const Date& _rNullDate)
+ {
+ sal_Int64 nTime = toDays(Date(_rVal.Day, _rVal.Month, _rVal.Year), _rNullDate);
+ Time aTimePart;
+
+ aTimePart.Hours = _rVal.Hours;
+ aTimePart.Minutes = _rVal.Minutes;
+ aTimePart.Seconds = _rVal.Seconds;
+ aTimePart.HundredthSeconds = _rVal.HundredthSeconds;
+
+ return ((double)nTime) + toDouble(aTimePart);
+ }
+ // -------------------------------------------------------------------------
+ static void addDays(sal_Int32 nDays, Date& _rDate)
+ {
+ sal_Int32 nTempDays = implRelativeToAbsoluteNull( _rDate );
+
+ nTempDays += nDays;
+ if ( nTempDays > MAX_DAYS )
+ {
+ _rDate.Day = 31;
+ _rDate.Month = 12;
+ _rDate.Year = 9999;
+ }
+ else if ( nTempDays <= 0 )
+ {
+ _rDate.Day = 1;
+ _rDate.Month = 1;
+ _rDate.Year = 00;
+ }
+ else
+ implBuildFromRelative( nTempDays, _rDate.Day, _rDate.Month, _rDate.Year );
+ }
+ // -----------------------------------------------------------------------
+ static void subDays( sal_Int32 nDays, Date& _rDate )
+ {
+ sal_Int32 nTempDays = implRelativeToAbsoluteNull( _rDate );
+
+ nTempDays -= nDays;
+ if ( nTempDays > MAX_DAYS )
+ {
+ _rDate.Day = 31;
+ _rDate.Month = 12;
+ _rDate.Year = 9999;
+ }
+ else if ( nTempDays <= 0 )
+ {
+ _rDate.Day = 1;
+ _rDate.Month = 1;
+ _rDate.Year = 00;
+ }
+ else
+ implBuildFromRelative( nTempDays, _rDate.Day, _rDate.Month, _rDate.Year );
+ }
+ // -------------------------------------------------------------------------
+ Date DBTypeConversion::toDate(double dVal, const Date& _rNullDate)
+ {
+ Date aRet = _rNullDate;
+
+ if (dVal >= 0)
+ addDays((sal_Int32)dVal,aRet);
+ else
+ subDays((sal_uInt32)(-dVal),aRet);
+ // x -= (sal_uInt32)(-nDays);
+
+ return aRet;
+ }
+ // -------------------------------------------------------------------------
+ Time DBTypeConversion::toTime(double dVal)
+ {
+ sal_Int32 nDays = (sal_Int32)dVal;
+ sal_Int32 nMS = sal_Int32((dVal - (double)nDays) * fMilliSecondsPerDay + 0.5);
+
+ sal_Int16 nSign;
+ if ( nMS < 0 )
+ {
+ nMS *= -1;
+ nSign = -1;
+ }
+ else
+ nSign = 1;
+
+ Time xRet;
+ // Zeit normalisieren
+ // we have to sal_Int32 here because otherwise we get an overflow
+ sal_Int32 nHundredthSeconds = nMS/10;
+ sal_Int32 nSeconds = nHundredthSeconds / 100;
+ sal_Int32 nMinutes = nSeconds / 60;
+
+ xRet.HundredthSeconds = (sal_uInt16)(nHundredthSeconds % 100);
+ xRet.Seconds = (sal_uInt16)(nSeconds % 60);
+ xRet.Hours = (sal_uInt16)(nMinutes / 60);
+ xRet.Minutes = (sal_uInt16)(nMinutes % 60);
+
+ // Zeit zusammenbauen
+ sal_Int32 nTime = (sal_Int32)(xRet.HundredthSeconds + (xRet.Seconds*100) + (xRet.Minutes*10000) + (xRet.Hours*1000000)) * nSign;
+
+ if(nTime < 0)
+ {
+ xRet.HundredthSeconds = 99;
+ xRet.Minutes = 59;
+ xRet.Seconds = 59;
+ xRet.Hours = 23;
+ }
+ return xRet;
+ }
+ //------------------------------------------------------------------------------
+ DateTime DBTypeConversion::toDateTime(double dVal, const Date& _rNullDate)
+ {
+ Date aDate = toDate(dVal, _rNullDate);
+ Time aTime = toTime(dVal);
+
+ DateTime xRet;
+
+ xRet.Day = aDate.Day;
+ xRet.Month = aDate.Month;
+ xRet.Year = aDate.Year;
+
+ xRet.HundredthSeconds = aTime.HundredthSeconds;
+ xRet.Minutes = aTime.Minutes;
+ xRet.Seconds = aTime.Seconds;
+ xRet.Hours = aTime.Hours;
+
+
+ return xRet;
+ }
+ //------------------------------------------------------------------------------
+ Date DBTypeConversion::toDate(const ::rtl::OUString& _sSQLString)
+ {
+ // get the token out of a string
+ static sal_Unicode sDateSep = '-';
+
+ sal_Int32 nIndex = 0;
+ sal_uInt16 nYear = 0,
+ nMonth = 0,
+ nDay = 0;
+ nYear = (sal_uInt16)_sSQLString.getToken(0,sDateSep,nIndex).toInt32();
+ if(nIndex != -1)
+ {
+ nMonth = (sal_uInt16)_sSQLString.getToken(0,sDateSep,nIndex).toInt32();
+ if(nIndex != -1)
+ nDay = (sal_uInt16)_sSQLString.getToken(0,sDateSep,nIndex).toInt32();
+ }
+
+ return Date(nDay,nMonth,nYear);
+ }
+
+ //-----------------------------------------------------------------------------
+ DateTime DBTypeConversion::toDateTime(const ::rtl::OUString& _sSQLString)
+ {
+ //@see http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Timestamp.html#valueOf(java.lang.String)
+ //@see http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Date.html#valueOf(java.lang.String)
+ //@see http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Time.html#valueOf(java.lang.String)
+
+ // the date part
+ Date aDate = toDate(_sSQLString);
+ Time aTime;
+ sal_Int32 nSeparation = _sSQLString.indexOf( ' ' );
+ if ( -1 != nSeparation )
+ aTime = toTime( _sSQLString.copy( nSeparation ) );
+
+ return DateTime(aTime.HundredthSeconds,aTime.Seconds,aTime.Minutes,aTime.Hours,aDate.Day,aDate.Month,aDate.Year);
+ }
+
+ //-----------------------------------------------------------------------------
+ Time DBTypeConversion::toTime(const ::rtl::OUString& _sSQLString)
+ {
+ static sal_Unicode sTimeSep = ':';
+
+ sal_Int32 nIndex = 0;
+ sal_uInt16 nHour = 0,
+ nMinute = 0,
+ nSecond = 0,
+ nHundredthSeconds = 0;
+ nHour = (sal_uInt16)_sSQLString.getToken(0,sTimeSep,nIndex).toInt32();
+ if(nIndex != -1)
+ {
+ nMinute = (sal_uInt16)_sSQLString.getToken(0,sTimeSep,nIndex).toInt32();
+ if(nIndex != -1)
+ {
+ nSecond = (sal_uInt16)_sSQLString.getToken(0,sTimeSep,nIndex).toInt32();
+ nIndex = 0;
+ ::rtl::OUString sNano(_sSQLString.getToken(1,'.',nIndex));
+ if ( sNano.getLength() )
+ {
+ // our time struct only supports hundredth seconds
+ sNano = sNano.copy(0,::std::min<sal_Int32>(sNano.getLength(),2));
+ const static ::rtl::OUString s_Zeros(RTL_CONSTASCII_USTRINGPARAM("00"));
+ sNano += s_Zeros.copy(0,s_Zeros.getLength() - sNano.getLength());
+ nHundredthSeconds = static_cast<sal_uInt16>(sNano.toInt32());
+ }
+ }
+ }
+ return Time(nHundredthSeconds,nSecond,nMinute,nHour);
+ }
+
+//.........................................................................
+} // namespace dbtools
+//.........................................................................
+
+
diff --git a/connectivity/source/commontools/dbexception.cxx b/connectivity/source/commontools/dbexception.cxx
new file mode 100644
index 000000000000..e266a5a83d4f
--- /dev/null
+++ b/connectivity/source/commontools/dbexception.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/dbexception.hxx>
+#include <comphelper/types.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <osl/diagnose.h>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdb/SQLErrorEvent.hpp>
+#include "TConnection.hxx"
+#include "resource/common_res.hrc"
+#include "resource/sharedresources.hxx"
+
+//.........................................................................
+namespace dbtools
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::comphelper;
+ using namespace ::connectivity;
+
+//==============================================================================
+//= SQLExceptionInfo - encapsulating the type info of an SQLException-derived class
+//==============================================================================
+//------------------------------------------------------------------------------
+SQLExceptionInfo::SQLExceptionInfo()
+ :m_eType(UNDEFINED)
+{
+}
+
+//------------------------------------------------------------------------------
+SQLExceptionInfo::SQLExceptionInfo(const ::com::sun::star::sdbc::SQLException& _rError)
+{
+ m_aContent <<= _rError;
+ implDetermineType();
+}
+
+//------------------------------------------------------------------------------
+SQLExceptionInfo::SQLExceptionInfo(const ::com::sun::star::sdbc::SQLWarning& _rError)
+{
+ m_aContent <<= _rError;
+ implDetermineType();
+}
+
+//------------------------------------------------------------------------------
+SQLExceptionInfo::SQLExceptionInfo(const ::com::sun::star::sdb::SQLContext& _rError)
+{
+ m_aContent <<= _rError;
+ implDetermineType();
+}
+
+//------------------------------------------------------------------------------
+SQLExceptionInfo::SQLExceptionInfo( const ::rtl::OUString& _rSimpleErrorMessage )
+{
+ SQLException aError;
+ aError.Message = _rSimpleErrorMessage;
+ m_aContent <<= aError;
+ implDetermineType();
+}
+
+//------------------------------------------------------------------------------
+SQLExceptionInfo::SQLExceptionInfo(const SQLExceptionInfo& _rCopySource)
+ :m_aContent(_rCopySource.m_aContent)
+ ,m_eType(_rCopySource.m_eType)
+{
+}
+
+//------------------------------------------------------------------------------
+const SQLExceptionInfo& SQLExceptionInfo::operator=(const ::com::sun::star::sdbc::SQLException& _rError)
+{
+ m_aContent <<= _rError;
+ implDetermineType();
+ return *this;
+}
+
+//------------------------------------------------------------------------------
+const SQLExceptionInfo& SQLExceptionInfo::operator=(const ::com::sun::star::sdbc::SQLWarning& _rError)
+{
+ m_aContent <<= _rError;
+ implDetermineType();
+ return *this;
+}
+
+//------------------------------------------------------------------------------
+const SQLExceptionInfo& SQLExceptionInfo::operator=(const ::com::sun::star::sdb::SQLContext& _rError)
+{
+ m_aContent <<= _rError;
+ implDetermineType();
+ return *this;
+}
+
+//------------------------------------------------------------------------------
+const SQLExceptionInfo& SQLExceptionInfo::operator=(const ::com::sun::star::sdb::SQLErrorEvent& _rErrorEvent)
+{
+ m_aContent = _rErrorEvent.Reason;
+ implDetermineType();
+ return *this;
+}
+
+//------------------------------------------------------------------------------
+const SQLExceptionInfo& SQLExceptionInfo::operator=(const ::com::sun::star::uno::Any& _rCaughtSQLException)
+{
+ m_aContent = _rCaughtSQLException;
+ implDetermineType();
+ return *this;
+}
+
+//------------------------------------------------------------------------------
+SQLExceptionInfo::SQLExceptionInfo(const ::com::sun::star::sdb::SQLErrorEvent& _rError)
+{
+ m_aContent = _rError.Reason;
+ implDetermineType();
+}
+
+//------------------------------------------------------------------------------
+SQLExceptionInfo::SQLExceptionInfo(const staruno::Any& _rError)
+{
+ const staruno::Type& aSQLExceptionType = ::getCppuType(reinterpret_cast< ::com::sun::star::sdbc::SQLException*>(NULL));
+ sal_Bool bValid = isAssignableFrom(aSQLExceptionType, _rError.getValueType());
+ if (bValid)
+ m_aContent = _rError;
+ // no assertion here : if used with the NextException member of an SQLException bValid==sal_False is allowed.
+
+ implDetermineType();
+}
+
+//------------------------------------------------------------------------------
+void SQLExceptionInfo::implDetermineType()
+{
+ staruno::Type aContentType = m_aContent.getValueType();
+
+ const Type& aSQLExceptionType = ::getCppuType( reinterpret_cast< SQLException* >( NULL ) );
+ const Type& aSQLWarningType = ::getCppuType( reinterpret_cast< SQLWarning* >( NULL ) );
+ const Type& aSQLContextType = ::getCppuType( reinterpret_cast< SQLContext* >( NULL ) );
+
+ if ( isAssignableFrom( aSQLContextType, m_aContent.getValueType() ) )
+ m_eType = SQL_CONTEXT;
+ else if ( isAssignableFrom( aSQLWarningType, m_aContent.getValueType() ) )
+ m_eType = SQL_WARNING;
+ else if ( isAssignableFrom( aSQLExceptionType, m_aContent.getValueType() ) )
+ m_eType = SQL_EXCEPTION;
+ else
+ {
+ m_eType = UNDEFINED;
+ m_aContent.clear();
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SQLExceptionInfo::isKindOf(TYPE _eType) const
+{
+ switch (_eType)
+ {
+ case SQL_CONTEXT:
+ return (m_eType == SQL_CONTEXT);
+ case SQL_WARNING:
+ return (m_eType == SQL_CONTEXT) || (m_eType == SQL_WARNING);
+ case SQL_EXCEPTION:
+ return (m_eType == SQL_CONTEXT) || (m_eType == SQL_WARNING) || (m_eType == SQL_EXCEPTION);
+ case UNDEFINED:
+ return (m_eType == UNDEFINED);
+ }
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+SQLExceptionInfo::operator const ::com::sun::star::sdbc::SQLException*() const
+{
+ OSL_ENSURE(isKindOf(SQL_EXCEPTION), "SQLExceptionInfo::operator SQLException* : invalid call !");
+ return reinterpret_cast<const ::com::sun::star::sdbc::SQLException*>(m_aContent.getValue());
+}
+
+//------------------------------------------------------------------------------
+SQLExceptionInfo::operator const ::com::sun::star::sdbc::SQLWarning*() const
+{
+ OSL_ENSURE(isKindOf(SQL_WARNING), "SQLExceptionInfo::operator SQLException* : invalid call !");
+ return reinterpret_cast<const ::com::sun::star::sdbc::SQLWarning*>(m_aContent.getValue());
+}
+
+//------------------------------------------------------------------------------
+SQLExceptionInfo::operator const ::com::sun::star::sdb::SQLContext*() const
+{
+ OSL_ENSURE(isKindOf(SQL_CONTEXT), "SQLExceptionInfo::operator SQLException* : invalid call !");
+ return reinterpret_cast<const ::com::sun::star::sdb::SQLContext*>(m_aContent.getValue());
+}
+
+//------------------------------------------------------------------------------
+void SQLExceptionInfo::prepend( const ::rtl::OUString& _rErrorMessage, const sal_Char* _pAsciiSQLState, const sal_Int32 _nErrorCode )
+{
+ SQLException aException;
+ aException.Message = _rErrorMessage;
+ aException.ErrorCode = _nErrorCode;
+ aException.SQLState = ::rtl::OUString::createFromAscii( _pAsciiSQLState ? _pAsciiSQLState : "S1000" );
+ aException.NextException = m_aContent;
+ m_aContent <<= aException;
+
+ m_eType = SQL_EXCEPTION;
+}
+
+//------------------------------------------------------------------------------
+void SQLExceptionInfo::append( TYPE _eType, const ::rtl::OUString& _rErrorMessage, const sal_Char* _pAsciiSQLState, const sal_Int32 _nErrorCode )
+{
+ // create the to-be-appended exception
+ Any aAppend;
+ switch ( _eType )
+ {
+ case SQL_EXCEPTION: aAppend <<= SQLException(); break;
+ case SQL_WARNING: aAppend <<= SQLWarning(); break;
+ case SQL_CONTEXT: aAppend <<= SQLContext(); break;
+ default:
+ OSL_ENSURE( false, "SQLExceptionInfo::append: invalid exception type: this will crash!" );
+ break;
+ }
+
+ SQLException* pAppendException( static_cast< SQLException* >( const_cast< void* >( aAppend.getValue() ) ) );
+ pAppendException->Message = _rErrorMessage;
+ pAppendException->SQLState = ::rtl::OUString::createFromAscii( _pAsciiSQLState );
+ pAppendException->ErrorCode = _nErrorCode;
+
+ // find the end of the current chain
+ Any* pChainIterator = &m_aContent;
+ SQLException* pLastException = NULL;
+ const Type& aSQLExceptionType( ::getCppuType< SQLException >() );
+ while ( pChainIterator )
+ {
+ if ( !pChainIterator->hasValue() )
+ break;
+
+ if ( !isAssignableFrom( aSQLExceptionType, pChainIterator->getValueType() ) )
+ break;
+
+ pLastException = static_cast< SQLException* >( const_cast< void* >( pChainIterator->getValue() ) );
+ pChainIterator = &pLastException->NextException;
+ }
+
+ // append
+ if ( pLastException )
+ pLastException->NextException = aAppend;
+ else
+ {
+ m_aContent = aAppend;
+ m_eType = _eType;
+ }
+}
+
+//------------------------------------------------------------------------------
+void SQLExceptionInfo::doThrow()
+{
+ if ( m_aContent.getValueTypeClass() == TypeClass_EXCEPTION )
+ ::cppu::throwException( m_aContent );
+ throw RuntimeException();
+}
+
+//==============================================================================
+//= SQLExceptionIteratorHelper
+//==============================================================================
+
+//------------------------------------------------------------------------------
+SQLExceptionIteratorHelper::SQLExceptionIteratorHelper( const SQLExceptionInfo& _rChainStart )
+ :m_pCurrent( NULL )
+ ,m_eCurrentType( SQLExceptionInfo::UNDEFINED )
+{
+ if ( _rChainStart.isValid() )
+ {
+ m_pCurrent = (const SQLException*)_rChainStart;
+ m_eCurrentType = _rChainStart.getType();
+ }
+}
+
+//------------------------------------------------------------------------------
+SQLExceptionIteratorHelper::SQLExceptionIteratorHelper( const ::com::sun::star::sdbc::SQLException& _rChainStart )
+ :m_pCurrent( &_rChainStart )
+ ,m_eCurrentType( SQLExceptionInfo::SQL_EXCEPTION )
+{
+}
+
+//------------------------------------------------------------------------------
+SQLExceptionIteratorHelper::SQLExceptionIteratorHelper( const ::com::sun::star::sdbc::SQLWarning& _rChainStart )
+ :m_pCurrent( &_rChainStart )
+ ,m_eCurrentType( SQLExceptionInfo::SQL_WARNING )
+{
+}
+
+//------------------------------------------------------------------------------
+SQLExceptionIteratorHelper::SQLExceptionIteratorHelper( const ::com::sun::star::sdb::SQLContext& _rChainStart )
+ :m_pCurrent( &_rChainStart )
+ ,m_eCurrentType( SQLExceptionInfo::SQL_CONTEXT )
+{
+}
+
+//------------------------------------------------------------------------------
+void SQLExceptionIteratorHelper::current( SQLExceptionInfo& _out_rInfo ) const
+{
+ switch ( m_eCurrentType )
+ {
+ case SQLExceptionInfo::SQL_EXCEPTION:
+ _out_rInfo = *m_pCurrent;
+ break;
+
+ case SQLExceptionInfo::SQL_WARNING:
+ _out_rInfo = *static_cast< const SQLWarning* >( m_pCurrent );
+ break;
+
+ case SQLExceptionInfo::SQL_CONTEXT:
+ _out_rInfo = *static_cast< const SQLContext* >( m_pCurrent );
+ break;
+
+ default:
+ _out_rInfo = Any();
+ break;
+ }
+}
+
+//------------------------------------------------------------------------------
+const ::com::sun::star::sdbc::SQLException* SQLExceptionIteratorHelper::next()
+{
+ OSL_ENSURE( hasMoreElements(), "SQLExceptionIteratorHelper::next : invalid call (please use hasMoreElements)!" );
+
+ const ::com::sun::star::sdbc::SQLException* pReturn = current();
+ if ( !m_pCurrent )
+ return pReturn;
+
+ // check for the next element within the chain
+ const Type aTypeException( ::cppu::UnoType< SQLException >::get() );
+
+ Type aNextElementType = m_pCurrent->NextException.getValueType();
+ if ( !isAssignableFrom( aTypeException, aNextElementType ) )
+ {
+ // no SQLException at all in the next chain element
+ m_pCurrent = NULL;
+ m_eCurrentType = SQLExceptionInfo::UNDEFINED;
+ return pReturn;
+ }
+
+ m_pCurrent = static_cast< const SQLException* >( m_pCurrent->NextException.getValue() );
+
+ // no finally determine the proper type of the exception
+ const Type aTypeContext( ::cppu::UnoType< SQLContext >::get() );
+ if ( isAssignableFrom( aTypeContext, aNextElementType ) )
+ {
+ m_eCurrentType = SQLExceptionInfo::SQL_CONTEXT;
+ return pReturn;
+ }
+
+ const Type aTypeWarning( ::cppu::UnoType< SQLWarning >::get() );
+ if ( isAssignableFrom( aTypeWarning, aNextElementType ) )
+ {
+ m_eCurrentType = SQLExceptionInfo::SQL_WARNING;
+ return pReturn;
+ }
+
+ // a simple SQLException
+ m_eCurrentType = SQLExceptionInfo::SQL_EXCEPTION;
+ return pReturn;
+}
+
+//------------------------------------------------------------------------------
+void SQLExceptionIteratorHelper::next( SQLExceptionInfo& _out_rInfo )
+{
+ current( _out_rInfo );
+ next();
+}
+
+//------------------------------------------------------------
+void throwFunctionSequenceException(const Reference< XInterface >& _Context, const Any& _Next) throw ( ::com::sun::star::sdbc::SQLException )
+{
+ ::connectivity::SharedResources aResources;
+ throw SQLException(
+ aResources.getResourceString(STR_ERRORMSG_SEQUENCE),
+ _Context,
+ getStandardSQLState( SQL_FUNCTION_SEQUENCE_ERROR ),
+ 0,
+ _Next
+ );
+}
+// -----------------------------------------------------------------------------
+void throwInvalidIndexException(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _Context,
+ const ::com::sun::star::uno::Any& _Next) throw ( ::com::sun::star::sdbc::SQLException )
+{
+ ::connectivity::SharedResources aResources;
+ throw SQLException(
+ aResources.getResourceString(STR_INVALID_INDEX),
+ _Context,
+ getStandardSQLState( SQL_INVALID_DESCRIPTOR_INDEX ),
+ 0,
+ _Next
+ );
+}
+// -----------------------------------------------------------------------------
+void throwFunctionNotSupportedException(const ::rtl::OUString& _rMsg,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _Context,
+ const ::com::sun::star::uno::Any& _Next) throw ( ::com::sun::star::sdbc::SQLException )
+{
+ throw SQLException(
+ _rMsg,
+ _Context,
+ getStandardSQLState( SQL_FUNCTION_NOT_SUPPORTED ),
+ 0,
+ _Next
+ );
+}
+// -----------------------------------------------------------------------------
+void throwFunctionNotSupportedException( const sal_Char* _pAsciiFunctionName, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext,
+ const ::com::sun::star::uno::Any* _pNextException ) throw ( ::com::sun::star::sdbc::SQLException )
+{
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_UNSUPPORTED_FUNCTION,
+ "$functionname$", ::rtl::OUString::createFromAscii( _pAsciiFunctionName )
+ ) );
+ throw SQLException(
+ sError,
+ _rxContext,
+ getStandardSQLState( SQL_FUNCTION_NOT_SUPPORTED ),
+ 0,
+ _pNextException ? *_pNextException : Any()
+ );
+}
+// -----------------------------------------------------------------------------
+void throwGenericSQLException(const ::rtl::OUString& _rMsg, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxSource)
+ throw (::com::sun::star::sdbc::SQLException)
+{
+ throwGenericSQLException(_rMsg, _rxSource, Any());
+}
+
+// -----------------------------------------------------------------------------
+void throwGenericSQLException(const ::rtl::OUString& _rMsg, const Reference< XInterface >& _rxSource, const Any& _rNextException)
+ throw (SQLException)
+{
+ throw SQLException( _rMsg, _rxSource, getStandardSQLState( SQL_GENERAL_ERROR ), 0, _rNextException);
+}
+
+// -----------------------------------------------------------------------------
+void throwFeatureNotImplementedException( const sal_Char* _pAsciiFeatureName, const Reference< XInterface >& _rxContext, const Any* _pNextException )
+ throw (SQLException)
+{
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_UNSUPPORTED_FEATURE,
+ "$featurename$", ::rtl::OUString::createFromAscii( _pAsciiFeatureName )
+ ) );
+
+ throw SQLException(
+ sError,
+ _rxContext,
+ getStandardSQLState( SQL_FEATURE_NOT_IMPLEMENTED ),
+ 0,
+ _pNextException ? *_pNextException : Any()
+ );
+}
+
+// -----------------------------------------------------------------------------
+void throwSQLException( const sal_Char* _pAsciiMessage, const sal_Char* _pAsciiState,
+ const Reference< XInterface >& _rxContext, const sal_Int32 _nErrorCode, const Any* _pNextException ) throw (SQLException)
+{
+ throw SQLException(
+ ::rtl::OUString::createFromAscii( _pAsciiMessage ),
+ _rxContext,
+ ::rtl::OUString::createFromAscii( _pAsciiState ),
+ _nErrorCode,
+ _pNextException ? *_pNextException : Any()
+ );
+}
+
+// -----------------------------------------------------------------------------
+void throwSQLException( const sal_Char* _pAsciiMessage, StandardSQLState _eSQLState,
+ const Reference< XInterface >& _rxContext, const sal_Int32 _nErrorCode,
+ const Any* _pNextException ) throw (SQLException)
+{
+ throwSQLException( _pAsciiMessage, getStandardSQLStateAscii( _eSQLState ), _rxContext, _nErrorCode, _pNextException );
+}
+
+// -----------------------------------------------------------------------------
+void throwSQLException( const ::rtl::OUString& _rMessage, StandardSQLState _eSQLState,
+ const Reference< XInterface >& _rxContext, const sal_Int32 _nErrorCode,
+ const Any* _pNextException ) throw (SQLException)
+{
+ throw SQLException(
+ _rMessage,
+ _rxContext,
+ getStandardSQLState( _eSQLState ),
+ _nErrorCode,
+ _pNextException ? *_pNextException : Any()
+ );
+}
+
+// -----------------------------------------------------------------------------
+const sal_Char* getStandardSQLStateAscii( StandardSQLState _eState )
+{
+ const sal_Char* pAsciiState = NULL;
+ switch ( _eState )
+ {
+ case SQL_WRONG_PARAMETER_NUMBER: pAsciiState = "07001"; break;
+ case SQL_INVALID_DESCRIPTOR_INDEX: pAsciiState = "07009"; break;
+ case SQL_UNABLE_TO_CONNECT: pAsciiState = "08001"; break;
+ case SQL_NUMERIC_OUT_OF_RANGE: pAsciiState = "22003"; break;
+ case SQL_INVALID_DATE_TIME: pAsciiState = "22007"; break;
+ case SQL_INVALID_CURSOR_STATE: pAsciiState = "24000"; break;
+ case SQL_TABLE_OR_VIEW_EXISTS: pAsciiState = "42S01"; break;
+ case SQL_TABLE_OR_VIEW_NOT_FOUND: pAsciiState = "42S02"; break;
+ case SQL_INDEX_ESISTS: pAsciiState = "42S11"; break;
+ case SQL_INDEX_NOT_FOUND: pAsciiState = "42S12"; break;
+ case SQL_COLUMN_EXISTS: pAsciiState = "42S21"; break;
+ case SQL_COLUMN_NOT_FOUND: pAsciiState = "42S22"; break;
+ case SQL_GENERAL_ERROR: pAsciiState = "HY000"; break;
+ case SQL_INVALID_SQL_DATA_TYPE: pAsciiState = "HY004"; break;
+ case SQL_OPERATION_CANCELED: pAsciiState = "HY008"; break;
+ case SQL_FUNCTION_SEQUENCE_ERROR: pAsciiState = "HY010"; break;
+ case SQL_INVALID_CURSOR_POSITION: pAsciiState = "HY109"; break;
+ case SQL_INVALID_BOOKMARK_VALUE: pAsciiState = "HY111"; break;
+ case SQL_FEATURE_NOT_IMPLEMENTED: pAsciiState = "HYC00"; break;
+ case SQL_FUNCTION_NOT_SUPPORTED: pAsciiState = "IM001"; break;
+ case SQL_CONNECTION_DOES_NOT_EXIST: pAsciiState = "08003"; break;
+
+ default:
+ break;
+ }
+ if ( !pAsciiState )
+ throw RuntimeException();
+ return pAsciiState;
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString getStandardSQLState( StandardSQLState _eState )
+{
+ return ::rtl::OUString::createFromAscii( getStandardSQLStateAscii( _eState ) );
+}
+
+// -----------------------------------------------------------------------------
+//.........................................................................
+} // namespace dbtools
+//.........................................................................
+
+
diff --git a/connectivity/source/commontools/dbmetadata.cxx b/connectivity/source/commontools/dbmetadata.cxx
new file mode 100644
index 000000000000..04754ecb2f19
--- /dev/null
+++ b/connectivity/source/commontools/dbmetadata.cxx
@@ -0,0 +1,448 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/dbmetadata.hxx"
+#include "connectivity/dbexception.hxx"
+#include "connectivity/DriversConfig.hxx"
+#include "resource/common_res.hrc"
+#include "resource/sharedresources.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/sdb/BooleanComparisonMode.hpp>
+#include <com/sun/star/sdbc/XDatabaseMetaData2.hpp>
+#include <com/sun/star/sdbcx/XUsersSupplier.hpp>
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <boost/optional.hpp>
+
+//........................................................................
+namespace dbtools
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::sdbc::XDatabaseMetaData;
+ using ::com::sun::star::sdbc::XDatabaseMetaData2;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::container::XChild;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::sdbcx::XUsersSupplier;
+ using ::com::sun::star::sdbcx::XDataDefinitionSupplier;
+ using ::com::sun::star::sdbc::XDriverAccess;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ /** === end UNO using === **/
+ namespace BooleanComparisonMode = ::com::sun::star::sdb::BooleanComparisonMode;
+
+ //====================================================================
+ //= DatabaseMetaData_Impl
+ //====================================================================
+ struct DatabaseMetaData_Impl
+ {
+ Reference< XConnection > xConnection;
+ Reference< XDatabaseMetaData > xConnectionMetaData;
+ ::connectivity::DriversConfig aDriverConfig;
+
+ ::boost::optional< ::rtl::OUString > sCachedIdentifierQuoteString;
+ ::boost::optional< ::rtl::OUString > sCachedCatalogSeparator;
+
+ DatabaseMetaData_Impl()
+ :xConnection()
+ ,xConnectionMetaData()
+ ,aDriverConfig( ::comphelper::getProcessServiceFactory() )
+ ,sCachedIdentifierQuoteString()
+ ,sCachedCatalogSeparator()
+ {
+ }
+ };
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ //................................................................
+ static void lcl_construct( DatabaseMetaData_Impl& _metaDataImpl, const Reference< XConnection >& _connection )
+ {
+ _metaDataImpl.xConnection = _connection;
+ if ( !_metaDataImpl.xConnection.is() )
+ return;
+
+ _metaDataImpl.xConnectionMetaData = _connection->getMetaData();
+ if ( !_metaDataImpl.xConnectionMetaData.is() )
+ throw IllegalArgumentException();
+ }
+
+ //................................................................
+ static void lcl_checkConnected( const DatabaseMetaData_Impl& _metaDataImpl )
+ {
+ if ( !_metaDataImpl.xConnection.is() || !_metaDataImpl.xConnectionMetaData.is() )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(STR_NO_CONNECTION_GIVEN));
+ throwSQLException( sError, SQL_CONNECTION_DOES_NOT_EXIST, NULL );
+ }
+ }
+
+ //................................................................
+ static bool lcl_getDriverSetting( const sal_Char* _asciiName, const DatabaseMetaData_Impl& _metaData, Any& _out_setting )
+ {
+ lcl_checkConnected( _metaData );
+ const ::comphelper::NamedValueCollection& rDriverMetaData = _metaData.aDriverConfig.getMetaData( _metaData.xConnectionMetaData->getURL() );
+ if ( !rDriverMetaData.has( _asciiName ) )
+ return false;
+ _out_setting = rDriverMetaData.get( _asciiName );
+ return true;
+ }
+
+ //................................................................
+ static bool lcl_getConnectionSetting( const sal_Char* _asciiName, const DatabaseMetaData_Impl& _metaData, Any& _out_setting )
+ {
+ try
+ {
+ Reference< XChild > xConnectionAsChild( _metaData.xConnection, UNO_QUERY );
+ if ( xConnectionAsChild.is() )
+ {
+ Reference< XPropertySet > xDataSource( xConnectionAsChild->getParent(), UNO_QUERY_THROW );
+ Reference< XPropertySet > xDataSourceSettings(
+ xDataSource->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Settings" ) ) ),
+ UNO_QUERY_THROW );
+
+ _out_setting = xDataSourceSettings->getPropertyValue( ::rtl::OUString::createFromAscii( _asciiName ) );
+ }
+ else
+ {
+ Reference< XDatabaseMetaData2 > xExtendedMetaData( _metaData.xConnectionMetaData, UNO_QUERY_THROW );
+ ::comphelper::NamedValueCollection aSettings( xExtendedMetaData->getConnectionInfo() );
+ _out_setting = aSettings.get( _asciiName );
+ return _out_setting.hasValue();
+ }
+ return true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false;
+ }
+
+ //................................................................
+ static const ::rtl::OUString& lcl_getConnectionStringSetting(
+ const DatabaseMetaData_Impl& _metaData, ::boost::optional< ::rtl::OUString >& _cachedSetting,
+ ::rtl::OUString (SAL_CALL XDatabaseMetaData::*_getter)() )
+ {
+ if ( !_cachedSetting )
+ {
+ lcl_checkConnected( _metaData );
+ try
+ {
+ _cachedSetting.reset( (_metaData.xConnectionMetaData.get()->*_getter)() );
+ }
+ catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
+ }
+ return *_cachedSetting;
+ }
+ }
+
+ //====================================================================
+ //= DatabaseMetaData
+ //====================================================================
+ //--------------------------------------------------------------------
+ DatabaseMetaData::DatabaseMetaData()
+ :m_pImpl( new DatabaseMetaData_Impl )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ DatabaseMetaData::DatabaseMetaData( const Reference< XConnection >& _connection )
+ :m_pImpl( new DatabaseMetaData_Impl )
+ {
+ lcl_construct( *m_pImpl, _connection );
+ }
+
+ //--------------------------------------------------------------------
+ DatabaseMetaData::DatabaseMetaData( const DatabaseMetaData& _copyFrom )
+ :m_pImpl( new DatabaseMetaData_Impl( *_copyFrom.m_pImpl ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ DatabaseMetaData& DatabaseMetaData::operator=( const DatabaseMetaData& _copyFrom )
+ {
+ if ( this == &_copyFrom )
+ return *this;
+
+ m_pImpl.reset( new DatabaseMetaData_Impl( *_copyFrom.m_pImpl ) );
+ return *this;
+ }
+
+ //--------------------------------------------------------------------
+ DatabaseMetaData::~DatabaseMetaData()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ bool DatabaseMetaData::isConnected() const
+ {
+ return m_pImpl->xConnection.is();
+ }
+
+ //--------------------------------------------------------------------
+ bool DatabaseMetaData::supportsSubqueriesInFrom() const
+ {
+ lcl_checkConnected( *m_pImpl );
+
+ bool supportsSubQueries = false;
+ try
+ {
+ sal_Int32 maxTablesInselect = m_pImpl->xConnectionMetaData->getMaxTablesInSelect();
+ supportsSubQueries = ( maxTablesInselect > 1 ) || ( maxTablesInselect == 0 );
+ // TODO: is there a better way to determine this? The above is not really true. More precise,
+ // it's a *very* generous heuristics ...
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return supportsSubQueries;
+ }
+
+ //--------------------------------------------------------------------
+ bool DatabaseMetaData::supportsPrimaryKeys() const
+ {
+ lcl_checkConnected( *m_pImpl );
+
+ bool doesSupportPrimaryKeys = false;
+ try
+ {
+ Any setting;
+ if ( !( lcl_getConnectionSetting( "PrimaryKeySupport", *m_pImpl, setting ) )
+ || !( setting >>= doesSupportPrimaryKeys )
+ )
+ doesSupportPrimaryKeys = m_pImpl->xConnectionMetaData->supportsCoreSQLGrammar();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return doesSupportPrimaryKeys;
+ }
+
+ //--------------------------------------------------------------------
+ const ::rtl::OUString& DatabaseMetaData::getIdentifierQuoteString() const
+ {
+ return lcl_getConnectionStringSetting( *m_pImpl, m_pImpl->sCachedIdentifierQuoteString, &XDatabaseMetaData::getIdentifierQuoteString );
+ }
+
+ //--------------------------------------------------------------------
+ const ::rtl::OUString& DatabaseMetaData::getCatalogSeparator() const
+ {
+ return lcl_getConnectionStringSetting( *m_pImpl, m_pImpl->sCachedCatalogSeparator, &XDatabaseMetaData::getCatalogSeparator );
+ }
+
+ //--------------------------------------------------------------------
+ bool DatabaseMetaData::restrictIdentifiersToSQL92() const
+ {
+ lcl_checkConnected( *m_pImpl );
+
+ bool restrict( false );
+ Any setting;
+ if ( lcl_getConnectionSetting( "EnableSQL92Check", *m_pImpl, setting ) )
+ OSL_VERIFY( setting >>= restrict );
+ return restrict;
+ }
+
+ //--------------------------------------------------------------------
+ bool DatabaseMetaData::generateASBeforeCorrelationName() const
+ {
+ bool doGenerate( true );
+ Any setting;
+ if ( lcl_getConnectionSetting( "GenerateASBeforeCorrelationName", *m_pImpl, setting ) )
+ OSL_VERIFY( setting >>= doGenerate );
+ return doGenerate;
+ }
+ //--------------------------------------------------------------------
+ bool DatabaseMetaData::shouldEscapeDateTime() const
+ {
+ bool doGenerate( true );
+ Any setting;
+ if ( lcl_getConnectionSetting( "EscapeDateTime", *m_pImpl, setting ) )
+ OSL_VERIFY( setting >>= doGenerate );
+ return doGenerate;
+ }
+ //--------------------------------------------------------------------
+ bool DatabaseMetaData::isAutoIncrementPrimaryKey() const
+ {
+ bool is( true );
+ Any setting;
+ if ( lcl_getDriverSetting( "AutoIncrementIsPrimaryKey", *m_pImpl, setting ) )
+ OSL_VERIFY( setting >>= is );
+ return is;
+ }
+ //--------------------------------------------------------------------
+ sal_Int32 DatabaseMetaData::getBooleanComparisonMode() const
+ {
+ sal_Int32 mode( BooleanComparisonMode::EQUAL_INTEGER );
+ Any setting;
+ if ( lcl_getConnectionSetting( "BooleanComparisonMode", *m_pImpl, setting ) )
+ OSL_VERIFY( setting >>= mode );
+ return mode;
+ }
+ //--------------------------------------------------------------------
+ bool DatabaseMetaData::supportsRelations() const
+ {
+ lcl_checkConnected( *m_pImpl );
+ bool bSupport = false;
+ try
+ {
+ bSupport = m_pImpl->xConnectionMetaData->supportsIntegrityEnhancementFacility();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ try
+ {
+ if ( !bSupport )
+ {
+ const ::rtl::OUString url = m_pImpl->xConnectionMetaData->getURL();
+ char pMySQL[] = "sdbc:mysql";
+ bSupport = url.matchAsciiL(pMySQL,(sizeof(pMySQL)/sizeof(pMySQL[0]))-1);
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bSupport;
+ }
+
+ //--------------------------------------------------------------------
+ bool DatabaseMetaData::supportsColumnAliasInOrderBy() const
+ {
+ bool doGenerate( true );
+ Any setting;
+ if ( lcl_getConnectionSetting( "ColumnAliasInOrderBy", *m_pImpl, setting ) )
+ OSL_VERIFY( setting >>= doGenerate );
+ return doGenerate;
+ }
+
+ //--------------------------------------------------------------------
+ bool DatabaseMetaData::supportsUserAdministration( const ::comphelper::ComponentContext& _rContext ) const
+ {
+ lcl_checkConnected( *m_pImpl );
+
+ bool isSupported( false );
+ try
+ {
+ // find the XUsersSupplier interface
+ // - either directly at the connection
+ Reference< XUsersSupplier > xUsersSupp( m_pImpl->xConnection, UNO_QUERY );
+ if ( !xUsersSupp.is() )
+ {
+ // - or at the driver manager
+ Reference< XDriverAccess > xDriverManager(
+ _rContext.createComponent( "com.sun.star.sdbc.DriverManager" ), UNO_QUERY_THROW );
+ Reference< XDataDefinitionSupplier > xDriver( xDriverManager->getDriverByURL( m_pImpl->xConnectionMetaData->getURL() ), UNO_QUERY );
+ if ( xDriver.is() )
+ xUsersSupp.set( xDriver->getDataDefinitionByConnection( m_pImpl->xConnection ), UNO_QUERY );
+ }
+
+ isSupported = ( xUsersSupp.is() && xUsersSupp->getUsers().is() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return isSupported;
+ }
+
+ //--------------------------------------------------------------------
+ bool DatabaseMetaData::displayEmptyTableFolders() const
+ {
+ bool doDisplay( true );
+#ifdef IMPLEMENTED_LATER
+ Any setting;
+ if ( lcl_getConnectionSetting( "DisplayEmptyTableFolders", *m_pImpl, setting ) )
+ OSL_VERIFY( setting >>= doDisplay );
+#else
+ try
+ {
+ Reference< XDatabaseMetaData > xMeta( m_pImpl->xConnectionMetaData, UNO_SET_THROW );
+ ::rtl::OUString sConnectionURL( xMeta->getURL() );
+ doDisplay = sConnectionURL.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "sdbc:mysql:mysqlc" ) ) == 0;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+#endif
+ return doDisplay;
+ }
+ //--------------------------------------------------------------------
+ bool DatabaseMetaData::supportsThreads() const
+ {
+ bool bSupported( true );
+ try
+ {
+ Reference< XDatabaseMetaData > xMeta( m_pImpl->xConnectionMetaData, UNO_SET_THROW );
+ ::rtl::OUString sConnectionURL( xMeta->getURL() );
+ bSupported = sConnectionURL.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "sdbc:mysql:mysqlc" ) ) != 0;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bSupported;
+ }
+
+//........................................................................
+} // namespace dbtools
+//........................................................................
+
diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx
new file mode 100644
index 000000000000..05bcf997268f
--- /dev/null
+++ b/connectivity/source/commontools/dbtools.cxx
@@ -0,0 +1,2173 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/CommonTools.hxx"
+#include "diagnose_ex.h"
+#include "TConnection.hxx"
+#include "connectivity/ParameterCont.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sdb/BooleanComparisonMode.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/ParametersRequest.hpp>
+#include <com/sun/star/sdb/RowSetVetoException.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/sdb/XInteractionSupplyParameters.hpp>
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#include <com/sun/star/sdb/XParametersSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdbc/XDriverManager.hpp>
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/task/XInteractionRequest.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/extract.hxx>
+#include <comphelper/interaction.hxx>
+#include <comphelper/property.hxx>
+#include <connectivity/conncleanup.hxx>
+#include <connectivity/dbconversion.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/statementcomposer.hxx>
+#include <osl/diagnose.h>
+#include <rtl/ustrbuf.hxx>
+#include <tools/diagnose_ex.h>
+
+#include "resource/common_res.hrc"
+#include "resource/sharedresources.hxx"
+#include "OSubComponent.hxx"
+
+#include <algorithm>
+
+using namespace ::comphelper;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::form;
+using namespace connectivity;
+
+//.........................................................................
+namespace dbtools
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::task;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::task;
+// using namespace cppu;
+// using namespace osl;
+
+//==============================================================================
+//==============================================================================
+namespace
+{
+ typedef sal_Bool (SAL_CALL XDatabaseMetaData::*FMetaDataSupport)();
+}
+//==============================================================================
+//==============================================================================
+sal_Int32 getDefaultNumberFormat(const Reference< XPropertySet >& _xColumn,
+ const Reference< XNumberFormatTypes >& _xTypes,
+ const Locale& _rLocale)
+{
+ OSL_ENSURE(_xTypes.is() && _xColumn.is(), "dbtools::getDefaultNumberFormat: invalid arg !");
+ if (!_xTypes.is() || !_xColumn.is())
+ return NumberFormat::UNDEFINED;
+
+ sal_Int32 nDataType = 0;
+ sal_Int32 nScale = 0;
+ try
+ {
+ // determine the datatype of the column
+ _xColumn->getPropertyValue(::rtl::OUString::createFromAscii("Type")) >>= nDataType;
+
+ if (DataType::NUMERIC == nDataType || DataType::DECIMAL == nDataType)
+ _xColumn->getPropertyValue(::rtl::OUString::createFromAscii("Scale")) >>= nScale;
+ }
+ catch (Exception&)
+ {
+ return NumberFormat::UNDEFINED;
+ }
+ return getDefaultNumberFormat(nDataType,
+ nScale,
+ ::cppu::any2bool(_xColumn->getPropertyValue(::rtl::OUString::createFromAscii("IsCurrency"))),
+ _xTypes,
+ _rLocale);
+}
+
+//------------------------------------------------------------------
+sal_Int32 getDefaultNumberFormat(sal_Int32 _nDataType,
+ sal_Int32 _nScale,
+ sal_Bool _bIsCurrency,
+ const Reference< XNumberFormatTypes >& _xTypes,
+ const Locale& _rLocale)
+{
+ OSL_ENSURE(_xTypes.is() , "dbtools::getDefaultNumberFormat: invalid arg !");
+ if (!_xTypes.is())
+ return NumberFormat::UNDEFINED;
+
+ sal_Int32 nFormat = 0;
+ sal_Int32 nNumberType = _bIsCurrency ? NumberFormat::CURRENCY : NumberFormat::NUMBER;
+ switch (_nDataType)
+ {
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ nFormat = _xTypes->getStandardFormat(NumberFormat::LOGICAL, _rLocale);
+ break;
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::BIGINT:
+ case DataType::FLOAT:
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::NUMERIC:
+ case DataType::DECIMAL:
+ {
+ try
+ {
+ nFormat = _xTypes->getStandardFormat((sal_Int16)nNumberType, _rLocale);
+ if(_nScale > 0)
+ {
+ // generate a new format if necessary
+ Reference< XNumberFormats > xFormats(_xTypes, UNO_QUERY);
+ ::rtl::OUString sNewFormat = xFormats->generateFormat( 0L, _rLocale, sal_False, sal_False, (sal_Int16)_nScale, sal_True);
+
+ // and add it to the formatter if necessary
+ nFormat = xFormats->queryKey(sNewFormat, _rLocale, sal_False);
+ if (nFormat == (sal_Int32)-1)
+ nFormat = xFormats->addNew(sNewFormat, _rLocale);
+ }
+ }
+ catch (Exception&)
+ {
+ nFormat = _xTypes->getStandardFormat((sal_Int16)nNumberType, _rLocale);
+ }
+ } break;
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ case DataType::CLOB:
+ nFormat = _xTypes->getStandardFormat(NumberFormat::TEXT, _rLocale);
+ break;
+ case DataType::DATE:
+ nFormat = _xTypes->getStandardFormat(NumberFormat::DATE, _rLocale);
+ break;
+ case DataType::TIME:
+ nFormat = _xTypes->getStandardFormat(NumberFormat::TIME, _rLocale);
+ break;
+ case DataType::TIMESTAMP:
+ nFormat = _xTypes->getStandardFormat(NumberFormat::DATETIME, _rLocale);
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ case DataType::SQLNULL:
+ case DataType::OTHER:
+ case DataType::OBJECT:
+ case DataType::DISTINCT:
+ case DataType::STRUCT:
+ case DataType::ARRAY:
+ case DataType::BLOB:
+ case DataType::REF:
+ default:
+ nFormat = _xTypes->getStandardFormat(NumberFormat::UNDEFINED, _rLocale);
+ //nFormat = NumberFormat::UNDEFINED;
+ }
+ return nFormat;
+}
+
+//==============================================================================
+//------------------------------------------------------------------------------
+Reference< XConnection> findConnection(const Reference< XInterface >& xParent)
+{
+ Reference< XConnection> xConnection(xParent, UNO_QUERY);
+ if (!xConnection.is())
+ {
+ Reference< XChild> xChild(xParent, UNO_QUERY);
+ if (xChild.is())
+ xConnection = findConnection(xChild->getParent());
+ }
+ return xConnection;
+}
+
+//------------------------------------------------------------------------------
+Reference< XDataSource> getDataSource_allowException(
+ const ::rtl::OUString& _rsTitleOrPath,
+ const Reference< XMultiServiceFactory >& _rxFactory )
+{
+ OSL_ENSURE( _rsTitleOrPath.getLength(), "getDataSource_allowException: invalid arg !" );
+
+ Reference< XNameAccess> xDatabaseContext(
+ _rxFactory->createInstance(
+ ::rtl::OUString::createFromAscii( "com.sun.star.sdb.DatabaseContext" ) ),UNO_QUERY );
+ OSL_ENSURE( xDatabaseContext.is(), "getDataSource_allowException: could not obtain the database context!" );
+
+ return Reference< XDataSource >( xDatabaseContext->getByName( _rsTitleOrPath ), UNO_QUERY );
+}
+
+//------------------------------------------------------------------------------
+Reference< XDataSource > getDataSource(
+ const ::rtl::OUString& _rsTitleOrPath,
+ const Reference< XMultiServiceFactory >& _rxFactory )
+{
+ Reference< XDataSource > xDS;
+ try
+ {
+ xDS = getDataSource_allowException( _rsTitleOrPath, _rxFactory );
+ }
+ catch(Exception)
+ {
+ }
+
+ return xDS;
+}
+
+//------------------------------------------------------------------------------
+Reference< XConnection > getConnection_allowException(
+ const ::rtl::OUString& _rsTitleOrPath,
+ const ::rtl::OUString& _rsUser,
+ const ::rtl::OUString& _rsPwd,
+ const Reference< XMultiServiceFactory>& _rxFactory)
+{
+ Reference< XDataSource> xDataSource( getDataSource_allowException(_rsTitleOrPath, _rxFactory) );
+ Reference<XConnection> xConnection;
+ if (xDataSource.is())
+ {
+ // do it with interaction handler
+ if(!_rsUser.getLength() || !_rsPwd.getLength())
+ {
+ Reference<XPropertySet> xProp(xDataSource,UNO_QUERY);
+ ::rtl::OUString sPwd, sUser;
+ sal_Bool bPwdReq = sal_False;
+ try
+ {
+ xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)) >>= sPwd;
+ bPwdReq = ::cppu::any2bool(xProp->getPropertyValue(::rtl::OUString::createFromAscii("IsPasswordRequired")));
+ xProp->getPropertyValue(::rtl::OUString::createFromAscii("User")) >>= sUser;
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(sal_False, "dbtools::getConnection: error while retrieving data source properties!");
+ }
+ if(bPwdReq && !sPwd.getLength())
+ { // password required, but empty -> connect using an interaction handler
+ Reference<XCompletedConnection> xConnectionCompletion(xProp, UNO_QUERY);
+ if (xConnectionCompletion.is())
+ { // instantiate the default SDB interaction handler
+ Reference< XInteractionHandler > xHandler(_rxFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.task.InteractionHandler")), UNO_QUERY);
+ OSL_ENSURE(xHandler.is(), "dbtools::getConnection service com.sun.star.task.InteractionHandler not available!");
+ if (xHandler.is())
+ {
+ xConnection = xConnectionCompletion->connectWithCompletion(xHandler);
+ }
+ }
+ }
+ else
+ xConnection = xDataSource->getConnection(sUser, sPwd);
+ }
+ if(!xConnection.is()) // try to get one if not already have one, just to make sure
+ xConnection = xDataSource->getConnection(_rsUser, _rsPwd);
+ }
+ return xConnection;
+}
+
+//------------------------------------------------------------------------------
+Reference< XConnection> getConnection_withFeedback(const ::rtl::OUString& _rDataSourceName,
+ const ::rtl::OUString& _rUser, const ::rtl::OUString& _rPwd, const Reference< XMultiServiceFactory>& _rxFactory)
+ SAL_THROW ( (SQLException) )
+{
+ Reference< XConnection > xReturn;
+ try
+ {
+ xReturn = getConnection_allowException(_rDataSourceName, _rUser, _rPwd, _rxFactory);
+ }
+ catch(SQLException&)
+ {
+ // allowed to pass
+ throw;
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(sal_False, "::dbtools::getConnection_withFeedback: unexpected (non-SQL) exception caught!");
+ }
+ return xReturn;
+}
+
+//------------------------------------------------------------------------------
+Reference< XConnection> getConnection(
+ const ::rtl::OUString& _rsTitleOrPath,
+ const ::rtl::OUString& _rsUser,
+ const ::rtl::OUString& _rsPwd,
+ const Reference< XMultiServiceFactory>& _rxFactory)
+{
+ Reference< XConnection > xReturn;
+ try
+ {
+ xReturn = getConnection_allowException(_rsTitleOrPath, _rsUser, _rsPwd, _rxFactory);
+ }
+ catch(Exception&)
+ {
+ }
+
+ // TODO: if there were not dozens of places which rely on getConnection not throwing an exception ....
+ // I would change this ...
+
+ return xReturn;
+}
+
+//------------------------------------------------------------------------------
+Reference< XConnection> getConnection(const Reference< XRowSet>& _rxRowSet) throw (RuntimeException)
+{
+ Reference< XConnection> xReturn;
+ Reference< XPropertySet> xRowSetProps(_rxRowSet, UNO_QUERY);
+ if (xRowSetProps.is())
+ xRowSetProps->getPropertyValue(::rtl::OUString::createFromAscii("ActiveConnection")) >>= xReturn;
+ return xReturn;
+}
+
+//------------------------------------------------------------------------------
+// helper function which allows to implement both the connectRowset and the ensureRowSetConnection semantics
+// if connectRowset (which is deprecated) is removed, this function and one of its parameters are
+// not needed anymore, the whole implementation can be moved into ensureRowSetConnection then)
+SharedConnection lcl_connectRowSet(const Reference< XRowSet>& _rxRowSet, const Reference< XMultiServiceFactory>& _rxFactory,
+ bool _bSetAsActiveConnection, bool _bAttachAutoDisposer )
+ SAL_THROW ( ( SQLException, WrappedTargetException, RuntimeException ) )
+{
+ SharedConnection xConnection;
+
+ do
+ {
+ Reference< XPropertySet> xRowSetProps(_rxRowSet, UNO_QUERY);
+ if ( !xRowSetProps.is() )
+ break;
+
+ // 1. already connected?
+ Reference< XConnection > xExistingConn(
+ xRowSetProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ActiveConnection" ) ) ),
+ UNO_QUERY );
+
+ if ( xExistingConn.is()
+ // 2. embedded in a database?
+ || isEmbeddedInDatabase( _rxRowSet, xExistingConn )
+ // 3. is there a connection in the parent hierarchy?
+ || ( xExistingConn = findConnection( _rxRowSet ) ).is()
+ )
+ {
+ if ( _bSetAsActiveConnection )
+ {
+ xRowSetProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ActiveConnection" ) ), makeAny( xExistingConn ) );
+ // no auto disposer needed, since we did not create the connection
+ }
+
+ xConnection.reset( xExistingConn, SharedConnection::NoTakeOwnership );
+ break;
+ }
+
+ // build a connection with it's current settings (4. data source name, or 5. URL)
+
+ const ::rtl::OUString sUserProp = ::rtl::OUString::createFromAscii("User");
+ ::rtl::OUString sDataSourceName;
+ xRowSetProps->getPropertyValue(::rtl::OUString::createFromAscii("DataSourceName")) >>= sDataSourceName;
+ ::rtl::OUString sURL;
+ xRowSetProps->getPropertyValue(::rtl::OUString::createFromAscii("URL")) >>= sURL;
+
+ Reference< XConnection > xPureConnection;
+ if (sDataSourceName.getLength())
+ { // the row set's data source property is set
+ // -> try to connect, get user and pwd setting for that
+ ::rtl::OUString sUser, sPwd;
+
+ if (hasProperty(sUserProp, xRowSetProps))
+ xRowSetProps->getPropertyValue(sUserProp) >>= sUser;
+ if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD), xRowSetProps))
+ xRowSetProps->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)) >>= sPwd;
+
+ xPureConnection = getConnection_allowException( sDataSourceName, sUser, sPwd, _rxFactory );
+ }
+ else if (sURL.getLength())
+ { // the row set has no data source, but a connection url set
+ // -> try to connection with that url
+ Reference< XDriverManager > xDriverManager(
+ _rxFactory->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ConnectionPool")), UNO_QUERY);
+ if (xDriverManager.is())
+ {
+ ::rtl::OUString sUser, sPwd;
+ if (hasProperty(sUserProp, xRowSetProps))
+ xRowSetProps->getPropertyValue(sUserProp) >>= sUser;
+ if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD), xRowSetProps))
+ xRowSetProps->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)) >>= sPwd;
+ if (sUser.getLength())
+ { // use user and pwd together with the url
+ Sequence< PropertyValue> aInfo(2);
+ aInfo.getArray()[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user"));
+ aInfo.getArray()[0].Value <<= sUser;
+ aInfo.getArray()[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("password"));
+ aInfo.getArray()[1].Value <<= sPwd;
+ xPureConnection = xDriverManager->getConnectionWithInfo( sURL, aInfo );
+ }
+ else
+ // just use the url
+ xPureConnection = xDriverManager->getConnection( sURL );
+ }
+ }
+ xConnection.reset(
+ xPureConnection,
+ _bAttachAutoDisposer ? SharedConnection::NoTakeOwnership : SharedConnection::TakeOwnership
+ /* take ownership if and only if we're *not* going to auto-dispose the connection */
+ );
+
+ // now if we created a connection, forward it to the row set
+ if ( xConnection.is() && _bSetAsActiveConnection )
+ {
+ try
+ {
+ if ( _bAttachAutoDisposer )
+ {
+ OAutoConnectionDisposer* pAutoDispose = new OAutoConnectionDisposer( _rxRowSet, xConnection );
+ Reference< XPropertyChangeListener > xEnsureDelete(pAutoDispose);
+ }
+ else
+ xRowSetProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ActiveConnection" ) ),
+ makeAny( xConnection.getTyped() )
+ );
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(0,"EXception when we set the new active connection!");
+ }
+ }
+ }
+ while ( false );
+
+ return xConnection;
+}
+
+//------------------------------------------------------------------------------
+Reference< XConnection> connectRowset(const Reference< XRowSet>& _rxRowSet, const Reference< XMultiServiceFactory>& _rxFactory,
+ sal_Bool _bSetAsActiveConnection ) SAL_THROW ( ( SQLException, WrappedTargetException, RuntimeException ) )
+{
+ SharedConnection xConnection = lcl_connectRowSet( _rxRowSet, _rxFactory, _bSetAsActiveConnection, true );
+ return xConnection.getTyped();
+}
+
+//------------------------------------------------------------------------------
+SharedConnection ensureRowSetConnection(const Reference< XRowSet>& _rxRowSet, const Reference< XMultiServiceFactory>& _rxFactory,
+ bool _bUseAutoConnectionDisposer ) SAL_THROW ( ( SQLException, WrappedTargetException, RuntimeException ) )
+{
+ return lcl_connectRowSet( _rxRowSet, _rxFactory, true, _bUseAutoConnectionDisposer );
+}
+
+//------------------------------------------------------------------------------
+Reference< XNameAccess> getTableFields(const Reference< XConnection>& _rxConn,const ::rtl::OUString& _rName)
+{
+ Reference< XComponent > xDummy;
+ return getFieldsByCommandDescriptor( _rxConn, CommandType::TABLE, _rName, xDummy );
+}
+//------------------------------------------------------------------------------
+Reference< XNameAccess> getPrimaryKeyColumns_throw(const Any& i_aTable)
+{
+ const Reference< XPropertySet > xTable(i_aTable,UNO_QUERY_THROW);
+ return getPrimaryKeyColumns_throw(xTable);
+}
+//------------------------------------------------------------------------------
+Reference< XNameAccess> getPrimaryKeyColumns_throw(const Reference< XPropertySet >& i_xTable)
+{
+ Reference<XNameAccess> xKeyColumns;
+ const Reference<XKeysSupplier> xKeySup(i_xTable,UNO_QUERY);
+ if ( xKeySup.is() )
+ {
+ const Reference<XIndexAccess> xKeys = xKeySup->getKeys();
+ if ( xKeys.is() )
+ {
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ const ::rtl::OUString sPropName = rPropMap.getNameByIndex(PROPERTY_ID_TYPE);
+ Reference<XPropertySet> xProp;
+ const sal_Int32 nCount = xKeys->getCount();
+ for(sal_Int32 i = 0;i< nCount;++i)
+ {
+ xProp.set(xKeys->getByIndex(i),UNO_QUERY_THROW);
+ if ( xProp.is() )
+ {
+ sal_Int32 nKeyType = 0;
+ xProp->getPropertyValue(sPropName) >>= nKeyType;
+ if(KeyType::PRIMARY == nKeyType)
+ {
+ const Reference<XColumnsSupplier> xKeyColsSup(xProp,UNO_QUERY_THROW);
+ xKeyColumns = xKeyColsSup->getColumns();
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return xKeyColumns;
+}
+
+//------------------------------------------------------------------------------
+namespace
+{
+ enum FieldLookupState
+ {
+ HANDLE_TABLE, HANDLE_QUERY, HANDLE_SQL, RETRIEVE_OBJECT, RETRIEVE_COLUMNS, DONE, FAILED
+ };
+}
+
+//------------------------------------------------------------------------------
+Reference< XNameAccess > getFieldsByCommandDescriptor( const Reference< XConnection >& _rxConnection,
+ const sal_Int32 _nCommandType, const ::rtl::OUString& _rCommand,
+ Reference< XComponent >& _rxKeepFieldsAlive, SQLExceptionInfo* _pErrorInfo ) SAL_THROW( ( ) )
+{
+ OSL_PRECOND( _rxConnection.is(), "::dbtools::getFieldsByCommandDescriptor: invalid connection!" );
+ OSL_PRECOND( ( CommandType::TABLE == _nCommandType ) || ( CommandType::QUERY == _nCommandType ) || ( CommandType::COMMAND == _nCommandType ),
+ "::dbtools::getFieldsByCommandDescriptor: invalid command type!" );
+ OSL_PRECOND( _rCommand.getLength(), "::dbtools::getFieldsByCommandDescriptor: invalid command (empty)!" );
+
+ Reference< XNameAccess > xFields;
+
+ // reset the error
+ if ( _pErrorInfo )
+ *_pErrorInfo = SQLExceptionInfo();
+ // reset the ownership holder
+ _rxKeepFieldsAlive.clear();
+
+ // go for the fields
+ try
+ {
+ // some kind of state machine to ease the sharing of code
+ FieldLookupState eState = FAILED;
+ switch ( _nCommandType )
+ {
+ case CommandType::TABLE:
+ eState = HANDLE_TABLE;
+ break;
+ case CommandType::QUERY:
+ eState = HANDLE_QUERY;
+ break;
+ case CommandType::COMMAND:
+ eState = HANDLE_SQL;
+ break;
+ }
+
+ // needed in various states:
+ Reference< XNameAccess > xObjectCollection;
+ Reference< XColumnsSupplier > xSupplyColumns;
+
+ // go!
+ while ( ( DONE != eState ) && ( FAILED != eState ) )
+ {
+ switch ( eState )
+ {
+ case HANDLE_TABLE:
+ {
+ // initial state for handling the tables
+
+ // get the table objects
+ Reference< XTablesSupplier > xSupplyTables( _rxConnection, UNO_QUERY );
+ if ( xSupplyTables.is() )
+ xObjectCollection = xSupplyTables->getTables();
+ // if something went wrong 'til here, then this will be handled in the next state
+
+ // next state: get the object
+ eState = RETRIEVE_OBJECT;
+ }
+ break;
+
+ case HANDLE_QUERY:
+ {
+ // initial state for handling the tables
+
+ // get the table objects
+ Reference< XQueriesSupplier > xSupplyQueries( _rxConnection, UNO_QUERY );
+ if ( xSupplyQueries.is() )
+ xObjectCollection = xSupplyQueries->getQueries();
+ // if something went wrong 'til here, then this will be handled in the next state
+
+ // next state: get the object
+ eState = RETRIEVE_OBJECT;
+ }
+ break;
+
+ case RETRIEVE_OBJECT:
+ // here we should have an object (aka query or table) collection, and are going
+ // to retrieve the desired object
+
+ // next state: default to FAILED
+ eState = FAILED;
+
+ OSL_ENSURE( xObjectCollection.is(), "::dbtools::getFieldsByCommandDescriptor: invalid connection (no sdb.Connection, or no Tables-/QueriesSupplier)!");
+ if ( xObjectCollection.is() )
+ {
+ if ( xObjectCollection.is() && xObjectCollection->hasByName( _rCommand ) )
+ {
+ xObjectCollection->getByName( _rCommand ) >>= xSupplyColumns;
+ // (xSupplyColumns being NULL will be handled in the next state)
+
+ // next: go for the columns
+ eState = RETRIEVE_COLUMNS;
+ }
+ }
+ break;
+
+ case RETRIEVE_COLUMNS:
+ OSL_ENSURE( xSupplyColumns.is(), "::dbtools::getFieldsByCommandDescriptor: could not retrieve the columns supplier!" );
+
+ // next state: default to FAILED
+ eState = FAILED;
+
+ if ( xSupplyColumns.is() )
+ {
+ xFields = xSupplyColumns->getColumns();
+ // that's it
+ eState = DONE;
+ }
+ break;
+
+ case HANDLE_SQL:
+ {
+ ::rtl::OUString sStatementToExecute( _rCommand );
+
+ // well, the main problem here is to handle statements which contain a parameter
+ // If we would simply execute a parametrized statement, then this will fail because
+ // we cannot supply any parameter values.
+ // Thus, we try to analyze the statement, and to append a WHERE 0=1 filter criterion
+ // This should cause every driver to not really execute the statement, but to return
+ // an empty result set with the proper structure. We then can use this result set
+ // to retrieve the columns.
+
+ try
+ {
+ Reference< XMultiServiceFactory > xComposerFac( _rxConnection, UNO_QUERY );
+
+ if ( xComposerFac.is() )
+ {
+ Reference< XSingleSelectQueryComposer > xComposer(xComposerFac->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.SingleSelectQueryComposer"))),UNO_QUERY);
+ if ( xComposer.is() )
+ {
+ xComposer->setQuery( sStatementToExecute );
+
+ // Now set the filter to a dummy restriction which will result in an empty
+ // result set.
+ xComposer->setFilter( ::rtl::OUString::createFromAscii( "0=1" ) );
+ sStatementToExecute = xComposer->getQuery( );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ // silent this error, this was just a try. If we're here, we did not change sStatementToExecute,
+ // so it will still be _rCommand, which then will be executed without being touched
+ }
+
+ // now execute
+ Reference< XPreparedStatement > xStatement = _rxConnection->prepareStatement( sStatementToExecute );
+ // transfer ownership of this temporary object to the caller
+ _rxKeepFieldsAlive = _rxKeepFieldsAlive.query( xStatement );
+
+ // set the "MaxRows" to 0. This is just in case our attempt to append a 0=1 filter
+ // failed - in this case, the MaxRows restriction should at least ensure that there
+ // is no data returned (which would be potentially expensive)
+ Reference< XPropertySet > xStatementProps( xStatement,UNO_QUERY );
+ try
+ {
+ if ( xStatementProps.is() )
+ xStatementProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxRows" ) ),
+ makeAny( sal_Int32( 0 ) )
+ );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "::dbtools::getFieldsByCommandDescriptor: could not set the MaxRows!" );
+ // oh damn. Not much of a chance to recover, we will no retrieve the complete
+ // full blown result set
+ }
+
+ xSupplyColumns = xSupplyColumns.query( xStatement->executeQuery() );
+ // this should have given us a result set which does not contain any data, but
+ // the structural information we need
+
+ // so the next state is to get the columns
+ eState = RETRIEVE_COLUMNS;
+ }
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "::dbtools::getFieldsByCommandDescriptor: oops! unhandled state here!" );
+ eState = FAILED;
+ }
+ }
+ }
+ catch( const SQLContext& e ) { if ( _pErrorInfo ) *_pErrorInfo = SQLExceptionInfo( e ); }
+ catch( const SQLWarning& e ) { if ( _pErrorInfo ) *_pErrorInfo = SQLExceptionInfo( e ); }
+ catch( const SQLException& e ) { if ( _pErrorInfo ) *_pErrorInfo = SQLExceptionInfo( e ); }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "::dbtools::getFieldsByCommandDescriptor: caught an exception while retrieving the fields!" );
+ }
+
+ return xFields;
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > getFieldNamesByCommandDescriptor( const Reference< XConnection >& _rxConnection,
+ const sal_Int32 _nCommandType, const ::rtl::OUString& _rCommand,
+ SQLExceptionInfo* _pErrorInfo ) SAL_THROW( ( ) )
+{
+ // get the container for the fields
+ Reference< XComponent > xKeepFieldsAlive;
+ Reference< XNameAccess > xFieldContainer = getFieldsByCommandDescriptor( _rxConnection, _nCommandType, _rCommand, xKeepFieldsAlive, _pErrorInfo );
+
+ // get the names of the fields
+ Sequence< ::rtl::OUString > aNames;
+ if ( xFieldContainer.is() )
+ aNames = xFieldContainer->getElementNames();
+
+ // clean up any temporary objects which have been created
+ disposeComponent( xKeepFieldsAlive );
+
+ // outta here
+ return aNames;
+}
+
+//------------------------------------------------------------------------------
+SQLContext prependContextInfo(const SQLException& _rException, const Reference< XInterface >& _rxContext, const ::rtl::OUString& _rContextDescription, const ::rtl::OUString& _rContextDetails)
+{
+ return SQLContext( _rContextDescription, _rxContext, ::rtl::OUString(), 0, makeAny( _rException ), _rContextDetails );
+}
+//------------------------------------------------------------------------------
+SQLException prependErrorInfo( const SQLException& _rChainedException, const Reference< XInterface >& _rxContext,
+ const ::rtl::OUString& _rAdditionalError, const StandardSQLState _eSQLState, const sal_Int32 _nErrorCode )
+{
+ return SQLException( _rAdditionalError, _rxContext,
+ _eSQLState == SQL_ERROR_UNSPECIFIED ? ::rtl::OUString() : getStandardSQLState( _eSQLState ),
+ _nErrorCode, makeAny( _rChainedException ) );
+}
+
+//--------------------------------------------------------------------------
+namespace
+{
+ struct NameComponentSupport
+ {
+ const bool bCatalogs;
+ const bool bSchemas;
+
+ NameComponentSupport( )
+ :bCatalogs( true )
+ ,bSchemas( true )
+ {
+ }
+
+ NameComponentSupport( const bool _bCatalogs, const bool _bSchemas )
+ :bCatalogs( _bCatalogs )
+ ,bSchemas( _bSchemas )
+ {
+ }
+ };
+
+ NameComponentSupport lcl_getNameComponentSupport( const Reference< XDatabaseMetaData >& _rxMetaData, EComposeRule _eComposeRule )
+ {
+ OSL_PRECOND( _rxMetaData.is(), "lcl_getNameComponentSupport: invalid meta data!" );
+
+ FMetaDataSupport pCatalogCall = &XDatabaseMetaData::supportsCatalogsInDataManipulation;
+ FMetaDataSupport pSchemaCall = &XDatabaseMetaData::supportsSchemasInDataManipulation;
+ bool bIgnoreMetaData = false;
+
+ switch ( _eComposeRule )
+ {
+ case eInTableDefinitions:
+ pCatalogCall = &XDatabaseMetaData::supportsCatalogsInTableDefinitions;
+ pSchemaCall = &XDatabaseMetaData::supportsSchemasInTableDefinitions;
+ break;
+ case eInIndexDefinitions:
+ pCatalogCall = &XDatabaseMetaData::supportsCatalogsInIndexDefinitions;
+ pSchemaCall = &XDatabaseMetaData::supportsSchemasInIndexDefinitions;
+ break;
+ case eInProcedureCalls:
+ pCatalogCall = &XDatabaseMetaData::supportsCatalogsInProcedureCalls;
+ pSchemaCall = &XDatabaseMetaData::supportsSchemasInProcedureCalls;
+ break;
+ case eInPrivilegeDefinitions:
+ pCatalogCall = &XDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions;
+ pSchemaCall = &XDatabaseMetaData::supportsSchemasInPrivilegeDefinitions;
+ break;
+ case eComplete:
+ bIgnoreMetaData = true;
+ break;
+ case eInDataManipulation:
+ // already properly set above
+ break;
+ }
+ return NameComponentSupport(
+ bIgnoreMetaData ? true : (_rxMetaData.get()->*pCatalogCall)(),
+ bIgnoreMetaData ? true : (_rxMetaData.get()->*pSchemaCall)()
+ );
+ }
+}
+
+//--------------------------------------------------------------------------
+static ::rtl::OUString impl_doComposeTableName( const Reference< XDatabaseMetaData >& _rxMetaData,
+ const ::rtl::OUString& _rCatalog, const ::rtl::OUString& _rSchema, const ::rtl::OUString& _rName,
+ sal_Bool _bQuote, EComposeRule _eComposeRule )
+{
+ OSL_ENSURE(_rxMetaData.is(), "impl_doComposeTableName : invalid meta data !");
+ if ( !_rxMetaData.is() )
+ return ::rtl::OUString();
+ OSL_ENSURE(_rName.getLength(), "impl_doComposeTableName : at least the name should be non-empty !");
+
+ const ::rtl::OUString sQuoteString = _rxMetaData->getIdentifierQuoteString();
+ const NameComponentSupport aNameComps( lcl_getNameComponentSupport( _rxMetaData, _eComposeRule ) );
+
+ ::rtl::OUStringBuffer aComposedName;
+
+ ::rtl::OUString sCatalogSep;
+ sal_Bool bCatlogAtStart = sal_True;
+ if ( _rCatalog.getLength() && aNameComps.bCatalogs )
+ {
+ sCatalogSep = _rxMetaData->getCatalogSeparator();
+ bCatlogAtStart = _rxMetaData->isCatalogAtStart();
+
+ if ( bCatlogAtStart && sCatalogSep.getLength())
+ {
+ aComposedName.append( _bQuote ? quoteName( sQuoteString, _rCatalog ) : _rCatalog );
+ aComposedName.append( sCatalogSep );
+ }
+ }
+
+ if ( _rSchema.getLength() && aNameComps.bSchemas )
+ {
+ aComposedName.append( _bQuote ? quoteName( sQuoteString, _rSchema ) : _rSchema );
+ aComposedName.appendAscii( "." );
+ }
+
+ aComposedName.append( _bQuote ? quoteName( sQuoteString, _rName ) : _rName );
+
+ if ( _rCatalog.getLength()
+ && !bCatlogAtStart
+ && sCatalogSep.getLength()
+ && aNameComps.bCatalogs
+ )
+ {
+ aComposedName.append( sCatalogSep );
+ aComposedName.append( _bQuote ? quoteName( sQuoteString, _rCatalog ) : _rCatalog );
+ }
+
+ return aComposedName.makeStringAndClear();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString quoteTableName(const Reference< XDatabaseMetaData>& _rxMeta
+ , const ::rtl::OUString& _rName
+ , EComposeRule _eComposeRule)
+{
+ ::rtl::OUString sCatalog, sSchema, sTable;
+ qualifiedNameComponents(_rxMeta,_rName,sCatalog,sSchema,sTable,_eComposeRule);
+ return impl_doComposeTableName( _rxMeta, sCatalog, sSchema, sTable, sal_True, _eComposeRule );
+}
+
+//------------------------------------------------------------------------------
+void qualifiedNameComponents(const Reference< XDatabaseMetaData >& _rxConnMetaData, const ::rtl::OUString& _rQualifiedName, ::rtl::OUString& _rCatalog, ::rtl::OUString& _rSchema, ::rtl::OUString& _rName,EComposeRule _eComposeRule)
+{
+ OSL_ENSURE(_rxConnMetaData.is(), "QualifiedNameComponents : invalid meta data!");
+
+ NameComponentSupport aNameComps( lcl_getNameComponentSupport( _rxConnMetaData, _eComposeRule ) );
+
+ ::rtl::OUString sSeparator = _rxConnMetaData->getCatalogSeparator();
+
+ ::rtl::OUString sName(_rQualifiedName);
+ // do we have catalogs ?
+ if ( aNameComps.bCatalogs )
+ {
+ if (_rxConnMetaData->isCatalogAtStart())
+ {
+ // search for the catalog name at the beginning
+ sal_Int32 nIndex = sName.indexOf(sSeparator);
+ if (-1 != nIndex)
+ {
+ _rCatalog = sName.copy(0, nIndex);
+ sName = sName.copy(nIndex + 1);
+ }
+ }
+ else
+ {
+ // Katalogname am Ende
+ sal_Int32 nIndex = sName.lastIndexOf(sSeparator);
+ if (-1 != nIndex)
+ {
+ _rCatalog = sName.copy(nIndex + 1);
+ sName = sName.copy(0, nIndex);
+ }
+ }
+ }
+
+ if ( aNameComps.bSchemas )
+ {
+ sal_Int32 nIndex = sName.indexOf((sal_Unicode)'.');
+ // OSL_ENSURE(-1 != nIndex, "QualifiedNameComponents : no schema separator!");
+ if ( nIndex != -1 )
+ _rSchema = sName.copy(0, nIndex);
+ sName = sName.copy(nIndex + 1);
+ }
+
+ _rName = sName;
+}
+
+//------------------------------------------------------------------------------
+Reference< XNumberFormatsSupplier> getNumberFormats(
+ const Reference< XConnection>& _rxConn,
+ sal_Bool _bAlloweDefault,
+ const Reference< XMultiServiceFactory>& _rxFactory)
+{
+ // ask the parent of the connection (should be an DatabaseAccess)
+ Reference< XNumberFormatsSupplier> xReturn;
+ Reference< XChild> xConnAsChild(_rxConn, UNO_QUERY);
+ ::rtl::OUString sPropFormatsSupplier = ::rtl::OUString::createFromAscii("NumberFormatsSupplier");
+ if (xConnAsChild.is())
+ {
+ Reference< XPropertySet> xConnParentProps(xConnAsChild->getParent(), UNO_QUERY);
+ if (xConnParentProps.is() && hasProperty(sPropFormatsSupplier, xConnParentProps))
+ xConnParentProps->getPropertyValue(sPropFormatsSupplier) >>= xReturn;
+ }
+ else if(_bAlloweDefault && _rxFactory.is())
+ {
+ xReturn = Reference< XNumberFormatsSupplier>(_rxFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatsSupplier")),UNO_QUERY);
+ }
+ return xReturn;
+}
+
+//==============================================================================
+//------------------------------------------------------------------------------
+void TransferFormComponentProperties(
+ const Reference< XPropertySet>& xOldProps,
+ const Reference< XPropertySet>& xNewProps,
+ const Locale& _rLocale)
+{
+try
+{
+ OSL_ENSURE( xOldProps.is() && xNewProps.is(), "TransferFormComponentProperties: invalid source/dest!" );
+ if ( !xOldProps.is() || !xNewProps.is() )
+ return;
+
+ // kopieren wir erst mal alle Props, die in Quelle und Ziel vorhanden sind und identische Beschreibungen haben
+ Reference< XPropertySetInfo> xOldInfo( xOldProps->getPropertySetInfo());
+ Reference< XPropertySetInfo> xNewInfo( xNewProps->getPropertySetInfo());
+
+ Sequence< Property> aOldProperties = xOldInfo->getProperties();
+ Sequence< Property> aNewProperties = xNewInfo->getProperties();
+ int nNewLen = aNewProperties.getLength();
+
+ Property* pOldProps = aOldProperties.getArray();
+ Property* pNewProps = aNewProperties.getArray();
+
+ ::rtl::OUString sPropDefaultControl(::rtl::OUString::createFromAscii("DefaultControl"));
+ ::rtl::OUString sPropLabelControl(::rtl::OUString::createFromAscii("LabelControl"));
+ ::rtl::OUString sPropFormatsSupplier(::rtl::OUString::createFromAscii("FormatsSupplier"));
+ ::rtl::OUString sPropCurrencySymbol(::rtl::OUString::createFromAscii("CurrencySymbol"));
+ ::rtl::OUString sPropDecimals(::rtl::OUString::createFromAscii("Decimals"));
+ ::rtl::OUString sPropEffectiveMin(::rtl::OUString::createFromAscii("EffectiveMin"));
+ ::rtl::OUString sPropEffectiveMax(::rtl::OUString::createFromAscii("EffectiveMax"));
+ ::rtl::OUString sPropEffectiveDefault(::rtl::OUString::createFromAscii("EffectiveDefault"));
+ ::rtl::OUString sPropDefaultText(::rtl::OUString::createFromAscii("DefaultText"));
+ ::rtl::OUString sPropDefaultDate(::rtl::OUString::createFromAscii("DefaultDate"));
+ ::rtl::OUString sPropDefaultTime(::rtl::OUString::createFromAscii("DefaultTime"));
+ ::rtl::OUString sPropValueMin(::rtl::OUString::createFromAscii("ValueMin"));
+ ::rtl::OUString sPropValueMax(::rtl::OUString::createFromAscii("ValueMax"));
+ ::rtl::OUString sPropDecimalAccuracy(::rtl::OUString::createFromAscii("DecimalAccuracy"));
+ ::rtl::OUString sPropClassId(::rtl::OUString::createFromAscii("ClassId"));
+ ::rtl::OUString sFormattedServiceName( ::rtl::OUString::createFromAscii( "com.sun.star.form.component.FormattedField" ) );
+
+ for (sal_Int16 i=0; i<aOldProperties.getLength(); ++i)
+ {
+ if ( (!pOldProps[i].Name.equals(sPropDefaultControl))
+ && (!pOldProps[i].Name.equals(sPropLabelControl))
+ )
+ {
+ // binaere Suche
+ Property* pResult = ::std::lower_bound(pNewProps, pNewProps + nNewLen,pOldProps[i].Name, ::comphelper::PropertyStringLessFunctor());
+ if ( pResult
+ && ( pResult != pNewProps + nNewLen && pResult->Name == pOldProps[i].Name )
+ && ( (pResult->Attributes & PropertyAttribute::READONLY) == 0 )
+ && ( pResult->Type.equals(pOldProps[i].Type)) )
+ { // Attribute stimmen ueberein und Property ist nicht read-only
+ try
+ {
+ xNewProps->setPropertyValue(pResult->Name, xOldProps->getPropertyValue(pResult->Name));
+ }
+ catch(IllegalArgumentException& e)
+ {
+ OSL_UNUSED( e );
+#ifdef DBG_UTIL
+ ::rtl::OUString sMessage = ::rtl::OUString::createFromAscii("TransferFormComponentProperties : could not transfer the value for property \"");
+ sMessage += pResult->Name;
+ sMessage += ::rtl::OUString::createFromAscii("\"");;
+ OSL_ENSURE(sal_False, ::rtl::OUStringToOString(sMessage, RTL_TEXTENCODING_ASCII_US));
+#endif
+ }
+ }
+ }
+ }
+
+
+ // fuer formatierte Felder (entweder alt oder neu) haben wir ein paar Sonderbehandlungen
+ Reference< XServiceInfo > xSI( xOldProps, UNO_QUERY );
+ sal_Bool bOldIsFormatted = xSI.is() && xSI->supportsService( sFormattedServiceName );
+ xSI = Reference< XServiceInfo >( xNewProps, UNO_QUERY );
+ sal_Bool bNewIsFormatted = xSI.is() && xSI->supportsService( sFormattedServiceName );
+
+ if (!bOldIsFormatted && !bNewIsFormatted)
+ return; // nothing to do
+
+ if (bOldIsFormatted && bNewIsFormatted)
+ // nein, wenn beide formatierte Felder sind, dann machen wir keinerlei Konvertierungen
+ // Das geht zu weit ;)
+ return;
+
+ if (bOldIsFormatted)
+ {
+ // aus dem eingestellten Format ein paar Properties rausziehen und zum neuen Set durchschleifen
+ Any aFormatKey( xOldProps->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FORMATKEY)) );
+ if (aFormatKey.hasValue())
+ {
+ Reference< XNumberFormatsSupplier> xSupplier;
+ xOldProps->getPropertyValue(sPropFormatsSupplier) >>= xSupplier;
+ if (xSupplier.is())
+ {
+ Reference< XNumberFormats> xFormats(xSupplier->getNumberFormats());
+ Reference< XPropertySet> xFormat(xFormats->getByKey(getINT32(aFormatKey)));
+ if (hasProperty(sPropCurrencySymbol, xFormat))
+ {
+ Any aVal( xFormat->getPropertyValue(sPropCurrencySymbol) );
+ if (aVal.hasValue() && hasProperty(sPropCurrencySymbol, xNewProps))
+ // (wenn die Quelle das nicht gesetzt hat, dann auch nicht kopieren, um den
+ // Default-Wert nicht zu ueberschreiben
+ xNewProps->setPropertyValue(sPropCurrencySymbol, aVal);
+ }
+ if (hasProperty(sPropDecimals, xFormat) && hasProperty(sPropDecimals, xNewProps))
+ xNewProps->setPropertyValue(sPropDecimals, xFormat->getPropertyValue(sPropDecimals));
+ }
+ }
+
+ // eine eventuelle-Min-Max-Konvertierung
+ Any aEffectiveMin( xOldProps->getPropertyValue(sPropEffectiveMin) );
+ if (aEffectiveMin.hasValue())
+ { // im Gegensatz zu ValueMin kann EffectiveMin void sein
+ if (hasProperty(sPropValueMin, xNewProps))
+ {
+ OSL_ENSURE(aEffectiveMin.getValueType().getTypeClass() == TypeClass_DOUBLE,
+ "TransferFormComponentProperties : invalid property type !");
+ xNewProps->setPropertyValue(sPropValueMin, aEffectiveMin);
+ }
+ }
+ Any aEffectiveMax( xOldProps->getPropertyValue(sPropEffectiveMax) );
+ if (aEffectiveMax.hasValue())
+ { // analog
+ if (hasProperty(sPropValueMax, xNewProps))
+ {
+ OSL_ENSURE(aEffectiveMax.getValueType().getTypeClass() == TypeClass_DOUBLE,
+ "TransferFormComponentProperties : invalid property type !");
+ xNewProps->setPropertyValue(sPropValueMax, aEffectiveMax);
+ }
+ }
+
+ // dann koennen wir noch Default-Werte konvertieren und uebernehmen
+ Any aEffectiveDefault( xOldProps->getPropertyValue(sPropEffectiveDefault) );
+ if (aEffectiveDefault.hasValue())
+ {
+ sal_Bool bIsString = aEffectiveDefault.getValueType().getTypeClass() == TypeClass_STRING;
+ OSL_ENSURE(bIsString || aEffectiveDefault.getValueType().getTypeClass() == TypeClass_DOUBLE,
+ "TransferFormComponentProperties : invalid property type !");
+ // die Effective-Properties sollten immer void oder string oder double sein ....
+
+ if (hasProperty(sPropDefaultDate, xNewProps) && !bIsString)
+ { // (einen ::rtl::OUString in ein Datum zu konvertieren muss nicht immer klappen, denn das ganze kann ja an
+ // eine Textspalte gebunden gewesen sein, aber mit einem double koennen wir was anfangen)
+ Date aDate = DBTypeConversion::toDate(getDouble(aEffectiveDefault));
+ xNewProps->setPropertyValue(sPropDefaultDate, makeAny(aDate));
+ }
+
+ if (hasProperty(sPropDefaultTime, xNewProps) && !bIsString)
+ { // voellig analog mit Zeit
+ Time aTime = DBTypeConversion::toTime(getDouble(aEffectiveDefault));
+ xNewProps->setPropertyValue(sPropDefaultTime, makeAny(aTime));
+ }
+
+ if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE), xNewProps) && !bIsString)
+ { // hier koennen wir einfach das double durchreichen
+ xNewProps->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE), aEffectiveDefault);
+ }
+
+ if (hasProperty(sPropDefaultText, xNewProps) && bIsString)
+ { // und hier den ::rtl::OUString
+ xNewProps->setPropertyValue(sPropDefaultText, aEffectiveDefault);
+ }
+
+ // nyi: die Uebersetzung zwischen doubles und ::rtl::OUString wuerde noch mehr Moeglichkeien eroeffnen
+ }
+ }
+
+ // die andere Richtung : das neu Control soll formatiert sein
+ if (bNewIsFormatted)
+ {
+ // zuerst die Formatierung
+ // einen Supplier koennen wir nicht setzen, also muss das neue Set schon einen mitbringen
+ Reference< XNumberFormatsSupplier> xSupplier;
+ xNewProps->getPropertyValue(sPropFormatsSupplier) >>= xSupplier;
+ if (xSupplier.is())
+ {
+ Reference< XNumberFormats> xFormats(xSupplier->getNumberFormats());
+
+ // Dezimal-Stellen
+ sal_Int16 nDecimals = 2;
+ if (hasProperty(sPropDecimalAccuracy, xOldProps))
+ xOldProps->getPropertyValue(sPropDecimalAccuracy) >>= nDecimals;
+
+ // Grund-Format (je nach ClassId des alten Sets)
+ sal_Int32 nBaseKey = 0;
+ if (hasProperty(sPropClassId, xOldProps))
+ {
+ Reference< XNumberFormatTypes> xTypeList(xFormats, UNO_QUERY);
+ if (xTypeList.is())
+ {
+ sal_Int16 nClassId = 0;
+ xOldProps->getPropertyValue(sPropClassId) >>= nClassId;
+ switch (nClassId)
+ {
+ case FormComponentType::DATEFIELD :
+ nBaseKey = xTypeList->getStandardFormat(NumberFormat::DATE, _rLocale);
+ break;
+
+ case FormComponentType::TIMEFIELD :
+ nBaseKey = xTypeList->getStandardFormat(NumberFormat::TIME, _rLocale);
+ break;
+
+ case FormComponentType::CURRENCYFIELD :
+ nBaseKey = xTypeList->getStandardFormat(NumberFormat::CURRENCY, _rLocale);
+ break;
+ }
+ }
+ }
+
+ // damit koennen wir ein neues Format basteln ...
+ ::rtl::OUString sNewFormat = xFormats->generateFormat(nBaseKey, _rLocale, sal_False, sal_False, nDecimals, 0);
+ // kein Tausender-Trennzeichen, negative Zahlen nicht in Rot, keine fuehrenden Nullen
+
+ // ... und zum FormatsSupplier hinzufuegen (wenn noetig)
+ sal_Int32 nKey = xFormats->queryKey(sNewFormat, _rLocale, sal_False);
+ if (nKey == (sal_Int32)-1)
+ { // noch nicht vorhanden in meinem Formatter ...
+ nKey = xFormats->addNew(sNewFormat, _rLocale);
+ }
+
+ xNewProps->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FORMATKEY), makeAny((sal_Int32)nKey));
+ }
+
+ // min-/max-Werte
+ Any aNewMin, aNewMax;
+ if (hasProperty(sPropValueMin, xOldProps))
+ aNewMin = xOldProps->getPropertyValue(sPropValueMin);
+ if (hasProperty(sPropValueMax, xOldProps))
+ aNewMax = xOldProps->getPropertyValue(sPropValueMax);
+ xNewProps->setPropertyValue(sPropEffectiveMin, aNewMin);
+ xNewProps->setPropertyValue(sPropEffectiveMax, aNewMax);
+
+ // Default-Wert
+ Any aNewDefault;
+ if (hasProperty(sPropDefaultDate, xOldProps))
+ {
+ Any aDate( xOldProps->getPropertyValue(sPropDefaultDate) );
+ if (aDate.hasValue())
+ aNewDefault <<= DBTypeConversion::toDouble(*(Date*)aDate.getValue());
+ }
+
+ if (hasProperty(sPropDefaultTime, xOldProps))
+ {
+ Any aTime( xOldProps->getPropertyValue(sPropDefaultTime) );
+ if (aTime.hasValue())
+ aNewDefault <<= DBTypeConversion::toDouble(*(Time*)aTime.getValue());
+ }
+
+ // double oder ::rtl::OUString werden direkt uebernommen
+ if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE), xOldProps))
+ aNewDefault = xOldProps->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE));
+ if (hasProperty(sPropDefaultText, xOldProps))
+ aNewDefault = xOldProps->getPropertyValue(sPropDefaultText);
+
+ if (aNewDefault.hasValue())
+ xNewProps->setPropertyValue(sPropEffectiveDefault, aNewDefault);
+ }
+}
+catch(const Exception&)
+{
+ OSL_ENSURE( sal_False, "TransferFormComponentProperties: caught an exception!" );
+}
+}
+
+//------------------------------------------------------------------------------
+sal_Bool canInsert(const Reference< XPropertySet>& _rxCursorSet)
+{
+ return ((_rxCursorSet.is() && (getINT32(_rxCursorSet->getPropertyValue(::rtl::OUString::createFromAscii("Privileges"))) & Privilege::INSERT) != 0));
+}
+
+//------------------------------------------------------------------------------
+sal_Bool canUpdate(const Reference< XPropertySet>& _rxCursorSet)
+{
+ return ((_rxCursorSet.is() && (getINT32(_rxCursorSet->getPropertyValue(::rtl::OUString::createFromAscii("Privileges"))) & Privilege::UPDATE) != 0));
+}
+
+//------------------------------------------------------------------------------
+sal_Bool canDelete(const Reference< XPropertySet>& _rxCursorSet)
+{
+ return ((_rxCursorSet.is() && (getINT32(_rxCursorSet->getPropertyValue(::rtl::OUString::createFromAscii("Privileges"))) & Privilege::DELETE) != 0));
+}
+// -----------------------------------------------------------------------------
+Reference< XDataSource> findDataSource(const Reference< XInterface >& _xParent)
+{
+ Reference< XOfficeDatabaseDocument> xDatabaseDocument(_xParent, UNO_QUERY);
+ Reference< XDataSource> xDataSource;
+ if ( xDatabaseDocument.is() )
+ xDataSource = xDatabaseDocument->getDataSource();
+ if ( !xDataSource.is() )
+ xDataSource.set(_xParent, UNO_QUERY);
+ if (!xDataSource.is())
+ {
+ Reference< XChild> xChild(_xParent, UNO_QUERY);
+ if ( xChild.is() )
+ xDataSource = findDataSource(xChild->getParent());
+ }
+ return xDataSource;
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString getComposedRowSetStatement( const Reference< XPropertySet >& _rxRowSet, const Reference< XMultiServiceFactory>& _rxFactory,
+ sal_Bool _bUseRowSetFilter, sal_Bool _bUseRowSetOrder, Reference< XSingleSelectQueryComposer >* _pxComposer )
+ SAL_THROW( ( SQLException ) )
+{
+ ::rtl::OUString sStatement;
+ try
+ {
+ Reference< XConnection> xConn = connectRowset( Reference< XRowSet >( _rxRowSet, UNO_QUERY ), _rxFactory, sal_True );
+ if ( xConn.is() ) // implies _rxRowSet.is()
+ {
+ // build the statement the row set is based on (can't use the ActiveCommand property of the set
+ // as this reflects the status after the last execute, not the currently set properties)
+
+ sal_Int32 nCommandType = CommandType::COMMAND;
+ ::rtl::OUString sCommand;
+ sal_Bool bEscapeProcessing = sal_False;
+
+ OSL_VERIFY( _rxRowSet->getPropertyValue( ::rtl::OUString::createFromAscii( "CommandType" ) ) >>= nCommandType );
+ OSL_VERIFY( _rxRowSet->getPropertyValue( ::rtl::OUString::createFromAscii( "Command" ) ) >>= sCommand );
+ OSL_VERIFY( _rxRowSet->getPropertyValue( ::rtl::OUString::createFromAscii( "EscapeProcessing" ) ) >>= bEscapeProcessing );
+
+ StatementComposer aComposer( xConn, sCommand, nCommandType, bEscapeProcessing );
+ // append sort
+ if ( _bUseRowSetOrder )
+ aComposer.setOrder( getString( _rxRowSet->getPropertyValue( ::rtl::OUString::createFromAscii( "Order" ) ) ) );
+
+ // append filter
+ if ( _bUseRowSetFilter )
+ {
+ sal_Bool bApplyFilter = sal_True;
+ _rxRowSet->getPropertyValue( ::rtl::OUString::createFromAscii( "ApplyFilter" ) ) >>= bApplyFilter;
+ if ( bApplyFilter )
+ aComposer.setFilter( getString( _rxRowSet->getPropertyValue( ::rtl::OUString::createFromAscii( "Filter" ) ) ) );
+ }
+
+ sStatement = aComposer.getQuery();
+
+ if ( _pxComposer )
+ {
+ *_pxComposer = aComposer.getComposer();
+ aComposer.setDisposeComposer( false );
+ }
+ }
+ }
+ catch( const SQLException& )
+ {
+ throw;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return sStatement;
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString getComposedRowSetStatement(
+ const Reference< XPropertySet >& _rxRowSet, const Reference< XMultiServiceFactory>& _rxFactory,
+ sal_Bool _bUseRowSetFilter, sal_Bool _bUseRowSetOrder )
+{
+ return getComposedRowSetStatement( _rxRowSet, _rxFactory, _bUseRowSetFilter, _bUseRowSetOrder, NULL );
+}
+
+//------------------------------------------------------------------------------
+Reference< XSingleSelectQueryComposer > getCurrentSettingsComposer(
+ const Reference< XPropertySet>& _rxRowSetProps,
+ const Reference< XMultiServiceFactory>& _rxFactory)
+{
+ Reference< XSingleSelectQueryComposer > xReturn;
+ try
+ {
+ getComposedRowSetStatement( _rxRowSetProps, _rxFactory, sal_True, sal_True, &xReturn );
+ }
+ catch( const SQLException& )
+ {
+ throw;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "::getCurrentSettingsComposer : caught an exception !" );
+ }
+
+ return xReturn;
+}
+//--------------------------------------------------------------------------
+::rtl::OUString composeTableName( const Reference< XDatabaseMetaData >& _rxMetaData,
+ const ::rtl::OUString& _rCatalog,
+ const ::rtl::OUString& _rSchema,
+ const ::rtl::OUString& _rName,
+ sal_Bool _bQuote,
+ EComposeRule _eComposeRule)
+{
+ return impl_doComposeTableName( _rxMetaData, _rCatalog, _rSchema, _rName, _bQuote, _eComposeRule );
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString composeTableNameForSelect( const Reference< XConnection >& _rxConnection,
+ const ::rtl::OUString& _rCatalog, const ::rtl::OUString& _rSchema, const ::rtl::OUString& _rName )
+{
+ sal_Bool bUseCatalogInSelect = isDataSourcePropertyEnabled( _rxConnection, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseCatalogInSelect" ) ), sal_True );
+ sal_Bool bUseSchemaInSelect = isDataSourcePropertyEnabled( _rxConnection, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseSchemaInSelect" ) ), sal_True );
+
+ return impl_doComposeTableName(
+ _rxConnection->getMetaData(),
+ bUseCatalogInSelect ? _rCatalog : ::rtl::OUString(),
+ bUseSchemaInSelect ? _rSchema : ::rtl::OUString(),
+ _rName,
+ true,
+ eInDataManipulation
+ );
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ static void lcl_getTableNameComponents( const Reference<XPropertySet>& _xTable,
+ ::rtl::OUString& _out_rCatalog, ::rtl::OUString& _out_rSchema, ::rtl::OUString& _out_rName )
+ {
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ Reference< XPropertySetInfo > xInfo = _xTable->getPropertySetInfo();
+ if ( xInfo.is()
+ && xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) )
+ {
+
+ ::rtl::OUString aCatalog;
+ ::rtl::OUString aSchema;
+ ::rtl::OUString aTable;
+ if ( xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME))
+ && xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) )
+ {
+ _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)) >>= _out_rCatalog;
+ _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= _out_rSchema;
+ }
+ _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= _out_rName;
+ }
+ else
+ OSL_ENSURE( false, "::dbtools::lcl_getTableNameComponents: this is no table object!" );
+ }
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString composeTableNameForSelect( const Reference< XConnection >& _rxConnection, const Reference<XPropertySet>& _xTable )
+{
+ ::rtl::OUString sCatalog, sSchema, sName;
+ lcl_getTableNameComponents( _xTable, sCatalog, sSchema, sName );
+
+ return composeTableNameForSelect( _rxConnection, sCatalog, sSchema, sName );
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString composeTableName(const Reference<XDatabaseMetaData>& _xMetaData,
+ const Reference<XPropertySet>& _xTable,
+ EComposeRule _eComposeRule,
+ bool _bSuppressCatalog,
+ bool _bSuppressSchema,
+ bool _bQuote )
+{
+ ::rtl::OUString sCatalog, sSchema, sName;
+ lcl_getTableNameComponents( _xTable, sCatalog, sSchema, sName );
+
+ return impl_doComposeTableName(
+ _xMetaData,
+ _bSuppressCatalog ? ::rtl::OUString() : sCatalog,
+ _bSuppressSchema ? ::rtl::OUString() : sSchema,
+ sName,
+ _bQuote,
+ _eComposeRule
+ );
+}
+// -----------------------------------------------------------------------------
+sal_Int32 getSearchColumnFlag( const Reference< XConnection>& _rxConn,sal_Int32 _nDataType)
+{
+ sal_Int32 nSearchFlag = 0;
+ Reference<XResultSet> xSet = _rxConn->getMetaData()->getTypeInfo();
+ if(xSet.is())
+ {
+ Reference<XRow> xRow(xSet,UNO_QUERY);
+ while(xSet->next())
+ {
+ if(xRow->getInt(2) == _nDataType)
+ {
+ nSearchFlag = xRow->getInt(9);
+ break;
+ }
+ }
+ }
+ return nSearchFlag;
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString createUniqueName( const Sequence< ::rtl::OUString >& _rNames, const ::rtl::OUString& _rBaseName, sal_Bool _bStartWithNumber )
+{
+ ::std::set< ::rtl::OUString > aUsedNames;
+ ::std::copy(
+ _rNames.getConstArray(),
+ _rNames.getConstArray() + _rNames.getLength(),
+ ::std::insert_iterator< ::std::set< ::rtl::OUString > >( aUsedNames, aUsedNames.end() )
+ );
+
+ ::rtl::OUString sName( _rBaseName );
+ sal_Int32 nPos = 1;
+ if ( _bStartWithNumber )
+ sName += ::rtl::OUString::valueOf( nPos );
+
+ while ( aUsedNames.find( sName ) != aUsedNames.end() )
+ {
+ sName = _rBaseName;
+ sName += ::rtl::OUString::valueOf( ++nPos );
+ }
+ return sName;
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString createUniqueName(const Reference<XNameAccess>& _rxContainer,const ::rtl::OUString& _rBaseName,sal_Bool _bStartWithNumber)
+{
+ Sequence< ::rtl::OUString > aElementNames;
+
+ OSL_ENSURE( _rxContainer.is(), "createUniqueName: invalid container!" );
+ if ( _rxContainer.is() )
+ aElementNames = _rxContainer->getElementNames();
+
+ return createUniqueName( aElementNames, _rBaseName, _bStartWithNumber );
+}
+
+// -----------------------------------------------------------------------------
+void showError(const SQLExceptionInfo& _rInfo,
+ const Reference< XWindow>& _xParent,
+ const Reference< XMultiServiceFactory >& _xFactory)
+{
+ if (_rInfo.isValid())
+ {
+ try
+ {
+ Sequence< Any > aArgs(2);
+ aArgs[0] <<= PropertyValue(::rtl::OUString::createFromAscii("SQLException"), 0, _rInfo.get(), PropertyState_DIRECT_VALUE);
+ aArgs[1] <<= PropertyValue(::rtl::OUString::createFromAscii("ParentWindow"), 0, makeAny(_xParent), PropertyState_DIRECT_VALUE);
+
+ static ::rtl::OUString s_sDialogServiceName = ::rtl::OUString::createFromAscii("com.sun.star.sdb.ErrorMessageDialog");
+ Reference< XExecutableDialog > xErrorDialog(
+ _xFactory->createInstanceWithArguments(s_sDialogServiceName, aArgs), UNO_QUERY);
+ if (xErrorDialog.is())
+ xErrorDialog->execute();
+ else
+ {
+ OSL_ENSURE(0,"dbtools::showError: no XExecutableDialog found!");
+ }
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(0,"showError: could not display the error message!");
+ }
+ }
+}
+
+// -------------------------------------------------------------------------
+sal_Bool implUpdateObject(const Reference< XRowUpdate >& _rxUpdatedObject,
+ const sal_Int32 _nColumnIndex, const Any& _rValue) SAL_THROW ( ( SQLException, RuntimeException ) )
+{
+ sal_Bool bSuccessfullyReRouted = sal_True;
+ switch (_rValue.getValueTypeClass())
+ {
+ case TypeClass_ANY:
+ {
+ Any aInnerValue;
+ _rValue >>= aInnerValue;
+ bSuccessfullyReRouted = implUpdateObject(_rxUpdatedObject, _nColumnIndex, aInnerValue);
+ }
+ break;
+
+ case TypeClass_VOID:
+ _rxUpdatedObject->updateNull(_nColumnIndex);
+ break;
+
+ case TypeClass_STRING:
+ _rxUpdatedObject->updateString(_nColumnIndex, *(rtl::OUString*)_rValue.getValue());
+ break;
+
+ case TypeClass_BOOLEAN:
+ _rxUpdatedObject->updateBoolean(_nColumnIndex, *(sal_Bool *)_rValue.getValue());
+ break;
+
+ case TypeClass_BYTE:
+ _rxUpdatedObject->updateByte(_nColumnIndex, *(sal_Int8 *)_rValue.getValue());
+ break;
+
+ case TypeClass_UNSIGNED_SHORT:
+ case TypeClass_SHORT:
+ _rxUpdatedObject->updateShort(_nColumnIndex, *(sal_Int16*)_rValue.getValue());
+ break;
+
+ case TypeClass_CHAR:
+ _rxUpdatedObject->updateString(_nColumnIndex,::rtl::OUString((sal_Unicode *)_rValue.getValue(),1));
+ break;
+
+ case TypeClass_UNSIGNED_LONG:
+ case TypeClass_LONG:
+ _rxUpdatedObject->updateInt(_nColumnIndex, *(sal_Int32*)_rValue.getValue());
+ break;
+
+ case TypeClass_HYPER:
+ {
+ sal_Int64 nValue = 0;
+ OSL_VERIFY( _rValue >>= nValue );
+ _rxUpdatedObject->updateLong( _nColumnIndex, nValue );
+ }
+ break;
+
+ case TypeClass_FLOAT:
+ _rxUpdatedObject->updateFloat(_nColumnIndex, *(float*)_rValue.getValue());
+ break;
+
+ case TypeClass_DOUBLE:
+ _rxUpdatedObject->updateDouble(_nColumnIndex, *(double*)_rValue.getValue());
+ break;
+
+ case TypeClass_SEQUENCE:
+ if (_rValue.getValueType() == ::getCppuType((const Sequence< sal_Int8 > *)0))
+ _rxUpdatedObject->updateBytes(_nColumnIndex, *(Sequence<sal_Int8>*)_rValue.getValue());
+ else
+ bSuccessfullyReRouted = sal_False;
+ break;
+ case TypeClass_STRUCT:
+ if (_rValue.getValueType() == ::getCppuType((const DateTime*)0))
+ _rxUpdatedObject->updateTimestamp(_nColumnIndex, *(DateTime*)_rValue.getValue());
+ else if (_rValue.getValueType() == ::getCppuType((const Date*)0))
+ _rxUpdatedObject->updateDate(_nColumnIndex, *(Date*)_rValue.getValue());
+ else if (_rValue.getValueType() == ::getCppuType((const Time*)0))
+ _rxUpdatedObject->updateTime(_nColumnIndex, *(Time*)_rValue.getValue());
+ else
+ bSuccessfullyReRouted = sal_False;
+ break;
+
+ case TypeClass_INTERFACE:
+ if (_rValue.getValueType() == ::getCppuType(static_cast<Reference< XInputStream>*>(NULL)))
+ {
+ Reference< XInputStream > xStream;
+ _rValue >>= xStream;
+ _rxUpdatedObject->updateBinaryStream(_nColumnIndex, xStream, xStream->available());
+ break;
+ }
+ // run through
+ default:
+ bSuccessfullyReRouted = sal_False;
+ }
+
+ return bSuccessfullyReRouted;
+}
+// -------------------------------------------------------------------------
+sal_Bool implSetObject( const Reference< XParameters >& _rxParameters,
+ const sal_Int32 _nColumnIndex, const Any& _rValue) SAL_THROW ( ( SQLException, RuntimeException ) )
+{
+ sal_Bool bSuccessfullyReRouted = sal_True;
+ switch (_rValue.getValueTypeClass())
+ {
+ case TypeClass_HYPER:
+ {
+ sal_Int64 nValue = 0;
+ OSL_VERIFY( _rValue >>= nValue );
+ _rxParameters->setLong( _nColumnIndex, nValue );
+ }
+ break;
+
+ case TypeClass_ANY:
+ {
+ Any aInnerValue;
+ _rValue >>= aInnerValue;
+ bSuccessfullyReRouted = implSetObject(_rxParameters, _nColumnIndex, aInnerValue);
+ }
+ break;
+
+ case TypeClass_VOID:
+ _rxParameters->setNull(_nColumnIndex,DataType::VARCHAR);
+ break;
+
+ case TypeClass_STRING:
+ _rxParameters->setString(_nColumnIndex, *(rtl::OUString*)_rValue.getValue());
+ break;
+
+ case TypeClass_BOOLEAN:
+ _rxParameters->setBoolean(_nColumnIndex, *(sal_Bool *)_rValue.getValue());
+ break;
+
+ case TypeClass_BYTE:
+ _rxParameters->setByte(_nColumnIndex, *(sal_Int8 *)_rValue.getValue());
+ break;
+
+ case TypeClass_UNSIGNED_SHORT:
+ case TypeClass_SHORT:
+ _rxParameters->setShort(_nColumnIndex, *(sal_Int16*)_rValue.getValue());
+ break;
+
+ case TypeClass_CHAR:
+ _rxParameters->setString(_nColumnIndex, ::rtl::OUString((sal_Unicode *)_rValue.getValue(),1));
+ break;
+
+ case TypeClass_UNSIGNED_LONG:
+ case TypeClass_LONG:
+ _rxParameters->setInt(_nColumnIndex, *(sal_Int32*)_rValue.getValue());
+ break;
+
+ case TypeClass_FLOAT:
+ _rxParameters->setFloat(_nColumnIndex, *(float*)_rValue.getValue());
+ break;
+
+ case TypeClass_DOUBLE:
+ _rxParameters->setDouble(_nColumnIndex, *(double*)_rValue.getValue());
+ break;
+
+ case TypeClass_SEQUENCE:
+ if (_rValue.getValueType() == ::getCppuType((const Sequence< sal_Int8 > *)0))
+ {
+ _rxParameters->setBytes(_nColumnIndex, *(Sequence<sal_Int8>*)_rValue.getValue());
+ }
+ else
+ bSuccessfullyReRouted = sal_False;
+ break;
+ case TypeClass_STRUCT:
+ if (_rValue.getValueType() == ::getCppuType((const DateTime*)0))
+ _rxParameters->setTimestamp(_nColumnIndex, *(DateTime*)_rValue.getValue());
+ else if (_rValue.getValueType() == ::getCppuType((const Date*)0))
+ _rxParameters->setDate(_nColumnIndex, *(Date*)_rValue.getValue());
+ else if (_rValue.getValueType() == ::getCppuType((const Time*)0))
+ _rxParameters->setTime(_nColumnIndex, *(Time*)_rValue.getValue());
+ else
+ bSuccessfullyReRouted = sal_False;
+ break;
+
+ case TypeClass_INTERFACE:
+ if (_rValue.getValueType() == ::getCppuType(static_cast<Reference< XInputStream>*>(NULL)))
+ {
+ Reference< XInputStream > xStream;
+ _rValue >>= xStream;
+ _rxParameters->setBinaryStream(_nColumnIndex, xStream, xStream->available());
+ break;
+ }
+ // run through
+ default:
+ bSuccessfullyReRouted = sal_False;
+
+ }
+
+ return bSuccessfullyReRouted;
+}
+
+//..................................................................
+namespace
+{
+ class OParameterWrapper : public ::cppu::WeakImplHelper1< XIndexAccess >
+ {
+ ::std::bit_vector m_aSet;
+ Reference<XIndexAccess> m_xSource;
+ public:
+ OParameterWrapper(const ::std::bit_vector& _aSet,const Reference<XIndexAccess>& _xSource) : m_aSet(_aSet),m_xSource(_xSource){}
+ private:
+ // ::com::sun::star::container::XElementAccess
+ virtual Type SAL_CALL getElementType() throw(RuntimeException)
+ {
+ return m_xSource->getElementType();
+ }
+ virtual sal_Bool SAL_CALL hasElements( ) throw(RuntimeException)
+ {
+ if ( m_aSet.empty() )
+ return m_xSource->hasElements();
+ return ::std::count(m_aSet.begin(),m_aSet.end(),false) != 0;
+ }
+ // ::com::sun::star::container::XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount( ) throw(RuntimeException)
+ {
+ if ( m_aSet.empty() )
+ return m_xSource->getCount();
+ return ::std::count(m_aSet.begin(),m_aSet.end(),false);
+ }
+ virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+ {
+ if ( m_aSet.empty() )
+ return m_xSource->getByIndex(Index);
+ if ( m_aSet.size() < (size_t)Index )
+ throw IndexOutOfBoundsException();
+
+ ::std::bit_vector::iterator aIter = m_aSet.begin();
+ ::std::bit_vector::iterator aEnd = m_aSet.end();
+ sal_Int32 i = 0;
+ sal_Int32 nParamPos = -1;
+ for(; aIter != aEnd && i <= Index; ++aIter)
+ {
+ ++nParamPos;
+ if ( !*aIter )
+ {
+ ++i;
+ }
+ }
+ return m_xSource->getByIndex(nParamPos);
+ }
+ };
+}
+
+// -----------------------------------------------------------------------------
+void askForParameters(const Reference< XSingleSelectQueryComposer >& _xComposer,
+ const Reference<XParameters>& _xParameters,
+ const Reference< XConnection>& _xConnection,
+ const Reference< XInteractionHandler >& _rxHandler,
+ const ::std::bit_vector& _aParametersSet)
+{
+ OSL_ENSURE(_xComposer.is(),"dbtools::askForParameters XSQLQueryComposer is null!");
+ OSL_ENSURE(_xParameters.is(),"dbtools::askForParameters XParameters is null!");
+ OSL_ENSURE(_xConnection.is(),"dbtools::askForParameters XConnection is null!");
+ OSL_ENSURE(_rxHandler.is(),"dbtools::askForParameters XInteractionHandler is null!");
+
+ // we have to set this here again because getCurrentSettingsComposer can force a setpropertyvalue
+ Reference<XParametersSupplier> xParameters = Reference<XParametersSupplier> (_xComposer, UNO_QUERY);
+
+ Reference<XIndexAccess> xParamsAsIndicies = xParameters.is() ? xParameters->getParameters() : Reference<XIndexAccess>();
+ Reference<XNameAccess> xParamsAsNames(xParamsAsIndicies, UNO_QUERY);
+ sal_Int32 nParamCount = xParamsAsIndicies.is() ? xParamsAsIndicies->getCount() : 0;
+ ::std::bit_vector aNewParameterSet( _aParametersSet );
+ if ( nParamCount || ::std::count(aNewParameterSet.begin(),aNewParameterSet.end(),true) != nParamCount )
+ {
+ static const ::rtl::OUString PROPERTY_NAME(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME));
+ aNewParameterSet.resize(nParamCount ,false);
+ typedef ::std::map< ::rtl::OUString, ::std::vector<sal_Int32> > TParameterPositions;
+ TParameterPositions aParameterNames;
+ for(sal_Int32 i = 0; i < nParamCount; ++i)
+ {
+ Reference<XPropertySet> xParam(xParamsAsIndicies->getByIndex(i),UNO_QUERY);
+ ::rtl::OUString sName;
+ xParam->getPropertyValue(PROPERTY_NAME) >>= sName;
+
+ TParameterPositions::iterator aFind = aParameterNames.find(sName);
+ if ( aFind != aParameterNames.end() )
+ aNewParameterSet[i] = true;
+ aParameterNames[sName].push_back(i+1);
+ }
+ // build an interaction request
+ // two continuations (Ok and Cancel)
+ OInteractionAbort* pAbort = new OInteractionAbort;
+ OParameterContinuation* pParams = new OParameterContinuation;
+ // the request
+ ParametersRequest aRequest;
+ Reference<XIndexAccess> xWrappedParameters = new OParameterWrapper(aNewParameterSet,xParamsAsIndicies);
+ aRequest.Parameters = xWrappedParameters;
+ aRequest.Connection = _xConnection;
+ OInteractionRequest* pRequest = new OInteractionRequest(makeAny(aRequest));
+ Reference< XInteractionRequest > xRequest(pRequest);
+ // some knittings
+ pRequest->addContinuation(pAbort);
+ pRequest->addContinuation(pParams);
+
+ // execute the request
+ _rxHandler->handle(xRequest);
+
+ if (!pParams->wasSelected())
+ {
+ // canceled by the user (i.e. (s)he canceled the dialog)
+ RowSetVetoException e;
+ e.ErrorCode = ParameterInteractionCancelled;
+ throw e;
+ }
+
+ // now transfer the values from the continuation object to the parameter columns
+ Sequence< PropertyValue > aFinalValues = pParams->getValues();
+ const PropertyValue* pFinalValues = aFinalValues.getConstArray();
+ for (sal_Int32 i=0; i<aFinalValues.getLength(); ++i, ++pFinalValues)
+ {
+ Reference< XPropertySet > xParamColumn(xWrappedParameters->getByIndex(i),UNO_QUERY);
+ if (xParamColumn.is())
+ {
+ ::rtl::OUString sName;
+ xParamColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
+ OSL_ENSURE(sName.equals(pFinalValues->Name), "::dbaui::askForParameters: inconsistent parameter names!");
+
+ // determine the field type and ...
+ sal_Int32 nParamType = 0;
+ xParamColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nParamType;
+ // ... the scale of the parameter column
+ sal_Int32 nScale = 0;
+ if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE), xParamColumn))
+ xParamColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)) >>= nScale;
+ // (the index of the parameters is one-based)
+ TParameterPositions::iterator aFind = aParameterNames.find(pFinalValues->Name);
+ ::std::vector<sal_Int32>::iterator aIterPos = aFind->second.begin();
+ ::std::vector<sal_Int32>::iterator aEndPos = aFind->second.end();
+ for(;aIterPos != aEndPos;++aIterPos)
+ {
+ if ( _aParametersSet.empty() || !_aParametersSet[(*aIterPos)-1] )
+ {
+ _xParameters->setObjectWithInfo(*aIterPos, pFinalValues->Value, nParamType, nScale);
+ }
+ }
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void setObjectWithInfo(const Reference<XParameters>& _xParams,
+ sal_Int32 parameterIndex,
+ const Any& x,
+ sal_Int32 sqlType,
+ sal_Int32 scale) throw(SQLException, RuntimeException)
+{
+ ORowSetValue aVal;
+ aVal.fill(x);
+ setObjectWithInfo(_xParams,parameterIndex,aVal,sqlType,scale);
+}
+// -----------------------------------------------------------------------------
+void setObjectWithInfo(const Reference<XParameters>& _xParams,
+ sal_Int32 parameterIndex,
+ const ::connectivity::ORowSetValue& _rValue,
+ sal_Int32 sqlType,
+ sal_Int32 scale) throw(SQLException, RuntimeException)
+{
+ if ( _rValue.isNull() )
+ _xParams->setNull(parameterIndex,sqlType);
+ else
+ {
+ switch(sqlType)
+ {
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ _xParams->setObjectWithInfo(parameterIndex,_rValue.makeAny(),sqlType,scale);
+ break;
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ _xParams->setString(parameterIndex,_rValue);
+ break;
+ case DataType::CLOB:
+ {
+ Any x(_rValue.makeAny());
+ ::rtl::OUString sValue;
+ if ( x >>= sValue )
+ _xParams->setString(parameterIndex,sValue);
+ else
+ {
+ Reference< XClob > xClob;
+ if(x >>= xClob)
+ _xParams->setClob(parameterIndex,xClob);
+ else
+ {
+ Reference< ::com::sun::star::io::XInputStream > xStream;
+ if(x >>= xStream)
+ _xParams->setCharacterStream(parameterIndex,xStream,xStream->available());
+ }
+ }
+ }
+ break;
+ case DataType::BIGINT:
+ if ( _rValue.isSigned() )
+ _xParams->setLong(parameterIndex,_rValue);
+ else
+ _xParams->setString(parameterIndex,_rValue);
+ break;
+
+ case DataType::FLOAT:
+ _xParams->setFloat(parameterIndex,_rValue);
+ break;
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ _xParams->setDouble(parameterIndex,_rValue);
+ break;
+ case DataType::DATE:
+ _xParams->setDate(parameterIndex,_rValue);
+ break;
+ case DataType::TIME:
+ _xParams->setTime(parameterIndex,_rValue);
+ break;
+ case DataType::TIMESTAMP:
+ _xParams->setTimestamp(parameterIndex,_rValue);
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ {
+ Any x(_rValue.makeAny());
+ Sequence< sal_Int8> aBytes;
+ if(x >>= aBytes)
+ _xParams->setBytes(parameterIndex,aBytes);
+ else
+ {
+ Reference< XBlob > xBlob;
+ if(x >>= xBlob)
+ _xParams->setBlob(parameterIndex,xBlob);
+ else
+ {
+ Reference< XClob > xClob;
+ if(x >>= xClob)
+ _xParams->setClob(parameterIndex,xClob);
+ else
+ {
+ Reference< ::com::sun::star::io::XInputStream > xBinStream;
+ if(x >>= xBinStream)
+ _xParams->setBinaryStream(parameterIndex,xBinStream,xBinStream->available());
+ }
+ }
+ }
+ }
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ _xParams->setBoolean(parameterIndex,_rValue);
+ break;
+ case DataType::TINYINT:
+ if ( _rValue.isSigned() )
+ _xParams->setByte(parameterIndex,_rValue);
+ else
+ _xParams->setShort(parameterIndex,_rValue);
+ break;
+ case DataType::SMALLINT:
+ if ( _rValue.isSigned() )
+ _xParams->setShort(parameterIndex,_rValue);
+ else
+ _xParams->setInt(parameterIndex,_rValue);
+ break;
+ case DataType::INTEGER:
+ if ( _rValue.isSigned() )
+ _xParams->setInt(parameterIndex,_rValue);
+ else
+ _xParams->setLong(parameterIndex,_rValue);
+ break;
+ default:
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_UNKNOWN_PARA_TYPE,
+ "$position$", ::rtl::OUString::valueOf(parameterIndex)
+ ) );
+ ::dbtools::throwGenericSQLException(sError,NULL);
+ }
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+void getBoleanComparisonPredicate( const ::rtl::OUString& _rExpression, const sal_Bool _bValue, const sal_Int32 _nBooleanComparisonMode,
+ ::rtl::OUStringBuffer& _out_rSQLPredicate )
+{
+ switch ( _nBooleanComparisonMode )
+ {
+ case BooleanComparisonMode::IS_LITERAL:
+ _out_rSQLPredicate.append( _rExpression );
+ if ( _bValue )
+ _out_rSQLPredicate.appendAscii( " IS TRUE" );
+ else
+ _out_rSQLPredicate.appendAscii( " IS FALSE" );
+ break;
+
+ case BooleanComparisonMode::EQUAL_LITERAL:
+ _out_rSQLPredicate.append( _rExpression );
+ _out_rSQLPredicate.appendAscii( _bValue ? " = TRUE" : " = FALSE" );
+ break;
+
+ case BooleanComparisonMode::ACCESS_COMPAT:
+ if ( _bValue )
+ {
+ _out_rSQLPredicate.appendAscii( " NOT ( ( " );
+ _out_rSQLPredicate.append( _rExpression );
+ _out_rSQLPredicate.appendAscii( " = 0 ) OR ( " );
+ _out_rSQLPredicate.append( _rExpression );
+ _out_rSQLPredicate.appendAscii( " IS NULL ) )" );
+ }
+ else
+ {
+ _out_rSQLPredicate.append( _rExpression );
+ _out_rSQLPredicate.appendAscii( " = 0" );
+ }
+ break;
+
+ case BooleanComparisonMode::EQUAL_INTEGER:
+ // fall through
+ default:
+ _out_rSQLPredicate.append( _rExpression );
+ _out_rSQLPredicate.appendAscii( _bValue ? " = 1" : " = 0" );
+ break;
+ }
+}
+
+//.........................................................................
+} // namespace dbtools
+//.........................................................................
+
+//.........................................................................
+namespace connectivity
+{
+//.........................................................................
+
+void release(oslInterlockedCount& _refCount,
+ ::cppu::OBroadcastHelper& rBHelper,
+ Reference< XInterface >& _xInterface,
+ ::com::sun::star::lang::XComponent* _pObject)
+{
+ if (osl_decrementInterlockedCount( &_refCount ) == 0)
+ {
+ osl_incrementInterlockedCount( &_refCount );
+
+ if (!rBHelper.bDisposed && !rBHelper.bInDispose)
+ {
+ // remember the parent
+ Reference< XInterface > xParent;
+ {
+ ::osl::MutexGuard aGuard( rBHelper.rMutex );
+ xParent = _xInterface;
+ _xInterface = NULL;
+ }
+
+ // First dispose
+ _pObject->dispose();
+
+ // only the alive ref holds the object
+ OSL_ASSERT( _refCount == 1 );
+
+ // release the parent in the ~
+ if (xParent.is())
+ {
+ ::osl::MutexGuard aGuard( rBHelper.rMutex );
+ _xInterface = xParent;
+ }
+
+// // destroy the object if xHoldAlive decrement the refcount to 0
+// m_pDerivedImplementation->WEAK::release();
+ }
+ }
+ else
+ osl_incrementInterlockedCount( &_refCount );
+}
+
+void checkDisposed(sal_Bool _bThrow) throw ( DisposedException )
+{
+ if (_bThrow)
+ throw DisposedException();
+
+}
+// -------------------------------------------------------------------------
+ OSQLColumns::Vector::const_iterator find( OSQLColumns::Vector::const_iterator __first,
+ OSQLColumns::Vector::const_iterator __last,
+ const ::rtl::OUString& _rVal,
+ const ::comphelper::UStringMixEqual& _rCase)
+ {
+ ::rtl::OUString sName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME);
+ return find(__first,__last,sName,_rVal,_rCase);
+ }
+ // -------------------------------------------------------------------------
+ OSQLColumns::Vector::const_iterator findRealName( OSQLColumns::Vector::const_iterator __first,
+ OSQLColumns::Vector::const_iterator __last,
+ const ::rtl::OUString& _rVal,
+ const ::comphelper::UStringMixEqual& _rCase)
+ {
+ ::rtl::OUString sRealName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME);
+ return find(__first,__last,sRealName,_rVal,_rCase);
+ }
+ // -------------------------------------------------------------------------
+ OSQLColumns::Vector::const_iterator find( OSQLColumns::Vector::const_iterator __first,
+ OSQLColumns::Vector::const_iterator __last,
+ const ::rtl::OUString& _rProp,
+ const ::rtl::OUString& _rVal,
+ const ::comphelper::UStringMixEqual& _rCase)
+ {
+ while (__first != __last && !_rCase(getString((*__first)->getPropertyValue(_rProp)),_rVal))
+ ++__first;
+ return __first;
+ }
+
+// -----------------------------------------------------------------------------
+} //namespace connectivity
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx
new file mode 100644
index 000000000000..c9a878fe1840
--- /dev/null
+++ b/connectivity/source/commontools/dbtools2.cxx
@@ -0,0 +1,974 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/dbtools.hxx"
+#include "connectivity/dbconversion.hxx"
+#include "connectivity/dbcharset.hxx"
+#include "connectivity/SQLStatementHelper.hxx"
+#include <unotools/confignode.hxx>
+#include "resource/sharedresources.hxx"
+#include "resource/common_res.hrc"
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include "TConnection.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/container/XChild.hpp>
+
+#include <tools/diagnose_ex.h>
+#include <unotools/sharedunocomponent.hxx>
+#include <comphelper/configurationhelper.hxx>
+
+//.........................................................................
+namespace dbtools
+{
+//.........................................................................
+ using namespace ::com::sun::star::uno;
+ 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;
+ using namespace ::com::sun::star::frame;
+ using namespace connectivity;
+ using namespace comphelper;
+
+::rtl::OUString createStandardColumnPart(const Reference< XPropertySet >& xColProp,const Reference< XConnection>& _xConnection,ISQLStatementHelper* _pHelper,const ::rtl::OUString& _sCreatePattern)
+{
+
+ Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData();
+
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+
+ ::rtl::OUString sTypeName;
+ sal_Int32 nDataType = 0;
+ sal_Int32 nPrecision = 0;
+ sal_Int32 nScale = 0;
+
+ const ::rtl::OUString sQuoteString = xMetaData->getIdentifierQuoteString();
+ ::rtl::OUStringBuffer aSql = ::dbtools::quoteName(sQuoteString,::comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))));
+
+ aSql.appendAscii(" ");
+
+ nDataType = nPrecision = nScale = 0;
+ sal_Bool bIsAutoIncrement = sal_False;
+ xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPENAME)) >>= sTypeName;
+ xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPE)) >>= nDataType;
+ xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_PRECISION)) >>= nPrecision;
+ xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCALE)) >>= nScale;
+ xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bIsAutoIncrement;
+
+ // check if the user enter a specific string to create autoincrement values
+ ::rtl::OUString sAutoIncrementValue;
+ Reference<XPropertySetInfo> xPropInfo = xColProp->getPropertySetInfo();
+ if ( xPropInfo.is() && xPropInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_AUTOINCREMENTCREATION)) )
+ xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_AUTOINCREMENTCREATION)) >>= sAutoIncrementValue;
+ // look if we have to use precisions
+ sal_Bool bUseLiteral = sal_False;
+ ::rtl::OUString sPreFix,sPostFix,sCreateParams;
+ {
+ Reference<XResultSet> xRes = xMetaData->getTypeInfo();
+ if(xRes.is())
+ {
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ while(xRes->next())
+ {
+ ::rtl::OUString sTypeName2Cmp = xRow->getString(1);
+ sal_Int32 nType = xRow->getShort(2);
+ sPreFix = xRow->getString (4);
+ sPostFix = xRow->getString (5);
+ sCreateParams = xRow->getString(6);
+ // first identical type will be used if typename is empty
+ if ( !sTypeName.getLength() && nType == nDataType )
+ sTypeName = sTypeName2Cmp;
+
+ if( sTypeName.equalsIgnoreAsciiCase(sTypeName2Cmp) && nType == nDataType && sCreateParams.getLength() && !xRow->wasNull())
+ {
+ bUseLiteral = sal_True;
+ break;
+ }
+ }
+ }
+ }
+
+ sal_Int32 nIndex = 0;
+ if ( sAutoIncrementValue.getLength() && (nIndex = sTypeName.indexOf(sAutoIncrementValue)) != -1 )
+ {
+ sTypeName = sTypeName.replaceAt(nIndex,sTypeName.getLength() - nIndex,::rtl::OUString());
+ }
+
+ if ( (nPrecision > 0 || nScale > 0) && bUseLiteral )
+ {
+ sal_Int32 nParenPos = sTypeName.indexOf('(');
+ if ( nParenPos == -1 )
+ {
+ aSql.append(sTypeName);
+ aSql.appendAscii("(");
+ }
+ else
+ {
+ aSql.append(sTypeName.copy(0,++nParenPos));
+ }
+
+ if ( nPrecision > 0 && nDataType != DataType::TIMESTAMP )
+ {
+ aSql.append(nPrecision);
+ if ( (nScale > 0) || (_sCreatePattern.getLength() && sCreateParams.indexOf(_sCreatePattern) != -1) )
+ aSql.appendAscii(",");
+ }
+ if ( (nScale > 0) || (_sCreatePattern.getLength() && sCreateParams.indexOf(_sCreatePattern) != -1 ) || nDataType == DataType::TIMESTAMP )
+ aSql.append(nScale);
+
+ if ( nParenPos == -1 )
+ aSql.appendAscii(")");
+ else
+ {
+ nParenPos = sTypeName.indexOf(')',nParenPos);
+ aSql.append(sTypeName.copy(nParenPos));
+ }
+ }
+ else
+ aSql.append(sTypeName); // simply add the type name
+
+ ::rtl::OUString aDefault = ::comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_DEFAULTVALUE)));
+ if ( aDefault.getLength() )
+ {
+ aSql.append(::rtl::OUString::createFromAscii(" DEFAULT "));
+ aSql.append(sPreFix);
+ aSql.append(aDefault);
+ aSql.append(sPostFix);
+ } // if ( aDefault.getLength() )
+
+ if(::comphelper::getINT32(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISNULLABLE))) == ColumnValue::NO_NULLS)
+ aSql.append(::rtl::OUString::createFromAscii(" NOT NULL"));
+
+ if ( bIsAutoIncrement && sAutoIncrementValue.getLength())
+ {
+ aSql.appendAscii(" ");
+ aSql.append(sAutoIncrementValue);
+ }
+
+ if ( _pHelper )
+ _pHelper->addComment(xColProp,aSql);
+
+ return aSql.makeStringAndClear();
+}
+// -----------------------------------------------------------------------------
+
+::rtl::OUString createStandardCreateStatement(const Reference< XPropertySet >& descriptor,const Reference< XConnection>& _xConnection,ISQLStatementHelper* _pHelper,const ::rtl::OUString& _sCreatePattern)
+{
+ ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("CREATE TABLE ");
+ ::rtl::OUString sCatalog,sSchema,sTable,sComposedName;
+
+ Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData();
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+
+ descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)) >>= sCatalog;
+ descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= sSchema;
+ descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= sTable;
+
+ sComposedName = ::dbtools::composeTableName( xMetaData, sCatalog, sSchema, sTable, sal_True, ::dbtools::eInTableDefinitions );
+ if ( !sComposedName.getLength() )
+ ::dbtools::throwFunctionSequenceException(_xConnection);
+
+ aSql.append(sComposedName);
+ aSql.append(::rtl::OUString::createFromAscii(" ("));
+
+ // columns
+ Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
+ Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
+ // check if there are columns
+ if(!xColumns.is() || !xColumns->getCount())
+ ::dbtools::throwFunctionSequenceException(_xConnection);
+
+ Reference< XPropertySet > xColProp;
+
+ sal_Int32 nCount = xColumns->getCount();
+ for(sal_Int32 i=0;i<nCount;++i)
+ {
+ if ( (xColumns->getByIndex(i) >>= xColProp) && xColProp.is() )
+ {
+ aSql.append(createStandardColumnPart(xColProp,_xConnection,_pHelper,_sCreatePattern));
+ aSql.appendAscii(",");
+ }
+ }
+ return aSql.makeStringAndClear();
+}
+namespace
+{
+ ::rtl::OUString generateColumnNames(const Reference<XIndexAccess>& _xColumns,const Reference<XDatabaseMetaData>& _xMetaData)
+ {
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ static const ::rtl::OUString sComma(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(",")));
+
+ const ::rtl::OUString sQuote(_xMetaData->getIdentifierQuoteString());
+ ::rtl::OUString sSql = ::rtl::OUString::createFromAscii(" (");
+ Reference< XPropertySet > xColProp;
+
+ sal_Int32 nColCount = _xColumns->getCount();
+ for(sal_Int32 i=0;i<nColCount;++i)
+ {
+ if ( (_xColumns->getByIndex(i) >>= xColProp) && xColProp.is() )
+ sSql += ::dbtools::quoteName(sQuote,::comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))))
+ + sComma;
+ }
+
+ if ( nColCount )
+ sSql = sSql.replaceAt(sSql.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")));
+ return sSql;
+ }
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString createStandardKeyStatement(const Reference< XPropertySet >& descriptor,const Reference< XConnection>& _xConnection)
+{
+ Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData();
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+
+ ::rtl::OUStringBuffer aSql;
+ // keys
+ Reference<XKeysSupplier> xKeySup(descriptor,UNO_QUERY);
+ Reference<XIndexAccess> xKeys = xKeySup->getKeys();
+ if ( xKeys.is() )
+ {
+ Reference< XPropertySet > xColProp;
+ Reference<XIndexAccess> xColumns;
+ Reference<XColumnsSupplier> xColumnSup;
+ ::rtl::OUString sCatalog,sSchema,sTable,sComposedName;
+ sal_Bool bPKey = sal_False;
+ for(sal_Int32 i=0;i<xKeys->getCount();++i)
+ {
+ if ( (xKeys->getByIndex(i) >>= xColProp) && xColProp.is() )
+ {
+
+ sal_Int32 nKeyType = ::comphelper::getINT32(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPE)));
+
+ if ( nKeyType == KeyType::PRIMARY )
+ {
+ if(bPKey)
+ ::dbtools::throwFunctionSequenceException(_xConnection);
+
+ bPKey = sal_True;
+ xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY);
+ xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY);
+ if(!xColumns.is() || !xColumns->getCount())
+ ::dbtools::throwFunctionSequenceException(_xConnection);
+
+ const ::rtl::OUString sQuote = xMetaData->getIdentifierQuoteString();
+ aSql.append(::rtl::OUString::createFromAscii(" PRIMARY KEY "));
+ aSql.append(generateColumnNames(xColumns,xMetaData));
+ }
+ else if(nKeyType == KeyType::UNIQUE)
+ {
+ xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY);
+ xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY);
+ if(!xColumns.is() || !xColumns->getCount())
+ ::dbtools::throwFunctionSequenceException(_xConnection);
+
+ const ::rtl::OUString sQuote = xMetaData->getIdentifierQuoteString();
+ aSql.append(::rtl::OUString::createFromAscii(" UNIQUE "));
+ aSql.append(generateColumnNames(xColumns,xMetaData));
+ }
+ else if(nKeyType == KeyType::FOREIGN)
+ {
+ sal_Int32 nDeleteRule = getINT32(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_DELETERULE)));
+
+ xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY);
+ xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY);
+ if(!xColumns.is() || !xColumns->getCount())
+ ::dbtools::throwFunctionSequenceException(_xConnection);
+
+ aSql.append(::rtl::OUString::createFromAscii(" FOREIGN KEY "));
+ ::rtl::OUString sRefTable = getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_REFERENCEDTABLE)));
+ ::dbtools::qualifiedNameComponents(xMetaData,
+ sRefTable,
+ sCatalog,
+ sSchema,
+ sTable,
+ ::dbtools::eInDataManipulation);
+ sComposedName = ::dbtools::composeTableName( xMetaData, sCatalog, sSchema, sTable, sal_True, ::dbtools::eInTableDefinitions );
+
+
+ if ( !sComposedName.getLength() )
+ ::dbtools::throwFunctionSequenceException(_xConnection);
+
+ aSql.append(generateColumnNames(xColumns,xMetaData));
+
+ switch(nDeleteRule)
+ {
+ case KeyRule::CASCADE:
+ aSql.append(::rtl::OUString::createFromAscii(" ON DELETE CASCADE "));
+ break;
+ case KeyRule::RESTRICT:
+ aSql.append(::rtl::OUString::createFromAscii(" ON DELETE RESTRICT "));
+ break;
+ case KeyRule::SET_NULL:
+ aSql.append(::rtl::OUString::createFromAscii(" ON DELETE SET NULL "));
+ break;
+ case KeyRule::SET_DEFAULT:
+ aSql.append(::rtl::OUString::createFromAscii(" ON DELETE SET DEFAULT "));
+ break;
+ default:
+ ;
+ }
+ }
+ }
+ }
+ }
+
+ if ( aSql.getLength() )
+ {
+ if ( aSql.charAt(aSql.getLength()-1) == ',' )
+ aSql.setCharAt(aSql.getLength()-1,')');
+ else
+ aSql.appendAscii(")");
+ }
+
+ return aSql.makeStringAndClear();
+
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString createSqlCreateTableStatement( const Reference< XPropertySet >& descriptor,
+ const Reference< XConnection>& _xConnection,
+ ISQLStatementHelper* _pHelper,
+ const ::rtl::OUString& _sCreatePattern)
+{
+ ::rtl::OUString aSql = ::dbtools::createStandardCreateStatement(descriptor,_xConnection,_pHelper,_sCreatePattern);
+ const ::rtl::OUString sKeyStmt = ::dbtools::createStandardKeyStatement(descriptor,_xConnection);
+ if ( sKeyStmt.getLength() )
+ aSql += sKeyStmt;
+ else
+ {
+ if ( aSql.lastIndexOf(',') == (aSql.getLength()-1) )
+ aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
+ else
+ aSql += ::rtl::OUString::createFromAscii(")");
+ }
+ return aSql;
+}
+namespace
+{
+ Reference<XPropertySet> lcl_createSDBCXColumn(const Reference<XNameAccess>& _xPrimaryKeyColumns,
+ const Reference<XConnection>& _xConnection,
+ const Any& _aCatalog,
+ const ::rtl::OUString& _aSchema,
+ const ::rtl::OUString& _aTable,
+ const ::rtl::OUString& _rQueryName,
+ const ::rtl::OUString& _rName,
+ sal_Bool _bCase,
+ sal_Bool _bQueryForInfo,
+ sal_Bool _bIsAutoIncrement,
+ sal_Bool _bIsCurrency,
+ sal_Int32 _nDataType)
+ {
+ Reference<XPropertySet> xProp;
+ Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData();
+ Reference< XResultSet > xResult = xMetaData->getColumns(_aCatalog, _aSchema, _aTable, _rQueryName);
+
+ if ( xResult.is() )
+ {
+ UStringMixEqual aMixCompare(_bCase);
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while( xResult->next() )
+ {
+ if ( aMixCompare(xRow->getString(4),_rName) )
+ {
+ sal_Int32 nField5 = xRow->getInt(5);
+ ::rtl::OUString aField6 = xRow->getString(6);
+ sal_Int32 nField7 = xRow->getInt(7)
+ , nField9 = xRow->getInt(9)
+ , nField11= xRow->getInt(11);
+ ::rtl::OUString sField12 = xRow->getString(12),
+ sField13 = xRow->getString(13);
+ ::comphelper::disposeComponent(xRow);
+
+ sal_Bool bAutoIncrement = _bIsAutoIncrement
+ ,bIsCurrency = _bIsCurrency;
+ if ( _bQueryForInfo )
+ {
+ const ::rtl::OUString sQuote = xMetaData->getIdentifierQuoteString();
+ ::rtl::OUString sQuotedName = ::dbtools::quoteName(sQuote,_rName);
+ ::rtl::OUString sComposedName;
+ sComposedName = composeTableNameForSelect(_xConnection, getString( _aCatalog ), _aSchema, _aTable );
+
+ ColumnInformationMap aInfo(_bCase);
+ collectColumnInformation(_xConnection,sComposedName,sQuotedName,aInfo);
+ ColumnInformationMap::iterator aIter = aInfo.begin();
+ if ( aIter != aInfo.end() )
+ {
+ bAutoIncrement = aIter->second.first.first;
+ bIsCurrency = aIter->second.first.second;
+ if ( DataType::OTHER == nField5 )
+ nField5 = aIter->second.second;
+ }
+ }
+ else if ( DataType::OTHER == nField5 )
+ nField5 = _nDataType;
+
+ if ( nField11 != ColumnValue::NO_NULLS )
+ {
+ try
+ {
+ if ( _xPrimaryKeyColumns.is() )
+ {
+ if ( _xPrimaryKeyColumns->hasByName(_rName) )
+ nField11 = ColumnValue::NO_NULLS;
+
+ }
+ else
+ {
+ Reference< XResultSet > xPKeys = xMetaData->getPrimaryKeys( _aCatalog, _aSchema, _aTable );
+ Reference< XRow > xPKeyRow( xPKeys, UNO_QUERY_THROW );
+ while( xPKeys->next() ) // there can be only one primary key
+ {
+ ::rtl::OUString sKeyColumn = xPKeyRow->getString(4);
+ if ( aMixCompare(_rName,sKeyColumn) )
+ {
+ nField11 = ColumnValue::NO_NULLS;
+ break;
+ }
+ }
+ }
+ }
+ catch(SQLException&)
+ {
+ OSL_ENSURE( false, "lcl_createSDBCXColumn: caught an exception!" );
+ }
+ }
+
+ connectivity::sdbcx::OColumn* pRet = new connectivity::sdbcx::OColumn(_rName,
+ aField6,
+ sField13,
+ sField12,
+ nField11,
+ nField7,
+ nField9,
+ nField5,
+ bAutoIncrement,
+ sal_False,
+ bIsCurrency,
+ _bCase);
+
+ xProp = pRet;
+ break;
+ }
+ }
+ }
+
+ return xProp;
+ }
+ //------------------------------------------------------------------
+ Reference< XModel> lcl_getXModel(const Reference< XInterface>& _xIface)
+ {
+ Reference< XInterface > xParent = _xIface;
+ Reference< XModel > xModel(xParent,UNO_QUERY);;
+ while( xParent.is() && !xModel.is() )
+ {
+ Reference<XChild> xChild(xParent,UNO_QUERY);
+ xParent.set(xChild.is() ? xChild->getParent() : Reference< XInterface >(),UNO_QUERY);
+ xModel.set(xParent,UNO_QUERY);
+ }
+ return xModel;
+ }
+}
+// -----------------------------------------------------------------------------
+Reference<XPropertySet> createSDBCXColumn(const Reference<XPropertySet>& _xTable,
+ const Reference<XConnection>& _xConnection,
+ const ::rtl::OUString& _rName,
+ sal_Bool _bCase,
+ sal_Bool _bQueryForInfo,
+ sal_Bool _bIsAutoIncrement,
+ sal_Bool _bIsCurrency,
+ sal_Int32 _nDataType)
+{
+ Reference<XPropertySet> xProp;
+ OSL_ENSURE(_xTable.is(),"Table is NULL!");
+ if ( !_xTable.is() )
+ return xProp;
+
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData();
+ Any aCatalog;
+ aCatalog = _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME));
+
+ ::rtl::OUString aSchema, aTable;
+ _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
+ _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable;
+
+ Reference<XNameAccess> xPrimaryKeyColumns = getPrimaryKeyColumns_throw(_xTable);
+
+ xProp = lcl_createSDBCXColumn(xPrimaryKeyColumns,_xConnection,aCatalog, aSchema, aTable, _rName,_rName,_bCase,_bQueryForInfo,_bIsAutoIncrement,_bIsCurrency,_nDataType);
+ if ( !xProp.is() )
+ {
+ xProp = lcl_createSDBCXColumn(xPrimaryKeyColumns,_xConnection,aCatalog, aSchema, aTable, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")),_rName,_bCase,_bQueryForInfo,_bIsAutoIncrement,_bIsCurrency,_nDataType);
+ if ( !xProp.is() )
+ xProp = new connectivity::sdbcx::OColumn(_rName,
+ ::rtl::OUString(),::rtl::OUString(),::rtl::OUString(),
+ ColumnValue::NULLABLE_UNKNOWN,
+ 0,
+ 0,
+ DataType::VARCHAR,
+ _bIsAutoIncrement,
+ sal_False,
+ _bIsCurrency,
+ _bCase);
+
+ }
+
+ return xProp;
+}
+
+// -----------------------------------------------------------------------------
+bool getBooleanDataSourceSetting( const Reference< XConnection >& _rxConnection, const sal_Char* _pAsciiSettingName )
+{
+ bool bValue( false );
+ try
+ {
+ Reference< XPropertySet> xDataSourceProperties( findDataSource( _rxConnection ), UNO_QUERY );
+ OSL_ENSURE( xDataSourceProperties.is(), "::dbtools::getBooleanDataSourceSetting: somebody is using this with a non-SDB-level connection!" );
+ if ( xDataSourceProperties.is() )
+ {
+ Reference< XPropertySet > xSettings(
+ xDataSourceProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Settings") ) ),
+ UNO_QUERY_THROW
+ );
+ OSL_VERIFY( xSettings->getPropertyValue( ::rtl::OUString::createFromAscii( _pAsciiSettingName ) ) >>= bValue );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bValue;
+}
+// -------------------------------------------------------------------------
+bool getDataSourceSetting( const Reference< XInterface >& _xChild, const ::rtl::OUString& _sAsciiSettingsName,
+ Any& /* [out] */ _rSettingsValue )
+{
+ bool bIsPresent = false;
+ try
+ {
+ const Reference< XPropertySet> xDataSourceProperties( findDataSource( _xChild ), UNO_QUERY );
+ OSL_ENSURE( xDataSourceProperties.is(), "getDataSourceSetting: invalid data source object!" );
+ if ( !xDataSourceProperties.is() )
+ return false;
+
+ const Reference< XPropertySet > xSettings(
+ xDataSourceProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Settings") ) ),
+ UNO_QUERY_THROW
+ );
+
+ _rSettingsValue = xSettings->getPropertyValue( _sAsciiSettingsName );
+ bIsPresent = true;
+ }
+ catch( const Exception& )
+ {
+ bIsPresent = false;
+ }
+ return bIsPresent;
+}
+// -------------------------------------------------------------------------
+bool getDataSourceSetting( const Reference< XInterface >& _rxDataSource, const sal_Char* _pAsciiSettingsName,
+ Any& /* [out] */ _rSettingsValue )
+{
+ ::rtl::OUString sAsciiSettingsName = ::rtl::OUString::createFromAscii(_pAsciiSettingsName);
+ return getDataSourceSetting( _rxDataSource, sAsciiSettingsName,_rSettingsValue );
+}
+// -----------------------------------------------------------------------------
+sal_Bool isDataSourcePropertyEnabled(const Reference<XInterface>& _xProp,const ::rtl::OUString& _sProperty,sal_Bool _bDefault)
+{
+ sal_Bool bEnabled = _bDefault;
+ try
+ {
+ Reference< XPropertySet> xProp(findDataSource(_xProp),UNO_QUERY);
+ if ( xProp.is() )
+ {
+ Sequence< PropertyValue > aInfo;
+ xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Info"))) >>= aInfo;
+ const PropertyValue* pValue =::std::find_if(aInfo.getConstArray(),
+ aInfo.getConstArray() + aInfo.getLength(),
+ ::std::bind2nd(TPropertyValueEqualFunctor(),_sProperty));
+ if ( pValue && pValue != (aInfo.getConstArray() + aInfo.getLength()) )
+ pValue->Value >>= bEnabled;
+ }
+ }
+ catch(SQLException&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bEnabled;
+}
+// -----------------------------------------------------------------------------
+Reference< XTablesSupplier> getDataDefinitionByURLAndConnection(
+ const ::rtl::OUString& _rsUrl,
+ const Reference< XConnection>& _xConnection,
+ const Reference< XMultiServiceFactory>& _rxFactory)
+{
+ Reference< XTablesSupplier> xTablesSup;
+ try
+ {
+ Reference< XDriverAccess> xManager(
+ _rxFactory->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.sdbc.DriverManager") ),
+ UNO_QUERY_THROW );
+ Reference< XDataDefinitionSupplier > xSupp( xManager->getDriverByURL( _rsUrl ), UNO_QUERY );
+
+ if ( xSupp.is() )
+ {
+ xTablesSup = xSupp->getDataDefinitionByConnection( _xConnection );
+ OSL_ENSURE(xTablesSup.is(),"No table supplier!");
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xTablesSup;
+}
+
+// -----------------------------------------------------------------------------
+sal_Int32 getTablePrivileges(const Reference< XDatabaseMetaData>& _xMetaData,
+ const ::rtl::OUString& _sCatalog,
+ const ::rtl::OUString& _sSchema,
+ const ::rtl::OUString& _sTable)
+{
+ OSL_ENSURE(_xMetaData.is(),"Invalid metadata!");
+ sal_Int32 nPrivileges = 0;
+ try
+ {
+ Any aVal;
+ if(_sCatalog.getLength())
+ aVal <<= _sCatalog;
+ Reference< XResultSet > xPrivileges = _xMetaData->getTablePrivileges(aVal, _sSchema, _sTable);
+ Reference< XRow > xCurrentRow(xPrivileges, UNO_QUERY);
+
+ if ( xCurrentRow.is() )
+ {
+ ::rtl::OUString sUserWorkingFor = _xMetaData->getUserName();
+ 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");
+ // after creation the set is positioned before the first record, per definitionem
+#ifdef DBG_UTIL
+ Reference< XResultSetMetaDataSupplier > xSup(xPrivileges,UNO_QUERY);
+ if ( xSup.is() )
+ {
+ Reference< XResultSetMetaData > xRsMetaData = xSup->getMetaData();
+ if ( xRsMetaData.is() )
+ {
+ sal_Int32 nCount = xRsMetaData->getColumnCount();
+ for (sal_Int32 i=1; i<=nCount; ++i)
+ {
+ ::rtl::OUString sColumnName = xRsMetaData->getColumnName(i);
+ }
+ }
+ }
+#endif
+
+ ::rtl::OUString sPrivilege, sGrantee;
+ while ( xPrivileges->next() )
+ {
+#ifdef DBG_UTIL
+ ::rtl::OUString sCat, sSchema, sName, sGrantor, sGrantable;
+ sCat = xCurrentRow->getString(1);
+ sSchema = xCurrentRow->getString(2);
+ sName = xCurrentRow->getString(3);
+ sGrantor = xCurrentRow->getString(4);
+#endif
+ sGrantee = xCurrentRow->getString(5);
+ sPrivilege = xCurrentRow->getString(6);
+#ifdef DBG_UTIL
+ sGrantable = xCurrentRow->getString(7);
+#endif
+
+ if (!sUserWorkingFor.equalsIgnoreAsciiCase(sGrantee))
+ continue;
+
+ if (sPrivilege.equalsIgnoreAsciiCase(sSELECT))
+ nPrivileges |= Privilege::SELECT;
+ else if (sPrivilege.equalsIgnoreAsciiCase(sINSERT))
+ nPrivileges |= Privilege::INSERT;
+ else if (sPrivilege.equalsIgnoreAsciiCase(sUPDATE))
+ nPrivileges |= Privilege::UPDATE;
+ else if (sPrivilege.equalsIgnoreAsciiCase(sDELETE))
+ nPrivileges |= Privilege::DELETE;
+ else if (sPrivilege.equalsIgnoreAsciiCase(sREAD))
+ nPrivileges |= Privilege::READ;
+ else if (sPrivilege.equalsIgnoreAsciiCase(sCREATE))
+ nPrivileges |= Privilege::CREATE;
+ else if (sPrivilege.equalsIgnoreAsciiCase(sALTER))
+ nPrivileges |= Privilege::ALTER;
+ else if (sPrivilege.equalsIgnoreAsciiCase(sREFERENCE))
+ nPrivileges |= Privilege::REFERENCE;
+ else if (sPrivilege.equalsIgnoreAsciiCase(sDROP))
+ nPrivileges |= Privilege::DROP;
+ }
+ }
+ disposeComponent(xPrivileges);
+ }
+ catch(const SQLException& e)
+ {
+ static ::rtl::OUString sNotSupportedState = ::rtl::OUString::createFromAscii("IM001");
+ // some drivers don't support any privileges so we assume that we are allowed to do all we want :-)
+ if(e.SQLState == sNotSupportedState)
+ nPrivileges |= Privilege::DROP |
+ Privilege::REFERENCE |
+ Privilege::ALTER |
+ Privilege::CREATE |
+ Privilege::READ |
+ Privilege::DELETE |
+ Privilege::UPDATE |
+ Privilege::INSERT |
+ Privilege::SELECT;
+ else
+ OSL_ENSURE(0,"Could not collect the privileges !");
+ }
+ return nPrivileges;
+}
+// -----------------------------------------------------------------------------
+// we need some more information about the column
+void collectColumnInformation(const Reference< XConnection>& _xConnection,
+ const ::rtl::OUString& _sComposedName,
+ const ::rtl::OUString& _rName,
+ ColumnInformationMap& _rInfo)
+{
+ static ::rtl::OUString STR_WHERE = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE "));
+
+ ::rtl::OUString sSelect = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT "));
+ sSelect += _rName;
+ sSelect += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM "));
+ sSelect += _sComposedName;
+ sSelect += STR_WHERE;
+ sSelect += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0 = 1"));
+
+ try
+ {
+ ::utl::SharedUNOComponent< XStatement > xStmt( _xConnection->createStatement() );
+ Reference< XPropertySet > xStatementProps( xStmt, UNO_QUERY_THROW );
+ xStatementProps->setPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_ESCAPEPROCESSING ), makeAny( (sal_Bool)sal_False ) );
+ Reference< XResultSet > xResult( xStmt->executeQuery( sSelect ), UNO_QUERY_THROW );
+ Reference< XResultSetMetaDataSupplier > xSuppMeta( xResult, UNO_QUERY_THROW );
+ Reference< XResultSetMetaData > xMeta( xSuppMeta->getMetaData(), UNO_QUERY_THROW );
+
+ sal_Int32 nCount = xMeta->getColumnCount();
+ OSL_ENSURE( nCount != 0, "::dbtools::collectColumnInformation: result set has empty (column-less) meta data!" );
+ for (sal_Int32 i=1; i <= nCount ; ++i)
+ {
+ _rInfo.insert(ColumnInformationMap::value_type(xMeta->getColumnName(i),
+ ColumnInformation(TBoolPair(xMeta->isAutoIncrement(i),xMeta->isCurrency(i)),xMeta->getColumnType(i))));
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+bool isEmbeddedInDatabase( const Reference< XInterface >& _rxComponent, Reference< XConnection >& _rxActualConnection )
+{
+ bool bIsEmbedded = false;
+ try
+ {
+ Reference< XModel > xModel = lcl_getXModel( _rxComponent );
+
+ if ( xModel.is() )
+ {
+ Sequence< PropertyValue > aArgs = xModel->getArgs();
+ const PropertyValue* pIter = aArgs.getConstArray();
+ const PropertyValue* pEnd = pIter + aArgs.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if ( pIter->Name.equalsAscii("ComponentData") )
+ {
+ Sequence<PropertyValue> aDocumentContext;
+ pIter->Value >>= aDocumentContext;
+ const PropertyValue* pContextIter = aDocumentContext.getConstArray();
+ const PropertyValue* pContextEnd = pContextIter + aDocumentContext.getLength();
+ for(;pContextIter != pContextEnd;++pContextIter)
+ {
+ if ( pContextIter->Name.equalsAscii( "ActiveConnection" )
+ && ( pContextIter->Value >>= _rxActualConnection )
+ )
+ {
+ bIsEmbedded = true;
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ // not intereseted in
+ }
+ return bIsEmbedded;
+}
+// -----------------------------------------------------------------------------
+namespace
+{
+ ::rtl::OUString lcl_getEncodingName( rtl_TextEncoding _eEncoding )
+ {
+ ::rtl::OUString sEncodingName;
+
+ OCharsetMap aCharsets;
+ OCharsetMap::CharsetIterator aEncodingPos = aCharsets.find( _eEncoding );
+ OSL_ENSURE( aEncodingPos != aCharsets.end(), "lcl_getEncodingName: *which* encoding?" );
+ if ( aEncodingPos != aCharsets.end() )
+ sEncodingName = (*aEncodingPos).getIanaName();
+
+ return sEncodingName;
+ }
+}
+
+// -----------------------------------------------------------------------------
+sal_Int32 DBTypeConversion::convertUnicodeString( const ::rtl::OUString& _rSource, ::rtl::OString& _rDest, rtl_TextEncoding _eEncoding ) SAL_THROW((com::sun::star::sdbc::SQLException))
+{
+ if ( !rtl_convertUStringToString( &_rDest.pData, _rSource.getStr(), _rSource.getLength(),
+ _eEncoding,
+ RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
+ RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE |
+ RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 |
+ RTL_UNICODETOTEXT_FLAGS_NOCOMPOSITE )
+ )
+ {
+ SharedResources aResources;
+ ::rtl::OUString sMessage = aResources.getResourceStringWithSubstitution( STR_CANNOT_CONVERT_STRING,
+ "$string$", _rSource,
+ "$charset$", lcl_getEncodingName( _eEncoding )
+ );
+
+ throw SQLException(
+ sMessage,
+ NULL,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "22018" ) ),
+ 22018,
+ Any()
+ );
+ }
+
+ return _rDest.getLength();
+}
+
+// -----------------------------------------------------------------------------
+sal_Int32 DBTypeConversion::convertUnicodeStringToLength( const ::rtl::OUString& _rSource, ::rtl::OString& _rDest,
+ sal_Int32 _nMaxLen, rtl_TextEncoding _eEncoding ) SAL_THROW((SQLException))
+{
+ sal_Int32 nLen = convertUnicodeString( _rSource, _rDest, _eEncoding );
+ if ( nLen > _nMaxLen )
+ {
+ SharedResources aResources;
+ ::rtl::OUString sMessage = aResources.getResourceStringWithSubstitution( STR_STRING_LENGTH_EXCEEDED,
+ "$string$", _rSource,
+ "$maxlen$", ::rtl::OUString::valueOf( _nMaxLen ),
+ "$charset$", lcl_getEncodingName( _eEncoding )
+ );
+
+ throw SQLException(
+ sMessage,
+ NULL,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "22001" ) ),
+ 22001,
+ Any()
+ );
+ }
+
+ return nLen;
+}
+::rtl::OUString lcl_getReportEngines()
+{
+ static ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.DataAccess/ReportEngines"));
+ return s_sNodeName;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString lcl_getDefaultReportEngine()
+{
+ static ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("DefaultReportEngine"));
+ return s_sNodeName;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString lcl_getReportEngineNames()
+{
+ static ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("ReportEngineNames"));
+ return s_sNodeName;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString getDefaultReportEngineServiceName(const Reference< XMultiServiceFactory >& _rxORB)
+{
+ ::utl::OConfigurationTreeRoot aReportEngines = ::utl::OConfigurationTreeRoot::createWithServiceFactory(
+ _rxORB, lcl_getReportEngines(), -1, ::utl::OConfigurationTreeRoot::CM_READONLY);
+
+ if ( aReportEngines.isValid() )
+ {
+ ::rtl::OUString sDefaultReportEngineName;
+ aReportEngines.getNodeValue(lcl_getDefaultReportEngine()) >>= sDefaultReportEngineName;
+ if ( sDefaultReportEngineName.getLength() )
+ {
+ ::utl::OConfigurationNode aReportEngineNames = aReportEngines.openNode(lcl_getReportEngineNames());
+ if ( aReportEngineNames.isValid() )
+ {
+ ::utl::OConfigurationNode aReportEngine = aReportEngineNames.openNode(sDefaultReportEngineName);
+ if ( aReportEngine.isValid() )
+ {
+ ::rtl::OUString sRet;
+ const static ::rtl::OUString s_sService(RTL_CONSTASCII_USTRINGPARAM("ServiceName"));
+ aReportEngine.getNodeValue(s_sService) >>= sRet;
+ return sRet;
+ }
+ }
+ }
+ else
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.pentaho.SOReportJobFactory"));
+ }
+ else
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.pentaho.SOReportJobFactory"));
+ return ::rtl::OUString();
+}
+// -----------------------------------------------------------------------------
+//.........................................................................
+} // namespace dbtools
+//.........................................................................
+
diff --git a/connectivity/source/commontools/filtermanager.cxx b/connectivity/source/commontools/filtermanager.cxx
new file mode 100644
index 000000000000..bab2ec4ed144
--- /dev/null
+++ b/connectivity/source/commontools/filtermanager.cxx
@@ -0,0 +1,198 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/filtermanager.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
+/** === end UNO includes === **/
+#include "TConnection.hxx"
+#include <osl/diagnose.h>
+#include "connectivity/dbtools.hxx"
+
+//........................................................................
+namespace dbtools
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace connectivity;
+
+ //====================================================================
+ //= FilterManager
+ //====================================================================
+ //--------------------------------------------------------------------
+ FilterManager::FilterManager( const Reference< XMultiServiceFactory >& _rxORB )
+ :m_xORB( _rxORB )
+ ,m_aFilterComponents( FC_COMPONENT_COUNT )
+ ,m_bApplyPublicFilter( true )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void FilterManager::initialize( const Reference< XPropertySet >& _rxComponentAggregate )
+ {
+ m_xComponentAggregate = _rxComponentAggregate;
+ OSL_ENSURE( m_xComponentAggregate.is(), "FilterManager::initialize: invalid arguments!" );
+
+ if ( m_xComponentAggregate.is() )
+ m_xComponentAggregate->setPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_APPLYFILTER), makeAny( (sal_Bool)sal_True ) );
+ }
+
+ //--------------------------------------------------------------------
+ void FilterManager::dispose( )
+ {
+ m_xComponentAggregate.clear();
+ }
+
+ //--------------------------------------------------------------------
+ const ::rtl::OUString& FilterManager::getFilterComponent( FilterComponent _eWhich ) const
+ {
+ return m_aFilterComponents[ _eWhich ];
+ }
+
+ //--------------------------------------------------------------------
+ void FilterManager::setFilterComponent( FilterComponent _eWhich, const ::rtl::OUString& _rComponent )
+ {
+ m_aFilterComponents[ _eWhich ] = _rComponent;
+ try
+ {
+ if ( m_xComponentAggregate.is() && (( _eWhich != fcPublicFilter ) || m_bApplyPublicFilter ) )
+ m_xComponentAggregate->setPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FILTER), makeAny( getComposedFilter() ) );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FilterManager::setFilterComponent: setting the filter failed!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void FilterManager::setApplyPublicFilter( sal_Bool _bApply )
+ {
+ if ( m_bApplyPublicFilter == _bApply )
+ return;
+
+ m_bApplyPublicFilter = _bApply;
+
+ try
+ {
+ if ( m_xComponentAggregate.is() && getFilterComponent( fcPublicFilter ).getLength() )
+ { // only if there changed something
+ m_xComponentAggregate->setPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FILTER), makeAny( getComposedFilter() ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FilterManager::setApplyPublicFilter: setting the filter failed!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ void lcl_ensureBracketed( ::rtl::OUString& /* [inout] */ _rExpression )
+ {
+ OSL_ENSURE( _rExpression.getLength(), "lcl_ensureBracketed: expression is empty!" );
+ if ( _rExpression.getLength() )
+ {
+ if ( ( _rExpression.getStr()[0] != '(' ) || ( _rExpression.getStr()[ _rExpression.getLength() - 1 ] != ')' ) )
+ {
+ ::rtl::OUString sComposed( RTL_CONSTASCII_USTRINGPARAM( "(" ) );
+ sComposed += _rExpression;
+ sComposed += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" ) );
+ _rExpression = sComposed;
+ }
+ }
+ }
+ }
+ //--------------------------------------------------------------------
+ void FilterManager::appendFilterComponent( ::rtl::OUString& /* [inout] */ _rAppendTo, const ::rtl::OUString& _rComponent ) const
+ {
+ if ( _rAppendTo.getLength() )
+ _rAppendTo += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " AND " ) );
+
+ ::rtl::OUString sComponent( _rComponent );
+ lcl_ensureBracketed( sComponent );
+ _rAppendTo += sComponent;
+ }
+
+ //--------------------------------------------------------------------
+ bool FilterManager::isThereAtMostOneComponent( ::rtl::OUString& _rOnlyComponent ) const
+ {
+ sal_Int32 nOnlyNonEmpty = -1;
+ sal_Int32 i;
+ for ( i = getFirstApplicableFilterIndex(); i < FC_COMPONENT_COUNT; ++i )
+ {
+ if ( m_aFilterComponents[ i ].getLength() )
+ {
+ if ( nOnlyNonEmpty != -1 )
+ // it's the second non-empty component
+ break;
+ else
+ nOnlyNonEmpty = i;
+ }
+ }
+ if ( nOnlyNonEmpty == -1 )
+ {
+ _rOnlyComponent = ::rtl::OUString();
+ return true;
+ }
+
+ if ( i == FC_COMPONENT_COUNT )
+ {
+ // we found only one non-empty filter component
+ _rOnlyComponent = m_aFilterComponents[ nOnlyNonEmpty ];
+ return true;
+ }
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString FilterManager::getComposedFilter( ) const
+ {
+ ::rtl::OUString sComposedFilter;
+
+ // if we have only one non-empty component, then there's no need to compose anything
+ if ( isThereAtMostOneComponent( sComposedFilter ) )
+ return sComposedFilter;
+
+ // append the single components
+ for ( sal_Int32 i = getFirstApplicableFilterIndex(); i < FC_COMPONENT_COUNT; ++i )
+ appendFilterComponent( sComposedFilter, m_aFilterComponents[ i ] );
+
+ return sComposedFilter;
+ }
+
+//........................................................................
+} // namespace dbtools
+//........................................................................
diff --git a/connectivity/source/commontools/formattedcolumnvalue.cxx b/connectivity/source/commontools/formattedcolumnvalue.cxx
new file mode 100644
index 000000000000..3707b7fdb65d
--- /dev/null
+++ b/connectivity/source/commontools/formattedcolumnvalue.cxx
@@ -0,0 +1,338 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/formattedcolumnvalue.hxx"
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbconversion.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+/** === end UNO includes === **/
+
+//#include <unotools/syslocale.hxx>
+#include <tools/diagnose_ex.h>
+#include <i18npool/mslangid.hxx>
+#include <comphelper/numbers.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <unotools/sharedunocomponent.hxx>
+
+//........................................................................
+namespace dbtools
+{
+//........................................................................
+
+ /** === 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::UNO_SET_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::XRowSet;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::util::XNumberFormatter;
+ using ::com::sun::star::util::Date;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::util::XNumberFormatsSupplier;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::lang::Locale;
+ using ::com::sun::star::util::XNumberFormatTypes;
+ using ::com::sun::star::sdb::XColumn;
+ using ::com::sun::star::sdb::XColumnUpdate;
+ using ::com::sun::star::lang::XComponent;
+ /** === end UNO using === **/
+ namespace DataType = ::com::sun::star::sdbc::DataType;
+ namespace NumberFormat = ::com::sun::star::util::NumberFormat;
+
+ //====================================================================
+ //= FormattedColumnValue_Data
+ //====================================================================
+ struct FormattedColumnValue_Data
+ {
+ Reference< XNumberFormatter > m_xFormatter;
+ Date m_aNullDate;
+ sal_Int32 m_nFormatKey;
+ sal_Int32 m_nFieldType;
+ sal_Int16 m_nKeyType;
+ bool m_bNumericField;
+
+ Reference< XColumn > m_xColumn;
+ Reference< XColumnUpdate > m_xColumnUpdate;
+
+ FormattedColumnValue_Data()
+ :m_xFormatter()
+ ,m_aNullDate( DBTypeConversion::getStandardDate() )
+ ,m_nFormatKey( 0 )
+ ,m_nFieldType( DataType::OTHER )
+ ,m_nKeyType( NumberFormat::UNDEFINED )
+ ,m_bNumericField( false )
+ ,m_xColumn()
+ ,m_xColumnUpdate()
+ {
+ }
+ };
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ //................................................................
+ void lcl_clear_nothrow( FormattedColumnValue_Data& _rData )
+ {
+ _rData.m_xFormatter.clear();
+ _rData.m_nFormatKey = 0;
+ _rData.m_nFieldType = DataType::OTHER;
+ _rData.m_nKeyType = NumberFormat::UNDEFINED;
+ _rData.m_bNumericField = false;
+
+ _rData.m_xColumn.clear();
+ _rData.m_xColumnUpdate.clear();
+ }
+
+ //................................................................
+ void lcl_initColumnDataValue_nothrow( FormattedColumnValue_Data& _rData,
+ const Reference< XNumberFormatter >& i_rNumberFormatter, const Reference< XPropertySet >& _rxColumn )
+ {
+ lcl_clear_nothrow( _rData );
+
+ OSL_PRECOND( i_rNumberFormatter.is(), "lcl_initColumnDataValue_nothrow: no number formats -> no formatted values!" );
+ if ( !i_rNumberFormatter.is() )
+ return;
+
+ try
+ {
+ Reference< XNumberFormatsSupplier > xNumberFormatsSupp( i_rNumberFormatter->getNumberFormatsSupplier(), UNO_SET_THROW );
+
+ // remember the column
+ _rData.m_xColumn.set( _rxColumn, UNO_QUERY_THROW );
+ _rData.m_xColumnUpdate.set( _rxColumn, UNO_QUERY );
+
+ // determine the field type, and whether it's a numeric field
+ OSL_VERIFY( _rxColumn->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Type" ) ) ) >>= _rData.m_nFieldType );
+
+ switch ( _rData.m_nFieldType )
+ {
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::REAL:
+ case DataType::BIGINT:
+ case DataType::DOUBLE:
+ case DataType::NUMERIC:
+ case DataType::DECIMAL:
+ _rData.m_bNumericField = true;
+ break;
+ default:
+ _rData.m_bNumericField = false;
+ break;
+ }
+
+ // get the format key of our bound field
+ Reference< XPropertySetInfo > xPSI( _rxColumn->getPropertySetInfo(), UNO_QUERY_THROW );
+ bool bHaveFieldFormat = false;
+ const ::rtl::OUString sFormatKeyProperty( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormatKey" ) ) );
+ if ( xPSI->hasPropertyByName( sFormatKeyProperty ) )
+ {
+ bHaveFieldFormat = ( _rxColumn->getPropertyValue( sFormatKeyProperty ) >>= _rData.m_nFormatKey );
+ }
+ if ( !bHaveFieldFormat )
+ {
+ // fall back to a format key as indicated by the field type
+ Locale aSystemLocale;
+ MsLangId::convertLanguageToLocale( MsLangId::getSystemLanguage(), aSystemLocale );
+ Reference< XNumberFormatTypes > xNumTypes( xNumberFormatsSupp->getNumberFormats(), UNO_QUERY_THROW );
+ _rData.m_nFormatKey = getDefaultNumberFormat( _rxColumn, xNumTypes, aSystemLocale );
+ }
+
+ // some more formatter settings
+ _rData.m_nKeyType = ::comphelper::getNumberFormatType( xNumberFormatsSupp->getNumberFormats(), _rData.m_nFormatKey );
+ Reference< XPropertySet > xFormatSettings( xNumberFormatsSupp->getNumberFormatSettings(), UNO_QUERY_THROW );
+ OSL_VERIFY( xFormatSettings->getPropertyValue( ::rtl::OUString::createFromAscii( "NullDate" ) ) >>= _rData.m_aNullDate );
+
+ // remember the formatter
+ _rData.m_xFormatter = i_rNumberFormatter;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //................................................................
+ void lcl_initColumnDataValue_nothrow( const ::comphelper::ComponentContext& i_rContext, FormattedColumnValue_Data& i_rData,
+ const Reference< XRowSet >& i_rRowSet, const Reference< XPropertySet >& i_rColumn )
+ {
+ OSL_PRECOND( i_rRowSet.is(), "lcl_initColumnDataValue_nothrow: no row set!" );
+ if ( !i_rRowSet.is() )
+ return;
+
+ Reference< XNumberFormatter > xNumberFormatter;
+ try
+ {
+ // get the number formats supplier of the connection of the form
+ Reference< XConnection > xConnection( getConnection( i_rRowSet ), UNO_QUERY_THROW );
+ Reference< XNumberFormatsSupplier > xSupplier( getNumberFormats( xConnection, sal_True, i_rContext.getLegacyServiceFactory() ), UNO_SET_THROW );
+
+ // create a number formatter for it
+ xNumberFormatter.set( i_rContext.createComponent( "com.sun.star.util.NumberFormatter" ), UNO_QUERY_THROW );
+ xNumberFormatter->attachNumberFormatsSupplier( xSupplier );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ lcl_initColumnDataValue_nothrow( i_rData, xNumberFormatter, i_rColumn );
+ }
+ }
+
+ //====================================================================
+ //= FormattedColumnValue
+ //====================================================================
+ //--------------------------------------------------------------------
+ FormattedColumnValue::FormattedColumnValue( const ::comphelper::ComponentContext& i_rContext,
+ const Reference< XRowSet >& _rxRowSet, const Reference< XPropertySet >& i_rColumn )
+ :m_pData( new FormattedColumnValue_Data )
+ {
+ lcl_initColumnDataValue_nothrow( i_rContext, *m_pData, _rxRowSet, i_rColumn );
+ }
+
+ //--------------------------------------------------------------------
+ FormattedColumnValue::FormattedColumnValue( const Reference< XNumberFormatter >& i_rNumberFormatter,
+ const Reference< XPropertySet >& _rxColumn )
+ :m_pData( new FormattedColumnValue_Data )
+ {
+ lcl_initColumnDataValue_nothrow( *m_pData, i_rNumberFormatter, _rxColumn );
+ }
+
+ //--------------------------------------------------------------------
+ void FormattedColumnValue::clear()
+ {
+ lcl_clear_nothrow( *m_pData );
+ }
+
+ //--------------------------------------------------------------------
+ FormattedColumnValue::~FormattedColumnValue()
+ {
+ clear();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 FormattedColumnValue::getFormatKey() const
+ {
+ return m_pData->m_nFormatKey;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 FormattedColumnValue::getFieldType() const
+ {
+ return m_pData->m_nFieldType;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int16 FormattedColumnValue::getKeyType() const
+ {
+ return m_pData->m_nKeyType;
+ }
+
+ //--------------------------------------------------------------------
+ bool FormattedColumnValue::isNumericField() const
+ {
+ return m_pData->m_bNumericField;
+ }
+
+ //--------------------------------------------------------------------
+ const Reference< XColumn >& FormattedColumnValue::getColumn() const
+ {
+ return m_pData->m_xColumn;
+ }
+
+ //--------------------------------------------------------------------
+ const Reference< XColumnUpdate >& FormattedColumnValue::getColumnUpdate() const
+ {
+ return m_pData->m_xColumnUpdate;
+ }
+
+ //--------------------------------------------------------------------
+ bool FormattedColumnValue::setFormattedValue( const ::rtl::OUString& _rFormattedStringValue ) const
+ {
+ OSL_PRECOND( m_pData->m_xColumnUpdate.is(), "FormattedColumnValue::setFormattedValue: no column!" );
+ if ( !m_pData->m_xColumnUpdate.is() )
+ return false;
+
+ try
+ {
+ if ( m_pData->m_bNumericField )
+ {
+ ::dbtools::DBTypeConversion::setValue( m_pData->m_xColumnUpdate, m_pData->m_xFormatter, m_pData->m_aNullDate,
+ _rFormattedStringValue, m_pData->m_nFormatKey, ::sal::static_int_cast< sal_Int16 >( m_pData->m_nFieldType ),
+ m_pData->m_nKeyType );
+ }
+ else
+ {
+ m_pData->m_xColumnUpdate->updateString( _rFormattedStringValue );
+ }
+ }
+ catch( const Exception& )
+ {
+ return false;
+ }
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString FormattedColumnValue::getFormattedValue() const
+ {
+ OSL_PRECOND( m_pData->m_xColumn.is(), "FormattedColumnValue::setFormattedValue: no column!" );
+
+ ::rtl::OUString sStringValue;
+ if ( m_pData->m_xColumn.is() )
+ {
+ sStringValue = DBTypeConversion::getValue(
+ m_pData->m_xColumn, m_pData->m_xFormatter, m_pData->m_aNullDate, m_pData->m_nFormatKey, m_pData->m_nKeyType
+ );
+ }
+ return sStringValue;
+ }
+
+//........................................................................
+} // namespace dbtools
+//........................................................................
diff --git a/connectivity/source/commontools/makefile.mk b/connectivity/source/commontools/makefile.mk
new file mode 100644
index 000000000000..cab216092241
--- /dev/null
+++ b/connectivity/source/commontools/makefile.mk
@@ -0,0 +1,103 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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=..$/..
+
+PRJNAME=connectivity
+TARGET=commontools
+
+# --- Settings -----------------------------------------------------
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/dbtools.pmk
+
+# Disable optimization for SunCC SPARC and MACOSX (funny loops
+# when parsing e.g. "x+width/2"),
+# also http://gcc.gnu.org/PR22392
+.IF ("$(OS)$(CPU)"=="SOLARISS" && "$(COM)"!="GCC") || "$(OS)"=="MACOSX" || ("$(OS)"=="LINUX" && "$(CPU)"=="P")
+NOOPTFILES= $(SLO)$/RowFunctionParser.obj
+.ENDIF
+
+ENVCFLAGS += -DBOOST_SPIRIT_USE_OLD_NAMESPACE
+
+# --- Files --------------------------------------------------------
+EXCEPTIONSFILES=\
+ $(SLO)$/predicateinput.obj \
+ $(SLO)$/ConnectionWrapper.obj \
+ $(SLO)$/TConnection.obj \
+ $(SLO)$/conncleanup.obj \
+ $(SLO)$/dbtools.obj \
+ $(SLO)$/dbtools2.obj \
+ $(SLO)$/dbexception.obj \
+ $(SLO)$/CommonTools.obj \
+ $(SLO)$/TColumnsHelper.obj \
+ $(SLO)$/TTableHelper.obj \
+ $(SLO)$/TKeys.obj \
+ $(SLO)$/TKey.obj \
+ $(SLO)$/TKeyColumns.obj \
+ $(SLO)$/TIndexes.obj \
+ $(SLO)$/TIndex.obj \
+ $(SLO)$/TIndexColumns.obj \
+ $(SLO)$/DateConversion.obj \
+ $(SLO)$/FDatabaseMetaDataResultSetMetaData.obj \
+ $(SLO)$/FDatabaseMetaDataResultSet.obj \
+ $(SLO)$/TDatabaseMetaDataBase.obj \
+ $(SLO)$/TPrivilegesResultSet.obj \
+ $(SLO)$/TSkipDeletedSet.obj \
+ $(SLO)$/dbmetadata.obj \
+ $(SLO)$/TSortIndex.obj \
+ $(SLO)$/dbcharset.obj \
+ $(SLO)$/propertyids.obj \
+ $(SLO)$/FValue.obj \
+ $(SLO)$/paramwrapper.obj \
+ $(SLO)$/statementcomposer.obj \
+ $(SLO)$/RowFunctionParser.obj \
+ $(SLO)$/sqlerror.obj \
+ $(SLO)$/filtermanager.obj \
+ $(SLO)$/parameters.obj \
+ $(SLO)$/ParamterSubstitution.obj \
+ $(SLO)$/DriversConfig.obj \
+ $(SLO)$/formattedcolumnvalue.obj \
+ $(SLO)$/BlobHelper.obj \
+ $(SLO)$/warningscontainer.obj
+
+SLOFILES=\
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/AutoRetrievingBase.obj \
+ $(SLO)$/dbconversion.obj
+
+
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/connectivity/source/commontools/parameters.cxx b/connectivity/source/commontools/parameters.cxx
new file mode 100644
index 000000000000..1eb75415917e
--- /dev/null
+++ b/connectivity/source/commontools/parameters.cxx
@@ -0,0 +1,1120 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/parameters.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/form/DatabaseParameterEvent.hpp>
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/sdb/XParametersSupplier.hpp>
+#include <com/sun/star/sdb/XInteractionSupplyParameters.hpp>
+#include <com/sun/star/sdb/ParametersRequest.hpp>
+/** === end UNO includes === **/
+
+#include <connectivity/dbtools.hxx>
+#include "connectivity/filtermanager.hxx"
+#include "TConnection.hxx"
+
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <comphelper/uno3.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/broadcasthelper.hxx>
+#include "connectivity/ParameterCont.hxx"
+#include <rtl/ustrbuf.hxx>
+
+//........................................................................
+namespace dbtools
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::task;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::container;
+
+ using namespace ::comphelper;
+ using namespace ::connectivity;
+
+ //====================================================================
+ //= ParameterManager
+ //====================================================================
+ //--------------------------------------------------------------------
+ ParameterManager::ParameterManager( ::osl::Mutex& _rMutex, const Reference< XMultiServiceFactory >& _rxORB )
+ :m_rMutex ( _rMutex )
+ ,m_aParameterListeners( _rMutex )
+ ,m_xORB ( _rxORB )
+ ,m_pOuterParameters ( NULL )
+ ,m_nInnerCount ( 0 )
+ ,m_bUpToDate ( false )
+ {
+ OSL_ENSURE( m_xORB.is(), "ParameterManager::ParameterManager: no service factory!" );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::initialize( const Reference< XPropertySet >& _rxComponent, const Reference< XAggregation >& _rxComponentAggregate )
+ {
+ OSL_ENSURE( !m_xComponent.get().is(), "ParameterManager::initialize: already initialized!" );
+
+ m_xComponent = _rxComponent;
+ m_xAggregatedRowSet = _rxComponentAggregate;
+ if ( m_xAggregatedRowSet.is() )
+ m_xAggregatedRowSet->queryAggregation( ::getCppuType( &m_xInnerParamUpdate ) ) >>= m_xInnerParamUpdate;
+ OSL_ENSURE( m_xComponent.get().is() && m_xInnerParamUpdate.is(), "ParameterManager::initialize: invalid arguments!" );
+ if ( !m_xComponent.get().is() || !m_xInnerParamUpdate.is() )
+ return;
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::dispose( )
+ {
+ clearAllParameterInformation();
+
+ m_xComposer.clear();
+ m_xParentComposer.clear();
+ //m_xComponent.clear();
+ m_xInnerParamUpdate.clear();
+ m_xAggregatedRowSet.clear();
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::clearAllParameterInformation()
+ {
+ m_xInnerParamColumns.clear();
+ if ( m_pOuterParameters.is() )
+ m_pOuterParameters->dispose();
+ m_pOuterParameters = NULL;
+ m_nInnerCount = 0;
+ ParameterInformation aEmptyInfo;
+ m_aParameterInformation.swap( aEmptyInfo );
+ m_aMasterFields.realloc( 0 );
+ m_aDetailFields.realloc( 0 );
+ m_sIdentifierQuoteString = ::rtl::OUString();
+ ::std::vector< bool > aEmptyArray;
+ m_aParametersVisited.swap( aEmptyArray );
+ m_bUpToDate = false;
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::disposing( const EventObject& /*_rDisposingEvent*/ )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setAllParametersNull() SAL_THROW( ( SQLException, RuntimeException ) )
+ {
+ OSL_PRECOND( isAlive(), "ParameterManager::setAllParametersNull: not initialized, or already disposed!" );
+ if ( !isAlive() )
+ return;
+
+ for ( sal_Int32 i = 1; i <= m_nInnerCount; ++i )
+ m_xInnerParamUpdate->setNull( i, DataType::VARCHAR );
+ }
+
+ //--------------------------------------------------------------------
+ bool ParameterManager::initializeComposerByComponent( const Reference< XPropertySet >& _rxComponent )
+ {
+ OSL_PRECOND( _rxComponent.is(), "ParameterManager::initializeComposerByComponent: invalid !" );
+
+ m_xComposer.clear();
+ m_xInnerParamColumns.clear();
+ m_nInnerCount = 0;
+
+ // create and fill a composer
+ try
+ {
+ // get a query composer for the 's settings
+ m_xComposer.reset( getCurrentSettingsComposer( _rxComponent, m_xORB ), SharedQueryComposer::TakeOwnership );
+
+ // see if the composer found parameters
+ Reference< XParametersSupplier > xParamSupp( m_xComposer, UNO_QUERY );
+ if ( xParamSupp.is() )
+ m_xInnerParamColumns = xParamSupp->getParameters();
+
+ if ( m_xInnerParamColumns.is() )
+ m_nInnerCount = m_xInnerParamColumns->getCount();
+ }
+ catch( const SQLException& )
+ {
+ }
+
+ return m_xInnerParamColumns.is();
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::collectInnerParameters( bool _bSecondRun )
+ {
+ OSL_PRECOND( m_xInnerParamColumns.is(), "ParameterManager::collectInnerParameters: missing some internal data!" );
+ if ( !m_xInnerParamColumns.is() )
+ return;
+
+ // strip previous index informations
+ if ( _bSecondRun )
+ {
+ for ( ParameterInformation::iterator aParamInfo = m_aParameterInformation.begin();
+ aParamInfo != m_aParameterInformation.end();
+ ++aParamInfo
+ )
+ {
+ aParamInfo->second.aInnerIndexes.clear();
+ }
+ }
+
+ // we need to map the parameter names (which is all we get from the 's
+ // MasterFields property) to indicies, which are needed by the XParameters
+ // interface of the row set)
+ Reference<XPropertySet> xParam;
+ for ( sal_Int32 i = 0; i < m_nInnerCount; ++i )
+ {
+ try
+ {
+ xParam.clear();
+ m_xInnerParamColumns->getByIndex( i ) >>= xParam;
+
+ ::rtl::OUString sName;
+ xParam->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME) ) >>= sName;
+
+ // only append additonal paramters when they are not already in the list
+ ParameterInformation::iterator aExistentPos = m_aParameterInformation.find( sName );
+ OSL_ENSURE( !_bSecondRun || ( aExistentPos != m_aParameterInformation.end() ),
+ "ParameterManager::collectInnerParameters: the parameter information should already exist in the second run!" );
+
+ if ( aExistentPos == m_aParameterInformation.end() )
+ {
+ aExistentPos = m_aParameterInformation.insert( ParameterInformation::value_type(
+ sName, xParam ) ).first;
+ }
+ else
+ aExistentPos->second.xComposerColumn = xParam;
+
+ aExistentPos->second.aInnerIndexes.push_back( i );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "ParameterManager::collectInnerParameters: caught an exception!" );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString ParameterManager::createFilterConditionFromColumnLink(
+ const ::rtl::OUString& _rMasterColumn, const ::rtl::OUString& _rDetailLink, ::rtl::OUString& _rNewParamName )
+ {
+ ::rtl::OUString sFilter;
+
+ // format is:
+ // <detail_column> = :<new_param_name>
+ sFilter = quoteName( m_sIdentifierQuoteString, _rDetailLink );
+ sFilter += ::rtl::OUString::createFromAscii( " = :" );
+
+ // generate a parameter name which is not already used
+ _rNewParamName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "link_from_" ) );
+ _rNewParamName += convertName2SQLName( _rMasterColumn, m_sSpecialCharacters );
+ while ( m_aParameterInformation.find( _rNewParamName ) != m_aParameterInformation.end() )
+ {
+ _rNewParamName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_" ) );
+ }
+
+ return sFilter += _rNewParamName;
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::classifyLinks( const Reference< XNameAccess >& _rxParentColumns,
+ const Reference< XNameAccess >& _rxColumns, ::std::vector< ::rtl::OUString >& _out_rAdditionalFilterComponents ) SAL_THROW(( Exception ))
+ {
+ OSL_PRECOND( m_aMasterFields.getLength() == m_aDetailFields.getLength(),
+ "ParameterManager::classifyLinks: master and detail fields should have the same length!" );
+ OSL_ENSURE( _rxColumns.is(), "ParameterManager::classifyLinks: invalid columns!" );
+
+ if ( !_rxColumns.is() )
+ return;
+
+ // we may need to strip any links which are invalid, so here go the containers
+ // for temporarirly holding the new pairs
+ ::std::vector< ::rtl::OUString > aStrippedMasterFields;
+ ::std::vector< ::rtl::OUString > aStrippedDetailFields;
+
+ bool bNeedExchangeLinks = false;
+
+ // classify the links
+ const ::rtl::OUString* pMasterFields = m_aMasterFields.getConstArray();
+ const ::rtl::OUString* pDetailFields = m_aDetailFields.getConstArray();
+ const ::rtl::OUString* pDetailFieldsEnd = pDetailFields + m_aDetailFields.getLength();
+ for ( ; pDetailFields < pDetailFieldsEnd; ++pDetailFields, ++pMasterFields )
+ {
+ if ( !pMasterFields->getLength() || !pDetailFields->getLength() )
+ continue;
+
+ // if not even the master part of the relationship exists in the parent , the
+ // link is invalid as a whole
+ // #i63674# / 2006-03-28 / frank.schoenheit@sun.com
+ if ( !_rxParentColumns->hasByName( *pMasterFields ) )
+ {
+ bNeedExchangeLinks = true;
+ continue;
+ }
+
+ bool bValidLink = true;
+
+ // is there an inner parameter with this name? That is, a parameter which is already part of
+ // the very original statement (not the one we create ourselve, with the additional parameters)
+ ParameterInformation::iterator aPos = m_aParameterInformation.find( *pDetailFields );
+ if ( aPos != m_aParameterInformation.end() )
+ { // there is an inner parameter with this name
+ aPos->second.eType = eLinkedByParamName;
+ aStrippedDetailFields.push_back( *pDetailFields );
+ }
+ else
+ {
+ // does the detail name denote a column?
+ if ( _rxColumns->hasByName( *pDetailFields ) )
+ {
+ ::rtl::OUString sNewParamName;
+ const ::rtl::OUString sFilterCondition = createFilterConditionFromColumnLink( *pMasterFields, *pDetailFields, sNewParamName );
+ OSL_PRECOND( sNewParamName.getLength(), "ParameterManager::classifyLinks: createFilterConditionFromColumnLink returned nonsense!" );
+
+ // remember meta information about this new parameter
+ ::std::pair< ParameterInformation::iterator, bool > aInsertionPos =
+ m_aParameterInformation.insert(
+ ParameterInformation::value_type( sNewParamName, ParameterMetaData( NULL ) )
+ );
+ OSL_ENSURE( aInsertionPos.second, "ParameterManager::classifyLinks: there already was a parameter with this name!" );
+ aInsertionPos.first->second.eType = eLinkedByColumnName;
+
+ // remember the filter component
+ _out_rAdditionalFilterComponents.push_back( sFilterCondition );
+
+ // remember the new "detail field" for this link
+ aStrippedDetailFields.push_back( sNewParamName );
+ bNeedExchangeLinks = true;
+ }
+ else
+ {
+ // the detail field neither denotes a column name, nor a parameter name
+ bValidLink = false;
+ bNeedExchangeLinks = true;
+ }
+ }
+
+ if ( bValidLink )
+ aStrippedMasterFields.push_back( *pMasterFields );
+ }
+ OSL_POSTCOND( aStrippedMasterFields.size() == aStrippedDetailFields.size(),
+ "ParameterManager::classifyLinks: inconsistency in new link pairs!" );
+
+ if ( bNeedExchangeLinks )
+ {
+ ::rtl::OUString *pFields = aStrippedMasterFields.empty() ? 0 : &aStrippedMasterFields[0];
+ m_aMasterFields = Sequence< ::rtl::OUString >( pFields, aStrippedMasterFields.size() );
+ pFields = aStrippedDetailFields.empty() ? 0 : &aStrippedDetailFields[0];
+ m_aDetailFields = Sequence< ::rtl::OUString >( pFields, aStrippedDetailFields.size() );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::analyzeFieldLinks( FilterManager& _rFilterManager, bool& /* [out] */ _rColumnsInLinkDetails )
+ {
+ OSL_PRECOND( isAlive(), "ParameterManager::analyzeFieldLinks: not initialized, or already disposed!" );
+ if ( !isAlive() )
+ return;
+
+ _rColumnsInLinkDetails = false;
+ try
+ {
+ // the links as determined by the properties
+ Reference< XPropertySet > xProp = m_xComponent;
+ OSL_ENSURE(xProp.is(),"Some already released my component!");
+ if ( xProp.is() )
+ {
+ xProp->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MASTERFIELDS) ) >>= m_aMasterFields;
+ xProp->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DETAILFIELDS) ) >>= m_aDetailFields;
+ }
+
+ {
+ // normalize to equal length
+ sal_Int32 nMasterLength = m_aMasterFields.getLength();
+ sal_Int32 nDetailLength = m_aDetailFields.getLength();
+
+ if ( nMasterLength > nDetailLength )
+ m_aMasterFields.realloc( nDetailLength );
+ else if ( nDetailLength > nMasterLength )
+ m_aDetailFields.realloc( nMasterLength );
+ }
+
+ Reference< XNameAccess > xColumns;
+ if ( !getColumns( xColumns, true ) )
+ // already asserted in getColumns
+ return;
+
+ Reference< XNameAccess > xParentColumns;
+ if ( !getParentColumns( xParentColumns, true ) )
+ return;
+
+ // classify the links - depending on what the detail fields in each link pair denotes
+ ::std::vector< ::rtl::OUString > aAdditionalFilterComponents;
+ classifyLinks( xParentColumns, xColumns, aAdditionalFilterComponents );
+
+ // did we find links where the detail field refers to a detail column (instead of a parameter name)?
+ if ( !aAdditionalFilterComponents.empty() )
+ {
+ const static ::rtl::OUString s_sAnd( RTL_CONSTASCII_USTRINGPARAM( " AND " ) );
+ // build a conjunction of all the filter components
+ ::rtl::OUStringBuffer sAdditionalFilter;
+ for ( ::std::vector< ::rtl::OUString >::const_iterator aComponent = aAdditionalFilterComponents.begin();
+ aComponent != aAdditionalFilterComponents.end();
+ ++aComponent
+ )
+ {
+ if ( sAdditionalFilter.getLength() )
+ sAdditionalFilter.append(s_sAnd);
+
+ sAdditionalFilter.appendAscii("( ",((sal_Int32)(sizeof("( ")-1)));
+ sAdditionalFilter.append(*aComponent);
+ sAdditionalFilter.appendAscii(" )",((sal_Int32)(sizeof(" )")-1)));
+ }
+
+ // now set this filter at the 's filter manager
+ _rFilterManager.setFilterComponent( FilterManager::fcLinkFilter, sAdditionalFilter.makeStringAndClear() );
+
+ _rColumnsInLinkDetails = true;
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "ParameterManager::analyzeFieldLinks: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::createOuterParameters()
+ {
+ OSL_PRECOND( !m_pOuterParameters.is(), "ParameterManager::createOuterParameters: outer parameters not initialized!" );
+ OSL_PRECOND( m_xInnerParamUpdate.is(), "ParameterManager::createOuterParameters: no write access to the inner parameters!" );
+ if ( !m_xInnerParamUpdate.is() )
+ return;
+
+ m_pOuterParameters = new param::ParameterWrapperContainer;
+
+#if OSL_DEBUG_LEVEL > 0
+ sal_Int32 nSmallestIndexLinkedByColumnName = -1;
+ sal_Int32 nLargestIndexNotLinkedByColumnName = -1;
+#endif
+ ::rtl::OUString sName;
+ for ( ParameterInformation::iterator aParam = m_aParameterInformation.begin();
+ aParam != m_aParameterInformation.end();
+ ++aParam
+ )
+ {
+#if OSL_DEBUG_LEVEL > 0
+ if ( aParam->second.aInnerIndexes.size() )
+ if ( aParam->second.eType == eLinkedByColumnName )
+ {
+ if ( nSmallestIndexLinkedByColumnName == -1 )
+ nSmallestIndexLinkedByColumnName = aParam->second.aInnerIndexes[ 0 ];
+ }
+ else
+ {
+ nLargestIndexNotLinkedByColumnName = aParam->second.aInnerIndexes[ aParam->second.aInnerIndexes.size() - 1 ];
+ }
+#endif
+ if ( aParam->second.eType != eFilledExternally )
+ continue;
+
+ // check which of the parameters have already been visited (e.g. filled via XParameters)
+ size_t nAlreadyVisited = 0;
+ for ( ::std::vector< sal_Int32 >::iterator aIndex = aParam->second.aInnerIndexes.begin();
+ aIndex != aParam->second.aInnerIndexes.end();
+ ++aIndex
+ )
+ {
+ if ( ( m_aParametersVisited.size() > (size_t)*aIndex ) && m_aParametersVisited[ *aIndex ] )
+ { // exclude this index
+ *aIndex = -1;
+ ++nAlreadyVisited;
+ }
+ }
+ if ( nAlreadyVisited == aParam->second.aInnerIndexes.size() )
+ continue;
+
+ // need a wrapper for this .... the "inner parameters" as supplied by a result set don't have a "Value"
+ // property, but the parameter listeners expect such a property. So we need an object "aggregating"
+ // xParam and supplying an additional property ("Value")
+ // (it's no real aggregation of course ...)
+ m_pOuterParameters->push_back( new param::ParameterWrapper( aParam->second.xComposerColumn, m_xInnerParamUpdate, aParam->second.aInnerIndexes ) );
+ }
+
+#if OSL_DEBUG_LEVEL > 0
+ OSL_ENSURE( ( nSmallestIndexLinkedByColumnName == -1 ) || ( nLargestIndexNotLinkedByColumnName == -1 ) ||
+ ( nSmallestIndexLinkedByColumnName > nLargestIndexNotLinkedByColumnName ),
+ "ParameterManager::createOuterParameters: inconsistency!" );
+
+ // for the master-detail links, where the detail field denoted a column name, we created an addtional ("artificial")
+ // filter, and *appended* it to all other (potentially) existing filters of the row set. This means that the indexes
+ // for the parameters resulting from the artifical filter should be larger than any other parameter index, and this
+ // is what the assertion checks.
+ // If the assertion fails, then we would need another handling for the "parameters visited" flags, since they're based
+ // on parameter indexes *without* the artificial filter (because this filter is not visible from the outside).
+#endif
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::updateParameterInfo( FilterManager& _rFilterManager )
+ {
+ OSL_PRECOND( isAlive(), "ParameterManager::updateParameterInfo: not initialized, or already disposed!" );
+ if ( !isAlive() )
+ return;
+
+ clearAllParameterInformation();
+ cacheConnectionInfo();
+
+ // check whether the is based on a statement/query which requires parameters
+ Reference< XPropertySet > xProp = m_xComponent;
+ OSL_ENSURE(xProp.is(),"Some already released my component!");
+ if ( xProp.is() )
+ {
+ if ( !initializeComposerByComponent( xProp ) )
+ { // okay, nothing to do
+ m_bUpToDate = true;
+ return;
+ } // if ( !initializeComposerByComponent( m_xComponent ) )
+ }
+ OSL_POSTCOND( m_xInnerParamColumns.is(), "ParameterManager::updateParameterInfo: initializeComposerByComponent did nonsense (1)!" );
+
+ // collect all parameters which are defined by the "inner parameters"
+ collectInnerParameters( false );
+
+ // analyze the master-detail relationships
+ bool bColumnsInLinkDetails = false;
+ analyzeFieldLinks( _rFilterManager, bColumnsInLinkDetails );
+
+ if ( bColumnsInLinkDetails )
+ {
+ // okay, in this case, analyzeFieldLinks modified the "real" filter at the RowSet, to contain
+ // an additional restriction (which we created ourself)
+ // So we need to update all information about our inner parameter columns
+ Reference< XPropertySet > xDirectRowSetProps;
+ m_xAggregatedRowSet->queryAggregation( ::getCppuType( &xDirectRowSetProps ) ) >>= xDirectRowSetProps;
+ OSL_VERIFY( initializeComposerByComponent( xDirectRowSetProps ) );
+ collectInnerParameters( true );
+ }
+
+ if ( !m_nInnerCount )
+ { // no parameters at all
+ m_bUpToDate = true;
+ return;
+ }
+
+ // for what now remains as outer parameters, create the wrappers for the single
+ // parameter columns
+ createOuterParameters();
+
+ m_bUpToDate = true;
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::fillLinkedParameters( const Reference< XNameAccess >& _rxParentColumns )
+ {
+ OSL_PRECOND( isAlive(), "ParameterManager::fillLinkedParameters: not initialized, or already disposed!" );
+ if ( !isAlive() )
+ return;
+ OSL_PRECOND( m_xInnerParamColumns.is(), "ParameterManager::fillLinkedParameters: no inner parameters found!" );
+ OSL_ENSURE ( _rxParentColumns.is(), "ParameterManager::fillLinkedParameters: invalid parent columns!" );
+
+ try
+ {
+ // the master and detail field( name)s of the
+ const ::rtl::OUString* pMasterFields = m_aMasterFields.getConstArray();
+ const ::rtl::OUString* pDetailFields = m_aDetailFields.getConstArray();
+
+ sal_Int32 nMasterLen = m_aMasterFields.getLength();
+ Any aParamType, aScale, aValue;
+
+ // loop through all master fields. For each of them, get the respective column from the
+ // parent , and forward it's current value as paramter value to the (inner) row set
+ for ( sal_Int32 i = 0; i < nMasterLen; ++i, ++pMasterFields, ++pDetailFields )
+ {
+ // does the name denote a valid column in the parent?
+ if ( !_rxParentColumns->hasByName( *pMasterFields ) )
+ {
+ OSL_ENSURE( sal_False, "ParameterManager::fillLinkedParameters: invalid master names should have been stripped long before!" );
+ continue;
+ }
+
+ // do we, for this name, know where to place the values?
+ ParameterInformation::const_iterator aParamInfo = m_aParameterInformation.find( *pDetailFields );
+ if ( ( aParamInfo == m_aParameterInformation.end() )
+ || ( aParamInfo->second.aInnerIndexes.empty() )
+ )
+ {
+ OSL_ENSURE( sal_False, "ParameterManager::fillLinkedParameters: nothing known about this detail field!" );
+ continue;
+ }
+
+ // the concrete master field
+ Reference< XPropertySet > xMasterField(_rxParentColumns->getByName( *pMasterFields ),UNO_QUERY);
+
+ // the positions where we have to fill in values for the current parameter name
+ for ( ::std::vector< sal_Int32 >::const_iterator aPosition = aParamInfo->second.aInnerIndexes.begin();
+ aPosition != aParamInfo->second.aInnerIndexes.end();
+ ++aPosition
+ )
+ {
+ // the concrete detail field
+ Reference< XPropertySet > xDetailField(m_xInnerParamColumns->getByIndex( *aPosition ),UNO_QUERY);
+ OSL_ENSURE( xDetailField.is(), "ParameterManager::fillLinkedParameters: invalid detail field!" );
+ if ( !xDetailField.is() )
+ continue;
+
+ // type and scale of the parameter field
+ sal_Int32 nParamType = DataType::VARCHAR;
+ OSL_VERIFY( xDetailField->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE) ) >>= nParamType );
+
+ sal_Int32 nScale = 0;
+ if ( xDetailField->getPropertySetInfo()->hasPropertyByName( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE) ) )
+ OSL_VERIFY( xDetailField->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE) ) >>= nScale );
+
+ // transfer the param value
+ try
+ {
+ m_xInnerParamUpdate->setObjectWithInfo(
+ *aPosition + 1, // parameters are based at 1
+ xMasterField->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_VALUE) ),
+ nParamType,
+ nScale
+ );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False,
+ ::rtl::OString( "ParameterManager::fillLinkedParameters: master-detail parameter number " )
+ += ::rtl::OString::valueOf( sal_Int32( *aPosition + 1 ) )
+ += ::rtl::OString( " could not be filled!" ) );
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool ParameterManager::completeParameters( const Reference< XInteractionHandler >& _rxCompletionHandler, const Reference< XConnection > _rxConnection )
+ {
+ OSL_PRECOND( isAlive(), "ParameterManager::completeParameters: not initialized, or already disposed!" );
+ OSL_ENSURE ( _rxCompletionHandler.is(), "ParameterManager::completeParameters: invalid interaction handler!" );
+
+ // two continuations (Ok and Cancel)
+ OInteractionAbort* pAbort = new OInteractionAbort;
+ OParameterContinuation* pParams = new OParameterContinuation;
+
+ // the request
+ ParametersRequest aRequest;
+ aRequest.Parameters = m_pOuterParameters.get();
+ aRequest.Connection = _rxConnection;
+ OInteractionRequest* pRequest = new OInteractionRequest( makeAny( aRequest ) );
+ Reference< XInteractionRequest > xRequest( pRequest );
+
+ // some knittings
+ pRequest->addContinuation( pAbort );
+ pRequest->addContinuation( pParams );
+
+ // execute the request
+ try
+ {
+ _rxCompletionHandler->handle( xRequest );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "ParameterManager::completeParameters: caught an exception while calling the handler!" );
+ }
+
+ if ( !pParams->wasSelected() )
+ // canceled by the user (i.e. (s)he canceled the dialog)
+ return false;
+
+ try
+ {
+ // transfer the values from the continuation object to the parameter columns
+ Sequence< PropertyValue > aFinalValues = pParams->getValues();
+ const PropertyValue* pFinalValues = aFinalValues.getConstArray();
+ for ( sal_Int32 i = 0; i < aFinalValues.getLength(); ++i, ++pFinalValues )
+ {
+ Reference< XPropertySet > xParamColumn(aRequest.Parameters->getByIndex( i ),UNO_QUERY);
+ if ( xParamColumn.is() )
+ {
+ #ifdef DBG_UTIL
+ ::rtl::OUString sName;
+ xParamColumn->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME) ) >>= sName;
+ OSL_ENSURE( sName == pFinalValues->Name, "ParameterManager::completeParameters: inconsistent parameter names!" );
+ #endif
+ xParamColumn->setPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_VALUE), pFinalValues->Value );
+ // the property sets are wrapper classes, translating the Value property into a call to
+ // the appropriate XParameters interface
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "ParameterManager::completeParameters: caught an exception while propagating the values!" );
+ }
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool ParameterManager::consultParameterListeners( ::osl::ResettableMutexGuard& _rClearForNotifies )
+ {
+ bool bCanceled = false;
+
+ sal_Int32 nParamsLeft = m_pOuterParameters->getParameters().size();
+ // TODO: shouldn't we subtract all the parameters which were already visited?
+ if ( nParamsLeft )
+ {
+ ::cppu::OInterfaceIteratorHelper aIter( m_aParameterListeners );
+ Reference< XPropertySet > xProp = m_xComponent;
+ OSL_ENSURE(xProp.is(),"Some already released my component!");
+ DatabaseParameterEvent aEvent( xProp.get(), m_pOuterParameters.get() );
+
+ _rClearForNotifies.clear();
+ while ( aIter.hasMoreElements() && !bCanceled )
+ bCanceled = !static_cast< XDatabaseParameterListener* >( aIter.next() )->approveParameter( aEvent );
+ _rClearForNotifies.reset();
+ }
+
+ return !bCanceled;
+ }
+
+ //--------------------------------------------------------------------
+ bool ParameterManager::fillParameterValues( const Reference< XInteractionHandler >& _rxCompletionHandler, ::osl::ResettableMutexGuard& _rClearForNotifies )
+ {
+ OSL_PRECOND( isAlive(), "ParameterManager::fillParameterValues: not initialized, or already disposed!" );
+ if ( !isAlive() )
+ return true;
+
+ if ( m_nInnerCount == 0 )
+ // no parameters at all
+ return true;
+
+ // fill the parameters from the master-detail relationship
+ Reference< XNameAccess > xParentColumns;
+ if ( getParentColumns( xParentColumns, false ) && xParentColumns->hasElements() && m_aMasterFields.getLength() )
+ fillLinkedParameters( xParentColumns );
+
+ // let the user (via the interaction handler) fill all remaining parameters
+ Reference< XConnection > xConnection;
+ getConnection( xConnection );
+
+ if ( _rxCompletionHandler.is() )
+ return completeParameters( _rxCompletionHandler, xConnection );
+
+ return consultParameterListeners( _rClearForNotifies );
+ }
+
+ //--------------------------------------------------------------------
+ bool ParameterManager::getConnection( Reference< XConnection >& /* [out] */ _rxConnection )
+ {
+ OSL_PRECOND( isAlive(), "ParameterManager::getConnection: not initialized, or already disposed!" );
+ if ( !isAlive() )
+ return false;
+
+ _rxConnection.clear();
+ try
+ {
+ Reference< XPropertySet > xProp = m_xComponent;
+ OSL_ENSURE(xProp.is(),"Some already released my component!");
+ if ( xProp.is() )
+ xProp->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ACTIVE_CONNECTION) ) >>= _rxConnection;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "ParameterManager::getConnection: could not retrieve the connection of the !" );
+ }
+ return _rxConnection.is();
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::cacheConnectionInfo() SAL_THROW(( ))
+ {
+ try
+ {
+ Reference< XConnection > xConnection;
+ getConnection( xConnection );
+ Reference< XDatabaseMetaData > xMeta;
+ if ( xConnection.is() )
+ xMeta = xConnection->getMetaData();
+ if ( xMeta.is() )
+ {
+ m_sIdentifierQuoteString = xMeta->getIdentifierQuoteString();
+ m_sSpecialCharacters = xMeta->getExtraNameCharacters();
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "ParameterManager::cacheConnectionInfo: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool ParameterManager::getColumns( Reference< XNameAccess >& /* [out] */ _rxColumns, bool _bFromComposer ) SAL_THROW(( Exception ))
+ {
+ _rxColumns.clear();
+
+ Reference< XColumnsSupplier > xColumnSupp;
+ if ( _bFromComposer )
+ xColumnSupp = xColumnSupp.query( m_xComposer );
+ else
+ xColumnSupp.set( m_xComponent.get(),UNO_QUERY);
+ if ( xColumnSupp.is() )
+ _rxColumns = xColumnSupp->getColumns();
+ OSL_ENSURE( _rxColumns.is(), "ParameterManager::getColumns: could not retrieve the columns for the detail !" );
+
+ return _rxColumns.is();
+ }
+
+ //--------------------------------------------------------------------
+ bool ParameterManager::getParentColumns( Reference< XNameAccess >& /* [out] */ _out_rxParentColumns, bool _bFromComposer )
+ {
+ OSL_PRECOND( isAlive(), "ParameterManager::getParentColumns: not initialized, or already disposed!" );
+
+ _out_rxParentColumns.clear();
+ try
+ {
+ // get the parent of the component we're working for
+ Reference< XChild > xAsChild( m_xComponent.get(), UNO_QUERY_THROW );
+ Reference< XPropertySet > xParent( xAsChild->getParent(), UNO_QUERY );
+ if ( !xParent.is() )
+ return false;
+
+ // the columns supplier: either from a composer, or directly from the
+ Reference< XColumnsSupplier > xParentColSupp;
+ if ( _bFromComposer )
+ {
+ // re-create the parent composer all the time. Else, we'd have to bother with
+ // being a listener at its properties, its loaded state, and event the parent-relationship.
+ m_xParentComposer.reset(
+ getCurrentSettingsComposer( xParent, m_xORB ),
+ SharedQueryComposer::TakeOwnership
+ );
+ xParentColSupp = xParentColSupp.query( m_xParentComposer );
+ }
+ else
+ xParentColSupp = xParentColSupp.query( xParent );
+
+ // get the columns of the parent
+ if ( xParentColSupp.is() )
+ _out_rxParentColumns = xParentColSupp->getColumns();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "ParameterManager::getParentColumns: caught an exception!" );
+ }
+ return _out_rxParentColumns.is();
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::addParameterListener( const Reference< XDatabaseParameterListener >& _rxListener )
+ {
+ if ( _rxListener.is() )
+ m_aParameterListeners.addInterface( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::removeParameterListener( const Reference< XDatabaseParameterListener >& _rxListener )
+ {
+ m_aParameterListeners.removeInterface( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::resetParameterValues( ) SAL_THROW(())
+ {
+ OSL_PRECOND( isAlive(), "ParameterManager::resetParameterValues: not initialized, or already disposed!" );
+ if ( !isAlive() )
+ return;
+
+ if ( !m_nInnerCount )
+ // no parameters at all
+ return;
+
+ try
+ {
+ Reference< XNameAccess > xColumns;
+ if ( !getColumns( xColumns, false ) )
+ // already asserted in getColumns
+ return;
+
+ Reference< XNameAccess > xParentColumns;
+ if ( !getParentColumns( xParentColumns, false ) )
+ return;
+
+ // loop through all links pairs
+ const ::rtl::OUString* pMasterFields = m_aMasterFields.getConstArray();
+ const ::rtl::OUString* pDetailFields = m_aDetailFields.getConstArray();
+
+ Reference< XPropertySet > xMasterField;
+ Reference< XPropertySet > xDetailField;
+
+ // now really ....
+ const ::rtl::OUString* pDetailFieldsEnd = pDetailFields + m_aDetailFields.getLength();
+ for ( ; pDetailFields < pDetailFieldsEnd; ++pDetailFields, ++pMasterFields )
+ {
+ if ( !xParentColumns->hasByName( *pMasterFields ) )
+ {
+ // if this name is unknown in the parent columns, then we don't have a source
+ // for copying the value to the detail columns
+ OSL_ENSURE( sal_False, "ParameterManager::resetParameterValues: this should have been stripped long before!" );
+ continue;
+ }
+
+ // for all inner parameters which are bound to the name as specified by the
+ // slave element of the link, propagate the value from the master column to this
+ // parameter column
+ ParameterInformation::const_iterator aParamInfo = m_aParameterInformation.find( *pDetailFields );
+ if ( ( aParamInfo == m_aParameterInformation.end() )
+ || ( aParamInfo->second.aInnerIndexes.empty() )
+ )
+ {
+ OSL_ENSURE( sal_False, "ParameterManager::resetParameterValues: nothing known about this detail field!" );
+ continue;
+ }
+
+ xParentColumns->getByName( *pMasterFields ) >>= xMasterField;
+ if ( !xMasterField.is() )
+ continue;
+
+ for ( ::std::vector< sal_Int32 >::const_iterator aPosition = aParamInfo->second.aInnerIndexes.begin();
+ aPosition != aParamInfo->second.aInnerIndexes.end();
+ ++aPosition
+ )
+ {
+ Reference< XPropertySet > xInnerParameter;
+ m_xInnerParamColumns->getByIndex( *aPosition ) >>= xInnerParameter;
+ if ( !xInnerParameter.is() )
+ continue;
+
+ ::rtl::OUString sParamColumnRealName;
+ xInnerParameter->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME) ) >>= sParamColumnRealName;
+ if ( xColumns->hasByName( sParamColumnRealName ) )
+ { // our own columns have a column which's name equals the real name of the param column
+ // -> transfer the value property
+ xColumns->getByName( sParamColumnRealName ) >>= xDetailField;
+ if ( xDetailField.is() )
+ xDetailField->setPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_VALUE), xMasterField->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_VALUE) ) );
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "ParameterManager::resetParameterValues: caught an exception!" );
+ }
+
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::externalParameterVisited( sal_Int32 _nIndex )
+ {
+ if ( m_aParametersVisited.size() < (size_t)_nIndex )
+ {
+ m_aParametersVisited.reserve( _nIndex );
+ for ( sal_Int32 i = m_aParametersVisited.size(); i < _nIndex; ++i )
+ m_aParametersVisited.push_back( false );
+ }
+ m_aParametersVisited[ _nIndex - 1 ] = true;
+ }
+
+#define VISIT_PARAMETER( method ) \
+ ::osl::MutexGuard aGuard( m_rMutex ); \
+ OSL_ENSURE( m_xInnerParamUpdate.is(), "ParameterManager::XParameters::setXXX: no XParameters access to the RowSet!" ); \
+ if ( !m_xInnerParamUpdate.is() ) \
+ return; \
+ m_xInnerParamUpdate->method; \
+ externalParameterVisited( _nIndex ) \
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setNull( sal_Int32 _nIndex, sal_Int32 sqlType )
+ {
+ VISIT_PARAMETER( setNull( _nIndex, sqlType ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setObjectNull( sal_Int32 _nIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName )
+ {
+ VISIT_PARAMETER( setObjectNull( _nIndex, sqlType, typeName ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setBoolean( sal_Int32 _nIndex, sal_Bool x )
+ {
+ VISIT_PARAMETER( setBoolean( _nIndex, x ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setByte( sal_Int32 _nIndex, sal_Int8 x )
+ {
+ VISIT_PARAMETER( setByte( _nIndex, x ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setShort( sal_Int32 _nIndex, sal_Int16 x )
+ {
+ VISIT_PARAMETER( setShort( _nIndex, x ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setInt( sal_Int32 _nIndex, sal_Int32 x )
+ {
+ VISIT_PARAMETER( setInt( _nIndex, x ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setLong( sal_Int32 _nIndex, sal_Int64 x )
+ {
+ VISIT_PARAMETER( setLong( _nIndex, x ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setFloat( sal_Int32 _nIndex, float x )
+ {
+ VISIT_PARAMETER( setFloat( _nIndex, x ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setDouble( sal_Int32 _nIndex, double x )
+ {
+ VISIT_PARAMETER( setDouble( _nIndex, x ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setString( sal_Int32 _nIndex, const ::rtl::OUString& x )
+ {
+ VISIT_PARAMETER( setString( _nIndex, x ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setBytes( sal_Int32 _nIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x )
+ {
+ VISIT_PARAMETER( setBytes( _nIndex, x ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setDate( sal_Int32 _nIndex, const ::com::sun::star::util::Date& x )
+ {
+ VISIT_PARAMETER( setDate( _nIndex, x ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setTime( sal_Int32 _nIndex, const ::com::sun::star::util::Time& x )
+ {
+ VISIT_PARAMETER( setTime( _nIndex, x ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setTimestamp( sal_Int32 _nIndex, const ::com::sun::star::util::DateTime& x )
+ {
+ VISIT_PARAMETER( setTimestamp( _nIndex, x ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setBinaryStream( sal_Int32 _nIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& x, sal_Int32 length )
+ {
+ VISIT_PARAMETER( setBinaryStream( _nIndex, x, length ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setCharacterStream( sal_Int32 _nIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& x, sal_Int32 length )
+ {
+ VISIT_PARAMETER( setCharacterStream( _nIndex, x, length ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setObject( sal_Int32 _nIndex, const ::com::sun::star::uno::Any& x )
+ {
+ VISIT_PARAMETER( setObject( _nIndex, x ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setObjectWithInfo( sal_Int32 _nIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale )
+ {
+ VISIT_PARAMETER( setObjectWithInfo( _nIndex, x, targetSqlType, scale ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setRef( sal_Int32 _nIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef>& x )
+ {
+ VISIT_PARAMETER( setRef( _nIndex, x ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setBlob( sal_Int32 _nIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob>& x )
+ {
+ VISIT_PARAMETER( setBlob( _nIndex, x ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setClob( sal_Int32 _nIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob>& x )
+ {
+ VISIT_PARAMETER( setClob( _nIndex, x ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::setArray( sal_Int32 _nIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray>& x )
+ {
+ VISIT_PARAMETER( setArray( _nIndex, x ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterManager::clearParameters( )
+ {
+ if ( m_xInnerParamUpdate.is() )
+ m_xInnerParamUpdate->clearParameters( );
+ }
+
+ //====================================================================
+ //= OParameterContinuation
+ //====================================================================
+ //--------------------------------------------------------------------
+ void SAL_CALL OParameterContinuation::setParameters( const Sequence< PropertyValue >& _rValues ) throw( RuntimeException )
+ {
+ m_aValues = _rValues;
+ }
+
+//........................................................................
+} // namespace frm
+//........................................................................
+
diff --git a/connectivity/source/commontools/paramwrapper.cxx b/connectivity/source/commontools/paramwrapper.cxx
new file mode 100644
index 000000000000..cef4508e3b30
--- /dev/null
+++ b/connectivity/source/commontools/paramwrapper.cxx
@@ -0,0 +1,364 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/paramwrapper.hxx>
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/lang/WrappedTargetException.hpp>
+#include <com/sun/star/sdb/XParametersSupplier.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+#include <comphelper/enumhelper.hxx>
+
+#define PROPERTY_ID_VALUE 1000
+
+//........................................................................
+namespace dbtools
+{
+namespace param
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::sdbc::XParameters;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::XWeak;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::beans::XFastPropertySet;
+ using ::com::sun::star::beans::XMultiPropertySet;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::beans::Property;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::sdbc::SQLException;
+ using ::com::sun::star::lang::WrappedTargetException;
+ using ::com::sun::star::lang::IndexOutOfBoundsException;
+ using ::com::sun::star::container::XEnumeration;
+ using ::com::sun::star::sdb::XSingleSelectQueryAnalyzer;
+ using ::com::sun::star::sdb::XParametersSupplier;
+ using ::com::sun::star::lang::DisposedException;
+ /** === end UNO using === **/
+ namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
+ namespace DataType = ::com::sun::star::sdbc::DataType;
+
+ //====================================================================
+ //= ParameterWrapper
+ //====================================================================
+ //--------------------------------------------------------------------
+ ParameterWrapper::ParameterWrapper( const Reference< XPropertySet >& _rxColumn )
+ :PropertyBase( m_aBHelper )
+ ,m_xDelegator( _rxColumn )
+ {
+ if ( m_xDelegator.is() )
+ m_xDelegatorPSI = m_xDelegator->getPropertySetInfo();
+ if ( !m_xDelegatorPSI.is() )
+ throw RuntimeException();
+ }
+
+ //--------------------------------------------------------------------
+ ParameterWrapper::ParameterWrapper( const Reference< XPropertySet >& _rxColumn,
+ const Reference< XParameters >& _rxAllParameters, const ::std::vector< sal_Int32 >& _rIndexes )
+ :PropertyBase( m_aBHelper )
+ ,m_aIndexes( _rIndexes )
+ ,m_xDelegator( _rxColumn )
+ ,m_xValueDestination( _rxAllParameters )
+ {
+ if ( m_xDelegator.is() )
+ m_xDelegatorPSI = m_xDelegator->getPropertySetInfo();
+ if ( !m_xDelegatorPSI.is() )
+ throw RuntimeException();
+
+ OSL_ENSURE( !m_aIndexes.empty(), "ParameterWrapper::ParameterWrapper: sure about the indexes?" );
+ }
+
+ //--------------------------------------------------------------------
+ ParameterWrapper::~ParameterWrapper()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XINTERFACE2( ParameterWrapper, UnoBase, PropertyBase )
+
+ //--------------------------------------------------------------------
+ Sequence< Type > SAL_CALL ParameterWrapper::getTypes( ) throw(RuntimeException)
+ {
+ Sequence< Type > aTypes( 4 );
+ aTypes[ 1 ] = ::getCppuType( static_cast< Reference< XWeak >* >( NULL ) );
+ aTypes[ 1 ] = ::getCppuType( static_cast< Reference< XPropertySet >* >( NULL ) );
+ aTypes[ 2 ] = ::getCppuType( static_cast< Reference< XFastPropertySet >* >( NULL ) );
+ aTypes[ 3 ] = ::getCppuType( static_cast< Reference< XMultiPropertySet >* >( NULL ) );
+ return aTypes;
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_GET_IMPLEMENTATION_ID( ParameterWrapper )
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString ParameterWrapper::impl_getPseudoAggregatePropertyName( sal_Int32 _nHandle ) const
+ {
+ Reference< XPropertySetInfo > xInfo = const_cast<ParameterWrapper*>( this )->getPropertySetInfo();
+ Sequence< Property > aProperties = xInfo->getProperties();
+ const Property* pProperties = aProperties.getConstArray();
+ for ( sal_Int32 i = 0; i < aProperties.getLength(); ++i, ++pProperties )
+ {
+ if ( pProperties->Handle == _nHandle )
+ return pProperties->Name;
+ }
+
+ OSL_ENSURE( sal_False, "ParameterWrapper::impl_getPseudoAggregatePropertyName: invalid argument!" );
+ return ::rtl::OUString();
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySetInfo > ParameterWrapper::getPropertySetInfo() throw( RuntimeException )
+ {
+ return createPropertySetInfo( getInfoHelper() );
+ }
+
+ //--------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& ParameterWrapper::getInfoHelper()
+ {
+ if ( !m_pInfoHelper.get() )
+ {
+ Sequence< Property > aProperties;
+ try
+ {
+ aProperties = m_xDelegatorPSI->getProperties();
+ sal_Int32 nProperties( aProperties.getLength() );
+ aProperties.realloc( nProperties + 1 );
+ aProperties[ nProperties ] = Property(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Value" ) ),
+ PROPERTY_ID_VALUE,
+ ::cppu::UnoType< Any >::get(),
+ PropertyAttribute::TRANSIENT | PropertyAttribute::MAYBEVOID
+ );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ m_pInfoHelper.reset( new ::cppu::OPropertyArrayHelper( aProperties, false ) );
+ }
+ return *m_pInfoHelper;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool ParameterWrapper::convertFastPropertyValue(Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle, const Any& rValue) throw( IllegalArgumentException )
+ {
+ OSL_ENSURE( PROPERTY_ID_VALUE == nHandle, "ParameterWrapper::convertFastPropertyValue: the only non-readonly prop should be our PROPERTY_VALUE!" );
+ (void)nHandle;
+
+ // we're lazy here ...
+ rOldValue = m_aValue.makeAny();
+ rConvertedValue = rValue;
+ return sal_True; // assume "modified" ...
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterWrapper::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw( Exception )
+ {
+ if ( nHandle == PROPERTY_ID_VALUE )
+ {
+ try
+ {
+ // TODO : aParamType & nScale can be obtained within the constructor ....
+ sal_Int32 nParamType = DataType::VARCHAR;
+ OSL_VERIFY( m_xDelegator->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Type" ) ) ) >>= nParamType );
+
+ sal_Int32 nScale = 0;
+ if ( m_xDelegatorPSI->hasPropertyByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Scale" ) ) ) )
+ OSL_VERIFY( m_xDelegator->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Scale" ) ) ) >>= nScale );
+
+ if ( m_xValueDestination.is() )
+ {
+ for ( ::std::vector< sal_Int32 >::iterator aIter = m_aIndexes.begin(); aIter != m_aIndexes.end(); ++aIter )
+ {
+ m_xValueDestination->setObjectWithInfo( *aIter + 1, rValue, nParamType, nScale );
+ // (the index of the parameters is one-based)
+ }
+ }
+
+ m_aValue = rValue;
+ }
+ catch( SQLException& e )
+ {
+ WrappedTargetException aExceptionWrapper;
+ aExceptionWrapper.Context = e.Context;
+ aExceptionWrapper.Message = e.Message;
+ aExceptionWrapper.TargetException <<= e;
+ throw WrappedTargetException( aExceptionWrapper );
+ }
+ }
+ else
+ {
+ ::rtl::OUString aName = impl_getPseudoAggregatePropertyName( nHandle );
+ m_xDelegator->setPropertyValue( aName, rValue );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterWrapper::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
+ {
+ if ( nHandle == PROPERTY_ID_VALUE )
+ {
+ rValue = m_aValue.makeAny();
+ }
+ else
+ {
+ ::rtl::OUString aName = impl_getPseudoAggregatePropertyName( nHandle );
+ rValue = m_xDelegator->getPropertyValue( aName );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ParameterWrapper::dispose()
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ m_aValue.setNull();
+ m_aIndexes.resize(0);
+ m_xDelegator.clear();
+ m_xDelegatorPSI.clear();
+ m_xValueDestination.clear();
+
+ m_aBHelper.bDisposed = sal_True;
+ }
+
+ //====================================================================
+ //= ParameterWrapperContainer
+ //====================================================================
+ //--------------------------------------------------------------------
+ ParameterWrapperContainer::ParameterWrapperContainer()
+ :ParameterWrapperContainer_Base( m_aMutex )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ParameterWrapperContainer::ParameterWrapperContainer( const Reference< XSingleSelectQueryAnalyzer >& _rxComposer )
+ :ParameterWrapperContainer_Base( m_aMutex )
+ {
+ Reference< XParametersSupplier > xSuppParams( _rxComposer, UNO_QUERY_THROW );
+ Reference< XIndexAccess > xParameters( xSuppParams->getParameters(), UNO_QUERY_THROW );
+ sal_Int32 nParamCount( xParameters->getCount() );
+ m_aParameters.reserve( nParamCount );
+ for ( sal_Int32 i=0; i<nParamCount; ++i )
+ {
+ m_aParameters.push_back( new ParameterWrapper( Reference< XPropertySet >( xParameters->getByIndex( i ), UNO_QUERY_THROW ) ) );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ParameterWrapperContainer::~ParameterWrapperContainer()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ Type SAL_CALL ParameterWrapperContainer::getElementType() throw( RuntimeException )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+ return ::getCppuType( static_cast< Reference< XPropertySet >* >( NULL ) );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL ParameterWrapperContainer::hasElements() throw( RuntimeException )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+ return !m_aParameters.empty();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 SAL_CALL ParameterWrapperContainer::getCount() throw( RuntimeException )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+ return m_aParameters.size();
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL ParameterWrapperContainer::getByIndex( sal_Int32 _nIndex ) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ if ( ( _nIndex < 0 ) || ( _nIndex >= (sal_Int32)m_aParameters.size() ) )
+ throw IndexOutOfBoundsException();
+
+ return makeAny( Reference< XPropertySet >( m_aParameters[ _nIndex ].get() ) );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XEnumeration > ParameterWrapperContainer::createEnumeration() throw( RuntimeException )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ return new ::comphelper::OEnumerationByIndex( static_cast< XIndexAccess* >( this ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ParameterWrapperContainer::impl_checkDisposed_throw()
+ {
+ if ( rBHelper.bDisposed )
+ throw DisposedException( ::rtl::OUString(), *this );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ParameterWrapperContainer::disposing()
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ for ( Parameters::const_iterator param = m_aParameters.begin();
+ param != m_aParameters.end();
+ ++param
+ )
+ {
+ (*param)->dispose();
+ }
+
+ Parameters aEmpty;
+ m_aParameters.swap( aEmpty );
+ }
+
+//........................................................................
+} } // namespace dbtools::param
+//........................................................................
+
diff --git a/connectivity/source/commontools/predicateinput.cxx b/connectivity/source/commontools/predicateinput.cxx
new file mode 100644
index 000000000000..8ffebb0cfbda
--- /dev/null
+++ b/connectivity/source/commontools/predicateinput.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 <connectivity/predicateinput.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/dbtools.hxx>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <osl/diagnose.h>
+#include <connectivity/sqlnode.hxx>
+#include <comphelper/numbers.hxx>
+
+//.........................................................................
+namespace dbtools
+{
+//.........................................................................
+
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::util::XNumberFormatsSupplier;
+ using ::com::sun::star::util::XNumberFormatter;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::lang::Locale;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::i18n::XLocaleData;
+ using ::com::sun::star::i18n::LocaleDataItem;
+
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::connectivity;
+
+ using ::connectivity::OSQLParseNode;
+
+ #define Reference ::com::sun::star::uno::Reference
+
+ //=====================================================================
+ //---------------------------------------------------------------------
+ static sal_Unicode lcl_getSeparatorChar( const ::rtl::OUString& _rSeparator, sal_Unicode _nFallback )
+ {
+ OSL_ENSURE( 0 < _rSeparator.getLength(), "::lcl_getSeparatorChar: invalid separator string!" );
+
+ sal_Unicode nReturn( _nFallback );
+ if ( _rSeparator.getLength() )
+ nReturn = static_cast< sal_Char >( _rSeparator.getStr()[0] );
+ return nReturn;
+ }
+
+ //=====================================================================
+ //= OPredicateInputController
+ //=====================================================================
+ //---------------------------------------------------------------------
+ sal_Bool OPredicateInputController::getSeparatorChars( const Locale& _rLocale, sal_Unicode& _rDecSep, sal_Unicode& _rThdSep ) const
+ {
+ _rDecSep = '.';
+ _rThdSep = ',';
+ try
+ {
+ LocaleDataItem aLocaleData;
+ if ( m_xLocaleData.is() )
+ {
+ aLocaleData = m_xLocaleData->getLocaleItem( _rLocale );
+ _rDecSep = lcl_getSeparatorChar( aLocaleData.decimalSeparator, _rDecSep );
+ _rThdSep = lcl_getSeparatorChar( aLocaleData.decimalSeparator, _rThdSep );
+ return sal_True;
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OPredicateInputController::getSeparatorChars: caught an exception!" );
+ }
+ return sal_False;
+ }
+
+ //---------------------------------------------------------------------
+ OPredicateInputController::OPredicateInputController(
+ const Reference< XMultiServiceFactory >& _rxORB, const Reference< XConnection >& _rxConnection, const IParseContext* _pParseContext )
+ :m_xORB( _rxORB )
+ ,m_xConnection( _rxConnection )
+ ,m_aParser( m_xORB, _pParseContext )
+ {
+ try
+ {
+ // create a number formatter / number formats supplier pair
+ OSL_ENSURE( m_xORB.is(), "OPredicateInputController::OPredicateInputController: need a service factory!" );
+ if ( m_xORB.is() )
+ {
+ m_xFormatter = Reference< XNumberFormatter >( m_xORB->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.NumberFormatter" ) ) ),
+ UNO_QUERY
+ );
+ }
+
+ Reference< XNumberFormatsSupplier > xNumberFormats = ::dbtools::getNumberFormats( m_xConnection, sal_True );
+ if ( !xNumberFormats.is() )
+ ::comphelper::disposeComponent( m_xFormatter );
+ else if ( m_xFormatter.is() )
+ m_xFormatter->attachNumberFormatsSupplier( xNumberFormats );
+
+ // create the locale data
+ if ( m_xORB.is() )
+ {
+ m_xLocaleData = m_xLocaleData.query( m_xORB->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.i18n.LocaleData" ) ) )
+ );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OPredicateInputController::OPredicateInputController: caught an exception!" );
+ }
+ }
+
+ //---------------------------------------------------------------------
+ OSQLParseNode* OPredicateInputController::implPredicateTree(::rtl::OUString& _rErrorMessage, const ::rtl::OUString& _rStatement, const Reference< XPropertySet > & _rxField) const
+ {
+ OSQLParseNode* pReturn = const_cast< OSQLParser& >( m_aParser ).predicateTree( _rErrorMessage, _rStatement, m_xFormatter, _rxField );
+ if ( !pReturn )
+ { // is it a text field ?
+ sal_Int32 nType = DataType::OTHER;
+ _rxField->getPropertyValue( ::rtl::OUString::createFromAscii( "Type" ) ) >>= nType;
+
+ if ( ( DataType::CHAR == nType )
+ || ( DataType::VARCHAR == nType )
+ || ( DataType::LONGVARCHAR == nType )
+ || ( DataType::CLOB == nType )
+ )
+ { // yes -> force a quoted text and try again
+ ::rtl::OUString sQuoted( _rStatement );
+ if ( sQuoted.getLength()
+ && ( (sQuoted.getStr()[0] != '\'')
+ || (sQuoted.getStr()[ sQuoted.getLength() - 1 ] != '\'' )
+ )
+ )
+ {
+ static const ::rtl::OUString sSingleQuote( RTL_CONSTASCII_USTRINGPARAM( "'" ) );
+ static const ::rtl::OUString sDoubleQuote( RTL_CONSTASCII_USTRINGPARAM( "''" ) );
+
+ sal_Int32 nIndex = -1;
+ sal_Int32 nTemp = 0;
+ while ( -1 != ( nIndex = sQuoted.indexOf( '\'',nTemp ) ) )
+ {
+ sQuoted = sQuoted.replaceAt( nIndex, 1, sDoubleQuote );
+ nTemp = nIndex+2;
+ }
+
+ ::rtl::OUString sTemp( sSingleQuote );
+ ( sTemp += sQuoted ) += sSingleQuote;
+ sQuoted = sTemp;
+ }
+ pReturn = const_cast< OSQLParser& >( m_aParser ).predicateTree( _rErrorMessage, sQuoted, m_xFormatter, _rxField );
+ }
+
+ // one more fallback: for numeric fields, and value strings containing a decimal/thousands separator
+ // problem which is to be solved with this:
+ // * a system locale "german"
+ // * a column formatted with an english number format
+ // => the output is german (as we use the system locale for this), i.e. "3,4"
+ // => the input does not recognize the german text, as predicateTree uses the number format
+ // of the column to determine the main locale - the locale on the context is only a fallback
+ if ( ( DataType::FLOAT == nType )
+ || ( DataType::REAL == nType )
+ || ( DataType::DOUBLE == nType )
+ || ( DataType::NUMERIC == nType )
+ || ( DataType::DECIMAL == nType )
+ )
+ {
+ const IParseContext& rParseContext = m_aParser.getContext();
+ // get the separators for the locale of our parse context
+ sal_Unicode nCtxDecSep;
+ sal_Unicode nCtxThdSep;
+ getSeparatorChars( rParseContext.getPreferredLocale(), nCtxDecSep, nCtxThdSep );
+
+ // determine the locale of the column we're building a predicate string for
+ sal_Unicode nFmtDecSep( nCtxDecSep );
+ sal_Unicode nFmtThdSep( nCtxThdSep );
+ try
+ {
+ Reference< XPropertySetInfo > xPSI( _rxField->getPropertySetInfo() );
+ if ( xPSI.is() && xPSI->hasPropertyByName( ::rtl::OUString::createFromAscii( "FormatKey" ) ) )
+ {
+ sal_Int32 nFormatKey = 0;
+ _rxField->getPropertyValue( ::rtl::OUString::createFromAscii( "FormatKey" ) ) >>= nFormatKey;
+ if ( nFormatKey && m_xFormatter.is() )
+ {
+ Locale aFormatLocale;
+ ::comphelper::getNumberFormatProperty(
+ m_xFormatter,
+ nFormatKey,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Locale" ) )
+ ) >>= aFormatLocale;
+
+ // valid locale
+ if ( aFormatLocale.Language.getLength() )
+ {
+ getSeparatorChars( aFormatLocale, nFmtDecSep, nCtxThdSep );
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OPredicateInputController::implPredicateTree: caught an exception while dealing with the formats!" );
+ }
+
+ sal_Bool bDecDiffers = ( nCtxDecSep != nFmtDecSep );
+ sal_Bool bFmtDiffers = ( nCtxThdSep != nFmtThdSep );
+ if ( bDecDiffers || bFmtDiffers )
+ { // okay, at least one differs
+ // "translate" the value into the "format locale"
+ ::rtl::OUString sTranslated( _rStatement );
+ const sal_Unicode nIntermediate( '_' );
+ sTranslated = sTranslated.replace( nCtxDecSep, nIntermediate );
+ sTranslated = sTranslated.replace( nCtxThdSep, nFmtThdSep );
+ sTranslated = sTranslated.replace( nIntermediate, nFmtDecSep );
+
+ pReturn = const_cast< OSQLParser& >( m_aParser ).predicateTree( _rErrorMessage, sTranslated, m_xFormatter, _rxField );
+ }
+ }
+ }
+ return pReturn;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OPredicateInputController::normalizePredicateString(
+ ::rtl::OUString& _rPredicateValue, const Reference< XPropertySet > & _rxField, ::rtl::OUString* _pErrorMessage ) const
+ {
+ OSL_ENSURE( m_xConnection.is() && m_xFormatter.is() && _rxField.is(),
+ "OPredicateInputController::normalizePredicateString: invalid state or params!" );
+
+ sal_Bool bSuccess = sal_False;
+ if ( m_xConnection.is() && m_xFormatter.is() && _rxField.is() )
+ {
+ // parse the string
+ ::rtl::OUString sError;
+ ::rtl::OUString sTransformedText( _rPredicateValue );
+ OSQLParseNode* pParseNode = implPredicateTree( sError, sTransformedText, _rxField );
+ if ( _pErrorMessage ) *_pErrorMessage = sError;
+
+ if ( pParseNode )
+ {
+ const IParseContext& rParseContext = m_aParser.getContext();
+ sal_Unicode nDecSeparator, nThousandSeparator;
+ getSeparatorChars( rParseContext.getPreferredLocale(), nDecSeparator, nThousandSeparator );
+
+ // translate it back into a string
+ sTransformedText = ::rtl::OUString();
+ pParseNode->parseNodeToPredicateStr(
+ sTransformedText, m_xConnection, m_xFormatter, _rxField,
+ rParseContext.getPreferredLocale(), (sal_Char)nDecSeparator, &rParseContext
+ );
+ _rPredicateValue = sTransformedText;
+ delete pParseNode;
+
+ bSuccess = sal_True;
+ }
+ }
+
+ return bSuccess;
+ }
+
+ //---------------------------------------------------------------------
+ ::rtl::OUString OPredicateInputController::getPredicateValue(
+ const ::rtl::OUString& _rPredicateValue, const Reference< XPropertySet > & _rxField,
+ sal_Bool _bForStatementUse, ::rtl::OUString* _pErrorMessage ) const
+ {
+ OSL_ENSURE( _rxField.is(), "OPredicateInputController::getPredicateValue: invalid params!" );
+ ::rtl::OUString sReturn;
+ if ( _rxField.is() )
+ {
+ ::rtl::OUString sValue( _rPredicateValue );
+
+ // a little problem : if the field is a text field, the normalizePredicateString added two
+ // '-characters to the text. If we would give this to predicateTree this would add
+ // two additional '-characters which we don't want. So check the field format.
+ // FS - 06.01.00 - 71532
+ sal_Bool bValidQuotedText = ( sValue.getLength() >= 2 )
+ && ( sValue.getStr()[0] == '\'' )
+ && ( sValue.getStr()[ sValue.getLength() - 1 ] == '\'' );
+ // again : as normalizePredicateString always did a conversion on the value text,
+ // bValidQuotedText == sal_True implies that we have a text field, as no other field
+ // values will be formatted with the quote characters
+ if ( bValidQuotedText )
+ {
+ sValue = sValue.copy( 1, sValue.getLength() - 2 );
+ static const ::rtl::OUString sSingleQuote( RTL_CONSTASCII_USTRINGPARAM( "'" ) );
+ static const ::rtl::OUString sDoubleQuote( RTL_CONSTASCII_USTRINGPARAM( "''" ) );
+
+ sal_Int32 nIndex = -1;
+ sal_Int32 nTemp = 0;
+ while ( -1 != ( nIndex = sValue.indexOf( sDoubleQuote,nTemp ) ) )
+ {
+ sValue = sValue.replaceAt( nIndex, 2, sSingleQuote );
+ nTemp = nIndex+2;
+ }
+ }
+
+ // The following is mostly stolen from the former implementation in the parameter dialog
+ // (dbaccess/source/ui/dlg/paramdialog.cxx). I do not fully understand this .....
+
+ ::rtl::OUString sError;
+ OSQLParseNode* pParseNode = implPredicateTree( sError, sValue, _rxField );
+ if ( _pErrorMessage ) *_pErrorMessage = sError;
+
+ if ( pParseNode )
+ {
+ OSQLParseNode* pOdbcSpec = pParseNode->getByRule( OSQLParseNode::odbc_fct_spec );
+ if ( pOdbcSpec )
+ {
+ if ( !_bForStatementUse )
+ {
+ if ( ( pOdbcSpec->count() >= 2 )
+ && ( SQL_NODE_STRING == pOdbcSpec->getChild(1)->getNodeType() )
+ )
+ {
+
+ sReturn = pOdbcSpec->getChild(1)->getTokenValue();
+ }
+ else
+ OSL_ENSURE( sal_False, "OPredicateInputController::getPredicateValue: unknown/invalid structure (odbc + param use)!" );
+ }
+ else
+ {
+ OSQLParseNode* pFuncSpecParent = pOdbcSpec->getParent();
+ OSL_ENSURE( pFuncSpecParent, "OPredicateInputController::getPredicateValue: an ODBC func spec node without parent?" );
+ if ( pFuncSpecParent )
+ pFuncSpecParent->parseNodeToStr(
+ sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True
+ );
+ }
+ }
+ else
+ {
+ if ( pParseNode->count() >= 3 )
+ {
+ OSQLParseNode* pValueNode = pParseNode->getChild(2);
+ OSL_ENSURE( pValueNode, "OPredicateInputController::getPredicateValue: invalid node child!" );
+ if ( !_bForStatementUse )
+ {
+ if ( SQL_NODE_STRING == pValueNode->getNodeType() )
+ sReturn = pValueNode->getTokenValue();
+ else
+ pValueNode->parseNodeToStr(
+ sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True
+ );
+ }
+ else
+ pValueNode->parseNodeToStr(
+ sReturn, m_xConnection, &m_aParser.getContext(), sal_False, sal_True
+ );
+ }
+ else
+ OSL_ENSURE( sal_False, "OPredicateInputController::getPredicateValue: unknown/invalid structure (noodbc)!" );
+ }
+
+ delete pParseNode;
+ }
+ }
+
+ return sReturn;
+ }
+//.........................................................................
+} // namespace dbtools
+//.........................................................................
+
+
diff --git a/connectivity/source/commontools/propertyids.cxx b/connectivity/source/commontools/propertyids.cxx
new file mode 100644
index 000000000000..b6bae373a7db
--- /dev/null
+++ b/connectivity/source/commontools/propertyids.cxx
@@ -0,0 +1,198 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "propertyids.hxx"
+
+namespace dbtools
+{
+ const sal_Char* getPROPERTY_QUERYTIMEOUT() { return "QueryTimeOut"; }
+ const sal_Char* getPROPERTY_MAXFIELDSIZE() { return "MaxFieldSize"; }
+ const sal_Char* getPROPERTY_MAXROWS() { return "MaxRows"; }
+ const sal_Char* getPROPERTY_CURSORNAME() { return "CursorName"; }
+ const sal_Char* getPROPERTY_RESULTSETCONCURRENCY() { return "ResultSetConcurrency"; }
+ const sal_Char* getPROPERTY_RESULTSETTYPE() { return "ResultSetType"; }
+ const sal_Char* getPROPERTY_FETCHDIRECTION() { return "FetchDirection"; }
+ const sal_Char* getPROPERTY_FETCHSIZE() { return "FetchSize"; }
+ const sal_Char* getPROPERTY_ESCAPEPROCESSING() { return "EscapeProcessing"; }
+ const sal_Char* getPROPERTY_USEBOOKMARKS() { return "UseBookmarks"; }
+
+ const sal_Char* getPROPERTY_NAME() { return "Name"; }
+ const sal_Char* getPROPERTY_TYPE() { return "Type"; }
+ const sal_Char* getPROPERTY_TYPENAME() { return "TypeName"; }
+ const sal_Char* getPROPERTY_PRECISION() { return "Precision"; }
+ const sal_Char* getPROPERTY_SCALE() { return "Scale"; }
+ const sal_Char* getPROPERTY_ISNULLABLE() { return "IsNullable"; }
+ const sal_Char* getPROPERTY_ISAUTOINCREMENT() { return "IsAutoIncrement"; }
+ const sal_Char* getPROPERTY_ISROWVERSION() { return "IsRowVersion"; }
+ const sal_Char* getPROPERTY_DESCRIPTION() { return "Description"; }
+ const sal_Char* getPROPERTY_DEFAULTVALUE() { return "DefaultValue"; }
+
+ const sal_Char* getPROPERTY_REFERENCEDTABLE() { return "ReferencedTable"; }
+ const sal_Char* getPROPERTY_UPDATERULE() { return "UpdateRule"; }
+ const sal_Char* getPROPERTY_DELETERULE() { return "DeleteRule"; }
+ const sal_Char* getPROPERTY_CATALOG() { return "Catalog"; }
+ const sal_Char* getPROPERTY_ISUNIQUE() { return "IsUnique"; }
+ const sal_Char* getPROPERTY_ISPRIMARYKEYINDEX() { return "IsPrimaryKeyIndex"; }
+ const sal_Char* getPROPERTY_ISCLUSTERED() { return "IsClustered"; }
+ const sal_Char* getPROPERTY_ISASCENDING() { return "IsAscending"; }
+ const sal_Char* getPROPERTY_SCHEMANAME() { return "SchemaName"; }
+ const sal_Char* getPROPERTY_CATALOGNAME() { return "CatalogName"; }
+ const sal_Char* getPROPERTY_COMMAND() { return "Command"; }
+ const sal_Char* getPROPERTY_CHECKOPTION() { return "CheckOption"; }
+ const sal_Char* getPROPERTY_PASSWORD() { return "Password"; }
+ const sal_Char* getPROPERTY_RELATEDCOLUMN() { return "RelatedColumn"; }
+
+ const sal_Char* getPROPERTY_FUNCTION() { return "Function"; }
+ const sal_Char* getPROPERTY_AGGREGATEFUNCTION() { return "AggregateFunction"; }
+ const sal_Char* getPROPERTY_TABLENAME() { return "TableName"; }
+ const sal_Char* getPROPERTY_REALNAME() { return "RealName"; }
+ const sal_Char* getPROPERTY_DBASEPRECISIONCHANGED() { return "DbasePrecisionChanged"; }
+ const sal_Char* getPROPERTY_ISCURRENCY() { return "IsCurrency"; }
+ const sal_Char* getPROPERTY_ISBOOKMARKABLE() { return "IsBookmarkable"; }
+
+ const sal_Char* getPROPERTY_FORMATKEY() { return "FormatKey"; }
+ const sal_Char* getPROPERTY_LOCALE() { return "Locale"; }
+
+ const sal_Char* getPROPERTY_AUTOINCREMENTCREATION() { return "AutoIncrementCreation"; }
+ const sal_Char* getPROPERTY_PRIVILEGES() { return "Privileges"; }
+ const sal_Char* getPROPERTY_ID_HAVINGCLAUSE() { return "HavingClause"; }
+ const sal_Char* getPROPERTY_ID_ISSIGNED() { return "IsSigned"; }
+ const sal_Char* getPROPERTY_ID_ISSEARCHABLE() { return "IsSearchable"; }
+
+ const sal_Char* getPROPERTY_ID_APPLYFILTER() { return "ApplyFilter"; }
+ const sal_Char* getPROPERTY_ID_FILTER() { return "Filter"; }
+ const sal_Char* getPROPERTY_ID_MASTERFIELDS() { return "MasterFields"; }
+ const sal_Char* getPROPERTY_ID_DETAILFIELDS() { return "DetailFields"; }
+ const sal_Char* getPROPERTY_ID_FIELDTYPE() { return "FieldType"; }
+ const sal_Char* getPROPERTY_ID_VALUE() { return "Value"; }
+ const sal_Char* getPROPERTY_ID_ACTIVE_CONNECTION() { return "ActiveConnection"; }
+ const sal_Char* getPROPERTY_ID_LABEL() { return "Label"; }
+
+ //============================================================
+ //= error messages
+ //============================================================
+ const sal_Char* getSQLSTATE_SEQUENCE() { return "HY010"; }
+ const sal_Char* getSTR_DELIMITER() { return "/"; }
+
+
+
+ OPropertyMap::~OPropertyMap()
+ {
+ ::std::map<sal_Int32 , rtl_uString*>::iterator aIter = m_aPropertyMap.begin();
+ for(;aIter != m_aPropertyMap.end();++aIter)
+ if(aIter->second)
+ rtl_uString_release(aIter->second);
+ }
+ // ------------------------------------------------------------------------------
+ ::rtl::OUString OPropertyMap::getNameByIndex(sal_Int32 _nIndex) const
+ {
+ ::rtl::OUString sRet;
+ ::std::map<sal_Int32 , rtl_uString*>::const_iterator aIter = m_aPropertyMap.find(_nIndex);
+ if(aIter == m_aPropertyMap.end())
+ sRet = const_cast<OPropertyMap*>(this)->fillValue(_nIndex);
+ else
+ sRet = aIter->second;
+ return sRet;
+ }
+ // ------------------------------------------------------------------------------
+ ::rtl::OUString OPropertyMap::fillValue(sal_Int32 _nIndex)
+ {
+ rtl_uString* pStr = NULL;
+ switch(_nIndex)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT: { rtl_uString_newFromAscii(&pStr,getPROPERTY_QUERYTIMEOUT() ); break; }
+ case PROPERTY_ID_MAXFIELDSIZE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_MAXFIELDSIZE() ); break; }
+ case PROPERTY_ID_MAXROWS: { rtl_uString_newFromAscii(&pStr,getPROPERTY_MAXROWS() ); break; }
+ case PROPERTY_ID_CURSORNAME: { rtl_uString_newFromAscii(&pStr,getPROPERTY_CURSORNAME() ); break; }
+ case PROPERTY_ID_RESULTSETCONCURRENCY: { rtl_uString_newFromAscii(&pStr,getPROPERTY_RESULTSETCONCURRENCY() ); break; }
+ case PROPERTY_ID_RESULTSETTYPE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_RESULTSETTYPE() ); break; }
+ case PROPERTY_ID_FETCHDIRECTION: { rtl_uString_newFromAscii(&pStr,getPROPERTY_FETCHDIRECTION() ); break; }
+ case PROPERTY_ID_FETCHSIZE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_FETCHSIZE() ); break; }
+ case PROPERTY_ID_ESCAPEPROCESSING: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ESCAPEPROCESSING() ); break; }
+ case PROPERTY_ID_USEBOOKMARKS: { rtl_uString_newFromAscii(&pStr,getPROPERTY_USEBOOKMARKS() ); break; }
+ // Column
+ case PROPERTY_ID_NAME: { rtl_uString_newFromAscii(&pStr,getPROPERTY_NAME() ); break; }
+ case PROPERTY_ID_TYPE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_TYPE() ); break; }
+ case PROPERTY_ID_TYPENAME: { rtl_uString_newFromAscii(&pStr,getPROPERTY_TYPENAME() ); break; }
+ case PROPERTY_ID_PRECISION: { rtl_uString_newFromAscii(&pStr,getPROPERTY_PRECISION() ); break; }
+ case PROPERTY_ID_SCALE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_SCALE() ); break; }
+ case PROPERTY_ID_ISNULLABLE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ISNULLABLE() ); break; }
+ case PROPERTY_ID_ISAUTOINCREMENT: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ISAUTOINCREMENT() ); break; }
+ case PROPERTY_ID_ISROWVERSION: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ISROWVERSION() ); break; }
+ case PROPERTY_ID_DESCRIPTION: { rtl_uString_newFromAscii(&pStr,getPROPERTY_DESCRIPTION() ); break; }
+ case PROPERTY_ID_DEFAULTVALUE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_DEFAULTVALUE() ); break; }
+
+ case PROPERTY_ID_REFERENCEDTABLE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_REFERENCEDTABLE() ); break; }
+ case PROPERTY_ID_UPDATERULE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_UPDATERULE() ); break; }
+ case PROPERTY_ID_DELETERULE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_DELETERULE() ); break; }
+ case PROPERTY_ID_CATALOG: { rtl_uString_newFromAscii(&pStr,getPROPERTY_CATALOG() ); break; }
+ case PROPERTY_ID_ISUNIQUE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ISUNIQUE() ); break; }
+ case PROPERTY_ID_ISPRIMARYKEYINDEX: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ISPRIMARYKEYINDEX() ); break; }
+ case PROPERTY_ID_ISCLUSTERED: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ISCLUSTERED() ); break; }
+ case PROPERTY_ID_ISASCENDING: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ISASCENDING() ); break; }
+ case PROPERTY_ID_SCHEMANAME: { rtl_uString_newFromAscii(&pStr,getPROPERTY_SCHEMANAME() ); break; }
+ case PROPERTY_ID_CATALOGNAME: { rtl_uString_newFromAscii(&pStr,getPROPERTY_CATALOGNAME() ); break; }
+
+ case PROPERTY_ID_COMMAND: { rtl_uString_newFromAscii(&pStr,getPROPERTY_COMMAND() ); break; }
+ case PROPERTY_ID_CHECKOPTION: { rtl_uString_newFromAscii(&pStr,getPROPERTY_CHECKOPTION() ); break; }
+ case PROPERTY_ID_PASSWORD: { rtl_uString_newFromAscii(&pStr,getPROPERTY_PASSWORD() ); break; }
+ case PROPERTY_ID_RELATEDCOLUMN: { rtl_uString_newFromAscii(&pStr,getPROPERTY_RELATEDCOLUMN() ); break; }
+
+ case PROPERTY_ID_FUNCTION: { rtl_uString_newFromAscii(&pStr,getPROPERTY_FUNCTION() ); break; }
+ case PROPERTY_ID_AGGREGATEFUNCTION: { rtl_uString_newFromAscii(&pStr,getPROPERTY_AGGREGATEFUNCTION() ); break; }
+ case PROPERTY_ID_TABLENAME: { rtl_uString_newFromAscii(&pStr,getPROPERTY_TABLENAME() ); break; }
+ case PROPERTY_ID_REALNAME: { rtl_uString_newFromAscii(&pStr,getPROPERTY_REALNAME() ); break; }
+ case PROPERTY_ID_DBASEPRECISIONCHANGED: { rtl_uString_newFromAscii(&pStr,getPROPERTY_DBASEPRECISIONCHANGED()); break; }
+ case PROPERTY_ID_ISCURRENCY: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ISCURRENCY() ); break; }
+ case PROPERTY_ID_ISBOOKMARKABLE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ISBOOKMARKABLE() ); break; }
+ case PROPERTY_ID_HY010: { rtl_uString_newFromAscii(&pStr,getSQLSTATE_SEQUENCE() ); break; }
+ case PROPERTY_ID_DELIMITER: { rtl_uString_newFromAscii(&pStr,getSTR_DELIMITER() ); break; }
+ case PROPERTY_ID_FORMATKEY: { rtl_uString_newFromAscii(&pStr,getPROPERTY_FORMATKEY() ); break; }
+ case PROPERTY_ID_LOCALE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_LOCALE() ); break; }
+ case PROPERTY_ID_AUTOINCREMENTCREATION: { rtl_uString_newFromAscii(&pStr,getPROPERTY_AUTOINCREMENTCREATION()); break; }
+ case PROPERTY_ID_PRIVILEGES: { rtl_uString_newFromAscii(&pStr,getPROPERTY_PRIVILEGES() ); break; }
+ case PROPERTY_ID_HAVINGCLAUSE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ID_HAVINGCLAUSE() ); break; }
+ case PROPERTY_ID_ISSIGNED: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ID_ISSIGNED() ); break; }
+ case PROPERTY_ID_ISSEARCHABLE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ID_ISSEARCHABLE() ); break; }
+ case PROPERTY_ID_LABEL: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ID_LABEL() ); break; }
+ case PROPERTY_ID_APPLYFILTER: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ID_APPLYFILTER() ); break; }
+ case PROPERTY_ID_FILTER: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ID_FILTER() ); break; }
+ case PROPERTY_ID_MASTERFIELDS: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ID_MASTERFIELDS() ); break; }
+ case PROPERTY_ID_DETAILFIELDS: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ID_DETAILFIELDS() ); break; }
+ case PROPERTY_ID_FIELDTYPE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ID_FIELDTYPE() ); break; }
+ case PROPERTY_ID_VALUE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ID_VALUE() ); break; }
+ case PROPERTY_ID_ACTIVE_CONNECTION: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ID_ACTIVE_CONNECTION() ); break; }
+ }
+ m_aPropertyMap[_nIndex] = pStr;
+ return pStr;
+ }
+}
+
+
diff --git a/connectivity/source/commontools/sqlerror.cxx b/connectivity/source/commontools/sqlerror.cxx
new file mode 100644
index 000000000000..a04284799894
--- /dev/null
+++ b/connectivity/source/commontools/sqlerror.cxx
@@ -0,0 +1,363 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/sqlerror.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdbc/SQLException.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/officeresourcebundle.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <rtl/ustrbuf.hxx>
+
+#include <string.h>
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ /** === 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::uno::XInterface;
+ using ::com::sun::star::sdbc::SQLException;
+ using ::com::sun::star::uno::Type;
+ /** === end UNO using === **/
+
+ //using SQLError::ParamValue; // GCC (unxlngi6) does not like this
+ namespace
+ {
+ typedef SQLError::ParamValue ParamValue;
+ }
+
+ //====================================================================
+ //= SQLError_Impl - declaration
+ //====================================================================
+ class SQLError_Impl
+ {
+ public:
+ SQLError_Impl( const ::comphelper::ComponentContext& _rContext );
+ ~SQLError_Impl();
+
+ // versions of the public SQLError methods which are just delegated to this impl-class
+ static const ::rtl::OUString& getMessagePrefix();
+ ::rtl::OUString getErrorMessage( const ErrorCondition _eCondition, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 );
+ ::rtl::OUString getSQLState( const ErrorCondition _eCondition );
+ static ErrorCode getErrorCode( const ErrorCondition _eCondition );
+ void raiseException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 );
+ void raiseException( const ErrorCondition _eCondition, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 );
+ void raiseTypedException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const Type& _rExceptionType, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 );
+ SQLException getSQLException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 );
+
+ private:
+ /// returns the basic error message associated with the given error condition, without any parameter replacements
+ ::rtl::OUString
+ impl_getErrorMessage( const ErrorCondition& _eCondition );
+
+ /// returns the SQLState associated with the given error condition
+ ::rtl::OUString
+ impl_getSQLState( const ErrorCondition& _eCondition );
+
+ /// returns an SQLException describing the given error condition
+ SQLException
+ impl_buildSQLException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext,
+ const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 );
+
+ /// initializes our resource bundle
+ bool impl_initResources();
+
+ private:
+ ::osl::Mutex m_aMutex;
+ ::comphelper::ComponentContext m_aContext;
+ ::std::auto_ptr< ::comphelper::OfficeResourceBundle > m_pResources;
+ bool m_bAttemptedInit;
+ };
+
+ //====================================================================
+ //= SQLError_Impl - implementation
+ //====================================================================
+ //--------------------------------------------------------------------
+ SQLError_Impl::SQLError_Impl( const ::comphelper::ComponentContext& _rContext )
+ :m_aContext( _rContext )
+ ,m_pResources( )
+ ,m_bAttemptedInit( false )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ SQLError_Impl::~SQLError_Impl()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ const ::rtl::OUString& SQLError_Impl::getMessagePrefix()
+ {
+ static ::rtl::OUString s_sMessagePrefix( RTL_CONSTASCII_USTRINGPARAM( "[OOoBase]" ) );
+ return s_sMessagePrefix;
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ //................................................................
+ /** substitutes a given placeholder in the given message with the given value
+ */
+ void lcl_substitutePlaceholder( ::rtl::OUString& _rMessage, const sal_Char* _pPlaceholder, ParamValue _rParamValue )
+ {
+ size_t nPlaceholderLen( strlen( _pPlaceholder ) );
+ sal_Int32 nIndex = _rMessage.indexOfAsciiL( _pPlaceholder, nPlaceholderLen );
+
+ bool bHasPlaceholder = ( nIndex != -1 );
+ bool bWantsPlaceholder = _rParamValue.is();
+ OSL_ENSURE( bHasPlaceholder == bWantsPlaceholder, "lcl_substitutePlaceholder: placeholder where none is expected, or no placeholder where one is needed!" );
+
+ if ( bHasPlaceholder && bWantsPlaceholder )
+ _rMessage = _rMessage.replaceAt( nIndex, nPlaceholderLen, *_rParamValue );
+ }
+
+ //................................................................
+ sal_Int32 lcl_getResourceID( const ErrorCondition _eCondition, bool _bSQLState )
+ {
+ return 256
+ + 2 * ::sal::static_int_cast< sal_Int32, ErrorCondition >( _eCondition )
+ + ( _bSQLState ? 1 : 0 );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SQLError_Impl::getErrorMessage( const ErrorCondition _eCondition, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 )
+ {
+ ::rtl::OUString sErrorMessage( impl_getErrorMessage( _eCondition ) );
+
+ lcl_substitutePlaceholder( sErrorMessage, "$1$", _rParamValue1 );
+ lcl_substitutePlaceholder( sErrorMessage, "$2$", _rParamValue2 );
+ lcl_substitutePlaceholder( sErrorMessage, "$3$", _rParamValue3 );
+
+ return sErrorMessage;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SQLError_Impl::getSQLState( const ErrorCondition _eCondition )
+ {
+ return impl_getSQLState( _eCondition );
+ }
+
+ //--------------------------------------------------------------------
+ ErrorCode SQLError_Impl::getErrorCode( const ErrorCondition _eCondition )
+ {
+ return 0 - ::sal::static_int_cast< ErrorCode, ErrorCondition >( _eCondition );
+ }
+
+ //--------------------------------------------------------------------
+ void SQLError_Impl::raiseException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 )
+ {
+ raiseTypedException(
+ _eCondition,
+ _rxContext,
+ ::cppu::UnoType< SQLException >::get(),
+ _rParamValue1,
+ _rParamValue2,
+ _rParamValue3
+ );
+ }
+
+ //--------------------------------------------------------------------
+ void SQLError_Impl::raiseException( const ErrorCondition _eCondition, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 )
+ {
+ raiseTypedException(
+ _eCondition,
+ NULL,
+ ::cppu::UnoType< SQLException >::get(),
+ _rParamValue1,
+ _rParamValue2,
+ _rParamValue3
+ );
+ }
+
+ //--------------------------------------------------------------------
+ void SQLError_Impl::raiseTypedException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext,
+ const Type& _rExceptionType, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 )
+ {
+ if ( !::cppu::UnoType< SQLException >::get().isAssignableFrom( _rExceptionType ) )
+ throw ::std::bad_cast();
+
+ // default-construct an exception of the desired type
+ Any aException( NULL, _rExceptionType );
+
+ // fill it
+ SQLException* pException = static_cast< SQLException* >( aException.pData );
+ *pException = impl_buildSQLException( _eCondition, _rxContext, _rParamValue1, _rParamValue2, _rParamValue3 );
+
+ // throw it
+ ::cppu::throwException( aException );
+ }
+
+ //--------------------------------------------------------------------
+ SQLException SQLError_Impl::getSQLException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext,
+ const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 )
+ {
+ return impl_buildSQLException( _eCondition, _rxContext, _rParamValue1, _rParamValue2, _rParamValue3 );
+ }
+
+ //--------------------------------------------------------------------
+ SQLException SQLError_Impl::impl_buildSQLException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext,
+ const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 )
+ {
+ return SQLException(
+ getErrorMessage( _eCondition, _rParamValue1, _rParamValue2, _rParamValue3 ),
+ _rxContext,
+ getSQLState( _eCondition ),
+ getErrorCode( _eCondition ),
+ Any()
+ );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SQLError_Impl::impl_getErrorMessage( const ErrorCondition& _eCondition )
+ {
+ ::rtl::OUStringBuffer aMessage;
+
+ if ( impl_initResources() )
+ {
+ ::rtl::OUString sResMessage( m_pResources->loadString( lcl_getResourceID( _eCondition, false ) ) );
+ OSL_ENSURE( sResMessage.getLength(), "SQLError_Impl::impl_getErrorMessage: illegal error condition, or invalid resource!" );
+ aMessage.append( getMessagePrefix() ).appendAscii( " " ).append( sResMessage );
+ }
+
+ return aMessage.makeStringAndClear();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SQLError_Impl::impl_getSQLState( const ErrorCondition& _eCondition )
+ {
+ ::rtl::OUString sState;
+
+ if ( impl_initResources() )
+ {
+ sal_Int32 nResourceId( lcl_getResourceID( _eCondition, true ) );
+ if ( m_pResources->hasString( nResourceId ) )
+ sState = m_pResources->loadString( nResourceId );
+ }
+
+ if ( !sState.getLength() )
+ sState = ::rtl::OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "S1000" ) );
+
+ return sState;
+ }
+
+ //--------------------------------------------------------------------
+ bool SQLError_Impl::impl_initResources()
+ {
+ if ( m_pResources.get() )
+ return true;
+ if ( m_bAttemptedInit )
+ return false;
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_bAttemptedInit = true;
+
+ m_pResources.reset( new ::comphelper::OfficeResourceBundle( m_aContext.getUNOContext(), "sdberr" ) );
+ return m_pResources.get() != NULL;
+ }
+
+ //====================================================================
+ //= SQLError
+ //====================================================================
+ //--------------------------------------------------------------------
+ SQLError::SQLError( const ::comphelper::ComponentContext& _rContext )
+ :m_pImpl( new SQLError_Impl( _rContext ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ SQLError::~SQLError()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ const ::rtl::OUString& SQLError::getMessagePrefix()
+ {
+ return SQLError_Impl::getMessagePrefix();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SQLError::getErrorMessage( const ErrorCondition _eCondition, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 ) const
+ {
+ return m_pImpl->getErrorMessage( _eCondition, _rParamValue1, _rParamValue2, _rParamValue3 );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SQLError::getSQLState( const ErrorCondition _eCondition ) const
+ {
+ return m_pImpl->getSQLState( _eCondition );
+ }
+
+ //--------------------------------------------------------------------
+ ErrorCode SQLError::getErrorCode( const ErrorCondition _eCondition )
+ {
+ return SQLError_Impl::getErrorCode( _eCondition );
+ }
+
+ //--------------------------------------------------------------------
+ void SQLError::raiseException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 ) const
+ {
+ m_pImpl->raiseException( _eCondition, _rxContext, _rParamValue1, _rParamValue2, _rParamValue3 );
+ }
+
+ //--------------------------------------------------------------------
+ void SQLError::raiseException( const ErrorCondition _eCondition, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 ) const
+ {
+ m_pImpl->raiseException( _eCondition, _rParamValue1, _rParamValue2, _rParamValue3 );
+ }
+
+ //--------------------------------------------------------------------
+ void SQLError::raiseTypedException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext,
+ const Type& _rExceptionType, const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 ) const
+ {
+ m_pImpl->raiseTypedException( _eCondition, _rxContext, _rExceptionType, _rParamValue1, _rParamValue2, _rParamValue3 );
+ }
+
+ //--------------------------------------------------------------------
+ SQLException SQLError::getSQLException( const ErrorCondition _eCondition, const Reference< XInterface >& _rxContext,
+ const ParamValue& _rParamValue1, const ParamValue& _rParamValue2, const ParamValue& _rParamValue3 ) const
+ {
+ return m_pImpl->getSQLException( _eCondition, _rxContext, _rParamValue1, _rParamValue2, _rParamValue3 );
+ }
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
diff --git a/connectivity/source/commontools/statementcomposer.cxx b/connectivity/source/commontools/statementcomposer.cxx
new file mode 100644
index 000000000000..0996eaaaaf86
--- /dev/null
+++ b/connectivity/source/commontools/statementcomposer.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 <connectivity/statementcomposer.hxx>
+
+#include <connectivity/dbtools.hxx>
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+/** === end UNO includes === **/
+
+#include <unotools/sharedunocomponent.hxx>
+#include <tools/diagnose_ex.h>
+#include <comphelper/property.hxx>
+
+//........................................................................
+namespace dbtools
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::sdb::XSingleSelectQueryComposer;
+ using ::com::sun::star::lang::NullPointerException;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::lang::XComponent;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::sdb::XQueriesSupplier;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::sdbc::SQLException;
+ /** === end UNO using === **/
+ namespace CommandType = ::com::sun::star::sdb::CommandType;
+
+ //====================================================================
+ //= StatementComposer_Data
+ //====================================================================
+ struct StatementComposer_Data
+ {
+ const Reference< XConnection > xConnection;
+ Reference< XSingleSelectQueryComposer > xComposer;
+ ::rtl::OUString sCommand;
+ ::rtl::OUString sFilter;
+ ::rtl::OUString sOrder;
+ sal_Int32 nCommandType;
+ sal_Bool bEscapeProcessing;
+ bool bComposerDirty;
+ bool bDisposeComposer;
+
+ StatementComposer_Data( const Reference< XConnection >& _rxConnection )
+ :xConnection( _rxConnection )
+ ,sCommand()
+ ,sFilter()
+ ,sOrder()
+ ,nCommandType( CommandType::COMMAND )
+ ,bEscapeProcessing( sal_True )
+ ,bComposerDirty( true )
+ ,bDisposeComposer( true )
+ {
+ if ( !_rxConnection.is() )
+ throw NullPointerException();
+ }
+ };
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ //----------------------------------------------------------------
+ void lcl_resetComposer( StatementComposer_Data& _rData )
+ {
+ if ( _rData.bDisposeComposer && _rData.xComposer.is() )
+ {
+ try
+ {
+ Reference< XComponent > xComposerComponent( _rData.xComposer, UNO_QUERY_THROW );
+ xComposerComponent->dispose();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ _rData.xComposer.clear();
+ }
+
+ //----------------------------------------------------------------
+ bool lcl_ensureUpToDateComposer_nothrow( StatementComposer_Data& _rData )
+ {
+ if ( !_rData.bComposerDirty )
+ return _rData.xComposer.is();
+ lcl_resetComposer( _rData );
+
+ try
+ {
+ ::rtl::OUString sStatement;
+ switch ( _rData.nCommandType )
+ {
+ case CommandType::COMMAND:
+ if ( _rData.bEscapeProcessing )
+ sStatement = _rData.sCommand;
+ // (in case of no escape processing we assume a not parseable statement)
+ break;
+
+ case CommandType::TABLE:
+ {
+ if ( !_rData.sCommand.getLength() )
+ break;
+
+ sStatement = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SELECT * FROM " ) );
+
+ ::rtl::OUString sCatalog, sSchema, sTable;
+ qualifiedNameComponents( _rData.xConnection->getMetaData(), _rData.sCommand, sCatalog, sSchema, sTable, eInDataManipulation );
+
+ sStatement += composeTableNameForSelect( _rData.xConnection, sCatalog, sSchema, sTable );
+ }
+ break;
+
+ case CommandType::QUERY:
+ {
+ // ask the connection for the query
+ Reference< XQueriesSupplier > xSupplyQueries( _rData.xConnection, UNO_QUERY_THROW );
+ Reference< XNameAccess > xQueries( xSupplyQueries->getQueries(), UNO_QUERY_THROW );
+
+ if ( !xQueries->hasByName( _rData.sCommand ) )
+ break;
+
+ Reference< XPropertySet > xQuery( xQueries->getByName( _rData.sCommand ), UNO_QUERY_THROW );
+
+ // a native query ?
+ sal_Bool bQueryEscapeProcessing = sal_False;
+ xQuery->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EscapeProcessing" ) ) ) >>= bQueryEscapeProcessing;
+ if ( !bQueryEscapeProcessing )
+ break;
+
+ // the command used by the query
+ xQuery->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Command" ) ) ) >>= sStatement;
+ if ( !sStatement.getLength() )
+ break;
+
+ // use a composer to build a statement from the query filter/order props
+ Reference< XMultiServiceFactory > xFactory( _rData.xConnection, UNO_QUERY_THROW );
+ ::utl::SharedUNOComponent< XSingleSelectQueryComposer > xComposer;
+ xComposer.set(
+ xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.SingleSelectQueryComposer" ) ) ),
+ UNO_QUERY_THROW
+ );
+
+ // the "basic" statement
+ xComposer->setElementaryQuery( sStatement );
+
+ // the sort order
+ const ::rtl::OUString sPropOrder( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Order" ) ) );
+ if ( ::comphelper::hasProperty( sPropOrder, xQuery ) )
+ {
+ ::rtl::OUString sOrder;
+ OSL_VERIFY( xQuery->getPropertyValue( sPropOrder ) >>= sOrder );
+ xComposer->setOrder( sOrder );
+ }
+
+ // the filter
+ sal_Bool bApplyFilter = sal_True;
+ const ::rtl::OUString sPropApply = ::rtl::OUString::createFromAscii( "ApplyFilter" );
+ if ( ::comphelper::hasProperty( sPropApply, xQuery ) )
+ {
+ OSL_VERIFY( xQuery->getPropertyValue( sPropApply ) >>= bApplyFilter );
+ }
+
+ if ( bApplyFilter )
+ {
+ ::rtl::OUString sFilter;
+ OSL_VERIFY( xQuery->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Filter" ) ) ) >>= sFilter );
+ xComposer->setFilter( sFilter );
+ }
+
+ // the composed statement
+ sStatement = xComposer->getQuery();
+ }
+ break;
+
+ default:
+ OSL_ENSURE(sal_False, "lcl_ensureUpToDateComposer_nothrow: no table, no query, no statement - what else ?!");
+ break;
+ }
+
+ if ( sStatement.getLength() )
+ {
+ // create an composer
+ Reference< XMultiServiceFactory > xFactory( _rData.xConnection, UNO_QUERY_THROW );
+ Reference< XSingleSelectQueryComposer > xComposer( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.SingleSelectQueryComposer" ) ) ),
+ UNO_QUERY_THROW );
+ xComposer->setElementaryQuery( sStatement );
+
+ // append sort/filter
+ xComposer->setOrder( _rData.sOrder );
+ xComposer->setFilter( _rData.sFilter );
+
+ sStatement = xComposer->getQuery();
+
+ _rData.xComposer = xComposer;
+ _rData.bComposerDirty = false;
+ }
+ }
+ catch( const SQLException& )
+ {
+ // allowed to leave here
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return _rData.xComposer.is();
+ }
+ }
+
+ //====================================================================
+ //= StatementComposer
+ //====================================================================
+ //--------------------------------------------------------------------
+ StatementComposer::StatementComposer( const Reference< XConnection >& _rxConnection,
+ const ::rtl::OUString& _rCommand, const sal_Int32 _nCommandType, const sal_Bool _bEscapeProcessing )
+ :m_pData( new StatementComposer_Data( _rxConnection ) )
+ {
+ OSL_PRECOND( _rxConnection.is(), "StatementComposer::StatementComposer: illegal connection!" );
+ m_pData->sCommand = _rCommand;
+ m_pData->nCommandType = _nCommandType;
+ m_pData->bEscapeProcessing = _bEscapeProcessing;
+ }
+
+ //--------------------------------------------------------------------
+ StatementComposer::~StatementComposer()
+ {
+ lcl_resetComposer( *m_pData );
+ }
+
+ //--------------------------------------------------------------------
+ void StatementComposer::setDisposeComposer( bool _bDoDispose )
+ {
+ m_pData->bDisposeComposer = _bDoDispose;
+ }
+
+ //--------------------------------------------------------------------
+ bool StatementComposer::getDisposeComposer() const
+ {
+ return m_pData->bDisposeComposer;
+ }
+
+ //--------------------------------------------------------------------
+ void StatementComposer::setFilter( const ::rtl::OUString& _rFilter )
+ {
+ m_pData->sFilter = _rFilter;
+ m_pData->bComposerDirty = true;
+ }
+
+ //--------------------------------------------------------------------
+ void StatementComposer::setOrder( const ::rtl::OUString& _rOrder )
+ {
+ m_pData->sOrder = _rOrder;
+ m_pData->bComposerDirty = true;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XSingleSelectQueryComposer > StatementComposer::getComposer()
+ {
+ lcl_ensureUpToDateComposer_nothrow( *m_pData );
+ return m_pData->xComposer;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString StatementComposer::getQuery()
+ {
+ if ( lcl_ensureUpToDateComposer_nothrow( *m_pData ) )
+ {
+ return m_pData->xComposer->getQuery();
+ }
+
+ return ::rtl::OUString();
+ }
+
+//........................................................................
+} // namespace dbtools
+//........................................................................
diff --git a/connectivity/source/commontools/warningscontainer.cxx b/connectivity/source/commontools/warningscontainer.cxx
new file mode 100644
index 000000000000..91890e8149df
--- /dev/null
+++ b/connectivity/source/commontools/warningscontainer.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 "connectivity/warningscontainer.hxx"
+#include "connectivity/dbexception.hxx"
+
+#include <osl/diagnose.h>
+
+//........................................................................
+namespace dbtools
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdb;
+
+ //====================================================================
+ //= WarningsContainer
+ //====================================================================
+ //--------------------------------------------------------------------
+ static void lcl_concatWarnings( Any& _rChainLeft, const Any& _rChainRight )
+ {
+ if ( !_rChainLeft.hasValue() )
+ _rChainLeft = _rChainRight;
+ else
+ {
+ // to travel the chain by reference (and not by value), we need the getValue ...
+ // looks like a hack, but the meaning of getValue is documented, and it's the only chance for reference-traveling ....
+
+ OSL_ENSURE( SQLExceptionInfo( _rChainLeft ).isValid(),
+ "lcl_concatWarnings: invalid warnings chain (this will crash)!" );
+
+ const SQLException* pChainTravel = static_cast< const SQLException* >( _rChainLeft.getValue() );
+ SQLExceptionIteratorHelper aReferenceIterHelper( *pChainTravel );
+ while ( aReferenceIterHelper.hasMoreElements() )
+ pChainTravel = aReferenceIterHelper.next();
+
+ // reached the end of the chain, and pChainTravel points to the last element
+ const_cast< SQLException* >( pChainTravel )->NextException = _rChainRight;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ WarningsContainer::~WarningsContainer()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void WarningsContainer::appendWarning(const SQLException& _rWarning)
+ {
+ lcl_concatWarnings( m_aOwnWarnings, makeAny( _rWarning ) );
+ }
+
+ //--------------------------------------------------------------------
+ void WarningsContainer::appendWarning( const SQLContext& _rContext )
+ {
+ lcl_concatWarnings( m_aOwnWarnings, makeAny( _rContext ));
+ }
+
+ //--------------------------------------------------------------------
+ void WarningsContainer::appendWarning(const SQLWarning& _rWarning)
+ {
+ lcl_concatWarnings( m_aOwnWarnings, makeAny( _rWarning ) );
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL WarningsContainer::getWarnings( ) const
+ {
+ Any aAllWarnings;
+ if ( m_xExternalWarnings.is() )
+ aAllWarnings = m_xExternalWarnings->getWarnings();
+
+ if ( m_aOwnWarnings.hasValue() )
+ lcl_concatWarnings( aAllWarnings, m_aOwnWarnings );
+
+ return aAllWarnings;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL WarningsContainer::clearWarnings( )
+ {
+ if ( m_xExternalWarnings.is() )
+ m_xExternalWarnings->clearWarnings();
+ m_aOwnWarnings.clear();
+ }
+
+ //--------------------------------------------------------------------
+ void WarningsContainer::appendWarning( const ::rtl::OUString& _rWarning, const sal_Char* _pAsciiSQLState, const Reference< XInterface >& _rxContext )
+ {
+ appendWarning( SQLWarning( _rWarning, _rxContext, ::rtl::OUString::createFromAscii( _pAsciiSQLState ), 0, Any() ) );
+ }
+
+//........................................................................
+} // namespace dbtools
+//........................................................................
diff --git a/connectivity/source/cpool/ZConnectionPool.cxx b/connectivity/source/cpool/ZConnectionPool.cxx
new file mode 100644
index 000000000000..a17538d921d1
--- /dev/null
+++ b/connectivity/source/cpool/ZConnectionPool.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 <stdio.h>
+#include "ZConnectionPool.hxx"
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/container/ElementExistException.hpp>
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+#include "ZPooledConnection.hxx"
+#include "ZPoolCollection.hxx"
+#ifndef _CONNECTIVITY_CONNECTIONWRAPPER_HXX_
+#include "connectivity/ConnectionWrapper.hxx"
+#endif
+#include <com/sun/star/beans/XPropertySet.hpp>
+#ifndef _CONNECTIVITY_CONNECTIONWRAPPER_HXX_
+#include "connectivity/ConnectionWrapper.hxx"
+#endif
+
+
+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 ::com::sun::star::container;
+using namespace ::osl;
+using namespace connectivity;
+
+#include <algorithm>
+
+//==========================================================================
+//= OPoolTimer
+//==========================================================================
+void SAL_CALL OPoolTimer::onShot()
+{
+ m_pPool->invalidatePooledConnections();
+}
+namespace
+{
+ //--------------------------------------------------------------------
+ static const ::rtl::OUString& getTimeoutNodeName()
+ {
+ static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("Timeout");
+ return s_sNodeName;
+ }
+
+}
+//==========================================================================
+//= OConnectionPool
+//==========================================================================
+//--------------------------------------------------------------------------
+OConnectionPool::OConnectionPool(const Reference< XDriver >& _xDriver,
+ const Reference< XInterface >& _xDriverNode,
+ const Reference< ::com::sun::star::reflection::XProxyFactory >& _rxProxyFactory)
+ :m_xDriver(_xDriver)
+ ,m_xDriverNode(_xDriverNode)
+ ,m_xProxyFactory(_rxProxyFactory)
+ ,m_nTimeOut(10)
+ ,m_nALiveCount(10)
+{
+ OSL_ENSURE(m_xDriverNode.is(),"NO valid Driver node set!");
+ Reference< XComponent > xComponent(m_xDriverNode, UNO_QUERY);
+ if (xComponent.is())
+ xComponent->addEventListener(this);
+
+ Reference<XPropertySet> xProp(m_xDriverNode,UNO_QUERY);
+ if(xProp.is())
+ xProp->addPropertyChangeListener(getTimeoutNodeName(),this);
+
+ OPoolCollection::getNodeValue(getTimeoutNodeName(),m_xDriverNode) >>= m_nALiveCount;
+ calculateTimeOuts();
+
+ m_xInvalidator = new OPoolTimer(this,::vos::TTimeValue(m_nTimeOut,0));
+ m_xInvalidator->start();
+}
+// -----------------------------------------------------------------------------
+OConnectionPool::~OConnectionPool()
+{
+ clear(sal_False);
+}
+// -----------------------------------------------------------------------------
+struct TRemoveEventListenerFunctor : ::std::unary_function<TPooledConnections::value_type,void>
+ ,::std::unary_function<TActiveConnectionMap::value_type,void>
+{
+ OConnectionPool* m_pConnectionPool;
+ sal_Bool m_bDispose;
+
+ TRemoveEventListenerFunctor(OConnectionPool* _pConnectionPool,sal_Bool _bDispose = sal_False)
+ : m_pConnectionPool(_pConnectionPool)
+ ,m_bDispose(_bDispose)
+ {
+ OSL_ENSURE(m_pConnectionPool,"No connection pool!");
+ }
+ // -----------------------------------------------------------------------------
+ void dispose(const Reference<XInterface>& _xComponent)
+ {
+ Reference< XComponent > xComponent(_xComponent, UNO_QUERY);
+
+ if ( xComponent.is() )
+ {
+ xComponent->removeEventListener(m_pConnectionPool);
+ if ( m_bDispose )
+ xComponent->dispose();
+ }
+ }
+ // -----------------------------------------------------------------------------
+ void operator()(const TPooledConnections::value_type& _aValue)
+ {
+ dispose(_aValue);
+ }
+ // -----------------------------------------------------------------------------
+ void operator()(const TActiveConnectionMap::value_type& _aValue)
+ {
+ dispose(_aValue.first);
+ }
+};
+// -----------------------------------------------------------------------------
+struct TConnectionPoolFunctor : ::std::unary_function<TConnectionMap::value_type,void>
+{
+ OConnectionPool* m_pConnectionPool;
+
+ TConnectionPoolFunctor(OConnectionPool* _pConnectionPool)
+ : m_pConnectionPool(_pConnectionPool)
+ {
+ OSL_ENSURE(m_pConnectionPool,"No connection pool!");
+ }
+ void operator()(const TConnectionMap::value_type& _aValue)
+ {
+ ::std::for_each(_aValue.second.aConnections.begin(),_aValue.second.aConnections.end(),TRemoveEventListenerFunctor(m_pConnectionPool,sal_True));
+ }
+};
+// -----------------------------------------------------------------------------
+void OConnectionPool::clear(sal_Bool _bDispose)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ if(m_xInvalidator->isTicking())
+ m_xInvalidator->stop();
+
+ ::std::for_each(m_aPool.begin(),m_aPool.end(),TConnectionPoolFunctor(this));
+ m_aPool.clear();
+
+ ::std::for_each(m_aActiveConnections.begin(),m_aActiveConnections.end(),TRemoveEventListenerFunctor(this,_bDispose));
+ m_aActiveConnections.clear();
+
+ Reference< XComponent > xComponent(m_xDriverNode, UNO_QUERY);
+ if (xComponent.is())
+ xComponent->removeEventListener(this);
+ Reference< XPropertySet > xProp(m_xDriverNode, UNO_QUERY);
+ if (xProp.is())
+ xProp->removePropertyChangeListener(getTimeoutNodeName(),this);
+
+m_xDriverNode.clear();
+m_xDriver.clear();
+}
+//--------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL OConnectionPool::getConnectionWithInfo( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _rInfo ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ Reference<XConnection> xConnection;
+
+ // create a unique id and look for it in our map
+ Sequence< PropertyValue > aInfo(_rInfo);
+ TConnectionMap::key_type nId;
+ OConnectionWrapper::createUniqueId(_rURL,aInfo,nId.m_pBuffer);
+ TConnectionMap::iterator aIter = m_aPool.find(nId);
+
+ if ( m_aPool.end() != aIter )
+ xConnection = getPooledConnection(aIter);
+
+ if ( !xConnection.is() )
+ xConnection = createNewConnection(_rURL,_rInfo);
+
+ return xConnection;
+}
+//--------------------------------------------------------------------------
+void SAL_CALL OConnectionPool::disposing( const ::com::sun::star::lang::EventObject& Source ) throw (RuntimeException)
+{
+ Reference<XConnection> xConnection(Source.Source,UNO_QUERY);
+ if(xConnection.is())
+ {
+ MutexGuard aGuard(m_aMutex);
+ TActiveConnectionMap::iterator aIter = m_aActiveConnections.find(xConnection);
+ OSL_ENSURE(aIter != m_aActiveConnections.end(),"OConnectionPool::disposing: Conenction wasn't in pool");
+ if(aIter != m_aActiveConnections.end())
+ { // move the pooled connection back to the pool
+ aIter->second.aPos->second.nALiveCount = m_nALiveCount;
+ aIter->second.aPos->second.aConnections.push_back(aIter->second.xPooledConnection);
+ m_aActiveConnections.erase(aIter);
+ }
+ }
+ else
+ {
+ m_xDriverNode.clear();
+ }
+}
+// -----------------------------------------------------------------------------
+Reference< XConnection> OConnectionPool::createNewConnection(const ::rtl::OUString& _rURL,const Sequence< PropertyValue >& _rInfo)
+{
+ // create new pooled conenction
+ Reference< XPooledConnection > xPooledConnection = new ::connectivity::OPooledConnection(m_xDriver->connect(_rURL,_rInfo),m_xProxyFactory);
+ // get the new connection from the pooled connection
+ Reference<XConnection> xConnection = xPooledConnection->getConnection();
+ if(xConnection.is())
+ {
+ // add our own as dispose listener to know when we should put the connection back to the pool
+ Reference< XComponent > xComponent(xConnection, UNO_QUERY);
+ if (xComponent.is())
+ xComponent->addEventListener(this);
+
+ // save some information to find the right pool later on
+ Sequence< PropertyValue > aInfo(_rInfo);
+ TConnectionMap::key_type nId;
+ OConnectionWrapper::createUniqueId(_rURL,aInfo,nId.m_pBuffer);
+ TConnectionPool aPack;
+
+ // insert the new connection and struct into the active connection map
+ aPack.nALiveCount = m_nALiveCount;
+ TActiveConnectionInfo aActiveInfo;
+ aActiveInfo.aPos = m_aPool.insert(TConnectionMap::value_type(nId,aPack)).first;
+ aActiveInfo.xPooledConnection = xPooledConnection;
+ m_aActiveConnections.insert(TActiveConnectionMap::value_type(xConnection,aActiveInfo));
+
+ if(m_xInvalidator->isExpired())
+ m_xInvalidator->start();
+ }
+
+ return xConnection;
+}
+// -----------------------------------------------------------------------------
+void OConnectionPool::invalidatePooledConnections()
+{
+ MutexGuard aGuard(m_aMutex);
+ TConnectionMap::iterator aIter = m_aPool.begin();
+ for (; aIter != m_aPool.end(); )
+ {
+ if(!(--(aIter->second.nALiveCount))) // connections are invalid
+ {
+ ::std::for_each(aIter->second.aConnections.begin(),aIter->second.aConnections.end(),TRemoveEventListenerFunctor(this,sal_True));
+
+ aIter->second.aConnections.clear();
+
+ // look if the iterator aIter is still present in the active connection map
+ TActiveConnectionMap::iterator aActIter = m_aActiveConnections.begin();
+ for (; aActIter != m_aActiveConnections.end(); ++aActIter)
+ {
+ if(aIter == aActIter->second.aPos)
+ break;
+ }
+ if(aActIter == m_aActiveConnections.end())
+ {// he isn't so we can delete him
+ TConnectionMap::iterator aDeleteIter = aIter;
+ ++aIter;
+ m_aPool.erase(aDeleteIter);
+ }
+ else
+ ++aIter;
+ }
+ else
+ ++aIter;
+ }
+ if(!m_aPool.empty())
+ m_xInvalidator->start();
+}
+// -----------------------------------------------------------------------------
+Reference< XConnection> OConnectionPool::getPooledConnection(TConnectionMap::iterator& _rIter)
+{
+ Reference<XConnection> xConnection;
+
+ if(!_rIter->second.aConnections.empty())
+ {
+ Reference< XPooledConnection > xPooledConnection = _rIter->second.aConnections.back();
+ _rIter->second.aConnections.pop_back();
+
+ OSL_ENSURE(xPooledConnection.is(),"Can not be null here!");
+ xConnection = xPooledConnection->getConnection();
+ Reference< XComponent > xComponent(xConnection, UNO_QUERY);
+ if (xComponent.is())
+ xComponent->addEventListener(this);
+
+ TActiveConnectionInfo aActiveInfo;
+ aActiveInfo.aPos = _rIter;
+ aActiveInfo.xPooledConnection = xPooledConnection;
+ m_aActiveConnections[xConnection] = aActiveInfo;
+ }
+ return xConnection;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OConnectionPool::propertyChange( const PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException)
+{
+ if(getTimeoutNodeName() == evt.PropertyName)
+ {
+ evt.NewValue >>= m_nALiveCount;
+ calculateTimeOuts();
+ }
+}
+// -----------------------------------------------------------------------------
+void OConnectionPool::calculateTimeOuts()
+{
+ sal_Int32 nTimeOutCorrection = 10;
+ if(m_nALiveCount < 100)
+ nTimeOutCorrection = 20;
+
+ m_nTimeOut = m_nALiveCount / nTimeOutCorrection;
+ m_nALiveCount = m_nALiveCount / m_nTimeOut;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/cpool/ZConnectionPool.hxx b/connectivity/source/cpool/ZConnectionPool.hxx
new file mode 100644
index 000000000000..1e521829f412
--- /dev/null
+++ b/connectivity/source/cpool/ZConnectionPool.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef _CONNECTIVITY_ZCONNECTIONPOOL_HXX_
+#define _CONNECTIVITY_ZCONNECTIONPOOL_HXX_
+
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/sdbc/XPooledConnection.hpp>
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/reflection/XProxyFactory.hpp>
+#include <cppuhelper/weakref.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <comphelper/stl_types.hxx>
+#include <osl/mutex.hxx>
+#include <vos/timer.hxx>
+#include <vos/ref.hxx>
+#include <rtl/digest.h>
+
+namespace connectivity
+{
+ class OConnectionPool;
+ //==========================================================================
+ /// OPoolTimer - Invalidates the connection pool
+ //==========================================================================
+ class OPoolTimer : public ::vos::OTimer
+ {
+ OConnectionPool* m_pPool;
+ public:
+ OPoolTimer(OConnectionPool* _pPool,const ::vos::TTimeValue& _Time)
+ : ::vos::OTimer(_Time)
+ ,m_pPool(_pPool)
+ {}
+ protected:
+ virtual void SAL_CALL onShot();
+ };
+
+ //==========================================================================
+ //= OConnectionPool - the one-instance service for PooledConnections
+ //= manages the active connections and the connections in the pool
+ //==========================================================================
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::beans::XPropertyChangeListener> OConnectionPool_Base;
+
+ // typedef for the interanl structure
+ typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPooledConnection> > TPooledConnections;
+
+ // contains the currently pooled connections
+ typedef struct
+ {
+ TPooledConnections aConnections;
+ sal_Int32 nALiveCount; // will be decremented everytime a time says to, when will reach zero the pool will be deleted
+ } TConnectionPool;
+
+ struct TDigestHolder
+ {
+ sal_uInt8 m_pBuffer[RTL_DIGEST_LENGTH_SHA1];
+ TDigestHolder()
+ {
+ m_pBuffer[0] = 0;
+ }
+
+ };
+
+ // typedef TDigestHolder
+
+ struct TDigestLess : public ::std::binary_function< TDigestHolder, TDigestHolder, bool>
+ {
+ bool operator() (const TDigestHolder& x, const TDigestHolder& y) const
+ {
+ sal_uInt32 i;
+ for(i=0;i < RTL_DIGEST_LENGTH_SHA1 && (x.m_pBuffer[i] >= y.m_pBuffer[i]); ++i)
+ ;
+ return i < RTL_DIGEST_LENGTH_SHA1;
+ }
+ };
+
+ typedef ::std::map< TDigestHolder,TConnectionPool,TDigestLess> TConnectionMap;
+
+ // contains additional information about a activeconnection which is needed to put it back to the pool
+ typedef struct
+ {
+ TConnectionMap::iterator aPos;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPooledConnection> xPooledConnection;
+ } TActiveConnectionInfo;
+
+ typedef ::std::map< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>,
+ TActiveConnectionInfo> TActiveConnectionMap;
+
+ class OConnectionPool : public OConnectionPool_Base
+ {
+ TConnectionMap m_aPool; // the pooled connections
+ TActiveConnectionMap m_aActiveConnections; // the currently active connections
+
+ ::osl::Mutex m_aMutex;
+ ::vos::ORef<OPoolTimer> m_xInvalidator; // invalidates the conntection pool when shot
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > m_xDriver; // the one and only driver for this connectionpool
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xDriverNode; // config node entry
+ ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XProxyFactory > m_xProxyFactory;
+ sal_Int32 m_nTimeOut;
+ sal_Int32 m_nALiveCount;
+
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> createNewConnection(const ::rtl::OUString& _rURL,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo);
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getPooledConnection(TConnectionMap::iterator& _rIter);
+ // calculate the timeout and the corresponding ALiveCount
+ void calculateTimeOuts();
+
+ protected:
+ // the dtor will be called from the last instance (last release call)
+ virtual ~OConnectionPool();
+ public:
+ OConnectionPool(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver >& _xDriver,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xDriverNode,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XProxyFactory >& _rxProxyFactory);
+
+ // delete all refs
+ void clear(sal_Bool _bDispose);
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnectionWithInfo( 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);
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
+
+ void invalidatePooledConnections();
+ };
+}
+#endif // _CONNECTIVITY_ZCONNECTIONPOOL_HXX_
+
+
diff --git a/connectivity/source/cpool/ZConnectionWrapper.cxx b/connectivity/source/cpool/ZConnectionWrapper.cxx
new file mode 100644
index 000000000000..b850601e4389
--- /dev/null
+++ b/connectivity/source/cpool/ZConnectionWrapper.cxx
@@ -0,0 +1,258 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ZConnectionWrapper.hxx"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/extract.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+
+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;
+// --------------------------------------------------------------------------------
+OConnectionWeakWrapper::OConnectionWeakWrapper(Reference< XAggregation >& _xConnection)
+ : OConnectionWeakWrapper_BASE(m_aMutex)
+{
+ setDelegation(_xConnection,m_refCount);
+ OSL_ENSURE(m_xConnection.is(),"OConnectionWeakWrapper: Connection must be valid!");
+}
+//-----------------------------------------------------------------------------
+OConnectionWeakWrapper::~OConnectionWeakWrapper()
+{
+ if ( !OConnectionWeakWrapper_BASE::rBHelper.bDisposed )
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ dispose();
+ }
+}
+// XServiceInfo
+// --------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OConnectionWeakWrapper, "com.sun.star.sdbc.drivers.OConnectionWeakWrapper", "com.sun.star.sdbc.Connection")
+
+// --------------------------------------------------------------------------------
+Reference< XStatement > SAL_CALL OConnectionWeakWrapper::createStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
+
+
+ return m_xConnection->createStatement();
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OConnectionWeakWrapper::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
+
+
+ return m_xConnection->prepareStatement(sql);
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OConnectionWeakWrapper::prepareCall( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
+
+
+ return m_xConnection->prepareCall(sql);
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConnectionWeakWrapper::nativeSQL( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
+
+
+ return m_xConnection->nativeSQL(sql);
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnectionWeakWrapper::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
+
+ m_xConnection->setAutoCommit(autoCommit);
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnectionWeakWrapper::getAutoCommit( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
+
+
+ return m_xConnection->getAutoCommit();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnectionWeakWrapper::commit( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
+
+
+ m_xConnection->commit();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnectionWeakWrapper::rollback( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
+
+
+ m_xConnection->rollback();
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnectionWeakWrapper::isClosed( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return m_xConnection->isClosed();
+}
+// --------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL OConnectionWeakWrapper::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
+
+
+ return m_xConnection->getMetaData();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnectionWeakWrapper::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
+
+
+ m_xConnection->setReadOnly(readOnly);
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnectionWeakWrapper::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
+
+
+ return m_xConnection->isReadOnly();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnectionWeakWrapper::setCatalog( const ::rtl::OUString& catalog ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
+
+
+ m_xConnection->setCatalog(catalog);
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConnectionWeakWrapper::getCatalog( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
+
+
+ return m_xConnection->getCatalog();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnectionWeakWrapper::setTransactionIsolation( sal_Int32 level ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
+
+
+ m_xConnection->setTransactionIsolation(level);
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OConnectionWeakWrapper::getTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
+
+
+ return m_xConnection->getTransactionIsolation();
+}
+// --------------------------------------------------------------------------------
+Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OConnectionWeakWrapper::getTypeMap( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
+
+
+ return m_xConnection->getTypeMap();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnectionWeakWrapper::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
+
+
+ m_xConnection->setTypeMap(typeMap);
+}
+// --------------------------------------------------------------------------------
+// XCloseable
+void SAL_CALL OConnectionWeakWrapper::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnectionWeakWrapper_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+//------------------------------------------------------------------------------
+void OConnectionWeakWrapper::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ OConnectionWeakWrapper_BASE::disposing();
+ OConnectionWrapper::disposing();
+}
+// -----------------------------------------------------------------------------
+// com::sun::star::lang::XUnoTunnel
+#ifdef N_DEBUG
+IMPLEMENT_FORWARD_XINTERFACE2(OConnectionWeakWrapper,OConnectionWeakWrapper_BASE,OConnectionWrapper)
+#else
+IMPLEMENT_FORWARD_REFCOUNT( OConnectionWeakWrapper, OConnectionWeakWrapper_BASE ) \
+::com::sun::star::uno::Any SAL_CALL OConnectionWeakWrapper::queryInterface( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException) \
+{ \
+ ::com::sun::star::uno::Any aReturn = OConnectionWeakWrapper_BASE::queryInterface( _rType ); \
+ if ( !aReturn.hasValue() ) \
+ aReturn = OConnectionWrapper::queryInterface( _rType ); \
+ return aReturn; \
+}
+#endif
+IMPLEMENT_FORWARD_XTYPEPROVIDER2(OConnectionWeakWrapper,OConnectionWeakWrapper_BASE,OConnectionWrapper)
+
+
diff --git a/connectivity/source/cpool/ZConnectionWrapper.hxx b/connectivity/source/cpool/ZConnectionWrapper.hxx
new file mode 100644
index 000000000000..770986230f17
--- /dev/null
+++ b/connectivity/source/cpool/ZConnectionWrapper.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_ZCONNECTIONWEAKWRAPPER_HXX_
+#define _CONNECTIVITY_ZCONNECTIONWEAKWRAPPER_HXX_
+
+#include <cppuhelper/compbase1.hxx>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/uno3.hxx>
+#include "connectivity/ConnectionWrapper.hxx"
+
+namespace connectivity
+{
+
+ //==========================================================================
+ //= OConnectionWeakWrapper - wraps all methods to the real connection from the driver
+ //= but when disposed it doesn't dispose the real connection
+ //==========================================================================
+ typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::sdbc::XConnection
+ > OConnectionWeakWrapper_BASE;
+
+ class OConnectionWeakWrapper : public ::comphelper::OBaseMutex
+ ,public OConnectionWeakWrapper_BASE
+ , public OConnectionWrapper
+ {
+ protected:
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ virtual ~OConnectionWeakWrapper();
+ public:
+ OConnectionWeakWrapper(::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >& _xConnection);
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO();
+ DECLARE_XTYPEPROVIDER()
+ DECLARE_XINTERFACE( )
+
+ // 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);
+ };
+}
+#endif // _CONNECTIVITY_ZCONNECTIONWEAKWRAPPER_HXX_
+
diff --git a/connectivity/source/cpool/ZDriverWrapper.cxx b/connectivity/source/cpool/ZDriverWrapper.cxx
new file mode 100644
index 000000000000..fda9807cffec
--- /dev/null
+++ b/connectivity/source/cpool/ZDriverWrapper.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 "ZDriverWrapper.hxx"
+#include "ZConnectionPool.hxx"
+#include <osl/diagnose.h>
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::beans;
+
+ //====================================================================
+ //= ODriverWrapper
+ //====================================================================
+ //--------------------------------------------------------------------
+ ODriverWrapper::ODriverWrapper( Reference< XAggregation >& _rxAggregateDriver, OConnectionPool* _pPool )
+ :m_pConnectionPool(_pPool)
+ {
+ OSL_ENSURE(_rxAggregateDriver.is(), "ODriverWrapper::ODriverWrapper: invalid aggregate!");
+ OSL_ENSURE(m_pConnectionPool, "ODriverWrapper::ODriverWrapper: invalid connection pool!");
+
+ if (m_pConnectionPool)
+ m_pConnectionPool->acquire();
+
+ osl_incrementInterlockedCount( &m_refCount );
+ if (_rxAggregateDriver.is())
+ {
+ // transfer the (one and only) real ref to the aggregate to our member
+ m_xDriverAggregate = _rxAggregateDriver;
+ _rxAggregateDriver = NULL;
+
+ // a second "real" reference
+ m_xDriver = Reference< XDriver >(m_xDriverAggregate, UNO_QUERY);
+ OSL_ENSURE(m_xDriver.is(), "ODriverWrapper::ODriverWrapper: invalid aggregate (no XDriver)!");
+
+ // set ourself as delegator
+ m_xDriverAggregate->setDelegator( static_cast< XWeak* >( this ) );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ ODriverWrapper::~ODriverWrapper()
+ {
+ if (m_xDriverAggregate.is())
+ m_xDriverAggregate->setDelegator(NULL);
+
+ if (m_pConnectionPool)
+ m_pConnectionPool->release();
+ m_pConnectionPool = NULL;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL ODriverWrapper::queryInterface( const Type& _rType ) throw (RuntimeException)
+ {
+ Any aReturn = ODriverWrapper_BASE::queryInterface(_rType);
+ return aReturn.hasValue() ? aReturn : (m_xDriverAggregate.is() ? m_xDriverAggregate->queryAggregation(_rType) : aReturn);
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XConnection > SAL_CALL ODriverWrapper::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw (SQLException, RuntimeException)
+ {
+ Reference< XConnection > xConnection;
+ if (m_pConnectionPool)
+ // route this through the pool
+ xConnection = m_pConnectionPool->getConnectionWithInfo( url, info );
+ else if (m_xDriver.is())
+ xConnection = m_xDriver->connect( url, info );
+
+ return xConnection;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL ODriverWrapper::acceptsURL( const ::rtl::OUString& url ) throw (SQLException, RuntimeException)
+ {
+ return m_xDriver.is() && m_xDriver->acceptsURL(url);
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< DriverPropertyInfo > SAL_CALL ODriverWrapper::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw (SQLException, RuntimeException)
+ {
+ Sequence< DriverPropertyInfo > aInfo;
+ if (m_xDriver.is())
+ aInfo = m_xDriver->getPropertyInfo(url, info);
+ return aInfo;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 SAL_CALL ODriverWrapper::getMajorVersion( ) throw (RuntimeException)
+ {
+ return m_xDriver.is() ? m_xDriver->getMajorVersion() : 0;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 SAL_CALL ODriverWrapper::getMinorVersion( ) throw (RuntimeException)
+ {
+ return m_xDriver.is() ? m_xDriver->getMinorVersion() : 0;
+ }
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
+
diff --git a/connectivity/source/cpool/ZDriverWrapper.hxx b/connectivity/source/cpool/ZDriverWrapper.hxx
new file mode 100644
index 000000000000..c4cc0fedf7d1
--- /dev/null
+++ b/connectivity/source/cpool/ZDriverWrapper.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_CPOOL_ZDRIVERWRAPPER_HXX_
+#define _CONNECTIVITY_CPOOL_ZDRIVERWRAPPER_HXX_
+
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <osl/mutex.hxx>
+#include <com/sun/star/uno/XAggregation.hpp>
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ class OConnectionPool;
+ //====================================================================
+ //= ODriverWrapper
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::sdbc::XDriver
+ > ODriverWrapper_BASE;
+
+ class ODriverWrapper : public ODriverWrapper_BASE
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >
+ m_xDriverAggregate;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver >
+ m_xDriver;
+ OConnectionPool* m_pConnectionPool;
+
+ public:
+ /** creates a new wrapper for a driver
+ @param _rxAggregateDriver
+ the driver to aggregate. The object will be reset to <NULL/> when returning from the ctor.
+ */
+ ODriverWrapper(
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >& _rxAggregateDriver,
+ OConnectionPool* _pPool
+ );
+
+
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ /// dtor
+ virtual ~ODriverWrapper();
+ // 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);
+ };
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
+#endif // _CONNECTIVITY_CPOOL_ZDRIVERWRAPPER_HXX_
+
+
diff --git a/connectivity/source/cpool/ZPoolCollection.cxx b/connectivity/source/cpool/ZPoolCollection.cxx
new file mode 100644
index 000000000000..71180220b9c2
--- /dev/null
+++ b/connectivity/source/cpool/ZPoolCollection.cxx
@@ -0,0 +1,581 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ZPoolCollection.hxx"
+#include "ZDriverWrapper.hxx"
+#include "ZConnectionPool.hxx"
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <comphelper/extract.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "diagnose_ex.h"
+
+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 ::com::sun::star::container;
+using namespace ::com::sun::star::reflection;
+using namespace ::osl;
+using namespace connectivity;
+
+//--------------------------------------------------------------------
+static const ::rtl::OUString& getConnectionPoolNodeName()
+{
+ static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("org.openoffice.Office.DataAccess/ConnectionPool");
+ return s_sNodeName;
+}
+//--------------------------------------------------------------------
+static const ::rtl::OUString& getEnablePoolingNodeName()
+{
+ static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("EnablePooling");
+ return s_sNodeName;
+}
+//--------------------------------------------------------------------
+static const ::rtl::OUString& getDriverNameNodeName()
+{
+ static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("DriverName");
+ return s_sNodeName;
+}
+// -----------------------------------------------------------------------------
+static const ::rtl::OUString& getDriverSettingsNodeName()
+{
+ static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("DriverSettings");
+ return s_sNodeName;
+}
+//--------------------------------------------------------------------------
+static const ::rtl::OUString& getEnableNodeName()
+{
+ static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("Enable");
+ return s_sNodeName;
+}
+
+//--------------------------------------------------------------------
+OPoolCollection::OPoolCollection(const Reference< XMultiServiceFactory >& _rxFactory)
+ :m_xServiceFactory(_rxFactory)
+{
+ // bootstrap all objects supporting the .sdb.Driver service
+ m_xManager = Reference< XDriverManager >(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.sdbc.DriverManager") ), UNO_QUERY);
+ m_xDriverAccess = Reference< XDriverAccess >(m_xManager, UNO_QUERY);
+ OSL_ENSURE(m_xDriverAccess.is(), "have no (or an invalid) driver manager!");
+
+ m_xProxyFactory = Reference< XProxyFactory >(
+ m_xServiceFactory->createInstance(
+ ::rtl::OUString::createFromAscii("com.sun.star.reflection.ProxyFactory")),
+ UNO_QUERY);
+ OSL_ENSURE(m_xProxyFactory.is(), "OConnectionPool::OConnectionPool: could not create a proxy factory!");
+
+ Reference<XPropertySet> xProp(getConfigPoolRoot(),UNO_QUERY);
+ if ( xProp.is() )
+ xProp->addPropertyChangeListener(getEnablePoolingNodeName(),this);
+ // attach as desktop listener to know when we have to release our pools
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+
+ m_xDesktop = Reference< ::com::sun::star::frame::XDesktop>( m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop") ), UNO_QUERY);
+ if ( m_xDesktop.is() )
+ m_xDesktop->addTerminateListener(this);
+
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// -----------------------------------------------------------------------------
+OPoolCollection::~OPoolCollection()
+{
+ clearConnectionPools(sal_False);
+}
+// -----------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL OPoolCollection::getConnection( const ::rtl::OUString& _rURL ) throw(SQLException, RuntimeException)
+{
+ return getConnectionWithInfo(_rURL,Sequence< PropertyValue >());
+}
+// -----------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL OPoolCollection::getConnectionWithInfo( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _rInfo ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ Reference< XConnection > xConnection;
+ Reference< XDriver > xDriver;
+ Reference< XInterface > xDriverNode;
+ ::rtl::OUString sImplName;
+ if(isPoolingEnabledByUrl(_rURL,xDriver,sImplName,xDriverNode) && xDriver.is())
+ {
+ OConnectionPool* pConnectionPool = getConnectionPool(sImplName,xDriver,xDriverNode);
+
+ if(pConnectionPool)
+ xConnection = pConnectionPool->getConnectionWithInfo(_rURL,_rInfo);
+ }
+ else if(xDriver.is())
+ xConnection = xDriver->connect(_rURL,_rInfo);
+
+ return xConnection;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OPoolCollection::setLoginTimeout( sal_Int32 seconds ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ m_xManager->setLoginTimeout(seconds);
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OPoolCollection::getLoginTimeout( ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ return m_xManager->getLoginTimeout();
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OPoolCollection::getImplementationName( ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ return getImplementationName_Static();
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL OPoolCollection::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 OPoolCollection::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+//---------------------------------------OPoolCollection----------------------------------
+Reference< XInterface > SAL_CALL OPoolCollection::CreateInstance(const Reference< XMultiServiceFactory >& _rxFactory)
+{
+ return static_cast<XDriverManager*>(new OPoolCollection(_rxFactory));
+}
+
+//--------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OPoolCollection::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbc.OConnectionPool");
+}
+
+//--------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OPoolCollection::getSupportedServiceNames_Static( ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ConnectionPool");
+ return aSupported;
+}
+// -----------------------------------------------------------------------------
+Reference< XDriver > SAL_CALL OPoolCollection::getDriverByURL( const ::rtl::OUString& _rURL ) throw(RuntimeException)
+{
+ // returns the original driver when no connection pooling is enabled else it returns the proxy
+ MutexGuard aGuard(m_aMutex);
+
+ Reference< XDriver > xDriver;
+ Reference< XInterface > xDriverNode;
+ ::rtl::OUString sImplName;
+ if(isPoolingEnabledByUrl(_rURL,xDriver,sImplName,xDriverNode))
+ {
+ Reference< XDriver > xExistentProxy;
+ // look if we already have a proxy for this driver
+ for ( ConstMapDriver2DriverRefIterator aLookup = m_aDriverProxies.begin();
+ aLookup != m_aDriverProxies.end();
+ ++aLookup
+ )
+ {
+ // hold the proxy alive as long as we're in this loop round
+ xExistentProxy = aLookup->second;
+
+ if (xExistentProxy.is() && (aLookup->first.get() == xDriver.get()))
+ // already created a proxy for this
+ break;
+ }
+ if (xExistentProxy.is())
+ {
+ xDriver = xExistentProxy;
+ }
+ else
+ { // create a new proxy for the driver
+ // this allows us to control the connections created by it
+ if (m_xProxyFactory.is())
+ {
+ Reference< XAggregation > xDriverProxy = m_xProxyFactory->createProxy(xDriver.get());
+ OSL_ENSURE(xDriverProxy.is(), "OConnectionPool::getDriverByURL: invalid proxy returned by the proxy factory!");
+
+ OConnectionPool* pConnectionPool = getConnectionPool(sImplName,xDriver,xDriverNode);
+ xDriver = new ODriverWrapper(xDriverProxy, pConnectionPool);
+ }
+ else
+ OSL_ENSURE(sal_False, "OConnectionPool::getDriverByURL: could not instantiate a proxy factory!");
+ }
+ }
+
+ return xDriver;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OPoolCollection::isDriverPoolingEnabled(const ::rtl::OUString& _sDriverImplName,
+ Reference< XInterface >& _rxDriverNode)
+{
+ sal_Bool bEnabled = sal_False;
+ Reference<XInterface> xConnectionPoolRoot = getConfigPoolRoot();
+ // then look for which of them settings are stored in the configuration
+ Reference< XNameAccess > xDirectAccess(openNode(getDriverSettingsNodeName(),xConnectionPoolRoot),UNO_QUERY);
+
+ if(xDirectAccess.is())
+ {
+ Sequence< ::rtl::OUString > aDriverKeys = xDirectAccess->getElementNames();
+ const ::rtl::OUString* pDriverKeys = aDriverKeys.getConstArray();
+ const ::rtl::OUString* pDriverKeysEnd = pDriverKeys + aDriverKeys.getLength();
+ for (;pDriverKeys != pDriverKeysEnd; ++pDriverKeys)
+ {
+ // the name of the driver in this round
+ if(_sDriverImplName == *pDriverKeys)
+ {
+ _rxDriverNode = openNode(*pDriverKeys,xDirectAccess);
+ if(_rxDriverNode.is())
+ getNodeValue(getEnableNodeName(),_rxDriverNode) >>= bEnabled;
+ break;
+ }
+ }
+ }
+ return bEnabled;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OPoolCollection::isPoolingEnabled()
+{
+ // the config node where all pooling relevant info are stored under
+ Reference<XInterface> xConnectionPoolRoot = getConfigPoolRoot();
+
+ // the global "enabled" flag
+ sal_Bool bEnabled = sal_False;
+ if(xConnectionPoolRoot.is())
+ getNodeValue(getEnablePoolingNodeName(),xConnectionPoolRoot) >>= bEnabled;
+ return bEnabled;
+}
+// -----------------------------------------------------------------------------
+Reference<XInterface> OPoolCollection::getConfigPoolRoot()
+{
+ if(!m_xConfigNode.is())
+ m_xConfigNode = createWithServiceFactory(getConnectionPoolNodeName());
+ return m_xConfigNode;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OPoolCollection::isPoolingEnabledByUrl(const ::rtl::OUString& _sUrl,
+ Reference< XDriver >& _rxDriver,
+ ::rtl::OUString& _rsImplName,
+ Reference< XInterface >& _rxDriverNode)
+{
+ sal_Bool bEnabled = sal_False;
+ if (m_xDriverAccess.is())
+ {
+ _rxDriver = m_xDriverAccess->getDriverByURL(_sUrl);
+ if (_rxDriver.is() && isPoolingEnabled())
+ {
+ Reference< XServiceInfo > xSerivceInfo(_rxDriver,UNO_QUERY);
+ OSL_ENSURE(xSerivceInfo.is(),"Each driver should have a XServiceInfo interface!");
+
+ if(xSerivceInfo.is())
+ {
+ // look for the implementation name of the driver
+ _rsImplName = xSerivceInfo->getImplementationName();
+ bEnabled = isDriverPoolingEnabled(_rsImplName,_rxDriverNode);
+ }
+ }
+ }
+ return bEnabled;
+}
+// -----------------------------------------------------------------------------
+void OPoolCollection::clearConnectionPools(sal_Bool _bDispose)
+{
+ OConnectionPools::const_iterator aIter = m_aPools.begin();
+ while(aIter != m_aPools.end())
+ {
+ aIter->second->clear(_bDispose);
+ aIter->second->release();
+ ::rtl::OUString sKeyValue = aIter->first;
+ ++aIter;
+ m_aPools.erase(sKeyValue);
+ }
+}
+// -----------------------------------------------------------------------------
+OConnectionPool* OPoolCollection::getConnectionPool(const ::rtl::OUString& _sImplName,
+ const Reference< XDriver >& _xDriver,
+ const Reference< XInterface >& _xDriverNode)
+{
+ OConnectionPool *pRet = 0;
+ OConnectionPools::const_iterator aFind = m_aPools.find(_sImplName);
+ if (aFind != m_aPools.end())
+ pRet = aFind->second;
+ else if (_xDriver.is() && _xDriverNode.is())
+ {
+ Reference<XPropertySet> xProp(_xDriverNode,UNO_QUERY);
+ if(xProp.is())
+ xProp->addPropertyChangeListener(getEnableNodeName(),this);
+ OConnectionPool* pConnectionPool = new OConnectionPool(_xDriver,_xDriverNode,m_xProxyFactory);
+ pConnectionPool->acquire();
+ aFind = m_aPools.insert(OConnectionPools::value_type(_sImplName,pConnectionPool)).first;
+ pRet = aFind->second;
+ }
+
+ OSL_ENSURE(pRet, "Could not query DriverManager from ConnectionPool!");
+
+ return pRet;
+}
+// -----------------------------------------------------------------------------
+Reference< XInterface > OPoolCollection::createWithServiceFactory(const ::rtl::OUString& _rPath) const
+{
+ Reference< XInterface > xInterface;
+ try
+ {
+ Reference< XInterface > xProvider = m_xServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider")));
+ OSL_ENSURE(xProvider.is(), "OConfigurationTreeRoot::createWithServiceFactory: could not instantiate the config provider service!");
+ Reference< XMultiServiceFactory > xProviderAsFac(xProvider, UNO_QUERY);
+ OSL_ENSURE(xProviderAsFac.is() || !xProvider.is(), "OConfigurationTreeRoot::createWithServiceFactory: the provider is missing an interface!");
+ if (xProviderAsFac.is())
+ xInterface = createWithProvider(xProviderAsFac, _rPath);
+ }
+ catch(const Exception&)
+ {
+ OSL_ENSURE(sal_False, "createWithServiceFactory: error while instantiating the provider service!");
+ }
+ return xInterface;
+}
+//------------------------------------------------------------------------
+Reference< XInterface > OPoolCollection::createWithProvider(const Reference< XMultiServiceFactory >& _rxConfProvider,
+ const ::rtl::OUString& _rPath) const
+{
+ OSL_ENSURE(_rxConfProvider.is(), "createWithProvider: invalid provider!");
+
+ Reference< XInterface > xInterface;
+#ifdef DBG_UTIL
+ if (_rxConfProvider.is())
+ {
+ try
+ {
+ Reference< XServiceInfo > xSI(_rxConfProvider, UNO_QUERY);
+ if (!xSI.is())
+ {
+ OSL_ENSURE(sal_False, "::createWithProvider: no XServiceInfo interface on the provider!");
+ }
+ else
+ {
+ OSL_ENSURE(xSI->supportsService(::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")),
+ "::createWithProvider: sure this is a provider? Missing the ConfigurationProvider service!");
+ }
+ }
+ catch(const Exception&)
+ {
+ OSL_ENSURE(sal_False, "::createWithProvider: unable to check the service conformance of the provider given!");
+ }
+ }
+#endif
+
+ if (_rxConfProvider.is())
+ {
+ try
+ {
+ Sequence< Any > aCreationArgs(3);
+ aCreationArgs[0] = makeAny(PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), 0, makeAny(_rPath), PropertyState_DIRECT_VALUE));
+ aCreationArgs[1] = makeAny(PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("depth")), 0, makeAny((sal_Int32)-1), PropertyState_DIRECT_VALUE));
+ aCreationArgs[2] = makeAny(PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("lazywrite")), 0, makeAny(sal_True), PropertyState_DIRECT_VALUE));
+
+ static ::rtl::OUString sAccessService = ::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess");
+
+ xInterface = _rxConfProvider->createInstanceWithArguments(sAccessService, aCreationArgs);
+ OSL_ENSURE(xInterface.is(), "::createWithProvider: could not create the node access!");
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(sal_False, "OConfigurationTreeRoot::createWithProvider: caught an exception while creating the access object!");
+ }
+ }
+ return xInterface;
+}
+// -----------------------------------------------------------------------------
+Reference<XInterface> OPoolCollection::openNode(const ::rtl::OUString& _rPath,const Reference<XInterface>& _xTreeNode) const throw()
+{
+ Reference< XHierarchicalNameAccess > xHierarchyAccess(_xTreeNode, UNO_QUERY);
+ Reference< XNameAccess > xDirectAccess(_xTreeNode, UNO_QUERY);
+ Reference< XInterface > xNode;
+
+ try
+ {
+ if (xDirectAccess.is() && xDirectAccess->hasByName(_rPath))
+ {
+ if (!::cppu::extractInterface(xNode, xDirectAccess->getByName(_rPath)))
+ OSL_ENSURE(sal_False, "OConfigurationNode::openNode: could not open the node!");
+ }
+ else if (xHierarchyAccess.is())
+ {
+ if (!::cppu::extractInterface(xNode, xHierarchyAccess->getByHierarchicalName(_rPath)))
+ OSL_ENSURE(sal_False, "OConfigurationNode::openNode: could not open the node!");
+ }
+
+ }
+ catch(const NoSuchElementException&)
+ {
+ OSL_ENSURE(sal_False,
+ ::rtl::OString("::openNode: there is no element named ")
+ += ::rtl::OString(_rPath.getStr(), _rPath.getLength(), RTL_TEXTENCODING_ASCII_US)
+ += ::rtl::OString("!"));
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(sal_False, "OConfigurationNode::openNode: caught an exception while retrieving the node!");
+ }
+ return xNode;
+}
+// -----------------------------------------------------------------------------
+Any OPoolCollection::getNodeValue(const ::rtl::OUString& _rPath,const Reference<XInterface>& _xTreeNode) throw()
+{
+ Reference< XHierarchicalNameAccess > xHierarchyAccess(_xTreeNode, UNO_QUERY);
+ Reference< XNameAccess > xDirectAccess(_xTreeNode, UNO_QUERY);
+ Any aReturn;
+ try
+ {
+ if (xDirectAccess.is() && xDirectAccess->hasByName(_rPath) )
+ {
+ aReturn = xDirectAccess->getByName(_rPath);
+ }
+ else if (xHierarchyAccess.is())
+ {
+ aReturn = xHierarchyAccess->getByHierarchicalName(_rPath);
+ }
+ }
+ catch(NoSuchElementException& e)
+ {
+ OSL_UNUSED( e ); // make compiler happy
+ OSL_ENSURE(sal_False,
+ ::rtl::OString("::getNodeValue: caught a NoSuchElementException while trying to open ")
+ += ::rtl::OString(e.Message.getStr(), e.Message.getLength(), RTL_TEXTENCODING_ASCII_US)
+ += ::rtl::OString("!"));
+ }
+ return aReturn;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OPoolCollection::queryTermination( const EventObject& /*Event*/ ) throw (::com::sun::star::frame::TerminationVetoException, RuntimeException)
+{
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OPoolCollection::notifyTermination( const EventObject& /*Event*/ ) throw (RuntimeException)
+{
+ clearDesktop();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OPoolCollection::disposing( const EventObject& Source ) throw (RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ if ( m_xDesktop == Source.Source )
+ {
+ clearDesktop();
+ }
+ else
+ {
+ try
+ {
+ Reference<XPropertySet> xProp(Source.Source,UNO_QUERY);
+ if(Source.Source == m_xConfigNode)
+ {
+ if ( xProp.is() )
+ xProp->removePropertyChangeListener(getEnablePoolingNodeName(),this);
+ m_xConfigNode.clear();
+ }
+ else if ( xProp.is() )
+ xProp->removePropertyChangeListener(getEnableNodeName(),this);
+ }
+ catch(const Exception&)
+ {
+ OSL_ENSURE(0,"Exception caught");
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OPoolCollection::propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ if(evt.Source == m_xConfigNode)
+ {
+ sal_Bool bEnabled = sal_True;
+ evt.NewValue >>= bEnabled;
+ if(!bEnabled )
+ {
+ m_aDriverProxies.clear();
+ m_aDriverProxies = MapDriver2DriverRef();
+ OConnectionPools::iterator aIter = m_aPools.begin();
+ for(;aIter != m_aPools.end();++aIter)
+ {
+ aIter->second->clear(sal_False);
+ aIter->second->release();
+ }
+ m_aPools.clear();
+ m_aPools = OConnectionPools();
+ }
+ }
+ else if(evt.Source.is())
+ {
+ sal_Bool bEnabled = sal_True;
+ evt.NewValue >>= bEnabled;
+ if(!bEnabled)
+ {
+ ::rtl::OUString sThisDriverName;
+ getNodeValue(getDriverNameNodeName(),evt.Source) >>= sThisDriverName;
+ // 1nd relase the driver
+ // look if we already have a proxy for this driver
+ MapDriver2DriverRefIterator aLookup = m_aDriverProxies.begin();
+ while( aLookup != m_aDriverProxies.end())
+ {
+ MapDriver2DriverRefIterator aFind = aLookup;
+ Reference<XServiceInfo> xInfo(aLookup->first,UNO_QUERY);
+ ++aLookup;
+ if(xInfo.is() && xInfo->getImplementationName() == sThisDriverName)
+ m_aDriverProxies.erase(aFind);
+ }
+
+ // 2nd clear the connectionpool
+ OConnectionPools::iterator aFind = m_aPools.find(sThisDriverName);
+ if(aFind != m_aPools.end() && aFind->second)
+ {
+ aFind->second->clear(sal_False);
+ aFind->second->release();
+ m_aPools.erase(aFind);
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OPoolCollection::clearDesktop()
+{
+ clearConnectionPools(sal_True);
+ if ( m_xDesktop.is() )
+ m_xDesktop->removeTerminateListener(this);
+m_xDesktop.clear();
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/cpool/ZPoolCollection.hxx b/connectivity/source/cpool/ZPoolCollection.hxx
new file mode 100644
index 000000000000..039f29efa241
--- /dev/null
+++ b/connectivity/source/cpool/ZPoolCollection.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_POOLCOLLECTION_HXX
+#define CONNECTIVITY_POOLCOLLECTION_HXX
+
+#include <cppuhelper/implbase5.hxx>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/sdbc/XDriverManager.hpp>
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/sdbc/XPooledConnection.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/frame/XTerminateListener.hpp>
+#include <com/sun/star/reflection/XProxyFactory.hpp>
+#include <comphelper/stl_types.hxx>
+#include <osl/mutex.hxx>
+
+namespace connectivity
+{
+ class OConnectionPool;
+ //==========================================================================
+ //= OPoolCollection - the one-instance service for PooledConnections
+ //= manages the active connections and the connections in the pool
+ //==========================================================================
+ typedef ::cppu::WeakImplHelper5< ::com::sun::star::sdbc::XDriverManager,
+ ::com::sun::star::sdbc::XDriverAccess,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::frame::XTerminateListener,
+ ::com::sun::star::beans::XPropertyChangeListener
+ > OPoolCollection_Base;
+
+ /// OPoolCollection: controll the whole connection pooling for oo
+ class OPoolCollection : public OPoolCollection_Base
+ {
+
+ //==========================================================================
+ typedef ::comphelper::OInterfaceCompare< ::com::sun::star::sdbc::XDriver > ODriverCompare;
+ DECLARE_STL_USTRINGACCESS_MAP(OConnectionPool*, OConnectionPools);
+
+ DECLARE_STL_MAP(
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver >,
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDriver >,
+ ODriverCompare,
+ MapDriver2DriverRef );
+
+ MapDriver2DriverRef m_aDriverProxies;
+ ::osl::Mutex m_aMutex;
+ OConnectionPools m_aPools; // the driver pools
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceFactory;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriverManager > m_xManager;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriverAccess > m_xDriverAccess;
+ ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XProxyFactory > m_xProxyFactory;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xConfigNode; // config node for generel connection pooling
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop> m_xDesktop;
+
+ private:
+ OPoolCollection(); // never implemented
+ OPoolCollection(const OPoolCollection&); // never implemented
+ int operator= (const OPoolCollection&); // never implemented
+
+ OPoolCollection(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+
+ // some configuration helper methods
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createWithServiceFactory(const ::rtl::OUString& _rPath) const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getConfigPoolRoot();
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createWithProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxConfProvider,
+ const ::rtl::OUString& _rPath) const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > openNode( const ::rtl::OUString& _rPath,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xTreeNode) const throw();
+ sal_Bool isPoolingEnabled();
+ sal_Bool isDriverPoolingEnabled(const ::rtl::OUString& _sDriverImplName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDriverNode);
+ sal_Bool isPoolingEnabledByUrl( const ::rtl::OUString& _sUrl,
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver >& _rxDriver,
+ ::rtl::OUString& _rsImplName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDriverNode);
+
+ OConnectionPool* getConnectionPool( const ::rtl::OUString& _sImplName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver >& _xDriver,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDriverNode);
+ void clearConnectionPools(sal_Bool _bDispose);
+ void clearDesktop();
+ protected:
+ virtual ~OPoolCollection();
+ public:
+
+ static ::com::sun::star::uno::Any getNodeValue( const ::rtl::OUString& _rPath,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _xTreeNode)throw();
+
+ // XDriverManager
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnectionWithInfo( 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 void SAL_CALL setLoginTimeout( sal_Int32 seconds ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getLoginTimeout( ) throw(::com::sun::star::uno::RuntimeException);
+
+ //XDriverAccess
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > SAL_CALL getDriverByURL( const ::rtl::OUString& url ) 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);
+
+ // XServiceInfo - static methods
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL CreateInstance(const::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
+ 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);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) 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);
+ };
+}
+#endif // CONNECTIVITY_POOLCOLLECTION_HXX
+
diff --git a/connectivity/source/cpool/ZPooledConnection.cxx b/connectivity/source/cpool/ZPooledConnection.cxx
new file mode 100644
index 000000000000..bd36b061b4d0
--- /dev/null
+++ b/connectivity/source/cpool/ZPooledConnection.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 "ZPooledConnection.hxx"
+#include "ZConnectionWrapper.hxx"
+#ifndef _CONNECTIVITY_CONNECTIONWRAPPER_HXX_
+#include "connectivity/ConnectionWrapper.hxx"
+#endif
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#include <comphelper/types.hxx>
+#include <comphelper/uno3.hxx>
+#include <cppuhelper/component.hxx>
+#include <cppuhelper/compbase1.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::reflection;
+using namespace connectivity;
+using namespace ::osl;
+
+OPooledConnection::OPooledConnection(const Reference< XConnection >& _xConnection,
+ const Reference< ::com::sun::star::reflection::XProxyFactory >& _rxProxyFactory)
+ : OPooledConnection_Base(m_aMutex)
+ ,m_xRealConnection(_xConnection)
+ ,m_xProxyFactory(_rxProxyFactory)
+{
+
+}
+// -----------------------------------------------------------------------------
+// OComponentHelper
+void SAL_CALL OPooledConnection::disposing(void)
+{
+ MutexGuard aGuard(m_aMutex);
+ if (m_xComponent.is())
+ m_xComponent->removeEventListener(this);
+m_xComponent.clear();
+ ::comphelper::disposeComponent(m_xRealConnection);
+}
+// -----------------------------------------------------------------------------
+// XEventListener
+void SAL_CALL OPooledConnection::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
+{
+m_xComponent.clear();
+}
+// -----------------------------------------------------------------------------
+//XPooledConnection
+Reference< XConnection > OPooledConnection::getConnection() throw(SQLException, RuntimeException)
+{
+ if(!m_xComponent.is() && m_xRealConnection.is())
+ {
+ Reference< XAggregation > xConProxy = m_xProxyFactory->createProxy(m_xRealConnection.get());
+ m_xComponent = new OConnectionWeakWrapper(xConProxy);
+ // register as event listener for the new connection
+ if (m_xComponent.is())
+ m_xComponent->addEventListener(this);
+ }
+ return Reference< XConnection >(m_xComponent,UNO_QUERY);
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/cpool/ZPooledConnection.hxx b/connectivity/source/cpool/ZPooledConnection.hxx
new file mode 100644
index 000000000000..abf162a378ac
--- /dev/null
+++ b/connectivity/source/cpool/ZPooledConnection.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_POOLEDCONNECTION_HXX
+#define CONNECTIVITY_POOLEDCONNECTION_HXX
+
+#include <cppuhelper/compbase2.hxx>
+#include <com/sun/star/sdbc/XPooledConnection.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <comphelper/broadcasthelper.hxx>
+#include <com/sun/star/reflection/XProxyFactory.hpp>
+
+
+namespace connectivity
+{
+ //==========================================================================
+ //= OPooledConnection -
+ //= allows to pool a real connection
+ //==========================================================================
+ typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::sdbc::XPooledConnection
+ ,::com::sun::star::lang::XEventListener> OPooledConnection_Base;
+
+ class OPooledConnection : public ::comphelper::OBaseMutex
+ ,public OPooledConnection_Base
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xRealConnection; // the connection fom driver
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xComponent; // the connection which wraps the real connection
+ ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XProxyFactory > m_xProxyFactory;
+ public:
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ OPooledConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XProxyFactory >& _rxProxyFactory);
+
+ //XPooledConnection
+ 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);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+ };
+
+}
+#endif // CONNECTIVITY_POOLEDCONNECTION_HXX
+
diff --git a/connectivity/source/cpool/Zregistration.cxx b/connectivity/source/cpool/Zregistration.cxx
new file mode 100644
index 000000000000..0786d9ea5f9a
--- /dev/null
+++ b/connectivity/source/cpool/Zregistration.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <stdio.h>
+#include <cppuhelper/factory.hxx>
+#include "ZPoolCollection.hxx"
+
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+using namespace connectivity;
+//==========================================================================
+//= registration
+//==========================================================================
+extern "C"
+{
+
+//---------------------------------------------------------------------------------------
+ void SAL_CALL component_getImplementationEnvironment(const sal_Char** _ppEnvTypeName, uno_Environment** /*_ppEnv*/)
+{
+ *_ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+sal_Bool SAL_CALL component_writeInfo(void* /*_pServiceManager*/, com::sun::star::registry::XRegistryKey* _pRegistryKey)
+{
+ ::rtl::OUString sMainKeyName = ::rtl::OUString::createFromAscii("/");
+ sMainKeyName += OPoolCollection::getImplementationName_Static();
+ sMainKeyName += ::rtl::OUString::createFromAscii("/UNO/SERVICES");
+
+ try
+ {
+ Reference< XRegistryKey > xMainKey = _pRegistryKey->createKey(sMainKeyName);
+ if (!xMainKey.is())
+ return sal_False;
+
+ Sequence< ::rtl::OUString > sServices = OPoolCollection::getSupportedServiceNames_Static();
+ const ::rtl::OUString* pServices = sServices.getConstArray();
+ for (sal_Int32 i=0; i<sServices.getLength(); ++i, ++pServices)
+ xMainKey->createKey(*pServices);
+ }
+ catch(InvalidRegistryException&)
+ {
+ return sal_False;
+ }
+ catch(InvalidValueException&)
+ {
+ return sal_False;
+ }
+ return sal_True;
+}
+
+//---------------------------------------------------------------------------------------
+void* SAL_CALL component_getFactory(const sal_Char* _pImplName, ::com::sun::star::lang::XMultiServiceFactory* _pServiceManager, void* /*_pRegistryKey*/)
+{
+ void* pRet = NULL;
+
+ if (OPoolCollection::getImplementationName_Static().compareToAscii(_pImplName) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory(
+ ::cppu::createOneInstanceFactory(
+ _pServiceManager,
+ OPoolCollection::getImplementationName_Static(),
+ OPoolCollection::CreateInstance,
+ OPoolCollection::getSupportedServiceNames_Static()
+ )
+ );
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+
+} // extern "C"
+
+
diff --git a/connectivity/source/cpool/dbpool.xml b/connectivity/source/cpool/dbpool.xml
new file mode 100644
index 000000000000..57a73f1d7a4f
--- /dev/null
+++ b/connectivity/source/cpool/dbpool.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>dbpool</module-name>
+ <component-description>
+ <author>Ocke Janssen</author>
+ <name>com.sun.star.comp.sdbc.OConnectionPool</name>
+ <description>
+ This is the implementation of the connection pool.
+ </description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service>com.sun.star.sdbc.ConnectionPool</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/cpool/exports.dxp b/connectivity/source/cpool/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/connectivity/source/cpool/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/connectivity/source/cpool/makefile.mk b/connectivity/source/cpool/makefile.mk
new file mode 100644
index 000000000000..1f6e49c6cbd7
--- /dev/null
+++ b/connectivity/source/cpool/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJINC=..
+PRJNAME=connectivity
+TARGET=dbpool
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/version.mk
+
+
+# --- Files -------------------------------------
+
+SLOFILES=\
+ $(SLO)$/ZConnectionWrapper.obj \
+ $(SLO)$/ZDriverWrapper.obj \
+ $(SLO)$/ZPooledConnection.obj \
+ $(SLO)$/ZConnectionPool.obj \
+ $(SLO)$/ZPoolCollection.obj \
+ $(SLO)$/Zregistration.obj
+
+# --- Library -----------------------------------
+
+SHL1TARGET= $(DBPOOL_TARGET)$(DBPOOL_MAJOR)
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(DBTOOLSLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(SHL1TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/connectivity/source/dbtools/dbt.xml b/connectivity/source/dbtools/dbt.xml
new file mode 100644
index 000000000000..8c5a3b916805
--- /dev/null
+++ b/connectivity/source/dbtools/dbt.xml
@@ -0,0 +1,16 @@
+<?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>dbt</module-name>
+ <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>comphelper</runtime-module-dependency>
+</module-description>
+
+
diff --git a/connectivity/source/dbtools/exports.dxp b/connectivity/source/dbtools/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/connectivity/source/dbtools/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/connectivity/source/dbtools/makefile.mk b/connectivity/source/dbtools/makefile.mk
new file mode 100644
index 000000000000..af4ac13e54cc
--- /dev/null
+++ b/connectivity/source/dbtools/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=connectivity
+TARGET=dbt
+USE_LDUMP2=TRUE
+
+TARGETTYPE=CUI
+USE_DEFFILE=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/dbtools.pmk
+.INCLUDE : $(PRJ)$/version.mk
+
+LDUMP=ldump2.exe
+
+# --- Library -----------------------------------
+
+LIB1TARGET=$(SLB)$/$(TARGET).lib
+LIB1FILES=\
+ $(SLB)$/sdbcx.lib \
+ $(SLB)$/commontools.lib \
+ $(SLB)$/sql.lib \
+ $(SLB)$/simpledbt.lib \
+ $(SLB)$/cnr.lib
+
+# --- dynamic library ---------------------------
+
+SHL1TARGET= $(DBTOOLS_TARGET)$(DLLPOSTFIX)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB) \
+ $(JVMACCESSLIB) \
+ $(UNOTOOLSLIB) \
+ $(TOOLSLIB) \
+ $(COMPHELPERLIB) \
+ $(I18NISOLANGLIB)
+
+# NETBSD: somewhere we have to instantiate the static data members.
+# NETBSD-1.2.1 doesn't know about weak symbols so the default mechanism for GCC won't work.
+# SCO and MACOSX: the linker does know about weak symbols, but we can't ignore multiple defined symbols
+.IF "$(OS)"=="NETBSD" || "$(OS)"=="SCO" || "$(OS)$(COM)"=="OS2GCC" || "$(OS)"=="MACOSX"
+SHL1STDLIBS+=$(UCBHELPERLIB)
+.ENDIF
+
+#SHL1DEPN=
+SHL1IMPLIB= idbtools
+
+SHL1LIBS= $(LIB1TARGET)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+DEF1NAME= $(SHL1TARGET)
+DEF1DEPN= $(MISC)$/$(SHL1TARGET).flt \
+ $(LIB1TARGET)
+
+DEFLIB1NAME=$(TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
+# --- filter file ------------------------------
+
+$(MISC)$/$(SHL1TARGET).flt: makefile.mk
+ @echo ------------------------------
+ @echo _TI >$@
+ @echo _real >>$@
+
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..0c5db12c3355
--- /dev/null
+++ b/connectivity/source/drivers/ado/AResultSet.cxx
@@ -0,0 +1,1173 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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)
+{
+ // ::osl::MutexGuard aGuard( m_aMutex );
+ //checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ // if ( getResultSetConcurrency() == ResultSetConcurrency::READ_ONLY )
+ // throw SQLException();
+}
+// -------------------------------------------------------------------------
+
+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=ResultSetConcurrency::READ_ONLY;
+ 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..157d1f7b68fa
--- /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_INVALID_DBASE_FILE,
+ "$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..421225b34935
--- /dev/null
+++ b/connectivity/source/drivers/file/FResultSet.cxx
@@ -0,0 +1,1898 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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 )
+ goto Error;
+ else 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..70be592405eb
--- /dev/null
+++ b/connectivity/source/drivers/flat/ETable.cxx
@@ -0,0 +1,847 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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;
+ if ( m_cStringDelimiter != '\0' )
+ aFirstLine.GetTokenSpecial(aField,nStartPosFirstLine2,m_cFieldDelimiter,m_cStringDelimiter);
+ else
+ 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..e7fab6acb6c0
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HStorageAccess.cxx
@@ -0,0 +1,551 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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 || len <= 0 )
+ {
+ 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);
+ if (JNI_FALSE != env->ExceptionCheck())
+ {
+ env->ExceptionClear();
+ OSL_ENSURE(0,"ExceptionClear");
+ }
+ OSL_ENSURE(buf,"buf is NULL");
+ if ( buf && len > 0 && len <= env->GetArrayLength(buffer))
+ {
+ Sequence< ::sal_Int8 > aData(buf + off,len);
+ env->ReleaseByteArrayElements(buffer, buf, JNI_ABORT);
+ xOut->writeBytes(aData);
+#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..57ed88b1dda8
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HStorageMap.cxx
@@ -0,0 +1,362 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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();
+ }
+ // this is done implicity by the closing of the input stream
+ else 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& ex)
+ {
+ OSL_UNUSED( ex );
+ 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..fd52f3092c0e
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/Boolean.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// 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();
+}
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..4f5670ace8aa
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/Object.cxx
@@ -0,0 +1,429 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.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 );
+}
+
+
+::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..f32b0cce4325
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/String.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 "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::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 > $@
diff --git a/connectivity/source/inc/AutoRetrievingBase.hxx b/connectivity/source/inc/AutoRetrievingBase.hxx
new file mode 100644
index 000000000000..af5206830cf3
--- /dev/null
+++ b/connectivity/source/inc/AutoRetrievingBase.hxx
@@ -0,0 +1,59 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_AUTOKEYRETRIEVINGBASE_HXX_
+#define _CONNECTIVITY_AUTOKEYRETRIEVINGBASE_HXX_
+
+#include <rtl/ustring.hxx>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ class OOO_DLLPUBLIC_DBTOOLS OAutoRetrievingBase
+ {
+ ::rtl::OUString m_sGeneratedValueStatement; // contains the statement which should be used when query for automatically generated values
+ sal_Bool m_bAutoRetrievingEnabled; // set to when we should allow to query for generated values
+ protected:
+ OAutoRetrievingBase() : m_bAutoRetrievingEnabled(sal_False) {}
+ virtual ~OAutoRetrievingBase(){}
+
+ inline void enableAutoRetrievingEnabled(sal_Bool _bAutoEnable) { m_bAutoRetrievingEnabled = _bAutoEnable; }
+ inline void setAutoRetrievingStatement(const ::rtl::OUString& _sStmt) { m_sGeneratedValueStatement = _sStmt; }
+ public:
+ inline sal_Bool isAutoRetrievingEnabled() const { return m_bAutoRetrievingEnabled; }
+ inline const ::rtl::OUString& getAutoRetrievingStatement() const { return m_sGeneratedValueStatement; }
+
+ /** transform the statement to query for auto generated values
+ @param _sInsertStatement
+ The "INSERT" statement, is used to query for column and table names
+ @return
+ The transformed generated statement.
+ */
+ ::rtl::OUString getTransformedGeneratedStatement(const ::rtl::OUString& _sInsertStatement) const;
+ };
+}
+#endif // _CONNECTIVITY_AUTOKEYRETRIEVINGBASE_HXX_
+
diff --git a/connectivity/source/inc/FDatabaseMetaDataResultSet.hxx b/connectivity/source/inc/FDatabaseMetaDataResultSet.hxx
new file mode 100644
index 000000000000..134e7e5dfca1
--- /dev/null
+++ b/connectivity/source/inc/FDatabaseMetaDataResultSet.hxx
@@ -0,0 +1,279 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_FDATABASEMETADATARESULTSET_HXX_
+#define _CONNECTIVITY_FDATABASEMETADATARESULTSET_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/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <cppuhelper/compbase9.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include "connectivity/CommonTools.hxx"
+#include <comphelper/propertycontainer.hxx>
+#include "connectivity/FValue.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+#include <comphelper/broadcasthelper.hxx>
+#include <vos/refernce.hxx>
+
+namespace connectivity
+{
+ class ODatabaseMetaDataResultSetMetaData;
+ typedef ::cppu::WeakComponentImplHelper9< ::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::lang::XInitialization,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::sdbc::XColumnLocate> ODatabaseMetaDataResultSet_BASE;
+
+ // typedef ORefVector<ORowSetValue> ORow;
+ // typedef ORefVector<ORow> ORows;
+
+ class OOO_DLLPUBLIC_DBTOOLS ODatabaseMetaDataResultSet :
+ public comphelper::OBaseMutex,
+ public ODatabaseMetaDataResultSet_BASE,
+ public ::comphelper::OPropertyContainer,
+ public ::comphelper::OPropertyArrayUsageHelper<ODatabaseMetaDataResultSet>
+ {
+
+ public:
+ DECLARE_STL_VECTOR(ORowSetValueDecoratorRef,ORow);
+ DECLARE_STL_VECTOR(ORow, ORows);
+
+ enum MetaDataResultSetType
+ {
+ /// describes a result set as expected by XDatabaseMetaData::getCatalogs
+ eCatalogs = 0,
+ /// describes a result set as expected by XDatabaseMetaData::getSchemas
+ eSchemas = 1,
+ /// describes a result set as expected by XDatabaseMetaData::getColumnPrivileges
+ eColumnPrivileges = 2,
+ /// describes a result set as expected by XDatabaseMetaData::getColumns
+ eColumns = 3,
+ /// describes a result set as expected by XDatabaseMetaData::getTables
+ eTables = 4,
+ /// describes a result set as expected by XDatabaseMetaData::getTableTypes
+ eTableTypes = 5,
+ /// describes a result set as expected by XDatabaseMetaData::getProcedureColumns
+ eProcedureColumns = 6,
+ /// describes a result set as expected by XDatabaseMetaData::getProcedures
+ eProcedures = 7,
+ /// describes a result set as expected by XDatabaseMetaData::getExportedKeys
+ eExportedKeys = 8,
+ /// describes a result set as expected by XDatabaseMetaData::getImportedKeys
+ eImportedKeys = 9,
+ /// describes a result set as expected by XDatabaseMetaData::getPrimaryKeys
+ ePrimaryKeys = 10,
+ /// describes a result set as expected by XDatabaseMetaData::getIndexInfo
+ eIndexInfo = 11,
+ /// describes a result set as expected by XDatabaseMetaData::getTablePrivileges
+ eTablePrivileges = 12,
+ /// describes a result set as expected by XDatabaseMetaData::getCrossReference
+ eCrossReference = 13,
+ /// describes a result set as expected by XDatabaseMetaData::getTypeInfo
+ eTypeInfo = 14,
+ /// describes a result set as expected by XDatabaseMetaData::getBestRowIdentifier
+ eBestRowIdentifier = 15,
+ /// describes a result set as expected by XDatabaseMetaData::getVersionColumns
+ eVersionColumns = 16
+ };
+
+ private:
+ ORowSetValue m_aEmptyValue;
+ ::com::sun::star::uno::WeakReferenceHelper m_aStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData;
+ sal_Int32 m_nColPos;
+
+ sal_Int32 m_nFetchSize;
+ sal_Int32 m_nResultSetType;
+ sal_Int32 m_nFetchDirection;
+ sal_Int32 m_nResultSetConcurrency;
+
+ void construct();
+ void checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException);
+ void setType(MetaDataResultSetType _eType);
+
+ protected:
+ ORows m_aRows;
+ ORows::iterator m_aRowsIter;
+ sal_Bool m_bBOF;
+ sal_Bool m_bEOF;
+
+ virtual const ORowSetValue& getValue(sal_Int32 columnIndex);
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ virtual ~ODatabaseMetaDataResultSet();
+ public:
+
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ /// default construction
+ ODatabaseMetaDataResultSet();
+ /// construction of a pre-defined result set type
+ ODatabaseMetaDataResultSet( MetaDataResultSetType _eType );
+
+ void setRows(const ORows& _rRows);
+
+ // XServiceInfo
+
+ 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);
+
+ protected:
+ 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);
+ // ::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);
+ //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);
+
+ // 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);
+
+ void setCatalogsMap();
+ void setSchemasMap();
+ void setColumnPrivilegesMap();
+ void setColumnsMap();
+ void setTablesMap();
+ void setTableTypes();
+ void setProcedureColumnsMap();
+ void setProceduresMap();
+ void setExportedKeysMap();
+ void setImportedKeysMap();
+ void setPrimaryKeysMap();
+ void setIndexInfoMap();
+ void setTablePrivilegesMap();
+ void setCrossReferenceMap();
+ void setTypeInfoMap();
+ void setBestRowIdentifierMap();
+ void setVersionColumnsMap();
+ public:
+ // some methods to get already defined ORowSetValues
+ // this increase the reuse of ORowSetValues
+ /// return an empty ORowSetValueDecorator
+ static ORowSetValueDecoratorRef getEmptyValue();
+ /// return an ORowSetValueDecorator with 0 as value
+ static ORowSetValueDecoratorRef get0Value();
+ /// return an ORowSetValueDecorator with 1 as value
+ static ORowSetValueDecoratorRef get1Value();
+ /// return an ORowSetValueDecorator with ColumnSearch::BASIC as value
+ static ORowSetValueDecoratorRef getBasicValue();
+ /// return an ORowSetValueDecorator with string SELECT as value
+ static ORowSetValueDecoratorRef getSelectValue();
+ /// return an ORowSetValueDecorator with string INSERT as value
+ static ORowSetValueDecoratorRef getInsertValue();
+ /// return an ORowSetValueDecorator with string DELETE as value
+ static ORowSetValueDecoratorRef getDeleteValue();
+ /// return an ORowSetValueDecorator with string UPDATE as value
+ static ORowSetValueDecoratorRef getUpdateValue();
+ /// return an ORowSetValueDecorator with string CREATE as value
+ static ORowSetValueDecoratorRef getCreateValue();
+ /// return an ORowSetValueDecorator with string READ as value
+ static ORowSetValueDecoratorRef getReadValue();
+ /// return an ORowSetValueDecorator with string ALTER as value
+ static ORowSetValueDecoratorRef getAlterValue();
+ /// return an ORowSetValueDecorator with string DROP as value
+ static ORowSetValueDecoratorRef getDropValue();
+ /// return an ORowSetValueDecorator with string ' as value
+ static ORowSetValueDecoratorRef getQuoteValue();
+
+ };
+}
+#endif // _CONNECTIVITY_FDATABASEMETADATARESULTSET_HXX_
+
diff --git a/connectivity/source/inc/FDatabaseMetaDataResultSetMetaData.hxx b/connectivity/source/inc/FDatabaseMetaDataResultSetMetaData.hxx
new file mode 100644
index 000000000000..de6979346f56
--- /dev/null
+++ b/connectivity/source/inc/FDatabaseMetaDataResultSetMetaData.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_DATABASEMETADATARESULTSETMETADATA_HXX_
+#define _CONNECTIVITY_DATABASEMETADATARESULTSETMETADATA_HXX_
+
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <cppuhelper/implbase1.hxx>
+#ifndef _VECTOR_
+#include <vector>
+#endif
+#include "FDatabaseMetaDataResultSet.hxx"
+#include "OColumn.hxx"
+#include "connectivity/StdTypeDefs.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ //**************************************************************
+ //************ Class: ODatabaseMetaDataResultSetMetaData
+ //**************************************************************
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> ODatabaseMetaResultSetMetaData_BASE;
+
+ class OOO_DLLPUBLIC_DBTOOLS ODatabaseMetaDataResultSetMetaData : public ODatabaseMetaResultSetMetaData_BASE
+ {
+ TIntVector m_vMapping; // when not every column is needed
+ ::std::map<sal_Int32,connectivity::OColumn> m_mColumns;
+ ::std::map<sal_Int32,connectivity::OColumn>::const_iterator m_mColumnsIter;
+
+ sal_Int32 m_nColCount;
+ protected:
+ virtual ~ODatabaseMetaDataResultSetMetaData();
+ public:
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ ODatabaseMetaDataResultSetMetaData( )
+ : m_nColCount(0)
+ {
+ }
+ /// 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);
+
+ // methods to set the right column mapping
+ void setColumnPrivilegesMap();
+ void setColumnMap();
+ void setColumnsMap();
+ void setTableNameMap();
+ void setTablesMap();
+ void setProcedureColumnsMap();
+ void setPrimaryKeysMap();
+ void setIndexInfoMap();
+ void setTablePrivilegesMap();
+ void setCrossReferenceMap();
+ void setTypeInfoMap();
+ void setProcedureNameMap();
+ void setProceduresMap();
+ void setTableTypes();
+ void setBestRowIdentifierMap() { setVersionColumnsMap();}
+ void setVersionColumnsMap();
+ void setExportedKeysMap() { setCrossReferenceMap(); }
+ void setImportedKeysMap() { setCrossReferenceMap(); }
+ void setCatalogsMap();
+ void setSchemasMap();
+ };
+}
+#endif // _CONNECTIVITY_FILE_ADATABASEMETARESULTSETMETADATA_HXX_
+
+
diff --git a/connectivity/source/inc/OColumn.hxx b/connectivity/source/inc/OColumn.hxx
new file mode 100644
index 000000000000..26f6d920b719
--- /dev/null
+++ b/connectivity/source/inc/OColumn.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_COLUMN_HXX_
+#define _CONNECTIVITY_COLUMN_HXX_
+
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ class OOO_DLLPUBLIC_DBTOOLS OColumn
+ {
+ ::rtl::OUString m_CatalogName;
+ ::rtl::OUString m_SchemaName;
+ ::rtl::OUString m_TableName;
+ ::rtl::OUString m_ColumnName;
+ ::rtl::OUString m_ColumnLabel;
+ ::rtl::OUString m_ColumnTypeName;
+ ::rtl::OUString m_ColumnServiceName;
+
+ sal_Int32 m_Nullable;
+ sal_Int32 m_ColumnDisplaySize;
+ sal_Int32 m_Precision;
+ sal_Int32 m_Scale;
+ sal_Int32 m_ColumnType;
+
+ sal_Bool m_AutoIncrement;
+ sal_Bool m_CaseSensitive;
+ sal_Bool m_Searchable;
+ sal_Bool m_Currency;
+ sal_Bool m_Signed;
+ sal_Bool m_ReadOnly;
+ sal_Bool m_Writable;
+ sal_Bool m_DefinitelyWritable;
+
+ public:
+ OColumn() {}
+ OColumn(const ::rtl::OUString &_aTableName,
+ const ::rtl::OUString &_aColumnName,
+
+ sal_Int32 _aNullable=0,
+ sal_Int32 _aColumnDisplaySize=0,
+ sal_Int32 _aPrecision=0,
+ sal_Int32 _aScale=0,
+ sal_Int32 _aColumnType=0,
+
+ sal_Bool _aAutoIncrement=sal_False,
+ sal_Bool _aCaseSensitive=sal_False,
+ sal_Bool _aSearchable=sal_True,
+ sal_Bool _aCurrency=sal_False,
+ sal_Bool _aSigned=sal_False,
+ sal_Bool _aReadOnly=sal_True,
+ sal_Bool _aWritable=sal_False,
+ sal_Bool _aDefinitelyWritable=sal_False,
+
+ const ::rtl::OUString &_aColumnLabel = ::rtl::OUString(),
+ const ::rtl::OUString &_aColumnTypeName = ::rtl::OUString(),
+ const ::rtl::OUString &_aColumnServiceName = ::rtl::OUString())
+ : m_TableName(_aTableName),
+ m_ColumnName(_aColumnName),
+ m_ColumnLabel(_aColumnLabel),
+ m_ColumnTypeName(_aColumnTypeName),
+ m_ColumnServiceName(_aColumnServiceName),
+
+ m_Nullable(_aNullable),
+ m_ColumnDisplaySize(_aColumnDisplaySize),
+ m_Precision(_aPrecision),
+ m_Scale(_aScale),
+ m_ColumnType(_aColumnType),
+
+ m_AutoIncrement(_aAutoIncrement),
+ m_CaseSensitive(_aCaseSensitive),
+ m_Searchable(_aSearchable),
+ m_Currency(_aCurrency),
+ m_Signed(_aSigned),
+ m_ReadOnly(_aReadOnly),
+ m_Writable(_aWritable),
+ m_DefinitelyWritable(_aDefinitelyWritable)
+ {
+ if(!m_ColumnLabel.getLength())
+ m_ColumnLabel = _aColumnName;
+ }
+
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void * SAL_CALL operator new( size_t ,void* _pHint ) SAL_THROW( () )
+ { return _pHint; }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ inline static void SAL_CALL operator delete( void *,void* ) SAL_THROW( () )
+ { }
+
+ sal_Bool isAutoIncrement() const { return m_AutoIncrement; }
+ sal_Bool isCaseSensitive() const { return m_CaseSensitive; }
+ sal_Bool isSearchable() const { return m_Searchable; }
+ sal_Bool isCurrency() const { return m_Currency; }
+ sal_Bool isSigned() const { return m_Signed; }
+ sal_Bool isReadOnly() const { return m_ReadOnly; }
+ sal_Bool isWritable() const { return m_Writable; }
+ sal_Bool isDefinitelyWritable() const { return m_DefinitelyWritable; }
+
+ sal_Int32 isNullable() const { return m_Nullable; }
+ sal_Int32 getColumnDisplaySize() const { return m_ColumnDisplaySize; }
+ sal_Int32 getPrecision() const { return m_Precision; }
+ sal_Int32 getScale() const { return m_Scale; }
+ sal_Int32 getColumnType() const { return m_ColumnType; }
+
+ const ::rtl::OUString& getColumnLabel() const { return m_ColumnLabel; }
+ const ::rtl::OUString& getColumnName() const { return m_ColumnName; }
+ const ::rtl::OUString& getSchemaName() const { return m_SchemaName; }
+ const ::rtl::OUString& getTableName() const { return m_TableName; }
+ const ::rtl::OUString& getCatalogName() const { return m_CatalogName; }
+ const ::rtl::OUString& getColumnTypeName() const { return m_ColumnTypeName; }
+ const ::rtl::OUString& getColumnServiceName() const { return m_ColumnServiceName; }
+
+ };
+}
+
+#endif //_CONNECTIVITY_COLUMN_HXX_
+
diff --git a/connectivity/source/inc/OSubComponent.hxx b/connectivity/source/inc/OSubComponent.hxx
new file mode 100644
index 000000000000..9927148f2512
--- /dev/null
+++ b/connectivity/source/inc/OSubComponent.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_OSUBCOMPONENT_HXX_
+#define _CONNECTIVITY_OSUBCOMPONENT_HXX_
+
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/interfacecontainer.h>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace com
+{
+ namespace sun
+ {
+ namespace star
+ {
+ namespace lang
+ {
+ class XComponent;
+ }
+ }
+ }
+}
+namespace connectivity
+{
+ OOO_DLLPUBLIC_DBTOOLS
+ void release(oslInterlockedCount& _refCount,
+ ::cppu::OBroadcastHelper& rBHelper,
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
+ ::com::sun::star::lang::XComponent* _pObject);
+ //************************************************************
+ // OSubComponent
+ //************************************************************
+ template <class SELF, class WEAK> class OSubComponent
+ {
+ protected:
+ // the parent must support the tunnel implementation
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xParent;
+ SELF* m_pDerivedImplementation;
+
+ public:
+ OSubComponent(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParent,
+ SELF* _pDerivedImplementation)
+ :m_xParent(_xParent)
+ ,m_pDerivedImplementation(_pDerivedImplementation)
+ {
+ }
+
+ protected:
+ void dispose_ChildImpl()
+ {
+ // avoid ambiguity
+ ::osl::MutexGuard aGuard( m_pDerivedImplementation->WEAK::rBHelper.rMutex );
+ m_xParent.clear();
+ }
+ void relase_ChildImpl()
+ {
+ ::connectivity::release(m_pDerivedImplementation->m_refCount,
+ m_pDerivedImplementation->WEAK::rBHelper,
+ m_xParent,
+ m_pDerivedImplementation);
+
+ m_pDerivedImplementation->WEAK::release();
+ }
+ };
+}
+#endif // _CONNECTIVITY_OSUBCOMPONENT_HXX_
+
diff --git a/connectivity/source/inc/OTypeInfo.hxx b/connectivity/source/inc/OTypeInfo.hxx
new file mode 100644
index 000000000000..d983b79da04e
--- /dev/null
+++ b/connectivity/source/inc/OTypeInfo.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_OTYPEINFO_HXX_
+#define _CONNECTIVITY_OTYPEINFO_HXX_
+
+#include <com/sun/star/sdbc/ColumnSearch.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ struct OTypeInfo
+ {
+ ::rtl::OUString aTypeName; // Name des Types in der Datenbank
+ ::rtl::OUString aLiteralPrefix; // Prefix zum Quoten
+ ::rtl::OUString aLiteralSuffix; // Suffix zum Quoten
+ ::rtl::OUString aCreateParams; // Parameter zum Erstellen
+ ::rtl::OUString aLocalTypeName;
+
+ sal_Int32 nPrecision; // Laenge des Types
+
+ sal_Int16 nMaximumScale; // Nachkommastellen
+ sal_Int16 nMinimumScale; // Min Nachkommastellen
+
+ sal_Int16 nType; // Datenbanktyp
+ sal_Int16 nSearchType; // kann nach dem Typen gesucht werden
+ sal_Int16 nNumPrecRadix; // indicating the radix, which is usually 2 or 10
+
+ sal_Bool bCurrency : 1, // Waehrung
+ bAutoIncrement : 1, // Ist es ein automatisch incrementierendes Feld
+ bNullable : 1, // Kann das Feld NULL annehmen
+ bCaseSensitive : 1, // Ist der Type Casesensitive
+ bUnsigned : 1, // Ist der Type Unsigned
+ bEmpty_1 : 1, // for later use
+ bEmpty_2 : 1;
+
+ OTypeInfo()
+ :nPrecision(0)
+ ,nMaximumScale(0)
+ ,nMinimumScale(0)
+ ,nType( ::com::sun::star::sdbc::DataType::OTHER)
+ ,nSearchType( ::com::sun::star::sdbc::ColumnSearch::FULL)
+ ,bCurrency(sal_False)
+ ,bAutoIncrement(sal_False)
+ ,bNullable(sal_True)
+ ,bCaseSensitive(sal_False)
+ ,bUnsigned(sal_False)
+ {}
+
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void * SAL_CALL operator new( size_t /*nSize*/,void* _pHint ) SAL_THROW( () )
+ { return _pHint; }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ inline static void SAL_CALL operator delete( void * /*pMem*/,void* /*_pHint*/ ) SAL_THROW( () )
+ { }
+
+ sal_Bool operator == (const OTypeInfo& lh) const { return lh.nType == nType; }
+ sal_Bool operator != (const OTypeInfo& lh) const { return lh.nType != nType; }
+
+ inline ::rtl::OUString getDBName() const { return aTypeName; }
+ };
+}
+#endif // _CONNECTIVITY_OTYPEINFO_HXX_
+
+
diff --git a/connectivity/source/inc/ParameterSubstitution.hxx b/connectivity/source/inc/ParameterSubstitution.hxx
new file mode 100644
index 000000000000..70a640e9d447
--- /dev/null
+++ b/connectivity/source/inc/ParameterSubstitution.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.
+ *
+ ************************************************************************/
+#include "precompiled_connectivity.hxx"
+#include <com/sun/star/util/XStringSubstitution.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <cppuhelper/implbase3.hxx>
+
+namespace connectivity
+{
+ typedef ::cppu::WeakImplHelper3< ::com::sun::star::util::XStringSubstitution
+ ,::com::sun::star::lang::XServiceInfo
+ ,::com::sun::star::lang::XInitialization > ParameterSubstitution_BASE;
+ class ParameterSubstitution : public ParameterSubstitution_BASE
+ {
+ ::osl::Mutex m_aMutex;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+
+ ParameterSubstitution( const ParameterSubstitution& );
+ ParameterSubstitution& operator=( const ParameterSubstitution& );
+ public:
+
+ 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);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext);
+ protected:
+ ParameterSubstitution(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
+ virtual ~ParameterSubstitution(){}
+
+ // 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);
+ // 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);
+
+ // XStringSubstitution
+ virtual ::rtl::OUString SAL_CALL substituteVariables( const ::rtl::OUString& aText, ::sal_Bool bSubstRequired ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL reSubstituteVariables( const ::rtl::OUString& aText ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSubstituteVariableValue( const ::rtl::OUString& variable ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ };
+// ==================================
+} // connectivity
+// ==================================
diff --git a/connectivity/source/inc/RowFunctionParser.hxx b/connectivity/source/inc/RowFunctionParser.hxx
new file mode 100644
index 000000000000..b514b82739d3
--- /dev/null
+++ b/connectivity/source/inc/RowFunctionParser.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_ROWFUNCTIONPARSER_HXX_INCLUDED
+#define CONNECTIVITY_ROWFUNCTIONPARSER_HXX_INCLUDED
+
+#include <sal/config.h>
+#ifndef BOOST_SHARED_PTR_HPP_INCLUDED
+#include <boost/shared_ptr.hpp>
+#endif
+#include "FDatabaseMetaDataResultSet.hxx"
+#include <vector>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+// -------------------------------------------------------------------------
+namespace connectivity
+{
+// -------------------------------------------------------------------------
+struct OOO_DLLPUBLIC_DBTOOLS RowEquation
+{
+ sal_Int32 nOperation;
+ ORowSetValueDecoratorRef nPara[ 3 ];
+
+ RowEquation() :
+ nOperation ( 0 )
+ {
+ }
+};
+
+enum ExpressionFunct
+{
+ FUNC_CONST,
+
+ ENUM_FUNC_EQUATION,
+
+ UNARY_FUNC_COLUMN,
+ ENUM_FUNC_AND,
+ ENUM_FUNC_OR
+};
+
+#define EXPRESSION_FLAG_SUMANGLE_MODE 1
+
+class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE ExpressionNode
+{
+public:
+ virtual ~ExpressionNode(){}
+
+ /** Operator to calculate function value.
+
+ This method calculates the function value.
+ */
+ virtual ORowSetValueDecoratorRef evaluate(const ODatabaseMetaDataResultSet::ORow& _aRow ) const = 0;
+
+ virtual void fill(const ODatabaseMetaDataResultSet::ORow& _aRow ) const = 0;
+
+ /** Operator to retrieve the type of expression node
+ */
+ virtual ExpressionFunct getType() const = 0;
+
+ /** Operator to retrieve the ms version of expression
+ */
+ virtual ODatabaseMetaDataResultSet::ORow fillNode(
+ std::vector< RowEquation >& rEquations, ExpressionNode* pOptionalArg, sal_uInt32 nFlags ) = 0;
+};
+typedef ::boost::shared_ptr< ExpressionNode > ExpressionNodeSharedPtr;
+
+/** This exception is thrown, when the arithmetic expression
+ parser failed to parse a string.
+ */
+struct OOO_DLLPUBLIC_DBTOOLS ParseError
+{
+ ParseError() {}
+ ParseError( const char* ) {}
+};
+
+class OOO_DLLPUBLIC_DBTOOLS FunctionParser
+{
+public:
+
+ /** Parse a string
+
+ The following grammar is accepted by this method:
+ <code>
+
+ number_digit = '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
+
+ number = number number_digit | number_digit
+
+ equal_function = '='
+ ternary_function = 'if'
+
+ string_reference = 'a-z,A-Z,0-9' ' '
+ modifier_reference = '$' '0-9' ' '
+
+ basic_expression =
+ number |
+ string_reference |
+ additive_expression equal_function additive_expression |
+ unary_function '(' number_digit ')'
+ ternary_function '(' additive_expression ',' additive_expression ',
+ ' additive_expression ')' | '(' additive_expression ')'
+
+ </code>
+
+ @param rFunction
+ The string to parse
+
+ @throws ParseError if an invalid expression is given.
+
+ @return the generated function object.
+ */
+
+ static ExpressionNodeSharedPtr parseFunction( const ::rtl::OUString& _sFunction);
+
+private:
+ // disabled constructor/destructor, since this is
+ // supposed to be a singleton
+ FunctionParser();
+
+ // default: disabled copy/assignment
+ FunctionParser(const FunctionParser&);
+ FunctionParser& operator=( const FunctionParser& );
+};
+
+// -------------------------------------------------------------------------
+} // namespace connectivity
+// -------------------------------------------------------------------------
+#endif /* CONNECTIVITY_ROWFUNCTIONPARSER_HXX_INCLUDED */
diff --git a/connectivity/source/inc/TConnection.hxx b/connectivity/source/inc/TConnection.hxx
new file mode 100644
index 000000000000..f1acaa1c8aac
--- /dev/null
+++ b/connectivity/source/inc/TConnection.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_CONNECTION_HXX
+#define CONNECTIVITY_CONNECTION_HXX
+
+#include <rtl/textenc.h>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <cppuhelper/compbase4.hxx>
+#include "propertyids.hxx"
+#include "connectivity/CommonTools.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+#include "resource/sharedresources.hxx"
+
+namespace connectivity
+{
+ typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::sdbc::XConnection,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::lang::XUnoTunnel
+ > OMetaConnection_BASE;
+
+ typedef ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > TConditions;
+
+ class OOO_DLLPUBLIC_DBTOOLS OMetaConnection : public OMetaConnection_BASE
+ {
+ protected:
+ ::osl::Mutex m_aMutex;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
+ m_aConnectionInfo;
+ connectivity::OWeakRefArray m_aStatements; // vector containing a list
+ // of all the Statement objects
+ // for this Connection
+ ::rtl::OUString m_sURL;
+ rtl_TextEncoding m_nTextEncoding; // the encoding which is used for all text conversions
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData >
+ m_xMetaData;
+ SharedResources m_aResources;
+ public:
+
+ static ::dbtools::OPropertyMap& getPropMap();
+
+ OMetaConnection();
+
+ inline rtl_TextEncoding getTextEncoding() const { return m_nTextEncoding; }
+ inline ::rtl::OUString getURL() const { return m_sURL; }
+ inline void setURL(const ::rtl::OUString& _rsUrl) { m_sURL = _rsUrl; }
+ void throwGenericSQLException( sal_uInt16 _nErrorResourceId,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _xContext );
+ const SharedResources& getResources() const { return m_aResources;}
+
+ inline void setConnectionInfo(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _aInfo) { m_aConnectionInfo = _aInfo; }
+ inline const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >&
+ getConnectionInfo() const { return m_aConnectionInfo; }
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ //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();
+ };
+}
+#endif // CONNECTIVITY_CONNECTION_HXX
+
+
diff --git a/connectivity/source/inc/TDatabaseMetaDataBase.hxx b/connectivity/source/inc/TDatabaseMetaDataBase.hxx
new file mode 100644
index 000000000000..3a7b47d2cbb2
--- /dev/null
+++ b/connectivity/source/inc/TDatabaseMetaDataBase.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_ODATABASEMETADATABASE_HXX_
+#define _CONNECTIVITY_ODATABASEMETADATABASE_HXX_
+
+#include <com/sun/star/sdbc/XDatabaseMetaData2.hpp>
+#include <cppuhelper/implbase2.hxx>
+#include <comphelper/broadcasthelper.hxx>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include "FDatabaseMetaDataResultSet.hxx"
+#include <functional>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ typedef ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > TConditions;
+ class OOO_DLLPUBLIC_DBTOOLS ODatabaseMetaDataBase :
+ public comphelper::OBaseMutex,
+ public ::cppu::WeakImplHelper2< ::com::sun::star::sdbc::XDatabaseMetaData2,
+ ::com::sun::star::lang::XEventListener>
+ {
+ private:
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aConnectionInfo;
+ ::connectivity::ODatabaseMetaDataResultSet::ORows m_aTypeInfoRows;
+
+ // cached database information
+ ::std::pair<bool,sal_Bool> m_isCatalogAtStart;
+ ::std::pair<bool,::rtl::OUString> m_sCatalogSeparator;
+ ::std::pair<bool,::rtl::OUString> m_sIdentifierQuoteString;
+ ::std::pair<bool,sal_Bool> m_supportsCatalogsInTableDefinitions;
+ ::std::pair<bool,sal_Bool> m_supportsSchemasInTableDefinitions;
+ ::std::pair<bool,sal_Bool> m_supportsCatalogsInDataManipulation;
+ ::std::pair<bool,sal_Bool> m_supportsSchemasInDataManipulation;
+ ::std::pair<bool,sal_Bool> m_supportsMixedCaseQuotedIdentifiers;
+ ::std::pair<bool,sal_Bool> m_supportsAlterTableWithAddColumn;
+ ::std::pair<bool,sal_Bool> m_supportsAlterTableWithDropColumn;
+ ::std::pair<bool,sal_Int32> m_MaxStatements;
+ ::std::pair<bool,sal_Int32> m_MaxTablesInSelect;
+ ::std::pair<bool,sal_Bool> m_storesMixedCaseQuotedIdentifiers;
+
+ template <typename T> T callImplMethod(::std::pair<bool,T>& _rCache,const ::std::mem_fun_t<T,ODatabaseMetaDataBase>& _pImplMethod)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !_rCache.first )
+ {
+ _rCache.second = _pImplMethod(this);
+ _rCache.first = true;
+ }
+ return _rCache.second;
+ }
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener> m_xListenerHelper; // forward the calls from the connection to me
+
+ virtual ~ODatabaseMetaDataBase();
+
+ protected:
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_getTypeInfo_throw() = 0;
+ // cached database information
+ virtual ::rtl::OUString impl_getIdentifierQuoteString_throw( ) = 0;
+ virtual sal_Bool impl_isCatalogAtStart_throw( ) = 0;
+ virtual ::rtl::OUString impl_getCatalogSeparator_throw( ) = 0;
+ virtual sal_Bool impl_supportsCatalogsInTableDefinitions_throw( ) = 0;
+ virtual sal_Bool impl_supportsSchemasInTableDefinitions_throw( ) = 0;
+ virtual sal_Bool impl_supportsCatalogsInDataManipulation_throw( ) = 0;
+ virtual sal_Bool impl_supportsSchemasInDataManipulation_throw( ) = 0;
+ virtual sal_Bool impl_supportsMixedCaseQuotedIdentifiers_throw( ) = 0;
+ virtual sal_Bool impl_supportsAlterTableWithAddColumn_throw( ) = 0;
+ virtual sal_Bool impl_supportsAlterTableWithDropColumn_throw( ) = 0;
+ virtual sal_Int32 impl_getMaxStatements_throw( ) = 0;
+ virtual sal_Int32 impl_getMaxTablesInSelect_throw( ) = 0;
+ virtual sal_Bool impl_storesMixedCaseQuotedIdentifiers_throw( ) = 0;
+
+
+ public:
+
+ ODatabaseMetaDataBase(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo);
+
+ // XDatabaseMetaData2
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getConnectionInfo( ) 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);
+
+ 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 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 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 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 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 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // cached database information
+ virtual ::rtl::OUString SAL_CALL getIdentifierQuoteString( ) 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 supportsCatalogsInTableDefinitions( ) 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 supportsCatalogsInDataManipulation( ) 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 supportsMixedCaseQuotedIdentifiers( ) 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_Int32 SAL_CALL getMaxStatements( ) 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_Bool SAL_CALL storesMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+}
+#endif // _CONNECTIVITY_ODATABASEMETADATABASE_HXX_
diff --git a/connectivity/source/inc/TKeyValue.hxx b/connectivity/source/inc/TKeyValue.hxx
new file mode 100644
index 000000000000..1430bf798418
--- /dev/null
+++ b/connectivity/source/inc/TKeyValue.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_TKEYVALUE_HXX
+#define CONNECTIVITY_TKEYVALUE_HXX
+
+#include "connectivity/FValue.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ class OOO_DLLPUBLIC_DBTOOLS OKeyValue
+ {
+ private:
+ ::std::vector<ORowSetValueDecoratorRef> m_aKeys;
+ sal_Int32 m_nValue;
+
+ protected:
+ OKeyValue();
+ OKeyValue(sal_Int32 nVal);
+ public:
+
+ ~OKeyValue();
+
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void * SAL_CALL operator new( size_t,void* _pHint ) SAL_THROW( () )
+ { return _pHint; }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ inline static void SAL_CALL operator delete( void *,void* ) SAL_THROW( () )
+ { }
+
+ static OKeyValue* createKeyValue(sal_Int32 nVal);
+ // static OKeyValue* createEmptyKeyValue();
+
+ inline void pushKey(const ORowSetValueDecoratorRef& _aValueRef)
+ {
+ m_aKeys.push_back(_aValueRef);
+ }
+ inline void setValue(sal_Int32 nVal) { m_nValue = nVal; }
+
+ ::rtl::OUString getKeyString(::std::vector<ORowSetValueDecoratorRef>::size_type i) const
+ {
+ OSL_ENSURE(m_aKeys.size() > i,"Wrong index for KEyValue");
+ return m_aKeys[i]->getValue();
+ }
+ double getKeyDouble(::std::vector<ORowSetValueDecoratorRef>::size_type i) const
+ {
+ OSL_ENSURE(m_aKeys.size() > i,"Wrong index for KEyValue");
+ return m_aKeys[i]->getValue();
+ }
+
+ inline sal_Int32 getValue() const { return m_nValue; }
+ };
+}
+
+#endif // CONNECTIVITY_TKEYVALUE_HXX
+
diff --git a/connectivity/source/inc/TPrivilegesResultSet.hxx b/connectivity/source/inc/TPrivilegesResultSet.hxx
new file mode 100644
index 000000000000..3b5bc4963167
--- /dev/null
+++ b/connectivity/source/inc/TPrivilegesResultSet.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_PRIVILEGESRESULTSET_HXX
+#define CONNECTIVITY_PRIVILEGESRESULTSET_HXX
+
+#include "FDatabaseMetaDataResultSet.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ class OOO_DLLPUBLIC_DBTOOLS OResultSetPrivileges :
+ public ODatabaseMetaDataResultSet
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> m_xTables;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow> m_xRow;
+ sal_Bool m_bResetValues;
+ protected:
+ virtual const ORowSetValue& getValue(sal_Int32 columnIndex);
+ public:
+ OResultSetPrivileges(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _rxMeta
+ ,const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern);
+
+ // ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XResultSet
+ virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+}
+#endif // CONNECTIVITY_PRIVILEGESRESULTSET_HXX
diff --git a/connectivity/source/inc/TResultSetHelper.hxx b/connectivity/source/inc/TResultSetHelper.hxx
new file mode 100644
index 000000000000..16f6ac049507
--- /dev/null
+++ b/connectivity/source/inc/TResultSetHelper.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_TRESULTSETHELPER_HXX
+#define CONNECTIVITY_TRESULTSETHELPER_HXX
+
+#include <sal/types.h>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE IResultSetHelper
+ {
+ public:
+ enum Movement
+ {
+ NEXT = 0,
+ PRIOR,
+ FIRST,
+ LAST,
+ RELATIVE,
+ ABSOLUTE,
+ BOOKMARK
+ };
+ public:
+ virtual sal_Bool move(Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool _bRetrieveData) = 0;
+ virtual sal_Int32 getDriverPos() const = 0;
+ virtual sal_Bool deletedVisible() const = 0;
+ virtual sal_Bool isRowDeleted() const = 0;
+ };
+}
+
+#endif // CONNECTIVITY_TRESULTSETHELPER_HXX
+
diff --git a/connectivity/source/inc/TSkipDeletedSet.hxx b/connectivity/source/inc/TSkipDeletedSet.hxx
new file mode 100644
index 000000000000..bcd3fc23f1a6
--- /dev/null
+++ b/connectivity/source/inc/TSkipDeletedSet.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_SKIPDELETEDSSET_HXX
+#define CONNECTIVITY_SKIPDELETEDSSET_HXX
+
+#include "TResultSetHelper.hxx"
+#include <rtl/alloc.h>
+#include <hash_map>
+#include <vector>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ /**
+ the class OSkipDeletedSet supports a general method to skip deleted rows
+ */
+ class OOO_DLLPUBLIC_DBTOOLS OSkipDeletedSet
+ {
+ ::std::vector<sal_Int32> m_aBookmarksPositions;// vector of iterators to position map, the order is the logical position
+ IResultSetHelper* m_pHelper; // used for moving in the resultset
+ bool m_bDeletedVisible;
+
+ sal_Bool moveAbsolute(sal_Int32 _nOffset,sal_Bool _bRetrieveData);
+ public:
+ OSkipDeletedSet(IResultSetHelper* _pHelper);
+ ~OSkipDeletedSet();
+
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void * SAL_CALL operator new( size_t,void* _pHint ) SAL_THROW( () )
+ { return _pHint; }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ inline static void SAL_CALL operator delete( void *,void* ) SAL_THROW( () )
+ { }
+
+ /**
+ skipDeleted moves the resultset to the position defined by the parameters
+ it garantees that the row isn't deleted
+ @param
+ IResultSetHelper::Movement _eCursorPosition in which direction the resultset should be moved
+ sal_Int32 _nOffset the position relativ to the movement
+ sal_Bool _bRetrieveData is true when the current row should be filled which data
+ @return
+ true when the movement was successful otherwise false
+ */
+ sal_Bool skipDeleted(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool _bRetrieveData);
+ /**
+ clear the map and the vector used in this class
+ */
+ void clear();
+ /**
+ getMappedPosition returns the mapped position of a logical position
+ @param
+ sal_Int32 _nBookmark the logical position
+
+ @return the mapped position
+ */
+ sal_Int32 getMappedPosition(sal_Int32 _nBookmark) const;
+ /**
+ insertNewPosition adds a new position to the map
+ @param
+ sal_Int32 _nPos the logical position
+ */
+ void insertNewPosition(sal_Int32 _nPos);
+ /**
+ deletePosition deletes this position from the map and decrement all following positions
+ @param
+ sal_Int32 _nPos the logical position
+ */
+ void deletePosition(sal_Int32 _nPos);
+ /**
+ getLastPosition returns the last position
+ @return the last position
+ */
+ inline sal_Int32 getLastPosition() const { return m_aBookmarksPositions.size(); }
+ inline void SetDeleted(bool _bDeletedVisible) { m_bDeletedVisible = _bDeletedVisible; }
+ };
+}
+#endif // CONNECTIVITY_SKIPDELETEDSSET_HXX
+
diff --git a/connectivity/source/inc/TSortIndex.hxx b/connectivity/source/inc/TSortIndex.hxx
new file mode 100644
index 000000000000..51a978121ca1
--- /dev/null
+++ b/connectivity/source/inc/TSortIndex.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_TSORTINDEX_HXX
+#define CONNECTIVITY_TSORTINDEX_HXX
+
+#include "connectivity/dbtoolsdllapi.hxx"
+#include "TKeyValue.hxx"
+
+namespace connectivity
+{
+ typedef enum
+ {
+ SQL_ORDERBYKEY_NONE, // do not sort
+ SQL_ORDERBYKEY_DOUBLE, // numeric key
+ SQL_ORDERBYKEY_STRING // String Key
+ } OKeyType;
+
+ typedef enum
+ {
+ SQL_ASC = 1, // ascending
+ SQL_DESC = -1 // otherwise
+ } TAscendingOrder;
+
+ class OKeySet;
+ class OKeyValue; // simple class which holds a sal_Int32 and a ::std::vector<ORowSetValueDecoratorRef>
+
+ /**
+ The class OSortIndex can be used to implement a sorted index.
+ This can depend on the fields which should be sorted.
+ */
+ class OOO_DLLPUBLIC_DBTOOLS OSortIndex
+ {
+ public:
+ typedef ::std::vector< ::std::pair<sal_Int32,OKeyValue*> > TIntValuePairVector;
+ typedef ::std::vector<OKeyType> TKeyTypeVector;
+
+ private:
+ TIntValuePairVector m_aKeyValues;
+ TKeyTypeVector m_aKeyType;
+ ::std::vector<TAscendingOrder> m_aAscending;
+ sal_Bool m_bFrozen;
+
+ public:
+
+ OSortIndex( const ::std::vector<OKeyType>& _aKeyType,
+ const ::std::vector<TAscendingOrder>& _aAscending);
+
+ ~OSortIndex();
+
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void * SAL_CALL operator new( size_t,void* _pHint ) SAL_THROW( () )
+ { return _pHint; }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ inline static void SAL_CALL operator delete( void *,void* ) SAL_THROW( () )
+ { }
+
+
+ /**
+ AddKeyValue appends a new value.
+ @param
+ pKeyValue the keyvalue to be appended
+ ATTENTION: when the sortindex is already frozen the parameter will be deleted
+ */
+ void AddKeyValue(OKeyValue * pKeyValue);
+
+ /**
+ Freeze freezes the sortindex so that new values could only be appended by their value
+ */
+ void Freeze();
+
+ /**
+ CreateKeySet creates the keyset which vaalues could be used to travel in your table/result
+ The returned keyset is frozen.
+ */
+ ::vos::ORef<OKeySet> CreateKeySet();
+
+
+
+ // look at the name
+ sal_Bool IsFrozen() const { return m_bFrozen; }
+ // returns the current size of the keyvalues
+ sal_Int32 Count() const { return m_aKeyValues.size(); }
+ /** GetValue returns the value at position nPos (1..n) [sorted access].
+ It only allowed to call this method after the sortindex has been frozen.
+ */
+
+ sal_Int32 GetValue(sal_Int32 nPos) const;
+
+ inline const ::std::vector<OKeyType>& getKeyType() const { return m_aKeyType; }
+ inline TAscendingOrder getAscending(::std::vector<TAscendingOrder>::size_type _nPos) const { return m_aAscending[_nPos]; }
+
+ };
+
+ /**
+ The class OKeySet is a refcountable vector which also has a state.
+ This state gives information about if the keyset is fixed.
+ */
+ class OOO_DLLPUBLIC_DBTOOLS OKeySet : public ORefVector<sal_Int32>
+ {
+ sal_Bool m_bFrozen;
+ public:
+ OKeySet()
+ : ORefVector<sal_Int32>()
+ , m_bFrozen(sal_False){}
+ OKeySet(Vector::size_type _nSize)
+ : ORefVector<sal_Int32>(_nSize)
+ , m_bFrozen(sal_False){}
+
+ sal_Bool isFrozen() const { return m_bFrozen; }
+ void setFrozen(sal_Bool _bFrozen=sal_True) { m_bFrozen = _bFrozen; }
+ };
+}
+#endif // CONNECTIVITY_TSORTINDEX_HXX
diff --git a/connectivity/source/inc/UStringDescription_Impl.hxx b/connectivity/source/inc/UStringDescription_Impl.hxx
new file mode 100644
index 000000000000..708117cc77b3
--- /dev/null
+++ b/connectivity/source/inc/UStringDescription_Impl.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_USTRINGDESCRIPTION_IMPL_HXX
+#define CONNECTIVITY_USTRINGDESCRIPTION_IMPL_HXX
+
+#define IMPLEMENT_CONSTASCII_USTRING(name) \
+UStringDescription name(connectivity::dbtools::get##name)
+
+UStringDescription::UStringDescription(PVFN _fCharFkt)
+{
+ pZeroTerminatedName = (*_fCharFkt)();
+ nLength = 0;
+ const sal_Char* pIter = pZeroTerminatedName;
+ while((*pIter++) != '\0')
+ ++nLength;
+}
+// -------------------------------------------------------------------------
+UStringDescription::~UStringDescription()
+{
+}
+
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_QUERYTIMEOUT );
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_MAXFIELDSIZE );
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_MAXROWS );
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CURSORNAME );
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_RESULTSETCONCURRENCY );
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_RESULTSETTYPE );
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FETCHDIRECTION );
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FETCHSIZE );
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ESCAPEPROCESSING );
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_USEBOOKMARKS );
+
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_NAME);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_TYPE);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_TYPENAME);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_PRECISION);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_SCALE);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISNULLABLE);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISAUTOINCREMENT);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISROWVERSION);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DESCRIPTION);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DEFAULTVALUE);
+
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_REFERENCEDTABLE);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_UPDATERULE);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DELETERULE);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CATALOG);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISUNIQUE);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISPRIMARYKEYINDEX);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISCLUSTERED);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISASCENDING);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_SCHEMANAME);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CATALOGNAME);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_COMMAND);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_CHECKOPTION);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_PASSWORD);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_RELATEDCOLUMN);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISSEARCHABLE);
+
+IMPLEMENT_CONSTASCII_USTRING(STAT_INVALID_INDEX);
+
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_FUNCTION);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_TABLENAME);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_REALNAME);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_DBASEPRECISIONCHANGED);
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISCURRENCY);
+
+IMPLEMENT_CONSTASCII_USTRING(PROPERTY_ISBOOKMARKABLE);
+//============================================================
+//= error messages
+//============================================================
+IMPLEMENT_CONSTASCII_USTRING(ERRORMSG_SEQUENCE);
+IMPLEMENT_CONSTASCII_USTRING(SQLSTATE_SEQUENCE);
+IMPLEMENT_CONSTASCII_USTRING(SQLSTATE_GENERAL);
+//============================================================
+//= different
+//============================================================
+IMPLEMENT_CONSTASCII_USTRING(STR_DELIMITER);
+
+#endif // CONNECTIVITY_USTRINGDESCRIPTION_IMPL_HXX
+
diff --git a/connectivity/source/inc/adabas/BCatalog.hxx b/connectivity/source/inc/adabas/BCatalog.hxx
new file mode 100644
index 000000000000..1a74d368311a
--- /dev/null
+++ b/connectivity/source/inc/adabas/BCatalog.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_ADABAS_CATALOG_HXX_
+#define _CONNECTIVITY_ADABAS_CATALOG_HXX_
+
+#include "connectivity/sdbcx/VCatalog.hxx"
+#include "odbc/OFunctiondefs.hxx"
+#include "connectivity/StdTypeDefs.hxx"
+
+namespace connectivity
+{
+ namespace adabas
+ {
+ // 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 OAdabasConnection;
+ class OAdabasCatalog : public connectivity::sdbcx::OCatalog
+ {
+ OAdabasConnection* m_pConnection; // used to get the metadata
+ SQLHANDLE m_aConnectionHdl; // used for odbc specific stuff
+
+ void fillVector(const ::rtl::OUString& _sQuery,TStringVector& _rVector);
+
+ protected:
+ /** builds the name which should be used to access the object later on in the collection.
+ Will only be called in fillNames.
+ @param _xRow
+ The cuurent row from a call of XDatabaseMetaData::getTables.
+ */
+ virtual ::rtl::OUString buildName( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >& _xRow);
+ public:
+ // implementation of the pure virtual methods
+ virtual void refreshTables();
+ virtual void refreshViews() ;
+ virtual void refreshGroups();
+ virtual void refreshUsers() ;
+
+ public:
+ OAdabasCatalog(SQLHANDLE _aConnectionHdl,OAdabasConnection* _pCon);
+
+ OAdabasConnection* getConnection() const { return m_pConnection; }
+ sdbcx::OCollection* getPrivateTables() const { return m_pTables;}
+ sdbcx::OCollection* getPrivateViews() const { return m_pViews; }
+
+ static const ::rtl::OUString& getDot();
+ // correct the the column properties of float/real/double values
+ // all & parameters are IN and OUT
+ static void correctColumnProperties(sal_Int32 _nPrec, sal_Int32& _rnType,::rtl::OUString& _rsTypeName);
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADABAS_CATALOG_HXX_
+
diff --git a/connectivity/source/inc/adabas/BColumn.hxx b/connectivity/source/inc/adabas/BColumn.hxx
new file mode 100644
index 000000000000..bfe036b5c858
--- /dev/null
+++ b/connectivity/source/inc/adabas/BColumn.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_ADABAS_COLUMN_HXX_
+#define _CONNECTIVITY_ADABAS_COLUMN_HXX_
+
+#include "connectivity/sdbcx/VColumn.hxx"
+
+namespace connectivity
+{
+ namespace adabas
+ {
+ class OAdabasColumn : public sdbcx::OColumn
+ {
+ public:
+ OAdabasColumn();
+ OAdabasColumn(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);
+
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADABAS_COLUMN_HXX_
+
diff --git a/connectivity/source/inc/adabas/BColumns.hxx b/connectivity/source/inc/adabas/BColumns.hxx
new file mode 100644
index 000000000000..404f07d740e6
--- /dev/null
+++ b/connectivity/source/inc/adabas/BColumns.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_ADABAS_COLUMNS_HXX_
+#define _CONNECTIVITY_ADABAS_COLUMNS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include "adabas/BTable.hxx"
+
+namespace connectivity
+{
+ namespace adabas
+ {
+ class OColumns : public sdbcx::OCollection
+ {
+ protected:
+ OAdabasTable* m_pTable;
+
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ OColumns( OAdabasTable* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector
+ ) : sdbcx::OCollection(*_pTable,sal_True,_rMutex,_rVector)
+ ,m_pTable(_pTable)
+ {}
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADABAS_COLUMNS_HXX_
+
diff --git a/connectivity/source/inc/adabas/BConnection.hxx b/connectivity/source/inc/adabas/BConnection.hxx
new file mode 100644
index 000000000000..678eb2e61049
--- /dev/null
+++ b/connectivity/source/inc/adabas/BConnection.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_ADABAS_BCONNECTION_HXX_
+#define _CONNECTIVITY_ADABAS_BCONNECTION_HXX_
+
+#include <cppuhelper/compbase2.hxx>
+#include "odbc/OConnection.hxx"
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <cppuhelper/weakref.hxx>
+#include <vos/ref.hxx>
+
+namespace connectivity
+{
+ namespace odbc
+ {
+ class ODBCDriver;
+ }
+ namespace adabas
+ {
+ typedef connectivity::odbc::OConnection OConnection_BASE2;
+
+ // we must use the name "OAdabasConnection" because of a compiler bug
+
+ class OAdabasConnection : public OConnection_BASE2
+ {
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog;
+
+ protected:
+ virtual SQLRETURN openConnectionWithAuth(const ::rtl::OUString& aConnectStr,sal_Int32 nTimeOut, const ::rtl::OUString& _uid,const ::rtl::OUString& _pwd);
+ virtual connectivity::odbc::OConnection* cloneConnection(); // creates a new connection
+ public:
+ virtual SQLRETURN Construct( const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info) throw(::com::sun::star::sdbc::SQLException);
+
+ OAdabasConnection(const SQLHANDLE _pDriverHandle,connectivity::odbc::ODBCDriver* _pDriver);
+
+ // OComponentHelper;
+ virtual void SAL_CALL disposing();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > createCatalog();
+ 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::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);
+
+ //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();
+
+ ::vos::ORef<OSQLColumns> createSelectColumns(const ::rtl::OUString& _rSql);
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADABAS_BCONNECTION_HXX_
+
diff --git a/connectivity/source/inc/adabas/BDatabaseMetaData.hxx b/connectivity/source/inc/adabas/BDatabaseMetaData.hxx
new file mode 100644
index 000000000000..bae7de19f4a3
--- /dev/null
+++ b/connectivity/source/inc/adabas/BDatabaseMetaData.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.
+ *
+ ************************************************************************/
+
+#include "odbc/ODatabaseMetaData.hxx"
+
+namespace connectivity
+{
+ namespace odbc
+ {
+ class OConnection;
+ }
+ namespace adabas
+ {
+ typedef odbc::ODatabaseMetaData OAdabasDatabaseMetaData_BASE;
+
+ class OAdabasDatabaseMetaData : public OAdabasDatabaseMetaData_BASE
+ {
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_getTypeInfo_throw();
+ public:
+ OAdabasDatabaseMetaData(const SQLHANDLE _pHandle,odbc::OConnection* _pCon)
+ : ODatabaseMetaData(_pHandle,_pCon)
+ {
+ }
+
+ // just to return our url
+ virtual ::rtl::OUString SAL_CALL getURL( ) 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);
+ };
+ }
+}
+
diff --git a/connectivity/source/inc/adabas/BDriver.hxx b/connectivity/source/inc/adabas/BDriver.hxx
new file mode 100644
index 000000000000..3b73da08cc6f
--- /dev/null
+++ b/connectivity/source/inc/adabas/BDriver.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_ADABAS_BDRIVER_HXX_
+#define _CONNECTIVITY_ADABAS_BDRIVER_HXX_
+
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XCreateCatalog.hpp>
+#include <com/sun/star/sdbcx/XDropCatalog.hpp>
+
+#include <com/sun/star/lang/XEventListener.hpp>
+
+//#include <unotools/tempfile.hxx>
+#include <cppuhelper/implbase4.hxx>
+#include "odbc/OFunctiondefs.hxx"
+#include "odbc/ODriver.hxx"
+
+namespace connectivity
+{
+ namespace adabas
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception );
+
+ typedef ::cppu::ImplHelper4< ::com::sun::star::sdbcx::XCreateCatalog,
+ ::com::sun::star::sdbcx::XDataDefinitionSupplier,
+ ::com::sun::star::lang::XEventListener,
+ ::com::sun::star::sdbcx::XDropCatalog> ODriver_BASE2;
+
+ typedef odbc::ODBCDriver ODriver_BASE;
+
+ class ODriver : public ODriver_BASE,
+ public ODriver_BASE2
+ {
+ typedef struct DatabaseStruct
+ {
+ ::rtl::OUString sControlUser;
+ ::rtl::OUString sControlPassword;
+ ::rtl::OUString sSysUser;
+ ::rtl::OUString sSysPassword;
+ ::rtl::OUString sDomainPassword;
+ ::rtl::OUString sCacheSize;
+ ::rtl::OUString sBackupFile;
+ ::rtl::OUString sDataDevName;
+ ::rtl::OUString sSysDevSpace;
+ ::rtl::OUString sTransLogName;
+ ::rtl::OUString sDBName;
+ sal_Int32 nDataIncrement; // which size the database should grow
+ sal_Int32 nDataSize;
+ sal_Int32 nLogSize;
+ sal_Bool bShutDown;
+ sal_Bool bRestoreDatabase;
+
+ DatabaseStruct() : nDataIncrement(0),nDataSize(0),nLogSize(0),bShutDown(sal_False),bRestoreDatabase(sal_False){ }
+ } TDatabaseStruct;
+
+ DECLARE_STL_USTRINGACCESS_MAP(TDatabaseStruct,TDatabaseMap);
+ TDatabaseMap m_aDatabaseMap; // contains all adabas databases with their flag to shut down or not
+
+ // environment vars
+ ::rtl::OUString m_sDbWork;
+ ::rtl::OUString m_sDbConfig;
+ ::rtl::OUString m_sDbRoot;
+ ::rtl::OUString m_sDbWorkURL;
+ ::rtl::OUString m_sDbConfigURL;
+ ::rtl::OUString m_sDbRootURL;
+ ::rtl::OUString m_sDbRunDir;
+ ::rtl::OUString m_sDelimit;
+
+ void checkAndInsertNewDevSpace(const ::rtl::OUString& _rDBName,const TDatabaseStruct& _rDBInfo);
+ void checkAndRestart(const ::rtl::OUString& _rDBName,const TDatabaseStruct& _rDbInfo);
+ void X_CONS(const ::rtl::OUString& _DBNAME,const ::rtl::OString& _ACTION,const ::rtl::OUString& _FILENAME);
+ sal_Bool getDBName(const ::rtl::OUString& _rName,::rtl::OUString& _rDBName) const;
+ ::rtl::OUString getDatabaseInitFile( const TDatabaseStruct& _aInfo);
+ ::rtl::OUString generateInitFile() const;
+ void fillEnvironmentVariables();
+ void fillInfo(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info, TDatabaseStruct& _rDBInfo /*out*/);
+ void LoadBatch(const ::rtl::OUString& _rDBNAME,
+ const ::rtl::OUString& _rUSR,
+ const ::rtl::OUString& _rPWD,
+ const ::rtl::OUString& _rBatch);
+ void XUTIL(const ::rtl::OUString& _rParam,
+ const ::rtl::OUString& _DBNAME,
+ const ::rtl::OUString& _USRNAME,
+ const ::rtl::OUString& _USRPWD);
+ int X_STOP(const ::rtl::OUString& _DBNAME);
+ int X_START(const ::rtl::OUString& _DBNAME);
+ void createDb(const TDatabaseStruct& _aInfo);
+ void clearDatabase(const ::rtl::OUString& _rDBName);
+ int X_PARAM(const ::rtl::OUString& _DBNAME,
+ const ::rtl::OUString& _USR,
+ const ::rtl::OUString& _PWD,
+ const ::rtl::OUString& _CMD);
+ sal_Int32 CreateFiles(const TDatabaseStruct& _aInfo);
+ sal_Bool CreateFile(const ::rtl::OUString &_FileName,
+ sal_Int32 _nSize);
+ void PutParam(const ::rtl::OUString& rDBNAME,
+ const ::rtl::OUString& rWhat,
+ const ::rtl::OUString& rHow);
+ void createNeededDirs( const ::rtl::OUString& _rDBName);
+ sal_Bool isKernelVersion(const char* _pVersion);
+ sal_Bool isVersion( const ::rtl::OUString& _rDBName,
+ const char* _pVersion);
+
+ void convertOldVersion( const ::rtl::OUString& _rDBName,
+ const TDatabaseStruct& _rDbInfo);
+
+ void installSystemTables( const TDatabaseStruct& _aInfo);
+
+ protected:
+ virtual SQLHANDLE EnvironmentHandle(::rtl::OUString &_rPath);
+ virtual ~ODriver();
+ public:
+ explicit ODriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+
+ // 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);
+ private:
+ DECLARE_SERVICE_INFO();
+
+ virtual oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const;
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ 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();
+
+ // XDriver
+ ::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);
+
+ // XDataDefinitionSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByURL( 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);
+
+ // XCreateCatalog
+ virtual void SAL_CALL createCatalog( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+ // XDropCatalog
+ virtual void SAL_CALL dropCatalog( const ::rtl::OUString& catalogName, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
+ };
+ }
+
+}
+#endif //_CONNECTIVITY_ADABAS_BDRIVER_HXX_
+
+
diff --git a/connectivity/source/inc/adabas/BGroup.hxx b/connectivity/source/inc/adabas/BGroup.hxx
new file mode 100644
index 000000000000..58358b579dcf
--- /dev/null
+++ b/connectivity/source/inc/adabas/BGroup.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_ADABAS_GROUP_HXX_
+#define _CONNECTIVITY_ADABAS_GROUP_HXX_
+
+#include "connectivity/sdbcx/VGroup.hxx"
+
+namespace connectivity
+{
+ namespace adabas
+ {
+ class OAdabasConnection;
+ class OAdabasGroup : public sdbcx::OGroup
+ {
+ OAdabasConnection* m_pConnection;
+ public:
+ virtual void refreshUsers();
+ public:
+ OAdabasGroup( OAdabasConnection* _pConnection);
+ OAdabasGroup( OAdabasConnection* _pConnection,const ::rtl::OUString& _Name);
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADABAS_GROUP_HXX_
+
diff --git a/connectivity/source/inc/adabas/BGroups.hxx b/connectivity/source/inc/adabas/BGroups.hxx
new file mode 100644
index 000000000000..33888d4cbefb
--- /dev/null
+++ b/connectivity/source/inc/adabas/BGroups.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_ADABAS_GROUPS_HXX_
+#define _CONNECTIVITY_ADABAS_GROUPS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+namespace connectivity
+{
+ namespace sdbcx
+ {
+ class IRefreshableGroups;
+ }
+ namespace adabas
+ {
+ class OAdabasConnection;
+ class OGroups : public sdbcx::OCollection
+ {
+ protected:
+ OAdabasConnection* m_pConnection;
+ connectivity::sdbcx::IRefreshableGroups* m_pParent;
+
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ OGroups(::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector,
+ OAdabasConnection* _pConnection,
+ connectivity::sdbcx::IRefreshableGroups* _pParent) : sdbcx::OCollection(_rParent,sal_True,_rMutex,_rVector)
+ ,m_pConnection(_pConnection)
+ ,m_pParent(_pParent)
+ {}
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_ADABAS_GROUPS_HXX_
+
diff --git a/connectivity/source/inc/adabas/BIndex.hxx b/connectivity/source/inc/adabas/BIndex.hxx
new file mode 100644
index 000000000000..0725d29d0cd6
--- /dev/null
+++ b/connectivity/source/inc/adabas/BIndex.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_ADABAS_INDEX_HXX_
+#define _CONNECTIVITY_ADABAS_INDEX_HXX_
+
+#include "connectivity/sdbcx/VIndex.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+
+namespace connectivity
+{
+ namespace adabas
+ {
+ class OAdabasTable;
+ class OAdabasIndex : public sdbcx::OIndex
+ {
+ OAdabasTable* m_pTable;
+ public:
+ virtual void refreshColumns();
+ public:
+ OAdabasIndex(OAdabasTable* _pTable);
+ OAdabasIndex( OAdabasTable* _pTable,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Catalog,
+ sal_Bool _isUnique,
+ sal_Bool _isPrimaryKeyIndex,
+ sal_Bool _isClustered
+ );
+ OAdabasTable* getTable() const { return m_pTable; }
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADABAS_INDEX_HXX_
+
diff --git a/connectivity/source/inc/adabas/BIndexColumn.hxx b/connectivity/source/inc/adabas/BIndexColumn.hxx
new file mode 100644
index 000000000000..b422ced8c337
--- /dev/null
+++ b/connectivity/source/inc/adabas/BIndexColumn.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_ADABAS_INDEXCOLUMN_HXX_
+#define _CONNECTIVITY_ADABAS_INDEXCOLUMN_HXX_
+
+#include "adabas/BColumn.hxx"
+
+namespace connectivity
+{
+ namespace adabas
+ {
+ class OIndexColumn : public OAdabasColumn
+ {
+ protected:
+ sal_Bool m_IsAscending;
+ public:
+ OIndexColumn();
+ OIndexColumn( sal_Bool _IsAscending,
+ 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);
+
+ virtual void construct();
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADABAS_INDEXCOLUMN_HXX_
+
diff --git a/connectivity/source/inc/adabas/BIndexColumns.hxx b/connectivity/source/inc/adabas/BIndexColumns.hxx
new file mode 100644
index 000000000000..ca85d71155e8
--- /dev/null
+++ b/connectivity/source/inc/adabas/BIndexColumns.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_ADABAS_INDEXCOLUMNS_HXX_
+#define _CONNECTIVITY_ADABAS_INDEXCOLUMNS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include "adabas/BIndex.hxx"
+
+namespace connectivity
+{
+ namespace adabas
+ {
+ class OIndexColumns : public sdbcx::OCollection
+ {
+ OAdabasIndex* m_pIndex;
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ public:
+ OIndexColumns( OAdabasIndex* _pIndex,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector)
+ : sdbcx::OCollection(*_pIndex,sal_True,_rMutex,_rVector)
+ ,m_pIndex(_pIndex)
+ {
+ }
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADABAS_INDEXCOLUMNS_HXX_
+
diff --git a/connectivity/source/inc/adabas/BIndexes.hxx b/connectivity/source/inc/adabas/BIndexes.hxx
new file mode 100644
index 000000000000..3a00416a4605
--- /dev/null
+++ b/connectivity/source/inc/adabas/BIndexes.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_ADABAS_INDEXES_HXX_
+#define _CONNECTIVITY_ADABAS_INDEXES_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "adabas/BTable.hxx"
+namespace connectivity
+{
+ namespace adabas
+ {
+ class OIndexes : public sdbcx::OCollection
+ {
+ OAdabasTable* m_pTable;
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ OIndexes(OAdabasTable* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector
+ ) : sdbcx::OCollection(*_pTable,sal_True,_rMutex,_rVector)
+ ,m_pTable(_pTable)
+ {}
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_ADABAS_INDEXES_HXX_
+
diff --git a/connectivity/source/inc/adabas/BKeys.hxx b/connectivity/source/inc/adabas/BKeys.hxx
new file mode 100644
index 000000000000..6ed97dd2e58e
--- /dev/null
+++ b/connectivity/source/inc/adabas/BKeys.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_ADABAS_KEYS_HXX_
+#define _CONNECTIVITY_ADABAS_KEYS_HXX_
+
+#include "connectivity/TKeys.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "adabas/BTable.hxx"
+namespace connectivity
+{
+ namespace adabas
+ {
+ class OKeys : public OKeysHelper
+ {
+ protected:
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+
+ virtual ::rtl::OUString getDropForeignKey() const;
+ public:
+ OKeys(OAdabasTable* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector
+ ) : OKeysHelper(_pTable,_rMutex,_rVector)
+ {}
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_ADABAS_KEYS_HXX_
+
diff --git a/connectivity/source/inc/adabas/BPreparedStatement.hxx b/connectivity/source/inc/adabas/BPreparedStatement.hxx
new file mode 100644
index 000000000000..a5cfac1666e4
--- /dev/null
+++ b/connectivity/source/inc/adabas/BPreparedStatement.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_ADABAS_PREPAREDSTATEMENT_HXX
+#define CONNECTIVITY_ADABAS_PREPAREDSTATEMENT_HXX
+
+#include "odbc/OPreparedStatement.hxx"
+#include "adabas/BConnection.hxx"
+
+namespace connectivity
+{
+ namespace adabas
+ {
+ class OAdabasPreparedStatement : public ::connectivity::odbc::OPreparedStatement
+ {
+ ::vos::ORef<OSQLColumns> m_aSelectColumns;
+ protected:
+ virtual odbc::OResultSet* createResulSet();
+ virtual void setResultSetConcurrency(sal_Int32 _par0) ;
+ virtual void setResultSetType(sal_Int32 _par0) ;
+ virtual void setUsingBookmarks(sal_Bool _bUseBookmark) ;
+ public:
+ OAdabasPreparedStatement( OAdabasConnection* _pConnection,const ::rtl::OUString& sql);
+ };
+ }
+}
+
+#endif // CONNECTIVITY_ADABAS_PREPAREDSTATEMENT_HXX
+
diff --git a/connectivity/source/inc/adabas/BResultSet.hxx b/connectivity/source/inc/adabas/BResultSet.hxx
new file mode 100644
index 000000000000..46dbf5684484
--- /dev/null
+++ b/connectivity/source/inc/adabas/BResultSet.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_ADABAS_RESULTSET_HXX
+#define CONNECTIVITY_ADABAS_RESULTSET_HXX
+
+#include "odbc/OResultSet.hxx"
+
+namespace connectivity
+{
+ namespace adabas
+ {
+ class OAdabasResultSet : public ::connectivity::odbc::OResultSet
+ {
+ ::vos::ORef<OSQLColumns> m_aSelectColumns;
+ public:
+ OAdabasResultSet(SQLHANDLE _pStatementHandle,::connectivity::odbc::OStatement_Base* pStmt,const ::vos::ORef<OSQLColumns>& _rSelectColumns)
+ : ::connectivity::odbc::OResultSet( _pStatementHandle,pStmt)
+ ,m_aSelectColumns(_rSelectColumns)
+ {}
+
+ // 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);
+
+ virtual sal_Bool SAL_CALL next( ) 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_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);
+ };
+ }
+}
+
+#endif // CONNECTIVITY_ADABAS_RESULTSET_HXX
+
diff --git a/connectivity/source/inc/adabas/BResultSetMetaData.hxx b/connectivity/source/inc/adabas/BResultSetMetaData.hxx
new file mode 100644
index 000000000000..1cbb328bcf1e
--- /dev/null
+++ b/connectivity/source/inc/adabas/BResultSetMetaData.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_ADABAS_RESULTSETMETADATA_HXX
+#define CONNECTIVITY_ADABAS_RESULTSETMETADATA_HXX
+
+#include "odbc/OResultSetMetaData.hxx"
+#include <vos/ref.hxx>
+
+namespace connectivity
+{
+ namespace adabas
+ {
+ //**************************************************************
+ //************ Class: ResultSetMetaData
+ //**************************************************************
+
+ typedef odbc::OResultSetMetaData OAdabasResultSetMetaData_BASE;
+ class OAdabasResultSetMetaData : public OAdabasResultSetMetaData_BASE
+ {
+ ::vos::ORef<OSQLColumns> m_aSelectColumns;
+ public:
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ OAdabasResultSetMetaData(odbc::OConnection* _pConnection, SQLHANDLE _pStmt ,const ::vos::ORef<OSQLColumns>& _rSelectColumns);
+ virtual ~OAdabasResultSetMetaData();
+
+ virtual sal_Int32 SAL_CALL getColumnType( 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 isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+#endif // CONNECTIVITY_ADABAS_RESULTSETMETADATA_HXX
diff --git a/connectivity/source/inc/adabas/BStatement.hxx b/connectivity/source/inc/adabas/BStatement.hxx
new file mode 100644
index 000000000000..abd8f93ef395
--- /dev/null
+++ b/connectivity/source/inc/adabas/BStatement.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_ADABAS_STATEMENT_HXX
+#define CONNECTIVITY_ADABAS_STATEMENT_HXX
+
+#include "odbc/OStatement.hxx"
+#include "adabas/BConnection.hxx"
+#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+#include "connectivity/commontools.hxx"
+#endif
+#include <vos/ref.hxx>
+
+namespace connectivity
+{
+ namespace adabas
+ {
+ class OAdabasStatement : public ::connectivity::odbc::OStatement
+ {
+ OAdabasConnection* m_pOwnConnection;
+ ::vos::ORef<OSQLColumns> m_aSelectColumns;
+ protected:
+ virtual odbc::OResultSet* createResulSet();
+ virtual void setResultSetConcurrency(sal_Int32 _par0);
+ virtual void setResultSetType(sal_Int32 _par0) ;
+ virtual void setUsingBookmarks(sal_Bool _bUseBookmark);
+ public:
+ OAdabasStatement( OAdabasConnection* _pConnection)
+ : ::connectivity::odbc::OStatement( _pConnection )
+ ,m_pOwnConnection(_pConnection)
+ {}
+
+ virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // CONNECTIVITY_ADABAS_STATEMENT_HXX
+
diff --git a/connectivity/source/inc/adabas/BTable.hxx b/connectivity/source/inc/adabas/BTable.hxx
new file mode 100644
index 000000000000..750f48093da1
--- /dev/null
+++ b/connectivity/source/inc/adabas/BTable.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_ADABAS_TABLE_HXX_
+#define _CONNECTIVITY_ADABAS_TABLE_HXX_
+
+#include "connectivity/sdbcx/VTable.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "adabas/BConnection.hxx"
+#include "connectivity/TTableHelper.hxx"
+
+namespace connectivity
+{
+ namespace adabas
+ {
+ typedef connectivity::OTableHelper OTable_TYPEDEF;
+
+ ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xColProp);
+
+ class OAdabasTable : public OTableHelper
+ {
+ OAdabasConnection* m_pConnection;
+ protected:
+ /** creates the column collection for the table
+ @param _rNames
+ The column names.
+ */
+ virtual sdbcx::OCollection* createColumns(const TStringVector& _rNames);
+
+ /** creates the key collection for the table
+ @param _rNames
+ The key names.
+ */
+ virtual sdbcx::OCollection* createKeys(const TStringVector& _rNames);
+
+ /** creates the index collection for the table
+ @param _rNames
+ The index names.
+ */
+ virtual sdbcx::OCollection* createIndexes(const TStringVector& _rNames);
+
+ public:
+ OAdabasTable( sdbcx::OCollection* _pTables,
+ OAdabasConnection* _pConnection);
+ OAdabasTable( sdbcx::OCollection* _pTables,
+ OAdabasConnection* _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()
+ );
+
+ ::rtl::OUString getTableName() const { return m_Name; }
+ ::rtl::OUString getSchema() const { return m_SchemaName; }
+
+ // 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();
+
+ // XAlterTable
+ virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& colName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ // XNamed
+ virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+ /**
+ returns the ALTER TABLE XXX COLUMN statement
+ */
+ ::rtl::OUString getAlterTableColumnPart(const ::rtl::OUString& _rsColumnName );
+
+ // starts a sql transaaction
+ void beginTransAction();
+ // rolls back a sql transaaction
+ void rollbackTransAction();
+ // ends a sql transaaction
+ void endTransAction();
+ // some methods to alter table structures
+ void alterColumnType(const ::rtl::OUString& _rColName,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDescriptor);
+ void alterNotNullValue(sal_Int32 _nNewNullable,const ::rtl::OUString& _rColName);
+ void alterDefaultValue(const ::rtl::OUString& _sNewDefault,const ::rtl::OUString& _rColName);
+ void dropDefaultValue(const ::rtl::OUString& _sNewDefault);
+ void addDefaultValue(const ::rtl::OUString& _sNewDefault,const ::rtl::OUString& _rColName);
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADABAS_TABLE_HXX_
+
diff --git a/connectivity/source/inc/adabas/BTables.hxx b/connectivity/source/inc/adabas/BTables.hxx
new file mode 100644
index 000000000000..089cbd082b42
--- /dev/null
+++ b/connectivity/source/inc/adabas/BTables.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_ADABAS_TABLES_HXX_
+#define _CONNECTIVITY_ADABAS_TABLES_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+namespace connectivity
+{
+ namespace adabas
+ {
+ 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);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+
+ void setComments(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void createTable( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+
+ virtual ::rtl::OUString getNameForObject(const sdbcx::ObjectType& _xObject);
+ 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);
+
+ // XDrop
+ void appendNew(const ::rtl::OUString& _rsNewTable);
+ // some helper functions
+ /**
+ returns a sql string which contains the column definition part for create or alter statements
+ */
+ static ::rtl::OUString getColumnSqlType(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColProp);
+ /**
+ returns the "not null" part or the default part of the table statement
+ */
+ static ::rtl::OUString getColumnSqlNotNullDefault(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColProp);
+ /**
+ returns the corresponding typename
+ can contain () which have to filled with values
+ */
+ static ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColProp);
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADABAS_TABLES_HXX_
+
diff --git a/connectivity/source/inc/adabas/BUser.hxx b/connectivity/source/inc/adabas/BUser.hxx
new file mode 100644
index 000000000000..d694b950e120
--- /dev/null
+++ b/connectivity/source/inc/adabas/BUser.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_ADABAS_USER_HXX_
+#define _CONNECTIVITY_ADABAS_USER_HXX_
+
+#include "connectivity/sdbcx/VUser.hxx"
+
+namespace connectivity
+{
+ namespace adabas
+ {
+ class OAdabasConnection;
+ typedef connectivity::sdbcx::OUser OUser_TYPEDEF;
+
+ class OAdabasUser : public OUser_TYPEDEF
+ {
+ OAdabasConnection* m_pConnection;
+
+ ::rtl::OUString getPrivilegeString(sal_Int32 nRights) const;
+ // return the privileges and additional the grant rights
+ void getAnyTablePrivileges(const ::rtl::OUString& objName, sal_Int32& nRights,sal_Int32& nRightsWithGrant) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ public:
+ virtual void refreshGroups();
+ public:
+ OAdabasUser( OAdabasConnection* _pConnection);
+ OAdabasUser( OAdabasConnection* _pConnection,const ::rtl::OUString& _Name);
+
+ // XUser
+ virtual void SAL_CALL changePassword( const ::rtl::OUString& objPassword, const ::rtl::OUString& newPassword ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XAuthorizable
+ virtual sal_Int32 SAL_CALL getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+
+ class OUserExtend;
+ typedef ::comphelper::OPropertyArrayUsageHelper<OUserExtend> OUserExtend_PROP;
+
+ class OUserExtend : public OAdabasUser,
+ public OUserExtend_PROP
+ {
+ protected:
+ ::rtl::OUString m_Password;
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ public:
+ OUserExtend(OAdabasConnection* _pConnection);
+
+ virtual void construct();
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADABAS_USER_HXX_
+
diff --git a/connectivity/source/inc/adabas/BUsers.hxx b/connectivity/source/inc/adabas/BUsers.hxx
new file mode 100644
index 000000000000..7f5d588e96ae
--- /dev/null
+++ b/connectivity/source/inc/adabas/BUsers.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_ADABAS_USERS_HXX_
+#define _CONNECTIVITY_ADABAS_USERS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+namespace connectivity
+{
+ namespace sdbcx
+ {
+ class IRefreshableUsers;
+ }
+ namespace adabas
+ {
+ class OAdabasConnection;
+ class OUsers : public sdbcx::OCollection
+ {
+ OAdabasConnection* m_pConnection;
+ connectivity::sdbcx::IRefreshableUsers* m_pParent;
+ public:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ OUsers( ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector,
+ OAdabasConnection* _pConnection,
+ connectivity::sdbcx::IRefreshableUsers* _pParent) : sdbcx::OCollection(_rParent,sal_True,_rMutex,_rVector)
+ ,m_pConnection(_pConnection)
+ ,m_pParent(_pParent)
+ {}
+
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_ADABAS_USERS_HXX_
+
diff --git a/connectivity/source/inc/adabas/BViews.hxx b/connectivity/source/inc/adabas/BViews.hxx
new file mode 100644
index 000000000000..cfb0389b28e9
--- /dev/null
+++ b/connectivity/source/inc/adabas/BViews.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_ADABAS_VIEWS_HXX_
+#define _CONNECTIVITY_ADABAS_VIEWS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+namespace connectivity
+{
+ namespace adabas
+ {
+ class OViews : public sdbcx::OCollection
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+ sal_Bool m_bInDrop;
+ // OCatalog* m_pParent;
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+
+ void createView( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ public:
+ OViews(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)
+ ,m_bInDrop(sal_False)
+ {}
+
+ // only the name is identical to ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ void dropByNameImpl(const ::rtl::OUString& elementName);
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADABAS_VIEWS_HXX_
+
diff --git a/connectivity/source/inc/ado/ACallableStatement.hxx b/connectivity/source/inc/ado/ACallableStatement.hxx
new file mode 100644
index 000000000000..be36bb3edca2
--- /dev/null
+++ b/connectivity/source/inc/ado/ACallableStatement.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_ADO_ACALLABLESTATEMENT_HXX_
+#define _CONNECTIVITY_ADO_ACALLABLESTATEMENT_HXX_
+
+#include "ado/APreparedStatement.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XOutParameters.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+namespace connectivity
+{
+ namespace ado
+ {
+ //**************************************************************
+ //************ Class: java.sql.CallableStatement
+ //**************************************************************
+
+ class OCallableStatement : public OPreparedStatement,
+ public ::com::sun::star::sdbc::XRow,
+ public ::com::sun::star::sdbc::XOutParameters
+ {
+ OLEVariant m_aValue;
+ public:
+ DECLARE_SERVICE_INFO();
+ virtual ~OCallableStatement() {} ;
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ OCallableStatement( OConnection* _pConnection,const OTypeInfoMap& _TypeInfo,const ::rtl::OUString& sql );
+
+ 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();
+
+ // 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);
+ // XOutParameters
+ virtual void SAL_CALL registerOutParameter( 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 registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+#endif // _CONNECTIVITY_OCallableStatement_HXX_
+
+
diff --git a/connectivity/source/inc/ado/ACatalog.hxx b/connectivity/source/inc/ado/ACatalog.hxx
new file mode 100644
index 000000000000..e622367e0b53
--- /dev/null
+++ b/connectivity/source/inc/ado/ACatalog.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_ADO_CATALOG_HXX_
+#define _CONNECTIVITY_ADO_CATALOG_HXX_
+
+#include "connectivity/sdbcx/VCatalog.hxx"
+#include "ado/Awrapadox.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class OConnection;
+
+ class OCatalog : public connectivity::sdbcx::OCatalog
+ {
+ WpADOCatalog m_aCatalog;
+ OConnection* m_pConnection;
+
+ public:
+ virtual void refreshTables();
+ virtual void refreshViews() ;
+ virtual void refreshGroups();
+ virtual void refreshUsers() ;
+
+ public:
+ OCatalog(_ADOCatalog* _pCatalog,OConnection* _pCon);
+ ~OCatalog();
+
+ OConnection* getConnection() const { return m_pConnection; }
+ sdbcx::OCollection* getPrivateTables() const { return m_pTables; }
+ WpADOCatalog getCatalog() const { return m_aCatalog; }
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADO_CATALOG_HXX_
+
diff --git a/connectivity/source/inc/ado/ACollection.hxx b/connectivity/source/inc/ado/ACollection.hxx
new file mode 100644
index 000000000000..b1e291ce1d5c
--- /dev/null
+++ b/connectivity/source/inc/ado/ACollection.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_ADO_COLLECTION_HXX_
+#define _CONNECTIVITY_ADO_COLLECTION_HXX_
+
+#include <cppuhelper/implbase3.hxx>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include "ado/Awrapadox.hxx"
+#include "ado/Aolevariant.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+namespace connectivity
+{
+ namespace ado
+ {
+ namespace starcontainer = ::com::sun::star::container;
+ namespace starlang = ::com::sun::star::lang;
+ namespace staruno = ::com::sun::star::uno;
+ namespace starbeans = ::com::sun::star::beans;
+
+ typedef ::cppu::WeakImplHelper3< starcontainer::XNameAccess,
+ starcontainer::XIndexAccess,
+ starlang::XServiceInfo> OCollectionBase;
+
+ //************************************************************
+ // OCollection
+ //************************************************************
+ template <class T,class SimT,class OCl> class OCollection : public OCollectionBase
+ {
+ private:
+ OCollection( const OCollection& ); // never implemented
+ OCollection& operator=( const OCollection& ); // never implemented
+
+ protected:
+ vector<OCl*> m_aElements;
+ ::cppu::OWeakObject& m_rParent;
+ ::osl::Mutex& m_rMutex; // mutex of the parent
+ T* m_pCollection;
+
+
+ public:
+ OCollection(::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex,T* _pCollection)
+ : m_rParent(_rParent)
+ ,m_rMutex(_rMutex)
+ ,m_pCollection(_pCollection)
+ {
+ m_pCollection->AddRef();
+ }
+
+ ~OCollection()
+ {
+ m_pCollection->Release();
+ }
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (staruno::RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ACollection");
+ }
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& _rServiceName ) throw(staruno::RuntimeException)
+ {
+ staruno::Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported)
+ if (pSupported->equals(_rServiceName))
+ return sal_True;
+
+ return sal_False;
+ }
+ virtual staruno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(staruno::RuntimeException)
+ {
+ staruno::Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Container");
+ return aSupported;
+ }
+
+ // dispatch the refcounting to the parent
+ virtual void SAL_CALL acquire() throw()
+ {
+ m_rParent.acquire();
+ }
+ virtual void SAL_CALL release() throw()
+ {
+ m_rParent.release();
+ }
+
+ // ::com::sun::star::container::XElementAccess
+ virtual staruno::Type SAL_CALL getElementType( ) throw(staruno::RuntimeException)
+ {
+ return::getCppuType(static_cast< staruno::Reference< starbeans::XPropertySet>*>(NULL));
+ }
+
+ virtual sal_Bool SAL_CALL hasElements( ) throw(staruno::RuntimeException)
+ {
+ ::osl::MutexGuard aGuard(m_rMutex);
+ return getCount() > 0;
+ }
+
+ // starcontainer::XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount( ) throw(staruno::RuntimeException)
+ {
+ ::osl::MutexGuard aGuard(m_rMutex);
+ sal_Int32 nCnt = 0;
+ m_pCollection->get_Count(&nCnt);
+ return nCnt;
+ }
+
+ virtual staruno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(starlang::IndexOutOfBoundsException, starlang::WrappedTargetException, staruno::RuntimeException)
+ {
+ ::osl::MutexGuard aGuard(m_rMutex);
+ if (Index < 0 || Index >= getCount())
+ throw starlang::IndexOutOfBoundsException();
+ SimT* pCol = NULL;
+ m_pCollection->get_Item(OLEVariant(Index),&pCol);
+ if(!pCol)
+ throw starlang::IndexOutOfBoundsException();
+
+ OCl* pIndex = new OCl(pCol);
+
+ m_aElements.push_back(pIndex);
+
+ return staruno::makeAny( staruno::Reference< starbeans::XPropertySet >(pIndex));
+ }
+
+
+ // starcontainer::XNameAccess
+ virtual staruno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(starcontainer::NoSuchElementException, starlang::WrappedTargetException, staruno::RuntimeException)
+ {
+ ::osl::MutexGuard aGuard(m_rMutex);
+
+ SimT* pCol = NULL;
+ m_pCollection->get_Item(OLEVariant(aName),&pCol);
+ if(!pCol)
+ throw starlang::IndexOutOfBoundsException();
+
+ OCl* pIndex = new OCl(pCol);
+
+ m_aElements.push_back(pIndex);
+
+ return staruno::makeAny( staruno::Reference< starbeans::XPropertySet >(pIndex));
+ }
+ virtual staruno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw(staruno::RuntimeException)
+ {
+ ::osl::MutexGuard aGuard(m_rMutex);
+ sal_Int32 nLen = getCount();
+ staruno::Sequence< ::rtl::OUString > aNameList(nLen);
+
+ ::rtl::OUString* pStringArray = aNameList.getArray();
+ OLEVariant aVar;
+ for (sal_Int32 i=0;i<nLen;++i)
+ {
+ aVar.setInt32(i);
+ SimT* pIdx = NULL;
+ m_pCollection->get_Item(aVar,&pIdx);
+ pIdx->AddRef();
+ _bstr_t sBSTR;
+ pIdx->get_Name(&sBSTR);
+ (*pStringArray) = (sal_Unicode*)sBSTR;
+ pIdx->Release();
+ ++pStringArray;
+ }
+ return aNameList;
+ }
+ virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(staruno::RuntimeException)
+ {
+ ::osl::MutexGuard aGuard(m_rMutex);
+ SimT* pCol = NULL;
+ m_pCollection->get_Item(OLEVariant(aName),&pCol);
+ return pCol != NULL;
+ }
+
+ void SAL_CALL disposing()
+ {
+ ::osl::MutexGuard aGuard(m_rMutex);
+ for (::std::vector<OCl*>::const_iterator i = m_aElements.begin(); i != m_aElements.end(); ++i)
+ {
+ (*i)->disposing();
+ (*i)->release();
+ }
+ m_aElements.clear();
+ }
+
+ };
+
+ class OIndex;
+ class OKey;
+ class OColumn;
+ class OTable;
+ class OView;
+ class OGroup;
+ class OUser;
+
+ typedef OCollection< ADOIndexes,ADOIndex,OIndex> OIndexes;
+ typedef OCollection< ADOKeys,ADOKey,OKey> OKeys;
+ typedef OCollection< ADOColumns,ADOColumn,OColumn> OColumns;
+ typedef OCollection< ADOTables,ADOTable,OTable> OTables;
+ typedef OCollection< ADOViews,ADOView,OView> OViews;
+ typedef OCollection< ADOGroups,ADOGroup,OGroup> OGroups;
+ typedef OCollection< ADOUsers,ADOUser,OUser> OUsers;
+
+ }
+}
+#endif // _CONNECTIVITY_ADO_COLLECTION_HXX_
+
+
+
diff --git a/connectivity/source/inc/ado/AColumn.hxx b/connectivity/source/inc/ado/AColumn.hxx
new file mode 100644
index 000000000000..f8eb107425dc
--- /dev/null
+++ b/connectivity/source/inc/ado/AColumn.hxx
@@ -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 _CONNECTIVITY_ADO_COLUMN_HXX_
+#define _CONNECTIVITY_ADO_COLUMN_HXX_
+
+#include "connectivity/sdbcx/VColumn.hxx"
+#include "ado/Awrapadox.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class OConnection;
+ typedef sdbcx::OColumn OColumn_ADO;
+ class OAdoColumn : public OColumn_ADO
+ {
+ WpADOColumn m_aColumn;
+ OConnection* m_pConnection;
+ ::rtl::OUString m_ReferencedColumn;
+ sal_Bool m_IsAscending;
+
+ void fillPropertyValues();
+ protected:
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue
+ )
+ throw (::com::sun::star::uno::Exception);
+ public:
+ OAdoColumn(sal_Bool _bCase,OConnection* _pConnection,_ADOColumn* _pColumn);
+ OAdoColumn(sal_Bool _bCase,OConnection* _pConnection);
+ // ODescriptor
+ virtual void construct();
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ // 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();
+
+ WpADOColumn getColumnImpl() const;
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADO_COLUMN_HXX_
+
diff --git a/connectivity/source/inc/ado/AColumns.hxx b/connectivity/source/inc/ado/AColumns.hxx
new file mode 100644
index 000000000000..5bbda06ab7a4
--- /dev/null
+++ b/connectivity/source/inc/ado/AColumns.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_ADO_COLUMNS_HXX_
+#define _CONNECTIVITY_ADO_COLUMNS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include "ado/Awrapadox.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class OConnection;
+ class OColumns : public sdbcx::OCollection
+ {
+ protected:
+ WpADOColumns m_aCollection;
+ OConnection* m_pConnection;
+
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ OColumns( ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector,
+ const WpADOColumns& _rCollection,
+ sal_Bool _bCase,
+ OConnection* _pConnection) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector)
+ ,m_aCollection(_rCollection)
+ ,m_pConnection(_pConnection)
+ {
+ }
+
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADO_COLUMNS_HXX_
+
diff --git a/connectivity/source/inc/ado/AConnection.hxx b/connectivity/source/inc/ado/AConnection.hxx
new file mode 100644
index 000000000000..67537155881c
--- /dev/null
+++ b/connectivity/source/inc/ado/AConnection.hxx
@@ -0,0 +1,151 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_ADO_ACONNECTION_HXX_
+#define _CONNECTIVITY_ADO_ACONNECTION_HXX_
+
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include "OSubComponent.hxx"
+#include <map>
+#include "connectivity/CommonTools.hxx"
+#include "OTypeInfo.hxx"
+#include "TConnection.hxx"
+#include "ado/Awrapado.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ struct OExtendedTypeInfo
+ {
+ ::connectivity::OTypeInfo aSimpleType; // the general type info
+ DataTypeEnum eType;
+
+ inline ::rtl::OUString getDBName() const { return aSimpleType.aTypeName; }
+ };
+
+ class WpADOConnection;
+ class ODriver;
+ class OCatalog;
+ typedef ::std::multimap<DataTypeEnum, OExtendedTypeInfo*> OTypeInfoMap;
+ typedef connectivity::OMetaConnection OConnection_BASE;
+
+
+ class OConnection : public OConnection_BASE,
+ public connectivity::OSubComponent<OConnection, OConnection_BASE>
+ {
+ friend class connectivity::OSubComponent<OConnection, OConnection_BASE>;
+
+ protected:
+ //====================================================================
+ // Data attributes
+ //====================================================================
+ OTypeInfoMap m_aTypeInfo; // vector containing an entry
+ // for each row returned by
+ // DatabaseMetaData.getTypeInfo.
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog;
+ ODriver* m_pDriver;
+ private:
+ WpADOConnection* m_pAdoConnection;
+ OCatalog* m_pCatalog;
+ sal_Int32 m_nEngineType;
+ sal_Bool m_bClosed;
+ sal_Bool m_bAutocommit;
+
+ protected:
+ void buildTypeInfo() throw( ::com::sun::star::sdbc::SQLException);
+ public:
+
+ OConnection(ODriver* _pDriver) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // OConnection(const SQLHANDLE _pConnectionHandle);
+ ~OConnection();
+ void construct(const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info);
+
+ void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException);
+
+ //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();
+ // XServiceInfo
+ DECLARE_SERVICE_INFO();
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XInterface
+ virtual void SAL_CALL release() throw();
+
+ // 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);
+ //
+ WpADOConnection* getConnection() { return m_pAdoConnection; }
+ void setCatalog(const ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier>& _xCat) { m_xCatalog = _xCat; }
+ void setCatalog(OCatalog* _pCatalog) { m_pCatalog = _pCatalog; }
+
+ const OTypeInfoMap* getTypeInfo() const { return &m_aTypeInfo;}
+ OCatalog* getAdoCatalog() const
+ {
+ if ( m_xCatalog.get().is() )
+ return m_pCatalog;
+ return NULL;
+ }
+
+ sal_Int32 getEngineType() const { return m_nEngineType; }
+ ODriver* getDriver() const { return m_pDriver; }
+
+ static const OExtendedTypeInfo* getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo,
+ DataTypeEnum _nType,
+ const ::rtl::OUString& _sTypeName,
+ sal_Int32 _nPrecision,
+ sal_Int32 _nScale,
+ sal_Bool& _brForceToType);
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADO_ACONNECTION_HXX_
+
diff --git a/connectivity/source/inc/ado/ADatabaseMetaData.hxx b/connectivity/source/inc/ado/ADatabaseMetaData.hxx
new file mode 100644
index 000000000000..2252363e606c
--- /dev/null
+++ b/connectivity/source/inc/ado/ADatabaseMetaData.hxx
@@ -0,0 +1,230 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_ADO_ADATABASEMETADATA_HXX_
+#define _CONNECTIVITY_ADO_ADATABASEMETADATA_HXX_
+
+#include "TDatabaseMetaDataBase.hxx"
+#ifndef _MAP_
+#include <map>
+#endif
+
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class WpADOConnection;
+ class OConnection;
+ //**************************************************************
+ //************ Class: ODatabaseMetaData
+ //**************************************************************
+
+ class ODatabaseMetaData : public ODatabaseMetaDataBase
+ {
+ typedef struct _LiteralInfo
+ {
+ ::rtl::OUString pwszLiteralValue;
+ sal_uInt32 cchMaxLen;
+ sal_Bool fSupported;
+ } LiteralInfo;
+
+ ::std::map<sal_uInt32,LiteralInfo> m_aLiteralInfo;
+ WpADOConnection* m_pADOConnection;
+ OConnection* m_pConnection;
+
+ void fillLiterals();
+ // get information out of rowset
+ sal_Int32 getMaxSize(sal_uInt32 _nId);
+ sal_Bool isCapable(sal_uInt32 _nId);
+ ::rtl::OUString getLiteral(sal_uInt32 _nProperty);
+
+ // get info out of propertyst
+ ::rtl::OUString getStringProperty(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getInt32Property(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Bool getBoolProperty(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ 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( );
+ public:
+
+ ODatabaseMetaData(OConnection* _pCon);
+
+ // 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 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 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 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);
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADO_ADATABASEMETADATA_HXX_
+
+
diff --git a/connectivity/source/inc/ado/ADatabaseMetaDataResultSet.hxx b/connectivity/source/inc/ado/ADatabaseMetaDataResultSet.hxx
new file mode 100644
index 000000000000..ce422f7ce528
--- /dev/null
+++ b/connectivity/source/inc/ado/ADatabaseMetaDataResultSet.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_ADO_ADATABASEMETADATARESULTSET_HXX_
+#define _CONNECTIVITY_ADO_ADATABASEMETADATARESULTSET_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 <cppuhelper/compbase7.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include "ado/AStatement.hxx"
+//#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+//#include "connectivity/CommonTools.hxx"
+//#endif
+#include <comphelper/broadcasthelper.hxx>
+#include "connectivity/StdTypeDefs.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class ODatabaseMetaDataResultSetMetaData;
+ /*
+ ** java_sql_ResultSet
+ */
+ typedef ::cppu::WeakComponentImplHelper7< ::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> ODatabaseMetaDataResultSet_BASE;
+
+ class ODatabaseMetaDataResultSet : public comphelper::OBaseMutex,
+ public ODatabaseMetaDataResultSet_BASE,
+ public ::cppu::OPropertySetHelper,
+ public ::comphelper::OPropertyArrayUsageHelper<ODatabaseMetaDataResultSet>
+ {
+ ::std::vector<sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 everytime
+
+ ::std::map<sal_Int32, TInt2IntMap > m_aValueRange;
+ ::std::map<sal_Int32, TInt2IntMap >::iterator m_aValueRangeIter;
+
+ ::std::map<sal_Int32, ::std::map< ::rtl::OUString,sal_Int32> > m_aStrValueRange;
+ ::std::map<sal_Int32, ::std::map< ::rtl::OUString,sal_Int32> >::iterator m_aStrValueRangeIter;
+
+ ::std::map<sal_Int32, ::std::map< sal_Int32,::rtl::OUString> > m_aIntValueRange;
+ ::std::map<sal_Int32, ::std::map< sal_Int32,::rtl::OUString> >::iterator m_aIntValueRangeIter;
+
+ ADORecordset* m_pRecordSet;
+ ::com::sun::star::uno::WeakReferenceHelper m_aStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData;
+ OLEVariant m_aValue;
+ sal_Int32 m_nRowPos;
+ sal_Bool m_bWasNull;
+ sal_Bool m_bEOF;
+ sal_Bool m_bOnFirstAfterOpen;
+
+ sal_Int32 getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ ::rtl::OUString getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ void setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+
+ inline sal_Int32 mapColumn (sal_Int32 column);
+ void checkRecordSet() throw(::com::sun::star::sdbc::SQLException);
+ OLEVariant getValue(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ 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;
+ public:
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ ODatabaseMetaDataResultSet( ADORecordset* _pRecordSet);
+ ~ODatabaseMetaDataResultSet();
+
+ // ::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);
+
+ const ::std::vector<sal_Int32>& getColumnMapping() { return m_aColMapping; }
+
+ void setCatalogsMap();
+ void setSchemasMap();
+ void setColumnPrivilegesMap();
+ void setColumnsMap();
+ void setTablesMap();
+ void setProcedureColumnsMap();
+ void setProceduresMap();
+ void setExportedKeysMap();
+ void setImportedKeysMap();
+ void setPrimaryKeysMap();
+ void setIndexInfoMap();
+ void setTablePrivilegesMap();
+ void setCrossReferenceMap();
+ void setTypeInfoMap(sal_Bool _bJetEngine);
+ };
+ // -------------------------------------------------------------------------
+ inline sal_Int32 ODatabaseMetaDataResultSet::mapColumn (sal_Int32 column)
+ {
+ sal_Int32 map = column;
+
+ if (!m_aColMapping.empty())
+ {
+ // Validate column number
+ map = m_aColMapping[column];
+ }
+
+ return map;
+ }
+ }
+
+}
+#endif // _CONNECTIVITY_ADO_ADATABASEMETADATARESULTSET_HXX_
+
diff --git a/connectivity/source/inc/ado/ADatabaseMetaDataResultSetMetaData.hxx b/connectivity/source/inc/ado/ADatabaseMetaDataResultSetMetaData.hxx
new file mode 100644
index 000000000000..cf4e43335596
--- /dev/null
+++ b/connectivity/source/inc/ado/ADatabaseMetaDataResultSetMetaData.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_ADO_ADATABASEMETADATARESULTSETMETADATA_HXX_
+#define _CONNECTIVITY_ADO_ADATABASEMETADATARESULTSETMETADATA_HXX_
+
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <cppuhelper/implbase1.hxx>
+#ifndef _VECTOR_
+#include <vector>
+#endif
+#include "ado/Awrapado.hxx"
+#include "ado/ADatabaseMetaDataResultSet.hxx"
+#include "OColumn.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ //**************************************************************
+ //************ Class: ResultSetMetaData
+ //**************************************************************
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> ODatabaseMetaResultSetMetaData_BASE;
+
+ class ODatabaseMetaDataResultSetMetaData : public ODatabaseMetaResultSetMetaData_BASE
+ {
+ friend class ODatabaseMetaDataResultSet;
+
+ const ::std::vector<sal_Int32> &m_vMapping; // when not every column is needed
+ ::std::map<sal_Int32,connectivity::OColumn> m_mColumns;
+ ::std::map<sal_Int32,connectivity::OColumn>::const_iterator m_mColumnsIter;
+
+ ADORecordset* m_pRecordSet;
+ sal_Int32 m_nColCount;
+
+ private:
+ ODatabaseMetaDataResultSetMetaData( const ODatabaseMetaDataResultSetMetaData& ); // never implemented
+ ODatabaseMetaDataResultSetMetaData& operator=( const ODatabaseMetaDataResultSetMetaData& ); // never implemented
+
+ protected:
+ void setColumnPrivilegesMap();
+ void setColumnsMap();
+ void setTablesMap();
+ void setProcedureColumnsMap();
+ void setPrimaryKeysMap();
+ void setIndexInfoMap();
+ void setTablePrivilegesMap();
+ void setCrossReferenceMap();
+ void setTypeInfoMap();
+ void setProceduresMap();
+ public:
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ ODatabaseMetaDataResultSetMetaData( ADORecordset* _pRecordSet ,ODatabaseMetaDataResultSet* _pRes)
+ : m_pRecordSet(_pRecordSet),m_vMapping(_pRes->getColumnMapping()),
+ m_nColCount(m_vMapping.size()-1)
+ {
+ if(m_pRecordSet)
+ m_pRecordSet->AddRef();
+ }
+ ~ODatabaseMetaDataResultSetMetaData();
+
+ /// 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_ADO_ADATABASEMETARESULTSETMETADATA_HXX_
+
diff --git a/connectivity/source/inc/ado/ADriver.hxx b/connectivity/source/inc/ado/ADriver.hxx
new file mode 100644
index 000000000000..30986533fa34
--- /dev/null
+++ b/connectivity/source/inc/ado/ADriver.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_ADO_ADRIVER_HXX_
+#define _CONNECTIVITY_ADO_ADRIVER_HXX_
+
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/compbase3.hxx>
+#include "connectivity/CommonTools.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception );
+
+ typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XDriver,
+ ::com::sun::star::sdbcx::XDataDefinitionSupplier,
+ ::com::sun::star::lang::XServiceInfo
+ > ODriver_BASE;
+ class ODriver : public ODriver_BASE
+ {
+ ::osl::Mutex m_aMutex;
+
+ connectivity::OWeakRefArray m_xConnections; // vector containing a list
+ // of all the Connection objects
+ // for this Driver
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
+
+
+ public:
+ ODriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB);
+ ~ODriver();
+
+ // 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);
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const { return m_xORB; }
+
+ private:
+ void impl_checkURL_throw(const ::rtl::OUString& _sUrl);
+
+ // 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);
+
+ // XDataDefinitionSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByURL( 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);
+ };
+ }
+
+}
+#endif //_CONNECTIVITY_ADO_ADRIVER_HXX_
+
+
diff --git a/connectivity/source/inc/ado/AGroup.hxx b/connectivity/source/inc/ado/AGroup.hxx
new file mode 100644
index 000000000000..a42e41e9b216
--- /dev/null
+++ b/connectivity/source/inc/ado/AGroup.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_ADABAS_GROUP_HXX_
+#define _CONNECTIVITY_ADABAS_GROUP_HXX_
+
+#include "connectivity/sdbcx/VGroup.hxx"
+#include "ado/Awrapadox.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ typedef sdbcx::OGroup OGroup_ADO;
+ class OCatalog;
+
+ class OAdoGroup : public OGroup_ADO
+ {
+ WpADOGroup m_aGroup;
+ OCatalog* m_pCatalog;
+
+ sal_Int32 MapRight(RightsEnum _eNum);
+ RightsEnum Map2Right(sal_Int32 _eNum);
+ ObjectTypeEnum MapObjectType(sal_Int32 _ObjType);
+ protected:
+ virtual void SAL_CALL getFastPropertyValue(::com::sun::star::uno::Any& rValue,sal_Int32 nHandle) const;
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const ::com::sun::star::uno::Any& rValue)throw (::com::sun::star::uno::Exception);
+
+ public:
+ virtual void refreshUsers();
+ public:
+ OAdoGroup(OCatalog* _pParent,sal_Bool _bCase, ADOGroup* _pGroup=NULL);
+ OAdoGroup(OCatalog* _pParent,sal_Bool _bCase, const ::rtl::OUString& _Name);
+
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ // 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();
+
+ // XAuthorizable
+ virtual sal_Int32 SAL_CALL getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ WpADOGroup getImpl() const { return m_aGroup; }
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADABAS_GROUP_HXX_
+
diff --git a/connectivity/source/inc/ado/AGroups.hxx b/connectivity/source/inc/ado/AGroups.hxx
new file mode 100644
index 000000000000..10c3af7d5aea
--- /dev/null
+++ b/connectivity/source/inc/ado/AGroups.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_ADO_GROUPS_HXX_
+#define _CONNECTIVITY_ADO_GROUPS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include "ado/Awrapadox.hxx"
+#include "ado/ACatalog.hxx"
+
+namespace connectivity
+{
+ namespace sdbcx
+ {
+ class IRefreshableGroups;
+ }
+ namespace ado
+ {
+ class OAdabasConnection;
+ class OGroups : public sdbcx::OCollection
+ {
+ WpADOGroups m_aCollection;
+ OCatalog* m_pCatalog;
+ protected:
+
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ OGroups(OCatalog* _pParent,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector,
+ const WpADOGroups& _rCollection,sal_Bool _bCase) : sdbcx::OCollection(*_pParent,_bCase,_rMutex,_rVector)
+ ,m_aCollection(_rCollection)
+ ,m_pCatalog(_pParent)
+ {
+ }
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_ADO_GROUPS_HXX_
+
diff --git a/connectivity/source/inc/ado/AIndex.hxx b/connectivity/source/inc/ado/AIndex.hxx
new file mode 100644
index 000000000000..5989dc59bd67
--- /dev/null
+++ b/connectivity/source/inc/ado/AIndex.hxx
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_ADO_INDEX_HXX_
+#define _CONNECTIVITY_ADO_INDEX_HXX_
+
+#include "connectivity/sdbcx/VIndex.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "ado/Awrapadox.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ typedef sdbcx::OIndex OIndex_ADO;
+
+ class OConnection;
+ class OAdoIndex : public OIndex_ADO
+ {
+ WpADOIndex m_aIndex;
+ OConnection* m_pConnection;
+ protected:
+ void fillPropertyValues();
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const ::com::sun::star::uno::Any& rValue)throw (::com::sun::star::uno::Exception);
+ public:
+ virtual void refreshColumns();
+ public:
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ OAdoIndex(sal_Bool _bCase, OConnection* _pConnection,ADOIndex* _pIndex);
+ OAdoIndex(sal_Bool _bCase, OConnection* _pConnection);
+ // 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();
+
+ WpADOIndex getImpl() const { return m_aIndex;}
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADO_INDEX_HXX_
+
diff --git a/connectivity/source/inc/ado/AIndexColumn.hxx b/connectivity/source/inc/ado/AIndexColumn.hxx
new file mode 100644
index 000000000000..42a92b028540
--- /dev/null
+++ b/connectivity/source/inc/ado/AIndexColumn.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_ADABAS_INDEXCOLUMN_HXX_
+#define _CONNECTIVITY_ADABAS_INDEXCOLUMN_HXX_
+
+#include "ado/AColumn.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class OIndexColumn : public OAdoColumn
+ {
+ protected:
+ sal_Bool m_IsAscending;
+ public:
+ OIndexColumn();
+ OIndexColumn( sal_Bool _IsAscending,
+ 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);
+
+ virtual void construct();
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADABAS_INDEXCOLUMN_HXX_
+
diff --git a/connectivity/source/inc/ado/AIndexColumns.hxx b/connectivity/source/inc/ado/AIndexColumns.hxx
new file mode 100644
index 000000000000..251c31ab51b7
--- /dev/null
+++ b/connectivity/source/inc/ado/AIndexColumns.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_ADABAS_INDEXCOLUMNS_HXX_
+#define _CONNECTIVITY_ADABAS_INDEXCOLUMNS_HXX_
+
+#include "adabas/BColumns.hxx"
+
+namespace connectivity
+{
+ namespace adabas
+ {
+ class OIndexColumns : public OColumns
+ {
+ protected:
+ virtual ::com::sun::star::uno::Reference< starcontainer::XNamed > createObject(const ::rtl::OUString& _rName);
+ virtual ::com::sun::star::uno::Reference< starbeans::XPropertySet > createDescriptor();
+ public:
+ OIndexColumns( ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector,
+ OTable* _pTable,
+ connectivity::sdbcx::IRefreshableColumns* _pParent)
+ : OColumns(_rParent,_rMutex,_rVector,_pTable,_pParent)
+ {
+ }
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADABAS_INDEXCOLUMNS_HXX_
+
diff --git a/connectivity/source/inc/ado/AIndexes.hxx b/connectivity/source/inc/ado/AIndexes.hxx
new file mode 100644
index 000000000000..d74c4c30ba93
--- /dev/null
+++ b/connectivity/source/inc/ado/AIndexes.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_ADO_INDEXES_HXX_
+#define _CONNECTIVITY_ADO_INDEXES_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "ado/Awrapadox.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class OConnection;
+ class OIndexes : public sdbcx::OCollection
+ {
+ WpADOIndexes m_aCollection;
+ OConnection* m_pConnection;
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ OIndexes(::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector,
+ const WpADOIndexes& _rCollection,
+ sal_Bool _bCase,
+ OConnection* _pConnection)
+ : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector)
+ , m_aCollection(_rCollection)
+ , m_pConnection(_pConnection)
+ {
+ }
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_ADO_INDEXES_HXX_
+
diff --git a/connectivity/source/inc/ado/AKey.hxx b/connectivity/source/inc/ado/AKey.hxx
new file mode 100644
index 000000000000..bcf859be1699
--- /dev/null
+++ b/connectivity/source/inc/ado/AKey.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_ADO_KEY_HXX_
+#define _CONNECTIVITY_ADO_KEY_HXX_
+
+#include "connectivity/sdbcx/VKey.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "ado/Awrapadox.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ typedef sdbcx::OKey OKey_ADO;
+
+ class OConnection;
+ class OAdoKey : public OKey_ADO
+ {
+ WpADOKey m_aKey;
+ OConnection* m_pConnection;
+ protected:
+ void fillPropertyValues();
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const ::com::sun::star::uno::Any& rValue)throw (::com::sun::star::uno::Exception);
+ public:
+ virtual void refreshColumns();
+ public:
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ OAdoKey(sal_Bool _bCase,OConnection* _pConnection,ADOKey* _pKey);
+ OAdoKey(sal_Bool _bCase,OConnection* _pConnection);
+
+ // 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();
+
+ WpADOKey getImpl() const { return m_aKey;}
+ // map the update/delete rules
+ static RuleEnum Map2Rule(const sal_Int32& _eNum);
+ static sal_Int32 MapRule(const RuleEnum& _eNum);
+
+ // map the keytypes
+ static sal_Int32 MapKeyRule(const KeyTypeEnum& _eNum);
+ static KeyTypeEnum Map2KeyRule(const sal_Int32& _eNum);
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADO_KEY_HXX_
+
diff --git a/connectivity/source/inc/ado/AKeyColumn.hxx b/connectivity/source/inc/ado/AKeyColumn.hxx
new file mode 100644
index 000000000000..9cd349659e93
--- /dev/null
+++ b/connectivity/source/inc/ado/AKeyColumn.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_ADABAS_KEYCOLUMN_HXX_
+#define _CONNECTIVITY_ADABAS_KEYCOLUMN_HXX_
+
+#include "ado/AColumn.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class OKeyColumn : public OAdoColumn
+ {
+ protected:
+ ::rtl::OUString m_ReferencedColumn;
+ public:
+ 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);
+
+ virtual void construct();
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADABAS_KEYCOLUMN_HXX_
+
diff --git a/connectivity/source/inc/ado/AKeyColumns.hxx b/connectivity/source/inc/ado/AKeyColumns.hxx
new file mode 100644
index 000000000000..2cd3d2fd9c38
--- /dev/null
+++ b/connectivity/source/inc/ado/AKeyColumns.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_ADO_KEYCOLUMNS_HXX_
+#define _CONNECTIVITY_ADO_KEYCOLUMNS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class OKeyColumns : public OColumns
+ {
+ protected:
+ virtual ::com::sun::star::uno::Reference< starcontainer::XNamed > createObject(const ::rtl::OUString& _rName);
+ virtual ::com::sun::star::uno::Reference< starbeans::XPropertySet > createDescriptor();
+ public:
+ OKeyColumns( ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector,
+ OTable* _pTable,
+ connectivity::sdbcx::IRefreshableColumns* _pParent)
+ : OColumns(_rParent,_rMutex,_rVector,_pTable,_pParent)
+ {
+ }
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADO_KEYCOLUMNS_HXX_
+
diff --git a/connectivity/source/inc/ado/AKeys.hxx b/connectivity/source/inc/ado/AKeys.hxx
new file mode 100644
index 000000000000..27c9ce1f26dc
--- /dev/null
+++ b/connectivity/source/inc/ado/AKeys.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_ADO_KEYS_HXX_
+#define _CONNECTIVITY_ADO_KEYS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include "ado/Awrapadox.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class OConnection;
+ class OKeys : public sdbcx::OCollection
+ {
+ WpADOKeys m_aCollection;
+ OConnection* m_pConnection;
+
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ OKeys(::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector,
+ const WpADOKeys& _rCollection,
+ sal_Bool _bCase,
+ OConnection* _pConnection) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector)
+ ,m_aCollection(_rCollection)
+ ,m_pConnection(_pConnection)
+ {
+ }
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_ADO_KEYS_HXX_
+
diff --git a/connectivity/source/inc/ado/APreparedStatement.hxx b/connectivity/source/inc/ado/APreparedStatement.hxx
new file mode 100644
index 000000000000..cceae70f87fb
--- /dev/null
+++ b/connectivity/source/inc/ado/APreparedStatement.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_ADO_APREPAREDSTATEMENT_HXX_
+#define _CONNECTIVITY_ADO_APREPAREDSTATEMENT_HXX_
+
+
+#include "ado/AStatement.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/XClearParameters.hpp>
+#include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+namespace connectivity
+{
+ class OSQLParseNode;
+ namespace ado
+ {
+
+ class OPreparedStatement : public OStatement_Base,
+ public ::com::sun::star::sdbc::XPreparedStatement,
+ public ::com::sun::star::sdbc::XParameters,
+ public ::com::sun::star::sdbc::XPreparedBatchExecution,
+ public ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ public ::com::sun::star::lang::XServiceInfo
+
+ {
+ void setParameter(sal_Int32 parameterIndex, const DataTypeEnum& _eType,const sal_Int32& _nSize,const OLEVariant& _Val)
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void replaceParameterNodeName( OSQLParseNode* _pNode,
+ const ::rtl::OUString& _sDefaultName,
+ sal_Int32& _nParameterCount);
+ protected:
+ //====================================================================
+ // Data attributes
+ //====================================================================
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData;
+ const OTypeInfoMap& m_aTypeInfo;
+ ADOParameters* m_pParameters;
+
+ virtual ~OPreparedStatement();
+
+ public:
+ DECLARE_SERVICE_INFO();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ OPreparedStatement( OConnection* _pConnection,const OTypeInfoMap& _TypeInfo,const ::rtl::OUString& sql);
+
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() 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);
+
+ // 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);
+ // XPreparedBatchExecution
+ virtual void SAL_CALL addBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) 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);
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADO_APREPAREDSTATEMENT_HXX_
+
diff --git a/connectivity/source/inc/ado/AResultSet.hxx b/connectivity/source/inc/ado/AResultSet.hxx
new file mode 100644
index 000000000000..01d7796c03d4
--- /dev/null
+++ b/connectivity/source/inc/ado/AResultSet.hxx
@@ -0,0 +1,237 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_ADO_ARESULTSET_HXX_
+#define _CONNECTIVITY_ADO_ARESULTSET_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 "ado/AStatement.hxx"
+//#ifndef _CONNECTIVITY_COMMONTOOLS_HXX_
+//#include "connectivity/CommonTools.hxx"
+//#endif
+#include <comphelper/broadcasthelper.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class OResultSetMetaData;
+ /*
+ ** 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::XResultSetUpdate,
+ ::com::sun::star::sdbc::XRowUpdate,
+ ::com::sun::star::sdbc::XCloseable,
+ ::com::sun::star::sdbc::XColumnLocate,
+ ::com::sun::star::sdbcx::XRowLocate,
+ ::com::sun::star::sdbcx::XDeleteRows,
+ ::com::sun::star::lang::XServiceInfo> OResultSet_BASE;
+
+ class OResultSet : public comphelper::OBaseMutex,
+ public OResultSet_BASE,
+ public ::cppu::OPropertySetHelper,
+ public ::comphelper::OPropertyArrayUsageHelper<OResultSet>
+ {
+
+ ADORecordset* m_pRecordSet;
+ OStatement_Base* m_pStmt;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData;
+ ::std::vector<OLEVariant> m_aBookmarks;
+ OLEVariant m_aValue;
+ sal_Int32 m_nRowPos;
+ sal_Bool m_bWasNull;
+ sal_Bool m_bEOF;
+ sal_Bool m_bOnFirstAfterOpen;
+
+ sal_Int32 getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ ::rtl::OUString getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ void setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void updateValue(sal_Int32 columnIndex,const OLEVariant& x);
+ OLEVariant getValue(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ 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 ~OResultSet();
+ public:
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ OResultSet( ADORecordset* _pRecordSet,OStatement_Base* pStmt);
+ OResultSet( ADORecordset* _pRecordSet);
+
+ // late constructor
+ void construct();
+ inline void setMetaData(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData>& _xMetaData) { m_xMetaData = _xMetaData;}
+
+ 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);
+
+ // ::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);
+ // 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& 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);
+
+ };
+ }
+
+}
+#endif // _CONNECTIVITY_ADO_ARESULTSET_HXX_
+
+
diff --git a/connectivity/source/inc/ado/AResultSetMetaData.hxx b/connectivity/source/inc/ado/AResultSetMetaData.hxx
new file mode 100644
index 000000000000..3702679f8d86
--- /dev/null
+++ b/connectivity/source/inc/ado/AResultSetMetaData.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_ADO_ARESULTSETMETADATA_HXX_
+#define _CONNECTIVITY_ADO_ARESULTSETMETADATA_HXX_
+
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <cppuhelper/implbase1.hxx>
+#ifndef _VECTOR_
+#include <vector>
+#endif
+#include "ado/Awrapado.hxx"
+#include "ado/AResultSet.hxx"
+#include "OColumn.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+
+ //**************************************************************
+ //************ Class: ResultSetMetaData
+ //**************************************************************
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> OResultSetMetaData_BASE;
+
+ class OResultSetMetaData : public OResultSetMetaData_BASE
+ {
+ friend class OResultSet;
+
+ ADORecordset* m_pRecordSet;
+ sal_Int32 m_nColCount;
+
+ sal_Int32 MapADOType2Jdbc(DataTypeEnum eType);
+ private:
+ OResultSetMetaData( const OResultSetMetaData& ); // never implemented
+ OResultSetMetaData& operator=( const OResultSetMetaData& ); // never implemented
+
+ protected:
+ virtual ~OResultSetMetaData();
+ public:
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ OResultSetMetaData( ADORecordset* _pRecordSet);
+
+ 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_ADO_ARESULTSETMETADATA_HXX_
+
diff --git a/connectivity/source/inc/ado/AStatement.hxx b/connectivity/source/inc/ado/AStatement.hxx
new file mode 100644
index 000000000000..86b6d92fc724
--- /dev/null
+++ b/connectivity/source/inc/ado/AStatement.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_ADO_ASTATEMENT_HXX_
+#define _CONNECTIVITY_ADO_ASTATEMENT_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/XBatchExecution.hpp>
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
+#include <cppuhelper/compbase5.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/uno3.hxx>
+#include <comphelper/broadcasthelper.hxx>
+#include "ado/AConnection.hxx"
+#ifndef _LIST_
+#include <list>
+#endif
+#include "ado/Awrapado.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+namespace connectivity
+{
+ namespace ado
+ {
+ typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::sdbc::XStatement,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::util::XCancellable,
+ ::com::sun::star::sdbc::XCloseable,
+ ::com::sun::star::sdbc::XMultipleResults> OStatement_BASE;
+
+ //**************************************************************
+ //************ Class: java.sql.Statement
+ //**************************************************************
+ class OStatement_Base : public comphelper::OBaseMutex,
+ public OStatement_BASE,
+ public ::cppu::OPropertySetHelper,
+ public ::comphelper::OPropertyArrayUsageHelper<OStatement_Base>,
+ public connectivity::OSubComponent<OStatement_Base, OStatement_BASE>
+
+ {
+ friend class connectivity::OSubComponent<OStatement_Base, OStatement_BASE>;
+ friend class OResultSet;
+
+ ::com::sun::star::sdbc::SQLWarning m_aLastWarning;
+
+ protected:
+ ::std::list< ::rtl::OUString> m_aBatchList;
+
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created
+ // for this Statement
+
+ OConnection* m_pConnection;// The owning Connection object
+ WpADOCommand m_Command;
+ WpADORecordset m_RecordSet;
+ OLEVariant m_RecordsAffected;
+ OLEVariant m_Parameters;
+ ::std::vector<connectivity::OTypeInfo> m_aTypeInfo; // Hashtable containing an entry
+ // for each row returned by
+ // DatabaseMetaData.getTypeInfo.
+ sal_Int32 m_nMaxRows;
+ sal_Int32 m_nFetchSize;
+ LockTypeEnum m_eLockType;
+ CursorTypeEnum m_eCursorType;
+
+ using OStatement_BASE::rBHelper;
+ private:
+
+ sal_Int32 getQueryTimeOut() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getMaxFieldSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getMaxRows() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ ::rtl::OUString getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ void setQueryTimeOut(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setMaxFieldSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setMaxRows(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setResultSetConcurrency(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setResultSetType(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setCursorName(const ::rtl::OUString &_par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ protected:
+
+ void assignRecordSet( ADORecordset* _pRS );
+
+ void reset () throw( ::com::sun::star::sdbc::SQLException);
+ void clearMyResultSet () throw( ::com::sun::star::sdbc::SQLException);
+ void setWarning (const ::com::sun::star::sdbc::SQLWarning &ex) throw( ::com::sun::star::sdbc::SQLException);
+ sal_Int32 getColumnCount () throw( ::com::sun::star::sdbc::SQLException);
+ sal_Int32 getRowCount () throw( ::com::sun::star::sdbc::SQLException);
+ sal_Int32 getPrecision ( sal_Int32 sqlType);
+
+ void disposeResultSet();
+
+ // 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;
+ public:
+ OStatement_Base(OConnection* _pConnection );
+
+ using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XInterface
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() 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);
+ // 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);
+ };
+
+ class OStatement : public OStatement_Base,
+ public ::com::sun::star::sdbc::XBatchExecution,
+ public ::com::sun::star::lang::XServiceInfo
+ {
+ public:
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ OStatement( OConnection* _pConnection) : OStatement_Base( _pConnection){};
+ ~OStatement();
+
+ DECLARE_SERVICE_INFO();
+
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ // XBatchExecution
+ virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADO_ASTATEMENT_HXX_
+
diff --git a/connectivity/source/inc/ado/ATable.hxx b/connectivity/source/inc/ado/ATable.hxx
new file mode 100644
index 000000000000..1048f1e2823b
--- /dev/null
+++ b/connectivity/source/inc/ado/ATable.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_ADO_TABLE_HXX_
+#define _CONNECTIVITY_ADO_TABLE_HXX_
+
+#include "connectivity/sdbcx/VTable.hxx"
+#include "ado/Awrapadox.hxx"
+#include "ado/ACatalog.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ typedef connectivity::sdbcx::OTable OTable_TYPEDEF;
+ typedef connectivity::sdbcx::OTableDescriptor_BASE OTableDescriptor_BASE_TYPEDEF;
+
+ class OAdoTable : public OTable_TYPEDEF
+ {
+ WpADOTable m_aTable;
+ OCatalog* m_pCatalog;
+
+ protected:
+ void fillPropertyValues();
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const ::com::sun::star::uno::Any& rValue)throw (::com::sun::star::uno::Exception);
+
+ public:
+ virtual void refreshColumns();
+ virtual void refreshKeys();
+ virtual void refreshIndexes();
+
+ // ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ public:
+ OAdoTable(sdbcx::OCollection* _pTables,sal_Bool _bCase,OCatalog* _pCatalog,_ADOTable* _pTable);
+ OAdoTable(sdbcx::OCollection* _pTables,sal_Bool _bCase,OCatalog* _pCatalog);
+
+
+ virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+ ::rtl::OUString getSchema() const { return m_SchemaName; }
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() const;
+ // 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();
+
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ // XRename
+ virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+
+ // XAlterTable
+ virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& colName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL alterColumnByIndex( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ //
+ sal_Bool create() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ WpADOTable getImpl() const { return m_aTable;}
+ OCatalog* getCatalog() const { return m_pCatalog; }
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADO_TABLE_HXX_
+
diff --git a/connectivity/source/inc/ado/ATables.hxx b/connectivity/source/inc/ado/ATables.hxx
new file mode 100644
index 000000000000..0bba73babbc6
--- /dev/null
+++ b/connectivity/source/inc/ado/ATables.hxx
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_ADO_TABLES_HXX_
+#define _CONNECTIVITY_ADO_TABLES_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include "ado/Awrapadox.hxx"
+#include "ado/ACatalog.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class OCatalog;
+ class OTables : public sdbcx::OCollection
+ {
+ WpADOTables m_aCollection;
+ OCatalog* m_pCatalog;
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ void setComments(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ OTables(OCatalog* _pParent, ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector,
+ const WpADOTables& _rCollection,
+ sal_Bool _bCase) : sdbcx::OCollection(*_pParent,_bCase,_rMutex,_rVector)
+ ,m_pCatalog(_pParent)
+ ,m_aCollection(_rCollection)
+ {
+ OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
+ }
+ void appendNew(const ::rtl::OUString& _rsNewTable);
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADO_TABLES_HXX_
+
diff --git a/connectivity/source/inc/ado/AUser.hxx b/connectivity/source/inc/ado/AUser.hxx
new file mode 100644
index 000000000000..ec0b7cbba399
--- /dev/null
+++ b/connectivity/source/inc/ado/AUser.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_ADO_USER_HXX_
+#define _CONNECTIVITY_ADO_USER_HXX_
+
+#include "connectivity/sdbcx/VUser.hxx"
+#include "ado/Awrapadox.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class OCatalog;
+ typedef connectivity::sdbcx::OUser OUser_TYPEDEF;
+ typedef connectivity::sdbcx::OUser_BASE OUser_BASE_TYPEDEF;
+
+ class OAdoUser : public OUser_TYPEDEF
+ {
+ protected:
+ WpADOUser m_aUser;
+ OCatalog* m_pCatalog;
+
+ 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;
+ public:
+ virtual void refreshGroups();
+ public:
+ OAdoUser(OCatalog* _pParent,sal_Bool _bCase, ADOUser* _pUser=NULL);
+ OAdoUser(OCatalog* _pParent,sal_Bool _bCase, const ::rtl::OUString& _Name);
+
+ // 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();
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XUser
+ virtual void SAL_CALL changePassword( const ::rtl::OUString& objPassword, const ::rtl::OUString& newPassword ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XAuthorizable
+ virtual sal_Int32 SAL_CALL getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ WpADOUser getImpl() const { return m_aUser;}
+ };
+
+ class OUserExtend;
+ typedef ::comphelper::OPropertyArrayUsageHelper<OUserExtend> OUserExtend_PROP;
+
+ class OUserExtend : public OAdoUser,
+ public OUserExtend_PROP
+ {
+ protected:
+ ::rtl::OUString m_Password;
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ public:
+ OUserExtend(OCatalog* _pParent,sal_Bool _bCase,ADOUser* _pUser=NULL);
+ OUserExtend(OCatalog* _pParent,sal_Bool _bCase,const ::rtl::OUString& _Name);
+
+ virtual void construct();
+ ::rtl::OUString getPassword() const { return m_Password;}
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADO_USER_HXX_
+
diff --git a/connectivity/source/inc/ado/AUsers.hxx b/connectivity/source/inc/ado/AUsers.hxx
new file mode 100644
index 000000000000..aae377cca111
--- /dev/null
+++ b/connectivity/source/inc/ado/AUsers.hxx
@@ -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 _CONNECTIVITY_ADO_USERS_HXX_
+#define _CONNECTIVITY_ADO_USERS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include "ado/Awrapadox.hxx"
+#include "ado/ACatalog.hxx"
+
+namespace connectivity
+{
+ namespace sdbcx
+ {
+ class IRefreshableUsers;
+ }
+ namespace ado
+ {
+
+ class OUsers : public sdbcx::OCollection
+ {
+ WpADOUsers m_aCollection;
+ OCatalog* m_pCatalog;
+ public:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ OUsers( OCatalog* _pParent,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector,
+ const WpADOUsers& _rCollection,
+ sal_Bool _bCase)
+ :sdbcx::OCollection(*_pParent,_bCase,_rMutex,_rVector)
+ ,m_aCollection(_rCollection)
+ ,m_pCatalog(_pParent)
+ {
+ }
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_ADO_USERS_HXX_
+
diff --git a/connectivity/source/inc/ado/AView.hxx b/connectivity/source/inc/ado/AView.hxx
new file mode 100644
index 000000000000..90589c54a5c8
--- /dev/null
+++ b/connectivity/source/inc/ado/AView.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_ADO_VIEW_HXX_
+#define _CONNECTIVITY_ADO_VIEW_HXX_
+
+#include "connectivity/sdbcx/VView.hxx"
+#include "ado/Awrapadox.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+
+ typedef sdbcx::OView OView_ADO;
+
+ class OAdoView : public OView_ADO
+ {
+ WpADOView m_aView;
+
+ protected:
+ // OPropertySetHelper
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle
+ ) const;
+ public:
+ OAdoView(sal_Bool _bCase, ADOView* _pView=NULL);
+
+ // 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();
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ WpADOView getImpl() const { return m_aView;}
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_ADO_VIEW_HXX_
+
diff --git a/connectivity/source/inc/ado/AViews.hxx b/connectivity/source/inc/ado/AViews.hxx
new file mode 100644
index 000000000000..8411dfa2b82c
--- /dev/null
+++ b/connectivity/source/inc/ado/AViews.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_ADO_VIEWS_HXX_
+#define _CONNECTIVITY_ADO_VIEWS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include "ado/Awrapadox.hxx"
+#include "ado/ACatalog.hxx"
+
+
+namespace connectivity
+{
+ namespace ado
+ {
+
+ class OViews : public sdbcx::OCollection
+ {
+ WpADOViews m_aCollection;
+ OCatalog* m_pCatalog;
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ void setComments(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ OViews(OCatalog* _pParent, ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector,
+ WpADOViews& _rCollection,sal_Bool _bCase) : sdbcx::OCollection(*_pParent,_bCase,_rMutex,_rVector)
+ ,m_aCollection(_rCollection)
+ ,m_pCatalog(_pParent)
+ {
+ }
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADO_VIEWS_HXX_
+
diff --git a/connectivity/source/inc/ado/Aolevariant.hxx b/connectivity/source/inc/ado/Aolevariant.hxx
new file mode 100644
index 000000000000..ab2641396f9b
--- /dev/null
+++ b/connectivity/source/inc/ado/Aolevariant.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef _CONNECTIVITY_ADO_AOLEVARIANT_HXX_
+#define _CONNECTIVITY_ADO_AOLEVARIANT_HXX_
+
+#include <sal/types.h>
+#ifdef __MINGW32__
+#include <windows.h>
+#endif
+#include <rtl/ustring.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include "ado_pre_sys_include.h"
+#include <oaidl.h>
+#include "ado_post_sys_include.h"
+
+namespace com
+{
+ namespace sun
+ {
+ namespace star
+ {
+ namespace util
+ {
+ struct Date;
+ struct Time;
+ struct DateTime;
+ }
+ }
+ }
+}
+namespace connectivity
+{
+ namespace ado
+ {
+ class OLEString
+ {
+ BSTR m_sStr;
+ public:
+ OLEString();
+ OLEString(const BSTR& _sBStr);
+ OLEString(const ::rtl::OUString& _sBStr);
+ OLEString(const OLEString& _rRh)
+ {
+ OLEString::operator=(_rRh);
+ }
+ ~OLEString();
+ OLEString& operator=(const ::rtl::OUString& _rSrc);
+ OLEString& operator=(const BSTR& _rSrc);
+ OLEString& operator=(const OLEString& _rSrc);
+ operator ::rtl::OUString() const;
+ operator BSTR() const;
+ BSTR* operator &();
+ sal_Int32 length() const;
+ };
+
+ class OLEVariant : public ::tagVARIANT
+ {
+ public:
+ OLEVariant();
+ OLEVariant(const VARIANT& varSrc);
+ OLEVariant(const OLEVariant& varSrc) ;
+ OLEVariant(sal_Bool x) ;
+ OLEVariant(sal_Int8 n) ;
+ OLEVariant(sal_Int16 n) ;
+ OLEVariant(sal_Int32 n) ;
+ OLEVariant(sal_Int64 x) ;
+
+ OLEVariant(const rtl::OUString& us) ;
+ ~OLEVariant() ;
+ OLEVariant(const ::com::sun::star::util::Date& x );
+ OLEVariant(const ::com::sun::star::util::Time& x );
+ OLEVariant(const ::com::sun::star::util::DateTime& x );
+ OLEVariant(const float &x);
+ OLEVariant(const double &x);
+ OLEVariant(IDispatch* pDispInterface);
+ OLEVariant(const ::com::sun::star::uno::Sequence< sal_Int8 >& x);
+ OLEVariant& operator=(const OLEVariant& varSrc);
+ // Assign a const VARIANT& (::VariantCopy handles everything)
+ //
+ OLEVariant& operator=(const tagVARIANT& varSrc);
+ // Assign a const VARIANT* (::VariantCopy handles everything)
+ //
+ OLEVariant& operator=(const VARIANT* pSrc);
+ void setByte(sal_uInt8 n) ;
+ void setInt16(sal_Int16 n) ;
+ void setInt32(sal_Int32 n) ;
+ void setFloat(float f) ;
+ void setDouble(double d) ;
+ void setDate(DATE d) ;
+ void setChar(unsigned char a) ;
+ void setCurrency(double aCur) ;
+ void setBool(sal_Bool b) ;
+ void setString(const rtl::OUString& us) ;
+ void setNoArg() ;
+
+ void setIDispatch(IDispatch* pDispInterface);
+ void setNull() ;
+ void setEmpty() ;
+
+ void setUI1SAFEARRAYPtr(SAFEARRAY* pSafeAr);
+ void setArray(SAFEARRAY* pSafeArray, VARTYPE vtType);
+ sal_Bool isNull() const ;
+ sal_Bool isEmpty() const ;
+
+ VARTYPE getType() const ;
+ void ChangeType(VARTYPE vartype, const OLEVariant* pSrc);
+
+
+ operator ::rtl::OUString() const;
+
+ operator sal_Bool() const { return getBool(); }
+ operator sal_Int8() const { return getInt8(); }
+ operator sal_Int16() const { return getInt16(); }
+ operator sal_Int32() const { return getInt32(); }
+ operator float() const { return getFloat(); }
+ operator double() const { return getDouble(); }
+
+ operator ::com::sun::star::uno::Sequence< sal_Int8 >() const;
+ operator ::com::sun::star::util::Date() const ;
+ operator ::com::sun::star::util::Time() const ;
+ operator ::com::sun::star::util::DateTime()const ;
+ ::rtl::OUString getString() const;
+ sal_Bool getBool() const;
+ IUnknown* getIUnknown() const;
+ IDispatch* getIDispatch() const;
+ sal_uInt8 getByte() const;
+ sal_Int16 getInt16() const;
+ sal_Int8 getInt8() const;
+ sal_Int32 getInt32() const;
+ sal_uInt32 getUInt32() const;
+ float getFloat() const;
+ double getDouble() const;
+ double getDate() const;
+ CY getCurrency() const;
+ SAFEARRAY* getUI1SAFEARRAYPtr() const;
+ ::com::sun::star::uno::Any makeAny() const;
+
+ static VARIANT_BOOL VariantBool(sal_Bool bEinBoolean);
+
+ private:
+ void CHS();
+
+ void set(double n);
+
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_ADO_AOLEVARIANT_HXX_
+
diff --git a/connectivity/source/inc/ado/Aolewrap.hxx b/connectivity/source/inc/ado/Aolewrap.hxx
new file mode 100644
index 000000000000..8bc9c4b4fa70
--- /dev/null
+++ b/connectivity/source/inc/ado/Aolewrap.hxx
@@ -0,0 +1,245 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_ADO_AOLEWRAP_HXX_
+#define _CONNECTIVITY_ADO_AOLEWRAP_HXX_
+
+#include <osl/diagnose.h>
+#include <osl/thread.h>
+#include <map>
+#include <vector>
+#include "connectivity/StdTypeDefs.hxx"
+
+namespace rtl
+{
+ class OUString;
+}
+namespace connectivity
+{
+ namespace ado
+ {
+ class OLEVariant;
+ class WpBase
+ {
+ protected:
+ IDispatch* pIUnknown;
+
+ void setIDispatch(IDispatch* _pIUnknown);
+ public:
+ WpBase();
+ WpBase(IDispatch* pInt);
+ //inline
+ WpBase& operator=(const WpBase& rhs);
+ WpBase& operator=(IDispatch* rhs);
+ WpBase(const WpBase& aWrapper);
+ virtual ~WpBase();
+ void clear();
+
+
+ sal_Bool IsValid() const;
+ operator IDispatch*();
+
+ };
+ //////////////////////////////////////////////////////////////////////////
+ //
+ // Template-Klasse WpOLEBase<class T>
+ // ==================================
+ //
+ // Objekte dieser Klasse haelt einen Zeiger auf ein Interface vom Typ T.
+ // Es gibt Konstruktoren und Zuweisungsoperator die sicherstellen, dass
+ // AddRef() und Release() entsprechend den COM-Konventionen gerufen werden.
+ // Ein Objekt kann auch keinen Zeiger halten (Nullzeiger), dann ergibt
+ // der Aufruf von IsValid() FALSE.
+ //
+ // Um effizientes pass-by-value machen zu koennen, ist diese (ebenso wie die
+ // abgeleiteten Klassen) eine ganz schmale Wrapper-Klasse unter Vermeidung
+ // virtueller Methoden und mit Inlining.
+
+ //------------------------------------------------------------------------
+ template<class T> class WpOLEBase : public WpBase
+ {
+ protected:
+ T* pInterface;
+
+ public:
+ WpOLEBase(T* pInt = NULL) : WpBase(pInt),pInterface(pInt){}
+
+
+ //inline
+ WpOLEBase<T>& operator=(const WpOLEBase<T>& rhs)
+ {
+ WpBase::operator=(rhs);
+ pInterface = rhs.pInterface;
+ return *this;
+ };
+
+ WpOLEBase<T>& operator=(T* rhs)
+ {
+ WpBase::operator=(rhs);
+ pInterface = rhs.pInterface;
+ return *this;
+ }
+
+ WpOLEBase(const WpOLEBase<T>& aWrapper)
+ {
+ operator=(aWrapper);
+ }
+
+ virtual ~WpOLEBase()
+ {
+ }
+
+ operator T*() const { return static_cast<T*>(pInterface); }
+ void setWithOutAddRef(T* _pInterface)
+ {
+ pInterface = _pInterface;
+ WpBase::setIDispatch(_pInterface);
+ }
+ };
+
+
+ //////////////////////////////////////////////////////////////////////////
+ //
+ // Template-Klasse WpOLECollection<class Ts, class T, class WrapT>
+ // ===============================================================
+ //
+ // Diese Klasse, welche sich von WpOLEBase<Ts> ableitet, abstrahiert die
+ // den DAO-Collections gemeinsamen Eigenschaften:
+ //
+ // Sie werden ueber ein Interface Ts (etwa: DAOFields) angesprochen
+ // und koennen ueber get_Item (hier:GetItem) Items des Typs T (genauer:
+ // mit Interface T, etwa DAOField) herausgeben.
+ //
+ // Diese Wrapperklasse gibt aber nicht ein Interface T heraus,
+ // sondern ein Objekt der Klasse WrapT. Dieses muss eine Konstruktion
+ // durch T zulassen, vorzugsweise ist es von WpOLEBase<T> abgeleitet.
+ //
+
+ //------------------------------------------------------------------------
+ template<class Ts, class T, class WrapT> class WpOLECollection : public WpOLEBase<Ts>
+ {
+ public:
+ using WpOLEBase<Ts>::pInterface;
+ using WpOLEBase<Ts>::IsValid;
+ // Konstruktoren, operator=
+ // diese rufen nur die Oberklasse
+ WpOLECollection(Ts* pInt=NULL):WpOLEBase<Ts>(pInt){}
+ WpOLECollection(const WpOLECollection& rhs){operator=(rhs);}
+ inline WpOLECollection& operator=(const WpOLECollection& rhs)
+ {WpOLEBase<Ts>::operator=(rhs); return *this;};
+
+ //////////////////////////////////////////////////////////////////////
+
+ inline void Refresh(){pInterface->Refresh();}
+
+ inline sal_Int32 GetItemCount() const
+ {
+ sal_Int32 nCount = 0;
+ return pInterface ? (SUCCEEDED(pInterface->get_Count(&nCount)) ? nCount : sal_Int32(0)) : sal_Int32(0);
+ }
+
+ inline WrapT GetItem(sal_Int32 index) const
+ {
+ OSL_ENSURE(index >= 0 && index<GetItemCount(),"Wrong index for field!");
+ T* pT = NULL;
+ WrapT aRet(NULL);
+ if(SUCCEEDED(pInterface->get_Item(OLEVariant(index), &pT)))
+ aRet.setWithOutAddRef(pT);
+ return aRet;
+ }
+
+ inline WrapT GetItem(const OLEVariant& index) const
+ {
+ T* pT = NULL;
+ WrapT aRet(NULL);
+ if(SUCCEEDED(pInterface->get_Item(index, &pT)))
+ aRet.setWithOutAddRef(pT);
+ return aRet;
+ }
+
+ inline WrapT GetItem(const ::rtl::OUString& sStr) const
+ {
+ WrapT aRet(NULL);
+ T* pT = NULL;
+ if (FAILED(pInterface->get_Item(OLEVariant(sStr), &pT)))
+ {
+#if OSL_DEBUG_LEVEL > 0
+ ::rtl::OString sTemp("Unknown Item: ");
+ sTemp += ::rtl::OString(sStr.getStr(),sStr.getLength(),osl_getThreadTextEncoding());
+ OSL_ENSURE(0,sTemp);
+#endif
+ }
+ else
+ aRet.setWithOutAddRef(pT);
+ return aRet;
+ }
+ inline void fillElementNames(TStringVector& _rVector)
+ {
+ if(IsValid())
+ {
+ Refresh();
+ sal_Int32 nCount = GetItemCount();
+ _rVector.reserve(nCount);
+ for(sal_Int32 i=0;i< nCount;++i)
+ {
+ WrapT aElement = GetItem(i);
+ if(aElement.IsValid())
+ _rVector.push_back(aElement.get_Name());
+ }
+ }
+ }
+ };
+
+ template<class Ts, class T, class WrapT> class WpOLEAppendCollection:
+ public WpOLECollection<Ts,T,WrapT>
+ {
+
+ public:
+ // Konstruktoren, operator=
+ // diese rufen nur die Oberklasse
+ using WpOLEBase<Ts>::pInterface;
+ WpOLEAppendCollection(Ts* pInt=NULL):WpOLECollection<Ts,T,WrapT>(pInt){}
+ WpOLEAppendCollection(const WpOLEAppendCollection& rhs){ operator=(rhs); }
+ inline WpOLEAppendCollection& operator=(const WpOLEAppendCollection& rhs)
+ {WpOLEBase<Ts>::operator=(rhs); return *this;};
+ //////////////////////////////////////////////////////////////////////
+
+ inline sal_Bool Append(const WrapT& aWrapT)
+ {
+ return SUCCEEDED(pInterface->Append(OLEVariant((T*)aWrapT)));
+ };
+
+ inline sal_Bool Delete(const ::rtl::OUString& sName)
+ {
+ return SUCCEEDED(pInterface->Delete(OLEVariant(sName)));
+ };
+
+
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADO_AOLEWRAP_HXX_
+
diff --git a/connectivity/source/inc/ado/Awrapado.hxx b/connectivity/source/inc/ado/Awrapado.hxx
new file mode 100644
index 000000000000..0e4cd9395255
--- /dev/null
+++ b/connectivity/source/inc/ado/Awrapado.hxx
@@ -0,0 +1,419 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_ADO_AWRAPADO_HXX_
+#define _CONNECTIVITY_ADO_AWRAPADO_HXX_
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+// Includes fuer ADO
+#include "ado_pre_sys_include.h"
+#include <oledb.h>
+#include <ocidl.h>
+#include <adoint.h>
+#include "ado_post_sys_include.h"
+
+
+#include "ado/adoimp.hxx"
+#include "ado/Aolewrap.hxx"
+#include "ado/Aolevariant.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class WpADOConnection;
+ class WpADOCommand;
+ class WpADORecordset;
+ class WpADOField;
+ class WpADOParameter;
+ class WpADOError;
+ class WpADOProperty;
+
+ typedef WpOLEAppendCollection< ADOFields, ADOField, WpADOField> WpADOFields;
+ typedef WpOLECollection< ADOProperties, ADOProperty, WpADOProperty> WpADOProperties;
+
+ //------------------------------------------------------------------------
+ class WpADOConnection : public WpOLEBase<ADOConnection>
+ {
+ friend class WpADOCommand;
+ public:
+
+ WpADOConnection(ADOConnection* pInt) : WpOLEBase<ADOConnection>(pInt){}
+
+ WpADOConnection(const WpADOConnection& rhs){operator=(rhs);}
+
+ WpADOConnection& operator=(const WpADOConnection& rhs)
+ {WpOLEBase<ADOConnection>::operator=(rhs); return *this;}
+
+ //////////////////////////////////////////////////////////////////////
+
+ WpADOProperties get_Properties() const;
+
+ rtl::OUString GetConnectionString() const;
+
+ sal_Bool PutConnectionString(const ::rtl::OUString &aCon) const;
+
+ sal_Int32 GetCommandTimeout() const;
+
+ void PutCommandTimeout(sal_Int32 nRet);
+
+ sal_Int32 GetConnectionTimeout() const ;
+
+ void PutConnectionTimeout(sal_Int32 nRet);
+
+ sal_Bool Close( ) ;
+
+ sal_Bool Execute(const ::rtl::OUString& _CommandText,OLEVariant& RecordsAffected,long Options, WpADORecordset** ppiRset);
+
+ sal_Bool BeginTrans();
+
+ sal_Bool CommitTrans( ) ;
+
+ sal_Bool RollbackTrans( );
+
+ sal_Bool Open(const ::rtl::OUString& ConnectionString, const ::rtl::OUString& UserID,const ::rtl::OUString& Password,long Options);
+
+ sal_Bool GetErrors(ADOErrors** pErrors);
+
+ ::rtl::OUString GetDefaultDatabase() const;
+
+ sal_Bool PutDefaultDatabase(const ::rtl::OUString& _bstr);
+
+ IsolationLevelEnum get_IsolationLevel() const ;
+
+ sal_Bool put_IsolationLevel(const IsolationLevelEnum& eNum) ;
+
+ sal_Int32 get_Attributes() const;
+
+ sal_Bool put_Attributes(sal_Int32 nRet);
+
+ CursorLocationEnum get_CursorLocation() const;
+
+ sal_Bool put_CursorLocation(const CursorLocationEnum &eNum) ;
+
+ ConnectModeEnum get_Mode() const;
+
+ sal_Bool put_Mode(const ConnectModeEnum &eNum) ;
+
+ ::rtl::OUString get_Provider() const;
+
+ sal_Bool put_Provider(const ::rtl::OUString& _bstr);
+
+ sal_Int32 get_State() const;
+
+ sal_Bool OpenSchema(SchemaEnum eNum,OLEVariant& Restrictions,OLEVariant& SchemaID,ADORecordset**pprset);
+
+ ::rtl::OUString get_Version() const;
+
+ // special methods
+ ADORecordset* getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table );
+ ADORecordset* getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table );
+ ADORecordset* getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table );
+ ADORecordset* getIndexInfo( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Bool unique, sal_Bool approximate );
+ ADORecordset* getTablePrivileges( const ::com::sun::star::uno::Any& catalog,
+ const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& tableNamePattern );
+ ADORecordset* 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);
+ ADORecordset* getProcedures( const ::com::sun::star::uno::Any& catalog,
+ const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& procedureNamePattern );
+ ADORecordset* getProcedureColumns( const ::com::sun::star::uno::Any& catalog,
+ const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& procedureNamePattern,
+ const ::rtl::OUString& columnNamePattern );
+ ADORecordset* 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 );
+ ADORecordset* getColumns( const ::com::sun::star::uno::Any& catalog,
+ const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& tableNamePattern,
+ const ::rtl::OUString& columnNamePattern );
+ ADORecordset* getColumnPrivileges( const ::com::sun::star::uno::Any& catalog,
+ const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& table,
+ const ::rtl::OUString& columnNamePattern );
+ ADORecordset* getTypeInfo(DataTypeEnum _eType = adEmpty );
+ };
+
+ //------------------------------------------------------------------------
+ class WpADOCommand : public WpOLEBase<ADOCommand>
+ {
+ public:
+ WpADOCommand(){}
+ // Konstruktoren, operator=
+ // diese rufen nur die Oberklasse
+ WpADOCommand(ADOCommand* pInt) : WpOLEBase<ADOCommand>(pInt){}
+
+ WpADOCommand(const WpADOCommand& rhs){operator=(rhs);}
+
+ WpADOCommand& operator=(const WpADOCommand& rhs)
+ {
+ WpOLEBase<ADOCommand>::operator=(rhs); return *this;}
+
+ //////////////////////////////////////////////////////////////////////
+
+ sal_Bool putref_ActiveConnection( WpADOConnection *pCon);
+
+ void put_ActiveConnection(/* [in] */ const OLEVariant& vConn);
+ void Create();
+ sal_Int32 get_State() const;
+ ::rtl::OUString get_CommandText() const;
+ sal_Bool put_CommandText(const ::rtl::OUString &aCon) ;
+ sal_Int32 get_CommandTimeout() const;
+ void put_CommandTimeout(sal_Int32 nRet);
+ sal_Bool get_Prepared() const;
+ sal_Bool put_Prepared(VARIANT_BOOL bPrepared) const;
+ sal_Bool Execute(OLEVariant& RecordsAffected,OLEVariant& Parameters,long Options, ADORecordset** ppiRset);
+ ADOParameter* CreateParameter(const ::rtl::OUString &_bstr,DataTypeEnum Type,ParameterDirectionEnum Direction,long nSize,const OLEVariant &Value);
+
+ ADOParameters* get_Parameters() const;
+ sal_Bool put_CommandType( /* [in] */ CommandTypeEnum lCmdType);
+ CommandTypeEnum get_CommandType( ) const ;
+ // gibt den Namen des Feldes zur"ueck
+ ::rtl::OUString GetName() const ;
+ sal_Bool put_Name(const ::rtl::OUString& _Name);
+ sal_Bool Cancel();
+ };
+ //------------------------------------------------------------------------
+ class WpADOError : public WpOLEBase<ADOError>
+ {
+ public:
+
+ // Konstruktoren, operator=
+ // diese rufen nur die Oberklasse
+
+ WpADOError(ADOError* pInt):WpOLEBase<ADOError>(pInt){}
+
+ WpADOError(const WpADOError& rhs){operator=(rhs);}
+
+ WpADOError& operator=(const WpADOError& rhs)
+ {WpOLEBase<ADOError>::operator=(rhs); return *this;}
+
+ //////////////////////////////////////////////////////////////////////
+
+ ::rtl::OUString GetDescription() const;
+
+ ::rtl::OUString GetSource() const ;
+
+ sal_Int32 GetNumber() const ;
+ ::rtl::OUString GetSQLState() const ;
+ sal_Int32 GetNativeError() const ;
+ };
+
+
+
+ //------------------------------------------------------------------------
+ class WpADOField : public WpOLEBase<ADOField>
+ {
+ // friend class WpADOFields;
+ public:
+
+ // Konstruktoren, operator=
+ // diese rufen nur die Oberklasse
+ WpADOField(ADOField* pInt=NULL):WpOLEBase<ADOField>(pInt){}
+ WpADOField(const WpADOField& rhs){operator=(rhs);}
+
+ WpADOField& operator=(const WpADOField& rhs)
+ {WpOLEBase<ADOField>::operator=(rhs); return *this;}
+ //////////////////////////////////////////////////////////////////////
+
+ WpADOProperties get_Properties();
+ sal_Int32 GetActualSize() const ;
+ sal_Int32 GetAttributes() const ;
+ sal_Int32 GetStatus() const ;
+ sal_Int32 GetDefinedSize() const ;
+ // gibt den Namen des Feldes zur"ueck
+ ::rtl::OUString GetName() const ;
+ DataTypeEnum GetADOType() const ;
+ void get_Value(OLEVariant& aValVar) const ;
+ OLEVariant get_Value() const;
+ sal_Bool PutValue(const OLEVariant& aVariant);
+ sal_Int32 GetPrecision() const ;
+ sal_Int32 GetNumericScale() const ;
+ sal_Bool AppendChunk(const OLEVariant& _Variant);
+ OLEVariant GetChunk(long Length) const;
+ void GetChunk(long Length,OLEVariant &aValVar) const;
+ OLEVariant GetOriginalValue() const;
+ void GetOriginalValue(OLEVariant &aValVar) const;
+ OLEVariant GetUnderlyingValue() const;
+
+ void GetUnderlyingValue(OLEVariant &aValVar) const;
+
+ sal_Bool PutPrecision(sal_Int8 _prec);
+
+ sal_Bool PutNumericScale(sal_Int8 _prec);
+
+ void PutADOType(DataTypeEnum eType) ;
+
+ sal_Bool PutDefinedSize(sal_Int32 _nDefSize);
+
+ sal_Bool PutAttributes(sal_Int32 _nDefSize);
+ };
+
+
+
+ //------------------------------------------------------------------------
+ class WpADOProperty: public WpOLEBase<ADOProperty>
+ {
+ public:
+ // Konstruktoren, operator=
+ // diese rufen nur die Oberklasse
+ WpADOProperty(ADOProperty* pInt=NULL):WpOLEBase<ADOProperty>(pInt){}
+ WpADOProperty(const WpADOProperty& rhs){operator=(rhs);}
+ WpADOProperty& operator=(const WpADOProperty& rhs)
+ {WpOLEBase<ADOProperty>::operator=(rhs); return *this;}
+ //////////////////////////////////////////////////////////////////////
+
+ OLEVariant GetValue() const;
+ void GetValue(OLEVariant &aValVar) const;
+ sal_Bool PutValue(const OLEVariant &aValVar) ;
+ ::rtl::OUString GetName() const ;
+ DataTypeEnum GetADOType() const ;
+ sal_Int32 GetAttributes() const ;
+ sal_Bool PutAttributes(sal_Int32 _nDefSize);
+ };
+
+
+ class WpADORecordset : public WpOLEBase<ADORecordset>
+ {
+
+ public:
+ // Konstruktoren, operator=
+ // diese rufen nur die Oberklasse
+ WpADORecordset(ADORecordset* pInt=NULL):WpOLEBase<ADORecordset>(pInt){}
+ WpADORecordset(const WpADORecordset& rhs){operator=(rhs);}
+ WpADORecordset& operator=(const WpADORecordset& rhs)
+ {
+ WpOLEBase<ADORecordset>::operator=(rhs);
+ return *this;
+ }
+ ~WpADORecordset()
+ {
+ // if(pInterface && get_State() == adStateOpen)
+ // Close();
+ }
+ //////////////////////////////////////////////////////////////////////
+ void Create();
+ sal_Bool Open(
+ /* [optional][in] */ VARIANT Source,
+ /* [optional][in] */ VARIANT ActiveConnection,
+ /* [defaultvalue][in] */ CursorTypeEnum CursorType,
+ /* [defaultvalue][in] */ LockTypeEnum LockType,
+ /* [defaultvalue][in] */ sal_Int32 Options);
+ LockTypeEnum GetLockType();
+ void Close();
+ sal_Bool Cancel() const;
+ sal_Int32 get_State( );
+ sal_Bool Supports( /* [in] */ CursorOptionEnum CursorOptions);
+ PositionEnum get_AbsolutePosition();
+ void GetDataSource(IUnknown** pIUnknown) const ;
+ void PutRefDataSource(IUnknown* pIUnknown);
+ void GetBookmark(VARIANT& var);
+ OLEVariant GetBookmark();
+ CompareEnum CompareBookmarks(const OLEVariant& left,const OLEVariant& right);
+ sal_Bool SetBookmark(const OLEVariant &pSafeAr);
+ WpADOFields GetFields() const;
+ sal_Bool Move(sal_Int32 nRows, VARIANT aBmk);
+ sal_Bool MoveNext();
+ sal_Bool MovePrevious();
+ sal_Bool MoveFirst();
+ sal_Bool MoveLast();
+
+ sal_Bool IsAtBOF() const;
+ sal_Bool IsAtEOF() const;
+ sal_Bool Delete(AffectEnum eNum);
+ sal_Bool AddNew(const OLEVariant &FieldList,const OLEVariant &Values);
+ sal_Bool Update(const OLEVariant &FieldList,const OLEVariant &Values);
+ sal_Bool CancelUpdate();
+ WpADOProperties get_Properties() const;
+ sal_Bool NextRecordset(OLEVariant& RecordsAffected,ADORecordset** ppiRset);
+ sal_Bool get_RecordCount(sal_Int32 &_nRet) const;
+ sal_Bool get_MaxRecords(sal_Int32 &_nRet) const;
+ sal_Bool put_MaxRecords(sal_Int32 _nRet);
+ sal_Bool get_CursorType(CursorTypeEnum &_nRet) const;
+ sal_Bool put_CursorType(CursorTypeEnum _nRet);
+ sal_Bool get_LockType(LockTypeEnum &_nRet) const;
+ sal_Bool put_LockType(LockTypeEnum _nRet);
+ sal_Bool get_CacheSize(sal_Int32 &_nRet) const;
+ sal_Bool put_CacheSize(sal_Int32 _nRet);
+ sal_Bool UpdateBatch(AffectEnum AffectRecords);
+ };
+
+ //------------------------------------------------------------------------
+ class WpADOParameter:public WpOLEBase<ADOParameter>
+ {
+ public:
+ // Konstruktoren, operator=
+ // diese rufen nur die Oberklasse
+ WpADOParameter(ADOParameter* pInt):WpOLEBase<ADOParameter>(pInt){}
+ WpADOParameter(const WpADOParameter& rhs):WpOLEBase<ADOParameter>(rhs){}
+ WpADOParameter& operator=(const WpADOParameter& rhs)
+ {WpOLEBase<ADOParameter>::operator=(rhs); return *this;}
+ //////////////////////////////////////////////////////////////////////
+
+ ::rtl::OUString GetName() const ;
+ DataTypeEnum GetADOType() const ;
+ void put_Type(const DataTypeEnum& _eType);
+ sal_Bool put_Size(const sal_Int32& _nSize);
+ sal_Int32 GetAttributes() const ;
+ sal_Int32 GetPrecision() const ;
+ sal_Int32 GetNumericScale() const ;
+ ParameterDirectionEnum get_Direction() const;
+ void GetValue(OLEVariant& aValVar) const ;
+ OLEVariant GetValue() const;
+ sal_Bool PutValue(const OLEVariant& aVariant);
+ sal_Bool AppendChunk(const OLEVariant& aVariant);
+ };
+
+ class OTools
+ {
+ public:
+ /** putValue set the property value at the ado column
+ @param _rProps the properties where to set
+ @param _aPosition which property to set
+ @param _aValVar the value to set
+ */
+ static void putValue(const WpADOProperties& _rProps,const OLEVariant &_aPosition,const OLEVariant &_aValVar);
+
+ /** getValue returns a specific property value
+ @param _rProps the properties where to set
+ @param _aPosition the property
+
+ @return the property value
+ */
+ static OLEVariant getValue(const WpADOProperties& _rProps,const OLEVariant &_aPosition);
+ };
+ }
+}
+#endif //_CONNECTIVITY_ADO_AWRAPADO_HXX_
+
diff --git a/connectivity/source/inc/ado/Awrapadox.hxx b/connectivity/source/inc/ado/Awrapadox.hxx
new file mode 100644
index 000000000000..452e17c7450f
--- /dev/null
+++ b/connectivity/source/inc/ado/Awrapadox.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_ADO_AWRAPADOX_HXX_
+#define _CONNECTIVITY_ADO_AWRAPADOX_HXX_
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+#ifndef __User_FWD_DEFINED__
+#define __User_FWD_DEFINED__
+typedef struct _ADOUser User;
+#endif /* __User_FWD_DEFINED__ */
+
+#ifndef __Group_FWD_DEFINED__
+#define __Group_FWD_DEFINED__
+typedef struct _ADOGroup Group;
+#endif /* __Group_FWD_DEFINED__ */
+
+#ifndef __Column_FWD_DEFINED__
+#define __Column_FWD_DEFINED__
+typedef struct _ADOColumn Column;
+#endif /* __Column_FWD_DEFINED__ */
+
+#ifndef __Index_FWD_DEFINED__
+#define __Index_FWD_DEFINED__
+typedef struct _ADOIndex Index;
+#endif /* __cplusplus */
+
+#ifndef __Key_FWD_DEFINED__
+#define __Key_FWD_DEFINED__
+typedef struct _ADOKey Key;
+#endif /* __Key_FWD_DEFINED__ */
+
+#ifndef __Table_FWD_DEFINED__
+#define __Table_FWD_DEFINED__
+typedef struct _ADOTable Table;
+#endif /* __Table_FWD_DEFINED__ */
+
+
+#include "ado_pre_sys_include.h"
+#include <adoint.h>
+#include <adoctint.h>
+#include "ado_post_sys_include.h"
+
+
+#include "ado/Aolewrap.hxx"
+#include "ado/Aolevariant.hxx"
+#include "ado/adoimp.hxx"
+#include "ado/Awrapado.hxx"
+#include "ado/WrapColumn.hxx"
+#include "ado/WrapIndex.hxx"
+#include "ado/WrapKey.hxx"
+#include "ado/WrapTable.hxx"
+#include "ado/WrapCatalog.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class WpADOView : public WpOLEBase<ADOView>
+ {
+ public:
+ WpADOView(ADOView* pInt=NULL) : WpOLEBase<ADOView>(pInt){}
+ WpADOView(const WpADOView& rhs){operator=(rhs);}
+
+ inline WpADOView& operator=(const WpADOView& rhs)
+ {WpOLEBase<ADOView>::operator=(rhs); return *this;}
+
+ ::rtl::OUString get_Name() const;
+ void get_Command(OLEVariant& _rVar) const;
+ void put_Command(OLEVariant& _rVar);
+ };
+
+ class WpADOGroup : public WpOLEBase<ADOGroup>
+ {
+ public:
+ WpADOGroup(ADOGroup* pInt=NULL) : WpOLEBase<ADOGroup>(pInt){}
+ WpADOGroup(const WpADOGroup& rhs){operator=(rhs);}
+
+ inline WpADOGroup& operator=(const WpADOGroup& rhs)
+ {WpOLEBase<ADOGroup>::operator=(rhs); return *this;}
+
+ void Create();
+
+ ::rtl::OUString get_Name() const;
+ void put_Name(const ::rtl::OUString& _rName);
+ RightsEnum GetPermissions(
+ /* [in] */ const OLEVariant& Name,
+ /* [in] */ ObjectTypeEnum ObjectType);
+ sal_Bool SetPermissions(
+ /* [in] */ const OLEVariant& Name,
+ /* [in] */ ObjectTypeEnum ObjectType,
+ /* [in] */ ActionEnum Action,
+ /* [in] */ RightsEnum Rights);
+ WpADOUsers get_Users( );
+ };
+
+ class WpADOUser : public WpOLEBase<_ADOUser>
+ {
+ public:
+ WpADOUser(_ADOUser* pInt=NULL) : WpOLEBase<_ADOUser>(pInt){}
+ WpADOUser(const WpADOUser& rhs){operator=(rhs);}
+
+ inline WpADOUser& operator=(const WpADOUser& rhs)
+ {WpOLEBase<_ADOUser>::operator=(rhs); return *this;}
+
+ void Create();
+
+ ::rtl::OUString get_Name() const;
+ void put_Name(const ::rtl::OUString& _rName);
+ sal_Bool ChangePassword(const ::rtl::OUString& _rPwd,const ::rtl::OUString& _rNewPwd);
+ WpADOGroups get_Groups();
+ RightsEnum GetPermissions(
+ /* [in] */ const OLEVariant& Name,
+ /* [in] */ ObjectTypeEnum ObjectType);
+ sal_Bool SetPermissions(
+ /* [in] */ const OLEVariant& Name,
+ /* [in] */ ObjectTypeEnum ObjectType,
+ /* [in] */ ActionEnum Action,
+ /* [in] */ RightsEnum Rights);
+ };
+ }
+}
+#endif // _CONNECTIVITY_ADO_AWRAPADOX_HXX_
+
diff --git a/connectivity/source/inc/ado/WrapCatalog.hxx b/connectivity/source/inc/ado/WrapCatalog.hxx
new file mode 100644
index 000000000000..5c3321777ba0
--- /dev/null
+++ b/connectivity/source/inc/ado/WrapCatalog.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_ADO_WRAP_CATALOG_HXX
+#define CONNECTIVITY_ADO_WRAP_CATALOG_HXX
+
+#include "ado/WrapTypeDefs.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class WpADOCatalog : public WpOLEBase<_ADOCatalog>
+ {
+ public:
+ WpADOCatalog(_ADOCatalog* pInt = NULL) : WpOLEBase<_ADOCatalog>(pInt){}
+ WpADOCatalog(const WpADOCatalog& rhs){operator=(rhs);}
+
+ inline WpADOCatalog& operator=(const WpADOCatalog& rhs)
+ {WpOLEBase<_ADOCatalog>::operator=(rhs); return *this;}
+
+ ::rtl::OUString GetObjectOwner(const ::rtl::OUString& _rName, ObjectTypeEnum _eNum);
+
+ void putref_ActiveConnection(IDispatch* pCon);
+ WpADOTables get_Tables();
+ WpADOViews get_Views();
+ WpADOGroups get_Groups();
+ WpADOUsers get_Users();
+ ADOProcedures* get_Procedures();
+ void Create();
+ };
+ }
+}
+
+#endif //CONNECTIVITY_ADO_WRAP_CATALOG_HXX
diff --git a/connectivity/source/inc/ado/WrapColumn.hxx b/connectivity/source/inc/ado/WrapColumn.hxx
new file mode 100644
index 000000000000..35b84be6ee8a
--- /dev/null
+++ b/connectivity/source/inc/ado/WrapColumn.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_ADO_WRAP_COLUMN_HXX
+#define CONNECTIVITY_ADO_WRAP_COLUMN_HXX
+
+#include "ado/Aolewrap.hxx"
+
+#include "ado_pre_sys_include.h"
+#include <adoint.h>
+#include "ado_post_sys_include.h"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class WpADOColumn : public WpOLEBase<_ADOColumn>
+ {
+ public:
+ WpADOColumn(_ADOColumn* pInt=NULL) : WpOLEBase<_ADOColumn>(pInt){}
+ WpADOColumn(const WpADOColumn& rhs){operator=(rhs);}
+
+ void Create();
+
+ inline WpADOColumn& operator=(const WpADOColumn& rhs)
+ {WpOLEBase<_ADOColumn>::operator=(rhs); return *this;}
+
+ ::rtl::OUString get_Name() const;
+ ::rtl::OUString get_RelatedColumn() const;
+ void put_Name(const ::rtl::OUString& _rName);
+ void put_RelatedColumn(const ::rtl::OUString& _rName);
+ DataTypeEnum get_Type() const;
+ void put_Type(const DataTypeEnum& _eNum) ;
+ sal_Int32 get_Precision() const;
+ void put_Precision(sal_Int32 _nPre) ;
+ sal_uInt8 get_NumericScale() const;
+ void put_NumericScale(sal_Int8 _nScale);
+ SortOrderEnum get_SortOrder() const;
+ void put_SortOrder(SortOrderEnum _nScale);
+ sal_Int32 get_DefinedSize() const;
+ ColumnAttributesEnum get_Attributes() const;
+ sal_Bool put_Attributes(const ColumnAttributesEnum& _eNum);
+ WpADOProperties get_Properties() const;
+ void put_ParentCatalog(/* [in] */ _ADOCatalog __RPC_FAR *ppvObject);
+ };
+ }
+}
+
+#endif //CONNECTIVITY_ADO_WRAP_COLUMN_HXX
diff --git a/connectivity/source/inc/ado/WrapIndex.hxx b/connectivity/source/inc/ado/WrapIndex.hxx
new file mode 100644
index 000000000000..4968d756d05c
--- /dev/null
+++ b/connectivity/source/inc/ado/WrapIndex.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_ADO_WRAP_INDEX_HXX
+#define CONNECTIVITY_ADO_WRAP_INDEX_HXX
+
+#include "ado/WrapTypeDefs.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class WpADOIndex : public WpOLEBase<_ADOIndex>
+ {
+ public:
+ WpADOIndex(_ADOIndex* pInt=NULL) : WpOLEBase<_ADOIndex>(pInt){}
+ WpADOIndex(const WpADOIndex& rhs){operator=(rhs);}
+
+ inline WpADOIndex& operator=(const WpADOIndex& rhs)
+ {WpOLEBase<_ADOIndex>::operator=(rhs); return *this;}
+
+ void Create();
+
+ ::rtl::OUString get_Name() const;
+ void put_Name(const ::rtl::OUString& _rName);
+ sal_Bool get_Clustered() const;
+ void put_Clustered(sal_Bool _b);
+ sal_Bool get_Unique() const;
+ void put_Unique(sal_Bool _b);
+ sal_Bool get_PrimaryKey() const;
+ void put_PrimaryKey(sal_Bool _b);
+ WpADOColumns get_Columns() const;
+ };
+ }
+}
+
+#endif //CONNECTIVITY_ADO_WRAP_INDEX_HXX
diff --git a/connectivity/source/inc/ado/WrapKey.hxx b/connectivity/source/inc/ado/WrapKey.hxx
new file mode 100644
index 000000000000..fb7dcd3181b1
--- /dev/null
+++ b/connectivity/source/inc/ado/WrapKey.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_ADO_WRAP_KEY_HXX
+#define CONNECTIVITY_ADO_WRAP_KEY_HXX
+
+#include "ado/WrapTypeDefs.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class WpADOKey : public WpOLEBase<ADOKey>
+ {
+ public:
+ WpADOKey(ADOKey* pInt=NULL) : WpOLEBase<ADOKey>(pInt){}
+ WpADOKey(const WpADOKey& rhs){operator=(rhs);}
+
+ inline WpADOKey& operator=(const WpADOKey& rhs)
+ {WpOLEBase<ADOKey>::operator=(rhs); return *this;}
+
+ void Create();
+
+ ::rtl::OUString get_Name() const;
+ void put_Name(const ::rtl::OUString& _rName);
+ KeyTypeEnum get_Type() const;
+ void put_Type(const KeyTypeEnum& _eNum) ;
+ ::rtl::OUString get_RelatedTable() const;
+ void put_RelatedTable(const ::rtl::OUString& _rName);
+ RuleEnum get_DeleteRule() const;
+ void put_DeleteRule(const RuleEnum& _eNum) ;
+ RuleEnum get_UpdateRule() const;
+ void put_UpdateRule(const RuleEnum& _eNum) ;
+ WpADOColumns get_Columns() const;
+ };
+ }
+}
+
+#endif //CONNECTIVITY_ADO_WRAP_KEY_HXX
diff --git a/connectivity/source/inc/ado/WrapTable.hxx b/connectivity/source/inc/ado/WrapTable.hxx
new file mode 100644
index 000000000000..b66f41017399
--- /dev/null
+++ b/connectivity/source/inc/ado/WrapTable.hxx
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_ADO_WRAP_TABLE_HXX
+#define CONNECTIVITY_ADO_WRAP_TABLE_HXX
+
+#include "ado/WrapTypeDefs.hxx"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class WpADOCatalog;
+
+ class WpADOTable : public WpOLEBase<_ADOTable>
+ {
+ public:
+ WpADOTable(_ADOTable* pInt=NULL) : WpOLEBase<_ADOTable>(pInt){}
+ WpADOTable(const WpADOTable& rhs){operator=(rhs);}
+
+ inline WpADOTable& operator=(const WpADOTable& rhs)
+ {WpOLEBase<_ADOTable>::operator=(rhs); return *this;}
+
+ void Create();
+
+ ::rtl::OUString get_Name() const;
+ void put_Name(const ::rtl::OUString& _rName);
+ ::rtl::OUString get_Type() const;
+ WpADOColumns get_Columns() const;
+ WpADOIndexes get_Indexes() const;
+ WpADOKeys get_Keys() const;
+ WpADOCatalog get_ParentCatalog() const;
+ WpADOProperties get_Properties() const;
+ void putref_ParentCatalog(/* [in] */ _ADOCatalog __RPC_FAR *ppvObject);
+ };
+
+
+ typedef WpOLEAppendCollection<ADOTables, _ADOTable, WpADOTable> WpADOTables;
+ }
+}
+
+#endif //CONNECTIVITY_ADO_WRAP_TABLE_HXX
diff --git a/connectivity/source/inc/ado/WrapTypeDefs.hxx b/connectivity/source/inc/ado/WrapTypeDefs.hxx
new file mode 100644
index 000000000000..bcf4156759d8
--- /dev/null
+++ b/connectivity/source/inc/ado/WrapTypeDefs.hxx
@@ -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_ADO_WRAP_TYPEDEFS_HXX
+#define CONNECTIVITY_ADO_WRAP_TYPEDEFS_HXX
+
+
+namespace connectivity
+{
+ namespace ado
+ {
+ class WpADOTable;
+ class WpADOKey;
+ class WpADOIndex;
+ class WpADOColumn;
+ class WpADOGroup;
+ class WpADOView;
+ class WpADOUser;
+
+ typedef WpOLEAppendCollection<ADOTables, _ADOTable, WpADOTable> WpADOTables;
+ typedef WpOLEAppendCollection<ADOKeys, ADOKey, WpADOKey> WpADOKeys;
+ typedef WpOLEAppendCollection<ADOIndexes, _ADOIndex, WpADOIndex> WpADOIndexes;
+ typedef WpOLEAppendCollection<ADOColumns, _ADOColumn, WpADOColumn> WpADOColumns;
+ typedef WpOLEAppendCollection<ADOGroups, ADOGroup, WpADOGroup> WpADOGroups;
+ typedef WpOLEAppendCollection<ADOViews, ADOView, WpADOView> WpADOViews;
+ typedef WpOLEAppendCollection<ADOUsers, _ADOUser, WpADOUser> WpADOUsers;
+ }
+}
+
+#endif //CONNECTIVITY_ADO_WRAP_TYPEDEFS_HXX
diff --git a/connectivity/source/inc/ado/adoimp.hxx b/connectivity/source/inc/ado/adoimp.hxx
new file mode 100644
index 000000000000..a7254ff0d020
--- /dev/null
+++ b/connectivity/source/inc/ado/adoimp.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef _CONNECTIVITY_ADO_ADOIMP_HXX_
+#define _CONNECTIVITY_ADO_ADOIMP_HXX_
+
+#include <com/sun/star/sdbc/SQLException.hpp>
+
+#include "ado_pre_sys_include.h"
+#include <adoctint.h>
+#include "ado_post_sys_include.h"
+
+struct ADOConnection;
+enum DataTypeEnum;
+namespace connectivity
+{
+ namespace ado
+ {
+
+ class WpADOField;
+ class OLEString;
+ class ADOS
+ {
+ public:
+ // Auch hier: BSTR mit SysFreeString() freigeben!
+ static OLEString& GetKeyStr();
+
+ static const CLSID CLSID_ADOCATALOG_25;
+ static const IID IID_ADOCATALOG_25;
+
+ static const CLSID CLSID_ADOCONNECTION_21;
+ static const IID IID_ADOCONNECTION_21;
+
+ static const CLSID CLSID_ADOCOMMAND_21;
+ static const IID IID_ADOCOMMAND_21;
+
+ static const CLSID CLSID_ADORECORDSET_21;
+ static const IID IID_ADORECORDSET_21;
+
+ static const CLSID CLSID_ADOINDEX_25;
+ static const IID IID_ADOINDEX_25;
+
+ static const CLSID CLSID_ADOCOLUMN_25;
+ static const IID IID_ADOCOLUMN_25;
+
+ static const CLSID CLSID_ADOKEY_25;
+ static const IID IID_ADOKEY_25;
+
+ static const CLSID CLSID_ADOTABLE_25;
+ static const IID IID_ADOTABLE_25;
+
+ static const CLSID CLSID_ADOGROUP_25;
+ static const IID IID_ADOGROUP_25;
+
+ static const CLSID CLSID_ADOUSER_25;
+ static const IID IID_ADOUSER_25;
+
+ static const CLSID CLSID_ADOVIEW_25;
+ static const IID IID_ADOVIEW_25;
+
+ static void ThrowException(ADOConnection* _pAdoCon,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ static sal_Int32 MapADOType2Jdbc(DataTypeEnum eType);
+ static DataTypeEnum MapJdbc2ADOType(sal_Int32 _nType,sal_Int32 _nJetEngine);
+ static sal_Bool isJetEngine(sal_Int32 _nEngineType);
+
+ static ObjectTypeEnum mapObjectType2Ado(sal_Int32 objType);
+ static sal_Int32 mapAdoType2Object(ObjectTypeEnum objType);
+ static sal_Int32 mapAdoRights2Sdbc(RightsEnum eRights);
+ static sal_Int32 mapRights2Ado(sal_Int32 nRights);
+
+ static WpADOField getField(ADORecordset* _pRecordSet,sal_Int32 _nColumnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+
+
+ }
+}
+
+#define ADO_PROP(ItemName) \
+ WpADOProperty aProp(aProps.GetItem(ItemName)); \
+ OLEVariant aVar; \
+ if(aProp.IsValid()) \
+ aVar = aProp.GetValue(); \
+ else \
+ ADOS::ThrowException(*m_pADOConnection,*this);
+
+
+#endif //_CONNECTIVITY_ADO_ADOIMP_HXX_
+
+
diff --git a/connectivity/source/inc/calc/CCatalog.hxx b/connectivity/source/inc/calc/CCatalog.hxx
new file mode 100644
index 000000000000..8144e3012453
--- /dev/null
+++ b/connectivity/source/inc/calc/CCatalog.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_CALC_CATALOG_HXX_
+#define _CONNECTIVITY_CALC_CATALOG_HXX_
+
+#include "file/FCatalog.hxx"
+
+namespace connectivity
+{
+ namespace calc
+ {
+ class OCalcConnection;
+ class OCalcCatalog : public file::OFileCatalog
+ {
+ public:
+ virtual void refreshTables();
+
+ public:
+ OCalcCatalog(OCalcConnection* _pCon);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_CALC_CATALOG_HXX_
+
diff --git a/connectivity/source/inc/calc/CColumns.hxx b/connectivity/source/inc/calc/CColumns.hxx
new file mode 100644
index 000000000000..f87355867a78
--- /dev/null
+++ b/connectivity/source/inc/calc/CColumns.hxx
@@ -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_CALC_COLUMNS_HXX_
+#define _CONNECTIVITY_CALC_COLUMNS_HXX_
+
+#include "file/FColumns.hxx"
+
+namespace connectivity
+{
+ namespace calc
+ {
+ class OCalcColumns : public file::OColumns
+ {
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ public:
+ OCalcColumns(file::OFileTable* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector
+ ) : file::OColumns(_pTable,_rMutex,_rVector)
+ {}
+
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_CALC_COLUMNS_HXX_
+
diff --git a/connectivity/source/inc/calc/CConnection.hxx b/connectivity/source/inc/calc/CConnection.hxx
new file mode 100644
index 000000000000..ee6cd7180378
--- /dev/null
+++ b/connectivity/source/inc/calc/CConnection.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_CALC_CONNECTION_HXX_
+#define _CONNECTIVITY_CALC_CONNECTION_HXX_
+
+#include "file/FConnection.hxx"
+
+namespace com { namespace sun { namespace star { namespace sheet {
+ class XSpreadsheetDocument;
+} } } }
+
+
+namespace connectivity
+{
+ namespace calc
+ {
+ class ODriver;
+ class OCalcConnection : public file::OConnection
+ {
+ // the spreadsheet document:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument > m_xDoc;
+ ::rtl::OUString m_sPassword;
+ String m_aFileName;
+ oslInterlockedCount m_nDocCount;
+
+ public:
+ OCalcConnection(ODriver* _pDriver);
+ virtual ~OCalcConnection();
+
+ 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);
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO();
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // 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);
+
+ // no interface methods
+ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument> acquireDoc();
+ void releaseDoc();
+
+ class ODocHolder
+ {
+ OCalcConnection* m_pConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument> m_xDoc;
+ public:
+ ODocHolder(OCalcConnection* _pConnection) : m_pConnection(_pConnection)
+ {
+ m_xDoc = m_pConnection->acquireDoc();
+ }
+ ~ODocHolder()
+ {
+ m_xDoc.clear();
+ m_pConnection->releaseDoc();
+ }
+ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument> getDoc() const { return m_xDoc; }
+ };
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_CALC_CONNECTION_HXX_
+
diff --git a/connectivity/source/inc/calc/CDatabaseMetaData.hxx b/connectivity/source/inc/calc/CDatabaseMetaData.hxx
new file mode 100644
index 000000000000..c2eff7deddf8
--- /dev/null
+++ b/connectivity/source/inc/calc/CDatabaseMetaData.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_CALC_DATABASEMETADATA_HXX_
+#define _CONNECTIVITY_CALC_DATABASEMETADATA_HXX_
+
+#include "file/FDatabaseMetaData.hxx"
+
+namespace connectivity
+{
+ namespace calc
+ {
+ //**************************************************************
+ //************ Class: java.sql.DatabaseMetaDataDate
+ //**************************************************************
+
+ class OCalcDatabaseMetaData : 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 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 getMaxColumnsInIndex( ) 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 ::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 ~OCalcDatabaseMetaData();
+ public:
+ OCalcDatabaseMetaData(file::OConnection* _pCon);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_CALC_DATABASEMETADATA_HXX_
+
diff --git a/connectivity/source/inc/calc/CDriver.hxx b/connectivity/source/inc/calc/CDriver.hxx
new file mode 100644
index 000000000000..6e98d9b3f00a
--- /dev/null
+++ b/connectivity/source/inc/calc/CDriver.hxx
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_CALC_DRIVER_HXX_
+#define _CONNECTIVITY_CALC_DRIVER_HXX_
+
+#include "file/FDriver.hxx"
+
+namespace connectivity
+{
+ namespace calc
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ ODriver_CreateInstance(const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
+ throw( ::com::sun::star::uno::Exception );
+
+ class ODriver : public file::OFileDriver
+ {
+ public:
+ ODriver(const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) :
+ file::OFileDriver(_rxFactory){}
+
+ static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
+ ::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);
+ };
+ }
+}
+
+#endif //_CONNECTIVITY_CALC_DRIVER_HXX_
+
diff --git a/connectivity/source/inc/calc/CPreparedStatement.hxx b/connectivity/source/inc/calc/CPreparedStatement.hxx
new file mode 100644
index 000000000000..ddbf9816c3a9
--- /dev/null
+++ b/connectivity/source/inc/calc/CPreparedStatement.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_CALC_PREPAREDSTATEMENT_HXX_
+#define _CONNECTIVITY_CALC_PREPAREDSTATEMENT_HXX_
+
+#include "file/FPreparedStatement.hxx"
+
+namespace connectivity
+{
+ namespace calc
+ {
+ class OConnection;
+ class OCalcPreparedStatement : public file::OPreparedStatement
+ {
+ protected:
+ virtual file::OResultSet* createResultSet();
+ public:
+ OCalcPreparedStatement( file::OConnection* _pConnection) : file::OPreparedStatement( _pConnection){}
+ DECLARE_SERVICE_INFO();
+ };
+ }
+}
+
+#endif //_CONNECTIVITY_CALC_PREPAREDSTATEMENT_HXX_
+
diff --git a/connectivity/source/inc/calc/CResultSet.hxx b/connectivity/source/inc/calc/CResultSet.hxx
new file mode 100644
index 000000000000..f2f9045ad935
--- /dev/null
+++ b/connectivity/source/inc/calc/CResultSet.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef _CONNECTIVITY_CALC_RESULTSET_HXX_
+#define _CONNECTIVITY_CALC_RESULTSET_HXX_
+
+#include "file/FResultSet.hxx"
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+namespace connectivity
+{
+ namespace calc
+ {
+ class OCalcResultSet;
+ // these typedef's are only necessary for the compiler
+ typedef ::cppu::ImplHelper2< ::com::sun::star::sdbcx::XRowLocate,
+ ::com::sun::star::sdbcx::XDeleteRows> OCalcResultSet_BASE;
+ typedef file::OResultSet OCalcResultSet_BASE2;
+ typedef ::comphelper::OPropertyArrayUsageHelper<OCalcResultSet> OCalcResultSet_BASE3;
+
+
+ class OCalcResultSet : public OCalcResultSet_BASE2,
+ public OCalcResultSet_BASE,
+ public OCalcResultSet_BASE3
+ {
+ sal_Bool m_bBookmarkable;
+ protected:
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ virtual sal_Bool fillIndexValues(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier> &_xIndex);
+ public:
+ DECLARE_SERVICE_INFO();
+
+ OCalcResultSet( file::OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator);
+
+ private:
+ // 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);
+ // 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);
+
+ virtual sal_Bool isRowDeleted() const { return sal_False; }
+
+ };
+ }
+}
+
+#endif //_CONNECTIVITY_CALC_RESULTSET_HXX_
+
diff --git a/connectivity/source/inc/calc/CStatement.hxx b/connectivity/source/inc/calc/CStatement.hxx
new file mode 100644
index 000000000000..1a44a2029e09
--- /dev/null
+++ b/connectivity/source/inc/calc/CStatement.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_CALC_STATEMENT_HXX_
+#define _CONNECTIVITY_CALC_STATEMENT_HXX_
+
+#include "file/FStatement.hxx"
+
+namespace connectivity
+{
+ namespace calc
+ {
+ class OConnection;
+ class OCalcStatement : public file::OStatement
+ {
+ protected:
+ virtual file::OResultSet* createResultSet();
+ public:
+ OCalcStatement( file::OConnection* _pConnection) : file::OStatement( _pConnection){}
+ DECLARE_SERVICE_INFO();
+ };
+ }
+}
+
+#endif //_CONNECTIVITY_CALC_STATEMENT_HXX_
+
diff --git a/connectivity/source/inc/calc/CTable.hxx b/connectivity/source/inc/calc/CTable.hxx
new file mode 100644
index 000000000000..fddd29d72506
--- /dev/null
+++ b/connectivity/source/inc/calc/CTable.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_CALC_TABLE_HXX_
+#define _CONNECTIVITY_CALC_TABLE_HXX_
+
+#include "file/FTable.hxx"
+#include <tools/date.hxx>
+
+namespace com { namespace sun { namespace star { namespace sheet {
+ class XSpreadsheet;
+ class XSpreadsheetDocument;
+} } } }
+
+namespace com { namespace sun { namespace star { namespace util {
+ class XNumberFormats;
+} } } }
+
+
+namespace connectivity
+{
+ namespace calc
+ {
+ typedef file::OFileTable OCalcTable_BASE;
+ class OCalcConnection;
+
+ typedef ::std::map< ::rtl::OUString,
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed>,
+ comphelper::UStringMixLess > OContainer;
+
+ class OCalcTable : public OCalcTable_BASE
+ {
+ private:
+ ::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;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet > m_xSheet;
+ OCalcConnection* m_pConnection;
+ sal_Int32 m_nStartCol;
+ sal_Int32 m_nStartRow;
+ sal_Int32 m_nDataCols;
+ sal_Int32 m_nDataRows;
+ sal_Bool m_bHasHeaders;
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats > m_xFormats;
+ ::Date m_aNullDate;
+
+ void fillColumns();
+
+ protected:
+ virtual void FileClose();
+ public:
+ virtual void refreshColumns();
+ virtual void refreshIndexes();
+
+ public:
+ OCalcTable( sdbcx::OCollection* _pTables,OCalcConnection* _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()
+ );
+
+ virtual sal_Int32 getCurrentLastPos() const;
+ virtual sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos);
+ virtual sal_Bool fetchRow(OValueRefRow& _rRow,const OSQLColumns& _rCols, sal_Bool _bUseTableDefs,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();
+
+ void construct();
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_CALC_TABLE_HXX_
+
diff --git a/connectivity/source/inc/calc/CTables.hxx b/connectivity/source/inc/calc/CTables.hxx
new file mode 100644
index 000000000000..08bcb98df463
--- /dev/null
+++ b/connectivity/source/inc/calc/CTables.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_CALC_TABLES_HXX_
+#define _CONNECTIVITY_CALC_TABLES_HXX_
+
+#include "file/FTables.hxx"
+
+namespace connectivity
+{
+ namespace calc
+ {
+ typedef file::OTables OCalcTables_BASE;
+
+ class OCalcTables : public OCalcTables_BASE
+ {
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ public:
+ OCalcTables(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector) : OCalcTables_BASE(_rMetaData,_rParent,_rMutex,_rVector)
+ {}
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_CALC_TABLES_HXX_
+
diff --git a/connectivity/source/inc/dbase/DCatalog.hxx b/connectivity/source/inc/dbase/DCatalog.hxx
new file mode 100644
index 000000000000..50a0ae607b6f
--- /dev/null
+++ b/connectivity/source/inc/dbase/DCatalog.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_DBASE_CATALOG_HXX_
+#define _CONNECTIVITY_DBASE_CATALOG_HXX_
+
+#include "file/FCatalog.hxx"
+
+namespace connectivity
+{
+ namespace dbase
+ {
+ class ODbaseConnection;
+ class ODbaseCatalog : public file::OFileCatalog
+ {
+ public:
+ virtual void refreshTables();
+
+ public:
+ ODbaseCatalog(ODbaseConnection* _pCon);
+ };
+ }
+}
+#endif // _CONNECTIVITY_DBASE_CATALOG_HXX_
+
diff --git a/connectivity/source/inc/dbase/DCode.hxx b/connectivity/source/inc/dbase/DCode.hxx
new file mode 100644
index 000000000000..e00ed85b7863
--- /dev/null
+++ b/connectivity/source/inc/dbase/DCode.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_DBASE_DCODE_HXX
+#define CONNECTIVITY_DBASE_DCODE_HXX
+
+#include "file/fanalyzer.hxx"
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "file/fcode.hxx"
+
+namespace connectivity
+{
+ namespace file
+ {
+ class OConnection;
+ }
+ namespace dbase
+ {
+ class OFILEAnalyzer : public file::OSQLAnalyzer
+ {
+ public:
+ OFILEAnalyzer(file::OConnection* _pConnection) : file::OSQLAnalyzer(_pConnection){}
+ virtual file::OOperandAttr* createOperandAttr(sal_Int32 _nPos,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xCol,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xIndexes=NULL);
+ };
+
+ // Attribute aus einer Ergebniszeile
+ class OFILEOperandAttr : public file::OOperandAttr
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xIndex;
+ public:
+ OFILEOperandAttr(sal_uInt16 _nPos,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xIndexes=NULL);
+
+ virtual sal_Bool isIndexed() const;
+ virtual file::OEvaluateSet* preProcess(file::OBoolOperator* pOp, file::OOperand* pRight = 0);
+ TYPEINFO();
+ };
+ }
+}
+
+#endif // CONNECTIVITY_DBASE_DCODE_HXX
+
diff --git a/connectivity/source/inc/dbase/DColumns.hxx b/connectivity/source/inc/dbase/DColumns.hxx
new file mode 100644
index 000000000000..b11e24d33661
--- /dev/null
+++ b/connectivity/source/inc/dbase/DColumns.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_DBASE_COLUMNS_HXX_
+#define _CONNECTIVITY_DBASE_COLUMNS_HXX_
+
+#include "file/FColumns.hxx"
+
+namespace connectivity
+{
+ namespace dbase
+ {
+ class ODbaseColumns : public file::OColumns
+ {
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ ODbaseColumns(file::OFileTable* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector
+ ) : file::OColumns(_pTable,_rMutex,_rVector)
+ {}
+ };
+ }
+}
+#endif // _CONNECTIVITY_DBASE_COLUMNS_HXX_
+
diff --git a/connectivity/source/inc/dbase/DConnection.hxx b/connectivity/source/inc/dbase/DConnection.hxx
new file mode 100644
index 000000000000..50192586d8a7
--- /dev/null
+++ b/connectivity/source/inc/dbase/DConnection.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_DBASE_DCONNECTION_HXX_
+#define _CONNECTIVITY_DBASE_DCONNECTION_HXX_
+
+#include "file/FConnection.hxx"
+
+namespace connectivity
+{
+ namespace dbase
+ {
+ class ODriver;
+ typedef file::OConnection ODbaseConnection_Base;
+ class ODbaseConnection : public ODbaseConnection_Base
+ {
+ protected:
+ virtual ~ODbaseConnection();
+ public:
+ ODbaseConnection(ODriver* _pDriver);
+ // 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_DBASE_DCONNECTION_HXX_
+
diff --git a/connectivity/source/inc/dbase/DDatabaseMetaData.hxx b/connectivity/source/inc/dbase/DDatabaseMetaData.hxx
new file mode 100644
index 000000000000..68159f0dce34
--- /dev/null
+++ b/connectivity/source/inc/dbase/DDatabaseMetaData.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_DBASE_ODATABASEMETADATA_HXX_
+#define _CONNECTIVITY_DBASE_ODATABASEMETADATA_HXX_
+
+#include "file/FDatabaseMetaData.hxx"
+
+namespace connectivity
+{
+ namespace dbase
+ {
+ //**************************************************************
+ //************ Class: java.sql.DatabaseMetaDataDate
+ //**************************************************************
+
+ class ODbaseDatabaseMetaData : public file::ODatabaseMetaData
+ {
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_getTypeInfo_throw();
+ virtual sal_Bool SAL_CALL isReadOnly( ) 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 ::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 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_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 getMaxColumnsInIndex( ) 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_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 impl_storesMixedCaseQuotedIdentifiers_throw( );
+ virtual sal_Bool impl_supportsMixedCaseQuotedIdentifiers_throw( );
+ protected:
+ virtual ~ODbaseDatabaseMetaData();
+ public:
+ ODbaseDatabaseMetaData(file::OConnection* _pCon);
+ };
+ }
+}
+#endif // _CONNECTIVITY_DBASE_ODATABASEMETADATA_HXX_
+
diff --git a/connectivity/source/inc/dbase/DDatabaseMetaDataResultSet.hxx b/connectivity/source/inc/dbase/DDatabaseMetaDataResultSet.hxx
new file mode 100644
index 000000000000..b6fbdb231d4d
--- /dev/null
+++ b/connectivity/source/inc/dbase/DDatabaseMetaDataResultSet.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_FILE_ADATABASEMETADATARESULTSET_HXX_
+#define _CONNECTIVITY_FILE_ADATABASEMETADATARESULTSET_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 <cppuhelper/compbase7.hxx>
+#include <comphelper/proparrhlp.hxx>
+#ifndef _CONNECTIVITY_FILE_ASTATEMENT_HXX_
+#include "file/FStatement.hxx"
+#endif
+#include "connectivity/CommonTools.hxx"
+#include <comphelper/propertycontainer.hxx>
+
+namespace connectivity
+{
+ namespace file
+ {
+ namespace ::com::sun::star::sdbc = ::com::sun::star::sdbc;
+ namespace ::com::sun::star::beans = ::com::sun::star::beans;
+ namespace ::com::sun::star::util = ::com::sun::star::util;
+
+ class ODatabaseMetaDataResultSetMetaData;
+ typedef ::cppu::WeakComponentImplHelper7< ::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> ODatabaseMetaDataResultSet_BASE;
+
+ DECLARE_STL_VECTOR(::com::sun::star::uno::Any,ORow);
+ DECLARE_STL_VECTOR(ORow, ORows);
+
+ class ODatabaseMetaDataResultSet : public comphelper::OBaseMutex,
+ public ODatabaseMetaDataResultSet_BASE,
+ public ::comphelper::OPropertyContainer,
+ public ::comphelper::OPropertyArrayUsageHelper<ODatabaseMetaDataResultSet>
+ {
+
+
+ ORows m_aRows;
+ ORowsIterator m_aRowsIter;
+ ::com::sun::star::uno::WeakReferenceHelper
+ m_aStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData>
+ m_xMetaData;
+ sal_Int32 m_nRowPos;
+ sal_Int32 m_nColPos;
+
+ sal_Int32 m_nFetchSize;
+ sal_Int32 m_nResultSetType;
+ sal_Int32 m_nFetchDirection;
+ sal_Int32 m_nResultSetConcurrency;
+
+ sal_Bool m_bWasNull;
+ sal_Bool m_bBOF;
+
+ void construct();
+
+ protected:
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ virtual ~ODatabaseMetaDataResultSet();
+ public:
+ DECLARE_CTY_DEFAULTS(ODatabaseMetaDataResultSet_BASE);
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ ODatabaseMetaDataResultSet( );
+
+
+ void setRows(const ORows& _rRows) { m_aRows = _rRows; }
+
+ void setCatalogsMap();
+ void setSchemasMap();
+ void setColumnPrivilegesMap();
+ void setColumnsMap();
+ void setTablesMap();
+ void setTableTypes();
+ void setProcedureColumnsMap();
+ void setProceduresMap();
+ void setExportedKeysMap();
+ void setImportedKeysMap();
+ void setPrimaryKeysMap();
+ void setIndexInfoMap();
+ void setTablePrivilegesMap();
+ void setCrossReferenceMap();
+ void setTypeInfoMap();
+
+ private:
+ // ::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)
+ {
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+ }
+ // 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);
+ };
+ }
+
+}
+#endif // _CONNECTIVITY_FILE_ADATABASEMETADATARESULTSET_HXX_
+
diff --git a/connectivity/source/inc/dbase/DDatabaseMetaDataResultSetMetaData.hxx b/connectivity/source/inc/dbase/DDatabaseMetaDataResultSetMetaData.hxx
new file mode 100644
index 000000000000..11cdb41c6545
--- /dev/null
+++ b/connectivity/source/inc/dbase/DDatabaseMetaDataResultSetMetaData.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_FILE_ADATABASEMETADATARESULTSETMETADATA_HXX_
+#define _CONNECTIVITY_FILE_ADATABASEMETADATARESULTSETMETADATA_HXX_
+
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <cppuhelper/implbase1.hxx>
+#ifndef _VECTOR_
+#include <vector>
+#endif
+#include "FDatabaseMetaDataResultSet.hxx"
+#include "OColumn.hxx"
+
+namespace connectivity
+{
+ namespace file
+ {
+ //**************************************************************
+ //************ Class: ResultSetMetaData
+ //**************************************************************
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> ODatabaseMetaResultSetMetaData_BASE;
+
+ class ODatabaseMetaDataResultSetMetaData : public ODatabaseMetaResultSetMetaData_BASE
+ {
+ friend class ODatabaseMetaDataResultSet;
+
+ ::std::vector<sal_Int32> m_vMapping; // when not every column is needed
+ ::std::map<sal_Int32,connectivity::OColumn> m_mColumns;
+ ::std::map<sal_Int32,connectivity::OColumn>::const_iterator m_mColumnsIter;
+
+ sal_Int32 m_nColCount;
+
+ protected:
+ void setColumnPrivilegesMap();
+ void setColumnsMap();
+ void setTablesMap();
+ void setProcedureColumnsMap();
+ void setPrimaryKeysMap();
+ void setIndexInfoMap();
+ void setTablePrivilegesMap();
+ void setCrossReferenceMap();
+ void setTypeInfoMap();
+ void setProceduresMap();
+ void setTableTypes();
+ public:
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ ODatabaseMetaDataResultSetMetaData( ODatabaseMetaDataResultSet* _pRes)
+ : m_nColCount(0)
+ {
+ }
+ ~ODatabaseMetaDataResultSetMetaData();
+
+ /// 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_FILE_ADATABASEMETARESULTSETMETADATA_HXX_
+
+
diff --git a/connectivity/source/inc/dbase/DDriver.hxx b/connectivity/source/inc/dbase/DDriver.hxx
new file mode 100644
index 000000000000..cbdfbe03c920
--- /dev/null
+++ b/connectivity/source/inc/dbase/DDriver.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_DBASE_DDRIVER_HXX_
+#define _CONNECTIVITY_DBASE_DDRIVER_HXX_
+
+#include <cppuhelper/compbase2.hxx>
+#include "connectivity/CommonTools.hxx"
+#include "file/FDriver.hxx"
+
+namespace connectivity
+{
+ namespace dbase
+ {
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception );
+
+ class ODriver : public file::OFileDriver
+ {
+ public:
+ ODriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) : file::OFileDriver(_rxFactory){}
+
+ // 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);
+
+ ::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);
+ };
+ }
+
+}
+#endif //_CONNECTIVITY_DBASE_DDRIVER_HXX_
+
diff --git a/connectivity/source/inc/dbase/DIndex.hxx b/connectivity/source/inc/dbase/DIndex.hxx
new file mode 100644
index 000000000000..9155ba72bb87
--- /dev/null
+++ b/connectivity/source/inc/dbase/DIndex.hxx
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_DBASE_INDEX_HXX_
+#define _CONNECTIVITY_DBASE_INDEX_HXX_
+
+#include "connectivity/sdbcx/VIndex.hxx"
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include "dbase/DTable.hxx"
+#include "dbase/dindexnode.hxx"
+
+#define dBASE_III_GROUP "dBase III"
+
+namespace connectivity
+{
+ namespace dbase
+ {
+ class OIndexIterator;
+ class ONDXKey;
+
+ typedef sdbcx::OIndex ODbaseIndex_BASE;
+ typedef file::OBoolOperator OBoolOperator_BASE;
+ typedef file::OOperand OOperand_BASE;
+
+ class ODbaseIndex : public ODbaseIndex_BASE
+ {
+ friend SvStream& operator << (SvStream &rStream, ODbaseIndex&);
+ friend SvStream& operator >> (SvStream &rStream, ODbaseIndex&);
+
+ friend class ONDXNode;
+ friend class ONDXPage;
+ friend class ONDXPagePtr;
+ friend class OIndexIterator;
+
+ public:
+ //==================================================================
+ // Kopfsatz-Struktur, verbleibt im Speicher
+ //==================================================================
+ struct NDXHeader
+ {
+ sal_uInt32 db_rootpage; /* Position der Rootpage */
+ sal_uInt32 db_pagecount; /* Anzahl Pages */
+ sal_uInt8 db_frei[4]; /* reserviert */
+ sal_uInt16 db_keylen; /* Laenge des Schluessels */
+ sal_uInt16 db_maxkeys; /* Max. # keys pro Seite */
+ sal_uInt16 db_keytype; /* Art des Schluessels
+ (0-Text)
+ (1-Numerisch) */
+ sal_uInt16 db_keyrec; /* Laenge eines IndexSatzes
+ SatzNr + keylen */
+ sal_uInt8 db_frei1[3]; /* reserviert */
+ sal_uInt8 db_unique; /* eindeutig */
+ char db_name[488]; /* index_name (Feldname) */
+ };
+
+ private:
+ SvStream* m_pFileStream; // Stream zum Lesen/Schreiben des Index
+ NDXHeader m_aHeader;
+ ONDXPageList m_aCollector; // Pool von nicht mehr benoetigten Seiten
+ ONDXPagePtr m_aRoot, // Wurzel des b+ Baums
+ m_aCurLeaf; // aktuelles Blatt
+ USHORT m_nCurNode; // Position des aktuellen Knoten
+
+ sal_uInt32 m_nPageCount,
+ m_nRootPage;
+
+ ODbaseTable* m_pTable;
+ BOOL m_bUseCollector : 1; // Verwenden des GarbageCollectors
+
+ ::rtl::OUString getCompletePath();
+ void closeImpl();
+ /* closes and kill the index file and throws an error.
+ */
+ void impl_killFileAndthrowError_throw(sal_uInt16 _nErrorId,const ::rtl::OUString& _sFile);
+ protected:
+ virtual ~ODbaseIndex();
+ public:
+ ODbaseIndex(ODbaseTable* _pTable);
+ ODbaseIndex(ODbaseTable* _pTable,const NDXHeader& _aHeader,const ::rtl::OUString& _Name);
+
+ sal_Bool openIndexFile();
+ virtual void refreshColumns();
+
+ // 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();
+
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ const ODbaseTable* getTable() const { return m_pTable; }
+ const NDXHeader& getHeader() const { return m_aHeader; }
+ virtual OIndexIterator* createIterator(OBoolOperator_BASE* pOp,
+ const OOperand_BASE* pOperand = NULL);
+
+ void SetRootPos(sal_uInt32 nPos) {m_nRootPage = nPos;}
+ void SetPageCount(sal_uInt32 nCount) {m_nPageCount = nCount;}
+
+ sal_uInt32 GetRootPos() {return m_nRootPage;}
+ sal_uInt32 GetPageCount() {return m_nPageCount;}
+
+ BOOL IsText() const {return m_aHeader.db_keytype == 0;}
+ USHORT GetMaxNodes() const {return m_aHeader.db_maxkeys;}
+
+ virtual BOOL Insert(sal_uInt32 nRec, const ORowSetValue& rValue);
+ virtual BOOL Update(sal_uInt32 nRec, const ORowSetValue&, const ORowSetValue&);
+ virtual BOOL Delete(sal_uInt32 nRec, const ORowSetValue& rValue);
+ virtual BOOL Find(sal_uInt32 nRec, const ORowSetValue& rValue);
+
+ void createINFEntry();
+ BOOL CreateImpl();
+ BOOL DropImpl();
+
+ DECLARE_SERVICE_INFO();
+ protected:
+
+ ONDXPage* CreatePage(sal_uInt32 nPagePos, ONDXPage* pParent = NULL, BOOL bLoad = FALSE);
+ void Collect(ONDXPage*);
+ ONDXPagePtr getRoot();
+
+ sal_Bool isUnique() const { return m_IsUnique; }
+ BOOL UseCollector() const {return m_bUseCollector;}
+ // Tree operationen
+ void Insert(ONDXPagePtr aCurPage, ONDXNode& rNode);
+ void Release(BOOL bSave = TRUE);
+ BOOL ConvertToKey(ONDXKey* rKey, sal_uInt32 nRec, const ORowSetValue& rValue);
+ };
+
+ SvStream& operator << (SvStream &rStream, ODbaseIndex&);
+ SvStream& operator >> (SvStream &rStream, ODbaseIndex&);
+ }
+}
+
+#endif // _CONNECTIVITY_DBASE_INDEX_HXX_
+
+
diff --git a/connectivity/source/inc/dbase/DIndexColumns.hxx b/connectivity/source/inc/dbase/DIndexColumns.hxx
new file mode 100644
index 000000000000..be4f2577237e
--- /dev/null
+++ b/connectivity/source/inc/dbase/DIndexColumns.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_DBASE_INDEXCOLUMNS_HXX_
+#define _CONNECTIVITY_DBASE_INDEXCOLUMNS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include "dbase/DIndex.hxx"
+#include "dbase/DTable.hxx"
+
+namespace connectivity
+{
+ namespace dbase
+ {
+ class ODbaseIndexColumns : public sdbcx::OCollection
+ {
+ ODbaseIndex* m_pIndex;
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ public:
+ ODbaseIndexColumns( ODbaseIndex* _pIndex,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector)
+ : sdbcx::OCollection(*_pIndex,_pIndex->getTable()->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(),_rMutex,_rVector)
+ , m_pIndex(_pIndex)
+ {}
+
+ };
+ }
+}
+#endif // _CONNECTIVITY_DBASE_INDEXCOLUMNS_HXX_
+
+
diff --git a/connectivity/source/inc/dbase/DIndexIter.hxx b/connectivity/source/inc/dbase/DIndexIter.hxx
new file mode 100644
index 000000000000..99ed3f37af91
--- /dev/null
+++ b/connectivity/source/inc/dbase/DIndexIter.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_DBASE_INDEXITER_HXX_
+#define _CONNECTIVITY_DBASE_INDEXITER_HXX_
+
+#include "file/fcode.hxx"
+#include "dbase/DIndex.hxx"
+#include "dbase/dindexnode.hxx"
+
+namespace connectivity
+{
+ namespace dbase
+ {
+ //==================================================================
+ // IndexIterator
+ //==================================================================
+ class OIndexIterator
+ {
+ protected:
+ file::OBoolOperator* m_pOperator;
+ const file::OOperand* m_pOperand;
+ ODbaseIndex* m_pIndex;
+ ONDXPagePtr m_aRoot,
+ m_aCurLeaf;
+ USHORT m_nCurNode;
+
+ protected:
+ ULONG Find(BOOL bFirst);
+ ULONG GetCompare(BOOL bFirst);
+ ULONG GetLike(BOOL bFirst);
+ ULONG GetNull(BOOL bFirst);
+ ULONG GetNotNull(BOOL bFirst);
+
+ ONDXKey* GetFirstKey(ONDXPage* pPage,
+ const file::OOperand& rKey);
+ ONDXKey* GetNextKey();
+ ODbaseIndex* GetIndex() const {return m_pIndex;}
+
+
+ public:
+ OIndexIterator(ODbaseIndex* pInd,
+ file::OBoolOperator* pOp,
+ const file::OOperand* pOper)
+ :m_pOperator(pOp)
+ ,m_pOperand(pOper)
+ ,m_pIndex(pInd)
+ ,m_nCurNode(NODE_NOTFOUND)
+ {
+ pInd->acquire();
+ }
+
+ virtual ~OIndexIterator();
+ ULONG First();
+ ULONG Next();
+
+ };
+ }
+}
+#endif // _CONNECTIVITY_DBASE_INDEXITER_HXX_
+
diff --git a/connectivity/source/inc/dbase/DIndexPage.hxx b/connectivity/source/inc/dbase/DIndexPage.hxx
new file mode 100644
index 000000000000..ad67a7f7ee20
--- /dev/null
+++ b/connectivity/source/inc/dbase/DIndexPage.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_DBASE_INDEXPAGE_HXX_
+#define _CONNECTIVITY_DBASE_INDEXPAGE_HXX_
+
+//#ifndef _REF_HXX
+//#include <tools/ref.hxx>
+//#endif
+#include <vos/ref.hxx>
+#include <tools/stream.hxx>
+#ifndef _VECTOR_
+#include <vector>
+#endif
+//#ifndef _CONNECTIVITY_FILE_FCODE_HXX_
+//#include "file/fcode.hxx"
+//#endif
+//#ifndef _CONNECTIVITY_DBASE_INDEXNODE_HXX_
+//#include "dbase/dindexnode.hxx"
+//#endif
+
+#if 0
+namespace connectivity
+{
+ namespace dbase
+ {
+ //==================================================================
+ // Index Seitenverweis
+ //==================================================================
+ // SV_DECL_REF(ONDXPage); // Basisklasse da weitere Informationen gehalten werden muessen
+
+ class ONDXPage;
+ typedef vos::ORef<ONDXPage> ONDXPagePtr_BASE;
+
+ class ONDXPagePtr : public ONDXPagePtr_BASE //ONDXPageRef
+ {
+ friend SvStream& operator << (SvStream &rStream, const ONDXPagePtr&);
+ friend SvStream& operator >> (SvStream &rStream, ONDXPagePtr&);
+
+ UINT32 nPagePos; // Position in der Indexdatei
+
+ public:
+ ONDXPagePtr(UINT32 nPos = 0):nPagePos(nPos){}
+ ONDXPagePtr(const ONDXPagePtr& rRef);
+ ONDXPagePtr(ONDXPage* pRefPage);
+
+ ONDXPagePtr& operator=(const ONDXPagePtr& rRef);
+ ONDXPagePtr& operator=(ONDXPage* pPageRef);
+
+ UINT32 GetPagePos() const {return nPagePos;}
+ BOOL HasPage() const {return nPagePos != 0;}
+ sal_Bool Is() const { return isValid(); }
+ void Clear()
+ {
+ unbind();
+ }
+ };
+
+ SvStream& operator << (SvStream &rStream, const ONDXPagePtr&);
+ SvStream& operator >> (SvStream &rStream, ONDXPagePtr&);
+ }
+}
+#endif
+#endif // _CONNECTIVITY_DBASE_INDEXPAGE_HXX_
+
diff --git a/connectivity/source/inc/dbase/DIndexes.hxx b/connectivity/source/inc/dbase/DIndexes.hxx
new file mode 100644
index 000000000000..e07e0cb90cb3
--- /dev/null
+++ b/connectivity/source/inc/dbase/DIndexes.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_DBASE_INDEXES_HXX_
+#define _CONNECTIVITY_DBASE_INDEXES_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include "dbase/DTable.hxx"
+
+namespace connectivity
+{
+ namespace dbase
+ {
+ class ODbaseTable;
+
+ typedef sdbcx::OCollection ODbaseIndexes_BASE;
+
+ class ODbaseIndexes : public ODbaseIndexes_BASE
+ {
+ ODbaseTable* m_pTable;
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ ODbaseIndexes(ODbaseTable* _pTable, ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector) : ODbaseIndexes_BASE(*_pTable,_pTable->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(),_rMutex,_rVector)
+ , m_pTable(_pTable)
+ {}
+
+ };
+ }
+}
+#endif // _CONNECTIVITY_DBASE_INDEXES_HXX_
+
diff --git a/connectivity/source/inc/dbase/DPreparedStatement.hxx b/connectivity/source/inc/dbase/DPreparedStatement.hxx
new file mode 100644
index 000000000000..ca682e3383c8
--- /dev/null
+++ b/connectivity/source/inc/dbase/DPreparedStatement.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_DBASE_DPREPAREDSTATEMENT_HXX_
+#define _CONNECTIVITY_DBASE_DPREPAREDSTATEMENT_HXX_
+
+#include "file/FPreparedStatement.hxx"
+
+namespace connectivity
+{
+ namespace dbase
+ {
+ class OConnection;
+ class ODbasePreparedStatement : public file::OPreparedStatement
+ {
+ protected:
+ virtual file::OResultSet* createResultSet();
+ public:
+ ODbasePreparedStatement( file::OConnection* _pConnection) : file::OPreparedStatement( _pConnection){}
+ DECLARE_SERVICE_INFO();
+ };
+ }
+}
+
+#endif //_CONNECTIVITY_DBASE_DPREPAREDSTATEMENT_HXX_
+
diff --git a/connectivity/source/inc/dbase/DResultSet.hxx b/connectivity/source/inc/dbase/DResultSet.hxx
new file mode 100644
index 000000000000..f84d749aabe8
--- /dev/null
+++ b/connectivity/source/inc/dbase/DResultSet.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef _CONNECTIVITY_DBASE_DRESULTSET_HXX_
+#define _CONNECTIVITY_DBASE_DRESULTSET_HXX_
+
+#include "file/FResultSet.hxx"
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+namespace connectivity
+{
+ namespace dbase
+ {
+ class ODbaseResultSet;
+ // these typedef's are only necessary for the compiler
+ typedef ::cppu::ImplHelper2< ::com::sun::star::sdbcx::XRowLocate,
+ ::com::sun::star::sdbcx::XDeleteRows> ODbaseResultSet_BASE;
+ typedef file::OResultSet ODbaseResultSet_BASE2;
+ typedef ::comphelper::OPropertyArrayUsageHelper<ODbaseResultSet> ODbaseResultSet_BASE3;
+
+
+ class ODbaseResultSet : public ODbaseResultSet_BASE2,
+ public ODbaseResultSet_BASE,
+ public ODbaseResultSet_BASE3
+ {
+ sal_Bool m_bBookmarkable;
+ protected:
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ virtual sal_Bool fillIndexValues(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier> &_xIndex);
+ virtual file::OSQLAnalyzer* createAnalyzer();
+ public:
+ DECLARE_SERVICE_INFO();
+
+ ODbaseResultSet( 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);
+ // 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);
+
+ // own methods
+ sal_Int32 getCurrentFilePos() const;
+
+ };
+ }
+}
+#endif //_CONNECTIVITY_DBASE_DRESULTSET_HXX_
+
diff --git a/connectivity/source/inc/dbase/DStatement.hxx b/connectivity/source/inc/dbase/DStatement.hxx
new file mode 100644
index 000000000000..fae73931be30
--- /dev/null
+++ b/connectivity/source/inc/dbase/DStatement.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_DBASE_DSTATEMENT_HXX_
+#define _CONNECTIVITY_DBASE_DSTATEMENT_HXX_
+
+#include "file/FStatement.hxx"
+
+namespace connectivity
+{
+ namespace dbase
+ {
+ class OConnection;
+ class ODbaseStatement : public file::OStatement
+ {
+ protected:
+ virtual file::OResultSet* createResultSet();
+ public:
+ ODbaseStatement( file::OConnection* _pConnection) : file::OStatement( _pConnection){}
+ DECLARE_SERVICE_INFO();
+ };
+ }
+}
+
+#endif //_CONNECTIVITY_DBASE_DSTATEMENT_HXX_
diff --git a/connectivity/source/inc/dbase/DTable.hxx b/connectivity/source/inc/dbase/DTable.hxx
new file mode 100644
index 000000000000..cca6d97c41c6
--- /dev/null
+++ b/connectivity/source/inc/dbase/DTable.hxx
@@ -0,0 +1,185 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_DBASE_TABLE_HXX_
+#define _CONNECTIVITY_DBASE_TABLE_HXX_
+
+#include "file/FTable.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include "connectivity/CommonTools.hxx"
+#include <tools/urlobj.hxx>
+
+
+namespace connectivity
+{
+ namespace dbase
+ {
+ typedef file::OFileTable ODbaseTable_BASE;
+ class ODbaseConnection;
+
+ typedef ::std::map< ::rtl::OUString,
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed>, comphelper::UStringMixLess > OContainer;
+
+ class ODbaseTable : public ODbaseTable_BASE
+ {
+ // der Typ einer dBase datei wird mit dem ersten Byte bestimmt
+ public:
+ enum DBFType { dBaseIII = 0x03,
+ dBaseIV = 0x04,
+ dBaseV = 0x05,
+ VisualFoxPro = 0x30,
+ VisualFoxProAuto = 0x31, // Visual FoxPro w. AutoIncrement field
+ dBaseFS = 0x43,
+ dBaseFSMemo = 0xB3,
+ dBaseIIIMemo = 0x83,
+ dBaseIVMemo = 0x8B,
+ dBaseIVMemoSQL = 0x8E,
+ FoxProMemo = 0xF5
+ };
+ enum DBFMemoType { MemodBaseIII = 0,
+ MemodBaseIV,
+ MemoFoxPro
+ };
+
+ private:
+ struct DBFHeader { /* Kopfsatz-Struktur */
+ DBFType db_typ; /* Dateityp */
+ BYTE db_aedat[3]; /* Datum der letzen Aenderung */
+ /* JJ MM TT */
+ sal_uInt32 db_anz; /* Anzahl der Saetze */
+ USHORT db_kopf; /* laenge Kopfsatz-Struktur */
+ USHORT db_slng; /* laenge der Daten-Saetze */
+ BYTE db_frei[20]; /* reserviert */
+ };
+ struct DBFColumn { /* Feldbezeichner */
+ BYTE db_fnm[11]; /* Feldname */
+ BYTE db_typ; /* Feldtyp */
+ UINT32 db_adr; /* Feldadresse */
+ BYTE db_flng; /* Feldlaenge */
+ BYTE db_dez; /* Dezimalstellen fuer N */
+ BYTE db_frei2[14]; /* reserviert */
+ };
+ struct DBFMemoHeader
+ {
+ DBFMemoType db_typ; /* Dateityp */
+ UINT32 db_next; /* naechster freier Block */
+ USHORT db_size; /* Blockgroesse: dBase 3 fest */
+ };
+
+ ::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;
+ ::std::vector<sal_Int32> m_aRealFieldLengths;
+ DBFHeader m_aHeader;
+ DBFMemoHeader m_aMemoHeader;
+ SvStream* m_pMemoStream;
+ rtl_TextEncoding m_eEncoding;
+ sal_Bool m_bWriteableMemo;
+
+ void alterColumn(sal_Int32 index,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& descriptor ,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XDataDescriptorFactory>& xOldColumn );
+ void readHeader();
+ void fillColumns();
+ String createTempFile();
+ void copyData(ODbaseTable* _pNewTable,sal_Int32 _nPos);
+ BOOL CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo);
+ BOOL CreateMemoFile(const INetURLObject& aFile);
+ BOOL HasMemoFields() const { return m_aHeader.db_typ > dBaseIV;}
+ BOOL ReadMemoHeader();
+ BOOL ReadMemo(ULONG nBlockNo, ORowSetValue& aVariable);
+
+ BOOL WriteMemo(ORowSetValue& aVariable, ULONG& rBlockNr);
+ BOOL WriteBuffer();
+ BOOL UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols);
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> isUniqueByColumnName(sal_Int32 _nColumnPos);
+ void AllocBuffer();
+
+ void throwInvalidDbaseFormat();
+ void SAL_CALL renameImpl( const ::rtl::OUString& newName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+ void throwInvalidColumnType(const sal_uInt16 _nErrorId,const ::rtl::OUString& _sColumnName);
+
+ protected:
+ virtual void FileClose();
+// using ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper;
+
+ public:
+ virtual void refreshColumns();
+ virtual void refreshIndexes();
+
+ public:
+ ODbaseTable( sdbcx::OCollection* _pTables,ODbaseConnection* _pConnection);
+ ODbaseTable( sdbcx::OCollection* _pTables,ODbaseConnection* _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_Int32 getCurrentLastPos() const;
+ virtual sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos);
+ virtual sal_Bool fetchRow(OValueRefRow& _rRow,const OSQLColumns& _rCols, sal_Bool _bUseTableDefs,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();
+ // XAlterTable
+ virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& colName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL alterColumnByIndex( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ // XRename
+ virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+
+ BOOL DropImpl();
+ BOOL CreateImpl();
+
+
+ virtual BOOL InsertRow(OValueRefVector& rRow, BOOL bFlush,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols);
+ virtual BOOL DeleteRow(const OSQLColumns& _rCols);
+ virtual BOOL UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols);
+
+ virtual void addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& descriptor);
+ virtual void dropColumn(sal_Int32 _nPos);
+
+ static String getEntry(file::OConnection* _pConnection,const ::rtl::OUString& _sURL );
+ static BOOL Drop_Static(const ::rtl::OUString& _sUrl,sal_Bool _bHasMemoFields,sdbcx::OCollection* _pIndexes );
+
+ virtual void refreshHeader();
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() const;
+ };
+ }
+}
+#endif // _CONNECTIVITY_DBASE_TABLE_HXX_
+
diff --git a/connectivity/source/inc/dbase/DTables.hxx b/connectivity/source/inc/dbase/DTables.hxx
new file mode 100644
index 000000000000..1ada68b8cf20
--- /dev/null
+++ b/connectivity/source/inc/dbase/DTables.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_DBASE_TABLES_HXX_
+#define _CONNECTIVITY_DBASE_TABLES_HXX_
+
+#include "file/FTables.hxx"
+
+namespace connectivity
+{
+ namespace dbase
+ {
+ // namespace ::com::sun::star::sdbcx = ::com::sun::star::sdbcx;
+ typedef file::OTables ODbaseTables_BASE;
+
+ class ODbaseTables : public ODbaseTables_BASE
+ {
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ ODbaseTables(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector) : ODbaseTables_BASE(_rMetaData,_rParent,_rMutex,_rVector)
+ {}
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+#endif // _CONNECTIVITY_DBASE_TABLES_HXX_
+
diff --git a/connectivity/source/inc/dbase/dindexnode.hxx b/connectivity/source/inc/dbase/dindexnode.hxx
new file mode 100644
index 000000000000..97661e3ff5d9
--- /dev/null
+++ b/connectivity/source/inc/dbase/dindexnode.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef _CONNECTIVITY_DBASE_INDEXNODE_HXX_
+#define _CONNECTIVITY_DBASE_INDEXNODE_HXX_
+
+#include "file/fcode.hxx"
+#include "file/FTable.hxx"
+#include "dbase/DIndexPage.hxx"
+#include "connectivity/FValue.hxx"
+#include <tools/ref.hxx>
+
+#define NODE_NOTFOUND 0xFFFF
+#define PAGE_SIZE 512
+
+namespace connectivity
+{
+ namespace dbase
+ {
+
+ class ONDXNode;
+ class ODbaseIndex;
+ //==================================================================
+ // Index Key
+ //==================================================================
+ typedef file::OOperand ONDXKey_BASE;
+ class ONDXKey : public ONDXKey_BASE
+ {
+ friend class ONDXNode;
+ UINT32 nRecord; /* Satzzeiger */
+ ORowSetValue xValue; /* Schluesselwert */
+
+ public:
+ ONDXKey(UINT32 nRec=0);
+ ONDXKey(const ORowSetValue& rVal, sal_Int32 eType, UINT32 nRec);
+ ONDXKey(const rtl::OUString& aStr, UINT32 nRec = 0);
+ ONDXKey(double aVal, UINT32 nRec = 0);
+
+ inline ONDXKey(const ONDXKey& rKey);
+
+ inline ONDXKey& operator= (const ONDXKey& rKey);
+ virtual void setValue(const ORowSetValue& _rVal);
+
+ virtual const ORowSetValue& getValue() const;
+
+ UINT32 GetRecord() const { return nRecord; }
+ void setRecord(UINT32 _nRec) { nRecord = _nRec; }
+ void ResetRecord() { nRecord = 0; }
+
+ BOOL operator == (const ONDXKey& rKey) const;
+ BOOL operator != (const ONDXKey& rKey) const;
+ BOOL operator < (const ONDXKey& rKey) const;
+ BOOL operator <= (const ONDXKey& rKey) const;
+ BOOL operator > (const ONDXKey& rKey) const;
+ BOOL operator >= (const ONDXKey& rKey) const;
+
+ BOOL Load (SvFileStream& rStream, BOOL bText);
+ BOOL Write(SvFileStream& rStream, BOOL bText);
+
+ static BOOL IsText(sal_Int32 eType);
+
+ private:
+ StringCompare Compare(const ONDXKey& rKey) const;
+ };
+
+
+
+
+ //==================================================================
+ // Index Seitenverweis
+ //==================================================================
+ SV_DECL_REF(ONDXPage) // Basisklasse da weitere Informationen gehalten werden muessen
+
+
+ class ONDXPagePtr : public ONDXPageRef
+ {
+ friend SvStream& operator << (SvStream &rStream, const ONDXPagePtr&);
+ friend SvStream& operator >> (SvStream &rStream, ONDXPagePtr&);
+
+ UINT32 nPagePos; // Position in der Indexdatei
+
+ public:
+ ONDXPagePtr(UINT32 nPos = 0):nPagePos(nPos){}
+ ONDXPagePtr(const ONDXPagePtr& rRef);
+ ONDXPagePtr(ONDXPage* pRefPage);
+
+ ONDXPagePtr& operator=(const ONDXPagePtr& rRef);
+ ONDXPagePtr& operator=(ONDXPage* pPageRef);
+
+ UINT32 GetPagePos() const {return nPagePos;}
+ BOOL HasPage() const {return nPagePos != 0;}
+ // sal_Bool Is() const { return isValid(); }
+ };
+ //==================================================================
+ // Index Seite
+ //==================================================================
+ class ONDXPage : public SvRefBase
+ {
+ friend class ODbaseIndex;
+
+ friend SvStream& operator << (SvStream &rStream, const ONDXPage&);
+ friend SvStream& operator >> (SvStream &rStream, ONDXPage&);
+
+ UINT32 nPagePos; // Position in der Indexdatei
+ BOOL bModified : 1;
+ USHORT nCount;
+
+ ONDXPagePtr aParent, // VaterSeite
+ aChild; // Zeiger auf rechte ChildPage
+ ODbaseIndex& rIndex;
+ ONDXNode* ppNodes; // array von Knoten
+
+ public:
+ // Knoten Operationen
+ USHORT Count() const {return nCount;}
+
+ BOOL Insert(ONDXNode& rNode, sal_uInt32 nRowsLeft = 0);
+ BOOL Insert(USHORT nIndex, ONDXNode& rNode);
+ BOOL Append(ONDXNode& rNode);
+ BOOL Delete(USHORT);
+ void Remove(USHORT);
+ void Release(BOOL bSave = TRUE);
+ void ReleaseFull(BOOL bSave = TRUE);
+
+ // Aufteilen und Zerlegen
+ ONDXNode Split(ONDXPage& rPage);
+ void Merge(USHORT nParentNodePos, ONDXPagePtr xPage);
+
+ // Zugriffsoperationen
+ ONDXNode& operator[] (USHORT nPos);
+ const ONDXNode& operator[] (USHORT nPos) const;
+
+ BOOL IsRoot() const;
+ BOOL IsLeaf() const;
+ BOOL IsModified() const;
+ BOOL HasParent();
+ BOOL HasChild() const;
+
+ BOOL IsFull() const;
+
+ UINT32 GetPagePos() const {return nPagePos;}
+ ONDXPagePtr& GetChild(ODbaseIndex* pIndex = 0);
+
+ // Parent braucht nicht nachgeladen zu werden
+ ONDXPagePtr GetParent();
+ ODbaseIndex& GetIndex() {return rIndex;}
+ const ODbaseIndex& GetIndex() const {return rIndex;}
+
+ // Setzen des Childs, ueber Referenz, um die PagePos zu erhalten
+ void SetChild(ONDXPagePtr aCh);
+ void SetParent(ONDXPagePtr aPa);
+
+ USHORT Search(const ONDXKey& rSearch);
+ USHORT Search(const ONDXPage* pPage);
+ void SearchAndReplace(const ONDXKey& rSearch, ONDXKey& rReplace);
+
+ protected:
+ ONDXPage(ODbaseIndex& rIndex, sal_uInt32 nPos, ONDXPage* = NULL);
+ ~ONDXPage();
+
+ virtual void QueryDelete();
+
+ void SetModified(BOOL bMod) {bModified = bMod;}
+ void SetPagePos(UINT32 nPage) {nPagePos = nPage;}
+
+ BOOL Find(const ONDXKey&); // rek. Abstieg
+ USHORT FindPos(const ONDXKey& rKey) const;
+
+#if OSL_DEBUG_LEVEL > 1
+ void PrintPage();
+#endif
+ };
+
+ SV_IMPL_REF(ONDXPage);
+
+ SvStream& operator << (SvStream &rStream, const ONDXPagePtr&);
+ SvStream& operator >> (SvStream &rStream, ONDXPagePtr&);
+
+ inline BOOL ONDXPage::IsRoot() const {return !aParent.Is();}
+ inline BOOL ONDXPage::IsLeaf() const {return !aChild.HasPage();}
+ inline BOOL ONDXPage::IsModified() const {return bModified;}
+ inline BOOL ONDXPage::HasParent() {return aParent.Is();}
+ inline BOOL ONDXPage::HasChild() const {return aChild.HasPage();}
+ inline ONDXPagePtr ONDXPage::GetParent() {return aParent;}
+
+ inline void ONDXPage::SetParent(ONDXPagePtr aPa = ONDXPagePtr())
+ {
+ aParent = aPa;
+ }
+
+ inline void ONDXPage::SetChild(ONDXPagePtr aCh = ONDXPagePtr())
+ {
+ aChild = aCh;
+ if (aChild.Is())
+ aChild->SetParent(this);
+ }
+ SvStream& operator >> (SvStream &rStream, ONDXPage& rPage);
+ SvStream& operator << (SvStream &rStream, const ONDXPage& rPage);
+
+
+ typedef ::std::vector<ONDXPage*> ONDXPageList;
+
+ //==================================================================
+ // Index Knoten
+ //==================================================================
+ class ONDXNode
+ {
+ friend class ONDXPage;
+ ONDXPagePtr aChild; /* naechster Seitenverweis */
+ ONDXKey aKey;
+
+ public:
+ ONDXNode(){}
+ ONDXNode(const ONDXKey& rKey,
+ ONDXPagePtr aPagePtr = ONDXPagePtr())
+ :aChild(aPagePtr),aKey(rKey) {}
+
+ // verweist der Knoten auf eine Seite
+ BOOL HasChild() const {return aChild.HasPage();}
+ // Ist ein Index angegeben, kann gegebenfalls die Seite nachgeladen werden
+ ONDXPagePtr& GetChild(ODbaseIndex* pIndex = NULL, ONDXPage* = NULL);
+
+ const ONDXKey& GetKey() const { return aKey;}
+ ONDXKey& GetKey() { return aKey;}
+
+ // Setzen des Childs, ueber Referenz, um die PagePos zu erhalten
+ void SetChild(ONDXPagePtr aCh = ONDXPagePtr(), ONDXPage* = NULL);
+ void SetKey(ONDXKey& rKey) {aKey = rKey;}
+
+ void Write(SvStream &rStream, const ONDXPage& rPage) const;
+ void Read(SvStream &rStream, ODbaseIndex&);
+ };
+ //==================================================================
+ // inline implementation
+ //==================================================================
+// inline ONDXKey::ONDXKey(const ORowSetValue& rVal, sal_Int32 eType, UINT32 nRec)
+// : ONDXKey_BASE(eType)
+// , nRecord(nRec),xValue(rVal)
+// {
+// }
+
+
+// inline ONDXKey::ONDXKey(const rtl::OUString& aStr, UINT32 nRec)
+// : ONDXKey_BASE(::com::sun::star::sdbc::DataType::VARCHAR)
+// ,nRecord(nRec)
+// {
+// if (aStr.len())
+// xValue = aStr;
+// }
+
+// inline ONDXKey::ONDXKey(double aVal, UINT32 nRec)
+// : ONDXKey_BASE(::com::sun::star::sdbc::DataType::DOUBLE)
+// ,nRecord(nRec)
+// ,xValue(aVal)
+// {
+// }
+
+// inline ONDXKey::ONDXKey(UINT32 nRec)
+// :nRecord(nRec)
+// {
+// }
+
+ inline ONDXKey::ONDXKey(const ONDXKey& rKey)
+ : ONDXKey_BASE(rKey.getDBType())
+ ,nRecord(rKey.nRecord)
+ ,xValue(rKey.xValue)
+ {
+ }
+
+ inline ONDXKey& ONDXKey::operator=(const ONDXKey& rKey)
+ {
+ if(&rKey == this)
+ return *this;
+
+ xValue = rKey.xValue;
+ nRecord = rKey.nRecord;
+ m_eDBType = rKey.getDBType();
+ return *this;
+ }
+
+ inline BOOL ONDXKey::operator == (const ONDXKey& rKey) const
+ {
+ if(&rKey == this)
+ return sal_True;
+ return Compare(rKey) == COMPARE_EQUAL;
+ }
+ inline BOOL ONDXKey::operator != (const ONDXKey& rKey) const
+ {
+ return !operator== (rKey);
+ }
+ inline BOOL ONDXKey::operator < (const ONDXKey& rKey) const
+ {
+ return Compare(rKey) == COMPARE_LESS;
+ }
+ inline BOOL ONDXKey::operator > (const ONDXKey& rKey) const
+ {
+ return Compare(rKey) == COMPARE_GREATER;
+ }
+ inline BOOL ONDXKey::operator <= (const ONDXKey& rKey) const
+ {
+ return !operator > (rKey);
+ }
+ inline BOOL ONDXKey::operator >= (const ONDXKey& rKey) const
+ {
+ return !operator< (rKey);
+ }
+
+ inline void ONDXNode::SetChild(ONDXPagePtr aCh, ONDXPage* pParent)
+ {
+ aChild = aCh;
+ if (aChild.Is())
+ aChild->SetParent(pParent);
+ }
+
+ }
+
+}
+
+
+
+
+#endif // _CONNECTIVITY_DBASE_INDEXNODE_HXX_
+
+
diff --git a/connectivity/source/inc/diagnose_ex.h b/connectivity/source/inc/diagnose_ex.h
new file mode 100644
index 000000000000..1bdb4f451281
--- /dev/null
+++ b/connectivity/source/inc/diagnose_ex.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.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_DIAGNOSE_EX_H
+#define CONNECTIVITY_DIAGNOSE_EX_H
+
+#if OSL_DEBUG_LEVEL > 0
+ #define OSL_VERIFY_RES( expression, fail_message ) \
+ OSL_ENSURE( expression, fail_message )
+ #define OSL_VERIFY_EQUALS( expression, compare, fail_message ) \
+ OSL_ENSURE( expression == compare, fail_message )
+#else
+ #define OSL_VERIFY_RES( expression, fail_message ) \
+ (void)(expression)
+ #define OSL_VERIFY_EQUALS( expression, compare, fail_message ) \
+ (void)(expression)
+#endif
+
+#define OSL_UNUSED( expression ) \
+ (void)(expression)
+
+#endif // CONNECTIVITY_DIAGNOSE_EX_H
diff --git a/connectivity/source/inc/file/FCatalog.hxx b/connectivity/source/inc/file/FCatalog.hxx
new file mode 100644
index 000000000000..2b16a43f42fc
--- /dev/null
+++ b/connectivity/source/inc/file/FCatalog.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_FILE_CATALOG_HXX_
+#define _CONNECTIVITY_FILE_CATALOG_HXX_
+
+#include "connectivity/sdbcx/VCatalog.hxx"
+
+#include "file/filedllapi.hxx"
+
+namespace connectivity
+{
+ namespace file
+ {
+ class OConnection;
+ class OOO_DLLPUBLIC_FILE SAL_NO_VTABLE OFileCatalog :
+ public connectivity::sdbcx::OCatalog
+ {
+ protected:
+ OConnection* m_pConnection;
+
+ /** builds the name which should be used to access the object later on in the collection.
+ Will only be called in fillNames.
+ @param _xRow
+ The current row from the resultset given to fillNames.
+ */
+ virtual ::rtl::OUString buildName( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >& _xRow);
+
+ public:
+ virtual void refreshTables();
+ virtual void refreshViews();
+ virtual void refreshGroups();
+ virtual void refreshUsers();
+
+ public:
+ OFileCatalog(OConnection* _pCon);
+ OConnection* getConnection() { return m_pConnection; }
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ // ::cppu::OComponentHelper
+ 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);
+ };
+ }
+}
+#endif // _CONNECTIVITY_FILE_CATALOG_HXX_
+
diff --git a/connectivity/source/inc/file/FColumns.hxx b/connectivity/source/inc/file/FColumns.hxx
new file mode 100644
index 000000000000..119ad228ad55
--- /dev/null
+++ b/connectivity/source/inc/file/FColumns.hxx
@@ -0,0 +1,59 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_FILE_COLUMNS_HXX_
+#define _CONNECTIVITY_FILE_COLUMNS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include "file/FTable.hxx"
+#include "file/filedllapi.hxx"
+
+namespace connectivity
+{
+ namespace file
+ {
+ class OOO_DLLPUBLIC_FILE OColumns : public sdbcx::OCollection
+ {
+ protected:
+ OFileTable* m_pTable;
+
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ public:
+ OColumns( OFileTable* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector
+ ) : sdbcx::OCollection(*_pTable,_pTable->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(),_rMutex,_rVector)
+ ,m_pTable(_pTable)
+ {}
+ };
+ }
+}
+#endif // _CONNECTIVITY_FILE_COLUMNS_HXX_
+
diff --git a/connectivity/source/inc/file/FConnection.hxx b/connectivity/source/inc/file/FConnection.hxx
new file mode 100644
index 000000000000..d908ec836264
--- /dev/null
+++ b/connectivity/source/inc/file/FConnection.hxx
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_FILE_OCONNECTION_HXX_
+#define _CONNECTIVITY_FILE_OCONNECTION_HXX_
+
+#include <com/sun/star/ucb/XContent.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include "OSubComponent.hxx"
+#ifndef _MAP_
+#include <map>
+#endif
+#include "connectivity/CommonTools.hxx"
+#include "OTypeInfo.hxx"
+#include <tools/string.hxx>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/ucb/XDynamicResultSet.hpp>
+#include "connectivity/sqlparse.hxx"
+#include "connectivity/sqliterator.hxx"
+#include "TConnection.hxx"
+#include "file/filedllapi.hxx"
+
+namespace connectivity
+{
+ namespace file
+ {
+
+ class OStatement_Base;
+ class ODatabaseMetaData;
+ class OFileDriver;
+
+ class OOO_DLLPUBLIC_FILE OConnection :
+ public connectivity::OMetaConnection,
+ public connectivity::OSubComponent<OConnection, connectivity::OMetaConnection>
+ {
+ friend class connectivity::OSubComponent<OConnection, connectivity::OMetaConnection>;
+
+ protected:
+ //====================================================================
+ // Data attributes
+ //====================================================================
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog;
+
+ ::com::sun::star::sdbc::SQLWarning m_aLastWarning; // Last SQLWarning generated by
+
+ String m_aFilenameExtension;
+ OFileDriver* m_pDriver; // Pointer to the owning
+ // driver object
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XDynamicResultSet > m_xDir; // directory
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent> m_xContent;
+
+ sal_Bool m_bClosed;
+ sal_Bool m_bAutoCommit;
+ sal_Bool m_bReadOnly;
+ sal_Bool m_bShowDeleted;
+ sal_Bool m_bCaseSensitiveExtension;
+ sal_Bool m_bCheckSQL92;
+ bool m_bDefaultTextEncoding;
+
+
+ void throwUrlNotValid(const ::rtl::OUString & _rsUrl,const ::rtl::OUString & _rsMessage);
+
+ virtual ~OConnection();
+ public:
+
+ OConnection(OFileDriver* _pDriver);
+
+ 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);
+
+ 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);
+ //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();
+
+ // no interface methods
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XDynamicResultSet > getDir() const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent> getContent() const { return m_xContent; }
+ // create a catalog or return the catalog already created
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > createCatalog();
+
+ sal_Bool matchesExtension( const String& _rExt ) const;
+
+ inline const String& getExtension() const { return m_aFilenameExtension; }
+ inline sal_Bool isCaseSensitveExtension() const { return m_bCaseSensitiveExtension; }
+ inline OFileDriver* getDriver() const { return m_pDriver; }
+ inline sal_Bool showDeleted() const { return m_bShowDeleted; }
+ inline sal_Bool isCheckEnabled() const { return m_bCheckSQL92; }
+ inline bool isTextEncodingDefaulted() const { return m_bDefaultTextEncoding; }
+
+ public:
+ struct GrantAccess
+ {
+ friend class ODatabaseMetaData;
+ private:
+ GrantAccess() { }
+ };
+
+ void setCaseSensitiveExtension( sal_Bool _bIsCS, GrantAccess ) { m_bCaseSensitiveExtension = _bIsCS; }
+ };
+ }
+}
+#endif // _CONNECTIVITY_FILE_OCONNECTION_HXX_
+
diff --git a/connectivity/source/inc/file/FDatabaseMetaData.hxx b/connectivity/source/inc/file/FDatabaseMetaData.hxx
new file mode 100644
index 000000000000..4104b72a8045
--- /dev/null
+++ b/connectivity/source/inc/file/FDatabaseMetaData.hxx
@@ -0,0 +1,197 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_FILE_ODATABASEMETADATA_HXX_
+#define _CONNECTIVITY_FILE_ODATABASEMETADATA_HXX_
+
+#include "TDatabaseMetaDataBase.hxx"
+#include "file/FConnection.hxx"
+#include "file/filedllapi.hxx"
+
+namespace connectivity
+{
+ namespace file
+ {
+ //**************************************************************
+ //************ Class: ODatabaseMetaData
+ //**************************************************************
+
+ class OOO_DLLPUBLIC_FILE SAL_NO_VTABLE ODatabaseMetaData :
+ public ODatabaseMetaDataBase
+ {
+ 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( );
+ protected:
+ OConnection* m_pConnection; // I need the native class not only the interface
+ virtual ~ODatabaseMetaData();
+ public:
+
+ ODatabaseMetaData(OConnection* _pCon);
+ // 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_FILE_ODATABASEMETADATA_HXX_
+
diff --git a/connectivity/source/inc/file/FDateFunctions.hxx b/connectivity/source/inc/file/FDateFunctions.hxx
new file mode 100644
index 000000000000..30c553dc17ab
--- /dev/null
+++ b/connectivity/source/inc/file/FDateFunctions.hxx
@@ -0,0 +1,242 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_FILE_FDATEFUNCTIONS_HXX_
+#define _CONNECTIVITY_FILE_FDATEFUNCTIONS_HXX_
+
+#include "file/fcode.hxx"
+#include "file/filedllapi.hxx"
+
+namespace connectivity
+{
+ class OSQLParseNode;
+ namespace file
+ {
+ /** DAYOFWEEK(date)
+ Returns the weekday index for date (1 = Sunday, 2 = Monday, ... 7 = Saturday). These index values correspond to the ODBC standard.
+
+ > SELECT DAYOFWEEK('1998-02-03');
+ -> 3
+ */
+ class OOp_DayOfWeek : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** DAYOFMONTH(date)
+ Returns the day of the month for date, in the range 1 to 31:
+
+ > SELECT DAYOFMONTH('1998-02-03');
+ -> 3
+ */
+ class OOp_DayOfMonth : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** DAYOFYEAR(date)
+ Returns the day of the year for date, in the range 1 to 366:
+
+ > SELECT DAYOFYEAR('1998-02-03');
+ -> 34
+
+ */
+ class OOp_DayOfYear : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** MONTH(date)
+ Returns the month for date, in the range 1 to 12:
+
+ > SELECT MONTH('1998-02-03');
+ -> 2
+ */
+ class OOp_Month : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** DAYNAME(date)
+ Returns the name of the weekday for date:
+
+ > SELECT DAYNAME('1998-02-05');
+ -> 'Thursday'
+
+ */
+ class OOp_DayName : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** MONTHNAME(date)
+ Returns the name of the month for date:
+
+ > SELECT MONTHNAME('1998-02-05');
+ -> 'February'
+
+ */
+ class OOp_MonthName : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** QUARTER(date)
+ Returns the quarter of the year for date, in the range 1 to 4:
+
+ > SELECT QUARTER('98-04-01');
+ -> 2
+
+ */
+ class OOp_Quarter : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** WEEK(date)
+ WEEK(date,first)
+ With a single argument, returns the week for date, in the range 0 to 53 (yes, there may be the beginnings of a week 53), for locations where Sunday is the first day of the week. The two-argument form of WEEK() allows you to specify whether the week starts on Sunday or Monday and whether the return value should be in the range 0-53 or 1-52. Here is a table for how the second argument works:
+ Value Meaning
+ 0 Week starts on Sunday and return value is in range 0-53
+ 1 Week starts on Monday and return value is in range 0-53
+ 2 Week starts on Sunday and return value is in range 1-53
+ 3 Week starts on Monday and return value is in range 1-53 (ISO 8601)
+
+ > SELECT WEEK('1998-02-20');
+ -> 7
+ > SELECT WEEK('1998-02-20',0);
+ -> 7
+ > SELECT WEEK('1998-02-20',1);
+ -> 8
+ > SELECT WEEK('1998-12-31',1);
+ -> 53
+
+ */
+ class OOp_Week : public ONthOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
+ };
+
+ /** YEAR(date)
+ Returns the year for date, in the range 1000 to 9999:
+
+ > SELECT YEAR('98-02-03');
+ -> 1998
+ */
+ class OOp_Year : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** HOUR(time)
+ Returns the hour for time, in the range 0 to 23:
+
+ > SELECT HOUR('10:05:03');
+ -> 10
+ */
+ class OOp_Hour : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** MINUTE(time)
+ Returns the minute for time, in the range 0 to 59:
+
+ > SELECT MINUTE('98-02-03 10:05:03');
+ -> 5
+
+ */
+ class OOp_Minute : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** SECOND(time)
+ Returns the second for time, in the range 0 to 59:
+
+ > SELECT SECOND('10:05:03');
+ -> 3
+ */
+ class OOp_Second : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** CURDATE()
+ CURRENT_DATE
+ Returns today's date as a value in 'YYYY-MM-DD' or YYYYMMDD format, depending on whether the function is used in a string or numeric context:
+
+ > SELECT CURDATE();
+ -> '1997-12-15'
+ */
+ class OOp_CurDate : public ONthOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
+ };
+
+ /** CURTIME()
+ CURRENT_TIME
+ Returns the current time as a value in 'HH:MM:SS' or HHMMSS format, depending on whether the function is used in a string or numeric context:
+
+ > SELECT CURTIME();
+ -> '23:50:26'
+ */
+ class OOp_CurTime : public ONthOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
+ };
+
+ /** NOW()
+ Returns the current date and time as a value in 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context:
+
+ > SELECT NOW();
+ -> '1997-12-15 23:50:26'
+ */
+ class OOp_Now : public ONthOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_FILE_FCODE_HXX_
+
diff --git a/connectivity/source/inc/file/FDriver.hxx b/connectivity/source/inc/file/FDriver.hxx
new file mode 100644
index 000000000000..416f6e48eb9d
--- /dev/null
+++ b/connectivity/source/inc/file/FDriver.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_FILE_ODRIVER_HXX_
+#define _CONNECTIVITY_FILE_ODRIVER_HXX_
+
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#include <cppuhelper/compbase3.hxx>
+#include "connectivity/CommonTools.hxx"
+#include "file/filedllapi.hxx"
+
+namespace connectivity
+{
+ namespace file
+ {
+ typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XDriver,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::sdbcx::XDataDefinitionSupplier> ODriver_BASE;
+
+ class OOO_DLLPUBLIC_FILE SAL_NO_VTABLE OFileDriver : public ODriver_BASE
+ {
+ protected:
+ ::osl::Mutex m_aMutex;
+
+ connectivity::OWeakRefArray m_xConnections; // vector containing a list
+ // of all the Connection objects
+ // for this Driver
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
+ public:
+ OFileDriver(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);
+
+ // XDataDefinitionSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByURL( 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);
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getFactory() const { return m_xFactory; }
+ };
+ }
+
+}
+#endif //_CONNECTIVITY_FILE_ODRIVER_HXX_
+
+
diff --git a/connectivity/source/inc/file/FNumericFunctions.hxx b/connectivity/source/inc/file/FNumericFunctions.hxx
new file mode 100644
index 000000000000..cd52f1a1158a
--- /dev/null
+++ b/connectivity/source/inc/file/FNumericFunctions.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_FILE_FNUMERICFUNCTIONS_HXX_
+#define _CONNECTIVITY_FILE_FNUMERICFUNCTIONS_HXX_
+
+#include "file/fcode.hxx"
+#include "file/filedllapi.hxx"
+
+namespace connectivity
+{
+ class OSQLParseNode;
+ namespace file
+ {
+ /** ABS(X)
+ Returns the absolute value of X:
+
+ > SELECT ABS(2);
+ -> 2
+ > SELECT ABS(-32);
+ -> 32
+
+ */
+ class OOp_Abs : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** SIGN(X)
+ Returns the sign of the argument as -1, 0, or 1, depending on whether X is negative, zero, or positive:
+
+ > SELECT SIGN(-32);
+ -> -1
+ > SELECT SIGN(0);
+ -> 0
+ > SELECT SIGN(234);
+ -> 1
+
+ */
+ class OOp_Sign : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** MOD(N,M)
+ %
+ Modulo (like the % operator in C). Returns the remainder of N divided by M:
+
+ > SELECT MOD(234, 10);
+ -> 4
+ > SELECT 253 % 7;
+ -> 1
+ > SELECT MOD(29,9);
+ -> 2
+ > SELECT 29 MOD 9;
+ -> 2
+ */
+ class OOp_Mod : public OBinaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
+ };
+
+ /** FLOOR(X)
+ Returns the largest integer value not greater than X:
+
+ > SELECT FLOOR(1.23);
+ -> 1
+ > SELECT FLOOR(-1.23);
+ -> -2
+
+ */
+ class OOp_Floor : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** CEILING(X)
+ Returns the smallest integer value not less than X:
+
+ > SELECT CEILING(1.23);
+ -> 2
+ > SELECT CEILING(-1.23);
+ -> -1
+
+ */
+ class OOp_Ceiling : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** ROUND(X)
+ ROUND(X,D)
+ Returns the argument X, rounded to the nearest integer. With two arguments rounded to a number to D decimals.
+
+ > SELECT ROUND(-1.23);
+ -> -1
+ > SELECT ROUND(-1.58);
+ -> -2
+ > SELECT ROUND(1.58);
+ -> 2
+ > SELECT ROUND(1.298, 1);
+ -> 1.3
+ > SELECT ROUND(1.298, 0);
+ -> 1
+ > SELECT ROUND(23.298, -1);
+ -> 20
+ */
+ class OOp_Round : public ONthOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
+ };
+
+ /** EXP(X)
+ Returns the value of e (the base of natural logarithms) raised to the power of X:
+
+ > SELECT EXP(2);
+ -> 7.389056
+ > SELECT EXP(-2);
+ -> 0.135335
+ */
+ class OOp_Exp : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** LN(X)
+ Returns the natural logarithm of X:
+
+ > SELECT LN(2);
+ -> 0.693147
+ > SELECT LN(-2);
+ -> NULL
+
+ */
+ class OOp_Ln : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** LOG(X)
+ LOG(B,X)
+ If called with one parameter, this function returns the natural logarithm of X:
+
+ > SELECT LOG(2);
+ -> 0.693147
+ > SELECT LOG(-2);
+ -> NULL
+
+ If called with two parameters, this function returns the logarithm of X for an arbitary base B:
+
+ > SELECT LOG(2,65536);
+ -> 16.000000
+ > SELECT LOG(1,100);
+ -> NULL
+ */
+ class OOp_Log : public ONthOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
+ };
+
+ /** LOG10(X)
+ Returns the base-10 logarithm of X:
+
+ > SELECT LOG10(2);
+ -> 0.301030
+ > SELECT LOG10(100);
+ -> 2.000000
+ > SELECT LOG10(-100);
+ -> NULL
+ */
+ class OOp_Log10 : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** POWER(X,Y)
+ Returns the value of X raised to the power of Y:
+
+ > SELECT POW(2,2);
+ -> 4.000000
+ > SELECT POW(2,-2);
+ -> 0.250000
+ */
+ class OOp_Pow : public OBinaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
+ };
+
+ /** SQRT(X)
+ Returns the non-negative square root of X:
+
+ > SELECT SQRT(4);
+ -> 2.000000
+ > SELECT SQRT(20);
+ -> 4.472136
+ */
+ class OOp_Sqrt : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** PI()
+ Returns the value of PI. The default shown number of decimals is 5, but internally uses the full double precession for PI.
+
+ > SELECT PI();
+ -> 3.141593
+ > SELECT PI()+0.000000000000000000;
+ -> 3.141592653589793116
+
+ */
+ class OOp_Pi : public ONthOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
+ };
+
+ /** COS(X)
+ Returns the cosine of X, where X is given in radians:
+
+ > SELECT COS(PI());
+ -> -1.000000
+ */
+ class OOp_Cos : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
+ };
+
+ /** SIN(X)
+ Returns the sine of X, where X is given in radians:
+
+ > SELECT SIN(PI());
+ -> 0.000000
+
+ */
+ class OOp_Sin : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
+ };
+ /** TAN(X)
+ Returns the tangent of X, where X is given in radians:
+
+ > SELECT TAN(PI()+1);
+ -> 1.557408
+ */
+ class OOp_Tan : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
+ };
+
+ /** ACOS(X)
+ Returns the arc cosine of X, that is, the value whose cosine is X. Returns NULL if X is not in the range -1 to 1:
+
+ > SELECT ACOS(1);
+ -> 0.000000
+ > SELECT ACOS(1.0001);
+ -> NULL
+ > SELECT ACOS(0);
+ -> 1.570796
+ */
+ class OOp_ACos : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
+ };
+
+ /** ASIN(X)
+ Returns the arc sine of X, that is, the value whose sine is X. Returns NULL if X is not in the range -1 to 1:
+
+ > SELECT ASIN(0.2);
+ -> 0.201358
+ > SELECT ASIN('foo');
+ -> 0.000000
+ */
+ class OOp_ASin : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
+ };
+
+ /** ATAN(X)
+ Returns the arc tangent of X, that is, the value whose tangent is X:
+
+ > SELECT ATAN(2);
+ -> 1.107149
+ > SELECT ATAN(-2);
+ -> -1.107149
+ */
+ class OOp_ATan : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
+ };
+
+ /** ATAN2(Y,X)
+ Returns the arc tangent of the two variables X and Y. It is similar to calculating the arc tangent of Y / X, except that the signs of both arguments are used to determine the quadrant of the result:
+
+ > SELECT ATAN2(-2,2);
+ -> -0.785398
+ > SELECT ATAN2(PI(),0);
+ -> 1.570796
+
+ */
+ class OOp_ATan2 : public OBinaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
+ };
+
+ /** DEGREES(X)
+ Returns the argument X, converted from radians to degrees:
+
+ > SELECT DEGREES(PI());
+ -> 180.000000
+ */
+ class OOp_Degrees : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
+ };
+
+ /** RADIANS(X)
+ Returns the argument X, converted from degrees to radians:
+
+ > SELECT RADIANS(90);
+ -> 1.570796
+
+ */
+ class OOp_Radians : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs = ORowSetValue()) const;
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_FILE_FNUMERICFUNCTIONS_HXX_
+
diff --git a/connectivity/source/inc/file/FPreparedStatement.hxx b/connectivity/source/inc/file/FPreparedStatement.hxx
new file mode 100644
index 000000000000..9528ca16a508
--- /dev/null
+++ b/connectivity/source/inc/file/FPreparedStatement.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_FILE_OPREPAREDSTATEMENT_HXX_
+#define _CONNECTIVITY_FILE_OPREPAREDSTATEMENT_HXX_
+
+#include "file/filedllapi.hxx"
+#include "file/FStatement.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/XClearParameters.hpp>
+#include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include "file/FResultSet.hxx"
+
+namespace connectivity
+{
+ namespace file
+ {
+
+ class OOO_DLLPUBLIC_FILE SAL_NO_VTABLE OPreparedStatement : public OStatement_BASE2,
+ public ::com::sun::star::sdbc::XPreparedStatement,
+ public ::com::sun::star::sdbc::XParameters,
+ public ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ public ::com::sun::star::lang::XServiceInfo
+
+ {
+ protected:
+ //====================================================================
+ // Data attributes
+ //====================================================================
+ ::rtl::OUString m_aSql;
+ OValueRefRow m_aParameterRow;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData;
+
+ OResultSet* m_pResultSet;
+ ::vos::ORef<connectivity::OSQLColumns> m_xParamColumns; // the parameter columns
+
+ // factory method for resultset's
+ virtual OResultSet* createResultSet();
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> initResultSet();
+
+ void checkAndResizeParameters(sal_Int32 parameterIndex);
+ void setParameter(sal_Int32 parameterIndex, const ORowSetValue& x);
+
+ 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();
+
+ virtual void parseParamterElem(const String& _sColumnName,OSQLParseNode* pRow_Value_Constructor_Elem);
+ virtual void initializeResultSet(OResultSet* _pResult);
+
+ virtual ~OPreparedStatement();
+ public:
+ DECLARE_SERVICE_INFO();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ OPreparedStatement( OConnection* _pConnection);
+
+ virtual void construct(const ::rtl::OUString& sql) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // 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);
+
+ // 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_FILE_OPREPAREDSTATEMENT_HXX_
+
+
diff --git a/connectivity/source/inc/file/FResultSet.hxx b/connectivity/source/inc/file/FResultSet.hxx
new file mode 100644
index 000000000000..530387ceef4a
--- /dev/null
+++ b/connectivity/source/inc/file/FResultSet.hxx
@@ -0,0 +1,357 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_FILE_FRESULTSET_HXX_
+#define _CONNECTIVITY_FILE_FRESULTSET_HXX_
+
+#ifndef _COM_SUN_STAR_SQLC_XRESULTSET_HPP_
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SQLC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SQLC_XRESULTSETMETADATASUPPLIER_HPP_
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SQLC_XCLOSEABLE_HPP_
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SQLC_XCOLUMNLOCATE_HPP_
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#endif
+#include <com/sun/star/util/XCancellable.hpp>
+#ifndef _COM_SUN_STAR_SQLC_XWARNINGSSUPPLIER_HPP_
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SQLC_XRESULTSETUPDATE_HPP_
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SQLC_XROWUPDATE_HPP_
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#endif
+#include <cppuhelper/compbase12.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include "file/FStatement.hxx"
+#include "connectivity/CommonTools.hxx"
+#include <comphelper/propertycontainer.hxx>
+#include "file/fanalyzer.hxx"
+#include "file/FTable.hxx"
+#include "file/filedllapi.hxx"
+#include <comphelper/broadcasthelper.hxx>
+#include "connectivity/StdTypeDefs.hxx"
+#include "TSortIndex.hxx"
+#include "TSkipDeletedSet.hxx"
+#include <com/sun/star/lang/XEventListener.hpp>
+
+namespace connectivity
+{
+ namespace file
+ {
+ /*
+ ** 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::XResultSetUpdate,
+ ::com::sun::star::sdbc::XRowUpdate,
+ ::com::sun::star::sdbc::XCloseable,
+ ::com::sun::star::sdbc::XColumnLocate,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::lang::XEventListener,
+ ::com::sun::star::lang::XUnoTunnel> OResultSet_BASE;
+
+ class OOO_DLLPUBLIC_FILE OResultSet :
+ public comphelper::OBaseMutex,
+ public ::connectivity::IResultSetHelper,
+ public OResultSet_BASE,
+ public ::comphelper::OPropertyContainer,
+ public ::comphelper::OPropertyArrayUsageHelper<OResultSet>
+ {
+
+ protected:
+ ::std::vector<void*> m_aBindVector;
+ ::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;
+
+ OValueRefRow m_aSelectRow;
+ OValueRefRow m_aRow;
+ OValueRefRow m_aEvaluateRow; // contains all values of a row
+ OValueRefRow m_aParameterRow;
+ OValueRefRow m_aInsertRow; // needed for insert by cursor
+ ORefAssignValues m_aAssignValues; // needed for insert,update and parameters
+ // to compare with the restrictions
+ TIntVector* m_pEvaluationKeySet;
+ TIntVector::iterator m_aEvaluateIter;
+
+
+// TInt2IntMap m_aBookmarks; // map from bookmarks to logical position
+// ::std::vector<TInt2IntMap::iterator> m_aBookmarksPositions;// vector of iterators to bookmark map, the order is the logical position
+ OSkipDeletedSet m_aSkipDeletedSet;
+
+ ::vos::ORef<OKeySet> m_pFileSet;
+ OKeySet::Vector::iterator m_aFileSetIter;
+
+
+
+ OSortIndex* m_pSortIndex;
+ ::vos::ORef<connectivity::OSQLColumns> m_xColumns; // this are the select columns
+ ::vos::ORef<connectivity::OSQLColumns> m_xParamColumns;
+ OFileTable* m_pTable;
+ connectivity::OSQLParseNode* m_pParseTree;
+
+ OSQLAnalyzer* m_pSQLAnalyzer;
+ connectivity::OSQLParseTreeIterator& m_aSQLIterator;
+
+ sal_Int32 m_nFetchSize;
+ sal_Int32 m_nResultSetType;
+ sal_Int32 m_nFetchDirection;
+ sal_Int32 m_nResultSetConcurrency;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData;
+ ::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
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xColsIdx; // table columns
+
+
+ ::rtl::OUString m_aTableRange;
+ rtl_TextEncoding m_nTextEncoding;
+ sal_Int32 m_nRowPos;
+ sal_Int32 m_nFilePos;
+ sal_Int32 m_nLastVisitedPos;
+ sal_Int32 m_nRowCountResult;
+ sal_Int32 m_nCurrentPosition; // current position of the resultset is returned when ask for getRow()
+ sal_Int32 m_nColumnCount;
+ sal_Bool m_bWasNull;
+ sal_Bool m_bEOF; // after last record
+ sal_Bool m_bLastRecord;
+ sal_Bool m_bInserted; // true when moveToInsertRow was called
+ // set to false when cursor moved or cancel
+ sal_Bool m_bRowUpdated;
+ sal_Bool m_bRowInserted;
+ sal_Bool m_bRowDeleted;
+ sal_Bool m_bShowDeleted;
+ sal_Bool m_bIsCount;
+
+ void initializeRow(OValueRefRow& _rRow,sal_Int32 _nColumnCount);
+ void construct();
+ sal_Bool evaluate();
+
+ BOOL ExecuteRow(IResultSetHelper::Movement eFirstCursorPosition,
+ INT32 nOffset = 1,
+ BOOL bEvaluate = TRUE,
+ BOOL bRetrieveData = TRUE);
+
+ OKeyValue* GetOrderbyKeyValue(OValueRefRow& _rRow);
+ BOOL IsSorted() const { return !m_aOrderbyColumnNumber.empty() && m_aOrderbyColumnNumber[0] != SQL_COLUMN_NOTFOUND;}
+
+ // return true when the select statement is "select count(*) from table"
+ inline sal_Bool isCount() const { return m_bIsCount; }
+ void checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException);
+
+ const ORowSetValue& getValue(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException);
+ void updateValue(sal_Int32 columnIndex,const ORowSetValue& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // clear insert row
+ void clearInsertRow();
+ void sortRows();
+ protected:
+
+ using OResultSet_BASE::rBHelper;
+
+ BOOL Move(IResultSetHelper::Movement eCursorPosition, INT32 nOffset, BOOL bRetrieveData);
+ virtual sal_Bool fillIndexValues(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier> &_xIndex);
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ virtual ~OResultSet();
+ public:
+ DECLARE_SERVICE_INFO();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ OResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator);
+
+ ::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);
+ // 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);
+ // 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();
+ //XEventlistener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ // special methods
+ inline sal_Int32 mapColumn(sal_Int32 column);
+ virtual BOOL OpenImpl();
+ virtual void doTableSpecials(const OSQLTable& _xTable);
+
+ inline sal_Int32 getRowCountResult() const { return m_nRowCountResult; }
+ inline void setParameterRow(const OValueRefRow& _rParaRow) { m_aParameterRow = _rParaRow; }
+ inline void setEvaluationRow(const OValueRefRow& _aRow) { m_aEvaluateRow = _aRow; }
+ inline void setParameterColumns(const ::vos::ORef<connectivity::OSQLColumns>& _xParamColumns) { m_xParamColumns = _xParamColumns; }
+ inline void setAssignValues(const ORefAssignValues& _aAssignValues) { m_aAssignValues = _aAssignValues; }
+ inline void setBindingRow(const OValueRefRow& _aRow) { m_aRow = _aRow; }
+ inline void setSelectRow(const OValueRefRow& _rRow)
+ {
+ m_aSelectRow = _rRow;
+ m_nColumnCount = m_aSelectRow->get().size();
+ }
+ inline void setColumnMapping(const ::std::vector<sal_Int32>& _aColumnMapping) { m_aColMapping = _aColumnMapping; }
+ inline void setSqlAnalyzer(OSQLAnalyzer* _pSQLAnalyzer) { m_pSQLAnalyzer = _pSQLAnalyzer; }
+
+ inline void setOrderByColumns(const ::std::vector<sal_Int32>& _aColumnOrderBy) { m_aOrderbyColumnNumber = _aColumnOrderBy; }
+ inline void setOrderByAscending(const ::std::vector<TAscendingOrder>& _aOrderbyAsc) { m_aOrderbyAscending = _aOrderbyAsc; }
+ inline void setEvaluationKeySet(TIntVector* _pEvaluationKeySet) { m_pEvaluationKeySet = _pEvaluationKeySet; }
+ inline void setMetaData(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData>& _xMetaData) { m_xMetaData = _xMetaData;}
+
+ // clears the resultset so it can be reused by a preparedstatement
+ void clear();
+ static void setBoundedColumns(const OValueRefRow& _rRow,
+ const OValueRefRow& _rSelectRow,
+ 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);
+
+ // IResultSetHelper
+ virtual sal_Bool move(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool _bRetrieveData);
+ virtual sal_Int32 getDriverPos() const;
+ virtual sal_Bool deletedVisible() const;
+ virtual sal_Bool isRowDeleted() const;
+ };
+ // -------------------------------------------------------------------------
+ inline sal_Int32 OResultSet::mapColumn(sal_Int32 column)
+ {
+ sal_Int32 map = column;
+
+ OSL_ENSURE(column > 0, "file::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;
+ }
+ }
+}
+#endif // _CONNECTIVITY_FILE_ORESULTSET_HXX_
+
+
diff --git a/connectivity/source/inc/file/FResultSetMetaData.hxx b/connectivity/source/inc/file/FResultSetMetaData.hxx
new file mode 100644
index 000000000000..60bd3b179709
--- /dev/null
+++ b/connectivity/source/inc/file/FResultSetMetaData.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_FILE_ORESULTSETMETADATA_HXX_
+#define _CONNECTIVITY_FILE_ORESULTSETMETADATA_HXX_
+
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include "connectivity/CommonTools.hxx"
+#include <vos/ref.hxx>
+#include "file/filedllapi.hxx"
+
+namespace connectivity
+{
+ namespace file
+ {
+ class OFileTable;
+ //**************************************************************
+ //************ Class: ResultSetMetaData
+ //**************************************************************
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> OResultSetMetaData_BASE;
+
+ class OOO_DLLPUBLIC_FILE OResultSetMetaData :
+ public OResultSetMetaData_BASE
+ {
+ ::rtl::OUString m_aTableName;
+ ::vos::ORef<connectivity::OSQLColumns> m_xColumns;
+ OFileTable* m_pTable;
+
+ void checkColumnIndex(sal_Int32 column) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ protected:
+ virtual ~OResultSetMetaData();
+ public:
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ OResultSetMetaData(const ::vos::ORef<connectivity::OSQLColumns>& _rxColumns,const ::rtl::OUString& _aTableName,OFileTable* _pTable);
+
+ /// 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_FILE_ORESULTSETMETADATA_HXX_
+
+
diff --git a/connectivity/source/inc/file/FStatement.hxx b/connectivity/source/inc/file/FStatement.hxx
new file mode 100644
index 000000000000..0983811b9bd2
--- /dev/null
+++ b/connectivity/source/inc/file/FStatement.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_FILE_OSTATEMENT_HXX_
+#define _CONNECTIVITY_FILE_OSTATEMENT_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/XBatchExecution.hpp>
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
+#include <comphelper/proparrhlp.hxx>
+#include <cppuhelper/compbase3.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <comphelper/uno3.hxx>
+#include "connectivity/CommonTools.hxx"
+#include "file/FConnection.hxx"
+#include "file/filedllapi.hxx"
+#ifndef _LIST_
+#include <list>
+#endif
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <comphelper/propertycontainer.hxx>
+#include "file/fanalyzer.hxx"
+#include <comphelper/broadcasthelper.hxx>
+#include "TSortIndex.hxx"
+
+#define SQL_COLUMN_NOTFOUND STRING_NOTFOUND
+
+namespace connectivity
+{
+ namespace file
+ {
+ class OResultSet;
+ class OFileTable;
+ typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::util::XCancellable,
+ ::com::sun::star::sdbc::XCloseable> OStatement_BASE;
+
+ //**************************************************************
+ //************ Class: java.sql.Statement
+ //**************************************************************
+ class OOO_DLLPUBLIC_FILE OStatement_Base :
+ public comphelper::OBaseMutex,
+ public OStatement_BASE,
+ public ::comphelper::OPropertyContainer,
+ public ::comphelper::OPropertyArrayUsageHelper<OStatement_Base>
+
+ {
+ protected:
+ ::std::vector<sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 everytime
+ ::std::vector<sal_Int32> m_aParameterIndexes; // maps the parameter index to column index
+ ::std::vector<sal_Int32> m_aOrderbyColumnNumber;
+ ::std::vector<TAscendingOrder> m_aOrderbyAscending;
+
+ ::com::sun::star::sdbc::SQLWarning m_aLastWarning;
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created
+ ::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
+
+
+ connectivity::OSQLParser m_aParser;
+ connectivity::OSQLParseTreeIterator m_aSQLIterator;
+
+ OConnection* m_pConnection;// The owning Connection object
+ connectivity::OSQLParseNode* m_pParseTree;
+ OSQLAnalyzer* m_pSQLAnalyzer; //the sql analyzer used by the resultset
+
+ ::std::vector<sal_Int32>* m_pEvaluationKeySet;
+
+ OFileTable* m_pTable; // the current table
+ OValueRefRow m_aSelectRow;
+ OValueRefRow m_aRow;
+ OValueRefRow m_aEvaluateRow; // contains all values of a row
+ ORefAssignValues m_aAssignValues; // needed for insert,update and parameters
+ // to compare with the restrictions
+
+ ::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;
+
+ ::cppu::OBroadcastHelper& rBHelper;
+
+ protected:
+ // initialize the column index map (mapping select columns to table columns)
+ void createColumnMapping();
+ // searches the statement for sort criteria
+ void anylizeSQL();
+ void setOrderbyColumn( connectivity::OSQLParseNode* pColumnRef,
+ connectivity::OSQLParseNode* pAscendingDescending);
+
+ virtual void initializeResultSet(OResultSet* _pResult);
+ // create the analyzer
+ virtual OSQLAnalyzer* createAnalyzer();
+
+ void reset () throw( ::com::sun::star::sdbc::SQLException);
+ void clearMyResultSet () throw( ::com::sun::star::sdbc::SQLException);
+ void setWarning (const ::com::sun::star::sdbc::SQLWarning &ex) throw( ::com::sun::star::sdbc::SQLException);
+ sal_Int32 getPrecision ( sal_Int32 sqlType);
+
+ void disposeResultSet();
+ void GetAssignValues();
+ void SetAssignValue(const String& aColumnName,
+ const String& aValue,
+ BOOL bSetNull = FALSE,
+ UINT32 nParameter=SQL_NO_PARAMETER);
+ void ParseAssignValues( const ::std::vector< String>& aColumnNameList,
+ connectivity::OSQLParseNode* pRow_Value_Constructor_Elem,xub_StrLen nIndex);
+
+ virtual void parseParamterElem(const String& _sColumnName,OSQLParseNode* pRow_Value_Constructor_Elem);
+ // factory method for resultset's
+ virtual OResultSet* createResultSet() = 0;
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ virtual ~OStatement_Base();
+ public:
+ connectivity::OSQLParseNode* getParseTree() const { return m_pParseTree;}
+
+ OStatement_Base(OConnection* _pConnection );
+
+ OConnection* getOwnConnection() const { return m_pConnection;}
+
+ using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
+
+ virtual void construct(const ::rtl::OUString& sql) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XInterface
+ // virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException) = 0;
+ 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);
+ // 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);
+ };
+
+ class OOO_DLLPUBLIC_FILE OStatement_BASE2 :
+ public OStatement_Base,
+ public connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>
+
+ {
+ friend class connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>;
+ public:
+ OStatement_BASE2(OConnection* _pConnection ) : OStatement_Base(_pConnection ),
+ connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this){}
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XInterface
+ virtual void SAL_CALL release() throw();
+ };
+
+ typedef ::cppu::ImplHelper2< ::com::sun::star::sdbc::XStatement,::com::sun::star::lang::XServiceInfo > OStatement_XStatement;
+ class OOO_DLLPUBLIC_FILE OStatement :
+ public OStatement_BASE2,
+ public OStatement_XStatement
+ {
+ protected:
+ // factory method for resultset's
+ virtual OResultSet* createResultSet();
+ public:
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ OStatement( OConnection* _pConnection) : OStatement_BASE2( _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();
+
+ // 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_FILE_OSTATEMENT_HXX_
+
diff --git a/connectivity/source/inc/file/FStringFunctions.hxx b/connectivity/source/inc/file/FStringFunctions.hxx
new file mode 100644
index 000000000000..d90f53b38cf3
--- /dev/null
+++ b/connectivity/source/inc/file/FStringFunctions.hxx
@@ -0,0 +1,283 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_FILE_FSTRINGFUNCTIONS_HXX_
+#define _CONNECTIVITY_FILE_FSTRINGFUNCTIONS_HXX_
+
+#include "file/fcode.hxx"
+#include "file/filedllapi.hxx"
+
+namespace connectivity
+{
+ class OSQLParseNode;
+ namespace file
+ {
+ /** UCASE(str)
+ UPPER(str)
+ Returns the string str with all characters changed to uppercase according to the current character set mapping (the default is ISO-8859-1 Latin1):
+
+ > SELECT UCASE('Hej');
+ -> 'HEJ'
+
+ */
+ class OOp_Upper : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** LCASE(str)
+ LOWER(str)
+ Returns the string str with all characters changed to lowercase according to the current character set mapping (the default is ISO-8859-1 Latin1):
+
+ > SELECT LCASE('QUADRATICALLY');
+ -> 'quadratically'
+
+ */
+ class OOp_Lower : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** ASCII(str)
+ Returns the ASCII code value of the leftmost character of the string str. Returns 0 if str is the empty string. Returns NULL if str is NULL:
+
+ > SELECT ASCII('2');
+ -> 50
+ > SELECT ASCII(2);
+ -> 50
+ > SELECT ASCII('dx');
+ -> 100
+
+ */
+ class OOp_Ascii : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** LENGTH(str)
+ OCTET_LENGTH(str)
+ CHAR_LENGTH(str)
+ CHARACTER_LENGTH(str)
+ Returns the length of the string str:
+
+ > SELECT LENGTH('text');
+ -> 4
+ > SELECT OCTET_LENGTH('text');
+ -> 4
+
+ */
+ class OOp_CharLength : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** CHAR(N,...)
+ CHAR() interprets the arguments as integers and returns a string consisting of the characters given by the ASCII code values of those integers. NULL values are skipped:
+
+ > SELECT CHAR(ascii('t'),ascii('e'),ascii('s'),ascii('t'));
+ -> 'test'
+ > SELECT CHAR(77,77.3,'77.3');
+ -> 'MMM'
+
+ */
+ class OOp_Char : public ONthOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
+ };
+
+ /** CONCAT(str1,str2,...)
+ Returns the string that results from concatenating the arguments. Returns NULL if any argument is NULL. May have more than 2 arguments. A numeric argument is converted to the equivalent string form:
+
+ > SELECT CONCAT('OO', 'o', 'OO');
+ -> 'OOoOO'
+ > SELECT CONCAT('OO', NULL, 'OO');
+ -> NULL
+ > SELECT CONCAT(14.3);
+ -> '14.3'
+
+ */
+ class OOp_Concat : public ONthOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
+ };
+
+ /** LOCATE(substr,str)
+ POSITION(substr IN str)
+ Returns the position of the first occurrence of substring substr in string str. Returns 0 if substr is not in str:
+
+ > SELECT LOCATE('bar', 'foobarbar');
+ -> 4
+ > SELECT LOCATE('xbar', 'foobar');
+ -> 0
+ LOCATE(substr,str,pos)
+ Returns the position of the first occurrence of substring substr in string str, starting at position pos. Returns 0 if substr is not in str:
+
+ > SELECT LOCATE('bar', 'foobarbar',5);
+ -> 7
+
+ */
+ class OOp_Locate : public ONthOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
+ };
+
+ /** SUBSTRING(str,pos)
+ SUBSTRING(str FROM pos)
+ Returns a substring from string str starting at position pos:
+
+ > SELECT SUBSTRING('Quadratically',5);
+ -> 'ratically'
+ > SELECT SUBSTRING('foobarbar' FROM 4);
+ -> 'barbar'
+ SUBSTRING(str,pos,len)
+ SUBSTRING(str FROM pos FOR len)
+ Returns a substring len characters long from string str, starting at position pos. The variant form that uses FROM is SQL-92 syntax:
+
+ > SELECT SUBSTRING('Quadratically',5,6);
+ -> 'ratica'
+
+ */
+ class OOp_SubString : public ONthOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
+ };
+
+ /** LTRIM(str)
+ Returns the string str with leading space characters removed:
+
+ > SELECT LTRIM(' barbar');
+ -> 'barbar'
+
+ */
+ class OOp_LTrim : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** RTRIM(str)
+ Returns the string str with trailing space characters removed:
+
+ > SELECT RTRIM('barbar ');
+ -> 'barbar'
+
+ */
+ class OOp_RTrim : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** SPACE(N)
+ Returns a string consisting of N space characters:
+
+ > SELECT SPACE(6);
+ -> ' '
+
+ */
+ class OOp_Space : public OUnaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const;
+ };
+
+ /** REPLACE(str,from_str,to_str)
+ Returns the string str with all occurrences of the string from_str replaced by the string to_str:
+
+ > SELECT REPLACE('www.OOo.com', 'w', 'Ww');
+ -> 'WwWwWw.OOo.com'
+
+ */
+ class OOp_Replace : public ONthOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
+ };
+
+ /** REPEAT(str,count)
+ Returns a string consisting of the string str repeated count times. If count <= 0, returns an empty string. Returns NULL if str or count are NULL:
+
+ > SELECT REPEAT('OOo', 3);
+ -> 'OOoOOoOOo'
+
+ */
+ class OOp_Repeat : public OBinaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
+ };
+
+ /** INSERT(str,pos,len,newstr)
+ Returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr:
+
+ > SELECT INSERT('Quadratic', 3, 4, 'What');
+ -> 'QuWhattic'
+
+ */
+ class OOp_Insert : public ONthOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
+ };
+
+ /** LEFT(str,len)
+ Returns the leftmost len characters from the string str:
+
+ > SELECT LEFT('foobarbar', 5);
+ -> 'fooba'
+
+ */
+ class OOp_Left : public OBinaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
+ };
+
+ /** RIGHT(str,len)
+ Returns the rightmost len characters from the string str:
+
+ > SELECT RIGHT('foobarbar', 4);
+ -> 'rbar'
+ */
+ class OOp_Right : public OBinaryOperator
+ {
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const;
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_FILE_FCODE_HXX_
+
diff --git a/connectivity/source/inc/file/FTable.hxx b/connectivity/source/inc/file/FTable.hxx
new file mode 100644
index 000000000000..bc4cd450f931
--- /dev/null
+++ b/connectivity/source/inc/file/FTable.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_FILE_TABLE_HXX_
+#define _CONNECTIVITY_FILE_TABLE_HXX_
+
+#include "connectivity/sdbcx/VTable.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#ifndef _CONNECTIVITY_FILE_BCONNECTION_HXX_
+#include "file/FConnection.hxx"
+#endif
+#include "file/filedllapi.hxx"
+#include <tools/stream.hxx>
+#include "connectivity/FValue.hxx"
+#include "TResultSetHelper.hxx"
+
+namespace connectivity
+{
+ namespace file
+ {
+ typedef connectivity::sdbcx::OTable OTable_TYPEDEF;
+
+ class OOO_DLLPUBLIC_FILE OFileTable : public OTable_TYPEDEF
+ {
+ protected:
+ OConnection* m_pConnection;
+ SvStream* m_pFileStream;
+ ::vos::ORef<OSQLColumns> m_aColumns;
+ sal_Int32 m_nFilePos; // aktuelle IResultSetHelper::Movement
+ sal_uInt8* m_pBuffer;
+ sal_uInt16 m_nBufferSize; // Groesse des ReadBuffer, wenn pBuffer != NULL
+ sal_Bool m_bWriteable; // svstream cann't say if we are writeable
+ // so we have to
+
+ virtual void FileClose();
+ virtual ~OFileTable( );
+ public:
+ virtual void refreshColumns();
+ virtual void refreshKeys();
+ virtual void refreshIndexes();
+ public:
+ OFileTable( sdbcx::OCollection* _pTables,OConnection* _pConnection);
+ OFileTable( sdbcx::OCollection* _pTables,OConnection* _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()
+ );
+
+ //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();
+ // ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ OConnection* getConnection() const { return m_pConnection;}
+ virtual sal_Int32 getCurrentLastPos() const {return -1;}
+
+ virtual sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) = 0;
+ virtual sal_Bool fetchRow(OValueRefRow& _rRow,const OSQLColumns& _rCols, sal_Bool _bUseTableDefs,sal_Bool bRetrieveData) = 0;
+
+ ::vos::ORef<OSQLColumns> getTableColumns() const {return m_aColumns;}
+ virtual BOOL InsertRow(OValueRefVector& rRow, BOOL bFlush,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols);
+ virtual BOOL DeleteRow(const OSQLColumns& _rCols);
+ virtual BOOL UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols);
+ virtual void addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& descriptor);
+ virtual void dropColumn(sal_Int32 _nPos);
+ // refresh the header of file based tables to see changes done by someone
+ virtual void refreshHeader();
+
+ ::rtl::OUString SAL_CALL getName() throw() { return m_Name; }
+
+ ::rtl::OUString getSchema() { return m_SchemaName; }
+ sal_Bool isReadOnly() const { return !m_bWriteable; }
+ // m_pFileStream && !m_pFileStream->IsWritable(); }
+ // 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();
+
+
+ sal_Int32 getFilePos() const { return m_nFilePos; }
+
+ public:
+ // helper
+
+ // creates a stream using ::utl::UcbStreamHelper::CreateStream, but the error is simplified
+ // (NULL or non-NULL is returned)
+ static SvStream* createStream_simpleError( const String& _rFileName, StreamMode _eOpenMode);
+ };
+ }
+}
+#endif // _CONNECTIVITY_FILE_TABLE_HXX_
+
diff --git a/connectivity/source/inc/file/FTables.hxx b/connectivity/source/inc/file/FTables.hxx
new file mode 100644
index 000000000000..4a15985c248b
--- /dev/null
+++ b/connectivity/source/inc/file/FTables.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_FILE_TABLES_HXX_
+#define _CONNECTIVITY_FILE_TABLES_HXX_
+
+#include "file/filedllapi.hxx"
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+
+namespace connectivity
+{
+ namespace file
+ {
+ class OOO_DLLPUBLIC_FILE SAL_NO_VTABLE OTables :
+ public sdbcx::OCollection
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+
+ 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,_rMetaData->storesMixedCaseQuotedIdentifiers(),_rMutex,_rVector)
+ ,m_xMetaData(_rMetaData)
+ {}
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+
+ // only the name is identical to ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ };
+ }
+}
+#endif // _CONNECTIVITY_FILE_TABLES_HXX_
+
diff --git a/connectivity/source/inc/file/fanalyzer.hxx b/connectivity/source/inc/file/fanalyzer.hxx
new file mode 100644
index 000000000000..c882b760765a
--- /dev/null
+++ b/connectivity/source/inc/file/fanalyzer.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_FILE_FANALYZER_HXX_
+#define _CONNECTIVITY_FILE_FANALYZER_HXX_
+
+#include "file/fcomp.hxx"
+#include "file/filedllapi.hxx"
+
+namespace connectivity
+{
+ namespace file
+ {
+ class OConnection;
+ class OOO_DLLPUBLIC_FILE OSQLAnalyzer
+ {
+ typedef ::std::list<OEvaluateSet*> OEvaluateSetList;
+ typedef ::std::pair< ::vos::ORef<OPredicateCompiler>,::vos::ORef<OPredicateInterpreter> > TPredicates;
+
+ ::std::vector< TPredicates > m_aSelectionEvaluations;
+ ::vos::ORef<OPredicateCompiler> m_aCompiler;
+ ::vos::ORef<OPredicateInterpreter> m_aInterpreter;
+ OConnection* m_pConnection;
+
+ mutable sal_Bool m_bHasSelectionCode;
+ mutable sal_Bool m_bSelectionFirstTime;
+
+ void bindRow(OCodeList& rCodeList,const OValueRefRow& _pRow,OEvaluateSetList& _rEvaluateSetList);
+
+ public:
+ OSQLAnalyzer(OConnection* _pConnection);
+ virtual ~OSQLAnalyzer();
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void * SAL_CALL operator new( size_t /*nSize*/,void* _pHint ) SAL_THROW( () )
+ { return _pHint; }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ inline static void SAL_CALL operator delete( void * /*pMem*/,void* /*_pHint*/ ) SAL_THROW( () )
+ { }
+
+ OConnection* getConnection() const { return m_pConnection; }
+ void describeParam(::vos::ORef<OSQLColumns> rParameterColumns); // genauere Beschreibung der Parameter
+ ::std::vector<sal_Int32>* bindEvaluationRow(OValueRefRow& _pRow); // Anbinden einer Ergebniszeile an die Restrictions
+ /** bind the select columns if they contain a function which needs a row value
+ @param _pRow the result row
+ */
+ void bindSelectRow(const OValueRefRow& _pRow);
+
+ /** binds the row to parameter for the restrictions
+ @param _pRow the parameter row
+ */
+ void bindParameterRow(OValueRefRow& _pRow);
+
+ void setIndexes(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xIndexes);
+
+ void dispose();
+ void start(OSQLParseNode* pSQLParseNode);
+ void clean();
+ virtual BOOL hasRestriction() const;
+ virtual BOOL hasFunctions() const;
+ inline BOOL evaluateRestriction() { return m_aInterpreter->start(); }
+ void setSelectionEvaluationResult(OValueRefRow& _pRow,const ::std::vector<sal_Int32>& _rColumnMapping);
+ void setOrigColumns(const OFileColumns& rCols);
+ virtual OOperandAttr* createOperandAttr(sal_Int32 _nPos,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xCol,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xIndexes=NULL);
+ };
+ }
+}
+#endif // _CONNECTIVITY_FILE_FANALYZER_HXX_
+
diff --git a/connectivity/source/inc/file/fcode.hxx b/connectivity/source/inc/file/fcode.hxx
new file mode 100644
index 000000000000..7a2125206549
--- /dev/null
+++ b/connectivity/source/inc/file/fcode.hxx
@@ -0,0 +1,396 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_FILE_FCODE_HXX_
+#define _CONNECTIVITY_FILE_FCODE_HXX_
+
+#include "connectivity/sqliterator.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include "connectivity/CommonTools.hxx"
+#include <tools/rtti.hxx>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include "connectivity/FValue.hxx"
+#include "file/filedllapi.hxx"
+
+namespace connectivity
+{
+ class OSQLParseNode;
+ namespace dbase
+ {
+ class ODbaseIndex;
+ }
+ namespace file
+ {
+
+ class OOperand;
+ typedef ::std::stack<OOperand*> OCodeStack;
+ class OBoolOperator;
+ typedef ::std::map<sal_Int32,sal_Int32> OEvaluateSet;
+
+ typedef ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> OFileColumns;
+
+
+ class OOO_DLLPUBLIC_FILE OCode
+ {
+ public:
+ OCode();
+ virtual ~OCode();
+
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void * SAL_CALL operator new( size_t /*nSize*/,void* _pHint ) SAL_THROW( () )
+ { return _pHint; }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ inline static void SAL_CALL operator delete( void * /*pMem*/,void* /*_pHint*/ ) SAL_THROW( () )
+ { }
+
+ TYPEINFO();
+ };
+
+
+ // operands that the parsetree generate
+ class OOO_DLLPUBLIC_FILE OOperand : public OCode
+ {
+ protected:
+ sal_Int32 m_eDBType;
+
+ OOperand(const sal_Int32& _rType) : m_eDBType(_rType){}
+ OOperand() : m_eDBType(::com::sun::star::sdbc::DataType::OTHER){}
+
+ public:
+ virtual const ORowSetValue& getValue() const = 0;
+ virtual void setValue(const ORowSetValue& _rVal) = 0;
+
+ virtual sal_Int32 getDBType() const {return m_eDBType;}
+ virtual OEvaluateSet* preProcess(OBoolOperator* pOp, OOperand* pRight = 0);
+ inline sal_Bool isValid() const;
+
+ TYPEINFO();
+ };
+
+ class OOO_DLLPUBLIC_FILE OOperandRow : public OOperand
+ {
+ sal_uInt16 m_nRowPos;
+ protected:
+ OValueRefRow m_pRow;
+
+ OOperandRow(sal_uInt16 _nPos, sal_Int32 _rType);
+ public:
+ sal_uInt16 getRowPos() const {return m_nRowPos;}
+ virtual const ORowSetValue& getValue() const;
+ virtual void setValue(const ORowSetValue& _rVal);
+ void bindValue(const OValueRefRow& _pRow); // Bindung an den Wert, den der Operand repraesentiert
+
+ TYPEINFO();
+ };
+
+ // Attribute aus einer Ergebniszeile
+ class OOO_DLLPUBLIC_FILE OOperandAttr : public OOperandRow
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xColumn;
+
+ public:
+ OOperandAttr(sal_uInt16 _nPos,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn);
+
+ virtual sal_Bool isIndexed() const;
+ virtual OEvaluateSet* preProcess(OBoolOperator* pOp, OOperand* pRight = 0);
+ TYPEINFO();
+ };
+
+ // Parameter fuer ein Praedikat
+ class OOperandParam : public OOperandRow
+ {
+ public:
+ OOperandParam(connectivity::OSQLParseNode* pNode, sal_Int32 _nPos);
+ void describe(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn, ::vos::ORef<connectivity::OSQLColumns> _xParamColumns);
+
+ TYPEINFO();
+ };
+
+ // WerteOperanden
+ class OOperandValue : public OOperand
+ {
+ protected:
+ ORowSetValue m_aValue;
+
+ protected:
+ OOperandValue(){}
+ OOperandValue(const ORowSetValue& _rVar, sal_Int32 eDbType)
+ : OOperand(eDbType)
+ , m_aValue(_rVar)
+ {}
+
+ OOperandValue(sal_Int32 eDbType) :OOperand(eDbType){}
+ public:
+ virtual const ORowSetValue& getValue() const;
+ virtual void setValue(const ORowSetValue& _rVal);
+
+ TYPEINFO();
+ };
+
+
+ // Konstanten
+ class OOperandConst : public OOperandValue
+ {
+ public:
+ OOperandConst(const connectivity::OSQLParseNode& rColumnRef, const rtl::OUString& aStrValue);
+
+ TYPEINFO();
+ };
+
+
+ // Ergebnis Operanden
+ class OOperandResult : public OOperandValue
+ {
+ protected:
+ OOperandResult(const ORowSetValue& _rVar, sal_Int32 eDbType)
+ :OOperandValue(_rVar, eDbType) {}
+ OOperandResult(sal_Int32 eDbType)
+ :OOperandValue(eDbType) {}
+ public:
+ OOperandResult(const ORowSetValue& _rVar)
+ :OOperandValue(_rVar, _rVar.getTypeKind()) {}
+ TYPEINFO();
+ };
+
+
+ class OOperandResultBOOL : public OOperandResult
+ {
+ public:
+ OOperandResultBOOL(sal_Bool bResult) : OOperandResult(::com::sun::star::sdbc::DataType::BIT)
+ {
+ m_aValue = bResult ? 1.0 : 0.0;
+ m_aValue.setBound(sal_True);
+ }
+ };
+
+ class OOperandResultNUM : public OOperandResult
+ {
+ public:
+ OOperandResultNUM(double fNum) : OOperandResult(::com::sun::star::sdbc::DataType::DOUBLE)
+ {
+ m_aValue = fNum;
+ m_aValue.setBound(sal_True);
+ }
+ };
+
+ /** special stop operand
+ is appended when a list of arguments ends
+ */
+ class OStopOperand : public OOperandValue
+ {
+ public:
+ OStopOperand(){}
+ TYPEINFO();
+ };
+
+ // Operatoren
+ class OOO_DLLPUBLIC_FILE OOperator : public OCode
+ {
+ public:
+ virtual void Exec(OCodeStack&) = 0;
+ virtual sal_uInt16 getRequestedOperands() const; // Anzahl benoetigter Operanden
+ // Standard ist 2
+ TYPEINFO();
+ };
+
+
+ // boolsche Operatoren
+
+ class OOO_DLLPUBLIC_FILE OBoolOperator : public OOperator
+ {
+ public:
+ TYPEINFO();
+ virtual void Exec(OCodeStack&);
+ virtual sal_Bool operate(const OOperand*, const OOperand*) const;
+ };
+
+ class OOp_NOT : public OBoolOperator
+ {
+ public:
+ TYPEINFO();
+
+ protected:
+ virtual void Exec(OCodeStack&);
+ virtual sal_Bool operate(const OOperand*, const OOperand* = NULL) const;
+ virtual sal_uInt16 getRequestedOperands() const;
+ };
+
+ class OOp_AND : public OBoolOperator
+ {
+ public:
+ TYPEINFO();
+
+ protected:
+ virtual sal_Bool operate(const OOperand*, const OOperand*) const;
+ };
+
+ class OOp_OR : public OBoolOperator
+ {
+ public:
+ TYPEINFO();
+ protected:
+ virtual sal_Bool operate(const OOperand*, const OOperand*) const;
+ };
+
+ class OOO_DLLPUBLIC_FILE OOp_ISNULL : public OBoolOperator
+ {
+ public:
+ TYPEINFO();
+ public:
+ virtual void Exec(OCodeStack&);
+ virtual sal_uInt16 getRequestedOperands() const;
+ virtual sal_Bool operate(const OOperand*, const OOperand* = NULL) const;
+ };
+
+ class OOO_DLLPUBLIC_FILE OOp_ISNOTNULL : public OOp_ISNULL
+ {
+ public:
+ TYPEINFO();
+ virtual sal_Bool operate(const OOperand*, const OOperand* = NULL) const;
+ };
+
+ class OOO_DLLPUBLIC_FILE OOp_LIKE : public OBoolOperator
+ {
+ public:
+ TYPEINFO();
+ protected:
+ const sal_Unicode cEscape;
+
+ public:
+ OOp_LIKE(const sal_Unicode cEsc = L'\0'):cEscape(cEsc){};
+
+ virtual sal_Bool operate(const OOperand*, const OOperand*) const;
+ };
+
+ class OOp_NOTLIKE : public OOp_LIKE
+ {
+ public:
+ TYPEINFO();
+ public:
+ OOp_NOTLIKE(const sal_Unicode cEsc = L'\0'):OOp_LIKE(cEsc){};
+
+ virtual sal_Bool operate(const OOperand*, const OOperand*) const;
+ };
+
+ class OOO_DLLPUBLIC_FILE OOp_COMPARE : public OBoolOperator
+ {
+ sal_Int32 aPredicateType;
+
+ public:
+ TYPEINFO();
+ OOp_COMPARE(sal_Int32 aPType)
+ :aPredicateType(aPType) {}
+
+ inline sal_Int32 getPredicateType() const { return aPredicateType; }
+ virtual sal_Bool operate(const OOperand*, const OOperand*) const;
+ };
+
+ // numerische Operatoren
+
+ class ONumOperator : public OOperator
+ {
+ public:
+ virtual void Exec(OCodeStack&);
+
+ TYPEINFO();
+
+ protected:
+ virtual double operate(const double& fLeft,const double& fRight) const = 0;
+ };
+
+ class OOp_ADD : public ONumOperator
+ {
+ protected:
+ virtual double operate(const double& fLeft,const double& fRight) const;
+ };
+
+ class OOp_SUB : public ONumOperator
+ {
+ protected:
+ virtual double operate(const double& fLeft,const double& fRight) const;
+ };
+
+ class OOp_MUL : public ONumOperator
+ {
+ protected:
+ virtual double operate(const double& fLeft,const double& fRight) const;
+ };
+
+ class OOp_DIV : public ONumOperator
+ {
+ protected:
+ virtual double operate(const double& fLeft,const double& fRight) const;
+ };
+
+ inline sal_Bool OOperand::isValid() const
+ {
+ return getValue().getDouble() != double(0.0);
+ }
+
+ // operator
+ class ONthOperator : public OOperator
+ {
+ public:
+ virtual void Exec(OCodeStack&);
+
+ TYPEINFO();
+
+ protected:
+ virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const = 0;
+ };
+
+ class OBinaryOperator : public OOperator
+ {
+ public:
+ virtual void Exec(OCodeStack&);
+
+ TYPEINFO();
+
+ protected:
+ virtual ORowSetValue operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const = 0;
+ };
+
+ class OUnaryOperator : public OOperator
+ {
+ public:
+ virtual void Exec(OCodeStack&);
+ virtual sal_uInt16 getRequestedOperands() const;
+ virtual ORowSetValue operate(const ORowSetValue& lhs) const = 0;
+
+ TYPEINFO();
+
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_FILE_FCODE_HXX_
+
diff --git a/connectivity/source/inc/file/fcomp.hxx b/connectivity/source/inc/file/fcomp.hxx
new file mode 100644
index 000000000000..b46d24ddd089
--- /dev/null
+++ b/connectivity/source/inc/file/fcomp.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef _CONNECTIVITY_FILE_FCOMP_HXX_
+#define _CONNECTIVITY_FILE_FCOMP_HXX_
+
+#include "file/fcode.hxx"
+#include "file/filedllapi.hxx"
+#ifndef _LIST_
+#include <list>
+#endif
+
+namespace connectivity
+{
+ class OSQLParseNode;
+ namespace file
+ {
+ class OCode;
+ class OOperand;
+ class OSQLAnalyzer;
+ typedef::std::vector<OCode*> OCodeList;
+
+ class OPredicateCompiler : public ::vos::OReference
+ {
+ friend class OPredicateInterpreter;
+ friend class OSQLAnalyzer;
+
+ OCodeList m_aCodeList;
+ OFileColumns m_orgColumns; // in filecurs this are the filecolumns
+ OSQLAnalyzer* m_pAnalyzer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xIndexes;
+ sal_Int32 m_nParamCounter;
+ sal_Bool m_bORCondition;
+ public:
+ OPredicateCompiler(OSQLAnalyzer* pAnalyzer);
+
+ virtual ~OPredicateCompiler();
+
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void * SAL_CALL operator new( size_t /*nSize*/,void* _pHint ) SAL_THROW( () )
+ { return _pHint; }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ inline static void SAL_CALL operator delete( void * /*pMem*/,void* /*_pHint*/ ) SAL_THROW( () )
+ { }
+ void dispose();
+
+ void start(connectivity::OSQLParseNode* pSQLParseNode);
+ OOperand* execute(connectivity::OSQLParseNode* pPredicateNode);
+
+ void Clean();
+ sal_Bool isClean() const {return m_aCodeList.empty();}
+ sal_Bool hasCode() const {return !isClean();}
+ sal_Bool hasORCondition() const {return m_bORCondition;}
+ void setOrigColumns(const OFileColumns& rCols) { m_orgColumns = rCols; }
+ const OFileColumns getOrigColumns() const { return m_orgColumns; }
+ protected:
+ OOperand* execute_COMPARE(connectivity::OSQLParseNode* pPredicateNode) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ OOperand* execute_LIKE(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ OOperand* execute_BETWEEN(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ OOperand* execute_ISNULL(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ OOperand* execute_Operand(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ OOperand* execute_Fold(OSQLParseNode* pPredicateNode) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ OOperand* executeFunction(OSQLParseNode* pPredicateNode) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+
+
+ class OPredicateInterpreter :
+ public ::vos::OReference
+ {
+ OCodeStack m_aStack;
+ ::vos::ORef<OPredicateCompiler> m_rCompiler;
+
+ public:
+ OPredicateInterpreter(const ::vos::ORef<OPredicateCompiler>& rComp) : m_rCompiler(rComp){}
+ virtual ~OPredicateInterpreter();
+
+ sal_Bool evaluate(OCodeList& rCodeList);
+ void evaluateSelection(OCodeList& rCodeList,ORowSetValueDecoratorRef& _rVal);
+
+ inline sal_Bool start()
+ {
+ return evaluate(m_rCompiler->m_aCodeList);
+ }
+
+ inline void startSelection(ORowSetValueDecoratorRef& _rVal)
+ {
+ return evaluateSelection(m_rCompiler->m_aCodeList,_rVal);
+ }
+
+
+ };
+ }
+}
+#endif // _CONNECTIVITY_FILE_FCOMP_HXX_
+
diff --git a/connectivity/source/inc/file/filedllapi.hxx b/connectivity/source/inc/file/filedllapi.hxx
new file mode 100644
index 000000000000..11f98fa80690
--- /dev/null
+++ b/connectivity/source/inc/file/filedllapi.hxx
@@ -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.
+ *
+************************************************************************/
+
+#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FILEDLLAPI_HXX
+#define INCLUDED_CONNECTIVITY_SOURCE_INC_FILE_FILEDLLAPI_HXX
+
+#include "sal/config.h"
+
+#include "sal/types.h"
+
+#if defined OOO_DLLIMPLEMENTATION_FILE
+#define OOO_DLLPUBLIC_FILE SAL_DLLPUBLIC_EXPORT
+#else
+#define OOO_DLLPUBLIC_FILE SAL_DLLPUBLIC_IMPORT
+#endif
+
+#endif
diff --git a/connectivity/source/inc/file/quotedstring.hxx b/connectivity/source/inc/file/quotedstring.hxx
new file mode 100644
index 000000000000..cb9215a014b2
--- /dev/null
+++ b/connectivity/source/inc/file/quotedstring.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_QUOTED_STRING_HXX
+#define CONNECTIVITY_QUOTED_STRING_HXX
+
+#include <tools/string.hxx>
+#include "file/filedllapi.hxx"
+
+namespace connectivity
+{
+ //==================================================================
+ // Ableitung von String mit ueberladenen GetToken/GetTokenCount-Methoden
+ // Speziell fuer FLAT FILE-Format: Strings koennen gequotet sein
+ //==================================================================
+ class OOO_DLLPUBLIC_FILE QuotedTokenizedString
+ {
+ String m_sString;
+ public:
+ QuotedTokenizedString() {}
+ QuotedTokenizedString(const String& _sString) : m_sString(_sString){}
+
+ xub_StrLen GetTokenCount( sal_Unicode cTok , sal_Unicode cStrDel ) const;
+ void GetTokenSpecial( String& _rStr,xub_StrLen& nStartPos, sal_Unicode cTok = ';', sal_Unicode cStrDel = '\0' ) const;
+ inline String& GetString() { return m_sString; }
+ inline xub_StrLen Len() const { return m_sString.Len(); }
+ inline operator String&() { return m_sString; }
+ };
+}
+
+#endif // CONNECTIVITY_QUOTED_STRING_HXX
diff --git a/connectivity/source/inc/flat/ECatalog.hxx b/connectivity/source/inc/flat/ECatalog.hxx
new file mode 100644
index 000000000000..4692f58171d8
--- /dev/null
+++ b/connectivity/source/inc/flat/ECatalog.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_FLAT_CATALOG_HXX_
+#define _CONNECTIVITY_FLAT_CATALOG_HXX_
+
+#include "file/FCatalog.hxx"
+
+namespace connectivity
+{
+ namespace flat
+ {
+ class OFlatConnection;
+ class OFlatCatalog : public file::OFileCatalog
+ {
+ public:
+ virtual void refreshTables();
+
+ public:
+ OFlatCatalog(OFlatConnection* _pCon);
+ };
+ }
+}
+#endif // _CONNECTIVITY_FLAT_CATALOG_HXX_
+
diff --git a/connectivity/source/inc/flat/EColumns.hxx b/connectivity/source/inc/flat/EColumns.hxx
new file mode 100644
index 000000000000..7c6e7dfd0f2e
--- /dev/null
+++ b/connectivity/source/inc/flat/EColumns.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_FLAT_COLUMNS_HXX_
+#define _CONNECTIVITY_FLAT_COLUMNS_HXX_
+
+#include "file/FColumns.hxx"
+
+namespace connectivity
+{
+ namespace flat
+ {
+ class OFlatColumns : public file::OColumns
+ {
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ public:
+ OFlatColumns(file::OFileTable* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector
+ ) : file::OColumns(_pTable,_rMutex,_rVector)
+ {}
+
+ };
+ }
+}
+#endif // _CONNECTIVITY_FLAT_COLUMNS_HXX_
+
diff --git a/connectivity/source/inc/flat/EConnection.hxx b/connectivity/source/inc/flat/EConnection.hxx
new file mode 100644
index 000000000000..3b4fb7e558d6
--- /dev/null
+++ b/connectivity/source/inc/flat/EConnection.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_FLAT_ECONNECTION_HXX_
+#define _CONNECTIVITY_FLAT_ECONNECTION_HXX_
+
+#include "file/FConnection.hxx"
+
+namespace connectivity
+{
+ namespace flat
+ {
+ class ODriver;
+ class OFlatConnection : public file::OConnection
+ {
+ private:
+ 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; //
+ public:
+ OFlatConnection(ODriver* _pDriver);
+ virtual ~OFlatConnection();
+
+ 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 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;}
+ // 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_FLAT_DCONNECTION_HXX_
+
diff --git a/connectivity/source/inc/flat/EDatabaseMetaData.hxx b/connectivity/source/inc/flat/EDatabaseMetaData.hxx
new file mode 100644
index 000000000000..79cb18bcbf40
--- /dev/null
+++ b/connectivity/source/inc/flat/EDatabaseMetaData.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_FLAT_EDATABASEMETADATA_HXX_
+#define _CONNECTIVITY_FLAT_EDATABASEMETADATA_HXX_
+
+#include "file/FDatabaseMetaData.hxx"
+
+namespace connectivity
+{
+ namespace flat
+ {
+ //**************************************************************
+ //************ Class: java.sql.DatabaseMetaDataDate
+ //**************************************************************
+
+ class OFlatDatabaseMetaData : public file::ODatabaseMetaData
+ {
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_getTypeInfo_throw();
+ protected:
+ virtual ~OFlatDatabaseMetaData();
+ public:
+ OFlatDatabaseMetaData(file::OConnection* _pCon);
+
+ 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);
+ };
+ }
+}
+#endif // _CONNECTIVITY_FLAT_ODATABASEMETADATA_HXX_
+
diff --git a/connectivity/source/inc/flat/EDriver.hxx b/connectivity/source/inc/flat/EDriver.hxx
new file mode 100644
index 000000000000..124dbf1f6156
--- /dev/null
+++ b/connectivity/source/inc/flat/EDriver.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_FLAT_EDRIVER_HXX_
+#define _CONNECTIVITY_FLAT_EDRIVER_HXX_
+
+#include <cppuhelper/compbase2.hxx>
+#include "connectivity/CommonTools.hxx"
+#include "file/FDriver.hxx"
+
+namespace connectivity
+{
+ namespace flat
+ {
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception );
+
+ class ODriver : public file::OFileDriver
+ {
+ public:
+ ODriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) : file::OFileDriver(_rxFactory){}
+
+ // 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);
+
+ ::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);
+ };
+ }
+
+}
+#endif //_CONNECTIVITY_FLAT_DDRIVER_HXX_
+
diff --git a/connectivity/source/inc/flat/EPreparedStatement.hxx b/connectivity/source/inc/flat/EPreparedStatement.hxx
new file mode 100644
index 000000000000..50ffb9173b79
--- /dev/null
+++ b/connectivity/source/inc/flat/EPreparedStatement.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_FLAT_DPREPAREDSTATEMENT_HXX_
+#define _CONNECTIVITY_FLAT_DPREPAREDSTATEMENT_HXX_
+
+#include "file/FPreparedStatement.hxx"
+
+namespace connectivity
+{
+ namespace flat
+ {
+ class OConnection;
+ class OFlatPreparedStatement : public file::OPreparedStatement
+ {
+ protected:
+ virtual file::OResultSet* createResultSet();
+ public:
+ OFlatPreparedStatement( file::OConnection* _pConnection) : file::OPreparedStatement( _pConnection){}
+ DECLARE_SERVICE_INFO();
+ };
+ }
+}
+
+#endif //_CONNECTIVITY_FLAT_DPREPAREDSTATEMENT_HXX_
+
diff --git a/connectivity/source/inc/flat/EResultSet.hxx b/connectivity/source/inc/flat/EResultSet.hxx
new file mode 100644
index 000000000000..6a9958dd7bea
--- /dev/null
+++ b/connectivity/source/inc/flat/EResultSet.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_FLAT_ERESULTSET_HXX_
+#define _CONNECTIVITY_FLAT_ERESULTSET_HXX_
+
+#include "file/FResultSet.hxx"
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+namespace connectivity
+{
+ namespace flat
+ {
+ class OFlatResultSet;
+ // these typedef's are only necessary for the compiler
+ typedef ::cppu::ImplHelper1< ::com::sun::star::sdbcx::XRowLocate> OFlatResultSet_BASE;
+ typedef file::OResultSet OFlatResultSet_BASE2;
+ typedef ::comphelper::OPropertyArrayUsageHelper<OFlatResultSet> OFlatResultSet_BASE3;
+
+
+ class OFlatResultSet : public OFlatResultSet_BASE2,
+ public OFlatResultSet_BASE,
+ public OFlatResultSet_BASE3
+ {
+ sal_Bool m_bBookmarkable;
+ protected:
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ public:
+ DECLARE_SERVICE_INFO();
+
+ OFlatResultSet( 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_FLAT_DRESULTSET_HXX_
+
diff --git a/connectivity/source/inc/flat/EStatement.hxx b/connectivity/source/inc/flat/EStatement.hxx
new file mode 100644
index 000000000000..c80dfe0405a2
--- /dev/null
+++ b/connectivity/source/inc/flat/EStatement.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_FLAT_ESTATEMENT_HXX_
+#define _CONNECTIVITY_FLAT_ESTATEMENT_HXX_
+
+#include "file/FStatement.hxx"
+
+namespace connectivity
+{
+ namespace flat
+ {
+ class OConnection;
+ class OFlatStatement : public file::OStatement
+ {
+ protected:
+ virtual file::OResultSet* createResultSet();
+ public:
+ OFlatStatement( file::OConnection* _pConnection) : file::OStatement( _pConnection){}
+ DECLARE_SERVICE_INFO();
+ };
+ }
+}
+
+#endif //_CONNECTIVITY_FLAT_DSTATEMENT_HXX_
diff --git a/connectivity/source/inc/flat/ETable.hxx b/connectivity/source/inc/flat/ETable.hxx
new file mode 100644
index 000000000000..51d57376c5d2
--- /dev/null
+++ b/connectivity/source/inc/flat/ETable.hxx
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_FLAT_TABLE_HXX_
+#define _CONNECTIVITY_FLAT_TABLE_HXX_
+
+#include "file/FTable.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include "connectivity/CommonTools.hxx"
+#include <tools/urlobj.hxx>
+#include "file/quotedstring.hxx"
+
+namespace connectivity
+{
+ namespace flat
+ {
+ typedef file::OFileTable OFlatTable_BASE;
+ class OFlatConnection;
+
+ typedef ::std::map< ::rtl::OUString,
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed>, comphelper::UStringMixLess > OContainer;
+ typedef ::std::map<sal_Int32, sal_Int32> TRowPositionsInFile;
+
+ class OFlatTable : public OFlatTable_BASE
+ {
+ // maps a row postion to a file position
+ TRowPositionsInFile m_aFilePosToEndLinePos;
+ ::std::map<sal_Int32, TRowPositionsInFile::iterator>
+ m_aRowPosToFilePos;
+ ::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;
+ ::com::sun::star::util::Date m_aNullDate;
+ sal_Int32 m_nStartRowFilePos;
+ sal_Int32 m_nRowPos;
+ sal_Int32 m_nMaxRowCount; // will be set if stream is once eof
+ sal_Unicode m_cStringDelimiter; // delimiter for strings m_cStringDelimiter blabla m_cStringDelimiter
+ sal_Unicode m_cFieldDelimiter; // look at the name
+ bool m_bNeedToReadLine;
+ private:
+ void fillColumns(const ::com::sun::star::lang::Locale& _aLocale);
+ BOOL CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo);
+ sal_Bool readLine(sal_Int32& _rnCurrentPos);
+ public:
+ virtual void refreshColumns();
+
+ public:
+ // DECLARE_CTY_DEFAULTS( OFlatTable_BASE);
+ OFlatTable( sdbcx::OCollection* _pTables,OFlatConnection* _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 void refreshHeader();
+
+ 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_FLAT_TABLE_HXX_
+
diff --git a/connectivity/source/inc/flat/ETables.hxx b/connectivity/source/inc/flat/ETables.hxx
new file mode 100644
index 000000000000..b14379d4c6ae
--- /dev/null
+++ b/connectivity/source/inc/flat/ETables.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_FLAT_TABLES_HXX_
+#define _CONNECTIVITY_FLAT_TABLES_HXX_
+
+#include "file/FTables.hxx"
+
+namespace connectivity
+{
+ namespace flat
+ {
+ // namespace ::com::sun::star::sdbcx = ::com::sun::star::sdbcx;
+ typedef file::OTables OFlatTables_BASE;
+
+ class OFlatTables : public OFlatTables_BASE
+ {
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ public:
+ OFlatTables(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector) : OFlatTables_BASE(_rMetaData,_rParent,_rMutex,_rVector)
+ {}
+ };
+ }
+}
+#endif // _CONNECTIVITY_FLAT_TABLES_HXX_
+
diff --git a/connectivity/source/inc/hsqldb/HCatalog.hxx b/connectivity/source/inc/hsqldb/HCatalog.hxx
new file mode 100644
index 000000000000..a58ddbcecf9d
--- /dev/null
+++ b/connectivity/source/inc/hsqldb/HCatalog.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_HSQLDB_CATALOG_HXX
+#define CONNECTIVITY_HSQLDB_CATALOG_HXX
+
+#include "connectivity/sdbcx/VCatalog.hxx"
+#include "connectivity/StdTypeDefs.hxx"
+
+namespace connectivity
+{
+ namespace hsqldb
+ {
+ // 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 OHCatalog : public connectivity::sdbcx::OCatalog
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+
+ /** calls XDatabaseMetaData::getTables.
+ @param _sKindOfObject
+ The type of tables to be fetched.
+ @param _rNames
+ The container for the names to be filled.
+ */
+ void refreshObjects(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _sKindOfObject,TStringVector& _rNames);
+
+ public:
+ // implementation of the pure virtual methods
+ virtual void refreshTables();
+ virtual void refreshViews() ;
+ virtual void refreshGroups();
+ virtual void refreshUsers() ;
+
+ public:
+ OHCatalog(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection);
+
+ inline sdbcx::OCollection* getPrivateTables() const { return m_pTables;}
+ inline sdbcx::OCollection* getPrivateViews() const { return m_pViews; }
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > getConnection() const { return m_xConnection; }
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ // ::cppu::OComponentHelper
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+#endif // CONNECTIVITY_HSQLDB_CATALOG_HXX
+
diff --git a/connectivity/source/inc/hsqldb/HColumns.hxx b/connectivity/source/inc/hsqldb/HColumns.hxx
new file mode 100644
index 000000000000..dc3e0e9655c2
--- /dev/null
+++ b/connectivity/source/inc/hsqldb/HColumns.hxx
@@ -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 CONNECTIVITY_HSQLDB_COLUMN_HXX
+#define CONNECTIVITY_HSQLDB_COLUMN_HXX
+#include "connectivity/TColumnsHelper.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+
+namespace connectivity
+{
+ namespace hsqldb
+ {
+ class OHSQLColumns : public OColumnsHelper
+ {
+ protected:
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ public:
+ OHSQLColumns( ::cppu::OWeakObject& _rParent
+ ,sal_Bool _bCase
+ ,::osl::Mutex& _rMutex
+ ,const TStringVector &_rVector
+ ,sal_Bool _bUseHardRef = sal_True
+ );
+ };
+
+ class OHSQLColumn;
+ typedef sdbcx::OColumn OHSQLColumn_BASE;
+ typedef ::comphelper::OIdPropertyArrayUsageHelper<OHSQLColumn> OHSQLColumn_PROP;
+
+ class OHSQLColumn : public OHSQLColumn_BASE,
+ public OHSQLColumn_PROP
+ {
+ ::rtl::OUString m_sAutoIncrement;
+ protected:
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const;
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ public:
+ OHSQLColumn(sal_Bool _bCase);
+ virtual void construct();
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+#endif // CONNECTIVITY_HSQLDB_COLUMN_HXX
+
diff --git a/connectivity/source/inc/hsqldb/HConnection.hxx b/connectivity/source/inc/hsqldb/HConnection.hxx
new file mode 100644
index 000000000000..021f09c485bd
--- /dev/null
+++ b/connectivity/source/inc/hsqldb/HConnection.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_HSQLDB_CONNECTION_HXX
+#define CONNECTIVITY_HSQLDB_CONNECTION_HXX
+
+#include "connectivity/ConnectionWrapper.hxx"
+/** === begin UNO includes === **/
+#include <com/sun/star/util/XFlushable.hpp>
+#include <com/sun/star/sdbc/XDriver.hpp>
+#ifndef __com_sun_star_sdb_application_XTableUIProvider_hpp__
+#include <com/sun/star/sdb/application/XTableUIProvider.hpp>
+#endif
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/compbase2.hxx>
+#include <comphelper/uno3.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <memory>
+
+namespace connectivity
+{
+ namespace hsqldb
+ {
+ class SAL_NO_VTABLE IMethodGuardAccess
+ {
+ public:
+ virtual ::osl::Mutex& getMutex() const = 0;
+ virtual void checkDisposed() const = 0;
+ };
+
+ //==========================================================================
+ //= OHsqlConnection - wraps all methods to the real connection from the driver
+ //= but when disposed it doesn't dispose the real connection
+ //==========================================================================
+ typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::util::XFlushable
+ , ::com::sun::star::sdb::application::XTableUIProvider
+ > OHsqlConnection_BASE;
+
+ class OHsqlConnection :public ::comphelper::OBaseMutex
+ ,public OHsqlConnection_BASE
+ ,public OConnectionWrapper
+ ,public IMethodGuardAccess
+ {
+ private:
+ ::cppu::OInterfaceContainerHelper m_aFlushListeners;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > m_xDriver;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
+ bool m_bIni;
+ bool m_bReadOnly;
+
+ protected:
+ virtual void SAL_CALL disposing(void);
+ virtual ~OHsqlConnection();
+
+ public:
+ OHsqlConnection(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > _rxDriver,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _xORB
+ );
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO();
+ DECLARE_XTYPEPROVIDER()
+ DECLARE_XINTERFACE( )
+
+ // IMethodGuardAccess
+ virtual ::osl::Mutex& getMutex() const;
+ virtual void checkDisposed() const;
+
+ // XFlushable
+ virtual void SAL_CALL flush( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XTableUIProvider
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > SAL_CALL getTableIcon( const ::rtl::OUString& TableName, ::sal_Int32 ColorMode ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getTableEditor( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& DocumentUI, const ::rtl::OUString& TableName ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ private:
+#if 0
+ // TODO: resource
+ /** creates the dialog used for editing a linked table
+
+ @param _rTableName
+ the name of the table to create the editor for.
+
+ @param _rxDocumentUI
+ the UI of the database document, for which the editor is to be created.
+ Must not be <NULL/>.
+
+ @return
+ the table editor dialog instance.
+
+ @throws ::com::sun::star::lang::WrappedTargetException
+ if creating the dialog instance fails
+
+ @throws ::com::sun::star::uno::RuntimeException
+ if a serious error occures
+
+ @precond
+ Our mutex is locked.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XExecutableDialog >
+ impl_createLinkedTableEditor_throw(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& _rxDocumentUI,
+ const ::rtl::OUString& _rTableName
+ );
+#endif
+
+ /** retrieves our table container
+ @return
+ our table container. Guaranteed to not be <NULL/>.
+ @throws ::com::sun::star::lang::WrappedTargetException
+ if a non-RuntimeException is caught during obtaining the container.
+ @throws ::com::sun::star::uno::RuntimeException
+ if a serious error occurs
+ @precond
+ We're not disposed.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ impl_getTableContainer_throw();
+
+ /** checks whether the given table name denotes an existing table
+ @param _rTableName
+ the fully name of the table to check for existence
+ @throws ::com::sun::star::lang::IllegalArgumentException
+ if the name does not denote an existing table
+ @precond
+ We're not disposed.
+ */
+ void impl_checkExistingTable_throw( const ::rtl::OUString& _rTableName );
+
+ /** checks whether the given table name refers to a HSQL TEXT TABLE
+ */
+ bool impl_isTextTable_nothrow( const ::rtl::OUString& _rTableName );
+
+ /** retrieves the icon for HSQL TEXT TABLEs
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >
+ impl_getTextTableIcon_nothrow( ::sal_Int32 _ColorMode );
+ };
+
+ //==========================================================================
+ //= OHsqlConnection
+ //==========================================================================
+ class MethodGuard : public ::osl::MutexGuard
+ {
+ private:
+ typedef ::osl::MutexGuard BaseGuard;
+
+ public:
+ MethodGuard( const IMethodGuardAccess& _rComponent )
+ :BaseGuard( _rComponent.getMutex() )
+ {
+ _rComponent.checkDisposed();
+ }
+ };
+ }
+}
+#endif // CONNECTIVITY_HSQLDB_CONNECTION_HXX
diff --git a/connectivity/source/inc/hsqldb/HDriver.hxx b/connectivity/source/inc/hsqldb/HDriver.hxx
new file mode 100644
index 000000000000..72d21d5774e1
--- /dev/null
+++ b/connectivity/source/inc/hsqldb/HDriver.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_HSQLDB_DRIVER_HXX
+#define CONNECTIVITY_HSQLDB_DRIVER_HXX
+
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#include <com/sun/star/sdbcx/XCreateCatalog.hpp>
+#include <com/sun/star/embed/XTransactionListener.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/compbase5.hxx>
+#include <comphelper/uno3.hxx>
+#include <comphelper/stl_types.hxx>
+#include <comphelper/broadcasthelper.hxx>
+#include "connectivity/CommonTools.hxx"
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ class OMetaConnection;
+
+ namespace hsqldb
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODriverDelegator_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception );
+
+ typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::sdbc::XDriver
+ ,::com::sun::star::sdbcx::XDataDefinitionSupplier
+ , ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::sdbcx::XCreateCatalog
+ , ::com::sun::star::embed::XTransactionListener
+ > ODriverDelegator_BASE;
+
+ typedef ::std::pair< ::com::sun::star::uno::WeakReferenceHelper,::com::sun::star::uno::WeakReferenceHelper> TWeakRefPair;
+ typedef ::std::pair< ::rtl::OUString ,TWeakRefPair > TWeakConnectionPair;
+
+ typedef ::std::pair< ::com::sun::star::uno::WeakReferenceHelper,TWeakConnectionPair> TWeakPair;
+ typedef ::std::vector< TWeakPair > TWeakPairVector;
+
+
+ /** delegates all calls to the orignal driver and extend the existing one with the SDBCX layer.
+
+ */
+ class ODriverDelegator : public ::comphelper::OBaseMutex
+ ,public ODriverDelegator_BASE
+ {
+ TWeakPairVector m_aConnections; // vector containing a list
+ // of all the Connection objects
+ // for this Driver
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > m_xDriver;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
+ sal_Bool m_bInShutDownConnections;
+
+ /** load the driver we want to delegate.
+ The <member>m_xDriver</member> may be <NULL/> if the driver could not be loaded.
+ @return
+ The driver which was currently selected.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > loadDriver( );
+
+ /** shut down the connection and revoke the storage from the map
+ @param _aIter
+ The connection to shut down and storage to revoke.
+ */
+ void shutdownConnection(const TWeakPairVector::iterator& _aIter);
+
+ public:
+ /** creates a new delegator for a HSQLDB driver
+ */
+ ODriverDelegator(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO();
+ 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);
+
+ // 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);
+
+ // XDataDefinitionSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByURL( 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);
+
+ // XCreateCatalog
+ virtual void SAL_CALL createCatalog( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XTransactionListener
+ virtual void SAL_CALL preCommit( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL commited( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL preRevert( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL reverted( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+
+ void shutdownConnections();
+ protected:
+ /// dtor
+ virtual ~ODriverDelegator();
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ /** called when we connected to a newly created embedded database
+ */
+ void onConnectedNewDatabase(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
+ );
+ };
+ }
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+#endif // CONNECTIVITY_HSQLDB_DRIVER_HXX
+
diff --git a/connectivity/source/inc/hsqldb/HStorageAccess.h b/connectivity/source/inc/hsqldb/HStorageAccess.h
new file mode 100644
index 000000000000..279b82225e73
--- /dev/null
+++ b/connectivity/source/inc/hsqldb/HStorageAccess.h
@@ -0,0 +1,95 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess */
+
+#ifndef _Included_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+#define _Included_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+#ifdef __cplusplus
+extern "C" {
+#endif
+/* Inaccessible static: class_00024com_00024sun_00024star_00024sdbcx_00024comp_00024hsqldb_00024StorageNativeOutputStream */
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: openStream
+ * Signature: (Ljava/lang/String;Ljava/lang/String;I)V
+ */
+JNIEXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_openStream
+ (JNIEnv *, jobject, jstring, jstring, jint);
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: close
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_close
+ (JNIEnv *, jobject, jstring, jstring);
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: getFilePointer
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)J
+ */
+JNIEXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_getFilePointer
+ (JNIEnv *, jobject, jstring, jstring);
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: length
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)J
+ */
+JNIEXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_length
+ (JNIEnv *, jobject, jstring, jstring);
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: read
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_read__Ljava_lang_String_2Ljava_lang_String_2
+ (JNIEnv *, jobject, jstring, jstring);
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: read
+ * Signature: (Ljava/lang/String;Ljava/lang/String;[BII)I
+ */
+JNIEXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_read__Ljava_lang_String_2Ljava_lang_String_2_3BII
+ (JNIEnv *, jobject, jstring, jstring, jbyteArray, jint, jint);
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: readInt
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_readInt
+ (JNIEnv *, jobject, jstring, jstring);
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: seek
+ * Signature: (Ljava/lang/String;Ljava/lang/String;J)V
+ */
+JNIEXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_seek
+ (JNIEnv *, jobject, jstring, jstring, jlong);
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: write
+ * Signature: (Ljava/lang/String;Ljava/lang/String;[BII)V
+ */
+JNIEXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_write
+ (JNIEnv *, jobject, jstring, jstring, jbyteArray, jint, jint);
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: writeInt
+ * Signature: (Ljava/lang/String;Ljava/lang/String;I)V
+ */
+JNIEXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_writeInt
+ (JNIEnv *, jobject, jstring, jstring, jint);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/connectivity/source/inc/hsqldb/HStorageAccess.hxx b/connectivity/source/inc/hsqldb/HStorageAccess.hxx
new file mode 100644
index 000000000000..13721e020101
--- /dev/null
+++ b/connectivity/source/inc/hsqldb/HStorageAccess.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_HSQLDB_STORAGEACCESS_HXX
+#define CONNECTIVITY_HSQLDB_STORAGEACCESS_HXX
+
+#include "hsqldb/HStorageAccess.h"
+
+namespace connectivity { namespace hsqldb
+{
+ class DataLogFile;
+} }
+
+jint read_from_storage_stream( JNIEnv * env, jobject obj_this, jstring name, jstring key, ::connectivity::hsqldb::DataLogFile* logger = NULL );
+jint read_from_storage_stream_into_buffer( JNIEnv * env, jobject obj_this,jstring name, jstring key, jbyteArray buffer, jint off, jint len, ::connectivity::hsqldb::DataLogFile* logger = NULL );
+void write_to_storage_stream_from_buffer( JNIEnv* env, jobject obj_this, jstring name, jstring key, jbyteArray buffer, jint off, jint len, ::connectivity::hsqldb::DataLogFile* logger = NULL );
+void write_to_storage_stream( JNIEnv* env, jobject obj_this, jstring name, jstring key, jint v, ::connectivity::hsqldb::DataLogFile* logger = NULL );
+
+#endif // CONNECTIVITY_HSQLDB_STORAGEACCESS_HXX
diff --git a/connectivity/source/inc/hsqldb/HStorageMap.hxx b/connectivity/source/inc/hsqldb/HStorageMap.hxx
new file mode 100644
index 000000000000..47cb4781c72a
--- /dev/null
+++ b/connectivity/source/inc/hsqldb/HStorageMap.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 CONNECTIVI_HSQLDB_HSTORAGEMAP_HXX
+#define CONNECTIVI_HSQLDB_HSTORAGEMAP_HXX
+
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/XTransactionListener.hpp>
+#include <com/sun/star/io/XStream.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#ifndef BOOST_SHARED_PTR_HPP_INCLUDED
+#include <boost/shared_ptr.hpp>
+#endif
+#include <comphelper/stl_types.hxx>
+#include <jni.h>
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+ namespace hsqldb
+ {
+ class StreamHelper
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream> m_xStream;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable> m_xSeek;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream> m_xOutputStream;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> m_xInputStream;
+ public:
+ StreamHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream>& _xStream);
+ ~StreamHelper();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> getInputStream();
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream> getOutputStream();
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable> getSeek();
+ };
+
+
+ DECLARE_STL_USTRINGACCESS_MAP(::boost::shared_ptr<StreamHelper>,TStreamMap);
+ typedef ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >, ::rtl::OUString > TStorageURLPair;
+ typedef ::std::pair< TStorageURLPair, TStreamMap> TStoragePair;
+ DECLARE_STL_USTRINGACCESS_MAP(TStoragePair,TStorages);
+ /** contains all storages so far accessed.
+ */
+ class StorageContainer
+ {
+ public:
+ static ::rtl::OUString registerStorage(const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage>& _xStorage,const ::rtl::OUString& _sURL);
+ static TStorages::mapped_type getRegisteredStorage(const ::rtl::OUString& _sKey);
+ static ::rtl::OUString getRegisteredKey(const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage>& _xStorage);
+ static void revokeStorage(const ::rtl::OUString& _sKey,const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XTransactionListener>& _xListener);
+
+ static TStreamMap::mapped_type registerStream(JNIEnv * env,jstring name, jstring key,sal_Int32 _nMode);
+ static void revokeStream(JNIEnv * env,jstring name, jstring key);
+ static TStreamMap::mapped_type getRegisteredStream( JNIEnv * env, jstring name, jstring key);
+
+ static ::rtl::OUString jstring2ustring(JNIEnv * env, jstring jstr);
+ static ::rtl::OUString removeURLPrefix(const ::rtl::OUString& _sURL,const ::rtl::OUString& _sFileURL);
+ static ::rtl::OUString removeOldURLPrefix(const ::rtl::OUString& _sURL);
+ static void throwJavaException(const ::com::sun::star::uno::Exception& _aException,JNIEnv * env);
+ };
+ //........................................................................
+ } // namespace hsqldb
+ //........................................................................
+//........................................................................
+} // namespace connectivity
+
+//........................................................................
+#endif // CONNECTIVI_HSQLDB_HSTORAGEMAP_HXX
+
diff --git a/connectivity/source/inc/hsqldb/HTable.hxx b/connectivity/source/inc/hsqldb/HTable.hxx
new file mode 100644
index 000000000000..ade78e9e5dfc
--- /dev/null
+++ b/connectivity/source/inc/hsqldb/HTable.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_HSQLDB_TABLE_HXX
+#define CONNECTIVITY_HSQLDB_TABLE_HXX
+
+#include "connectivity/TTableHelper.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <comphelper/IdPropArrayHelper.hxx>
+
+namespace connectivity
+{
+ namespace hsqldb
+ {
+
+ ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xColProp);
+
+ class OHSQLTable;
+ typedef ::comphelper::OIdPropertyArrayUsageHelper< OHSQLTable > OHSQLTable_PROP;
+ class OHSQLTable : public OTableHelper
+ ,public OHSQLTable_PROP
+ {
+ sal_Int32 m_nPrivileges; // we have to set our privileges by our own
+
+ /** executes the statmenmt.
+ @param _rStatement
+ The statement to execute.
+ */
+ void executeStatement(const ::rtl::OUString& _rStatement );
+ protected:
+
+ /** creates the column collection for the table
+ @param _rNames
+ The column names.
+ */
+ virtual sdbcx::OCollection* createColumns(const TStringVector& _rNames);
+
+ /** creates the key collection for the table
+ @param _rNames
+ The key names.
+ */
+ virtual sdbcx::OCollection* createKeys(const TStringVector& _rNames);
+
+ /** creates the index collection for the table
+ @param _rNames
+ The index names.
+ */
+ virtual sdbcx::OCollection* createIndexes(const TStringVector& _rNames);
+
+ /** used to implement the creation of the array helper which is shared amongst all instances of the class.
+ This method needs to be implemented in derived classes.
+ <BR>
+ The method gets called with s_aMutex acquired.
+ <BR>
+ as long as IPropertyArrayHelper has no virtual destructor, the implementation of ~OPropertyArrayUsageHelper
+ assumes that you created an ::cppu::OPropertyArrayHelper when deleting s_pProps.
+ @return an pointer to the newly created array helper. Must not be NULL.
+ */
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const;
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ public:
+ OHSQLTable( sdbcx::OCollection* _pTables,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection);
+ OHSQLTable( sdbcx::OCollection* _pTables,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
+ 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(),
+ sal_Int32 _nPrivileges = 0
+ );
+
+ // ODescriptor
+ virtual void construct();
+ // 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();
+
+ 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);
+ // XAlterTable
+ virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& colName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+
+ // XRename
+ virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+
+ /**
+ returns the ALTER TABLE XXX COLUMN statement
+ */
+ ::rtl::OUString getAlterTableColumnPart();
+
+ // some methods to alter table structures
+ void alterColumnType(sal_Int32 nNewType,const ::rtl::OUString& _rColName,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDescriptor);
+ void alterDefaultValue(const ::rtl::OUString& _sNewDefault,const ::rtl::OUString& _rColName);
+ void dropDefaultValue(const ::rtl::OUString& _sNewDefault);
+
+ };
+ }
+}
+#endif // CONNECTIVITY_HSQLDB_TABLE_HXX
+
diff --git a/connectivity/source/inc/hsqldb/HTables.hxx b/connectivity/source/inc/hsqldb/HTables.hxx
new file mode 100644
index 000000000000..0a892e36beba
--- /dev/null
+++ b/connectivity/source/inc/hsqldb/HTables.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_HSQLDB_TABLES_HXX
+#define CONNECTIVITY_HSQLDB_TABLES_HXX
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+namespace connectivity
+{
+ namespace hsqldb
+ {
+ class OTables : 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);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+
+ void createTable( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual ::rtl::OUString getNameForObject(const sdbcx::ObjectType& _xObject);
+ 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);
+
+ // XDrop
+ void appendNew(const ::rtl::OUString& _rsNewTable);
+ // some helper functions
+ /**
+ returns a sql string which contains the column definition part for create or alter statements
+ */
+ static ::rtl::OUString getColumnSqlType(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColProp);
+ /**
+ returns the "not null" part or the default part of the table statement
+ */
+ static ::rtl::OUString getColumnSqlNotNullDefault(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColProp);
+ /**
+ returns the corresponding typename
+ can contain () which have to filled with values
+ */
+ static ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColProp);
+ };
+ }
+}
+#endif // CONNECTIVITY_HSQLDB_TABLES_HXX
+
diff --git a/connectivity/source/inc/hsqldb/HTools.hxx b/connectivity/source/inc/hsqldb/HTools.hxx
new file mode 100644
index 000000000000..fc64b6a9db7f
--- /dev/null
+++ b/connectivity/source/inc/hsqldb/HTools.hxx
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_HTOOLS_HXX
+#define CONNECTIVITY_HTOOLS_HXX
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <rtl/ustrbuf.hxx>
+
+//........................................................................
+namespace connectivity { namespace hsqldb
+{
+//........................................................................
+
+ //====================================================================
+ //= HTools
+ //====================================================================
+ class HTools
+ {
+ public:
+ /** appens a proper WHERE clause to the given buffer, which filters
+ for a given table name
+
+ @param _bShortForm
+ <TRUE/> if the column names of the system table which is being asked
+ have the short form (TABLE_CAT instead of TABLE_CATALOG, and so on)
+ */
+ static void appendTableFilterCrit(
+ ::rtl::OUStringBuffer& _inout_rBuffer, const ::rtl::OUString& _rCatalog,
+ const ::rtl::OUString _rSchema, const ::rtl::OUString _rName,
+ bool _bShortForm
+ );
+ };
+
+//........................................................................
+} } // namespace connectivity::hsqldb
+//........................................................................
+
+#endif // CONNECTIVITY_HTOOLS_HXX
diff --git a/connectivity/source/inc/hsqldb/HUser.hxx b/connectivity/source/inc/hsqldb/HUser.hxx
new file mode 100644
index 000000000000..ca750f597c2b
--- /dev/null
+++ b/connectivity/source/inc/hsqldb/HUser.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_HSQLDB_USER_HXX_
+#define _CONNECTIVITY_HSQLDB_USER_HXX_
+
+#include "connectivity/sdbcx/VUser.hxx"
+#include "com/sun/star/sdbc/XConnection.hpp"
+
+namespace connectivity
+{
+ namespace hsqldb
+ {
+ typedef connectivity::sdbcx::OUser OUser_TYPEDEF;
+
+ class OHSQLUser : public OUser_TYPEDEF
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+
+ ::rtl::OUString getPrivilegeString(sal_Int32 nRights) const;
+ // return the privileges and additional the grant rights
+ void findPrivilegesAndGrantPrivileges(const ::rtl::OUString& objName, sal_Int32 objType,sal_Int32& nRights,sal_Int32& nRightsWithGrant) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ public:
+ virtual void refreshGroups();
+ public:
+ OHSQLUser( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection);
+ OHSQLUser( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,const ::rtl::OUString& _Name);
+
+ // XUser
+ virtual void SAL_CALL changePassword( const ::rtl::OUString& objPassword, const ::rtl::OUString& newPassword ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XAuthorizable
+ virtual sal_Int32 SAL_CALL getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+
+ class OUserExtend;
+ typedef ::comphelper::OPropertyArrayUsageHelper<OUserExtend> OUserExtend_PROP;
+
+ class OUserExtend : public OHSQLUser,
+ public OUserExtend_PROP
+ {
+ protected:
+ ::rtl::OUString m_Password;
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ public:
+ OUserExtend(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection);
+
+ virtual void construct();
+ };
+ }
+}
+#endif // _CONNECTIVITY_HSQLDB_USER_HXX_
+
diff --git a/connectivity/source/inc/hsqldb/HUsers.hxx b/connectivity/source/inc/hsqldb/HUsers.hxx
new file mode 100644
index 000000000000..772d07730af9
--- /dev/null
+++ b/connectivity/source/inc/hsqldb/HUsers.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_HSQLDB_USERS_HXX_
+#define _CONNECTIVITY_HSQLDB_USERS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include "com/sun/star/sdbc/XConnection.hpp"
+namespace connectivity
+{
+ namespace sdbcx
+ {
+ class IRefreshableUsers;
+ }
+ namespace hsqldb
+ {
+ class OUsers : public sdbcx::OCollection
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+ connectivity::sdbcx::IRefreshableUsers* m_pParent;
+ public:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ 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);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_HSQLDB_USERS_HXX_
+
diff --git a/connectivity/source/inc/hsqldb/HView.hxx b/connectivity/source/inc/hsqldb/HView.hxx
new file mode 100644
index 000000000000..5bed5acb02bb
--- /dev/null
+++ b/connectivity/source/inc/hsqldb/HView.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_HVIEW_HXX
+#define CONNECTIVITY_HVIEW_HXX
+
+#include "connectivity/sdbcx/VView.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdbcx/XAlterView.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/uno3.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+//........................................................................
+namespace connectivity { namespace hsqldb
+{
+//........................................................................
+
+ //====================================================================
+ //= HView
+ //====================================================================
+ typedef ::connectivity::sdbcx::OView HView_Base;
+ typedef ::cppu::ImplHelper1< ::com::sun::star::sdbcx::XAlterView > HView_IBASE;
+ class HView :public HView_Base
+ ,public HView_IBASE
+ {
+ public:
+ HView(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ sal_Bool _bCaseSensitive,
+ const ::rtl::OUString& _rSchemaName,
+ const ::rtl::OUString& _rName
+ );
+
+ // UNO
+ DECLARE_XINTERFACE()
+ DECLARE_XTYPEPROVIDER()
+
+ // XAlterView
+ virtual void SAL_CALL alterCommand( const ::rtl::OUString& NewCommand ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual ~HView();
+
+ protected:
+ // OPropertyContainer
+ virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& _rValue, sal_Int32 _nHandle ) const;
+
+ private:
+ /** retrieves the current command of the View
+
+ @throws ::com::sun::star::lang::WrappedTargetException
+ if an error occurs while retrieving the command from the database and
+ <arg>_bAllowSQLExceptin</arg> is <FALSE/>
+ @throws ::com::sun::star::sdbc::SQLException
+ if an error occurs while retrieving the command from the database and
+ <arg>_bAllowSQLException</arg> is <TRUE/>
+ */
+ ::rtl::OUString impl_getCommand_throw( bool _bAllowSQLException ) const;
+
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+ private:
+ using HView_Base::getFastPropertyValue;
+ };
+
+//........................................................................
+} } // namespace connectivity::hsqldb
+//........................................................................
+
+#endif // CONNECTIVITY_HVIEW_HXX
diff --git a/connectivity/source/inc/hsqldb/HViews.hxx b/connectivity/source/inc/hsqldb/HViews.hxx
new file mode 100644
index 000000000000..5b819449d6ff
--- /dev/null
+++ b/connectivity/source/inc/hsqldb/HViews.hxx
@@ -0,0 +1,63 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_VIEWS_HXX_
+#define _CONNECTIVITY_HSQLDB_VIEWS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+namespace connectivity
+{
+ namespace hsqldb
+ {
+ class HViews : public sdbcx::OCollection
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+ sal_Bool m_bInDrop;
+
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+
+ void createView( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ public:
+ HViews(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, const TStringVector &_rVector );
+
+ // only the name is identical to ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ void dropByNameImpl(const ::rtl::OUString& elementName);
+ };
+ }
+}
+#endif // _CONNECTIVITY_HSQLDB_VIEWS_HXX_
+
diff --git a/connectivity/source/inc/hsqldb/StorageFileAccess.h b/connectivity/source/inc/hsqldb/StorageFileAccess.h
new file mode 100644
index 000000000000..6d39465b4401
--- /dev/null
+++ b/connectivity/source/inc/hsqldb/StorageFileAccess.h
@@ -0,0 +1,37 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess */
+
+#ifndef _Included_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess
+#define _Included_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess
+ * Method: isStreamElement
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_isStreamElement
+ (JNIEnv *, jobject, jstring, jstring);
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess
+ * Method: removeElement
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_removeElement
+ (JNIEnv *, jobject, jstring, jstring);
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess
+ * Method: renameElement
+ * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_renameElement
+ (JNIEnv *, jobject, jstring, jstring, jstring);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/connectivity/source/inc/hsqldb/StorageNativeInputStream.h b/connectivity/source/inc/hsqldb/StorageNativeInputStream.h
new file mode 100644
index 000000000000..8f8beb511fca
--- /dev/null
+++ b/connectivity/source/inc/hsqldb/StorageNativeInputStream.h
@@ -0,0 +1,70 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream */
+
+#ifndef _Included_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+#define _Included_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+#ifdef __cplusplus
+extern "C" {
+#endif
+/* Inaccessible static: class_00024com_00024sun_00024star_00024sdbcx_00024comp_00024hsqldb_00024StorageNativeOutputStream */
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: openStream
+ * Signature: (Ljava/lang/String;Ljava/lang/String;I)V
+ */
+JNIEXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_openStream
+ (JNIEnv * env, jobject obj_this,jstring key, jstring name, jint);
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: read
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)I
+ */
+JNIEXPORT 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);
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: read
+ * Signature: (Ljava/lang/String;Ljava/lang/String;[BII)I
+ */
+JNIEXPORT 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, jint, jint);
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: close
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_close
+ (JNIEnv *, jobject, jstring, jstring);
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: skip
+ * Signature: (Ljava/lang/String;Ljava/lang/String;J)J
+ */
+JNIEXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_skip
+ (JNIEnv *, jobject, jstring, jstring, jlong);
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: available
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_available
+ (JNIEnv *, jobject, jstring, jstring);
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: read
+ * Signature: (Ljava/lang/String;Ljava/lang/String;[B)I
+ */
+JNIEXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2_3B
+ (JNIEnv *, jobject, jstring, jstring, jbyteArray);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/connectivity/source/inc/internalnode.hxx b/connectivity/source/inc/internalnode.hxx
new file mode 100644
index 000000000000..2f234f8d27b1
--- /dev/null
+++ b/connectivity/source/inc/internalnode.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_SQLINTERNALNODE_HXX
+#define _CONNECTIVITY_SQLINTERNALNODE_HXX
+
+#include "connectivity/dbtoolsdllapi.hxx"
+#include <connectivity/sqlnode.hxx>
+
+namespace connectivity
+{
+ //==========================================================================
+ //= OSQLInternalNode
+ //==========================================================================
+ /** special node for avoiding memory leaks
+ */
+ class OSQLInternalNode : public OSQLParseNode
+ {
+ public:
+ OSQLInternalNode(const sal_Char* pNewValue,
+ SQLNodeType eNodeType,
+ sal_uInt32 nNodeID = 0);
+ OSQLInternalNode(const ::rtl::OString& _rNewValue,
+ SQLNodeType eNodeType,
+ sal_uInt32 nNodeID = 0);
+ OSQLInternalNode(const sal_Unicode* pNewValue,
+ SQLNodeType eNodeType,
+ sal_uInt32 nNodeID = 0);
+ OSQLInternalNode(const ::rtl::OUString& _rNewValue,
+ SQLNodeType eNodeType,
+ sal_uInt32 nNodeID = 0);
+
+ virtual ~OSQLInternalNode();
+ };
+}
+
+#endif //_CONNECTIVITY_SQLINTERNALNODE_HXX
diff --git a/connectivity/source/inc/java/ContextClassLoader.hxx b/connectivity/source/inc/java/ContextClassLoader.hxx
new file mode 100644
index 000000000000..69df7c1b13cd
--- /dev/null
+++ b/connectivity/source/inc/java/ContextClassLoader.hxx
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_CONTEXTCLASSLOADER_HXX
+#define CONNECTIVITY_CONTEXTCLASSLOADER_HXX
+
+#include "java/GlobalRef.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+namespace comphelper
+{
+ class ResourceBasedEventLogger;
+}
+
+//........................................................................
+namespace connectivity { namespace jdbc
+{
+//........................................................................
+
+ //====================================================================
+ //= ContextClassLoaderScope
+ //====================================================================
+ /**
+ */
+ class ContextClassLoaderScope
+ {
+ public:
+ /** creates the instance. If isActive returns <FALSE/> afterwards, then an exception
+ happend in the JVM, which should be raised as UNO exception by the caller
+
+ @param environment
+ the current JNI environment
+ @param newClassLoader
+ the new class loader to set at the current thread
+ @param _rLoggerForErrors
+ the logger which should be passed to java_lang_object::ThrowLoggedSQLException in case
+ an error occurs
+ @param _rxErrorContext
+ the context which should be passed to java_lang_object::ThrowLoggedSQLException in case
+ an error occurs
+
+ */
+ ContextClassLoaderScope(
+ JNIEnv& environment,
+ const GlobalRef< jobject >& newClassLoader,
+ const ::comphelper::ResourceBasedEventLogger& _rLoggerForErrors,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxErrorContext
+ );
+
+ ~ContextClassLoaderScope() { pop(true); }
+
+ void pop() { pop(false); }
+
+ bool isActive() const
+ {
+ return ( m_currentThread.is() )
+ && ( m_setContextClassLoaderMethod != NULL );
+ }
+
+ private:
+ ContextClassLoaderScope(ContextClassLoaderScope &); // not defined
+ void operator =(ContextClassLoaderScope &); // not defined
+
+ void pop( bool clearExceptions );
+
+ JNIEnv& m_environment;
+ LocalRef< jobject > m_currentThread;
+ LocalRef< jobject > m_oldContextClassLoader;
+ jmethodID m_setContextClassLoaderMethod;
+ };
+
+
+//........................................................................
+} } // namespace connectivity::jdbc
+//........................................................................
+
+#endif // CONNECTIVITY_CONTEXTCLASSLOADER_HXX
diff --git a/connectivity/source/inc/java/GlobalRef.hxx b/connectivity/source/inc/java/GlobalRef.hxx
new file mode 100644
index 000000000000..98511037eeaa
--- /dev/null
+++ b/connectivity/source/inc/java/GlobalRef.hxx
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_GLOBALREF_HXX
+#define CONNECTIVITY_GLOBALREF_HXX
+
+#include "java/LocalRef.hxx"
+#include "java/lang/Object.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <jvmaccess/virtualmachine.hxx>
+
+//........................................................................
+namespace connectivity { namespace jdbc
+{
+//........................................................................
+
+ //====================================================================
+ //= GlobalRef
+ //====================================================================
+ /** helper class to hold a local ref to a JNI object
+ */
+ template< typename T >
+ class GlobalRef
+ {
+ public:
+ GlobalRef()
+ :m_object( NULL )
+ {
+ }
+
+ GlobalRef( const GlobalRef& _source )
+ :m_object( NULL )
+ {
+ *this = _source;
+ }
+
+ GlobalRef& operator=( const GlobalRef& _source )
+ {
+ if ( &_source == this )
+ return *this;
+
+ SDBThreadAttach t;
+ set( t.env(), _source.get() );
+ return *this;
+ }
+
+ ~GlobalRef()
+ {
+ reset();
+ }
+
+ void reset()
+ {
+ if ( m_object != NULL )
+ {
+ SDBThreadAttach t;
+ t.env().DeleteGlobalRef( m_object );
+ m_object = NULL;
+ }
+ }
+
+ void set( JNIEnv& _environment, T _object )
+ {
+ if ( m_object != NULL )
+ _environment.DeleteGlobalRef( m_object );
+ m_object = _object;
+ if ( m_object )
+ m_object = static_cast< T >( _environment.NewGlobalRef( m_object ) );
+ }
+
+ void set( LocalRef< T >& _object )
+ {
+ set( _object.env(), _object.release() );
+ }
+
+ T get() const
+ {
+ return m_object;
+ }
+
+ bool is() const
+ {
+ return m_object != NULL;
+ }
+
+ private:
+ T m_object;
+ };
+
+
+//........................................................................
+} } // namespace connectivity::jdbc
+//........................................................................
+
+#endif // CONNECTIVITY_GLOBALREF_HXX
diff --git a/connectivity/source/inc/java/LocalRef.hxx b/connectivity/source/inc/java/LocalRef.hxx
new file mode 100644
index 000000000000..888366b0bff2
--- /dev/null
+++ b/connectivity/source/inc/java/LocalRef.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_LOCALREF_HXX
+#define CONNECTIVITY_LOCALREF_HXX
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <jvmaccess/virtualmachine.hxx>
+
+//........................................................................
+namespace connectivity { namespace jdbc
+{
+//........................................................................
+
+ //====================================================================
+ //= LocalRef
+ //====================================================================
+ /** helper class to hold a local ref to a JNI object
+
+ Note that this class never actually calls NewLocalRef. It is assumed that all objects
+ passed are already acquired with a local ref (as it usually is the case if you obtain
+ the object from an JNI method).
+ */
+ template< typename T >
+ class LocalRef
+ {
+ public:
+ explicit LocalRef( JNIEnv& environment )
+ :m_environment( environment )
+ ,m_object( NULL )
+ {
+ }
+
+ LocalRef( JNIEnv& environment, T object )
+ :m_environment( environment )
+ ,m_object( object )
+ {
+ }
+
+ ~LocalRef()
+ {
+ reset();
+ }
+
+ T release()
+ {
+ T t = m_object;
+ m_object = NULL;
+ return t;
+ }
+
+ void set( T object ) { reset(); m_object = object; }
+
+ void reset()
+ {
+ if ( m_object != NULL )
+ {
+ m_environment.DeleteLocalRef( m_object );
+ m_object = NULL;
+ }
+ }
+
+ JNIEnv& env() const { return m_environment; }
+ T get() const { return m_object; }
+ bool is() const { return m_object != NULL; }
+
+ private:
+ LocalRef(LocalRef &); // not defined
+ void operator =(LocalRef &); // not defined
+
+ protected:
+ JNIEnv& m_environment;
+ T m_object;
+ };
+
+//........................................................................
+} } // namespace connectivity::jdbc
+//........................................................................
+
+#endif // CONNECTIVITY_LOCALREF_HXX
diff --git a/connectivity/source/inc/java/io/InputStream.hxx b/connectivity/source/inc/java/io/InputStream.hxx
new file mode 100644
index 000000000000..914d9ed3f263
--- /dev/null
+++ b/connectivity/source/inc/java/io/InputStream.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_JAVA_IO_INPUTSTREAM_HXX_
+#define _CONNECTIVITY_JAVA_IO_INPUTSTREAM_HXX_
+
+#include "java/lang/Object.hxx"
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/io/XInputStream.hpp>
+
+namespace connectivity
+{
+
+ //**************************************************************
+ //************ Class: java.io.InputStream
+ //**************************************************************
+ class java_io_InputStream : public java_lang_Object,
+ public ::cppu::WeakImplHelper1< ::com::sun::star::io::XInputStream>
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ virtual ~java_io_InputStream();
+ public:
+ virtual jclass getMyClass() const;
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_io_InputStream( JNIEnv * pEnv, jobject myObj );
+ // 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);
+ };
+}
+#endif // _CONNECTIVITY_JAVA_IO_INPUTSTREAM_HXX_
+
diff --git a/connectivity/source/inc/java/io/Reader.hxx b/connectivity/source/inc/java/io/Reader.hxx
new file mode 100644
index 000000000000..6e846fd2c295
--- /dev/null
+++ b/connectivity/source/inc/java/io/Reader.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_JAVA_IO_READER_HXX_
+#define _CONNECTIVITY_JAVA_IO_READER_HXX_
+
+#include "java/lang/Object.hxx"
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/io/XInputStream.hpp>
+
+namespace connectivity
+{
+ //**************************************************************
+ //************ Class: java.io.InputStream
+ //**************************************************************
+ class java_io_Reader : public java_lang_Object,
+ public ::cppu::WeakImplHelper1< ::com::sun::star::io::XInputStream>
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ virtual ~java_io_Reader();
+ public:
+ virtual jclass getMyClass() const;
+
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_io_Reader( JNIEnv * pEnv, jobject myObj );
+ // 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);
+ };
+}
+#endif // _CONNECTIVITY_JAVA_IO_READER_HXX_
+
diff --git a/connectivity/source/inc/java/lang/Boolean.hxx b/connectivity/source/inc/java/lang/Boolean.hxx
new file mode 100644
index 000000000000..35655f8c1934
--- /dev/null
+++ b/connectivity/source/inc/java/lang/Boolean.hxx
@@ -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_JAVA_LANG_BOOLEAN_HXX_
+#define _CONNECTIVITY_JAVA_LANG_BOOLEAN_HXX_
+
+#include "java/lang/Object.hxx"
+//**************************************************************
+//************ Class: java.lang.Boolean
+//**************************************************************
+namespace connectivity
+{
+ class java_lang_Boolean : public java_lang_Object
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ public:
+ virtual jclass getMyClass() const;
+ virtual ~java_lang_Boolean();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_lang_Boolean( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){}
+
+ static jclass st_getMyClass();
+ };
+}
+
+#endif // _CONNECTIVITY_JAVA_LANG_BOOLEAN_HXX_
+
+
diff --git a/connectivity/source/inc/java/lang/Class.hxx b/connectivity/source/inc/java/lang/Class.hxx
new file mode 100644
index 000000000000..b7a7182ae202
--- /dev/null
+++ b/connectivity/source/inc/java/lang/Class.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_JAVA_LANG_CLASS_HXX_
+#define _CONNECTIVITY_JAVA_LANG_CLASS_HXX_
+//**************************************************************
+//************ Class: java.lang.Class
+//**************************************************************
+#include "java/lang/Object.hxx"
+
+namespace connectivity
+{
+ class java_lang_Class : public java_lang_Object
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ public:
+ virtual jclass getMyClass() const;
+ virtual ~java_lang_Class();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_lang_Class( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){}
+
+ static java_lang_Class * forName( const ::rtl::OUString &_par0 );
+ // return the jre object
+ jobject newInstanceObject();
+
+ };
+}
+
+#endif // _CONNECTIVITY_JAVA_LANG_CLASS_HXX_
+
diff --git a/connectivity/source/inc/java/lang/Exception.hxx b/connectivity/source/inc/java/lang/Exception.hxx
new file mode 100644
index 000000000000..52261bfa255b
--- /dev/null
+++ b/connectivity/source/inc/java/lang/Exception.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_JAVA_LANG_EXCEPTION_HXX_
+#define _CONNECTIVITY_JAVA_LANG_EXCEPTION_HXX_
+
+#include "java/lang/Throwable.hxx"
+
+namespace connectivity
+{
+
+ //**************************************************************
+ //************ Class: java.lang.Exception
+ //**************************************************************
+ class java_lang_Exception : public java_lang_Throwable{
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ public:
+ virtual jclass getMyClass() const;
+ virtual ~java_lang_Exception();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_lang_Exception( JNIEnv * pEnv, jobject myObj ) : java_lang_Throwable( pEnv, myObj ){}
+
+ };
+}
+#endif // _CONNECTIVITY_JAVA_LANG_EXCEPTION_HXX_
+
diff --git a/connectivity/source/inc/java/lang/Object.hxx b/connectivity/source/inc/java/lang/Object.hxx
new file mode 100644
index 000000000000..c00c5e67e06d
--- /dev/null
+++ b/connectivity/source/inc/java/lang/Object.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_
+#define _CONNECTIVITY_JAVA_LANG_OBJECT_HXX_
+
+#if STLPORT_VERSION>=321
+// jni.h needs cstdarg for std::va_list
+#include <cstdarg>
+#endif
+#include <osl/thread.h>
+#include <com/sun/star/sdbc/SQLException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <osl/diagnose.h>
+#include <jvmaccess/virtualmachine.hxx>
+#include <memory>
+#include <functional>
+#include <boost/shared_ptr.hpp>
+
+//=====================================================================
+
+#ifdef HAVE_64BIT_POINTERS
+#error "no 64 bit pointer"
+#else
+#ifdef OS2
+#define PVOID_TO_INT64(x) (jlong)(sal_Int32)x
+#define INT64_TO_PVOID(x) (void *)x
+#endif // OS2
+#endif //HAVE_64BIT_POINTERS
+
+namespace comphelper
+{
+ class ResourceBasedEventLogger;
+}
+
+namespace connectivity
+{
+ typedef ::boost::shared_ptr< jvmaccess::VirtualMachine::AttachGuard> TGuard;
+ class SDBThreadAttach
+ {
+ jvmaccess::VirtualMachine::AttachGuard m_aGuard;
+ SDBThreadAttach(SDBThreadAttach&);
+ SDBThreadAttach& operator= (SDBThreadAttach&);
+ public:
+ SDBThreadAttach();
+ ~SDBThreadAttach();
+
+ JNIEnv* pEnv;
+ static void addRef();
+ static void releaseRef();
+
+ public:
+ JNIEnv& env() const
+ {
+ // according to the documentation of jvmaccess::VirtualMachine::AttachGuard, our env is never
+ // NULL, so why bothering with pointer checks?
+ return *pEnv;
+ }
+ };
+ //=====================================================================
+ //=====================================================================
+ class java_lang_Class;
+ class java_lang_Object
+ {
+ // Zuweisungsoperator und Copy Konstruktor sind verboten
+ java_lang_Object& operator= (java_lang_Object&);
+ java_lang_Object(java_lang_Object&);
+
+ // nur zum Zerstoeren des C++ Pointers in vom JSbxObject
+ // abgeleiteten Java Objekten
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
+
+ protected:
+ // der JAVA Handle zu dieser Klasse
+ jobject object;
+ // Klassendefinition
+
+ // neu in SJ2:
+ static jclass theClass; // die Klasse braucht nur einmal angefordert werden !
+
+ virtual jclass getMyClass() const;
+
+ public:
+ // der Konstruktor, der fuer die abgeleiteten Klassen verwendet
+ // werden soll.
+ java_lang_Object( JNIEnv * pEnv, jobject myObj );
+ // der eigentliche Konstruktor
+ java_lang_Object(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory=NULL);
+
+ virtual ~java_lang_Object();
+
+ void saveRef( JNIEnv * pEnv, jobject myObj );
+ jobject getJavaObject() const { return object; }
+ java_lang_Object * GetWrapper() { return this; }
+ void clearObject(JNIEnv& rEnv);
+ void clearObject();
+
+ virtual ::rtl::OUString toString() const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() { return m_xFactory; }
+
+ static void ThrowSQLException(JNIEnv * pEnv,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> & _rContext);
+ static void ThrowLoggedSQLException(
+ const ::comphelper::ResourceBasedEventLogger& _rLogger,
+ JNIEnv* pEnvironment,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext
+ );
+
+ static ::rtl::Reference< jvmaccess::VirtualMachine > getVM(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory=NULL);
+
+ static jclass findMyClass(const char* _pClassName);
+ void obtainMethodId(JNIEnv* _pEnv, const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID) const;
+
+ sal_Bool callBooleanMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const;
+ sal_Bool callBooleanMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const;
+ jobject callResultSetMethod( JNIEnv& _rEnv, const char* _pMethodName, jmethodID& _inout_MethodID ) const;
+ sal_Int32 callIntMethod( const char* _pMethodName, jmethodID& _inout_MethodID,bool _bIgnoreException = false ) const;
+ sal_Int32 callIntMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const;
+ sal_Int32 callIntMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID,const ::rtl::OUString& _nArgument ) const;
+ ::rtl::OUString callStringMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const;
+ ::rtl::OUString callStringMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const;
+ void callVoidMethod( const char* _pMethodName, jmethodID& _inout_MethodID) const;
+ void callVoidMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument,bool _bIgnoreException = false ) const;
+ void callVoidMethodWithBoolArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument,bool _bIgnoreException = false ) const;
+ void callVoidMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID, const ::rtl::OUString& _nArgument ) const;
+ jobject callObjectMethod( JNIEnv * pEnv, const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID ) const;
+ jobject callObjectMethodWithIntArg( JNIEnv * pEnv, const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const;
+
+ template< typename T >
+ T callMethodWithIntArg(T (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) ,const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const
+ {
+ SDBThreadAttach t;
+ obtainMethodId(t.pEnv, _pMethodName,_pSignature, _inout_MethodID);
+ T out = (t.pEnv->*pCallMethod)( object, _inout_MethodID,_nArgument);
+ ThrowSQLException( t.pEnv, NULL );
+ return out;
+ }
+
+ template< typename T >
+ void callVoidMethod(const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID,sal_Int32 _nArgument, const T& _aValue) const
+ {
+ SDBThreadAttach t;
+ obtainMethodId(t.pEnv, _pMethodName,_pSignature, _inout_MethodID);
+ t.pEnv->CallVoidMethod( object, _inout_MethodID,_nArgument,_aValue);
+ ThrowSQLException( t.pEnv, NULL );
+ }
+
+
+ };
+}
+#endif //_CONNECTIVITY_JAVA_LANG_OBJJECT_HXX_
+
+
diff --git a/connectivity/source/inc/java/lang/String.hxx b/connectivity/source/inc/java/lang/String.hxx
new file mode 100644
index 000000000000..3e4bfd6c1399
--- /dev/null
+++ b/connectivity/source/inc/java/lang/String.hxx
@@ -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_JAVA_LANG_STRING_HXX_
+#define _CONNECTIVITY_JAVA_LANG_STRING_HXX_
+
+#include "java/lang/Object.hxx"
+
+namespace connectivity
+{
+ class java_lang_String : public java_lang_Object
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ public:
+ virtual jclass getMyClass() const;
+ virtual ~java_lang_String();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_lang_String( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){}
+
+ operator ::rtl::OUString();
+
+ static jclass st_getMyClass();
+ };
+
+}
+
+#endif // _CONNECTIVITY_JAVA_LANG_STRING_HXX_
+
diff --git a/connectivity/source/inc/java/lang/Throwable.hxx b/connectivity/source/inc/java/lang/Throwable.hxx
new file mode 100644
index 000000000000..a5823c24b1d9
--- /dev/null
+++ b/connectivity/source/inc/java/lang/Throwable.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_JAVA_LANG_THROWABLE_HXX_
+#define _CONNECTIVITY_JAVA_LANG_THROWABLE_HXX_
+
+#include "java/lang/Object.hxx"
+
+namespace connectivity
+{
+ //**************************************************************
+ //************ Class: java.lang.Throwable
+ //**************************************************************
+ class java_lang_Throwable : public java_lang_Object
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ public:
+ virtual jclass getMyClass() const;
+ virtual ~java_lang_Throwable();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_lang_Throwable( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){}
+ ::rtl::OUString getMessage() const;
+ ::rtl::OUString getLocalizedMessage() const;
+
+ static jclass st_getMyClass();
+ };
+}
+#endif // _CONNECTIVITY_JAVA_LANG_THROWABLE_HXX_
+
diff --git a/connectivity/source/inc/java/math/BigDecimal.hxx b/connectivity/source/inc/java/math/BigDecimal.hxx
new file mode 100644
index 000000000000..ed6fbf8f814c
--- /dev/null
+++ b/connectivity/source/inc/java/math/BigDecimal.hxx
@@ -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_JAVA_MATH_BIGDECIMAL_HXX_
+#define _CONNECTIVITY_JAVA_MATH_BIGDECIMAL_HXX_
+
+#include "java/lang/Object.hxx"
+//**************************************************************
+//************ Class: java.lang.Boolean
+//**************************************************************
+namespace connectivity
+{
+ class java_math_BigDecimal : public java_lang_Object
+ {
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ public:
+ virtual jclass getMyClass() const;
+ virtual ~java_math_BigDecimal();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_math_BigDecimal( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){}
+
+ java_math_BigDecimal( const ::rtl::OUString& _par0 );
+ java_math_BigDecimal( const double& _par0 );
+ };
+}
+
+#endif // _CONNECTIVITY_JAVA_MATH_BIGDECIMAL_HXX_
+
+
diff --git a/connectivity/source/inc/java/sql/Array.hxx b/connectivity/source/inc/java/sql/Array.hxx
new file mode 100644
index 000000000000..1a4f4794e7ff
--- /dev/null
+++ b/connectivity/source/inc/java/sql/Array.hxx
@@ -0,0 +1,63 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_JAVA_SQL_ARRAY_HXX_
+#define _CONNECTIVITY_JAVA_SQL_ARRAY_HXX_
+
+#include "java/lang/Object.hxx"
+#include <com/sun/star/sdbc/XArray.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+namespace connectivity
+{
+
+ //**************************************************************
+ //************ Class: java.sql.SQLWarning
+ //**************************************************************
+ class java_sql_Array : public java_lang_Object,
+ public ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XArray>
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ public:
+ virtual jclass getMyClass() const;
+ virtual ~java_sql_Array();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_Array( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){}
+
+ // XArray
+ virtual ::rtl::OUString SAL_CALL getBaseTypeName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBaseType( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getArray( 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::Sequence< ::com::sun::star::uno::Any > SAL_CALL 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);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( 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::XResultSet > SAL_CALL 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);
+
+ };
+}
+#endif // _CONNECTIVITY_JAVA_SQL_ARRAY_HXX_
+
diff --git a/connectivity/source/inc/java/sql/Blob.hxx b/connectivity/source/inc/java/sql/Blob.hxx
new file mode 100644
index 000000000000..c0392447cbe0
--- /dev/null
+++ b/connectivity/source/inc/java/sql/Blob.hxx
@@ -0,0 +1,63 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_JAVA_SQL_BLOB_HXX_
+#define _CONNECTIVITY_JAVA_SQL_BLOB_HXX_
+
+#include "java/lang/Object.hxx"
+#include <com/sun/star/sdbc/XBlob.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+namespace connectivity
+{
+
+ //**************************************************************
+ //************ Class: java.sql.SQLWarning
+ //**************************************************************
+ class java_sql_Blob : public java_lang_Object,
+ public ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XBlob>
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ virtual ~java_sql_Blob();
+ public:
+ virtual jclass getMyClass() const;
+
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_Blob( JNIEnv * pEnv, jobject myObj );
+
+ // XBlob
+ virtual sal_Int64 SAL_CALL length( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int64 pos, sal_Int32 length ) 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( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL position( const ::com::sun::star::uno::Sequence< sal_Int8 >& pattern, sal_Int64 start ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL 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);
+ };
+}
+#endif // _CONNECTIVITY_JAVA_SQL_BLOB_HXX_
+
diff --git a/connectivity/source/inc/java/sql/CallableStatement.hxx b/connectivity/source/inc/java/sql/CallableStatement.hxx
new file mode 100644
index 000000000000..1e7cde631096
--- /dev/null
+++ b/connectivity/source/inc/java/sql/CallableStatement.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef _CONNECTIVITY_JAVA_SQL_CALLABLESTATEMENT_HXX_
+#define _CONNECTIVITY_JAVA_SQL_CALLABLESTATEMENT_HXX_
+
+#include "java/sql/PreparedStatement.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XOutParameters.hpp>
+
+namespace connectivity
+{
+
+ //**************************************************************
+ //************ Class: java.sql.CallableStatement
+ //**************************************************************
+
+ class java_sql_CallableStatement : public java_sql_PreparedStatement,
+ public ::com::sun::star::sdbc::XRow,
+ public ::com::sun::star::sdbc::XOutParameters
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ virtual void createStatement(JNIEnv* _pEnv);
+
+ virtual ~java_sql_CallableStatement();
+ public:
+ DECLARE_SERVICE_INFO();
+ virtual jclass getMyClass() const;
+
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_CallableStatement( JNIEnv * pEnv, java_sql_Connection& _rCon, const ::rtl::OUString& sql );
+
+ 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);
+
+ // 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);
+ // XOutParameters
+ virtual void SAL_CALL registerOutParameter( 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 registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+}
+#endif // _CONNECTIVITY_JAVA_SQL_CALLABLESTATEMENT_HXX_
+
diff --git a/connectivity/source/inc/java/sql/Clob.hxx b/connectivity/source/inc/java/sql/Clob.hxx
new file mode 100644
index 000000000000..e8c9b92b5f16
--- /dev/null
+++ b/connectivity/source/inc/java/sql/Clob.hxx
@@ -0,0 +1,63 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_JAVA_SQL_CLOB_HXX_
+#define _CONNECTIVITY_JAVA_SQL_CLOB_HXX_
+
+#include "java/lang/Object.hxx"
+#include <com/sun/star/sdbc/XClob.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+namespace connectivity
+{
+
+ //**************************************************************
+ //************ Class: java.sql.SQLWarning
+ //**************************************************************
+ class java_sql_Clob : public java_lang_Object,
+ public ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XClob>
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ virtual ~java_sql_Clob();
+ public:
+ virtual jclass getMyClass() const;
+
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_Clob( JNIEnv * pEnv, jobject myObj );
+
+ // XClob
+ virtual sal_Int64 SAL_CALL length( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSubString( sal_Int64 pos, sal_Int32 length ) 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( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL position( const ::rtl::OUString& searchstr, sal_Int32 start ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL 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);
+ };
+}
+#endif // _CONNECTIVITY_JAVA_SQL_CLOB_HXX_
+
diff --git a/connectivity/source/inc/java/sql/Connection.hxx b/connectivity/source/inc/java/sql/Connection.hxx
new file mode 100644
index 000000000000..b0b20c0e32d3
--- /dev/null
+++ b/connectivity/source/inc/java/sql/Connection.hxx
@@ -0,0 +1,151 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_JAVA_SQL_CONNECTION_HXX_
+#define _CONNECTIVITY_JAVA_SQL_CONNECTION_HXX_
+
+#include "java/lang/Object.hxx"
+#include "TConnection.hxx"
+#include "connectivity/CommonTools.hxx"
+#include "OSubComponent.hxx"
+#include <cppuhelper/weakref.hxx>
+#include "AutoRetrievingBase.hxx"
+#include "java/sql/ConnectionLog.hxx"
+#include "java/LocalRef.hxx"
+#include "java/GlobalRef.hxx"
+
+#include <com/sun/star/beans/NamedValue.hpp>
+
+namespace connectivity
+{
+ class java_sql_Driver;
+
+ typedef OMetaConnection java_sql_Connection_BASE;
+
+ class java_sql_Connection : public java_sql_Connection_BASE,
+ public java_lang_Object,
+ public OSubComponent<java_sql_Connection, java_sql_Connection_BASE>,
+ public OAutoRetrievingBase
+ {
+ friend class OSubComponent<java_sql_Connection, java_sql_Connection_BASE>;
+ const java_sql_Driver* m_pDriver;
+ jobject m_pDriverobject;
+ jdbc::GlobalRef< jobject >
+ m_pDriverClassLoader;
+
+ jclass m_Driver_theClass;
+ java::sql::ConnectionLog
+ m_aLogger;
+ sal_Bool m_bParameterSubstitution;
+ sal_Bool m_bIgnoreDriverPrivileges;
+ sal_Bool m_bIgnoreCurrency;
+ ::com::sun::star::uno::Any m_aCatalogRestriction;
+ ::com::sun::star::uno::Any m_aSchemaRestriction;
+
+ /** transform named parameter into unnamed one.
+ @param _sSQL
+ The SQL statement to transform.
+ @return
+ The new statement witgh unnamed parameters.
+ */
+ ::rtl::OUString transFormPreparedStatement(const ::rtl::OUString& _sSQL);
+ void loadDriverFromProperties(
+ const ::rtl::OUString& _sDriverClass,
+ const ::rtl::OUString& _sDriverClassPath,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& _rSystemProperties
+ );
+ /** load driver class path from system configuration.
+ @param _sDriverClass
+ The driver class name to look for in the configuration.
+ */
+ ::rtl::OUString impl_getJavaDriverClassPath_nothrow(const ::rtl::OUString& _sDriverClass);
+
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+
+ virtual ~java_sql_Connection();
+
+ public:
+ virtual jclass getMyClass() const;
+
+ DECLARE_SERVICE_INFO();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_Connection( const java_sql_Driver& _rDriver );
+ sal_Bool construct( const ::rtl::OUString& url,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info);
+
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >&
+ getConnectionInfo() const { return m_aConnectionInfo; }
+
+ inline sal_Bool isIgnoreDriverPrivilegesEnabled() const { return m_bIgnoreDriverPrivileges;}
+ inline sal_Bool isIgnoreCurrencyEnabled() const { return m_bIgnoreCurrency; }
+ inline const ::com::sun::star::uno::Any& getCatalogRestriction() const { return m_aCatalogRestriction; }
+ inline const ::com::sun::star::uno::Any& getSchemaRestriction() const { return m_aSchemaRestriction; }
+
+ /** returns the instance used for logging events related to this connection
+ */
+ const java::sql::ConnectionLog& getLogger() const { return m_aLogger; }
+
+ /** returns the class loader which was used to load the driver class
+
+ Usually used in conjunction with a ContextClassLoaderScope instance.
+ */
+ const jdbc::GlobalRef< jobject >& getDriverClassLoader() const { return m_pDriverClassLoader; }
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XInterface
+ virtual void SAL_CALL release() throw();
+
+ // 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);
+ };
+}
+#endif // _CONNECTIVITY_JAVA_SQL_CONNECTION_HXX_
+
diff --git a/connectivity/source/inc/java/sql/ConnectionLog.hxx b/connectivity/source/inc/java/sql/ConnectionLog.hxx
new file mode 100644
index 000000000000..69cc8f392da2
--- /dev/null
+++ b/connectivity/source/inc/java/sql/ConnectionLog.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_CONNECTIONLOG_HXX
+#define CONNECTIVITY_CONNECTIONLOG_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/logging/LogLevel.hpp>
+/** === end UNO includes === **/
+
+#include <rtl/ustring.hxx>
+
+// Strange enough, GCC requires the following forward declarations of the various
+// convertLogArgToString flavors to be *before* the inclusion of comphelper/logging.hxx
+
+namespace com { namespace sun { namespace star { namespace util
+{
+ struct Date;
+ struct Time;
+ struct DateTime;
+} } } }
+
+//........................................................................
+namespace comphelper { namespace log { namespace convert
+{
+//........................................................................
+
+ // helpers for logging more data types than are defined in comphelper/logging.hxx
+ ::rtl::OUString convertLogArgToString( const ::com::sun::star::util::Date& _rDate );
+ ::rtl::OUString convertLogArgToString( const ::com::sun::star::util::Time& _rTime );
+ ::rtl::OUString convertLogArgToString( const ::com::sun::star::util::DateTime& _rDateTime );
+
+//........................................................................
+} } }
+//........................................................................
+
+#include <comphelper/logging.hxx>
+
+namespace connectivity
+{
+ namespace LogLevel = ::com::sun::star::logging::LogLevel;
+}
+
+//........................................................................
+namespace connectivity { namespace java { namespace sql {
+//........................................................................
+
+ //====================================================================
+ //= ConnectionLog
+ //====================================================================
+ typedef ::comphelper::ResourceBasedEventLogger ConnectionLog_Base;
+ class ConnectionLog : public ConnectionLog_Base
+ {
+ public:
+ enum ObjectType
+ {
+ CONNECTION = 0,
+ STATEMENT,
+ RESULTSET,
+
+ ObjectTypeCount = RESULTSET + 1
+ };
+
+ private:
+ const sal_Int32 m_nObjectID;
+
+ public:
+ /// will construct an instance of ObjectType CONNECTION
+ ConnectionLog( const ::comphelper::ResourceBasedEventLogger& _rDriverLog );
+ /// will create an instance with the same object ID / ObjectType as a given source instance
+ ConnectionLog( const ConnectionLog& _rSourceLog );
+ /// will create an instance of arbitrary ObjectType
+ ConnectionLog( const ConnectionLog& _rSourceLog, ObjectType _eType );
+
+ sal_Int32 getObjectID() const { return m_nObjectID; }
+
+ /// logs a given message, without any arguments, or source class/method names
+ bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID )
+ {
+ return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID );
+ }
+
+ template< typename ARGTYPE1 >
+ bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1 ) const
+ {
+ return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1 );
+ }
+
+ template< typename ARGTYPE1, typename ARGTYPE2 >
+ bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2 ) const
+ {
+ return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1, _argument2 );
+ }
+
+ template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3 >
+ bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3 ) const
+ {
+ return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1, _argument2, _argument3 );
+ }
+
+ template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4 >
+ bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4 ) const
+ {
+ return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1, _argument2, _argument3, _argument4 );
+ }
+
+ template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5 >
+ bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5 ) const
+ {
+ return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1, _argument2, _argument3, _argument4, _argument5 );
+ }
+ };
+
+//........................................................................
+} } } // namespace connectivity::java::sql
+//........................................................................
+
+#endif // CONNECTIVITY_CONNECTIONLOG_HXX
diff --git a/connectivity/source/inc/java/sql/DatabaseMetaData.hxx b/connectivity/source/inc/java/sql/DatabaseMetaData.hxx
new file mode 100644
index 000000000000..a517194f4ca8
--- /dev/null
+++ b/connectivity/source/inc/java/sql/DatabaseMetaData.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_JAVA_SQL_DATABASEMETADATA_HXX_
+#define _CONNECTIVITY_JAVA_SQL_DATABASEMETADATA_HXX_
+
+#include "java/lang/Object.hxx"
+#include "TDatabaseMetaDataBase.hxx"
+
+#include "java/sql/ConnectionLog.hxx"
+
+namespace connectivity
+{
+ class java_sql_Connection;
+ //**************************************************************
+ //************ Class: java.sql.DatabaseMetaDataDate
+ //**************************************************************
+
+ class java_sql_DatabaseMetaData : public ODatabaseMetaDataBase,
+ public java_lang_Object
+ {
+ java_sql_Connection* m_pConnection;
+ java::sql::ConnectionLog m_aLogger;
+
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+
+ public:
+ virtual jclass getMyClass() const;
+ virtual ~java_sql_DatabaseMetaData();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_DatabaseMetaData( JNIEnv * pEnv, jobject myObj, java_sql_Connection& _rConnection );
+
+ 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( );
+
+ 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 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 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);
+
+ private:
+ sal_Bool impl_callBooleanMethod( const char* _pMethodName, jmethodID& _inout_MethodID );
+ ::rtl::OUString impl_callStringMethod( const char* _pMethodName, jmethodID& _inout_MethodID );
+ sal_Int32 impl_callIntMethod( const char* _pMethodName, jmethodID& _inout_MethodID );
+ sal_Bool impl_callBooleanMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument );
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >
+ impl_callResultSetMethod( const char* _pMethodName, jmethodID& _inout_MethodID );
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >
+ impl_callResultSetMethodWithStrings( const char* _pMethodName, jmethodID& _inout_MethodID, const ::com::sun::star::uno::Any& _rCatalog,
+ const ::rtl::OUString& _rSchemaPattern, const ::rtl::OUString& _rLeastPattern,
+ const ::rtl::OUString* _pOptionalAdditionalString = NULL);
+ };
+}
+#endif // _CONNECTIVITY_JAVA_SQL_DATABASEMETADATA_HXX_
+
diff --git a/connectivity/source/inc/java/sql/Driver.hxx b/connectivity/source/inc/java/sql/Driver.hxx
new file mode 100644
index 000000000000..4d148f5d752c
--- /dev/null
+++ b/connectivity/source/inc/java/sql/Driver.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_JAVA_SQL_DRIVER_HXX_
+#define _CONNECTIVITY_JAVA_SQL_DRIVER_HXX_
+
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include "java/lang/Object.hxx"
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include <comphelper/logging.hxx>
+#include <comphelper/componentcontext.hxx>
+
+namespace connectivity
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL java_sql_Driver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception );
+
+ class java_sql_Driver : public ::cppu::WeakImplHelper2< ::com::sun::star::sdbc::XDriver,::com::sun::star::lang::XServiceInfo>
+ {
+ ::comphelper::ComponentContext m_aContext;
+ ::comphelper::ResourceBasedEventLogger m_aLogger;
+
+ protected:
+ virtual ~java_sql_Driver();
+
+ public:
+ java_sql_Driver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+
+ 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 ::comphelper::ComponentContext& getContext() const { return m_aContext; }
+ const ::comphelper::ResourceBasedEventLogger& getLogger() const { return m_aLogger; }
+ };
+
+}
+#endif //_CONNECTIVITY_JAVA_SQL_DRIVER_HXX_
+
diff --git a/connectivity/source/inc/java/sql/DriverPropertyInfo.hxx b/connectivity/source/inc/java/sql/DriverPropertyInfo.hxx
new file mode 100644
index 000000000000..b04e090666a2
--- /dev/null
+++ b/connectivity/source/inc/java/sql/DriverPropertyInfo.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_JAVA_SQL_DRIVERPOPERTYINFO_HXX_
+#define _CONNECTIVITY_JAVA_SQL_DRIVERPOPERTYINFO_HXX_
+
+#include "java/lang/Object.hxx"
+#include <com/sun/star/sdbc/DriverPropertyInfo.hpp>
+
+namespace connectivity
+{
+
+//**************************************************************
+//************ Class: java.sql.DriverPropertyInfo
+//**************************************************************
+ class java_sql_DriverPropertyInfo : public java_lang_Object
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ public:
+ virtual jclass getMyClass() const;
+ virtual ~java_sql_DriverPropertyInfo();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_DriverPropertyInfo( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){}
+ operator ::com::sun::star::sdbc::DriverPropertyInfo();
+
+ ::rtl::OUString name();
+ ::rtl::OUString description();
+ ::rtl::OUString value();
+ sal_Bool required();
+ ::com::sun::star::uno::Sequence< ::rtl::OUString> choices();
+ };
+}
+
+#endif // _CONNECTIVITY_JAVA_SQL_DRIVERPOPERTYINFO_HXX_
+
diff --git a/connectivity/source/inc/java/sql/JStatement.hxx b/connectivity/source/inc/java/sql/JStatement.hxx
new file mode 100644
index 000000000000..c58494fb8036
--- /dev/null
+++ b/connectivity/source/inc/java/sql/JStatement.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef _CONNECTIVITY_JAVA_SQL_STATEMENT_HXX_
+#define _CONNECTIVITY_JAVA_SQL_STATEMENT_HXX_
+
+#include "java/lang/Object.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/XBatchExecution.hpp>
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
+#include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
+#include <comphelper/proparrhlp.hxx>
+#include <cppuhelper/compbase6.hxx>
+#include <comphelper/uno3.hxx>
+#include "connectivity/CommonTools.hxx"
+#include "OSubComponent.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <comphelper/broadcasthelper.hxx>
+
+#include "java/sql/ConnectionLog.hxx"
+
+namespace connectivity
+{
+
+ typedef ::cppu::WeakComponentImplHelper6< ::com::sun::star::sdbc::XStatement,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::util::XCancellable,
+ ::com::sun::star::sdbc::XCloseable,
+ ::com::sun::star::sdbc::XGeneratedResultSet,
+ ::com::sun::star::sdbc::XMultipleResults> java_sql_Statement_BASE;
+
+ class java_sql_Connection;
+
+ //**************************************************************
+ //************ Class: java.sql.Statement
+ //**************************************************************
+ class java_sql_Statement_Base : public comphelper::OBaseMutex,
+ public java_sql_Statement_BASE,
+ public java_lang_Object,
+ public ::cppu::OPropertySetHelper,
+ public ::comphelper::OPropertyArrayUsageHelper<java_sql_Statement_Base>
+
+ {
+
+ sal_Int32 getQueryTimeOut() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getMaxFieldSize() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getMaxRows() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getResultSetConcurrency() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getResultSetType() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getFetchDirection() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getFetchSize() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ ::rtl::OUString getCursorName() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ void setQueryTimeOut(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setMaxFieldSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setMaxRows(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setResultSetConcurrency(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setResultSetType(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setCursorName(const ::rtl::OUString &_par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setEscapeProcessing(sal_Bool _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement> m_xGeneratedStatement;
+ java_sql_Connection* m_pConnection;
+ java::sql::ConnectionLog m_aLogger;
+ ::rtl::OUString m_sSqlStatement;
+ // Properties
+ sal_Int32 m_nResultSetConcurrency;
+ sal_Int32 m_nResultSetType;
+ sal_Bool m_bEscapeProcessing;
+ ::cppu::OBroadcastHelper& rBHelper;
+
+
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+
+ // 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 createStatement(JNIEnv* _pEnv) = 0;
+
+ virtual ~java_sql_Statement_Base();
+
+ sal_Int32 impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID);
+ sal_Int32 impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nDefault);
+
+ public:
+ virtual jclass getMyClass() const;
+
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_Statement_Base( JNIEnv * pEnv, java_sql_Connection& _rCon );
+
+ sal_Int32 getStatementObjectID() const { return m_aLogger.getObjectID(); }
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XInterface
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() 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);
+ // 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);
+ //XGeneratedResultSet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getGeneratedValues( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ public:
+ using ::cppu::OPropertySetHelper::getFastPropertyValue;
+ };
+
+ class OStatement_BASE2 :public java_sql_Statement_Base
+ ,public OSubComponent<OStatement_BASE2, java_sql_Statement_BASE>
+
+ {
+ friend class OSubComponent<OStatement_BASE2, java_sql_Statement_BASE>;
+ public:
+ OStatement_BASE2(JNIEnv * pEnv, java_sql_Connection& _rCon ) : java_sql_Statement_Base( pEnv, _rCon ),
+ OSubComponent<OStatement_BASE2, java_sql_Statement_BASE>((::cppu::OWeakObject*)(&_rCon), this){}
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XInterface
+ virtual void SAL_CALL release() throw();
+ };
+
+ class java_sql_Statement : public OStatement_BASE2,
+ public ::com::sun::star::sdbc::XBatchExecution,
+ public ::com::sun::star::lang::XServiceInfo
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+
+ virtual void createStatement(JNIEnv* _pEnv);
+
+ virtual ~java_sql_Statement();
+ public:
+ DECLARE_SERVICE_INFO();
+ virtual jclass getMyClass() const;
+
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_Statement( JNIEnv * pEnv, java_sql_Connection& _rCon ) : OStatement_BASE2( pEnv, _rCon){};
+
+ 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();
+ // XBatchExecution
+ virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+}
+#endif // _CONNECTIVITY_JAVA_SQL_STATEMENT_HXX_
+
diff --git a/connectivity/source/inc/java/sql/PreparedStatement.hxx b/connectivity/source/inc/java/sql/PreparedStatement.hxx
new file mode 100644
index 000000000000..994b0996f60c
--- /dev/null
+++ b/connectivity/source/inc/java/sql/PreparedStatement.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_JAVA_SQL_PREPAREDSTATEMENT_HXX_
+#define _CONNECTIVITY_JAVA_SQL_PREPAREDSTATEMENT_HXX_
+
+#include "java/sql/JStatement.hxx"
+#include <com/sun/star/sdbc/XPreparedStatement.hpp>
+#include <com/sun/star/sdbc/XParameters.hpp>
+// #include <com/sun/star/sdbc/XClearParameters.hpp>
+#include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+namespace connectivity
+{
+ //**************************************************************
+ //************ Class: java.sql.PreparedStatement
+ //**************************************************************
+
+ class java_sql_PreparedStatement : public OStatement_BASE2,
+ public ::com::sun::star::sdbc::XPreparedStatement,
+ public ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ public ::com::sun::star::sdbc::XParameters,
+ public ::com::sun::star::sdbc::XPreparedBatchExecution,
+ public ::com::sun::star::lang::XServiceInfo
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+
+ virtual void createStatement(JNIEnv* _pEnv);
+ virtual ~java_sql_PreparedStatement();
+ public:
+ DECLARE_SERVICE_INFO();
+ virtual jclass getMyClass() const;
+
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_PreparedStatement( JNIEnv * pEnv, java_sql_Connection& _rCon,const ::rtl::OUString& sql );
+
+ 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);
+ // XPreparedBatchExecution
+ virtual void SAL_CALL addBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) 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);
+
+ public:
+ using java_sql_Statement_Base::executeQuery;
+ using java_sql_Statement_Base::executeUpdate;
+ using java_sql_Statement_Base::execute;
+ };
+}
+#endif // _CONNECTIVITY_JAVA_SQL_PREPAREDSTATEMENT_HXX_
+
diff --git a/connectivity/source/inc/java/sql/Ref.hxx b/connectivity/source/inc/java/sql/Ref.hxx
new file mode 100644
index 000000000000..7f9d2848fc5a
--- /dev/null
+++ b/connectivity/source/inc/java/sql/Ref.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_JAVA_SQL_REF_HXX_
+#define _CONNECTIVITY_JAVA_SQL_REF_HXX_
+
+#include "java/lang/Object.hxx"
+#include <com/sun/star/sdbc/XRef.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+namespace connectivity
+{
+ //**************************************************************
+ //************ Class: java.sql.Ref
+ //**************************************************************
+ class java_sql_Ref : public java_lang_Object,
+ public ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XRef>
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ virtual ~java_sql_Ref();
+ public:
+ virtual jclass getMyClass() const;
+
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_Ref( JNIEnv * pEnv, jobject myObj );
+
+ // XRef
+ virtual ::rtl::OUString SAL_CALL getBaseTypeName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+}
+#endif // _CONNECTIVITY_JAVA_SQL_REF_HXX_
+
diff --git a/connectivity/source/inc/java/sql/ResultSet.hxx b/connectivity/source/inc/java/sql/ResultSet.hxx
new file mode 100644
index 000000000000..1cac80ad10a8
--- /dev/null
+++ b/connectivity/source/inc/java/sql/ResultSet.hxx
@@ -0,0 +1,208 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_JAVA_SQL_RESULTSET_HXX_
+#define _CONNECTIVITY_JAVA_SQL_RESULTSET_HXX_
+
+#include "java/lang/Object.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 <cppuhelper/compbase10.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include "connectivity/CommonTools.hxx"
+#include "java/sql/JStatement.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include "java/sql/ConnectionLog.hxx"
+
+namespace connectivity
+{
+
+ /*
+ ** java_sql_ResultSet
+ */
+ typedef ::cppu::WeakComponentImplHelper10< ::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::sdbc::XCloseable,
+ ::com::sun::star::sdbc::XColumnLocate,
+ ::com::sun::star::lang::XServiceInfo> java_sql_ResultSet_BASE;
+
+ class java_sql_Connection;
+ class java_sql_ResultSet : public comphelper::OBaseMutex,
+ public java_sql_ResultSet_BASE,
+ public java_lang_Object,
+ public ::cppu::OPropertySetHelper,
+ public ::comphelper::OPropertyArrayUsageHelper<java_sql_ResultSet>
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData;
+ java::sql::ConnectionLog m_aLogger;
+ java_sql_Connection* m_pConnection;
+
+ sal_Int32 getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ ::rtl::OUString getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ void setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+
+ // 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 ~java_sql_ResultSet();
+ public:
+ DECLARE_SERVICE_INFO();
+ virtual jclass getMyClass() const;
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_ResultSet( JNIEnv * pEnv, jobject myObj, const java::sql::ConnectionLog& _rParentLogger,java_sql_Connection& _rConnection,
+ java_sql_Statement_Base* pStmt = NULL );
+
+ // ::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);
+ // 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);
+
+ public:
+ using ::cppu::OPropertySetHelper::getFastPropertyValue;
+ };
+}
+#endif // _CONNECTIVITY_JAVA_SQL_RESULTSET_HXX_
+
diff --git a/connectivity/source/inc/java/sql/ResultSetMetaData.hxx b/connectivity/source/inc/java/sql/ResultSetMetaData.hxx
new file mode 100644
index 000000000000..553065991d7e
--- /dev/null
+++ b/connectivity/source/inc/java/sql/ResultSetMetaData.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef _CONNECTIVITY_JAVA_SQL_RESULTSETMETADATA_HXX_
+#define _CONNECTIVITY_JAVA_SQL_RESULTSETMETADATA_HXX_
+
+#include "java/lang/Object.hxx"
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include "java/sql/ConnectionLog.hxx"
+
+namespace connectivity
+{
+ //**************************************************************
+ //************ Class: java.sql.ResultSetMetaData
+ //**************************************************************
+ class java_sql_Connection;
+ class java_sql_ResultSetMetaData : public ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData>,
+ public java_lang_Object
+ {
+ protected:
+ java::sql::ConnectionLog m_aLogger;
+ java_sql_Connection* m_pConnection;
+ sal_Int32 m_nColumnCount;
+
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ virtual ~java_sql_ResultSetMetaData();
+ public:
+ virtual jclass getMyClass() const;
+
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_ResultSetMetaData( JNIEnv * pEnv, jobject myObj, const java::sql::ConnectionLog& _rResultSetLogger, java_sql_Connection& _rCon );
+
+ 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_JAVA_SQL_RESULTSETMETADATA_HXX_
+
diff --git a/connectivity/source/inc/java/sql/SQLException.hxx b/connectivity/source/inc/java/sql/SQLException.hxx
new file mode 100644
index 000000000000..5a346edda84f
--- /dev/null
+++ b/connectivity/source/inc/java/sql/SQLException.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_JAVA_SQL_SQLEXCEPTION_HXX_
+#define _CONNECTIVITY_JAVA_SQL_SQLEXCEPTION_HXX_
+
+#include "java/lang/Exception.hxx"
+#include <com/sun/star/sdbc/SQLException.hpp>
+
+namespace connectivity
+{
+ namespace starsdbc = ::com::sun::star::sdbc;
+ //**************************************************************
+ //************ Class: java.sql.SQLException
+ //**************************************************************
+ class java_sql_SQLException_BASE;
+ class java_sql_SQLException : public starsdbc::SQLException
+ {
+ public:
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_SQLException(){}
+ java_sql_SQLException( const java_sql_SQLException_BASE& _rException,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> & _rContext);
+ };
+
+ class java_sql_SQLException_BASE : public java_lang_Exception
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ public:
+ virtual jclass getMyClass() const;
+ virtual ~java_sql_SQLException_BASE();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_SQLException_BASE( JNIEnv * pEnv, jobject myObj );
+
+ ::rtl::OUString getSQLState() const;
+ sal_Int32 getErrorCode() const;
+ starsdbc::SQLException getNextException() const;
+
+ static jclass st_getMyClass();
+ };
+
+}
+#endif // _CONNECTIVITY_JAVA_SQL_SQLEXCEPTION_HXX_
+
diff --git a/connectivity/source/inc/java/sql/SQLWarning.hxx b/connectivity/source/inc/java/sql/SQLWarning.hxx
new file mode 100644
index 000000000000..60b74c3a0151
--- /dev/null
+++ b/connectivity/source/inc/java/sql/SQLWarning.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_JAVA_SQL_SQLWARNING_HXX_
+#define _CONNECTIVITY_JAVA_SQL_SQLWARNING_HXX_
+
+#include "java/sql/SQLException.hxx"
+//#ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_
+//#include <com/sun/star/sdbc/SQLWarning.hpp>
+//#endif
+
+namespace connectivity
+{
+ // namespace starsdbc = ::com::sun::star::sdbc;
+ // namespace ::com::sun::star::uno = ::com::sun::star::uno;
+ //**************************************************************
+ //************ Class: java.sql.SQLWarning
+ //**************************************************************
+ class java_sql_SQLWarning_BASE : public java_sql_SQLException_BASE
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ public:
+ virtual jclass getMyClass() const;
+ virtual ~java_sql_SQLWarning_BASE();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_SQLWarning_BASE( JNIEnv * pEnv, jobject myObj ) : java_sql_SQLException_BASE( pEnv, myObj ){}
+
+ };
+
+ class java_sql_SQLWarning : public java_sql_SQLException
+ {
+ public:
+ java_sql_SQLWarning(const java_sql_SQLWarning_BASE& _rW,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> & _rContext)
+ : java_sql_SQLException(_rW,_rContext) {}
+ };
+}
+#endif // _CONNECTIVITY_JAVA_SQL_SQLWARNING_HXX_
+
diff --git a/connectivity/source/inc/java/sql/Timestamp.hxx b/connectivity/source/inc/java/sql/Timestamp.hxx
new file mode 100644
index 000000000000..de642014ee1c
--- /dev/null
+++ b/connectivity/source/inc/java/sql/Timestamp.hxx
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_JAVA_SQL_TIMESTAMP_HXX_
+#define _CONNECTIVITY_JAVA_SQL_TIMESTAMP_HXX_
+
+#include "java/util/Date.hxx"
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+
+
+namespace connectivity
+{
+ //**************************************************************
+ //************ Class: java.sql.Date
+ //**************************************************************
+
+ class java_sql_Date : public java_util_Date
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ public:
+ virtual jclass getMyClass() const;
+ virtual ~java_sql_Date();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_Date( JNIEnv * pEnv, jobject myObj ) : java_util_Date(pEnv,myObj){}
+ java_sql_Date( const ::com::sun::star::util::Date& _rOut );
+
+ operator ::com::sun::star::util::Date();
+ static jclass st_getMyClass();
+ };
+
+
+ //**************************************************************
+ //************ Class: java.sql.Time
+ //**************************************************************
+
+ class java_sql_Time : public java_util_Date
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ public:
+ virtual jclass getMyClass() const;
+ virtual ~java_sql_Time();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_Time( JNIEnv * pEnv, jobject myObj ) : java_util_Date( pEnv, myObj ){}
+ java_sql_Time( const ::com::sun::star::util::Time& _rOut );
+ operator ::com::sun::star::util::Time();
+ static jclass st_getMyClass();
+ };
+
+ //**************************************************************
+ //************ Class: java.sql.Timestamp
+ //**************************************************************
+ class java_sql_Timestamp : public java_util_Date
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ public:
+ virtual jclass getMyClass() const;
+ virtual ~java_sql_Timestamp();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_sql_Timestamp( JNIEnv * pEnv, jobject myObj ) : java_util_Date( pEnv, myObj ){}
+ java_sql_Timestamp( const ::com::sun::star::util::DateTime& _rOut);
+ operator ::com::sun::star::util::DateTime();
+
+ sal_Int32 getNanos();
+ void setNanos(sal_Int32 n);
+ static jclass st_getMyClass();
+ };
+}
+#endif // _CONNECTIVITY_JAVA_SQL_TIMESTAMP_HXX_
+
diff --git a/connectivity/source/inc/java/tools.hxx b/connectivity/source/inc/java/tools.hxx
new file mode 100644
index 000000000000..66f339247dfc
--- /dev/null
+++ b/connectivity/source/inc/java/tools.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_JAVA_TOOLS_HXX_
+#define _CONNECTIVITY_JAVA_TOOLS_HXX_
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/uno/Sequence.h>
+
+#ifndef JNI_H
+#include <jni.h>
+#endif
+#include "java/sql/SQLException.hxx"
+#include <comphelper/uno3.hxx>
+
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+
+
+namespace connectivity
+{
+
+ jstring convertwchar_tToJavaString(JNIEnv *pEnv,const ::rtl::OUString& _Temp);
+ ::rtl::OUString JavaString2String(JNIEnv *pEnv,jstring _Str);
+ class java_util_Properties;
+
+ java_util_Properties* createStringPropertyArray(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ template<class T,class JT> ::com::sun::star::uno::Sequence< T > copyArrayAndDelete(JNIEnv *pEnv,jobjectArray _Array, const T*, const JT* )
+ {
+ ::com::sun::star::uno::Sequence< T > xOut;
+ if(_Array)
+ {
+ jsize nLen = pEnv->GetArrayLength(_Array);
+ xOut.realloc(nLen);
+ for(jsize i=0;i<nLen;++i)
+ {
+ JT xInfo(pEnv,pEnv->GetObjectArrayElement(_Array,i));
+ java_lang_Object::ThrowSQLException(pEnv,NULL);
+ xOut.getArray()[i] = xInfo;
+ }
+ pEnv->DeleteLocalRef(_Array);
+ }
+ return xOut;
+ }
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > Map2XNameAccess(JNIEnv *pEnv,jobject _pMap);
+ jobject convertTypeMapToJavaMap(JNIEnv *pEnv,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > & _rMap);
+
+ /** return if a exception occured
+ @param pEnv
+ The native java env
+ @param _bClear
+ <TRUE/> if the execption should be cleared
+ @return
+ <TRUE/> if an exception is occured
+ */
+ sal_Bool isExceptionOccured(JNIEnv *pEnv,sal_Bool _bClear);
+
+ jobject createByteInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length);
+ jobject createCharArrayReader(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length);
+}
+
+#endif // _CONNECTIVITY_JAVA_TOOLS_HXX_
+
diff --git a/connectivity/source/inc/java/util/Date.hxx b/connectivity/source/inc/java/util/Date.hxx
new file mode 100644
index 000000000000..c42c09a927cf
--- /dev/null
+++ b/connectivity/source/inc/java/util/Date.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_JAVA_UTIL_DATE_HXX_
+#define _CONNECTIVITY_JAVA_UTIL_DATE_HXX_
+
+#include "java/lang/Object.hxx"
+#include <com/sun/star/util/Date.hpp>
+
+namespace connectivity
+{
+
+ //**************************************************************
+ //************ Class: java.util.Date
+ //**************************************************************
+
+ class java_util_Date : public java_lang_Object
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ public:
+ virtual jclass getMyClass() const;
+ virtual ~java_util_Date();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_util_Date( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){}
+ };
+}
+#endif // _CONNECTIVITY_JAVA_UTIL_DATE_HXX_
+
diff --git a/connectivity/source/inc/java/util/Property.hxx b/connectivity/source/inc/java/util/Property.hxx
new file mode 100644
index 000000000000..9e6cef045473
--- /dev/null
+++ b/connectivity/source/inc/java/util/Property.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_java_util_Properties
+#define CONNECTIVITY_java_util_Properties
+
+#include "java/lang/Object.hxx"
+
+namespace connectivity
+{
+ class java_util_Properties : public java_lang_Object
+ {
+ protected:
+ // statische Daten fuer die Klasse
+ static jclass theClass;
+ public:
+ virtual jclass getMyClass() const;
+ virtual ~java_util_Properties();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ java_util_Properties( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){}
+ java_util_Properties( );
+ void setProperty(const ::rtl::OUString key, const ::rtl::OUString& value);
+ };
+}
+
+#endif // CONNECTIVITY_java_util_Properties
diff --git a/connectivity/source/inc/mysql/YCatalog.hxx b/connectivity/source/inc/mysql/YCatalog.hxx
new file mode 100644
index 000000000000..49450f17a342
--- /dev/null
+++ b/connectivity/source/inc/mysql/YCatalog.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_MYSQL_CATALOG_HXX
+#define CONNECTIVITY_MYSQL_CATALOG_HXX
+
+#include "connectivity/sdbcx/VCatalog.hxx"
+#include "connectivity/StdTypeDefs.hxx"
+
+namespace connectivity
+{
+ namespace mysql
+ {
+ // 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 OAdabasConnection;
+ class OMySQLCatalog : public connectivity::sdbcx::OCatalog
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+
+ /** calls XDatabaseMetaData::getTables.
+ @param _sKindOfObject
+ The type of tables to be fetched.
+ @param _rNames
+ The container for the names to be filled. <OUT/>
+ */
+ void refreshObjects(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _sKindOfObject,TStringVector& _rNames);
+
+ public:
+ // implementation of the pure virtual methods
+ virtual void refreshTables();
+ virtual void refreshViews() ;
+ virtual void refreshGroups();
+ virtual void refreshUsers() ;
+
+ public:
+ OMySQLCatalog(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection);
+
+ inline sdbcx::OCollection* getPrivateTables() const { return m_pTables;}
+ inline sdbcx::OCollection* getPrivateViews() const { return m_pViews; }
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > getConnection() const { return m_xConnection; }
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ // ::cppu::OComponentHelper
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+#endif // CONNECTIVITY_MYSQL_CATALOG_HXX
+
diff --git a/connectivity/source/inc/mysql/YColumns.hxx b/connectivity/source/inc/mysql/YColumns.hxx
new file mode 100644
index 000000000000..e6b8a416c8b7
--- /dev/null
+++ b/connectivity/source/inc/mysql/YColumns.hxx
@@ -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 CONNECTIVITY_MYSQL_COLUMN_HXX
+#define CONNECTIVITY_MYSQL_COLUMN_HXX
+#include "connectivity/TColumnsHelper.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+
+namespace connectivity
+{
+ namespace mysql
+ {
+ class OMySQLColumns : public OColumnsHelper
+ {
+ protected:
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ public:
+ OMySQLColumns( ::cppu::OWeakObject& _rParent
+ ,sal_Bool _bCase
+ ,::osl::Mutex& _rMutex
+ ,const TStringVector &_rVector
+ ,sal_Bool _bUseHardRef = sal_True
+ );
+ };
+
+ class OMySQLColumn;
+ typedef sdbcx::OColumn OMySQLColumn_BASE;
+ typedef ::comphelper::OIdPropertyArrayUsageHelper<OMySQLColumn> OMySQLColumn_PROP;
+
+ class OMySQLColumn : public OMySQLColumn_BASE,
+ public OMySQLColumn_PROP
+ {
+ ::rtl::OUString m_sAutoIncrement;
+ protected:
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const;
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ public:
+ OMySQLColumn(sal_Bool _bCase);
+ virtual void construct();
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+#endif // CONNECTIVITY_MYSQL_COLUMN_HXX
+
diff --git a/connectivity/source/inc/mysql/YDriver.hxx b/connectivity/source/inc/mysql/YDriver.hxx
new file mode 100644
index 000000000000..dd231c87fda9
--- /dev/null
+++ b/connectivity/source/inc/mysql/YDriver.hxx
@@ -0,0 +1,126 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_MYSQL_DRIVER_HXX
+#define CONNECTIVITY_MYSQL_DRIVER_HXX
+
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/compbase3.hxx>
+#include <comphelper/uno3.hxx>
+#include <comphelper/stl_types.hxx>
+#include <comphelper/broadcasthelper.hxx>
+#include "connectivity/CommonTools.hxx"
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ class OMetaConnection;
+
+ namespace mysql
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODriverDelegator_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception );
+
+ typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XDriver
+ , ::com::sun::star::sdbcx::XDataDefinitionSupplier
+ , ::com::sun::star::lang::XServiceInfo
+ > ODriverDelegator_BASE;
+
+ typedef ::std::pair< ::com::sun::star::uno::WeakReferenceHelper,OMetaConnection*> TWeakConnectionPair;
+ typedef ::std::pair< ::com::sun::star::uno::WeakReferenceHelper,TWeakConnectionPair> TWeakPair;
+ typedef ::std::vector< TWeakPair > TWeakPairVector;
+ DECLARE_STL_USTRINGACCESS_MAP(::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver >,TJDBCDrivers);
+ typedef enum
+ {
+ D_ODBC,
+ D_JDBC,
+ D_NATIVE
+ } T_DRIVERTYPE;
+
+
+ /** delegates all calls to the orignal driver and extend the existing one with the SDBCX layer.
+
+ */
+ class ODriverDelegator : public ::comphelper::OBaseMutex
+ ,public ODriverDelegator_BASE
+ {
+ TJDBCDrivers m_aJdbcDrivers; // all jdbc drivers
+ TWeakPairVector m_aConnections; // vector containing a list
+ // of all the Connection objects
+ // for this Driver
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > m_xODBCDriver;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > m_xNativeDriver;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
+ ::rtl::OUString m_sOldDriverClass;
+ T_DRIVERTYPE m_eDriverType;
+
+ /** load the driver we want to delegate.
+ The <member>m_xODBCDriver</member> or <member>m_xDBCDriver</member> may be <NULL/> if the driver could not be loaded.
+ @param url
+ The URL.
+ @param info
+ The property info contains which driver we have to delegate.
+ @return
+ The driver which was currently selected.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > loadDriver( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info );
+
+ public:
+ /** creates a new delegator for a mysql driver
+ */
+ ODriverDelegator(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO();
+ 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);
+
+ // 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);
+
+ // XDataDefinitionSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByURL( 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);
+ protected:
+ /// dtor
+ virtual ~ODriverDelegator();
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ };
+ }
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+#endif // CONNECTIVITY_MYSQL_DRIVER_HXX
+
diff --git a/connectivity/source/inc/mysql/YTable.hxx b/connectivity/source/inc/mysql/YTable.hxx
new file mode 100644
index 000000000000..4f660282748a
--- /dev/null
+++ b/connectivity/source/inc/mysql/YTable.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_MYSQL_TABLE_HXX
+#define CONNECTIVITY_MYSQL_TABLE_HXX
+
+#include "connectivity/TTableHelper.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <comphelper/IdPropArrayHelper.hxx>
+
+namespace connectivity
+{
+ namespace mysql
+ {
+
+ ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xColProp);
+
+ class OMySQLTable;
+ typedef ::comphelper::OIdPropertyArrayUsageHelper< OMySQLTable > OMySQLTable_PROP;
+ class OMySQLTable : public OTableHelper
+ ,public OMySQLTable_PROP
+ {
+ sal_Int32 m_nPrivileges; // we have to set our privileges by our own
+
+ /** executes the statmenmt.
+ @param _rStatement
+ The statement to execute.
+ */
+ void executeStatement(const ::rtl::OUString& _rStatement );
+ protected:
+
+ /** creates the column collection for the table
+ @param _rNames
+ The column names.
+ */
+ virtual sdbcx::OCollection* createColumns(const TStringVector& _rNames);
+
+ /** creates the key collection for the table
+ @param _rNames
+ The key names.
+ */
+ virtual sdbcx::OCollection* createKeys(const TStringVector& _rNames);
+
+ /** creates the index collection for the table
+ @param _rNames
+ The index names.
+ */
+ virtual sdbcx::OCollection* createIndexes(const TStringVector& _rNames);
+
+ /** Returns always "RENAME TABLE " even for views.
+ *
+ * \return The start of the rename statement.
+ * @see http://dev.mysql.com/doc/refman/5.1/de/rename-table.html
+ */
+ virtual ::rtl::OUString getRenameStart() const;
+
+ /** used to implement the creation of the array helper which is shared amongst all instances of the class.
+ This method needs to be implemented in derived classes.
+ <BR>
+ The method gets called with s_aMutex acquired.
+ <BR>
+ as long as IPropertyArrayHelper has no virtual destructor, the implementation of ~OPropertyArrayUsageHelper
+ assumes that you created an ::cppu::OPropertyArrayHelper when deleting s_pProps.
+ @return an pointer to the newly created array helper. Must not be NULL.
+ */
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const;
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ public:
+ OMySQLTable( sdbcx::OCollection* _pTables,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection);
+ OMySQLTable( sdbcx::OCollection* _pTables,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
+ 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(),
+ sal_Int32 _nPrivileges = 0
+ );
+
+ // ODescriptor
+ virtual void construct();
+ // 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();
+
+ // XAlterTable
+ virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& colName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+ /** returns the ALTER TABLE XXX statement
+ */
+ ::rtl::OUString getAlterTableColumnPart();
+
+ // some methods to alter table structures
+ void alterColumnType(sal_Int32 nNewType,const ::rtl::OUString& _rColName,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDescriptor);
+ void alterDefaultValue(const ::rtl::OUString& _sNewDefault,const ::rtl::OUString& _rColName);
+ void dropDefaultValue(const ::rtl::OUString& _sNewDefault);
+
+ virtual ::rtl::OUString getTypeCreatePattern() const;
+ };
+ }
+}
+#endif // CONNECTIVITY_MYSQL_TABLE_HXX
+
diff --git a/connectivity/source/inc/mysql/YTables.hxx b/connectivity/source/inc/mysql/YTables.hxx
new file mode 100644
index 000000000000..ec19ac83140b
--- /dev/null
+++ b/connectivity/source/inc/mysql/YTables.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_MYSQL_TABLES_HXX
+#define CONNECTIVITY_MYSQL_TABLES_HXX
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include "connectivity/SQLStatementHelper.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+namespace connectivity
+{
+ namespace mysql
+ {
+ class OTables : public sdbcx::OCollection,
+ public ::dbtools::ISQLStatementHelper
+ {
+ ::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);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+
+ void createTable( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual ::rtl::OUString getNameForObject(const sdbcx::ObjectType& _xObject);
+ 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);
+
+ // XDrop
+ void appendNew(const ::rtl::OUString& _rsNewTable);
+ // some helper functions
+ /**
+ returns a sql string which contains the column definition part for create or alter statements
+ */
+ static ::rtl::OUString getColumnSqlType(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColProp);
+ /**
+ returns the "not null" part or the default part of the table statement
+ */
+ static ::rtl::OUString getColumnSqlNotNullDefault(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColProp);
+ /**
+ returns the corresponding typename
+ can contain () which have to filled with values
+ */
+ static ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColProp);
+
+ /** convert the sql statement to fit MySQL notation
+ @param _sSql in/out
+ */
+ static ::rtl::OUString adjustSQL(const ::rtl::OUString& _sSql);
+
+ // ISQLStatementHelper
+ virtual void addComment(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor,::rtl::OUStringBuffer& _rOut);
+ };
+ }
+}
+#endif // CONNECTIVITY_MYSQL_TABLES_HXX
+
diff --git a/connectivity/source/inc/mysql/YUser.hxx b/connectivity/source/inc/mysql/YUser.hxx
new file mode 100644
index 000000000000..f546ae12443c
--- /dev/null
+++ b/connectivity/source/inc/mysql/YUser.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MYSQL_USER_HXX_
+#define _CONNECTIVITY_MYSQL_USER_HXX_
+
+#include "connectivity/sdbcx/VUser.hxx"
+#include "com/sun/star/sdbc/XConnection.hpp"
+
+namespace connectivity
+{
+ namespace mysql
+ {
+ typedef connectivity::sdbcx::OUser OUser_TYPEDEF;
+
+ class OMySQLUser : public OUser_TYPEDEF
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+
+ ::rtl::OUString getPrivilegeString(sal_Int32 nRights) const;
+ // return the privileges and additional the grant rights
+ void findPrivilegesAndGrantPrivileges(const ::rtl::OUString& objName, sal_Int32 objType,sal_Int32& nRights,sal_Int32& nRightsWithGrant) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ public:
+ virtual void refreshGroups();
+ public:
+ OMySQLUser( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection);
+ OMySQLUser( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,const ::rtl::OUString& _Name);
+
+ // XUser
+ virtual void SAL_CALL changePassword( const ::rtl::OUString& objPassword, const ::rtl::OUString& newPassword ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XAuthorizable
+ virtual sal_Int32 SAL_CALL getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+
+ class OUserExtend;
+ typedef ::comphelper::OPropertyArrayUsageHelper<OUserExtend> OUserExtend_PROP;
+
+ class OUserExtend : public OMySQLUser,
+ public OUserExtend_PROP
+ {
+ protected:
+ ::rtl::OUString m_Password;
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ public:
+ OUserExtend(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection);
+
+ virtual void construct();
+ };
+ }
+}
+#endif // _CONNECTIVITY_MYSQL_USER_HXX_
+
diff --git a/connectivity/source/inc/mysql/YUsers.hxx b/connectivity/source/inc/mysql/YUsers.hxx
new file mode 100644
index 000000000000..252925577d9b
--- /dev/null
+++ b/connectivity/source/inc/mysql/YUsers.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MYSQL_USERS_HXX_
+#define _CONNECTIVITY_MYSQL_USERS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include "com/sun/star/sdbc/XConnection.hpp"
+namespace connectivity
+{
+ namespace sdbcx
+ {
+ class IRefreshableUsers;
+ }
+ namespace mysql
+ {
+ class OUsers : public sdbcx::OCollection
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+ connectivity::sdbcx::IRefreshableUsers* m_pParent;
+ public:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+ public:
+ 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);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MYSQL_USERS_HXX_
+
diff --git a/connectivity/source/inc/mysql/YViews.hxx b/connectivity/source/inc/mysql/YViews.hxx
new file mode 100644
index 000000000000..9fe5de9022f5
--- /dev/null
+++ b/connectivity/source/inc/mysql/YViews.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_MYSQL_VIEWS_HXX_
+#define _CONNECTIVITY_MYSQL_VIEWS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+namespace connectivity
+{
+ namespace mysql
+ {
+ class OViews : public sdbcx::OCollection
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+ sal_Bool m_bInDrop;
+ // OCatalog* m_pParent;
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
+ virtual sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
+
+ void createView( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
+ public:
+ OViews(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)
+ ,m_bInDrop(sal_False)
+ {}
+
+ // only the name is identical to ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ void dropByNameImpl(const ::rtl::OUString& elementName);
+ };
+ }
+}
+#endif // _CONNECTIVITY_MYSQL_VIEWS_HXX_
+
diff --git a/connectivity/source/inc/odbc/OBoundParam.hxx b/connectivity/source/inc/odbc/OBoundParam.hxx
new file mode 100644
index 000000000000..e3eb6d6dd49f
--- /dev/null
+++ b/connectivity/source/inc/odbc/OBoundParam.hxx
@@ -0,0 +1,222 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_OBOUNPARAM_HXX_
+#define _CONNECTIVITY_OBOUNPARAM_HXX_
+
+#include <com/sun/star/io/XInputStream.hpp>
+#include "odbc/odbcbasedllapi.hxx"
+
+namespace connectivity
+{
+ namespace odbc
+ {
+ class OOO_DLLPUBLIC_ODBCBASE OBoundParam
+ {
+
+ public:
+ OBoundParam()
+ {
+ paramLength = NULL;
+ binaryData = NULL;
+ pA1=0;
+ pA2=0;
+ pB1=0;
+ pB2=0;
+ pC1=0;
+ pC2=0;
+ pS1=0;
+ pS2=0;
+ }
+ ~OBoundParam()
+ {
+ delete [] binaryData;
+ delete [] paramLength;
+ }
+ //--------------------------------------------------------------------
+ // initialize
+ // Perform an necessary initialization
+ //--------------------------------------------------------------------
+ void initialize ()
+ {
+ // Allocate storage for the length. Note - the length is
+ // stored in native format, and will have to be converted
+ // to a Java sal_Int32. The jdbcodbc 'C' bridge provides an
+ // interface to do this.
+
+ paramLength = new sal_Int8[4];
+ }
+
+ //--------------------------------------------------------------------
+ // allocBindDataBuffer
+ // Allocates and returns a new bind data buffer of the specified
+ // length
+ //--------------------------------------------------------------------
+ sal_Int8* allocBindDataBuffer (sal_Int32 bufLen)
+ {
+ if ( binaryData )
+ delete [] binaryData;
+ binaryData = new sal_Int8[bufLen];
+
+ // Reset the input stream, we are doing a new bind
+ setInputStream (NULL, 0);
+
+ return binaryData;
+ }
+
+ //--------------------------------------------------------------------
+ // getBindDataBuffer
+ // Returns the data buffer to be used when binding to a parameter
+ //--------------------------------------------------------------------
+ sal_Int8* getBindDataBuffer ()
+ {
+ return binaryData;
+ }
+
+ //--------------------------------------------------------------------
+ // getBindLengthBuffer
+ // Returns the length buffer to be used when binding to a parameter
+ //--------------------------------------------------------------------
+ sal_Int8* getBindLengthBuffer ()
+ {
+ return paramLength;
+ }
+
+ //--------------------------------------------------------------------
+ // setInputStream
+ // Sets the input stream for the bound parameter
+ //--------------------------------------------------------------------
+ void setInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& inputStream,
+ sal_Int32 len)
+ {
+ paramInputStream = inputStream;
+ paramInputStreamLen = len;
+ }
+
+ void setSequence(const ::com::sun::star::uno::Sequence< sal_Int8 >& _aSequence)
+ {
+ aSequence = _aSequence;
+ }
+
+ //--------------------------------------------------------------------
+ // getInputStream
+ // Gets the input stream for the bound parameter
+ //--------------------------------------------------------------------
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> getInputStream ()
+ {
+ return paramInputStream;
+ }
+
+ //--------------------------------------------------------------------
+ // getInputStreamLen
+ // Gets the input stream length for the bound parameter
+ //--------------------------------------------------------------------
+ sal_Int32 getInputStreamLen ()
+ {
+ return paramInputStreamLen;
+ }
+
+ //--------------------------------------------------------------------
+ // setSqlType
+ // Sets the Java sql type used to register an OUT parameter
+ //--------------------------------------------------------------------
+
+ void setSqlType(sal_Int32 type)
+ {
+ sqlType = type;
+ }
+
+ //--------------------------------------------------------------------
+ // getSqlType
+ // Gets the Java sql type used to register an OUT parameter
+ //--------------------------------------------------------------------
+
+ sal_Int32 getSqlType ()
+ {
+ return sqlType;
+ }
+
+ //--------------------------------------------------------------------
+ // setOutputParameter
+ // Sets the flag indicating if this is an OUTPUT parameter
+ //--------------------------------------------------------------------
+
+ void setOutputParameter (sal_Bool output)
+ {
+ outputParameter = output;
+ }
+
+ //--------------------------------------------------------------------
+ // isOutputParameter
+ // Gets the OUTPUT parameter flag
+ //--------------------------------------------------------------------
+
+ sal_Bool isOutputParameter ()
+ {
+ return outputParameter;
+ }
+
+ protected:
+ //====================================================================
+ // Data attributes
+ //====================================================================
+
+ sal_Int8* binaryData; // Storage area to be used
+ // when binding the parameter
+
+ sal_Int8* paramLength; // Storage area to be used
+ // for the bound length of the
+ // parameter. Note that this
+ // data is in native format.
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> paramInputStream;
+ ::com::sun::star::uno::Sequence< sal_Int8 > aSequence;
+ // When an input stream is
+ // bound to a parameter, the
+ // input stream is saved
+ // until needed.
+
+ sal_Int32 paramInputStreamLen; // Length of input stream
+
+ sal_Int32 sqlType; // Java SQL type used to
+ // register an OUT parameter
+
+ sal_Bool outputParameter; // true for OUTPUT parameters
+
+
+ sal_Int32 pA1; //pointers
+ sal_Int32 pA2;
+ sal_Int32 pB1;
+ sal_Int32 pB2;
+ sal_Int32 pC1;
+ sal_Int32 pC2;
+ sal_Int32 pS1;
+ sal_Int32 pS2;// reserved for strings(UTFChars)
+ };
+ }
+}
+#endif // _CONNECTIVITY_OBOUNPARAM_HXX_
+
diff --git a/connectivity/source/inc/odbc/OConnection.hxx b/connectivity/source/inc/odbc/OConnection.hxx
new file mode 100644
index 000000000000..94ffd3a57263
--- /dev/null
+++ b/connectivity/source/inc/odbc/OConnection.hxx
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_ODBC_OCONNECTION_HXX_
+#define _CONNECTIVITY_ODBC_OCONNECTION_HXX_
+
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include "odbc/OFunctiondefs.hxx"
+#include "odbc/odbcbasedllapi.hxx"
+#include "OSubComponent.hxx"
+#include "connectivity/CommonTools.hxx"
+#include "TConnection.hxx"
+#include "OTypeInfo.hxx"
+#include <cppuhelper/weakref.hxx>
+#include "AutoRetrievingBase.hxx"
+#include <osl/module.h>
+
+
+#include <map>
+
+namespace connectivity
+{
+ namespace odbc
+ {
+
+ class OStatement_Base;
+ class ODBCDriver;
+ class ODatabaseMetaData;
+
+ typedef connectivity::OMetaConnection OConnection_BASE;
+ typedef ::std::vector< ::connectivity::OTypeInfo> TTypeInfoVector;
+
+ class OOO_DLLPUBLIC_ODBCBASE OConnection :
+ public OConnection_BASE,
+ public connectivity::OSubComponent<OConnection, OConnection_BASE>,
+ public OAutoRetrievingBase
+ {
+ friend class connectivity::OSubComponent<OConnection, OConnection_BASE>;
+
+ protected:
+ //====================================================================
+ // Data attributes
+ //====================================================================
+ ::std::map< SQLHANDLE,OConnection*> m_aConnections; // holds all connectionas which are need for serveral statements
+ TTypeInfoVector m_aTypeInfo; // vector containing an entry
+ // for each row returned by
+ // DatabaseMetaData.getTypeInfo.
+
+
+ ::com::sun::star::sdbc::SQLWarning m_aLastWarning; // Last SQLWarning generated by
+ // an operation
+ ::rtl::OUString m_sUser; // the user name
+ ODBCDriver* m_pDriver; // Pointer to the owning
+ // driver object
+
+ SQLHANDLE m_aConnectionHandle;
+ SQLHANDLE m_pDriverHandleCopy; // performance reason
+ sal_Int32 m_nStatementCount;
+ sal_Bool m_bClosed;
+ sal_Bool m_bUseCatalog; // should we use the catalog on filebased databases
+ sal_Bool m_bUseOldDateFormat;
+ sal_Bool m_bParameterSubstitution;
+ sal_Bool m_bIgnoreDriverPrivileges;
+ sal_Bool m_bPreventGetVersionColumns; // #i60273#
+ sal_Bool m_bReadOnly;
+
+
+ SQLRETURN OpenConnection(const ::rtl::OUString& aConnectStr,sal_Int32 nTimeOut, sal_Bool bSilent);
+
+ virtual OConnection* cloneConnection(); // creates a new connection
+
+ public:
+ oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const;
+ virtual SQLRETURN Construct( const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info) throw(::com::sun::star::sdbc::SQLException);
+
+ OConnection(const SQLHANDLE _pDriverHandle,ODBCDriver* _pDriver);
+ // OConnection(const SQLHANDLE _pConnectionHandle);
+ 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);
+ //
+ SQLHANDLE getConnection() { return m_aConnectionHandle; }
+
+ // should we use the catalog on filebased databases
+ inline sal_Bool isCatalogUsed() const { return m_bUseCatalog; }
+ inline sal_Bool isParameterSubstitutionEnabled() const { return m_bParameterSubstitution; }
+ inline sal_Bool isIgnoreDriverPrivilegesEnabled() const { return m_bIgnoreDriverPrivileges; }
+ inline sal_Bool preventGetVersionColumns() const { return m_bPreventGetVersionColumns; }
+ inline sal_Bool useOldDateFormat() const { return m_bUseOldDateFormat; }
+ inline SQLHANDLE getDriverHandle() const { return m_pDriverHandleCopy;}
+ inline ODBCDriver* getDriver() const { return m_pDriver;}
+ inline ::rtl::OUString getUserName() const { return m_sUser; }
+
+ SQLHANDLE createStatementHandle();
+ // close and free the handle and set it to SQL_NULLHANDLE
+ void freeStatementHandle(SQLHANDLE& _pHandle);
+
+ void buildTypeInfo() throw( ::com::sun::star::sdbc::SQLException);
+ const TTypeInfoVector& getTypeInfo() const { return m_aTypeInfo; }
+ };
+ }
+}
+#endif // _CONNECTIVITY_ODBC_OCONNECTION_HXX_
+
diff --git a/connectivity/source/inc/odbc/ODatabaseMetaData.hxx b/connectivity/source/inc/odbc/ODatabaseMetaData.hxx
new file mode 100644
index 000000000000..5805f336e034
--- /dev/null
+++ b/connectivity/source/inc/odbc/ODatabaseMetaData.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_ODBC_ODATABASEMETADATA_HXX_
+#define _CONNECTIVITY_ODBC_ODATABASEMETADATA_HXX_
+
+#include "odbc/OConnection.hxx"
+#include "odbc/odbcbasedllapi.hxx"
+#include "TDatabaseMetaDataBase.hxx"
+
+namespace connectivity
+{
+ namespace odbc
+ {
+ //**************************************************************
+ //************ Class: ODatabaseMetaData
+ //**************************************************************
+
+ class OOO_DLLPUBLIC_ODBCBASE ODatabaseMetaData :
+ public ODatabaseMetaDataBase
+ {
+ SQLHANDLE m_aConnectionHandle;
+ OConnection* m_pConnection;
+ sal_Bool m_bUseCatalog;
+ sal_Bool m_bOdbc3;
+
+ // 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( );
+ protected:
+ ::rtl::OUString getURLImpl();
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_getTypeInfo_throw();
+ virtual ~ODatabaseMetaData();
+ public:
+
+ inline OConnection* getOwnConnection() const { return m_pConnection; }
+ inline oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const
+ {
+ return m_pConnection->getOdbcFunction(_nIndex);
+ }
+
+ ODatabaseMetaData(const SQLHANDLE _pHandle,OConnection* _pCon);
+
+
+
+ // 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 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 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);
+ };
+ }
+}
+#endif // _CONNECTIVITY_ODBC_ODATABASEMETADATA_HXX_
+
diff --git a/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx b/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx
new file mode 100644
index 000000000000..d0aa60a812ca
--- /dev/null
+++ b/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx
@@ -0,0 +1,242 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_ODBC_ADATABASEMETADATARESULTSET_HXX_
+#define _CONNECTIVITY_ODBC_ADATABASEMETADATARESULTSET_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 <cppuhelper/compbase7.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include "odbc/OStatement.hxx"
+#include "odbc/ODatabaseMetaData.hxx"
+#include "odbc/odbcbasedllapi.hxx"
+#include <comphelper/broadcasthelper.hxx>
+#include "connectivity/StdTypeDefs.hxx"
+
+namespace connectivity
+{
+ namespace odbc
+ {
+ class ODatabaseMetaDataResultSetMetaData;
+ /*
+ ** java_sql_ResultSet
+ */
+ typedef ::cppu::WeakComponentImplHelper7< ::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> ODatabaseMetaDataResultSet_BASE;
+
+ class OOO_DLLPUBLIC_ODBCBASE ODatabaseMetaDataResultSet :
+ public comphelper::OBaseMutex,
+ public ODatabaseMetaDataResultSet_BASE,
+ public ::cppu::OPropertySetHelper,
+ public ::comphelper::OPropertyArrayUsageHelper<ODatabaseMetaDataResultSet>
+ {
+ ::connectivity::TIntVector m_aColMapping; // pos 0 is unused so we don't have to decrement 1 everytime
+
+ ::std::map<sal_Int32, ::connectivity::TInt2IntMap > m_aValueRange;
+ ::std::map<sal_Int32, ::connectivity::TString2IntMap > m_aStrValueRange;
+
+ ::std::map<sal_Int32, ::connectivity::TInt2StringMap > m_aIntValueRange;
+ ::std::map<sal_Int32,SWORD> m_aODBCColumnTypes;
+
+ SQLHANDLE m_aStatementHandle;
+ SQLHANDLE m_aConnectionHandle;
+ ::com::sun::star::uno::WeakReferenceHelper m_aStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData;
+ SQLUSMALLINT* m_pRowStatusArray;
+ OConnection* m_pConnection;
+ rtl_TextEncoding m_nTextEncoding;
+ sal_Int32 m_nRowPos;
+ sal_Int32 m_nLastColumnPos; // used for m_aRow just to know where we are
+ sal_Int32 m_nDriverColumnCount; // column count of the driver wich can sometimes be less than the metadata count
+ SQLRETURN m_nCurrentFetchState;
+ sal_Bool m_bWasNull;
+ sal_Bool m_bEOF; // after last record
+ sal_Bool m_bFreeHandle;
+
+ // set the columncount of the driver
+ void checkColumnCount();
+ sal_Int32 getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ ::rtl::OUString getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ SWORD impl_getColumnType_nothrow(sal_Int32 columnIndex);
+
+ sal_Int32 mapColumn (sal_Int32 column);
+
+ 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;
+ ~ODatabaseMetaDataResultSet();
+ public:
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ ODatabaseMetaDataResultSet(OConnection* _pConnection);
+
+
+ inline oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const
+ {
+ return m_pConnection->getOdbcFunction(_nIndex);
+ }
+ // ::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);
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > operator *()
+ {
+ return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(*(ODatabaseMetaDataResultSet_BASE*)this);
+ }
+ // 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);
+
+ const ::connectivity::TIntVector& getColumnMapping() { return m_aColMapping; }
+
+ void openTablesTypes( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void openTypeInfo() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void openCatalogs() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void openSchemas() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void openTables(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);
+ void openColumnPrivileges( 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);
+ void openColumns( 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);
+ void openProcedureColumns( 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);
+ void openProcedures( 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);
+ void openVersionColumns(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);
+ void openBestRowIdentifier( 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);
+ void openForeignKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString* schema,const ::rtl::OUString* table,
+ const ::com::sun::star::uno::Any& catalog2, const ::rtl::OUString* schema2,const ::rtl::OUString* table2)throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void openExportedKeys(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);
+ void openImportedKeys(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);
+ void openPrimaryKeys(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);
+ void openTablePrivileges(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);
+ void openSpecialColumns(sal_Bool _bRowVer,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);
+ void openIndexInfo( 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);
+
+ protected:
+ using OPropertySetHelper::getFastPropertyValue;
+ };
+ }
+
+}
+#endif // _CONNECTIVITY_ADO_ADATABASEMETADATARESULTSET_HXX_
+
diff --git a/connectivity/source/inc/odbc/ODefs3.hxx b/connectivity/source/inc/odbc/ODefs3.hxx
new file mode 100644
index 000000000000..6bd4025248c8
--- /dev/null
+++ b/connectivity/source/inc/odbc/ODefs3.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_ODBC_ODEFS_HXX_
+#define _CONNECTIVITY_ODBC_ODEFS_HXX_
+
+#define N3SQLAllocHandle SQLAllocHandle
+#define N3SQLConnect SQLConnect
+#define N3SQLDriverConnect SQLDriverConnect
+#define N3SQLBrowseConnect SQLBrowseConnect
+#define N3SQLDataSources SQLDataSources
+#define N3SQLDrivers SQLDrivers
+#define N3SQLGetInfo SQLGetInfo
+#define N3SQLGetFunctions SQLGetFunctions
+#define N3SQLGetTypeInfo SQLGetTypeInfo
+#define N3SQLSetConnectAttr SQLSetConnectAttr
+#define N3SQLGetConnectAttr SQLGetConnectAttr
+#define N3SQLSetEnvAttr SQLSetEnvAttr
+#define N3SQLGetEnvAttr SQLGetEnvAttr
+#define N3SQLSetStmtAttr SQLSetStmtAttr
+#define N3SQLGetStmtAttr SQLgetStmtAttr
+#define N3SQLSetDescField SQLSetDescField
+#define N3SQLGetDescField SQLGetDescField
+#define N3SQLGetDescRec SQLGetDescRec
+#define N3SQLSetDescRec SQLSetDescRec
+#define N3SQLPrepare SQLPrepare
+#define N3SQLBindParameter SQLBindParameter
+#define N3SQLGetCursorName SQLGetCursorName
+#define N3SQLSetCursorName SQLSetCursorName
+#define N3SQLExecute SQLExecute
+#define N3SQLExecDirect SQLExecDirect
+#define N3SQLNativeSql SQLNativeSql
+#define N3SQLDescribeParam SQLDescribeParam
+#define N3SQLNumParams SQLNumParams
+#define N3SQLParamData SQLParamData
+#define N3SQLPutData SQLPutData
+#define N3SQLRowCount SQLRowCount
+#define N3SQLNumResultCols SQLNumResultCols
+#define N3SQLDescribeCol SQLDescribeCol
+#define N3SQLColAttribute SQLColAttribute
+#define N3SQLBindCol SQLBindCol
+#define N3SQLFetch SQLFetch
+#define N3SQLFetchScroll SQLFetchScroll
+#define N3SQLGetData SQLGetData
+#define N3SQLSetPos SQLSetPos
+#define N3SQLBulkOperations SQLBulkOperations
+#define N3SQLMoreResults SQLMoreResults
+#define N3SQLGetDiagField SQLGetDiagField
+#define N3SQLGetDiagRec SQLGetDiagRec
+#define N3SQLColumnPrivileges SQLColumnPrivileges
+#define N3SQLColumns SQLColumns
+#define N3SQLForeignKeys SQLForeignKeys
+#define N3SQLPrimaryKeys SQLPrimaryKeys
+#define N3SQLProcedureColumns SQLProcedureColumns
+#define N3SQLProcedures SQLProcedures
+#define N3SQLSpecialColumns SQLSpecialColumns
+#define N3SQLStatistics SQLStatistics
+#define N3SQLTablePrivileges SQLTablePrivileges
+#define N3SQLTables SQLTables
+#define N3SQLFreeStmt SQLFreeStmt
+#define N3SQLCloseCursor SQLCloseCursor
+#define N3SQLCancel SQLCancel
+#define N3SQLEndTran SQLEndTran
+#define N3SQLDisconnect SQLDisconnect
+#define N3SQLFreeHandle SQLFreeHandle
+#define N3SQLGetCursorName SQLGetCursorName
+
+#endif // _CONNECTIVITY_ODBC_ODEFS_HXX_
+
diff --git a/connectivity/source/inc/odbc/ODriver.hxx b/connectivity/source/inc/odbc/ODriver.hxx
new file mode 100644
index 000000000000..4be1e371129a
--- /dev/null
+++ b/connectivity/source/inc/odbc/ODriver.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_ODBC_ODRIVER_HXX_
+#define _CONNECTIVITY_ODBC_ODRIVER_HXX_
+
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/compbase2.hxx>
+#include "odbc/OFunctiondefs.hxx"
+#include "odbc/odbcbasedllapi.hxx"
+#include "connectivity/CommonTools.hxx"
+#include <osl/module.h>
+
+namespace connectivity
+{
+ namespace odbc
+ {
+ typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::sdbc::XDriver, ::com::sun::star::lang::XServiceInfo > ODriver_BASE;
+
+ class OOO_DLLPUBLIC_ODBCBASE SAL_NO_VTABLE ODBCDriver : public ODriver_BASE
+ {
+ protected:
+ ::osl::Mutex m_aMutex;
+
+ connectivity::OWeakRefArray m_xConnections; // vector containing a list
+ // of all the Connection objects
+ // for this Driver
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
+ SQLHANDLE m_pDriverHandle;
+
+ virtual SQLHANDLE EnvironmentHandle(::rtl::OUString &_rPath) = 0;
+
+ public:
+
+ ODBCDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+
+ // only possibility to get the odbc functions
+ virtual oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const = 0;
+ // 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);
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const { return m_xORB; }
+ };
+ }
+
+}
+#endif //_CONNECTIVITY_ODBC_ODRIVER_HXX_
+
+
diff --git a/connectivity/source/inc/odbc/OFunctiondefs.hxx b/connectivity/source/inc/odbc/OFunctiondefs.hxx
new file mode 100644
index 000000000000..36c2a2f722da
--- /dev/null
+++ b/connectivity/source/inc/odbc/OFunctiondefs.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+//--------------------------------------------------------------------------
+#ifndef _CONNECTIVITY_OFUNCTIONDEFS_HXX_
+#define _CONNECTIVITY_OFUNCTIONDEFS_HXX_
+
+#if defined(WIN) || defined(WNT)
+
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable:4005)
+#endif
+
+// just to go with calling convention of windows
+#define SQL_API __stdcall
+#include <odbc/sqlext.h>
+#undef SQL_API
+#define SQL_API __stdcall
+
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
+#ifndef SQL_C_BOOKMARK
+#define SQL_C_BOOKMARK SQL_C_ULONG /* BOOKMARK */
+#endif
+
+#ifndef SQL_OPT_TRACE_OFF
+#define SQL_OPT_TRACE_OFF 0UL
+#endif
+
+#define SDB_ODBC_CHAR UCHAR
+
+#endif
+
+//--------------------------------------------------------------------------
+
+#ifdef OS2
+#define ALLREADY_HAVE_OS2_TYPES
+#define DONT_TD_VOID
+#include <svpm.h>
+#include <odbc/sqlext.h>
+#define SDB_ODBC_CHAR UCHAR
+#endif // OS2
+
+#ifdef OS2__00
+
+#ifdef ODBCIMP
+
+// Stub-Version: dynamische Bindung an die DLL zur Laufzeit.
+// odbcstub definiert die in den Quellen benutzten NSQL...-Methoden
+// als indirekte Funktionsaufrufe.
+// odbcimp zieht sich selbst preos2, odbc und postos2 an.
+// #include "odbc3imp.hxx"
+
+#else
+
+// Zur Zeit verwenden wir die ODBC-DLL von Watcom-SQL direkt (ueber die
+// mitgelieferte Lib).
+
+#ifndef ODBC_OS2
+#define ODBC_OS2
+#endif
+
+#include <svpm.h>
+#include <odbc.h>
+#define SQL_API __syscall
+#ifndef SQL_MAX_MESSAGE_LENGTH
+#define SQL_MAX_MESSAGE_LENGTH MAX_MESSAGE_LENGTH
+#endif
+#ifndef SQL_MAX_DSN_LENGTH
+#define SQL_MAX_DSN_LENGTH MAX_DSN_LENGTH
+#endif
+#ifndef SQL_AUTOCOMMIT_ON
+#define SQL_AUTOCOMMIT_ON 1UL
+#endif
+#ifndef SQL_AUTOCOMMIT_OFF
+#define SQL_AUTOCOMMIT_OFF 0UL
+#endif
+
+#define SQL_FETCH_PRIOR SQL_FETCH_PREV
+#define SQL_NO_TOTAL (-4)
+
+// #include "odbc3defs.hxx"
+
+#endif
+
+// In der ODBC.H von Watcom werden Strings als char * erwartet
+// (nicht, wie sonst bei ODBC ueblich, als UCHAR *).
+#if defined( ICC ) || defined( WTC )
+#define SDB_ODBC_CHAR unsigned char
+#else
+#define SDB_ODBC_CHAR char
+#endif
+
+#endif
+
+//--------------------------------------------------------------------------
+
+#ifdef UNX
+
+// Zur Zeit verwenden wir die ODBC-shared library von Q+E direkt (ueber die
+// mitgelieferte Lib).
+
+#ifndef ODBC_UNX
+#define ODBC_UNX
+#endif
+#define CALLBACK
+#define EXPORT
+#ifdef SYSTEM_ODBC_HEADERS
+#include <sqlext.h>
+#else
+#include <odbc/sqlext.h>
+#endif
+#undef sal_Bool // Ist in qeodbc.h definiert, wird aber von solar.h noch einmal
+ // definiert.
+
+#define SDB_ODBC_CHAR UCHAR
+#define SQL_WCHAR (-8)
+#define SQL_WVARCHAR (-9)
+#define SQL_WLONGVARCHAR (-10)
+#define SQL_C_WCHAR SQL_WCHAR
+
+
+#endif // UNX
+
+//--------------------------------------------------------------------------
+
+#ifndef SQL_WCHAR
+#define SQL_WCHAR (-8)
+#endif
+#ifndef SQL_WVARCHAR
+#define SQL_WVARCHAR (-9)
+#endif
+#ifndef SQL_WLONGVARCHAR
+#define SQL_WLONGVARCHAR (-10)
+#endif
+#ifndef SQL_C_WCHAR
+#define SQL_C_WCHAR SQL_WCHAR
+#endif
+
+#ifdef UNICODE
+#define SQL_C_TCHAR SQL_C_WCHAR
+#else
+#define SQL_C_TCHAR SQL_C_CHAR
+#endif
+
+#endif // _CONNECTIVITY_OFUNCTIONDEFS_HXX_
+
+
diff --git a/connectivity/source/inc/odbc/OFunctions.hxx b/connectivity/source/inc/odbc/OFunctions.hxx
new file mode 100644
index 000000000000..99a8db65eb14
--- /dev/null
+++ b/connectivity/source/inc/odbc/OFunctions.hxx
@@ -0,0 +1,556 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_ODBC_OFUNCTIONS_HXX_
+#define _CONNECTIVITY_ODBC_OFUNCTIONS_HXX_
+
+#include "odbc/OFunctiondefs.hxx"
+#include <rtl/ustring.hxx>
+#include <osl/module.h>
+
+namespace connectivity
+{
+
+// sal_Bool LoadFunctions(oslModule pODBCso, sal_Bool _bDS=sal_True);
+// sal_Bool LoadLibrary_ODBC3(::rtl::OUString &_rPath);
+// sal_Bool LoadLibrary_ADABAS(::rtl::OUString &_rPath);
+
+ // Connecting to a data source
+ typedef SQLRETURN (SQL_API *T3SQLAllocHandle) (SQLSMALLINT HandleType,SQLHANDLE InputHandle,SQLHANDLE * OutputHandlePtr);
+
+ #define N3SQLAllocHandle(a,b,c) (*(T3SQLAllocHandle)getOdbcFunction(ODBC3SQLAllocHandle))(a,b,c)
+
+ typedef SQLRETURN (SQL_API *T3SQLConnect) (SQLHDBC ConnectionHandle,SQLCHAR *ServerName,SQLSMALLINT NameLength1,SQLCHAR *UserName,SQLSMALLINT NameLength2,SQLCHAR *Authentication,SQLSMALLINT NameLength3);
+
+ #define N3SQLConnect(a,b,c,d,e,f,g) (*(T3SQLConnect)getOdbcFunction(ODBC3SQLConnect))(a,b,c,d,e,f,g)
+
+ typedef SQLRETURN (SQL_API *T3SQLDriverConnect) ( SQLHDBC ConnectionHandle,
+ HWND WindowHandle,
+ SQLCHAR * InConnectionString,
+ SQLSMALLINT StringLength1,
+ SQLCHAR * OutConnectionString,
+ SQLSMALLINT BufferLength,
+ SQLSMALLINT * StringLength2Ptr,
+ SQLUSMALLINT DriverCompletion);
+
+ #define N3SQLDriverConnect(a,b,c,d,e,f,g,h) (*(T3SQLDriverConnect)getOdbcFunction(ODBC3SQLDriverConnect))(a,b,c,d,e,f,g,h)
+
+ typedef SQLRETURN (SQL_API *T3SQLBrowseConnect) ( SQLHDBC ConnectionHandle,
+ SQLCHAR * InConnectionString,
+ SQLSMALLINT StringLength1,
+ SQLCHAR * OutConnectionString,
+ SQLSMALLINT BufferLength,
+ SQLSMALLINT * StringLength2Ptr);
+
+ #define N3SQLBrowseConnect(a,b,c,d,e,f) (*(T3SQLBrowseConnect)getOdbcFunction(ODBC3SQLBrowseConnect))(a,b,c,d,e,f)
+
+ // Obtaining information about a driver and data source
+ typedef SQLRETURN (SQL_API *T3SQLDataSources) ( SQLHENV EnvironmentHandle,
+ SQLUSMALLINT Direction,
+ SQLCHAR * ServerName,
+ SQLSMALLINT BufferLength1,
+ SQLSMALLINT * NameLength1Ptr,
+ SQLCHAR * Description,
+ SQLSMALLINT BufferLength2,
+ SQLSMALLINT * NameLength2Ptr);
+
+ #define N3SQLDataSources(a,b,c,d,e,f,g,h) (*(T3SQLDataSources)getOdbcFunction(ODBC3SQLDataSources))(a,b,c,d,e,f,g,h)
+
+ typedef SQLRETURN (SQL_API *T3SQLDrivers) ( SQLHENV EnvironmentHandle,
+ SQLUSMALLINT Direction,
+ SQLCHAR * DriverDescription,
+ SQLSMALLINT BufferLength1,
+ SQLSMALLINT * DescriptionLengthPtr,
+ SQLCHAR * DriverAttributes,
+ SQLSMALLINT BufferLength2,
+ SQLSMALLINT * AttributesLengthPtr);
+
+ #define N3SQLDrivers(a,b,c,d,e,f,g,h) (*(T3SQLDrivers)getOdbcFunction(ODBC3SQLDrivers))(a,b,c,d,e,f,g,h)
+
+ typedef SQLRETURN (SQL_API *T3SQLGetInfo) ( SQLHDBC ConnectionHandle,
+ SQLUSMALLINT InfoType,
+ SQLPOINTER InfoValuePtr,
+ SQLSMALLINT BufferLength,
+ SQLSMALLINT * StringLengthPtr);
+
+ #define N3SQLGetInfo(a,b,c,d,e) (*(T3SQLGetInfo)getOdbcFunction(ODBC3SQLGetInfo))(a,b,c,d,e)
+
+ typedef SQLRETURN (SQL_API *T3SQLGetFunctions) (SQLHDBC ConnectionHandle,
+ SQLUSMALLINT FunctionId,
+ SQLUSMALLINT * SupportedPtr);
+
+ #define N3SQLGetFunctions(a,b,c) (*(T3SQLGetFunctions)getOdbcFunction(ODBC3SQLGetFunctions))(a,b,c)
+
+ typedef SQLRETURN (SQL_API *T3SQLGetTypeInfo) ( SQLHSTMT StatementHandle,
+ SQLSMALLINT DataType);
+
+ #define N3SQLGetTypeInfo(a,b) (*(T3SQLGetTypeInfo)getOdbcFunction(ODBC3SQLGetTypeInfo))(a,b)
+
+ // Setting and retrieving driver attributes
+ typedef SQLRETURN (SQL_API *T3SQLSetConnectAttr)(SQLHDBC ConnectionHandle,
+ SQLINTEGER Attribute,
+ SQLPOINTER ValuePtr,
+ SQLINTEGER StringLength);
+
+ #define N3SQLSetConnectAttr(a,b,c,d) (*(T3SQLSetConnectAttr)getOdbcFunction(ODBC3SQLSetConnectAttr))(a,b,c,d)
+
+ typedef SQLRETURN (SQL_API *T3SQLGetConnectAttr) (SQLHDBC ConnectionHandle,
+ SQLINTEGER Attribute,
+ SQLPOINTER ValuePtr,
+ SQLINTEGER BufferLength,
+ SQLINTEGER* StringLength);
+
+ #define N3SQLGetConnectAttr(a,b,c,d,e) (*(T3SQLGetConnectAttr)getOdbcFunction(ODBC3SQLGetConnectAttr))(a,b,c,d,e)
+
+
+ typedef SQLRETURN (SQL_API *T3SQLSetEnvAttr) ( SQLHENV EnvironmentHandle,
+ SQLINTEGER Attribute,
+ SQLPOINTER ValuePtr,
+ SQLINTEGER StringLength);
+
+ #define N3SQLSetEnvAttr(a,b,c,d) (*(T3SQLSetEnvAttr)getOdbcFunction(ODBC3SQLSetEnvAttr))(a,b,c,d)
+
+ typedef SQLRETURN (SQL_API *T3SQLGetEnvAttr) ( SQLHENV EnvironmentHandle,
+ SQLINTEGER Attribute,
+ SQLPOINTER ValuePtr,
+ SQLINTEGER BufferLength,
+ SQLINTEGER* StringLength);
+
+ #define N3SQLGetEnvAttr(a,b,c,d,e) (*(T3SQLGetEnvAttr)getOdbcFunction(ODBC3SQLGetEnvAttr))(a,b,c,d,e)
+
+
+ typedef SQLRETURN (SQL_API *T3SQLSetStmtAttr) ( SQLHSTMT StatementHandle,
+ SQLINTEGER Attribute,
+ SQLPOINTER ValuePtr,
+ SQLINTEGER StringLength);
+
+ #define N3SQLSetStmtAttr(a,b,c,d) (*(T3SQLSetStmtAttr)getOdbcFunction(ODBC3SQLSetStmtAttr))(a,b,c,d)
+
+ typedef SQLRETURN (SQL_API *T3SQLGetStmtAttr) ( SQLHSTMT StatementHandle,
+ SQLINTEGER Attribute,
+ SQLPOINTER ValuePtr,
+ SQLINTEGER BufferLength,
+ SQLINTEGER* StringLength);
+
+ #define N3SQLGetStmtAttr(a,b,c,d,e) (*(T3SQLGetStmtAttr)getOdbcFunction(ODBC3SQLGetStmtAttr))(a,b,c,d,e)
+
+ // Setting and retrieving descriptor fields
+ /*typedef SQLRETURN (SQL_API *T3SQLSetDescField) (SQLHDESC DescriptorHandle,
+ SQLSMALLINT RecNumber,
+ SQLSMALLINT FieldIdentifier,
+ SQLPOINTER ValuePtr,
+ SQLINTEGER BufferLength);
+
+ #define N3SQLSetDescField(a,b,c,d,e) (*(T3SQLSetDescField)getOdbcFunction(ODBC3SQLSetDescField))(a,b,c,d,e)
+
+ typedef SQLRETURN (SQL_API *T3SQLGetDescField) ( SQLHDESC DescriptorHandle,
+ SQLSMALLINT RecNumber,
+ SQLSMALLINT FieldIdentifier,
+ SQLPOINTER ValuePtr,
+ SQLINTEGER BufferLength,
+ SQLINTEGER * StringLengthPtr);
+
+ #define N3SQLGetDescField(a,b,c,d,e,f) (*(T3SQLGetDescField)getOdbcFunction(ODBC3SQLGetDescField))(a,b,c,d,e,f)
+
+
+ typedef SQLRETURN (SQL_API *T3SQLGetDescRec) ( SQLHDESC DescriptorHandle,
+ SQLSMALLINT RecNumber,
+ SQLCHAR * Name,
+ SQLSMALLINT BufferLength,
+ SQLSMALLINT * StringLengthPtr,
+ SQLSMALLINT * TypePtr,
+ SQLSMALLINT * SubTypePtr,
+ SQLLEN * LengthPtr,
+ SQLSMALLINT * PrecisionPtr,
+ SQLSMALLINT * ScalePtr,
+ SQLSMALLINT * NullablePtr);
+
+ #define N3SQLGetDescRec(a,b,c,d,e,f,g,h,i,j,k) (*(T3SQLGetDescRec)getOdbcFunction(ODBC3SQLGetDescRec))(a,b,c,d,e,f,g,h,i,j,k)
+
+
+ typedef SQLRETURN (SQL_API *T3SQLSetDescRec) ( SQLHDESC DescriptorHandle,
+ SQLSMALLINT RecNumber,
+ SQLSMALLINT Type,
+ SQLSMALLINT SubType,
+ SQLINTEGER Length,
+ SQLSMALLINT Precision,
+ SQLSMALLINT Scale,
+ SQLPOINTER DataPtr,
+ SQLLEN * StringLengthPtr,
+ SQLLEN * IndicatorPtr);
+
+ #define N3SQLSetDescRec(a,b,c,d,e,f,g,h,i,j) (*(T3SQLSetDescRec)getOdbcFunction(ODBC3SQLSetDescRec))(a,b,c,d,e,f,g,h,i,j)
+ */
+
+ // Preparing SQL requests
+ typedef SQLRETURN (SQL_API *T3SQLPrepare) ( SQLHSTMT StatementHandle,
+ SQLCHAR * StatementText,
+ SQLINTEGER TextLength);
+
+ #define N3SQLPrepare(a,b,c) (*(T3SQLPrepare)getOdbcFunction(ODBC3SQLPrepare))(a,b,c)
+
+ typedef SQLRETURN (SQL_API *T3SQLBindParameter) (SQLHSTMT StatementHandle,
+ SQLUSMALLINT ParameterNumber,
+ SQLSMALLINT InputOutputType,
+ SQLSMALLINT ValueType,
+ SQLSMALLINT ParameterType,
+ SQLULEN ColumnSize,
+ SQLSMALLINT DecimalDigits,
+ SQLPOINTER ParameterValuePtr,
+ SQLLEN BufferLength,
+ SQLLEN * StrLen_or_IndPtr);
+
+ #define N3SQLBindParameter(a,b,c,d,e,f,g,h,i,j) (*(T3SQLBindParameter)getOdbcFunction(ODBC3SQLBindParameter))(a,b,c,d,e,f,g,h,i,j)
+
+ /*typedef SQLRETURN (SQL_API *T3SQLGetCursorName) (SQLHSTMT StatementHandle,
+ SQLCHAR * CursorName,
+ SQLSMALLINT BufferLength,
+ SQLSMALLINT * NameLengthPtr);
+
+ #define N3SQLGetCursorName(a,b,c,d) (*(T3SQLGetCursorName)getOdbcFunction(ODBC3SQLGetCursorName))(a,b,c,d)
+ */
+
+ typedef SQLRETURN (SQL_API *T3SQLSetCursorName) (SQLHSTMT StatementHandle,
+ SQLCHAR * CursorName,
+ SQLSMALLINT NameLength);
+
+ #define N3SQLSetCursorName(a,b,c) (*(T3SQLSetCursorName)getOdbcFunction(ODBC3SQLSetCursorName))(a,b,c)
+
+ // Submitting requests
+ typedef SQLRETURN (SQL_API *T3SQLExecute) ( SQLHSTMT StatementHandle);
+
+ #define N3SQLExecute(a) (*(T3SQLExecute)getOdbcFunction(ODBC3SQLExecute))(a)
+
+ typedef SQLRETURN (SQL_API *T3SQLExecDirect) ( SQLHSTMT StatementHandle,
+ SQLCHAR * StatementText,
+ SQLINTEGER TextLength);
+
+ #define N3SQLExecDirect(a,b,c) (*(T3SQLExecDirect)getOdbcFunction(ODBC3SQLExecDirect))(a,b,c)
+
+ /*typedef SQLRETURN (SQL_API *T3SQLNativeSql) ( SQLHDBC ConnectionHandle,
+ SQLCHAR * InStatementText,
+ SQLINTEGER TextLength1,
+ SQLCHAR * utStatementText,
+ SQLINTEGER BufferLength,
+ SQLINTEGER * TextLength2Ptr);
+
+ #define N3SQLNativeSql(a,b,c,d,e,f) (*(T3SQLNativeSql)getOdbcFunction(ODBC3SQLNativeSql))(a,b,c,d,e,f)*/
+
+ typedef SQLRETURN (SQL_API *T3SQLDescribeParam) (SQLHSTMT StatementHandle,
+ SQLUSMALLINT ParameterNumber,
+ SQLSMALLINT * DataTypePtr,
+ SQLULEN * ParameterSizePtr,
+ SQLSMALLINT * DecimalDigitsPtr,
+ SQLSMALLINT * NullablePtr);
+
+ #define N3SQLDescribeParam(a,b,c,d,e,f) (*(T3SQLDescribeParam)getOdbcFunction(ODBC3SQLDescribeParam))(a,b,c,d,e,f)
+
+ typedef SQLRETURN (SQL_API *T3SQLNumParams) ( SQLHSTMT StatementHandle,
+ SQLSMALLINT * ParameterCountPtr);
+
+ #define N3SQLNumParams(a,b) (*(T3SQLNumParams)getOdbcFunction(ODBC3SQLNumParams))(a,b)
+
+ typedef SQLRETURN (SQL_API *T3SQLParamData) ( SQLHSTMT StatementHandle,
+ SQLPOINTER * ValuePtrPtr);
+
+ #define N3SQLParamData(a,b) (*(T3SQLParamData)getOdbcFunction(ODBC3SQLParamData))(a,b)
+
+ typedef SQLRETURN (SQL_API *T3SQLPutData) ( SQLHSTMT StatementHandle,
+ SQLPOINTER DataPtr,
+ SQLLEN StrLen_or_Ind);
+
+ #define N3SQLPutData(a,b,c) (*(T3SQLPutData)getOdbcFunction(ODBC3SQLPutData))(a,b,c)
+
+ // Retrieving results and information about results
+ typedef SQLRETURN (SQL_API *T3SQLRowCount) ( SQLHSTMT StatementHandle,
+ SQLLEN * RowCountPtr);
+
+ #define N3SQLRowCount(a,b) (*(T3SQLRowCount)getOdbcFunction(ODBC3SQLRowCount))(a,b)
+
+ typedef SQLRETURN (SQL_API *T3SQLNumResultCols) (SQLHSTMT StatementHandle,
+ SQLSMALLINT * ColumnCountPtr);
+
+ #define N3SQLNumResultCols(a,b) (*(T3SQLNumResultCols)getOdbcFunction(ODBC3SQLNumResultCols))(a,b)
+
+ typedef SQLRETURN (SQL_API *T3SQLDescribeCol) ( SQLHSTMT StatementHandle,
+ SQLUSMALLINT ColumnNumber,
+ SQLCHAR * ColumnName,
+ SQLSMALLINT BufferLength,
+ SQLSMALLINT * NameLengthPtr,
+ SQLSMALLINT * DataTypePtr,
+ SQLULEN * ColumnSizePtr,
+ SQLSMALLINT * DecimalDigitsPtr,
+ SQLSMALLINT * NullablePtr);
+
+ #define N3SQLDescribeCol(a,b,c,d,e,f,g,h,i) (*(T3SQLDescribeCol)getOdbcFunction(ODBC3SQLDescribeCol))(a,b,c,d,e,f,g,h,i)
+
+ typedef SQLRETURN (SQL_API *T3SQLColAttribute) (SQLHSTMT StatementHandle,
+ SQLUSMALLINT ColumnNumber,
+ SQLUSMALLINT FieldIdentifier,
+ SQLPOINTER CharacterAttributePtr,
+ SQLSMALLINT BufferLength,
+ SQLSMALLINT * StringLengthPtr,
+ SQLLEN * NumericAttributePtr);
+
+ #define N3SQLColAttribute(a,b,c,d,e,f,g) (*(T3SQLColAttribute)getOdbcFunction(ODBC3SQLColAttribute))(a,b,c,d,e,f,g)
+
+ typedef SQLRETURN (SQL_API *T3SQLBindCol) ( SQLHSTMT StatementHandle,
+ SQLUSMALLINT ColumnNumber,
+ SQLSMALLINT TargetType,
+ SQLPOINTER TargetValuePtr,
+ SQLLEN BufferLength,
+ SQLLEN * StrLen_or_IndPtr);
+
+ #define N3SQLBindCol(a,b,c,d,e,f) (*(T3SQLBindCol)getOdbcFunction(ODBC3SQLBindCol))(a,b,c,d,e,f)
+
+ typedef SQLRETURN (SQL_API *T3SQLFetch) ( SQLHSTMT StatementHandle);
+
+ #define N3SQLFetch(a) (*(T3SQLFetch)getOdbcFunction(ODBC3SQLFetch))(a)
+
+ typedef SQLRETURN (SQL_API *T3SQLFetchScroll) ( SQLHSTMT StatementHandle,
+ SQLSMALLINT FetchOrientation,
+ SQLLEN FetchOffset);
+
+ #define N3SQLFetchScroll(a,b,c) (*(T3SQLFetchScroll)getOdbcFunction(ODBC3SQLFetchScroll))(a,b,c)
+
+ typedef SQLRETURN (SQL_API *T3SQLGetData) ( SQLHSTMT StatementHandle,
+ SQLUSMALLINT ColumnNumber,
+ SQLSMALLINT TargetType,
+ SQLPOINTER TargetValuePtr,
+ SQLLEN BufferLength,
+ SQLLEN * StrLen_or_IndPtr);
+
+ #define N3SQLGetData(a,b,c,d,e,f) (*(T3SQLGetData)getOdbcFunction(ODBC3SQLGetData))(a,b,c,d,e,f)
+
+ typedef SQLRETURN (SQL_API *T3SQLSetPos) ( SQLHSTMT StatementHandle,
+ SQLSETPOSIROW RowNumber,
+ SQLUSMALLINT Operation,
+ SQLUSMALLINT LockType);
+
+ #define N3SQLSetPos(a,b,c,d) (*(T3SQLSetPos)getOdbcFunction(ODBC3SQLSetPos))(a,b,c,d)
+
+ typedef SQLRETURN (SQL_API *T3SQLBulkOperations) ( SQLHSTMT StatementHandle,
+ SQLSMALLINT Operation);
+
+ #define N3SQLBulkOperations(a,b) (*(T3SQLBulkOperations)getOdbcFunction(ODBC3SQLBulkOperations))(a,b)
+
+ typedef SQLRETURN (SQL_API *T3SQLMoreResults) ( SQLHSTMT StatementHandle);
+
+ #define N3SQLMoreResults(a) (*(T3SQLMoreResults)getOdbcFunction(ODBC3SQLMoreResults))(a)
+
+ /*typedef SQLRETURN (SQL_API *T3SQLGetDiagField) (SQLSMALLINT HandleType,
+ SQLHANDLE Handle,
+ SQLSMALLINT RecNumber,
+ SQLSMALLINT DiagIdentifier,
+ SQLPOINTER DiagInfoPtr,
+ SQLSMALLINT BufferLength,
+ SQLSMALLINT * StringLengthPtr);
+
+ #define N3SQLGetDiagField(a,b,c,d,e,f,g) (*(T3SQLGetDiagField)getOdbcFunction(ODBC3SQLGetDiagField))(a,b,c,d,e,f,g)*/
+
+ typedef SQLRETURN (SQL_API *T3SQLGetDiagRec) ( SQLSMALLINT HandleType,
+ SQLHANDLE Handle,
+ SQLSMALLINT RecNumber,
+ SQLCHAR * Sqlstate,
+ SQLINTEGER * NativeErrorPtr,
+ SQLCHAR * MessageText,
+ SQLSMALLINT BufferLength,
+ SQLSMALLINT * TextLengthPtr);
+
+
+ #define N3SQLGetDiagRec(a,b,c,d,e,f,g,h) (*(T3SQLGetDiagRec)getOdbcFunction(ODBC3SQLGetDiagRec))(a,b,c,d,e,f,g,h)
+
+ // Obtaining information about the data source's system tables (catalog functions)
+ typedef SQLRETURN (SQL_API *T3SQLColumnPrivileges) (SQLHSTMT StatementHandle,
+ SQLCHAR * CatalogName,
+ SQLSMALLINT NameLength1,
+ SQLCHAR * SchemaName,
+ SQLSMALLINT NameLength2,
+ SQLCHAR * TableName,
+ SQLSMALLINT NameLength3,
+ SQLCHAR * ColumnName,
+ SQLSMALLINT NameLength4);
+
+ #define N3SQLColumnPrivileges(a,b,c,d,e,f,g,h,i) (*(T3SQLColumnPrivileges)getOdbcFunction(ODBC3SQLColumnPrivileges))(a,b,c,d,e,f,g,h,i)
+
+ typedef SQLRETURN (SQL_API *T3SQLColumns) ( SQLHSTMT StatementHandle,
+ SQLCHAR * CatalogName,
+ SQLSMALLINT NameLength1,
+ SQLCHAR * SchemaName,
+ SQLSMALLINT NameLength2,
+ SQLCHAR * TableName,
+ SQLSMALLINT NameLength3,
+ SQLCHAR * ColumnName,
+ SQLSMALLINT NameLength4);
+
+ #define N3SQLColumns(a,b,c,d,e,f,g,h,i) (*(T3SQLColumns)getOdbcFunction(ODBC3SQLColumns))(a,b,c,d,e,f,g,h,i)
+
+ typedef SQLRETURN (SQL_API *T3SQLForeignKeys) ( SQLHSTMT StatementHandle,
+ SQLCHAR * PKCatalogName,
+ SQLSMALLINT NameLength1,
+ SQLCHAR * PKSchemaName,
+ SQLSMALLINT NameLength2,
+ SQLCHAR * PKTableName,
+ SQLSMALLINT NameLength3,
+ SQLCHAR * FKCatalogName,
+ SQLSMALLINT NameLength4,
+ SQLCHAR * FKSchemaName,
+ SQLSMALLINT NameLength5,
+ SQLCHAR * FKTableName,
+ SQLSMALLINT NameLength6);
+
+ #define N3SQLForeignKeys(a,b,c,d,e,f,g,h,i,j,k,l,m) (*(T3SQLForeignKeys)getOdbcFunction(ODBC3SQLForeignKeys))(a,b,c,d,e,f,g,h,i,j,k,l,m)
+
+ typedef SQLRETURN (SQL_API *T3SQLPrimaryKeys) ( SQLHSTMT StatementHandle,
+ SQLCHAR * CatalogName,
+ SQLSMALLINT NameLength1,
+ SQLCHAR * SchemaName,
+ SQLSMALLINT NameLength2,
+ SQLCHAR * TableName,
+ SQLSMALLINT NameLength3);
+
+ #define N3SQLPrimaryKeys(a,b,c,d,e,f,g) (*(T3SQLPrimaryKeys)getOdbcFunction(ODBC3SQLPrimaryKeys))(a,b,c,d,e,f,g)
+
+ typedef SQLRETURN (SQL_API *T3SQLProcedureColumns) (SQLHSTMT StatementHandle,
+ SQLCHAR * CatalogName,
+ SQLSMALLINT NameLength1,
+ SQLCHAR * SchemaName,
+ SQLSMALLINT NameLength2,
+ SQLCHAR * ProcName,
+ SQLSMALLINT NameLength3,
+ SQLCHAR * ColumnName,
+ SQLSMALLINT NameLength4);
+
+ #define N3SQLProcedureColumns(a,b,c,d,e,f,g,h,i) (*(T3SQLProcedureColumns)getOdbcFunction(ODBC3SQLProcedureColumns))(a,b,c,d,e,f,g,h,i)
+
+ typedef SQLRETURN (SQL_API *T3SQLProcedures) ( SQLHSTMT StatementHandle,
+ SQLCHAR * CatalogName,
+ SQLSMALLINT NameLength1,
+ SQLCHAR * SchemaName,
+ SQLSMALLINT NameLength2,
+ SQLCHAR * ProcName,
+ SQLSMALLINT NameLength3);
+
+ #define N3SQLProcedures(a,b,c,d,e,f,g) (*(T3SQLProcedures)getOdbcFunction(ODBC3SQLProcedures))(a,b,c,d,e,f,g)
+
+ typedef SQLRETURN (SQL_API *T3SQLSpecialColumns) (SQLHSTMT StatementHandle,
+ SQLUSMALLINT IdentifierType,
+ SQLCHAR * CatalogName,
+ SQLSMALLINT NameLength1,
+ SQLCHAR * SchemaName,
+ SQLSMALLINT NameLength2,
+ SQLCHAR * TableName,
+ SQLSMALLINT NameLength3,
+ SQLUSMALLINT Scope,
+ SQLUSMALLINT Nullable);
+
+ #define N3SQLSpecialColumns(a,b,c,d,e,f,g,h,i,j) (*(T3SQLSpecialColumns)getOdbcFunction(ODBC3SQLSpecialColumns))(a,b,c,d,e,f,g,h,i,j)
+
+ typedef SQLRETURN (SQL_API *T3SQLStatistics) ( SQLHSTMT StatementHandle,
+ SQLCHAR * CatalogName,
+ SQLSMALLINT NameLength1,
+ SQLCHAR * SchemaName,
+ SQLSMALLINT NameLength2,
+ SQLCHAR * TableName,
+ SQLSMALLINT NameLength3,
+ SQLUSMALLINT Unique,
+ SQLUSMALLINT Reserved);
+
+ #define N3SQLStatistics(a,b,c,d,e,f,g,h,i) (*(T3SQLStatistics)getOdbcFunction(ODBC3SQLStatistics))(a,b,c,d,e,f,g,h,i)
+
+ typedef SQLRETURN (SQL_API *T3SQLTablePrivileges) (SQLHSTMT StatementHandle,
+ SQLCHAR * CatalogName,
+ SQLSMALLINT NameLength1,
+ SQLCHAR * SchemaName,
+ SQLSMALLINT NameLength2,
+ SQLCHAR * TableName,
+ SQLSMALLINT NameLength3);
+
+ #define N3SQLTablePrivileges(a,b,c,d,e,f,g) (*(T3SQLTablePrivileges)getOdbcFunction(ODBC3SQLTablePrivileges))(a,b,c,d,e,f,g)
+
+ typedef SQLRETURN (SQL_API *T3SQLTables) ( SQLHSTMT StatementHandle,
+ SQLCHAR * CatalogName,
+ SQLSMALLINT NameLength1,
+ SQLCHAR * SchemaName,
+ SQLSMALLINT NameLength2,
+ SQLCHAR * TableName,
+ SQLSMALLINT NameLength3,
+ SQLCHAR * TableType,
+ SQLSMALLINT NameLength4);
+
+ #define N3SQLTables(a,b,c,d,e,f,g,h,i) (*(T3SQLTables)getOdbcFunction(ODBC3SQLTables))(a,b,c,d,e,f,g,h,i)
+
+ // Terminating a statement
+ typedef SQLRETURN (SQL_API *T3SQLFreeStmt) ( SQLHSTMT StatementHandle,
+ SQLUSMALLINT Option);
+
+ #define N3SQLFreeStmt(a,b) (*(T3SQLFreeStmt)getOdbcFunction(ODBC3SQLFreeStmt))(a,b)
+
+ typedef SQLRETURN (SQL_API *T3SQLCloseCursor) (SQLHSTMT StatementHandle);
+
+ #define N3SQLCloseCursor(a) (*(T3SQLCloseCursor)getOdbcFunction(ODBC3SQLCloseCursor))(a)
+
+ typedef SQLRETURN (SQL_API *T3SQLCancel) ( SQLHSTMT StatementHandle);
+
+ #define N3SQLCancel(a) (*(T3SQLCancel)getOdbcFunction(ODBC3SQLCancel))(a)
+
+ typedef SQLRETURN (SQL_API *T3SQLEndTran) ( SQLSMALLINT HandleType,
+ SQLHANDLE Handle,
+ SQLSMALLINT CompletionType);
+
+ #define N3SQLEndTran(a,b,c) (*(T3SQLEndTran)getOdbcFunction(ODBC3SQLEndTran))(a,b,c)
+
+ // Terminating a connection
+ typedef SQLRETURN (SQL_API *T3SQLDisconnect) (SQLHDBC ConnectionHandle);
+
+ #define N3SQLDisconnect(a) (*(T3SQLDisconnect)getOdbcFunction(ODBC3SQLDisconnect))(a)
+
+ typedef SQLRETURN (SQL_API *T3SQLFreeHandle) (SQLSMALLINT HandleType,
+ SQLHANDLE Handle);
+
+ #define N3SQLFreeHandle(a,b) (*(T3SQLFreeHandle)getOdbcFunction(ODBC3SQLFreeHandle))(a,b)
+
+ typedef SQLRETURN (SQL_API *T3SQLGetCursorName) ( SQLHSTMT StatementHandle,
+ SQLCHAR * CursorName,
+ SQLSMALLINT BufferLength,
+ SQLSMALLINT* NameLength2);
+
+ #define N3SQLGetCursorName(a,b,c,d) (*(T3SQLGetCursorName)getOdbcFunction(ODBC3SQLGetCursorName))(a,b,c,d)
+
+ typedef SQLRETURN (SQL_API *T3SQLNativeSql) ( SQLHSTMT ConnectionHandle,
+ SQLCHAR * InStatementText,
+ SQLINTEGER TextLength1,
+ SQLCHAR * OutStatementText,
+ SQLINTEGER BufferLength,
+ SQLINTEGER * TextLength2Ptr);
+
+ #define N3SQLNativeSql(a,b,c,d,e,f) (*(T3SQLNativeSql)getOdbcFunction(ODBC3SQLNativeSql))(a,b,c,d,e,f)
+}
+
+#endif // _CONNECTIVITY_ODBC_OFUNCTIONS_HXX_
+
+
diff --git a/connectivity/source/inc/odbc/OPreparedStatement.hxx b/connectivity/source/inc/odbc/OPreparedStatement.hxx
new file mode 100644
index 000000000000..ff7ca19f7d1d
--- /dev/null
+++ b/connectivity/source/inc/odbc/OPreparedStatement.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_ODBC_OPREPAREDSTATEMENT_HXX_
+#define _CONNECTIVITY_ODBC_OPREPAREDSTATEMENT_HXX_
+
+#include "odbc/odbcbasedllapi.hxx"
+#include "odbc/OStatement.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>
+#include <cppuhelper/implbase5.hxx>
+
+namespace connectivity
+{
+ namespace odbc
+ {
+
+ class OBoundParam;
+ typedef ::cppu::ImplHelper5< ::com::sun::star::sdbc::XPreparedStatement,
+ ::com::sun::star::sdbc::XParameters,
+ ::com::sun::star::sdbc::XPreparedBatchExecution,
+ ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ ::com::sun::star::lang::XServiceInfo> OPreparedStatement_BASE;
+
+ class OOO_DLLPUBLIC_ODBCBASE OPreparedStatement :
+ public OStatement_BASE2,
+ 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
+ //====================================================================
+ SQLSMALLINT numParams; // Number of parameter markers
+ // for the prepared statement
+
+ OBoundParam* boundParams;
+ // Array of bound parameter
+ // objects. Each parameter
+ // marker will have a
+ // corresponding object to
+ // hold bind information, and
+ // resulting data.
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData;
+ sal_Bool m_bPrepared;
+
+ void FreeParams();
+ void putParamData (sal_Int32 index) throw(::com::sun::star::sdbc::SQLException);
+ void setStream (sal_Int32 ParameterIndex,const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& x,
+ SQLLEN length,sal_Int32 SQLtype) throw(::com::sun::star::sdbc::SQLException);
+ sal_Int32 getParamLength ( sal_Int32 index);
+ sal_Int8* getLengthBuf (sal_Int32 index);
+ sal_Int8* getDataBuf (sal_Int32 index);
+ sal_Int8* allocBindBuf ( sal_Int32 index, sal_Int32 bufLen);
+ void initBoundParam () throw(::com::sun::star::sdbc::SQLException);
+ void setParameter(sal_Int32 parameterIndex,sal_Int32 _nType,sal_Int32 _nSize,void* _pData);
+
+ sal_Int32 getPrecision ( sal_Int32 sqlType);
+
+ sal_Bool isPrepared() const { return m_bPrepared;}
+ void prepareStatement();
+ void checkParameterIndex(sal_Int32 _parameterIndex);
+ void setDecimal( sal_Int32 parameterIndex, const ::rtl::OUString& x );
+
+ /**
+ creates the driver specific resultset (factory)
+ */
+ virtual OResultSet* createResulSet();
+
+ protected:
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue)
+ throw (::com::sun::star::uno::Exception);
+ public:
+ DECLARE_SERVICE_INFO();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ OPreparedStatement( OConnection* _pConnection,const ::rtl::OUString& sql);
+
+ //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);
+ // XPreparedBatchExecution
+ virtual void SAL_CALL addBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) 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);
+
+ public:
+ using OStatement_Base::executeQuery;
+ using OStatement_Base::executeUpdate;
+ using OStatement_Base::execute;
+ };
+ }
+}
+#endif // _CONNECTIVITY_ODBC_OPREPAREDSTATEMENT_HXX_
+
diff --git a/connectivity/source/inc/odbc/OResultSet.hxx b/connectivity/source/inc/odbc/OResultSet.hxx
new file mode 100644
index 000000000000..41aee7db1cea
--- /dev/null
+++ b/connectivity/source/inc/odbc/OResultSet.hxx
@@ -0,0 +1,327 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_ODBC_ORESULTSET_HXX_
+#define _CONNECTIVITY_ODBC_ORESULTSET_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/compbase12.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include "odbc/OFunctions.hxx"
+#include "odbc/OStatement.hxx"
+#include "odbc/odbcbasedllapi.hxx"
+#include "connectivity/CommonTools.hxx"
+#include "connectivity/FValue.hxx"
+#include "TSkipDeletedSet.hxx"
+
+namespace connectivity
+{
+ namespace odbc
+ {
+
+ /*
+ ** 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::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> OResultSet_BASE;
+
+
+ typedef ::std::pair<sal_Int64,sal_Int32> TVoidPtr;
+ typedef ::std::allocator< TVoidPtr > TVoidAlloc;
+ typedef ::std::vector<TVoidPtr> TVoidVector;
+ // typedef ::com::sun::star::uno::Sequence<TVoidPtr> TVoidVector;
+ /// unary_function Functor object for class ZZ returntype is void
+ struct OOO_DLLPUBLIC_ODBCBASE TBookmarkPosMapCompare : ::std::binary_function< ::com::sun::star::uno::Sequence<sal_Int8>, ::com::sun::star::uno::Sequence<sal_Int8>, bool >
+ {
+ inline bool operator()( const ::com::sun::star::uno::Sequence<sal_Int8>& _rLH,
+ const ::com::sun::star::uno::Sequence<sal_Int8>& _rRH) const
+ {
+ if(_rLH.getLength() == _rRH.getLength())
+ {
+ sal_Int32 nCount = _rLH.getLength();
+ if(nCount != 4)
+ {
+ const sal_Int8* pLHBack = _rLH.getConstArray() + nCount - 1;
+ const sal_Int8* pRHBack = _rRH.getConstArray() + nCount - 1;
+
+ sal_Int32 i;
+ for(i=0;i < nCount;++i,--pLHBack,--pRHBack)
+ {
+ if(!(*pLHBack) && *pRHBack)
+ return sal_True;
+ else if(*pLHBack && !(*pRHBack))
+ return sal_False;
+ }
+ for(i=0,++pLHBack,++pRHBack;i < nCount;++pLHBack,++pRHBack,++i)
+ if(*pLHBack < *pRHBack)
+ return sal_True;
+ return sal_False;
+ }
+ else
+ return *reinterpret_cast<const sal_Int32*>(_rLH.getConstArray()) < *reinterpret_cast<const sal_Int32*>(_rRH.getConstArray());
+
+ }
+ else
+ return _rLH.getLength() < _rRH.getLength();
+ }
+ };
+
+ typedef ::std::map< ::com::sun::star::uno::Sequence<sal_Int8>, sal_Int32,TBookmarkPosMapCompare > TBookmarkPosMap;
+
+ class OOO_DLLPUBLIC_ODBCBASE OResultSet :
+ public comphelper::OBaseMutex,
+ public ::connectivity::IResultSetHelper,
+ public OResultSet_BASE,
+ public ::cppu::OPropertySetHelper,
+ public ::comphelper::OPropertyArrayUsageHelper<OResultSet>
+ {
+ protected:
+ TBookmarkPosMap m_aPosToBookmarks;
+ // used top hold the information about the value and the datatype to save calls to metadata
+ typedef ::std::vector<ORowSetValue> TDataRow;
+
+ TVoidVector m_aBindVector;
+ ::std::vector<SQLLEN> m_aLengthVector;
+ ::std::map<sal_Int32,SWORD> m_aODBCColumnTypes;
+ ::com::sun::star::uno::Sequence<sal_Int8> m_aBookmark;
+
+ TDataRow m_aRow; // only used when SQLGetData can't be called in any order
+ ORowSetValue m_aEmptyValue; // needed for the getValue method when no prefetch is used
+ SQLHANDLE m_aStatementHandle;
+ SQLHANDLE m_aConnectionHandle;
+ OStatement_Base* m_pStatement;
+ OSkipDeletedSet* m_pSkipDeletedSet;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData;
+ SQLUSMALLINT* m_pRowStatusArray;
+ rtl_TextEncoding m_nTextEncoding;
+ sal_Int32 m_nRowPos;
+ sal_Int32 m_nLastColumnPos; // used for m_aRow just to know where we are
+ mutable sal_uInt32 m_nUseBookmarks;
+ SQLRETURN m_nCurrentFetchState;
+ sal_Bool m_bWasNull;
+ sal_Bool m_bEOF; // after last record
+ sal_Bool m_bLastRecord;
+ sal_Bool m_bFreeHandle;
+ sal_Bool m_bInserting;
+ sal_Bool m_bFetchData; // true when SQLGetaData can be called in any order or when fetching data for m_aRow
+ sal_Bool m_bRowInserted;
+ sal_Bool m_bRowDeleted;
+ sal_Bool m_bUseFetchScroll;
+
+ sal_Bool isBookmarkable() const;
+ sal_Int32 getResultSetConcurrency() const;
+ sal_Int32 getResultSetType() const;
+ sal_Int32 getFetchDirection() const;
+ sal_Int32 getFetchSize() const;
+ ::rtl::OUString getCursorName() const;
+
+ void setFetchDirection(sal_Int32 _par0);
+ void setFetchSize(sal_Int32 _par0);
+
+
+ void fillRow(sal_Int32 _nToColumn);
+ void allocBuffer();
+ void releaseBuffer();
+ void updateValue(sal_Int32 columnIndex,SQLSMALLINT _nType,void* _pValue) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void fillNeededData(SQLRETURN _nRet);
+ const ORowSetValue& getValue(sal_Int32 _nColumnIndex,SQLSMALLINT _nType,void* _pValue,SQLINTEGER _rSize);
+ sal_Bool moveImpl(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool _bRetrieveData);
+ TVoidPtr allocBindColumn(sal_Int32 _nType,sal_Int32 _nColumnIndex);
+ SQLRETURN unbind(sal_Bool _bUnbindHandle = sal_True);
+ SWORD impl_getColumnType_nothrow(sal_Int32 columnIndex);
+
+ // 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;
+ public:
+ DECLARE_SERVICE_INFO();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ OResultSet( SQLHANDLE _pStatementHandle,OStatement_Base* pStmt);
+ virtual ~OResultSet();
+
+ void construct();
+
+ inline oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const
+ {
+ return m_pStatement->getOdbcFunction(_nIndex);
+ }
+
+ ::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);
+ }
+
+ inline void setMetaData(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData>& _xMetaData) { m_xMetaData = _xMetaData;}
+
+ // ::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);
+ // 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& 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);
+
+ // IResultSetHelper
+ virtual sal_Bool move(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool _bRetrieveData);
+ virtual sal_Int32 getDriverPos() const;
+ virtual sal_Bool deletedVisible() const;
+ virtual sal_Bool isRowDeleted() const;
+
+ protected:
+ using OPropertySetHelper::getFastPropertyValue;
+ };
+ }
+}
+#endif // _CONNECTIVITY_ODBC_ORESULTSET_HXX_
+
+
diff --git a/connectivity/source/inc/odbc/OResultSetMetaData.hxx b/connectivity/source/inc/odbc/OResultSetMetaData.hxx
new file mode 100644
index 000000000000..f0a1605034af
--- /dev/null
+++ b/connectivity/source/inc/odbc/OResultSetMetaData.hxx
@@ -0,0 +1,126 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_ODBC_ORESULTSETMETADATA_HXX_
+#define _CONNECTIVITY_ODBC_ORESULTSETMETADATA_HXX_
+
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include "odbc/OFunctions.hxx"
+#include "odbc/odbcbasedllapi.hxx"
+#ifndef _VECTOR_
+#include <vector>
+#endif
+#include "odbc/OConnection.hxx"
+
+namespace connectivity
+{
+ namespace odbc
+ {
+ //**************************************************************
+ //************ Class: ResultSetMetaData
+ //**************************************************************
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> OResultSetMetaData_BASE;
+
+ class OOO_DLLPUBLIC_ODBCBASE OResultSetMetaData :
+ public OResultSetMetaData_BASE
+ {
+ protected:
+ ::std::vector<sal_Int32> m_vMapping; // when not every column is needed
+ ::std::map<sal_Int32,sal_Int32> m_aColumnTypes;
+
+ SQLHANDLE m_aStatementHandle;
+ OConnection* m_pConnection;
+ sal_Int32 m_nColCount;
+ sal_Bool m_bUseODBC2Types;
+
+ ::rtl::OUString getCharColAttrib(sal_Int32 column,sal_Int32 ident) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getNumColAttrib(sal_Int32 column,sal_Int32 ident) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ public:
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ OResultSetMetaData(OConnection* _pConnection, SQLHANDLE _pStmt )
+ :m_aStatementHandle( _pStmt )
+ ,m_pConnection(_pConnection)
+ ,m_nColCount(-1)
+ ,m_bUseODBC2Types(sal_False)
+ {}
+ OResultSetMetaData(OConnection* _pConnection, SQLHANDLE _pStmt ,const ::std::vector<sal_Int32> & _vMapping)
+ :m_vMapping(_vMapping)
+ ,m_aStatementHandle( _pStmt )
+ ,m_pConnection(_pConnection)
+ ,m_nColCount(_vMapping.size()-1)
+ ,m_bUseODBC2Types(sal_False)
+ {}
+ virtual ~OResultSetMetaData();
+
+
+ static SQLLEN getNumColAttrib(OConnection* _pConnection
+ ,SQLHANDLE _aStatementHandle
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface
+ ,sal_Int32 _column
+ ,sal_Int32 ident) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ static SQLSMALLINT 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);
+
+ inline oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const
+ {
+ return m_pConnection->getOdbcFunction(_nIndex);
+ }
+ /// 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_ODBC_ORESULTSETMETADATA_HXX_
+
diff --git a/connectivity/source/inc/odbc/OStatement.hxx b/connectivity/source/inc/odbc/OStatement.hxx
new file mode 100644
index 000000000000..57c8e4c2fa09
--- /dev/null
+++ b/connectivity/source/inc/odbc/OStatement.hxx
@@ -0,0 +1,248 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_ODBC_OSTATEMENT_HXX_
+#define _CONNECTIVITY_ODBC_OSTATEMENT_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/XBatchExecution.hpp>
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
+#include <comphelper/proparrhlp.hxx>
+#include <cppuhelper/compbase6.hxx>
+#include <comphelper/uno3.hxx>
+#include "connectivity/CommonTools.hxx"
+#include "odbc/OFunctions.hxx"
+#include "odbc/OConnection.hxx"
+#include "odbc/odbcbasedllapi.hxx"
+#include <list>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <comphelper/broadcasthelper.hxx>
+
+namespace connectivity
+{
+ namespace odbc
+ {
+
+ typedef ::cppu::WeakComponentImplHelper6< ::com::sun::star::sdbc::XStatement,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::util::XCancellable,
+ ::com::sun::star::sdbc::XCloseable,
+ ::com::sun::star::sdbc::XGeneratedResultSet,
+ ::com::sun::star::sdbc::XMultipleResults> OStatement_BASE;
+
+ class OResultSet;
+ //**************************************************************
+ //************ Class: java.sql.Statement
+ //**************************************************************
+ class OOO_DLLPUBLIC_ODBCBASE OStatement_Base :
+ public comphelper::OBaseMutex,
+ public OStatement_BASE,
+ public ::cppu::OPropertySetHelper,
+ public ::comphelper::OPropertyArrayUsageHelper<OStatement_Base>
+
+ {
+ ::com::sun::star::sdbc::SQLWarning m_aLastWarning;
+ protected:
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement> m_xGeneratedStatement;
+ // for this Statement
+
+ ::std::list< ::rtl::OUString> m_aBatchList;
+ ::rtl::OUString m_sSqlStatement;
+
+ OConnection* m_pConnection;// The owning Connection object
+ SQLHANDLE m_aStatementHandle;
+ SQLUSMALLINT* m_pRowStatusArray;
+ ::cppu::OBroadcastHelper& rBHelper;
+
+ protected:
+
+ sal_Int32 getQueryTimeOut() const;
+ sal_Int32 getMaxFieldSize() const;
+ sal_Int32 getMaxRows() const;
+ sal_Int32 getResultSetConcurrency() const;
+ sal_Int32 getResultSetType() const;
+ sal_Int32 getFetchDirection() const;
+ sal_Int32 getFetchSize() const;
+ ::rtl::OUString getCursorName() const;
+ sal_Bool isUsingBookmarks() const;
+ sal_Bool getEscapeProcessing() const;
+ sal_Int32 getStmtOption (short fOption) const;
+
+ void setQueryTimeOut(sal_Int32 _par0) ;
+ void setMaxFieldSize(sal_Int32 _par0) ;
+ void setMaxRows(sal_Int32 _par0) ;
+ void setFetchDirection(sal_Int32 _par0) ;
+ void setFetchSize(sal_Int32 _par0) ;
+ void setCursorName(const ::rtl::OUString &_par0);
+ void setEscapeProcessing( const sal_Bool _bEscapeProc );
+
+ virtual void setResultSetConcurrency(sal_Int32 _par0) ;
+ virtual void setResultSetType(sal_Int32 _par0) ;
+ virtual void setUsingBookmarks(sal_Bool _bUseBookmark) ;
+
+ void reset () throw( ::com::sun::star::sdbc::SQLException);
+ void clearMyResultSet () throw( ::com::sun::star::sdbc::SQLException);
+ void setWarning (const ::com::sun::star::sdbc::SQLWarning &ex) throw( ::com::sun::star::sdbc::SQLException);
+ sal_Bool lockIfNecessary (const ::rtl::OUString& sql) throw( ::com::sun::star::sdbc::SQLException);
+ sal_Int32 getColumnCount () throw( ::com::sun::star::sdbc::SQLException);
+
+ //--------------------------------------------------------------------
+ // getResultSet
+ // getResultSet returns the current result as a ResultSet. It
+ // returns NULL if the current result is not a ResultSet.
+ //--------------------------------------------------------------------
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > getResultSet (sal_Bool checkCount) throw( ::com::sun::star::sdbc::SQLException);
+ /**
+ creates the driver specific resultset (factory)
+ */
+ virtual OResultSet* createResulSet();
+
+ SQLLEN getRowCount () throw( ::com::sun::star::sdbc::SQLException);
+
+
+ void disposeResultSet();
+
+ // 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 ~OStatement_Base();
+
+ public:
+ OStatement_Base(OConnection* _pConnection );
+ using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
+
+ inline oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const
+ {
+ return m_pConnection->getOdbcFunction(_nIndex);
+ }
+ // 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);
+ // 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);
+ // 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);
+ //XGeneratedResultSet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getGeneratedValues( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // other methods
+ SQLHANDLE getConnectionHandle() { return m_pConnection->getConnection(); }
+ OConnection* getOwnConnection() const { return m_pConnection;}
+ /** getCursorProperties return the properties for a specific cursor type
+ @param _nCursorType the CursorType
+ @param bFirst when true the first property set is returned
+
+ @return the cursor properties
+ */
+ SQLUINTEGER getCursorProperties(SQLINTEGER _nCursorType,sal_Bool bFirst);
+
+ protected:
+ using OPropertySetHelper::getFastPropertyValue;
+ };
+
+ class OOO_DLLPUBLIC_ODBCBASE OStatement_BASE2 :
+ public OStatement_Base
+ ,public ::connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>
+
+ {
+ friend class OSubComponent<OStatement_BASE2, OStatement_BASE>;
+ public:
+ OStatement_BASE2(OConnection* _pConnection ) : OStatement_Base(_pConnection ),
+ ::connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this){}
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XInterface
+ virtual void SAL_CALL release() throw();
+ };
+
+ class OOO_DLLPUBLIC_ODBCBASE OStatement :
+ public OStatement_BASE2,
+ public ::com::sun::star::sdbc::XBatchExecution,
+ public ::com::sun::star::lang::XServiceInfo
+ {
+ protected:
+ virtual ~OStatement(){}
+ public:
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ OStatement( OConnection* _pConnection) : OStatement_BASE2( _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();
+ // XBatchExecution
+ virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+#endif // _CONNECTIVITY_ODBC_OSTATEMENT_HXX_
+
diff --git a/connectivity/source/inc/odbc/OTools.hxx b/connectivity/source/inc/odbc/OTools.hxx
new file mode 100644
index 000000000000..3c311242114d
--- /dev/null
+++ b/connectivity/source/inc/odbc/OTools.hxx
@@ -0,0 +1,276 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_OTOOLS_HXX_
+#define _CONNECTIVITY_OTOOLS_HXX_
+
+#include "odbc/OFunctiondefs.hxx"
+#include "odbc/odbcbasedllapi.hxx"
+#include <com/sun/star/sdbc/SQLException.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include <osl/thread.h>
+#include <rtl/ustring.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <rtl/textenc.h>
+
+#define ODBC3SQLAllocHandle 1
+#define ODBC3SQLConnect 2
+#define ODBC3SQLDriverConnect 3
+#define ODBC3SQLBrowseConnect 4
+#define ODBC3SQLDataSources 5
+#define ODBC3SQLDrivers 6
+#define ODBC3SQLGetInfo 7
+#define ODBC3SQLGetFunctions 8
+#define ODBC3SQLGetTypeInfo 9
+#define ODBC3SQLSetConnectAttr 10
+#define ODBC3SQLGetConnectAttr 11
+#define ODBC3SQLSetEnvAttr 12
+#define ODBC3SQLGetEnvAttr 13
+#define ODBC3SQLSetStmtAttr 14
+#define ODBC3SQLGetStmtAttr 15
+#define ODBC3SQLPrepare 16
+#define ODBC3SQLBindParameter 17
+#define ODBC3SQLSetCursorName 18
+#define ODBC3SQLExecute 19
+#define ODBC3SQLExecDirect 20
+#define ODBC3SQLDescribeParam 21
+#define ODBC3SQLNumParams 22
+#define ODBC3SQLParamData 23
+#define ODBC3SQLPutData 24
+#define ODBC3SQLRowCount 25
+#define ODBC3SQLNumResultCols 26
+#define ODBC3SQLDescribeCol 27
+#define ODBC3SQLColAttribute 28
+#define ODBC3SQLBindCol 29
+#define ODBC3SQLFetch 30
+#define ODBC3SQLFetchScroll 31
+#define ODBC3SQLGetData 32
+#define ODBC3SQLSetPos 33
+#define ODBC3SQLBulkOperations 34
+#define ODBC3SQLMoreResults 35
+#define ODBC3SQLGetDiagRec 36
+#define ODBC3SQLColumnPrivileges 37
+#define ODBC3SQLColumns 38
+#define ODBC3SQLForeignKeys 39
+#define ODBC3SQLPrimaryKeys 40
+#define ODBC3SQLProcedureColumns 41
+#define ODBC3SQLProcedures 42
+#define ODBC3SQLSpecialColumns 43
+#define ODBC3SQLStatistics 44
+#define ODBC3SQLTablePrivileges 45
+#define ODBC3SQLTables 46
+#define ODBC3SQLFreeStmt 47
+#define ODBC3SQLCloseCursor 48
+#define ODBC3SQLCancel 49
+#define ODBC3SQLEndTran 50
+#define ODBC3SQLDisconnect 51
+#define ODBC3SQLFreeHandle 52
+#define ODBC3SQLGetCursorName 53
+#define ODBC3SQLNativeSql 54
+
+namespace connectivity
+{
+ namespace odbc
+ {
+ class OConnection;
+
+ const sal_uInt32 ODBC_FRACTION_UNITS_PER_HSECOND = 10000000L;
+ const sal_Int32 MAX_PUT_DATA_LENGTH = 2000;
+
+ class OOO_DLLPUBLIC_ODBCBASE OTools
+ {
+ public:
+ static void ThrowException( OConnection* _pConnection,
+ SQLRETURN _rRetCode,
+ SQLHANDLE _pContext,
+ SQLSMALLINT _nHandleType,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
+ sal_Bool _bNoFound=sal_True,
+ rtl_TextEncoding _nTextEncoding = RTL_TEXTENCODING_MS_1252)
+ throw(::com::sun::star::sdbc::SQLException);
+
+ static void GetInfo(OConnection* _pConnection,
+ SQLHANDLE _aConnectionHandle,
+ SQLUSMALLINT _nInfo,
+ ::rtl::OUString &_rValue,
+ 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);
+
+ static void GetInfo(OConnection* _pConnection,
+ SQLHANDLE _aConnectionHandle,
+ SQLUSMALLINT _nInfo,
+ sal_Int32 &_rValue,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ static void GetInfo(OConnection* _pConnection,
+ SQLHANDLE _aConnectionHandle,
+ SQLUSMALLINT _nInfo,
+ SQLUSMALLINT &_rValue,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ static void GetInfo(OConnection* _pConnection,
+ SQLHANDLE _aConnectionHandle,
+ SQLUSMALLINT _nInfo,
+ SQLUINTEGER &_rValue,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ static void GetInfo(OConnection* _pConnection,
+ SQLHANDLE _aConnectionHandle,
+ SQLUSMALLINT _nInfo,
+ sal_Bool &_rValue,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ static sal_Int32 MapOdbcType2Jdbc(sal_Int32 _nType);
+ static sal_Int32 jdbcTypeToOdbc(sal_Int32 jdbcType);
+
+ static DATE_STRUCT DateToOdbcDate(const ::com::sun::star::util::Date& x)
+ {
+ DATE_STRUCT aVal;
+ aVal.year = x.Year;
+ aVal.month = x.Month;
+ aVal.day = x.Day;
+ return aVal;
+ }
+ static TIME_STRUCT TimeToOdbcTime(const ::com::sun::star::util::Time& x)
+ {
+ TIME_STRUCT aVal;
+ aVal.hour = x.Hours;
+ aVal.minute = x.Minutes;
+ aVal.second = x.Seconds;
+ return aVal;
+ }
+ static TIMESTAMP_STRUCT DateTimeToTimestamp(const ::com::sun::star::util::DateTime& x)
+ {
+ TIMESTAMP_STRUCT aVal;
+ aVal.year = x.Year;
+ aVal.month = x.Month;
+ aVal.day = x.Day;
+ aVal.hour = x.Hours;
+ aVal.minute = x.Minutes;
+ aVal.second = x.Seconds;
+ aVal.fraction = x.HundredthSeconds * ODBC_FRACTION_UNITS_PER_HSECOND;
+ return aVal;
+ }
+ /**
+ getBindTypes set the ODBC type for C
+ @param _bUseWChar true when Unicode should be used
+ @param _bUseOldTimeDate true when the old datetime format should be used
+ @param _nOdbcType the ODBC sql type
+ @param fCType the C type for the ODBC type
+ @param fSqlType the SQL type for the ODBC type
+ */
+ static void getBindTypes(sal_Bool _bUseWChar,
+ sal_Bool _bUseOldTimeDate,
+ SQLSMALLINT _nOdbcType,
+ SQLSMALLINT& fCType,
+ SQLSMALLINT& fSqlType);
+
+ static ::rtl::OUString getStringValue( OConnection* _pConnection,
+ SQLHANDLE _aStatementHandle,
+ sal_Int32 columnIndex,
+ SQLSMALLINT _fSqlType,
+ sal_Bool &_bWasNull,
+ 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);
+
+ static ::com::sun::star::uno::Sequence<sal_Int8> getBytesValue(OConnection* _pConnection,
+ SQLHANDLE _aStatementHandle,
+ sal_Int32 columnIndex,
+ SQLSMALLINT _fSqlType,
+ sal_Bool &_bWasNull,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ static void 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);
+
+ /**
+ bindData copies the from pValue to pData
+ @param _nOdbcType the ODBC sql type
+ @param _bUseWChar true when Unicode should be used
+ @param _pData contains a copy of the data to be set
+ @param _pValue contains the data to be copied
+ @param _nTextEncoding the text encoding
+ @param _nColumnSize the columnsize which is a out param
+ */
+ static void bindData( SQLSMALLINT _nOdbcType,
+ sal_Bool _bUseWChar,
+ sal_Int8 *&_pData,
+ SQLLEN*& pLen,
+ const void* _pValue,
+ rtl_TextEncoding _nTextEncoding,
+ SQLULEN& _nColumnSize);
+
+ static void bindParameter( OConnection* _pConnection,
+ SQLHANDLE _hStmt,
+ sal_Int32 nPos,
+ sal_Int8*& pDataBuffer,
+ sal_Int8* pLenBuffer,
+ SQLSMALLINT _nJDBCtype,
+ 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);
+
+ static void 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);
+ };
+
+ template <class T> void 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,
+ T& _rValue) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+ {
+ OTools::getValue(_pConnection,_aStatementHandle,columnIndex,_nType,_bWasNull,_xInterface,&_rValue,sizeof _rValue);
+ }
+ //-----------------------------------------------------------------------------
+
+
+ }
+}
+#endif // _CONNECTIVITY_OTOOLS_HXX_
+
diff --git a/connectivity/source/inc/odbc/odbcbasedllapi.hxx b/connectivity/source/inc/odbc/odbcbasedllapi.hxx
new file mode 100644
index 000000000000..a1474098df63
--- /dev/null
+++ b/connectivity/source/inc/odbc/odbcbasedllapi.hxx
@@ -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.
+ *
+************************************************************************/
+
+#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_ODBCBASEDLLAPI_HXX
+#define INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_ODBCBASEDLLAPI_HXX
+
+#include "sal/config.h"
+
+#include "sal/types.h"
+
+#if defined OOO_DLLIMPLEMENTATION_ODBCBASE
+#define OOO_DLLPUBLIC_ODBCBASE SAL_DLLPUBLIC_EXPORT
+#else
+#define OOO_DLLPUBLIC_ODBCBASE SAL_DLLPUBLIC_IMPORT
+#endif
+
+#endif
diff --git a/connectivity/source/inc/propertyids.hxx b/connectivity/source/inc/propertyids.hxx
new file mode 100644
index 000000000000..b28278b0477d
--- /dev/null
+++ b/connectivity/source/inc/propertyids.hxx
@@ -0,0 +1,159 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_PROPERTYIDS_HXX_
+#define _CONNECTIVITY_PROPERTYIDS_HXX_
+
+// this define has to be set to split the names into different dll's or so's
+// every dll has his own set of property names
+#include <rtl/ustring.hxx>
+#ifndef _MAP_
+#include <map>
+#endif
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace dbtools
+{
+ class OOO_DLLPUBLIC_DBTOOLS OPropertyMap
+ {
+ ::std::map<sal_Int32 , rtl_uString*> m_aPropertyMap;
+
+ ::rtl::OUString fillValue(sal_Int32 _nIndex);
+ public:
+ OPropertyMap()
+ {
+ }
+ ~OPropertyMap();
+ ::rtl::OUString getNameByIndex(sal_Int32 _nIndex) const;
+ };
+}
+
+namespace connectivity
+{
+ namespace CONNECTIVITY_PROPERTY_NAME_SPACE
+ {
+ typedef const sal_Char* (*PVFN)();
+
+ struct OOO_DLLPUBLIC_DBTOOLS UStringDescription
+ {
+ const sal_Char* pZeroTerminatedName;
+ sal_Int32 nLength;
+
+ UStringDescription(PVFN _fCharFkt);
+ operator ::rtl::OUString() const { return ::rtl::OUString(pZeroTerminatedName,nLength,RTL_TEXTENCODING_ASCII_US); }
+ ~UStringDescription();
+ private:
+ UStringDescription();
+ };
+ }
+}
+
+
+//------------------------------------------------------------------------------
+#define DECL_PROP1IMPL(varname, type) \
+pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_##varname), PROPERTY_ID_##varname, ::getCppuType(reinterpret_cast< type*>(NULL)),
+//------------------------------------------------------------------------------
+#define DECL_PROP0(varname, type) \
+ DECL_PROP1IMPL(varname, type) 0)
+//------------------------------------------------------------------------------
+#define DECL_BOOL_PROP1IMPL(varname) \
+ pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_##varname), PROPERTY_ID_##varname, ::getBooleanCppuType(),
+//------------------------------------------------------------------------------
+#define DECL_BOOL_PROP0(varname) \
+ DECL_BOOL_PROP1IMPL(varname) 0)
+
+
+#define PROPERTY_ID_QUERYTIMEOUT 1
+#define PROPERTY_ID_MAXFIELDSIZE 2
+#define PROPERTY_ID_MAXROWS 3
+#define PROPERTY_ID_CURSORNAME 4
+#define PROPERTY_ID_RESULTSETCONCURRENCY 5
+#define PROPERTY_ID_RESULTSETTYPE 6
+#define PROPERTY_ID_FETCHDIRECTION 7
+#define PROPERTY_ID_FETCHSIZE 8
+#define PROPERTY_ID_ESCAPEPROCESSING 9
+#define PROPERTY_ID_USEBOOKMARKS 10
+// Column
+#define PROPERTY_ID_NAME 11
+#define PROPERTY_ID_TYPE 12
+#define PROPERTY_ID_TYPENAME 13
+#define PROPERTY_ID_PRECISION 14
+#define PROPERTY_ID_SCALE 15
+#define PROPERTY_ID_ISNULLABLE 16
+#define PROPERTY_ID_ISAUTOINCREMENT 17
+#define PROPERTY_ID_ISROWVERSION 18
+#define PROPERTY_ID_DESCRIPTION 19
+#define PROPERTY_ID_DEFAULTVALUE 20
+
+#define PROPERTY_ID_REFERENCEDTABLE 21
+#define PROPERTY_ID_UPDATERULE 22
+#define PROPERTY_ID_DELETERULE 23
+#define PROPERTY_ID_CATALOG 24
+#define PROPERTY_ID_ISUNIQUE 25
+#define PROPERTY_ID_ISPRIMARYKEYINDEX 26
+#define PROPERTY_ID_ISCLUSTERED 27
+#define PROPERTY_ID_ISASCENDING 28
+#define PROPERTY_ID_SCHEMANAME 29
+#define PROPERTY_ID_CATALOGNAME 30
+
+#define PROPERTY_ID_COMMAND 31
+#define PROPERTY_ID_CHECKOPTION 32
+#define PROPERTY_ID_PASSWORD 33
+#define PROPERTY_ID_RELATEDCOLUMN 34
+
+#define PROPERTY_ID_FUNCTION 35
+#define PROPERTY_ID_TABLENAME 36
+#define PROPERTY_ID_REALNAME 37
+#define PROPERTY_ID_DBASEPRECISIONCHANGED 38
+#define PROPERTY_ID_ISCURRENCY 39
+#define PROPERTY_ID_ISBOOKMARKABLE 40
+
+#define PROPERTY_ID_INVALID_INDEX 41
+#define PROPERTY_ID_HY010 43
+#define PROPERTY_ID_LABEL 44
+#define PROPERTY_ID_DELIMITER 45
+#define PROPERTY_ID_FORMATKEY 46
+#define PROPERTY_ID_LOCALE 47
+#define PROPERTY_ID_IM001 48
+
+#define PROPERTY_ID_AUTOINCREMENTCREATION 49
+
+#define PROPERTY_ID_PRIVILEGES 50
+#define PROPERTY_ID_HAVINGCLAUSE 51
+
+#define PROPERTY_ID_ISSIGNED 52
+#define PROPERTY_ID_AGGREGATEFUNCTION 53
+#define PROPERTY_ID_ISSEARCHABLE 54
+
+#define PROPERTY_ID_APPLYFILTER 55
+#define PROPERTY_ID_FILTER 56
+#define PROPERTY_ID_MASTERFIELDS 57
+#define PROPERTY_ID_DETAILFIELDS 58
+#define PROPERTY_ID_FIELDTYPE 59
+#define PROPERTY_ID_VALUE 60
+#define PROPERTY_ID_ACTIVE_CONNECTION 61
+
+#endif // _CONNECTIVITY_PROPERTYIDS_HXX_
diff --git a/connectivity/source/inc/resource/adabas_res.hrc b/connectivity/source/inc/resource/adabas_res.hrc
new file mode 100644
index 000000000000..a5911dcd0e98
--- /dev/null
+++ b/connectivity/source/inc/resource/adabas_res.hrc
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_RESOURCE_ADABAS_HRC
+#define CONNECTIVITY_RESOURCE_ADABAS_HRC
+
+#include "resource/conn_shared_res.hrc"
+#include "resource/common_res.hrc"
+
+// ============================================================================
+// = the Adabas D driver's resource strings
+// ============================================================================
+#define STR_NO_DISK_SPACE ( STR_ADABAS_BASE + 1 )
+#define STR_COMMAND_NOT_FOUND ( STR_ADABAS_BASE + 2 )
+#define STR_DATABASE_NEEDS_CONVERTING ( STR_ADABAS_BASE + 3 )
+#define STR_USER_NO_DELETE ( STR_ADABAS_BASE + 9 )
+
+#endif // CONNECTIVITY_RESOURCE_ADABAS_HRC
+
diff --git a/connectivity/source/inc/resource/ado_res.hrc b/connectivity/source/inc/resource/ado_res.hrc
new file mode 100644
index 000000000000..717e194ca3a4
--- /dev/null
+++ b/connectivity/source/inc/resource/ado_res.hrc
@@ -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_RESOURCE_ADO_HRC
+#define CONNECTIVITY_RESOURCE_ADO_HRC
+
+#include "resource/conn_shared_res.hrc"
+#include "resource/common_res.hrc"
+
+// ============================================================================
+// = the ado driver's resource strings
+// ============================================================================
+#define STR_INVALID_COLUMN_DESCRIPTOR_ERROR ( STR_ADO_BASE + 1 )
+#define STR_INVALID_GROUP_DESCRIPTOR_ERROR ( STR_ADO_BASE + 2 )
+#define STR_INVALID_INDEX_DESCRIPTOR_ERROR ( STR_ADO_BASE + 3 )
+#define STR_INVALID_KEY_DESCRIPTOR_ERROR ( STR_ADO_BASE + 4 )
+#define STR_INVALID_TABLE_DESCRIPTOR_ERROR ( STR_ADO_BASE + 5 )
+#define STR_INVALID_USER_DESCRIPTOR_ERROR ( STR_ADO_BASE + 6 )
+#define STR_INVALID_VIEW_DESCRIPTOR_ERROR ( STR_ADO_BASE + 7 )
+#define STR_VIEW_NO_COMMAND_ERROR ( STR_ADO_BASE + 8 )
+#define STR_TYPE_NOT_CONVERT ( STR_ADO_BASE + 9 )
+#define STR_NO_CONNECTION ( STR_ADO_BASE + 10 )
+
+
+#endif // CONNECTIVITY_RESOURCE_ADO_HRC
+
diff --git a/connectivity/source/inc/resource/calc_res.hrc b/connectivity/source/inc/resource/calc_res.hrc
new file mode 100644
index 000000000000..e71901814140
--- /dev/null
+++ b/connectivity/source/inc/resource/calc_res.hrc
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_RESOURCE_CALC_HRC
+#define CONNECTIVITY_RESOURCE_CALC_HRC
+
+#include "resource/conn_shared_res.hrc"
+#include "resource/common_res.hrc"
+
+// ============================================================================
+// = the calc driver's resource strings
+// ============================================================================
+
+#define STR_LOAD_FILE_ERROR_MESSAGE ( STR_CALC_BASE + 0 )
+
+#endif // CONNECTIVITY_RESOURCE_CALC_HRC
+
diff --git a/connectivity/source/inc/resource/common_res.hrc b/connectivity/source/inc/resource/common_res.hrc
new file mode 100644
index 000000000000..ac7cb89a630e
--- /dev/null
+++ b/connectivity/source/inc/resource/common_res.hrc
@@ -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_RESOURCE_COMMON_HRC
+#define CONNECTIVITY_RESOURCE_COMMON_HRC
+
+#ifndef CONNECTIVITY_SHARED_RES_HRC
+#include "resource/conn_shared_res.hrc"
+#endif
+
+// ============================================================================
+// = common strings
+// ============================================================================
+
+#define STR_STRING_LENGTH_EXCEEDED ( STR_COMMON_BASE + 1 )
+#define STR_CANNOT_CONVERT_STRING ( STR_COMMON_BASE + 2 )
+#define STR_URI_SYNTAX_ERROR ( STR_COMMON_BASE + 3 )
+#define STR_COULD_NOT_LOAD_FILE ( STR_COMMON_BASE + 4 )
+#define STR_QUERY_TOO_COMPLEX ( STR_COMMON_BASE + 5 )
+#define STR_OPERATOR_TOO_COMPLEX ( STR_COMMON_BASE + 6 )
+#define STR_QUERY_INVALID_LIKE_COLUMN ( STR_COMMON_BASE + 7 )
+#define STR_QUERY_INVALID_LIKE_STRING ( STR_COMMON_BASE + 8 )
+#define STR_QUERY_NOT_LIKE_TOO_COMPLEX ( STR_COMMON_BASE + 9 )
+#define STR_QUERY_LIKE_WILDCARD ( STR_COMMON_BASE + 10 )
+#define STR_QUERY_LIKE_WILDCARD_MANY ( STR_COMMON_BASE + 11 )
+#define STR_INVALID_COLUMNNAME ( STR_COMMON_BASE + 12 )
+#define STR_NO_CLASSNAME ( STR_COMMON_BASE + 13 )
+#define STR_NO_CLASSNAME_PATH ( STR_COMMON_BASE + 14 )
+#define STR_UNKNOWN_PARA_TYPE ( STR_COMMON_BASE + 15 )
+#define STR_INVALID_COLUMN_SELECTION ( STR_COMMON_BASE + 16 )
+#define STR_PARA_ONLY_PREPARED ( STR_COMMON_BASE + 17 )
+#define STR_COLUMN_NOT_UPDATEABLE ( STR_COMMON_BASE + 18 )
+#define STR_ROW_ALREADY_DELETED ( STR_COMMON_BASE + 19 )
+#define STR_UNKNOWN_COLUMN_TYPE ( STR_COMMON_BASE + 20 )
+#define STR_FORMULA_WRONG ( STR_COMMON_BASE + 21 )
+#define STR_NO_JAVA ( STR_COMMON_BASE + 22 )
+#define STR_NO_RESULTSET ( STR_COMMON_BASE + 23 )
+#define STR_NO_ROWCOUNT ( STR_COMMON_BASE + 24 )
+#define STR_ERRORMSG_SEQUENCE ( STR_COMMON_BASE + 25 )
+#define STR_INVALID_INDEX ( STR_COMMON_BASE + 26 )
+#define STR_UNSUPPORTED_FUNCTION ( STR_COMMON_BASE + 27 )
+#define STR_UNSUPPORTED_FEATURE ( STR_COMMON_BASE + 28 )
+#define STR_UNKNOWN_COLUMN_NAME ( STR_COMMON_BASE + 29 )
+#define STR_INVALID_PARA_COUNT ( STR_COMMON_BASE + 30 )
+#define STR_PRIVILEGE_NOT_GRANTED ( STR_COMMON_BASE + 31 )
+#define STR_PRIVILEGE_NOT_REVOKED ( STR_COMMON_BASE + 32 )
+#define STR_INVALID_BOOKMARK ( STR_COMMON_BASE + 33 )
+#define STR_NO_ELEMENT_NAME ( STR_COMMON_BASE + 34 )
+#define STR_NO_INPUTSTREAM ( STR_COMMON_BASE + 35 )
+#define STR_INPUTSTREAM_WRONG_LEN ( STR_COMMON_BASE + 36 )
+#define STR_WRONG_PARAM_INDEX ( STR_COMMON_BASE + 37 )
+#define STR_NO_CONNECTION_GIVEN ( STR_COMMON_BASE + 38 )
+
+#endif // CONNECTIVITY_RESOURCE_COMMON_HRC
diff --git a/connectivity/source/inc/resource/conn_shared_res.hrc b/connectivity/source/inc/resource/conn_shared_res.hrc
new file mode 100644
index 000000000000..981f5a89b4df
--- /dev/null
+++ b/connectivity/source/inc/resource/conn_shared_res.hrc
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_SHARED_RES_HRC
+#define CONNECTIVITY_SHARED_RES_HRC
+
+// ============================================================================
+// = normal resource ids, per driver
+
+// Mozilla driver resource ids
+#define STR_MOZAB_BASE 1000
+
+// common resource ids
+#define STR_COMMON_BASE 1200
+
+// Spreadsheet driver resource ids
+#define STR_CALC_BASE 1300
+
+// DBase driver resource ids
+#define STR_DBASE_BASE 1400
+
+// ADO driver resource ids
+#define STR_ADO_BASE 1450
+
+// EVOAB2 driver resource ids
+#define STR_EVOAB2_BASE 1500
+
+// FILE driver resource ids
+#define STR_FILE_BASE 1550
+
+// KAB driver resource ids
+#define STR_KAB_BASE 1600
+
+// MACAB driver resource ids
+#define STR_MACAB_BASE 1650
+
+// Adabas D driver resource ids
+#define STR_ADABAS_BASE 1700
+
+// hsqldb driver resource ids
+#define STR_HSQLDB_BASE 1750
+// ============================================================================
+// = resource ids for log messages
+#define STR_LOG_MESSAGE_BASE 10000
+
+// log messages for the jdbc driver
+#define STR_JDBC_LOG_MESSAGE_BASE STR_LOG_MESSAGE_BASE + 500
+
+#endif
diff --git a/connectivity/source/inc/resource/dbase_res.hrc b/connectivity/source/inc/resource/dbase_res.hrc
new file mode 100644
index 000000000000..d4b31e614ced
--- /dev/null
+++ b/connectivity/source/inc/resource/dbase_res.hrc
@@ -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_RESOURCE_DBASE_HRC
+#define CONNECTIVITY_RESOURCE_DBASE_HRC
+
+#include "resource/conn_shared_res.hrc"
+#include "resource/common_res.hrc"
+
+// ============================================================================
+// = the calc driver's resource strings
+// ============================================================================
+
+#define STR_COULD_NOT_DELETE_INDEX ( STR_DBASE_BASE + 0 )
+#define STR_COULD_NOT_CREATE_INDEX_NOT_UNIQUE ( STR_DBASE_BASE + 1 )
+#define STR_SQL_NAME_ERROR ( STR_DBASE_BASE + 2 )
+#define STR_COULD_NOT_DELETE_FILE ( STR_DBASE_BASE + 3 )
+#define STR_INVALID_COLUMN_TYPE ( STR_DBASE_BASE + 4 )
+#define STR_INVALID_COLUMN_PRECISION ( STR_DBASE_BASE + 5 )
+#define STR_INVALID_PRECISION_SCALE ( STR_DBASE_BASE + 6 )
+#define STR_INVALID_COLUMN_NAME_LENGTH ( STR_DBASE_BASE + 7 )
+#define STR_DUPLICATE_VALUE_IN_COLUMN ( STR_DBASE_BASE + 8 )
+#define STR_INVALID_COLUMN_DECIMAL_VALUE ( STR_DBASE_BASE + 9 )
+#define STR_COLUMN_NOT_ALTERABLE ( STR_DBASE_BASE + 10 )
+#define STR_COLUMN_NOT_ADDABLE ( STR_DBASE_BASE + 11 )
+#define STR_COLUMN_NOT_DROP ( STR_DBASE_BASE + 12 )
+#define STR_COULD_NOT_ALTER_TABLE ( STR_DBASE_BASE + 13 )
+#define STR_INVALID_DBASE_FILE ( STR_DBASE_BASE + 14 )
+#define STR_ONL_ONE_COLUMN_PER_INDEX ( STR_DBASE_BASE + 15 )
+#define STR_COULD_NOT_CREATE_INDEX ( STR_DBASE_BASE + 16 )
+#define STR_COULD_NOT_CREATE_INDEX_NAME ( STR_DBASE_BASE + 17 )
+#define STR_INVALID_COLUMN_VALUE ( STR_DBASE_BASE + 18 )
+#define STR_TABLE_NOT_DROP ( STR_DBASE_BASE + 19 )
+#define STR_COULD_NOT_CREATE_INDEX_KEYSIZE ( STR_DBASE_BASE + 20 )
+
+#endif // CONNECTIVITY_RESOURCE_DBASE_HRC
+
diff --git a/connectivity/source/inc/resource/evoab2_res.hrc b/connectivity/source/inc/resource/evoab2_res.hrc
new file mode 100644
index 000000000000..ebe7170beb96
--- /dev/null
+++ b/connectivity/source/inc/resource/evoab2_res.hrc
@@ -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_RESOURCE_EVOAB2_HRC
+#define CONNECTIVITY_RESOURCE_EVOAB2_HRC
+
+#include "resource/conn_shared_res.hrc"
+#include "resource/common_res.hrc"
+
+// ============================================================================
+// = the calc driver's resource strings
+// ============================================================================
+
+#define STR_CANNOT_OPEN_BOOK ( STR_EVOAB2_BASE + 0 )
+#define STR_SORT_BY_COL_ONLY ( STR_EVOAB2_BASE + 1 )
+
+#endif // CONNECTIVITY_RESOURCE_CALC_HRC
+
diff --git a/connectivity/source/inc/resource/file_res.hrc b/connectivity/source/inc/resource/file_res.hrc
new file mode 100644
index 000000000000..bbc451920ef4
--- /dev/null
+++ b/connectivity/source/inc/resource/file_res.hrc
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_RESOURCE_FILE_HRC
+#define CONNECTIVITY_RESOURCE_FILE_HRC
+
+#include "resource/conn_shared_res.hrc"
+#include "resource/common_res.hrc"
+// ============================================================================
+// = the file driver's resource strings
+// ============================================================================
+
+#define STR_QUERY_COMPLEX_COUNT ( STR_FILE_BASE + 0 )
+#define STR_QUERY_INVALID_BETWEEN ( STR_FILE_BASE + 1 )
+#define STR_TABLE_READONLY ( STR_FILE_BASE + 2 )
+#define STR_DELETE_ROW ( STR_FILE_BASE + 3 )
+#define STR_NO_VALID_FILE_URL ( STR_FILE_BASE + 4 )
+#define STR_QUERY_MORE_TABLES ( STR_FILE_BASE + 5 )
+#define STR_QUERY_NO_TABLE ( STR_FILE_BASE + 6 )
+#define STR_QUERY_NO_COLUMN ( STR_FILE_BASE + 7 )
+#define STR_QUERY_FUNCTION_NOT_SUPPORTED ( STR_FILE_BASE + 8 )
+
+#endif // CONNECTIVITY_RESOURCE_FILE_HRC
+
diff --git a/connectivity/source/inc/resource/hsqldb_res.hrc b/connectivity/source/inc/resource/hsqldb_res.hrc
new file mode 100644
index 000000000000..640ed8f5ce81
--- /dev/null
+++ b/connectivity/source/inc/resource/hsqldb_res.hrc
@@ -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_RESOURCE_HSQLDB_HRC
+#define CONNECTIVITY_RESOURCE_HSQLDB_HRC
+
+#include "resource/conn_shared_res.hrc"
+#include "resource/common_res.hrc"
+
+// ============================================================================
+// = the hsqldb driver's resource strings
+// ============================================================================
+
+#define STR_NO_STROAGE ( STR_HSQLDB_BASE + 0 )
+#define STR_INVALID_FILE_URL ( STR_HSQLDB_BASE + 1 )
+#define STR_NO_TABLE_CONTAINER ( STR_HSQLDB_BASE + 2 )
+#define STR_NO_TABLE_EDITOR_DIALOG ( STR_HSQLDB_BASE + 3 )
+#define STR_NO_TABLENAME ( STR_HSQLDB_BASE + 4 )
+#define STR_NO_DOCUMENTUI ( STR_HSQLDB_BASE + 5 )
+#define STR_ERROR_NEW_VERSION ( STR_HSQLDB_BASE + 6 )
+
+#endif // CONNECTIVITY_RESOURCE_HSQLDB_HRC
+
diff --git a/connectivity/source/inc/resource/jdbc_log.hrc b/connectivity/source/inc/resource/jdbc_log.hrc
new file mode 100644
index 000000000000..ff2c483f0948
--- /dev/null
+++ b/connectivity/source/inc/resource/jdbc_log.hrc
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_RESOURCE_JDBC_LOG_HRC
+#define CONNECTIVITY_RESOURCE_JDBC_LOG_HRC
+
+#include "resource/conn_shared_res.hrc"
+
+#define STR_LOG_DRIVER_CONNECTING_URL ( STR_JDBC_LOG_MESSAGE_BASE + 1 )
+#define STR_LOG_DRIVER_SUCCESS ( STR_JDBC_LOG_MESSAGE_BASE + 2 )
+#define STR_LOG_CREATE_STATEMENT ( STR_JDBC_LOG_MESSAGE_BASE + 3 )
+#define STR_LOG_CREATED_STATEMENT_ID ( STR_JDBC_LOG_MESSAGE_BASE + 4 )
+#define STR_LOG_PREPARE_STATEMENT ( STR_JDBC_LOG_MESSAGE_BASE + 5 )
+#define STR_LOG_PREPARED_STATEMENT_ID ( STR_JDBC_LOG_MESSAGE_BASE + 6 )
+#define STR_LOG_PREPARE_CALL ( STR_JDBC_LOG_MESSAGE_BASE + 7 )
+#define STR_LOG_PREPARED_CALL_ID ( STR_JDBC_LOG_MESSAGE_BASE + 8 )
+#define STR_LOG_NATIVE_SQL ( STR_JDBC_LOG_MESSAGE_BASE + 9 )
+#define STR_LOG_LOADING_DRIVER ( STR_JDBC_LOG_MESSAGE_BASE + 10 )
+#define STR_LOG_NO_DRIVER_CLASS ( STR_JDBC_LOG_MESSAGE_BASE + 11 )
+#define STR_LOG_CONN_SUCCESS ( STR_JDBC_LOG_MESSAGE_BASE + 12 )
+#define STR_LOG_NO_SYSTEM_CONNECTION ( STR_JDBC_LOG_MESSAGE_BASE + 13 )
+#define STR_LOG_GOT_JDBC_CONNECTION ( STR_JDBC_LOG_MESSAGE_BASE + 14 )
+#define STR_LOG_SHUTDOWN_CONNECTION ( STR_JDBC_LOG_MESSAGE_BASE + 15 )
+#define STR_LOG_GENERATED_VALUES ( STR_JDBC_LOG_MESSAGE_BASE + 16 )
+#define STR_LOG_GENERATED_VALUES_FALLBACK ( STR_JDBC_LOG_MESSAGE_BASE + 17 )
+#define STR_LOG_EXECUTE_STATEMENT ( STR_JDBC_LOG_MESSAGE_BASE + 18 )
+#define STR_LOG_EXECUTE_QUERY ( STR_JDBC_LOG_MESSAGE_BASE + 19 )
+#define STR_LOG_CLOSING_STATEMENT ( STR_JDBC_LOG_MESSAGE_BASE + 20 )
+#define STR_LOG_EXECUTE_UPDATE ( STR_JDBC_LOG_MESSAGE_BASE + 21 )
+#define STR_LOG_UPDATE_COUNT ( STR_JDBC_LOG_MESSAGE_BASE + 22 )
+#define STR_LOG_RESULT_SET_CONCURRENCY ( STR_JDBC_LOG_MESSAGE_BASE + 23 )
+#define STR_LOG_RESULT_SET_TYPE ( STR_JDBC_LOG_MESSAGE_BASE + 24 )
+#define STR_LOG_FETCH_DIRECTION ( STR_JDBC_LOG_MESSAGE_BASE + 25 )
+#define STR_LOG_FETCH_SIZE ( STR_JDBC_LOG_MESSAGE_BASE + 26 )
+#define STR_LOG_SET_ESCAPE_PROCESSING ( STR_JDBC_LOG_MESSAGE_BASE + 27 )
+#define STR_LOG_EXECUTING_PREPARED ( STR_JDBC_LOG_MESSAGE_BASE + 28 )
+#define STR_LOG_EXECUTING_PREPARED_UPDATE ( STR_JDBC_LOG_MESSAGE_BASE + 29 )
+#define STR_LOG_EXECUTING_PREPARED_QUERY ( STR_JDBC_LOG_MESSAGE_BASE + 30 )
+#define STR_LOG_STRING_PARAMETER ( STR_JDBC_LOG_MESSAGE_BASE + 31 )
+#define STR_LOG_BOOLEAN_PARAMETER ( STR_JDBC_LOG_MESSAGE_BASE + 32 )
+#define STR_LOG_BYTE_PARAMETER ( STR_JDBC_LOG_MESSAGE_BASE + 33 )
+#define STR_LOG_DATE_PARAMETER ( STR_JDBC_LOG_MESSAGE_BASE + 34 )
+#define STR_LOG_TIME_PARAMETER ( STR_JDBC_LOG_MESSAGE_BASE + 35 )
+#define STR_LOG_TIMESTAMP_PARAMETER ( STR_JDBC_LOG_MESSAGE_BASE + 36 )
+#define STR_LOG_DOUBLE_PARAMETER ( STR_JDBC_LOG_MESSAGE_BASE + 37 )
+#define STR_LOG_FLOAT_PARAMETER ( STR_JDBC_LOG_MESSAGE_BASE + 38 )
+#define STR_LOG_INT_PARAMETER ( STR_JDBC_LOG_MESSAGE_BASE + 39 )
+#define STR_LOG_LONG_PARAMETER ( STR_JDBC_LOG_MESSAGE_BASE + 40 )
+#define STR_LOG_NULL_PARAMETER ( STR_JDBC_LOG_MESSAGE_BASE + 41 )
+#define STR_LOG_OBJECT_NULL_PARAMETER ( STR_JDBC_LOG_MESSAGE_BASE + 42 )
+#define STR_LOG_SHORT_PARAMETER ( STR_JDBC_LOG_MESSAGE_BASE + 43 )
+#define STR_LOG_BYTES_PARAMETER ( STR_JDBC_LOG_MESSAGE_BASE + 44 )
+#define STR_LOG_CHARSTREAM_PARAMETER ( STR_JDBC_LOG_MESSAGE_BASE + 45 )
+#define STR_LOG_BINARYSTREAM_PARAMETER ( STR_JDBC_LOG_MESSAGE_BASE + 46 )
+#define STR_LOG_CLEAR_PARAMETERS ( STR_JDBC_LOG_MESSAGE_BASE + 47 )
+#define STR_LOG_META_DATA_METHOD ( STR_JDBC_LOG_MESSAGE_BASE + 48 )
+#define STR_LOG_META_DATA_METHOD_ARG1 ( STR_JDBC_LOG_MESSAGE_BASE + 49 )
+#define STR_LOG_META_DATA_METHOD_ARG2 ( STR_JDBC_LOG_MESSAGE_BASE + 50 )
+#define STR_LOG_META_DATA_METHOD_ARG3 ( STR_JDBC_LOG_MESSAGE_BASE + 51 )
+#define STR_LOG_META_DATA_METHOD_ARG4 ( STR_JDBC_LOG_MESSAGE_BASE + 52 )
+#define STR_LOG_META_DATA_RESULT ( STR_JDBC_LOG_MESSAGE_BASE + 53 )
+#define STR_LOG_META_DATA_SUCCESS ( STR_JDBC_LOG_MESSAGE_BASE + 54 )
+#define STR_LOG_THROWING_EXCEPTION ( STR_JDBC_LOG_MESSAGE_BASE + 55 )
+#define STR_LOG_SETTING_SYSTEM_PROPERTY ( STR_JDBC_LOG_MESSAGE_BASE + 56 )
+
+#endif // CONNECTIVITY_RESOURCE_JDBC_LOG_HRC
diff --git a/connectivity/source/inc/resource/kab_res.hrc b/connectivity/source/inc/resource/kab_res.hrc
new file mode 100644
index 000000000000..b03eecdb2b90
--- /dev/null
+++ b/connectivity/source/inc/resource/kab_res.hrc
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_RESOURCE_KAB_HRC
+#define CONNECTIVITY_RESOURCE_KAB_HRC
+
+#include "resource/conn_shared_res.hrc"
+#include "resource/common_res.hrc"
+// ============================================================================
+// = the kab driver's resource strings
+// ============================================================================
+
+#define STR_NO_KDE_INST ( STR_KAB_BASE + 0 )
+#define STR_KDE_VERSION_TOO_OLD ( STR_KAB_BASE + 1 )
+#define STR_KDE_VERSION_TOO_NEW ( STR_KAB_BASE + 2 )
+#define STR_KDE_VERSION_TOO_NEW_WORK_AROUND ( STR_KAB_BASE + 3 )
+
+#endif // CONNECTIVITY_RESOURCE_KAB_HRC
+
diff --git a/connectivity/source/inc/resource/macab_res.hrc b/connectivity/source/inc/resource/macab_res.hrc
new file mode 100644
index 000000000000..74d64aa28ad8
--- /dev/null
+++ b/connectivity/source/inc/resource/macab_res.hrc
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_RESOURCE_MACAB_HRC
+#define CONNECTIVITY_RESOURCE_MACAB_HRC
+
+#include "resource/conn_shared_res.hrc"
+#include "resource/common_res.hrc"
+// ============================================================================
+// = the macab driver's resource strings
+// ============================================================================
+
+#define STR_NO_TABLE ( STR_MACAB_BASE + 0 )
+#define STR_NO_MAC_OS_FOUND ( STR_MACAB_BASE + 1 )
+
+#endif // CONNECTIVITY_RESOURCE_MACAB_HRC
+
diff --git a/connectivity/source/inc/resource/mozab_res.hrc b/connectivity/source/inc/resource/mozab_res.hrc
new file mode 100644
index 000000000000..01e93ae17fd5
--- /dev/null
+++ b/connectivity/source/inc/resource/mozab_res.hrc
@@ -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_RESOURCE_MOZAB_HRC
+#define CONNECTIVITY_RESOURCE_MOZAB_HRC
+
+#ifndef CONNECTIVITY_SHARED_RES_HRC
+#include "resource/conn_shared_res.hrc"
+#endif
+
+// ============================================================================
+// = the mozab driver's resource strings
+// ============================================================================
+
+#define STR_MOZILLA_ADDRESSBOOKS ( STR_MOZAB_BASE + 0 )
+#define STR_THUNDERBIRD_ADDRESSBOOKS ( STR_MOZAB_BASE + 1 )
+#define STR_OE_ADDRESSBOOK ( STR_MOZAB_BASE + 2 )
+#define STR_OUTLOOK_MAPI_ADDRESSBOOK ( STR_MOZAB_BASE + 3 )
+ // FREE
+#define STR_NO_TABLE_CREATION_SUPPORT ( STR_MOZAB_BASE + 5 )
+#define STR_MOZILLA_IS_RUNNING ( STR_MOZAB_BASE + 6 )
+#define STR_COULD_NOT_RETRIEVE_AB_ENTRY ( STR_MOZAB_BASE + 7 )
+#define STR_COULD_NOT_GET_DIRECTORY_NAME ( STR_MOZAB_BASE + 8 )
+#define STR_TIMEOUT_WAITING ( STR_MOZAB_BASE + 9 )
+#define STR_ERR_EXECUTING_QUERY ( STR_MOZAB_BASE + 10 )
+#define STR_MOZILLA_IS_RUNNIG_NO_CHANGES ( STR_MOZAB_BASE + 11 )
+#define STR_FOREIGN_PROCESS_CHANGED_AB ( STR_MOZAB_BASE + 12 )
+#define STR_CANT_FIND_ROW ( STR_MOZAB_BASE + 13 )
+#define STR_CANT_FIND_CARD_FOR_ROW ( STR_MOZAB_BASE + 14 )
+#define STR_QUERY_INVALID_IS_NULL_COLUMN ( STR_MOZAB_BASE + 15 )
+#define STR_NO_HOSTNAME ( STR_MOZAB_BASE + 16 )
+#define STR_NO_BASEDN ( STR_MOZAB_BASE + 17 )
+#define STR_COULD_NOT_CONNECT_LDAP ( STR_MOZAB_BASE + 18 )
+#define STR_ERROR_REFRESH_ROW ( STR_MOZAB_BASE + 19 )
+#define STR_ILLEGAL_MOVEMENT ( STR_MOZAB_BASE + 20 )
+#define STR_ERROR_GET_ROW ( STR_MOZAB_BASE + 21 )
+#define STR_COMMIT_ROW ( STR_MOZAB_BASE + 22 )
+#define STR_INVALID_ROW_UPDATE ( STR_MOZAB_BASE + 23 )
+#define STR_ROW_CAN_NOT_SAVE ( STR_MOZAB_BASE + 24 )
+#define STR_CAN_NOT_CANCEL_ROW_UPDATE ( STR_MOZAB_BASE + 25 )
+#define STR_CAN_NOT_CREATE_ROW ( STR_MOZAB_BASE + 26 )
+#define STR_QUERY_AT_LEAST_ONE_TABLES ( STR_MOZAB_BASE + 27 )
+#define STR_NO_COUNT_SUPPORT ( STR_MOZAB_BASE + 28 )
+#define STR_STMT_TYPE_NOT_SUPPORTED ( STR_MOZAB_BASE + 29 )
+#define STR_COULD_NOT_LOAD_LIB ( STR_MOZAB_BASE + 30 )
+#define STR_UNSPECIFIED_ERROR ( STR_MOZAB_BASE + 31 )
+#define STR_COULD_NOT_CREATE_ADDRESSBOOK ( STR_MOZAB_BASE + 32 )
+
+#endif // CONNECTIVITY_RESOURCE_MOZAB_HRC
+
diff --git a/connectivity/source/inc/resource/sharedresources.hxx b/connectivity/source/inc/resource/sharedresources.hxx
new file mode 100644
index 000000000000..e7a2a1e52153
--- /dev/null
+++ b/connectivity/source/inc/resource/sharedresources.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_SHAREDRESOURCES_HXX
+#define CONNECTIVITY_SHAREDRESOURCES_HXX
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <rtl/ustring.hxx>
+#include <list>
+#include "connectivity/dbtoolsdllapi.hxx"
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ typedef sal_uInt16 ResourceId;
+ //====================================================================
+ //= SharedResources
+ //====================================================================
+ /** helper class for accessing resources shared by different libraries
+ in the connectivity module
+ */
+ class OOO_DLLPUBLIC_DBTOOLS SharedResources
+ {
+ public:
+ SharedResources();
+ ~SharedResources();
+
+ /** loads a string from the shared resource file
+ @param _nResId
+ the resource ID of the string
+ @return
+ the string from the resource file
+ */
+ ::rtl::OUString
+ getResourceString(
+ ResourceId _nResId
+ ) const;
+
+ /** loads a string from the shared resource file, and replaces
+ a given ASCII pattern with a given string
+
+ @param _nResId
+ the resource ID of the string to load
+ @param _pAsciiPatternToReplace
+ the ASCII string which is to search in the string. Must not be <NULL/>.
+ @param _rStringToSubstitute
+ the String which should substitute the ASCII pattern.
+
+ @return
+ the string from the resource file, with applied string substitution
+ */
+ ::rtl::OUString
+ getResourceStringWithSubstitution(
+ ResourceId _nResId,
+ const sal_Char* _pAsciiPatternToReplace,
+ const ::rtl::OUString& _rStringToSubstitute
+ ) const;
+
+ /** loads a string from the shared resource file, and replaces
+ a given ASCII pattern with a given string
+
+ @param _nResId
+ the resource ID of the string to load
+ @param _pAsciiPatternToReplace1
+ the ASCII string (1) which is to search in the string. Must not be <NULL/>.
+ @param _rStringToSubstitute1
+ the String which should substitute the ASCII pattern (1)
+ @param _pAsciiPatternToReplace2
+ the ASCII string (2) which is to search in the string. Must not be <NULL/>.
+ @param _rStringToSubstitute2
+ the String which should substitute the ASCII pattern (2)
+
+ @return
+ the string from the resource file, with applied string substitution
+ */
+ ::rtl::OUString
+ getResourceStringWithSubstitution(
+ ResourceId _nResId,
+ const sal_Char* _pAsciiPatternToReplace1,
+ const ::rtl::OUString& _rStringToSubstitute1,
+ const sal_Char* _pAsciiPatternToReplace2,
+ const ::rtl::OUString& _rStringToSubstitute2
+ ) const;
+
+ /** loads a string from the shared resource file, and replaces
+ a given ASCII pattern with a given string
+
+ @param _nResId
+ the resource ID of the string to load
+ @param _pAsciiPatternToReplace1
+ the ASCII string (1) which is to search in the string. Must not be <NULL/>.
+ @param _rStringToSubstitute1
+ the String which should substitute the ASCII pattern (1)
+ @param _pAsciiPatternToReplace2
+ the ASCII string (2) which is to search in the string. Must not be <NULL/>.
+ @param _rStringToSubstitute2
+ the String which should substitute the ASCII pattern (2)
+ @param _pAsciiPatternToReplace3
+ the ASCII string (3) which is to search in the string. Must not be <NULL/>.
+ @param _rStringToSubstitute3
+ the String which should substitute the ASCII pattern (3)
+
+ @return
+ the string from the resource file, with applied string substitution
+ */
+ ::rtl::OUString
+ getResourceStringWithSubstitution(
+ ResourceId _nResId,
+ const sal_Char* _pAsciiPatternToReplace1,
+ const ::rtl::OUString& _rStringToSubstitute1,
+ const sal_Char* _pAsciiPatternToReplace2,
+ const ::rtl::OUString& _rStringToSubstitute2,
+ const sal_Char* _pAsciiPatternToReplace3,
+ const ::rtl::OUString& _rStringToSubstitute3
+ ) const;
+
+ /** loads a string from the shared resource file, and replaces a given ASCII pattern with a given string
+
+ @param _nResId
+ the resource ID of the string to load
+ @param _aStringToSubstitutes
+ A list of substitutions.
+
+ @return
+ the string from the resource file, with applied string substitution
+ */
+ ::rtl::OUString getResourceStringWithSubstitution( ResourceId _nResId,
+ const ::std::list< ::std::pair<const sal_Char* , ::rtl::OUString > > _aStringToSubstitutes) const;
+ };
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
+#endif // CONNECTIVITY_SHAREDRESOURCES_HXX
+
diff --git a/connectivity/source/inc/sqlscan.hxx b/connectivity/source/inc/sqlscan.hxx
new file mode 100644
index 000000000000..a7e21ef879fe
--- /dev/null
+++ b/connectivity/source/inc/sqlscan.hxx
@@ -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.
+ *
+ ************************************************************************/
+#ifndef _CONNECTIVITY_SQLSCAN_HXX
+#define _CONNECTIVITY_SQLSCAN_HXX
+
+#include <stdarg.h>
+#include "connectivity/IParseContext.hxx"
+#include "connectivity/dbtoolsdllapi.hxx"
+
+namespace connectivity
+{
+ //==========================================================================
+ //= OSQLScanner
+ //==========================================================================
+ /** Scanner for SQL92
+ */
+ class OOO_DLLPUBLIC_DBTOOLS OSQLScanner
+ {
+ const IParseContext* m_pContext; // context for parse, knows all international stuff
+ ::rtl::OString m_sStatement; // statement to parse
+ ::rtl::OUString m_sErrorMessage;
+
+ sal_Int32 m_nCurrentPos; // next position to read from the statement
+ sal_Bool m_bInternational; // do we have a statement which may uses
+ sal_Int32 m_nRule; // rule to be set
+
+ public:
+ OSQLScanner();
+ virtual ~OSQLScanner();
+
+ inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void * SAL_CALL operator new( size_t,void* _pHint ) SAL_THROW( () )
+ { return _pHint; }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ inline static void SAL_CALL operator delete( void *,void* ) SAL_THROW( () )
+ { }
+
+ virtual sal_Int32 SQLyygetc(void);
+ virtual void SQLyyerror(char *fmt);
+ virtual void output(sal_Int32) { OSL_ASSERT("Internal error in sdblex.l: output not possible"); }
+ virtual void ECHO(void) { OSL_ASSERT("Internal error in sdblex.l: ECHO not possible"); }
+ virtual IParseContext::InternationalKeyCode getInternationalTokenID(const char* sToken) const;
+
+ // setting the new information before scanning
+ void prepareScan(const ::rtl::OUString & rNewStatement, const IParseContext* pContext, sal_Bool bInternational);
+ const ::rtl::OUString& getErrorMessage() const {return m_sErrorMessage;}
+ ::rtl::OString getStatement() const { return m_sStatement; }
+
+ sal_Int32 SQLlex();
+ // set this as scanner for flex
+ void setScanner(sal_Bool _bNull=sal_False);
+ // rules settings
+ void SetRule(sal_Int32 nRule) {m_nRule = nRule;}
+ sal_Int32 GetCurrentRule() const;
+ sal_Int32 GetGERRule() const;
+ sal_Int32 GetENGRule() const;
+ sal_Int32 GetSQLRule() const;
+ sal_Int32 GetDATERule() const;
+ sal_Int32 GetSTRINGRule() const;
+ inline sal_Int32 GetCurrentPos() const { return m_nCurrentPos; }
+ };
+}
+
+#endif
diff --git a/connectivity/source/manager/exports.dxp b/connectivity/source/manager/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/connectivity/source/manager/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/connectivity/source/manager/makefile.mk b/connectivity/source/manager/makefile.mk
new file mode 100644
index 000000000000..52ec191ec836
--- /dev/null
+++ b/connectivity/source/manager/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJINC=..
+PRJNAME=connectivity
+TARGET=sdbc
+
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ----------------------------------
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/version.mk
+
+
+# --- Files -------------------------------------
+
+SLOFILES=\
+ $(SLO)$/mdrivermanager.obj \
+ $(SLO)$/mregistration.obj \
+
+# --- Library -----------------------------------
+
+SHL1TARGET= $(SDBC_TARGET)$(SDBC_MAJOR)
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(COMPHELPERLIB) \
+ $(DBTOOLSLIB) \
+ $(UNOTOOLSLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(SHL1TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/connectivity/source/manager/mdrivermanager.cxx b/connectivity/source/manager/mdrivermanager.cxx
new file mode 100644
index 000000000000..a88450399c17
--- /dev/null
+++ b/connectivity/source/manager/mdrivermanager.cxx
@@ -0,0 +1,741 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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 "mdrivermanager.hxx"
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/container/XContentEnumerationAccess.hpp>
+#include <com/sun/star/container/ElementExistException.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
+
+#include <tools/diagnose_ex.h>
+#include <comphelper/extract.hxx>
+#include <comphelper/stl_types.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/weakref.hxx>
+#include <osl/diagnose.h>
+
+#include <algorithm>
+#include <functional>
+
+namespace drivermanager
+{
+
+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 ::com::sun::star::container;
+using namespace ::com::sun::star::logging;
+using namespace ::osl;
+
+#define SERVICE_SDBC_DRIVER ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver")
+
+void throwNoSuchElementException() throw(NoSuchElementException)
+{
+ throw NoSuchElementException();
+}
+
+//==========================================================================
+//= ODriverEnumeration
+//==========================================================================
+class ODriverEnumeration : public ::cppu::WeakImplHelper1< XEnumeration >
+{
+ friend class OSDBCDriverManager;
+
+ DECLARE_STL_VECTOR( SdbcDriver, DriverArray );
+ DriverArray m_aDrivers;
+ ConstDriverArrayIterator m_aPos;
+ // order matters!
+
+protected:
+ virtual ~ODriverEnumeration();
+public:
+ ODriverEnumeration(const DriverArray& _rDriverSequence);
+
+// XEnumeration
+ virtual sal_Bool SAL_CALL hasMoreElements( ) throw(RuntimeException);
+ virtual Any SAL_CALL nextElement( ) throw(NoSuchElementException, WrappedTargetException, RuntimeException);
+};
+
+//--------------------------------------------------------------------------
+ODriverEnumeration::ODriverEnumeration(const DriverArray& _rDriverSequence)
+ :m_aDrivers( _rDriverSequence )
+ ,m_aPos( m_aDrivers.begin() )
+{
+}
+
+//--------------------------------------------------------------------------
+ODriverEnumeration::~ODriverEnumeration()
+{
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL ODriverEnumeration::hasMoreElements( ) throw(RuntimeException)
+{
+ return m_aPos != m_aDrivers.end();
+}
+
+//--------------------------------------------------------------------------
+Any SAL_CALL ODriverEnumeration::nextElement( ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ if ( !hasMoreElements() )
+ throwNoSuchElementException();
+
+ return makeAny( *m_aPos++ );
+}
+
+ //=====================================================================
+ //= helper
+ //=====================================================================
+ //---------------------------------------------------------------------
+ //--- 24.08.01 11:27:59 -----------------------------------------------
+
+ /// an STL functor which ensures that a SdbcDriver described by a DriverAccess is loaded
+ struct EnsureDriver : public ::std::unary_function< DriverAccess, DriverAccess >
+ {
+ const DriverAccess& operator()( const DriverAccess& _rDescriptor ) const
+ {
+ if ( !_rDescriptor.xDriver.is() )
+ // we did not load this driver, yet
+ if ( _rDescriptor.xComponentFactory.is() )
+ // we have a factory for it
+ const_cast< DriverAccess& >( _rDescriptor ).xDriver = _rDescriptor.xDriver.query( _rDescriptor.xComponentFactory->createInstance() );
+ return _rDescriptor;
+ }
+ };
+
+ //---------------------------------------------------------------------
+ //--- 24.08.01 11:28:04 -----------------------------------------------
+
+ /// an STL functor which extracts a SdbcDriver from a DriverAccess
+ struct ExtractDriverFromAccess : public ::std::unary_function< DriverAccess, SdbcDriver >
+ {
+ SdbcDriver operator()( const DriverAccess& _rAccess ) const
+ {
+ return _rAccess.xDriver;
+ }
+ };
+
+ //---------------------------------------------------------------------
+ //--- 24.08.01 12:37:50 -----------------------------------------------
+
+ typedef ::std::unary_compose< ExtractDriverFromAccess, EnsureDriver > ExtractAfterLoad_BASE;
+ /// an STL functor which loads a driver described by a DriverAccess, and extracts the SdbcDriver
+ struct ExtractAfterLoad : public ExtractAfterLoad_BASE
+ {
+ ExtractAfterLoad() : ExtractAfterLoad_BASE( ExtractDriverFromAccess(), EnsureDriver() ) { }
+ };
+
+ //---------------------------------------------------------------------
+ //--- 24.08.01 11:42:36 -----------------------------------------------
+
+ struct ExtractDriverFromCollectionElement : public ::std::unary_function< DriverCollection::value_type, SdbcDriver >
+ {
+ SdbcDriver operator()( const DriverCollection::value_type& _rElement ) const
+ {
+ return _rElement.second;
+ }
+ };
+
+ //---------------------------------------------------------------------
+ //--- 24.08.01 11:51:03 -----------------------------------------------
+
+ // predicate for checking whether or not a driver accepts a given URL
+ class AcceptsURL : public ::std::unary_function< SdbcDriver, bool >
+ {
+ protected:
+ const ::rtl::OUString& m_rURL;
+
+ public:
+ // ctor
+ AcceptsURL( const ::rtl::OUString& _rURL ) : m_rURL( _rURL ) { }
+
+ //.................................................................
+ bool operator()( const SdbcDriver& _rDriver ) const
+ {
+ // ask the driver
+ if ( _rDriver.is() && _rDriver->acceptsURL( m_rURL ) )
+ return true;
+
+ // does not accept ...
+ return false;
+ }
+ };
+
+ //---------------------------------------------------------------------
+ //--- 24.08.01 12:51:54 -----------------------------------------------
+
+ static sal_Int32 lcl_getDriverPrecedence( const ::comphelper::ComponentContext& _rContext, Sequence< ::rtl::OUString >& _rPrecedence )
+ {
+ _rPrecedence.realloc( 0 );
+ try
+ {
+ // some strings we need
+ const ::rtl::OUString sConfigurationProviderServiceName =
+ ::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider");
+ const ::rtl::OUString sDriverManagerConfigLocation =
+ ::rtl::OUString::createFromAscii("org.openoffice.Office.DataAccess/DriverManager");
+ const ::rtl::OUString sDriverPreferenceLocation =
+ ::rtl::OUString::createFromAscii("DriverPrecedence");
+ const ::rtl::OUString sNodePathArgumentName =
+ ::rtl::OUString::createFromAscii("nodepath");
+ const ::rtl::OUString sNodeAccessServiceName =
+ ::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess");
+
+ // create a configuration provider
+ Reference< XMultiServiceFactory > xConfigurationProvider;
+ if ( !_rContext.createComponent( sConfigurationProviderServiceName, xConfigurationProvider ) )
+ throw ServiceNotRegisteredException( sConfigurationProviderServiceName, NULL );
+
+ // one argument for creating the node access: the path to the configuration node
+ Sequence< Any > aCreationArgs(1);
+ aCreationArgs[0] <<= NamedValue( sNodePathArgumentName, makeAny( sDriverManagerConfigLocation ) );
+
+ // create the node access
+ Reference< XNameAccess > xDriverManagerNode(xConfigurationProvider->createInstanceWithArguments(sNodeAccessServiceName, aCreationArgs), UNO_QUERY);
+
+ OSL_ENSURE(xDriverManagerNode.is(), "lcl_getDriverPrecedence: could not open my configuration node!");
+ if (xDriverManagerNode.is())
+ {
+ // obtain the preference list
+ Any aPreferences = xDriverManagerNode->getByName(sDriverPreferenceLocation);
+#if OSL_DEBUG_LEVEL > 0
+ sal_Bool bSuccess =
+#endif
+ aPreferences >>= _rPrecedence;
+ OSL_ENSURE(bSuccess || !aPreferences.hasValue(), "lcl_getDriverPrecedence: invalid value for the preferences node (no string sequence but not NULL)!");
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return _rPrecedence.getLength();
+ }
+
+ //---------------------------------------------------------------------
+ //--- 24.08.01 13:01:56 -----------------------------------------------
+
+ /// an STL argorithm compatible predicate comparing two DriverAccess instances by their implementation names
+ struct CompareDriverAccessByName : public ::std::binary_function< DriverAccess, DriverAccess, bool >
+ {
+ //.................................................................
+ bool operator()( const DriverAccess& lhs, const DriverAccess& rhs )
+ {
+ return lhs.sImplementationName < rhs.sImplementationName ? true : false;
+ }
+ };
+
+ //---------------------------------------------------------------------
+ //--- 24.08.01 13:08:17 -----------------------------------------------
+
+ /// and STL argorithm compatible predicate comparing a DriverAccess' impl name to a string
+ struct CompareDriverAccessToName : public ::std::binary_function< DriverAccess, ::rtl::OUString, bool >
+ {
+ //.................................................................
+ bool operator()( const DriverAccess& lhs, const ::rtl::OUString& rhs )
+ {
+ return lhs.sImplementationName < rhs ? true : false;
+ }
+ //.................................................................
+ bool operator()( const ::rtl::OUString& lhs, const DriverAccess& rhs )
+ {
+ return lhs < rhs.sImplementationName ? true : false;
+ }
+ };
+
+ /// and STL argorithm compatible predicate comparing a DriverAccess' impl name to a string
+ struct EqualDriverAccessToName : public ::std::binary_function< DriverAccess, ::rtl::OUString, bool >
+ {
+ ::rtl::OUString m_sImplName;
+ EqualDriverAccessToName(const ::rtl::OUString& _sImplName) : m_sImplName(_sImplName){}
+ //.................................................................
+ bool operator()( const DriverAccess& lhs)
+ {
+ return lhs.sImplementationName.equals(m_sImplName);
+ }
+ };
+
+//==========================================================================
+//= OSDBCDriverManager
+//==========================================================================
+//--------------------------------------------------------------------------
+OSDBCDriverManager::OSDBCDriverManager( const Reference< XComponentContext >& _rxContext )
+ :m_aContext( _rxContext )
+ ,m_aEventLogger( _rxContext, "org.openoffice.logging.sdbc.DriverManager" )
+ ,m_aDriverConfig(m_aContext.getLegacyServiceFactory())
+ ,m_nLoginTimeout(0)
+{
+ // bootstrap all objects supporting the .sdb.Driver service
+ bootstrapDrivers();
+
+ // initialize the drivers order
+ initializeDriverPrecedence();
+}
+
+//---------------------------------------------------------------------
+OSDBCDriverManager::~OSDBCDriverManager()
+{
+}
+
+//---------------------------------------------------------------------
+//--- 24.08.01 11:15:32 -----------------------------------------------
+
+void OSDBCDriverManager::bootstrapDrivers()
+{
+ Reference< XContentEnumerationAccess > xEnumAccess( m_aContext.getLegacyServiceFactory(), UNO_QUERY );
+ Reference< XEnumeration > xEnumDrivers;
+ if (xEnumAccess.is())
+ xEnumDrivers = xEnumAccess->createContentEnumeration(SERVICE_SDBC_DRIVER);
+
+ OSL_ENSURE( xEnumDrivers.is(), "OSDBCDriverManager::bootstrapDrivers: no enumeration for the drivers available!" );
+ if (xEnumDrivers.is())
+ {
+ Reference< XSingleServiceFactory > xFactory;
+ Reference< XServiceInfo > xSI;
+ while (xEnumDrivers->hasMoreElements())
+ {
+ ::cppu::extractInterface( xFactory, xEnumDrivers->nextElement() );
+ OSL_ENSURE( xFactory.is(), "OSDBCDriverManager::bootstrapDrivers: no factory extracted" );
+
+ if ( xFactory.is() )
+ {
+ // we got a factory for the driver
+ DriverAccess aDriverDescriptor;
+ sal_Bool bValidDescriptor = sal_False;
+
+ // can it tell us something about the implementation name?
+ xSI = xSI.query( xFactory );
+ if ( xSI.is() )
+ { // yes -> no need to load the driver immediately (load it later when needed)
+ aDriverDescriptor.sImplementationName = xSI->getImplementationName();
+ aDriverDescriptor.xComponentFactory = xFactory;
+ bValidDescriptor = sal_True;
+
+ m_aEventLogger.log( LogLevel::CONFIG,
+ "found SDBC driver $1$, no need to load it",
+ aDriverDescriptor.sImplementationName
+ );
+ }
+ else
+ {
+ // no -> create the driver
+ Reference< XDriver > xDriver( xFactory->createInstance(), UNO_QUERY );
+ OSL_ENSURE( xDriver.is(), "OSDBCDriverManager::bootstrapDrivers: a driver which is no driver?!" );
+
+ if ( xDriver.is() )
+ {
+ aDriverDescriptor.xDriver = xDriver;
+ // and obtain it's implementation name
+ xSI = xSI.query( xDriver );
+ OSL_ENSURE( xSI.is(), "OSDBCDriverManager::bootstrapDrivers: a driver without service info?" );
+ if ( xSI.is() )
+ {
+ aDriverDescriptor.sImplementationName = xSI->getImplementationName();
+ bValidDescriptor = sal_True;
+
+ m_aEventLogger.log( LogLevel::CONFIG,
+ "found SDBC driver $1$, needed to load it",
+ aDriverDescriptor.sImplementationName
+ );
+ }
+ }
+ }
+
+ if ( bValidDescriptor )
+ {
+ m_aDriversBS.push_back( aDriverDescriptor );
+ }
+ }
+ }
+ }
+}
+
+//--------------------------------------------------------------------------
+void OSDBCDriverManager::initializeDriverPrecedence()
+{
+ if ( m_aDriversBS.empty() )
+ // nothing to do
+ return;
+
+ try
+ {
+ // get the precedence of the drivers from the configuration
+ Sequence< ::rtl::OUString > aDriverOrder;
+ if ( 0 == lcl_getDriverPrecedence( m_aContext, aDriverOrder ) )
+ // nothing to do
+ return;
+
+ // aDriverOrder now is the list of driver implementation names in the order they should be used
+
+ if ( m_aEventLogger.isLoggable( LogLevel::CONFIG ) )
+ {
+ sal_Int32 nOrderedCount = aDriverOrder.getLength();
+ for ( sal_Int32 i=0; i<nOrderedCount; ++i )
+ m_aEventLogger.log( LogLevel::CONFIG,
+ "configuration's driver order: driver $1$ of $2$: $3$",
+ (sal_Int32)(i + 1), nOrderedCount, aDriverOrder[i]
+ );
+ }
+
+ // sort our bootstrapped drivers
+ ::std::sort( m_aDriversBS.begin(), m_aDriversBS.end(), CompareDriverAccessByName() );
+
+ // loop through the names in the precedence order
+ const ::rtl::OUString* pDriverOrder = aDriverOrder.getConstArray();
+ const ::rtl::OUString* pDriverOrderEnd = pDriverOrder + aDriverOrder.getLength();
+
+ // the first driver for which there is no preference
+ DriverAccessArrayIterator aNoPrefDriversStart = m_aDriversBS.begin();
+ // at the moment this is the first of all drivers we know
+
+ for ( ; ( pDriverOrder < pDriverOrderEnd ) && ( aNoPrefDriversStart != m_aDriversBS.end() ); ++pDriverOrder )
+ {
+ // look for the impl name in the DriverAccess array
+ ::std::pair< DriverAccessArrayIterator, DriverAccessArrayIterator > aPos =
+ ::std::equal_range( aNoPrefDriversStart, m_aDriversBS.end(), *pDriverOrder, CompareDriverAccessToName() );
+
+ if ( aPos.first != aPos.second )
+ { // we have a DriverAccess with this impl name
+
+ OSL_ENSURE( ::std::distance( aPos.first, aPos.second ) == 1,
+ "OSDBCDriverManager::initializeDriverPrecedence: more than one driver with this impl name? How this?" );
+ // move the DriverAccess pointed to by aPos.first to the position pointed to by aNoPrefDriversStart
+
+ if ( aPos.first != aNoPrefDriversStart )
+ { // if this does not hold, the DriverAccess alread has the correct position
+
+ // rotate the range [aNoPrefDriversStart, aPos.second) right 1 element
+ ::std::rotate( aNoPrefDriversStart, aPos.second - 1, aPos.second );
+ }
+
+ // next round we start searching and pos right
+ ++aNoPrefDriversStart;
+ }
+ }
+ }
+ catch (Exception&)
+ {
+ OSL_ENSURE(sal_False, "OSDBCDriverManager::initializeDriverPrecedence: caught an exception while sorting the drivers!");
+ }
+}
+
+//--------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL OSDBCDriverManager::getConnection( const ::rtl::OUString& _rURL ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ m_aEventLogger.log( LogLevel::INFO,
+ "connection requested for URL $1$",
+ _rURL
+ );
+
+ Reference< XConnection > xConnection;
+ Reference< XDriver > xDriver = implGetDriverForURL(_rURL);
+ if (xDriver.is())
+ {
+ // TODO : handle the login timeout
+ xConnection = xDriver->connect(_rURL, Sequence< PropertyValue >());
+ // may throw an exception
+ m_aEventLogger.log( LogLevel::INFO,
+ "connection retrieved for URL $1$",
+ _rURL
+ );
+ }
+
+ return xConnection;
+}
+
+//--------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL OSDBCDriverManager::getConnectionWithInfo( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _rInfo ) throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ m_aEventLogger.log( LogLevel::INFO,
+ "connection with info requested for URL $1$",
+ _rURL
+ );
+
+ Reference< XConnection > xConnection;
+ Reference< XDriver > xDriver = implGetDriverForURL(_rURL);
+ if (xDriver.is())
+ {
+ // TODO : handle the login timeout
+ xConnection = xDriver->connect(_rURL, _rInfo);
+ // may throw an exception
+ m_aEventLogger.log( LogLevel::INFO,
+ "connection with info retrieved for URL $1$",
+ _rURL
+ );
+ }
+
+ return xConnection;
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OSDBCDriverManager::setLoginTimeout( sal_Int32 seconds ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ m_nLoginTimeout = seconds;
+}
+
+//--------------------------------------------------------------------------
+sal_Int32 SAL_CALL OSDBCDriverManager::getLoginTimeout( ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ return m_nLoginTimeout;
+}
+
+//--------------------------------------------------------------------------
+Reference< XEnumeration > SAL_CALL OSDBCDriverManager::createEnumeration( ) throw(RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ ODriverEnumeration::DriverArray aDrivers;
+
+ // ensure that all our bootstrapped drivers are insatntiated
+ ::std::for_each( m_aDriversBS.begin(), m_aDriversBS.end(), EnsureDriver() );
+
+ // copy the bootstrapped drivers
+ ::std::transform(
+ m_aDriversBS.begin(), // "copy from" start
+ m_aDriversBS.end(), // "copy from" end
+ ::std::back_inserter( aDrivers ), // insert into
+ ExtractDriverFromAccess() // transformation to apply (extract a driver from a driver access)
+ );
+
+ // append the runtime drivers
+ ::std::transform(
+ m_aDriversRT.begin(), // "copy from" start
+ m_aDriversRT.end(), // "copy from" end
+ ::std::back_inserter( aDrivers ), // insert into
+ ExtractDriverFromCollectionElement() // transformation to apply (extract a driver from a driver access)
+ );
+
+ return new ODriverEnumeration( aDrivers );
+}
+
+//--------------------------------------------------------------------------
+::com::sun::star::uno::Type SAL_CALL OSDBCDriverManager::getElementType( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::getCppuType(static_cast< Reference< XDriver >* >(NULL));
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL OSDBCDriverManager::hasElements( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ return !(m_aDriversBS.empty() && m_aDriversRT.empty());
+}
+
+//--------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OSDBCDriverManager::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_static();
+}
+
+//--------------------------------------------------------------------------
+sal_Bool SAL_CALL OSDBCDriverManager::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 OSDBCDriverManager::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_static();
+}
+
+//--------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OSDBCDriverManager::Create( const Reference< XMultiServiceFactory >& _rxFactory )
+{
+ ::comphelper::ComponentContext aContext( _rxFactory );
+ return *( new OSDBCDriverManager( aContext.getUNOContext() ) );
+}
+
+//--------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OSDBCDriverManager::getImplementationName_static( ) throw(RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.comp.sdbc.OSDBCDriverManager");
+}
+
+//--------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OSDBCDriverManager::getSupportedServiceNames_static( ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = getSingletonName_static();
+ return aSupported;
+}
+
+//--------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OSDBCDriverManager::getSingletonName_static( ) throw(RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdbc.DriverManager" ) );
+}
+
+//--------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OSDBCDriverManager::getRegisteredObject( const ::rtl::OUString& _rName ) throw(Exception, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+ ConstDriverCollectionIterator aSearch = m_aDriversRT.find(_rName);
+ if (aSearch == m_aDriversRT.end())
+ throwNoSuchElementException();
+
+ return aSearch->second.get();
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OSDBCDriverManager::registerObject( const ::rtl::OUString& _rName, const Reference< XInterface >& _rxObject ) throw(Exception, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ m_aEventLogger.log( LogLevel::INFO,
+ "attempt to register new driver for name $1$",
+ _rName
+ );
+
+ ConstDriverCollectionIterator aSearch = m_aDriversRT.find(_rName);
+ if (aSearch == m_aDriversRT.end())
+ {
+ Reference< XDriver > xNewDriver(_rxObject, UNO_QUERY);
+ if (xNewDriver.is())
+ m_aDriversRT.insert(DriverCollection::value_type(_rName, xNewDriver));
+ else
+ throw IllegalArgumentException();
+ }
+ else
+ throw ElementExistException();
+
+ m_aEventLogger.log( LogLevel::INFO,
+ "new driver registered for name $1$",
+ _rName
+ );
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL OSDBCDriverManager::revokeObject( const ::rtl::OUString& _rName ) throw(Exception, RuntimeException)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ m_aEventLogger.log( LogLevel::INFO,
+ "attempt to revoke driver for name $1$",
+ _rName
+ );
+
+ DriverCollectionIterator aSearch = m_aDriversRT.find(_rName);
+ if (aSearch == m_aDriversRT.end())
+ throwNoSuchElementException();
+
+ m_aDriversRT.erase(aSearch); // we already have the iterator so we could use it
+
+ m_aEventLogger.log( LogLevel::INFO,
+ "driver revoked for name $1$",
+ _rName
+ );
+}
+
+//--------------------------------------------------------------------------
+Reference< XDriver > SAL_CALL OSDBCDriverManager::getDriverByURL( const ::rtl::OUString& _rURL ) throw(RuntimeException)
+{
+ m_aEventLogger.log( LogLevel::INFO,
+ "driver requested for URL $1$",
+ _rURL
+ );
+
+ Reference< XDriver > xDriver( implGetDriverForURL( _rURL ) );
+
+ if ( xDriver.is() )
+ m_aEventLogger.log( LogLevel::INFO,
+ "driver obtained for URL $1$",
+ _rURL
+ );
+
+ return xDriver;
+}
+
+//--------------------------------------------------------------------------
+Reference< XDriver > OSDBCDriverManager::implGetDriverForURL(const ::rtl::OUString& _rURL)
+{
+ Reference< XDriver > xReturn;
+
+ {
+ const ::rtl::OUString sDriverFactoryName = m_aDriverConfig.getDriverFactoryName(_rURL);
+
+ EqualDriverAccessToName aEqual(sDriverFactoryName);
+ DriverAccessArray::iterator aFind = ::std::find_if(m_aDriversBS.begin(),m_aDriversBS.end(),aEqual);
+ if ( aFind == m_aDriversBS.end() )
+ {
+ // search all bootstrapped drivers
+ aFind = ::std::find_if(
+ m_aDriversBS.begin(), // begin of search range
+ m_aDriversBS.end(), // end of search range
+ std::unary_compose< AcceptsURL, ExtractAfterLoad >( AcceptsURL( _rURL ), ExtractAfterLoad() )
+ // compose two functors: extract the driver from the access, then ask the resulting driver for acceptance
+ );
+ } // if ( m_aDriversBS.find(sDriverFactoryName ) == m_aDriversBS.end() )
+ else
+ {
+ EnsureDriver aEnsure;
+ aEnsure(*aFind);
+ }
+
+ // found something?
+ if ( m_aDriversBS.end() != aFind && aFind->xDriver.is() && aFind->xDriver->acceptsURL(_rURL) )
+ xReturn = aFind->xDriver;
+ }
+
+ if ( !xReturn.is() )
+ {
+ // no -> search the runtime drivers
+ DriverCollectionIterator aPos = ::std::find_if(
+ m_aDriversRT.begin(), // begin of search range
+ m_aDriversRT.end(), // end of search range
+ std::unary_compose< AcceptsURL, ExtractDriverFromCollectionElement >( AcceptsURL( _rURL ), ExtractDriverFromCollectionElement() )
+ // compose two functors: extract the driver from the access, then ask the resulting driver for acceptance
+ );
+
+ if ( m_aDriversRT.end() != aPos )
+ xReturn = aPos->second;
+ }
+
+ return xReturn;
+}
+
+} // namespace drivermanager
diff --git a/connectivity/source/manager/mdrivermanager.hxx b/connectivity/source/manager/mdrivermanager.hxx
new file mode 100644
index 000000000000..a9287013ed02
--- /dev/null
+++ b/connectivity/source/manager/mdrivermanager.hxx
@@ -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.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_DRIVERMANAGER_HXX_
+#define _CONNECTIVITY_DRIVERMANAGER_HXX_
+
+#include <com/sun/star/sdbc/XDriverManager.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+
+#include <cppuhelper/implbase5.hxx>
+#include <comphelper/stl_types.hxx>
+#include <comphelper/logging.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <osl/mutex.hxx>
+#include "connectivity/DriversConfig.hxx"
+
+namespace drivermanager
+{
+
+ //======================================================================
+ //= various
+ //======================================================================
+ typedef ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > SdbcDriver;
+ DECLARE_STL_USTRINGACCESS_MAP( SdbcDriver, DriverCollection );
+
+ typedef ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > DriverFactory;
+ struct DriverAccess
+ {
+ ::rtl::OUString sImplementationName; /// the implementation name of the driver
+ DriverFactory xComponentFactory; /// the factory to create the driver component (if not already done so)
+ SdbcDriver xDriver; /// the driver itself
+ };
+
+ //==========================================================================
+ //= OSDBCDriverManager - the one-instance service for managing SDBC drivers
+ //==========================================================================
+ typedef ::cppu::WeakImplHelper5 < ::com::sun::star::sdbc::XDriverManager
+ , ::com::sun::star::sdbc::XDriverAccess
+ , ::com::sun::star::container::XEnumerationAccess
+ , ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::uno::XNamingService
+ > OSDBCDriverManager_Base;
+
+ class OSDBCDriverManager : public OSDBCDriverManager_Base
+ {
+ friend class ODriverEnumeration;
+
+ ::osl::Mutex m_aMutex;
+ ::comphelper::ComponentContext m_aContext;
+ ::comphelper::EventLogger m_aEventLogger;
+
+ DECLARE_STL_VECTOR(DriverAccess, DriverAccessArray);
+ DriverAccessArray m_aDriversBS;
+
+ // for drivers registered at runtime (not bootstrapped) we don't require an XServiceInfo interface,
+ // so we have to remember their impl-name in another way
+ DECLARE_STL_USTRINGACCESS_MAP(SdbcDriver, DriverCollection);
+ DriverCollection m_aDriversRT;
+
+ ::connectivity::DriversConfig m_aDriverConfig;
+ sal_Int32 m_nLoginTimeout;
+
+ private:
+ OSDBCDriverManager(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
+ ~OSDBCDriverManager();
+
+ public:
+
+ // XDriverManager
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnectionWithInfo( 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 void SAL_CALL setLoginTimeout( sal_Int32 seconds ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getLoginTimeout( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XDriverAccess
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > SAL_CALL getDriverByURL( const ::rtl::OUString& url ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XEnumerationAccess
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XElementAccess
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements( ) 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);
+
+ // XServiceInfo - static methods
+ 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 ::rtl::OUString SAL_CALL getSingletonName_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 >& _rxContext );
+
+ // XNamingService
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getRegisteredObject( const ::rtl::OUString& Name ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL registerObject( const ::rtl::OUString& Name, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Object ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL revokeObject( const ::rtl::OUString& Name ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > implGetDriverForURL(const ::rtl::OUString& _rURL);
+
+ /** retrieve the driver order preferences from the configuration and
+ sort m_aDriversBS accordingly.
+ */
+ void initializeDriverPrecedence();
+
+ void bootstrapDrivers();
+ };
+
+} // namespace drivermanager
+
+#endif // _CONNECTIVITY_DRIVERMANAGER_HXX_
+
+
diff --git a/connectivity/source/manager/mregistration.cxx b/connectivity/source/manager/mregistration.cxx
new file mode 100644
index 000000000000..f3bdf74c9574
--- /dev/null
+++ b/connectivity/source/manager/mregistration.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "mdrivermanager.hxx"
+
+#include <cppuhelper/factory.hxx>
+
+#include <stdio.h>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+
+//==========================================================================
+//= registration
+//==========================================================================
+extern "C"
+{
+
+//---------------------------------------------------------------------------------------
+SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(const sal_Char** _ppEnvTypeName, uno_Environment** /*_ppEnv*/)
+{
+ *_ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(void* /*_pServiceManager*/, com::sun::star::registry::XRegistryKey* _pRegistryKey)
+{
+
+
+ sal_Bool bReturn = sal_False;
+
+ try
+ {
+ ::rtl::OUString sMainKeyName = ::rtl::OUString::createFromAscii("/");
+ sMainKeyName += ::drivermanager::OSDBCDriverManager::getImplementationName_static();
+ sMainKeyName += ::rtl::OUString::createFromAscii("/UNO/SERVICES");
+ Reference< XRegistryKey > xMainKey = _pRegistryKey->createKey(sMainKeyName);
+ if (xMainKey.is())
+ {
+ Sequence< ::rtl::OUString > sServices(::drivermanager::OSDBCDriverManager::getSupportedServiceNames_static());
+ const ::rtl::OUString* pBegin = sServices.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + sServices.getLength();
+ for (;pBegin != pEnd ; ++pBegin)
+ xMainKey->createKey(*pBegin);
+ bReturn = sal_True;
+ }
+ }
+ catch(InvalidRegistryException&)
+ {
+ }
+ catch(InvalidValueException&)
+ {
+ }
+ return bReturn;
+}
+
+//---------------------------------------------------------------------------------------
+SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(const sal_Char* _pImplName, ::com::sun::star::lang::XMultiServiceFactory* _pServiceManager, void* /*_pRegistryKey*/)
+{
+ void* pRet = NULL;
+
+ if (::drivermanager::OSDBCDriverManager::getImplementationName_static().compareToAscii(_pImplName) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory(
+ ::cppu::createOneInstanceFactory(
+ _pServiceManager,
+ ::drivermanager::OSDBCDriverManager::getImplementationName_static(),
+ ::drivermanager::OSDBCDriverManager::Create,
+ ::drivermanager::OSDBCDriverManager::getSupportedServiceNames_static()
+ )
+ );
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+
+} // extern "C"
+
+
diff --git a/connectivity/source/manager/sdbc.mxp.map b/connectivity/source/manager/sdbc.mxp.map
new file mode 100644
index 000000000000..14e33ebafb65
--- /dev/null
+++ b/connectivity/source/manager/sdbc.mxp.map
@@ -0,0 +1,53 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
+__mh_dylib_header
+___builtin_delete
+___builtin_new
+___check_eh_spec
+___cp_pop_exception
+___cp_push_exception
+___eh_alloc
+___eh_rtime_match
+___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
+__._9bad_alloc
+___tf9bad_alloc
+___vt_9bad_alloc
+___vt_9exception
+__keymgr_get_per_thread_data
+__._10bad_typeid
+__._8bad_cast
+___get_eh_info
+___is_pointer__FPv
+___throw_type_match_rtti
+___vt_10bad_typeid
+___vt_8bad_cast
+__keymgr_set_per_thread_data
+___tf9exception
+___ti9exception
+_what__C9exception
+__._9type_info
+___eq__C9type_infoRCB0
+___tf16__user_type_info
+___tf9type_info
+___ti9type_info
+___vt_9type_info
+___18OSDBCDriverManagerRCQ53com3sun4star3unot9Reference1ZQ53com3sun4star4lang20XMultiServiceFactory
+___18ODriverEnumerationRCQ24_STLt6vector2ZQ53com3sun4star3unot9Reference1ZQ53com3sun4star4sdbc7XDriverZQ24_STLt9allocator1ZB2
+_implGetDriverForURL__18OSDBCDriverManagerRCQ23rtl8OUString
+___tf13bad_exception
+___uncatch_exception
+___eh_free
+___tfv
+___dynamic_cast
diff --git a/connectivity/source/parse/PColumn.cxx b/connectivity/source/parse/PColumn.cxx
new file mode 100644
index 000000000000..43e38f5a1674
--- /dev/null
+++ b/connectivity/source/parse/PColumn.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"
+
+#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_
+#include "connectivity/PColumn.hxx"
+#endif
+#include "connectivity/dbtools.hxx"
+#include "TConnection.hxx"
+#include <comphelper/types.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace dbtools;
+using namespace connectivity::parse;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+
+// -------------------------------------------------------------------------
+OParseColumn::OParseColumn(const Reference<XPropertySet>& _xColumn,sal_Bool _bCase)
+ : connectivity::sdbcx::OColumn( getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)))
+ , getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)))
+ , getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)))
+ , getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION)))
+ , getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))
+ , getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))
+ , getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))
+ , getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))
+ , getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)))
+ , sal_False
+ , getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))
+ , _bCase
+ )
+ , m_bFunction(sal_False)
+ , m_bDbasePrecisionChanged(sal_False)
+ , m_bAggregateFunction(sal_False)
+ , m_bIsSearchable( sal_True )
+{
+ construct();
+}
+
+// -------------------------------------------------------------------------
+OParseColumn::OParseColumn( const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _TypeName,
+ const ::rtl::OUString& _DefaultValue,
+ const ::rtl::OUString& _Description,
+ sal_Int32 _IsNullable,
+ sal_Int32 _Precision,
+ sal_Int32 _Scale,
+ sal_Int32 _Type,
+ sal_Bool _IsAutoIncrement,
+ sal_Bool _IsCurrency,
+ sal_Bool _bCase
+ ) : connectivity::sdbcx::OColumn(_Name,
+ _TypeName,
+ _DefaultValue,
+ _Description,
+ _IsNullable,
+ _Precision,
+ _Scale,
+ _Type,
+ _IsAutoIncrement,
+ sal_False,
+ _IsCurrency,
+ _bCase)
+ , m_bFunction(sal_False)
+ , m_bDbasePrecisionChanged(sal_False)
+ , m_bAggregateFunction(sal_False)
+ , m_bIsSearchable( sal_True )
+{
+ construct();
+}
+
+// -------------------------------------------------------------------------
+::vos::ORef< OSQLColumns > OParseColumn::createColumnsForResultSet( const Reference< XResultSetMetaData >& _rxResMetaData,
+ const Reference< XDatabaseMetaData >& _rxDBMetaData,const Reference< XNameAccess>& i_xQueryColumns )
+{
+ sal_Int32 nColumnCount = _rxResMetaData->getColumnCount();
+ ::vos::ORef< OSQLColumns > aReturn( new OSQLColumns ); aReturn->get().reserve( nColumnCount );
+
+ StringMap aColumnMap;
+ for ( sal_Int32 i = 1; i <= nColumnCount; ++i )
+ {
+ OParseColumn* pColumn = createColumnForResultSet( _rxResMetaData, _rxDBMetaData, i,aColumnMap );
+ aReturn->get().push_back( pColumn );
+ if ( i_xQueryColumns.is() && i_xQueryColumns->hasByName(pColumn->getRealName()) )
+ {
+ Reference<XPropertySet> xColumn(i_xQueryColumns->getByName(pColumn->getRealName()),UNO_QUERY_THROW);
+ ::rtl::OUString sLabel;
+ xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_LABEL)) >>= sLabel;
+ if ( sLabel.getLength() )
+ pColumn->setLabel(sLabel);
+ }
+ }
+
+ return aReturn;
+}
+
+// -------------------------------------------------------------------------
+OParseColumn* OParseColumn::createColumnForResultSet( const Reference< XResultSetMetaData >& _rxResMetaData,
+ const Reference< XDatabaseMetaData >& _rxDBMetaData, sal_Int32 _nColumnPos,StringMap& _rColumns )
+{
+ ::rtl::OUString sLabel = _rxResMetaData->getColumnLabel( _nColumnPos );
+ // retrieve the name of the column
+ // check for duplicate entries
+ if(_rColumns.find(sLabel) != _rColumns.end())
+ {
+ ::rtl::OUString sAlias(sLabel);
+ sal_Int32 searchIndex=1;
+ while(_rColumns.find(sAlias) != _rColumns.end())
+ {
+ (sAlias = sLabel) += ::rtl::OUString::valueOf(searchIndex++);
+ }
+ sLabel = sAlias;
+ }
+ _rColumns.insert(StringMap::value_type(sLabel,0));
+ OParseColumn* pColumn = new OParseColumn(
+ sLabel,
+ _rxResMetaData->getColumnTypeName( _nColumnPos ),
+ ::rtl::OUString(),
+ ::rtl::OUString(),
+ _rxResMetaData->isNullable( _nColumnPos ),
+ _rxResMetaData->getPrecision( _nColumnPos ),
+ _rxResMetaData->getScale( _nColumnPos ),
+ _rxResMetaData->getColumnType( _nColumnPos ),
+ _rxResMetaData->isAutoIncrement( _nColumnPos ),
+ _rxResMetaData->isCurrency( _nColumnPos ),
+ _rxDBMetaData->storesMixedCaseQuotedIdentifiers()
+ );
+ pColumn->setTableName( ::dbtools::composeTableName( _rxDBMetaData,
+ _rxResMetaData->getCatalogName( _nColumnPos ),
+ _rxResMetaData->getSchemaName( _nColumnPos ),
+ _rxResMetaData->getTableName( _nColumnPos ),
+ sal_False,
+ eComplete
+ ) );
+ pColumn->setIsSearchable( _rxResMetaData->isSearchable( _nColumnPos ) );
+ pColumn->setRealName(_rxResMetaData->getColumnName( _nColumnPos ));
+ pColumn->setLabel(sLabel);
+ return pColumn;
+}
+
+// -------------------------------------------------------------------------
+OParseColumn::~OParseColumn()
+{
+}
+// -------------------------------------------------------------------------
+void OParseColumn::construct()
+{
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION), PROPERTY_ID_FUNCTION, 0, &m_bFunction, ::getCppuType(reinterpret_cast< sal_Bool*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_AGGREGATEFUNCTION), PROPERTY_ID_AGGREGATEFUNCTION, 0, &m_bAggregateFunction, ::getCppuType(reinterpret_cast< sal_Bool*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME), PROPERTY_ID_TABLENAME, 0, &m_aTableName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME), PROPERTY_ID_REALNAME, 0, &m_aRealName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DBASEPRECISIONCHANGED), PROPERTY_ID_DBASEPRECISIONCHANGED, 0, &m_bDbasePrecisionChanged, ::getCppuType(reinterpret_cast<sal_Bool*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISSEARCHABLE), PROPERTY_ID_ISSEARCHABLE, 0, &m_bIsSearchable, ::getCppuType(reinterpret_cast< sal_Bool*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_LABEL), PROPERTY_ID_LABEL, 0, &m_sLabel, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OParseColumn::createArrayHelper() const
+{
+ return doCreateArrayHelper();
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & SAL_CALL OParseColumn::getInfoHelper()
+{
+ OSL_ENSURE( !isNew(), "OParseColumn::OOrderColumn: a *new* OrderColumn?" );
+ return *OParseColumn_PROP::getArrayHelper();
+}
+// -----------------------------------------------------------------------------
+OOrderColumn::OOrderColumn( const Reference<XPropertySet>& _xColumn
+ ,sal_Bool _bCase
+ ,sal_Bool _bAscending)
+ : connectivity::sdbcx::OColumn( getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)))
+ , getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)))
+ , getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)))
+ , getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION)))
+ , getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))
+ , getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))
+ , getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))
+ , getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))
+ , getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)))
+ , sal_False
+ , getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))
+ , _bCase
+ )
+ , m_bAscending(_bAscending)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+OOrderColumn::~OOrderColumn()
+{
+}
+// -------------------------------------------------------------------------
+void OOrderColumn::construct()
+{
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISASCENDING),PROPERTY_ID_ISASCENDING,0,&m_bAscending, ::getCppuType(reinterpret_cast< sal_Bool*>(NULL)));
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OOrderColumn::createArrayHelper() const
+{
+ return doCreateArrayHelper();
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & SAL_CALL OOrderColumn::getInfoHelper()
+{
+ OSL_ENSURE( !isNew(), "OOrderColumn::OOrderColumn: a *new* OrderColumn?" );
+ return *OOrderColumn_PROP::getArrayHelper();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OOrderColumn::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1);
+ if ( m_bOrder )
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.OrderColumn");
+ else
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.GroupColumn");
+
+ return aSupported;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/parse/internalnode.cxx b/connectivity/source/parse/internalnode.cxx
new file mode 100644
index 000000000000..39b4a4af3b48
--- /dev/null
+++ b/connectivity/source/parse/internalnode.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "internalnode.hxx"
+
+#include <algorithm>
+#include <connectivity/sqlparse.hxx>
+
+using namespace connectivity;
+
+//-----------------------------------------------------------------------------
+OSQLInternalNode::OSQLInternalNode(const sal_Char* pNewValue,
+ SQLNodeType eNodeType,
+ sal_uInt32 nNodeID)
+ : OSQLParseNode(pNewValue,eNodeType,nNodeID)
+{
+ OSL_ENSURE(OSQLParser::s_pGarbageCollector, "Collector not initialized");
+ (*OSQLParser::s_pGarbageCollector)->push_back(this);
+}
+
+//-----------------------------------------------------------------------------
+OSQLInternalNode::OSQLInternalNode(const ::rtl::OString &_NewValue,
+ SQLNodeType eNodeType,
+ sal_uInt32 nNodeID)
+ :OSQLParseNode(_NewValue,eNodeType,nNodeID)
+{
+ OSL_ENSURE(OSQLParser::s_pGarbageCollector, "Collector not initialized");
+ (*OSQLParser::s_pGarbageCollector)->push_back(this);
+}
+
+//-----------------------------------------------------------------------------
+OSQLInternalNode::OSQLInternalNode(const sal_Unicode* pNewValue,
+ SQLNodeType eNodeType,
+ sal_uInt32 nNodeID)
+ :OSQLParseNode(pNewValue,eNodeType,nNodeID)
+{
+ OSL_ENSURE(OSQLParser::s_pGarbageCollector, "Collector not initialized");
+ (*OSQLParser::s_pGarbageCollector)->push_back(this);
+}
+
+//-----------------------------------------------------------------------------
+OSQLInternalNode::OSQLInternalNode(const ::rtl::OUString &_NewValue,
+ SQLNodeType eNodeType,
+ sal_uInt32 nNodeID)
+ :OSQLParseNode(_NewValue,eNodeType,nNodeID)
+{
+ OSL_ENSURE(OSQLParser::s_pGarbageCollector, "Collector not initialized");
+ (*OSQLParser::s_pGarbageCollector)->push_back(this);
+}
+
+
+//-----------------------------------------------------------------------------
+OSQLInternalNode::~OSQLInternalNode()
+{
+ // remove the node from the garbage list
+
+ OSL_ENSURE(OSQLParser::s_pGarbageCollector, "Collector not initialized");
+ (*OSQLParser::s_pGarbageCollector)->erase(this);
+}
diff --git a/connectivity/source/parse/makefile.mk b/connectivity/source/parse/makefile.mk
new file mode 100644
index 000000000000..98eb4685903c
--- /dev/null
+++ b/connectivity/source/parse/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=connectivity
+TARGET=sql
+INCPRE=$(MISC)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/dbtools.pmk
+
+# --- Files --------------------------------------------------------
+
+YACCTARGET= $(MISC)$/sqlbison.cxx
+YACCFILES= sqlbison.y
+YACCFLAGS=-v -d -l -pSQLyy -bsql
+
+EXCEPTIONSFILES = \
+ $(SLO)$/PColumn.obj \
+ $(SLO)$/sqliterator.obj \
+ $(SLO)$/sqlnode.obj \
+ $(SLO)$/wrap_sqlbison.obj \
+ $(SLO)$/internalnode.obj
+
+SLOFILES = \
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/wrap_sqlflex.obj
+
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+$(MISC)$/%.cxx: %.l
+ flex -i -8 -PSQLyy -L -o$(MISC)$/sqlflex.cxx sqlflex.l
+
+$(INCCOM)$/sqlbison.hxx : $(YACCTARGET)
+$(EXCEPTIONSFILES) : $(INCCOM)$/sqlbison.hxx
+$(SLO)$/wrap_sqlbison.obj : $(YACCTARGET)
+$(SLO)$/wrap_sqlflex.obj : $(MISC)$/sqlflex.cxx $(INCCOM)$/sqlbison.hxx
diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y
new file mode 100644
index 000000000000..84e9aa2532ff
--- /dev/null
+++ b/connectivity/source/parse/sqlbison.y
@@ -0,0 +1,4381 @@
+%{
+//--------------------------------------------------------------------------
+//
+// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+//
+// Copyright 2000, 2010 Oracle and/or its affiliates.
+//
+// OpenOffice.org - a multi-platform office productivity suite
+//
+// This file is part of OpenOffice.org.
+//
+// OpenOffice.org is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License version 3
+// only, as published by the Free Software Foundation.
+//
+// OpenOffice.org is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License version 3 for more details
+// (a copy is included in the LICENSE file that accompanied this code).
+//
+// You should have received a copy of the GNU Lesser General 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 <vector>
+#include <string.h>
+
+#ifndef _CONNECTIVITY_SQLNODE_HXX
+#include <connectivity/sqlnode.hxx>
+#endif
+#ifndef _CONNECTIVITY_SQLPARSE_HXX
+#include <connectivity/sqlparse.hxx>
+#endif
+#ifndef _CONNECTIVITY_SQLINTERNALNODE_HXX
+#include <internalnode.hxx>
+#endif
+#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
+#include <com/sun/star/lang/Locale.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
+#include <com/sun/star/sdbc/DataType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_DATE_HPP_
+#include <com/sun/star/util/Date.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_
+#include <com/sun/star/util/DateTime.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_TIME_HPP_
+#include <com/sun/star/util/Time.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATS_HPP_
+#include <com/sun/star/util/XNumberFormats.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_
+#include <com/sun/star/util/NumberFormat.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_I18N_KPARSETYPE_HPP_
+#include <com/sun/star/i18n/KParseType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_I18N_KPARSETOKENS_HPP_
+#include <com/sun/star/i18n/KParseTokens.hpp>
+#endif
+#ifndef _CONNECTIVITY_SQLSCAN_HXX
+#include "sqlscan.hxx"
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef _DBHELPER_DBCONVERSION_HXX_
+#include "connectivity/dbconversion.hxx"
+#endif
+#include <rtl/ustrbuf.hxx>
+
+#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:4273 4701 4706)
+#endif
+
+static ::rtl::OUString aEmptyString;
+
+static connectivity::OSQLInternalNode* newNode(const sal_Char* pNewValue,
+ const connectivity::SQLNodeType eNodeType,
+ const sal_uInt32 nNodeID = 0)
+{
+ return new connectivity::OSQLInternalNode(pNewValue, eNodeType, nNodeID);
+}
+
+static connectivity::OSQLInternalNode* newNode(const ::rtl::OString& _NewValue,
+ const connectivity::SQLNodeType eNodeType,
+ const sal_uInt32 nNodeID = 0)
+{
+ return new connectivity::OSQLInternalNode(_NewValue, eNodeType, nNodeID);
+}
+
+static connectivity::OSQLInternalNode* newNode(const ::rtl::OUString& _NewValue,
+ const connectivity::SQLNodeType eNodeType,
+ const sal_uInt32 nNodeID = 0)
+{
+ return new connectivity::OSQLInternalNode(_NewValue, eNodeType, nNodeID);
+}
+
+
+// yyi ist die interne Nr. der Regel, die gerade reduziert wird.
+// Ueber die Mapping-Tabelle yyrmap wird daraus eine externe Regel-Nr.
+#define SQL_NEW_RULE newNode(aEmptyString, SQL_NODE_RULE, yyr1[yyn])
+#define SQL_NEW_LISTRULE newNode(aEmptyString, SQL_NODE_LISTRULE, yyr1[yyn])
+#define SQL_NEW_COMMALISTRULE newNode(aEmptyString, SQL_NODE_COMMALISTRULE, yyr1[yyn])
+
+
+connectivity::OSQLParser* xxx_pGLOBAL_SQLPARSER;
+
+#define YYERROR_VERBOSE
+
+#define SQLyyerror(s) \
+{ \
+ xxx_pGLOBAL_SQLPARSER->error(s); \
+}
+
+using namespace connectivity;
+#define SQLyylex xxx_pGLOBAL_SQLPARSER->SQLlex
+%}
+ /* symbolic tokens */
+
+%union {
+ connectivity::OSQLParseNode * pParseNode;
+}
+%type <pParseNode> '(' ')' ',' ':' ';' '?' '[' ']' '{' '}' '.' 'K' 'M' 'G' 'T' 'P'
+
+%token <pParseNode> SQL_TOKEN_STRING SQL_TOKEN_ACCESS_DATE SQL_TOKEN_INT SQL_TOKEN_REAL_NUM
+%token <pParseNode> SQL_TOKEN_INTNUM SQL_TOKEN_APPROXNUM SQL_TOKEN_NOT SQL_TOKEN_NAME
+
+
+%nonassoc <pParseNode> SQL_TOKEN_UMINUS
+
+
+
+ /* literal keyword tokens */
+
+%token <pParseNode> SQL_TOKEN_ALL SQL_TOKEN_ALTER SQL_TOKEN_AMMSC SQL_TOKEN_ANY SQL_TOKEN_AS SQL_TOKEN_ASC SQL_TOKEN_AT SQL_TOKEN_AUTHORIZATION SQL_TOKEN_AVG
+
+%token <pParseNode> SQL_TOKEN_BETWEEN SQL_TOKEN_BIT SQL_TOKEN_BOTH SQL_TOKEN_BY
+
+%token <pParseNode> SQL_TOKEN_CAST SQL_TOKEN_CHARACTER SQL_TOKEN_CHECK SQL_TOKEN_COLLATE SQL_TOKEN_COMMIT SQL_TOKEN_CONTINUE SQL_TOKEN_CONVERT SQL_TOKEN_COUNT SQL_TOKEN_CREATE SQL_TOKEN_CROSS
+%token <pParseNode> SQL_TOKEN_CURRENT SQL_TOKEN_CURSOR
+
+%token <pParseNode> SQL_TOKEN_DATE SQL_TOKEN_DATEVALUE SQL_TOKEN_DAY SQL_TOKEN_DEC SQL_TOKEN_DECIMAL SQL_TOKEN_DECLARE SQL_TOKEN_DEFAULT SQL_TOKEN_DELETE SQL_TOKEN_DESC
+%token <pParseNode> SQL_TOKEN_DISTINCT SQL_TOKEN_DOUBLE SQL_TOKEN_DROP
+
+%token <pParseNode> SQL_TOKEN_ESCAPE SQL_TOKEN_EXCEPT SQL_TOKEN_EXISTS SQL_TOKEN_FALSE SQL_TOKEN_FETCH SQL_TOKEN_FLOAT SQL_TOKEN_FOR SQL_TOKEN_FOREIGN SQL_TOKEN_FOUND SQL_TOKEN_FROM SQL_TOKEN_FULL
+
+%token <pParseNode> SQL_TOKEN_GRANT SQL_TOKEN_GROUP SQL_TOKEN_HAVING SQL_TOKEN_IN SQL_TOKEN_INDICATOR SQL_TOKEN_INNER SQL_TOKEN_INTEGER SQL_TOKEN_INTO SQL_TOKEN_IS SQL_TOKEN_INTERSECT
+
+%token <pParseNode> SQL_TOKEN_JOIN SQL_TOKEN_KEY SQL_TOKEN_LEADING SQL_TOKEN_LIKE SQL_TOKEN_LOCAL SQL_TOKEN_LOWER
+%token <pParseNode> SQL_TOKEN_MAX SQL_TOKEN_MIN SQL_TOKEN_NATURAL SQL_TOKEN_NCHAR SQL_TOKEN_NULL SQL_TOKEN_NUMERIC
+
+%token <pParseNode> SQL_TOKEN_OCTET_LENGTH SQL_TOKEN_OF SQL_TOKEN_ON SQL_TOKEN_OPTION SQL_TOKEN_ORDER SQL_TOKEN_OUTER
+
+%token <pParseNode> SQL_TOKEN_PRECISION SQL_TOKEN_PRIMARY SQL_TOKEN_PRIVILEGES SQL_TOKEN_PROCEDURE SQL_TOKEN_PUBLIC
+%token <pParseNode> SQL_TOKEN_REAL SQL_TOKEN_REFERENCES SQL_TOKEN_ROLLBACK
+
+%token <pParseNode> SQL_TOKEN_SCHEMA SQL_TOKEN_SELECT SQL_TOKEN_SET SQL_TOKEN_SIZE SQL_TOKEN_SMALLINT SQL_TOKEN_SOME SQL_TOKEN_SQLCODE SQL_TOKEN_SQLERROR SQL_TOKEN_SUM
+
+%token <pParseNode> SQL_TOKEN_TABLE SQL_TOKEN_TIME SQL_TOKEN_TIMESTAMP SQL_TOKEN_TIMEZONE_HOUR SQL_TOKEN_TIMEZONE_MINUTE SQL_TOKEN_TO SQL_TOKEN_TRAILING SQL_TOKEN_TRANSLATE SQL_TOKEN_TRIM SQL_TOKEN_TRUE SQL_TOKEN_UNION
+%token <pParseNode> SQL_TOKEN_UNIQUE SQL_TOKEN_UNKNOWN SQL_TOKEN_UPDATE SQL_TOKEN_UPPER SQL_TOKEN_USAGE SQL_TOKEN_USER SQL_TOKEN_USING SQL_TOKEN_VALUES SQL_TOKEN_VIEW
+%token <pParseNode> SQL_TOKEN_WHERE SQL_TOKEN_WITH SQL_TOKEN_WORK SQL_TOKEN_ZONE
+
+/* ODBC KEYWORDS */
+%token <pParseNode> SQL_TOKEN_CALL SQL_TOKEN_D SQL_TOKEN_FN SQL_TOKEN_T SQL_TOKEN_TS SQL_TOKEN_OJ
+/* string functions */
+%token <pParseNode> SQL_TOKEN_ASCII SQL_TOKEN_BIT_LENGTH SQL_TOKEN_CHAR SQL_TOKEN_CHAR_LENGTH SQL_TOKEN_SQL_TOKEN_INTNUM
+%token <pParseNode> SQL_TOKEN_CONCAT
+%token <pParseNode> SQL_TOKEN_DIFFERENCE SQL_TOKEN_INSERT SQL_TOKEN_LCASE SQL_TOKEN_LEFT SQL_TOKEN_LENGTH SQL_TOKEN_LOCATE
+%token <pParseNode> SQL_TOKEN_LOCATE_2 SQL_TOKEN_LTRIM SQL_TOKEN_POSITION SQL_TOKEN_REPEAT SQL_TOKEN_REPLACE
+%token <pParseNode> SQL_TOKEN_RIGHT SQL_TOKEN_RTRIM SQL_TOKEN_SOUNDEX SQL_TOKEN_SPACE SQL_TOKEN_SUBSTRING SQL_TOKEN_UCASE
+
+/* time and date functions */
+%token <pParseNode> SQL_TOKEN_CURRENT_DATE SQL_TOKEN_CURRENT_TIME SQL_TOKEN_CURRENT_TIMESTAMP SQL_TOKEN_CURDATE SQL_TOKEN_CURTIME
+%token <pParseNode> SQL_TOKEN_DAYNAME SQL_TOKEN_DAYOFMONTH SQL_TOKEN_DAYOFWEEK SQL_TOKEN_DAYOFYEAR SQL_TOKEN_EXTRACT
+%token <pParseNode> SQL_TOKEN_HOUR SQL_TOKEN_MINUTE SQL_TOKEN_MONTH SQL_TOKEN_MONTHNAME SQL_TOKEN_NOW SQL_TOKEN_QUARTER SQL_TOKEN_DATEDIFF
+%token <pParseNode> SQL_TOKEN_SECOND SQL_TOKEN_TIMESTAMPADD SQL_TOKEN_TIMESTAMPDIFF SQL_TOKEN_TIMEVALUE SQL_TOKEN_WEEK SQL_TOKEN_YEAR
+
+/* numeric functions */
+%token <pParseNode> SQL_TOKEN_ABS SQL_TOKEN_ACOS SQL_TOKEN_ASIN SQL_TOKEN_ATAN SQL_TOKEN_ATAN2 SQL_TOKEN_CEILING
+%token <pParseNode> SQL_TOKEN_COS SQL_TOKEN_COT SQL_TOKEN_DEGREES SQL_TOKEN_EXP SQL_TOKEN_FLOOR SQL_TOKEN_LOGF SQL_TOKEN_LOG SQL_TOKEN_LN
+%token <pParseNode> SQL_TOKEN_LOG10 SQL_TOKEN_MOD SQL_TOKEN_PI SQL_TOKEN_POWER SQL_TOKEN_RADIANS SQL_TOKEN_RAND SQL_TOKEN_ROUNDMAGIC
+%token <pParseNode> SQL_TOKEN_ROUND SQL_TOKEN_SIGN SQL_TOKEN_SIN SQL_TOKEN_SQRT SQL_TOKEN_TAN SQL_TOKEN_TRUNCATE
+
+// computational operation
+%token <pParseNode> SQL_TOKEN_EVERY SQL_TOKEN_INTERSECTION SQL_TOKEN_FUSION SQL_TOKEN_COLLECT SQL_TOKEN_VAR_POP SQL_TOKEN_VAR_SAMP
+%token <pParseNode> SQL_TOKEN_STDDEV_SAMP SQL_TOKEN_STDDEV_POP
+
+%token <pParseNode> SQL_TOKEN_RANK SQL_TOKEN_DENSE_RANK SQL_TOKEN_PERCENT_RANK SQL_TOKEN_CUME_DIST SQL_TOKEN_PERCENTILE_CONT SQL_TOKEN_PERCENTILE_DISC SQL_TOKEN_WITHIN SQL_TOKEN_ARRAY_AGG
+%token <pParseNode> SQL_TOKEN_CASE SQL_TOKEN_THEN SQL_TOKEN_END SQL_TOKEN_NULLIF SQL_TOKEN_COALESCE SQL_TOKEN_WHEN SQL_TOKEN_ELSE
+%token <pParseNode> SQL_TOKEN_BEFORE SQL_TOKEN_AFTER SQL_TOKEN_INSTEAD SQL_TOKEN_EACH SQL_TOKEN_REFERENCING SQL_TOKEN_BEGIN SQL_TOKEN_ATOMIC SQL_TOKEN_TRIGGER SQL_TOKEN_ROW SQL_TOKEN_STATEMENT
+%token <pParseNode> SQL_TOKEN_NEW SQL_TOKEN_OLD
+%token <pParseNode> SQL_TOKEN_VALUE SQL_TOKEN_CURRENT_CATALOG SQL_TOKEN_CURRENT_DEFAULT_TRANSFORM_GROUP SQL_TOKEN_CURRENT_PATH SQL_TOKEN_CURRENT_ROLE SQL_TOKEN_CURRENT_SCHEMA SQL_TOKEN_CURRENT_USER
+%token <pParseNode> SQL_TOKEN_SESSION_USER SQL_TOKEN_SYSTEM_USER SQL_TOKEN_VARCHAR SQL_TOKEN_VARBINARY SQL_TOKEN_VARYING SQL_TOKEN_OBJECT SQL_TOKEN_NCLOB SQL_TOKEN_NATIONAL
+%token <pParseNode> SQL_TOKEN_LARGE SQL_TOKEN_CLOB SQL_TOKEN_BLOB SQL_TOKEN_BIGINT SQL_TOKEN_BINARY SQL_TOKEN_WITHOUT SQL_TOKEN_BOOLEAN SQL_TOKEN_INTERVAL
+ /* operators */
+%left SQL_TOKEN_NAME
+%left <pParseNode> SQL_TOKEN_OR
+%left <pParseNode> SQL_TOKEN_AND
+
+%left <pParseNode> SQL_LESSEQ SQL_GREATEQ SQL_NOTEQUAL SQL_LESS SQL_GREAT SQL_EQUAL /* '<' '>' = <> < > <= >= != */
+%left <pParseNode> '+' '-' SQL_CONCAT
+%left <pParseNode> '*' '/'
+%left SQL_TOKEN_NATURAL SQL_TOKEN_CROSS SQL_TOKEN_FULL SQL_TOKEN_LEFT SQL_TOKEN_RIGHT
+%left ')'
+%right '='
+%right '.'
+%right '('
+
+
+%token <pParseNode> SQL_TOKEN_INVALIDSYMBOL
+
+/*%type <pParseNode> sql_single_statement */
+
+%type <pParseNode> sql /*schema */
+%type <pParseNode> column_def_opt_list column_def_opt table_constraint_def column_commalist
+%type <pParseNode> view_def opt_with_check_option opt_column_commalist privilege_def
+%type <pParseNode> opt_with_grant_option privileges operation_commalist operation
+%type <pParseNode> grantee_commalist grantee opt_order_by_clause ordering_spec_commalist
+%type <pParseNode> ordering_spec opt_asc_desc manipulative_statement commit_statement
+%type <pParseNode> /*delete_statement_positioned*/ delete_statement_searched fetch_statement
+%type <pParseNode> insert_statement values_or_query_spec
+%type <pParseNode> rollback_statement select_statement_into opt_all_distinct
+%type <pParseNode> /*update_statement_positioned*/ assignment_commalist assignment
+%type <pParseNode> update_statement_searched target_commalist target opt_where_clause
+%type <pParseNode> select_statement selection table_exp from_clause table_ref_commalist table_ref
+%type <pParseNode> where_clause opt_group_by_clause column_ref_commalist opt_having_clause
+%type <pParseNode> search_condition predicate comparison_predicate comparison_predicate_part_2 between_predicate between_predicate_part_2
+%type <pParseNode> like_predicate opt_escape test_for_null null_predicate_part_2 in_predicate in_predicate_part_2 character_like_predicate_part_2 other_like_predicate_part_2
+%type <pParseNode> all_or_any_predicate any_all_some existence_test subquery quantified_comparison_predicate_part_2
+%type <pParseNode> scalar_exp_commalist parameter_ref literal parenthesized_boolean_value_expression
+%type <pParseNode> column_ref data_type column cursor parameter range_variable user /*like_check*/
+/* neue Regeln bei OJ */
+%type <pParseNode> derived_column as_clause table_name num_primary term num_value_exp
+%type <pParseNode> value_exp_primary num_value_fct unsigned_value_spec cast_spec set_fct_spec scalar_subquery
+%type <pParseNode> position_exp extract_exp length_exp general_value_spec
+%type <pParseNode> general_set_fct set_fct_type query_exp non_join_query_exp joined_table
+%type <pParseNode> non_join_query_term non_join_query_primary simple_table
+%type <pParseNode> table_value_const_list row_value_constructor row_value_const_list row_value_constructor_elem
+%type <pParseNode> qualified_join value_exp query_term join_type outer_join_type join_condition boolean_term
+%type <pParseNode> boolean_factor truth_value boolean_test boolean_primary named_columns_join join_spec
+%type <pParseNode> cast_operand cast_target factor datetime_value_exp /*interval_value_exp*/ datetime_term datetime_factor
+%type <pParseNode> datetime_primary datetime_value_fct time_zone time_zone_specifier /*interval_term*/ interval_qualifier
+%type <pParseNode> start_field non_second_datetime_field end_field single_datetime_field extract_field datetime_field time_zone_field
+%type <pParseNode> extract_source char_length_exp octet_length_exp bit_length_exp select_sublist string_value_exp
+%type <pParseNode> char_value_exp concatenation char_factor char_primary string_value_fct char_substring_fct fold
+%type <pParseNode> form_conversion char_translation trim_fct trim_operands trim_spec bit_value_fct bit_substring_fct op_column_commalist
+%type <pParseNode> /*bit_concatenation*/ bit_value_exp bit_factor bit_primary collate_clause char_value_fct unique_spec value_exp_commalist in_predicate_value unique_test update_source
+%type <pParseNode> function_arg_commalist3 string_function_3Argument function_arg_commalist4 string_function_4Argument function_arg_commalist2 string_function_1Argument string_function_2Argument
+%type <pParseNode> date_function_0Argument date_function_1Argument function_name12 function_name23 function_name1 function_name2 function_name3 function_name0 numeric_function_0Argument numeric_function_1Argument numeric_function_2Argument date_function_3Argument
+%type <pParseNode> all query_primary sql_not for_length upper_lower comparison column_val cross_union /*opt_schema_element_list*/
+%type <pParseNode> /*op_authorization op_schema*/ nil_fkt schema_element base_table_def base_table_element base_table_element_commalist
+%type <pParseNode> column_def odbc_fct_spec odbc_call_spec odbc_fct_type op_parameter union_statement
+%type <pParseNode> op_odbc_call_parameter odbc_parameter_commalist odbc_parameter function_args_commalist function_arg
+%type <pParseNode> catalog_name schema_name table_node numeric_function string_function function_name date_function table_primary_as_range_column opt_as
+%type <pParseNode> ordered_set_function inverse_distribution_function hypothetical_set_function hypothetical_set_function_value_expression_list rank_function_type within_group_specification inverse_distribution_function_type array_aggregate_function inverse_distribution_function_argument
+%type <pParseNode> case_expression else_clause result_expression result case_abbreviation case_specification searched_when_clause simple_when_clause searched_case simple_case
+%type <pParseNode> when_operand_list when_operand case_operand
+%type <pParseNode> trigger_definition trigger_name trigger_action_time trigger_event transition_table_or_variable_list triggered_action trigger_column_list triggered_when_clause triggered_SQL_statement SQL_procedure_statement old_transition_variable_name new_transition_variable_name
+%type <pParseNode> op_referencing op_trigger_columnlist op_triggered_action_for opt_row trigger_for SQL_procedure_statement_list transition_table_or_variable old_transition_table_name new_transition_table_name transition_table_name
+%type <pParseNode> searched_when_clause_list simple_when_clause_list predefined_type opt_char_set_spec opt_collate_clause character_string_type national_character_string_type
+%type <pParseNode> binary_string_type numeric_type boolean_type datetime_type interval_type opt_paren_precision paren_char_length opt_paren_char_large_length paren_character_large_object_length
+%type <pParseNode> large_object_length opt_multiplier character_large_object_type national_character_large_object_type binary_large_object_string_type opt_with_or_without_time_zone
+%type <pParseNode> approximate_numeric_type exact_numeric_type opt_paren_precision_scale
+%%
+
+/* Parse Tree an OSQLParser zurueckliefern
+ * (der Zugriff ueber yyval nach Aufruf des Parsers scheitert,
+ *
+ */
+sql_single_statement:
+ sql
+ { xxx_pGLOBAL_SQLPARSER->setParseTree( $1 ); }
+ | sql ';'
+ { xxx_pGLOBAL_SQLPARSER->setParseTree( $1 ); }
+ ;
+
+ /* schema definition language */
+ /* Note: other ``sql:sal_Unicode() rules appear later in the grammar */
+
+sql:
+ manipulative_statement
+ | schema_element
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ ;
+
+/***
+
+op_authorization:
+ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_AUTHORIZATION user
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+op_schema:
+ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_NAME
+ | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ }
+ ;
+
+schema:
+ SQL_TOKEN_CREATE SQL_TOKEN_SCHEMA op_schema op_authorization opt_schema_element_list
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ }
+ ;
+
+opt_schema_element_list:
+ {$$ = SQL_NEW_RULE;}
+ | schema_glement_list
+ ;
+
+schema_element_list:
+ schema_element
+ {$$ = SQL_NEW_LISTRULE;
+ $$->append($1);}
+ | schema_element_list schema_element
+ {$1->append($2);
+ $$ = $1;}
+ ;
+*/
+
+schema_element:
+ base_table_def
+ | view_def
+ | privilege_def
+ | trigger_definition
+ ;
+
+base_table_def:
+ SQL_TOKEN_CREATE SQL_TOKEN_TABLE table_node '(' base_table_element_commalist ')'
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($5);
+ $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));}
+ ;
+
+base_table_element_commalist:
+ base_table_element
+ {$$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);}
+ | base_table_element_commalist ',' base_table_element
+ {$1->append($3);
+ $$ = $1;}
+ ;
+
+base_table_element:
+ column_def
+ | table_constraint_def
+ ;
+
+column_def:
+ column data_type column_def_opt_list
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ ;
+
+column_def_opt_list:
+ /* empty */ {$$ = SQL_NEW_LISTRULE;}
+ | column_def_opt_list column_def_opt
+ {$1->append($2);
+ $$ = $1;}
+ ;
+
+nil_fkt:
+ datetime_value_fct
+ ;
+unique_spec:
+ SQL_TOKEN_UNIQUE
+ | SQL_TOKEN_PRIMARY SQL_TOKEN_KEY
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+column_def_opt:
+ SQL_TOKEN_NOT SQL_TOKEN_NULL
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+ | unique_spec
+ | SQL_TOKEN_DEFAULT literal
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+ | SQL_TOKEN_DEFAULT SQL_TOKEN_NULL
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+ | SQL_TOKEN_DEFAULT SQL_TOKEN_USER
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+ | SQL_TOKEN_DEFAULT nil_fkt
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ | SQL_TOKEN_CHECK
+ | SQL_TOKEN_CHECK '(' search_condition ')'
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));}
+ | SQL_TOKEN_REFERENCES table_node
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+ | SQL_TOKEN_REFERENCES table_node '(' column_commalist ')'
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($4);
+ $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));}
+ ;
+
+table_constraint_def:
+ unique_spec '(' column_commalist ')'
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));}
+ | SQL_TOKEN_FOREIGN SQL_TOKEN_KEY '(' column_commalist ')' SQL_TOKEN_REFERENCES table_node
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($4);
+ $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
+ $$->append($6);
+ $$->append($7);}
+ | SQL_TOKEN_FOREIGN SQL_TOKEN_KEY '(' column_commalist ')' SQL_TOKEN_REFERENCES table_node '(' column_commalist ')'
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($4);
+ $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
+ $$->append($6);
+ $$->append($7);
+ $$->append($8 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($9);
+ $$->append($10 = newNode(")", SQL_NODE_PUNCTUATION));}
+ | SQL_TOKEN_CHECK '(' search_condition ')'
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));}
+ ;
+op_column_commalist:
+ /* empty */ {$$ = SQL_NEW_RULE;}
+ | '(' column_commalist ')'
+ {$$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+column_commalist:
+ column_commalist ',' column
+ {$1->append($3);
+ $$ = $1;}
+ | column
+ {$$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);}
+ ;
+
+view_def:
+ SQL_TOKEN_CREATE SQL_TOKEN_VIEW table_node opt_column_commalist SQL_TOKEN_AS select_statement opt_with_check_option
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ $$->append($6);
+ $$->append($7);}
+ ;
+
+opt_with_check_option:
+ /* empty */ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_WITH SQL_TOKEN_CHECK SQL_TOKEN_OPTION
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);}
+ ;
+
+opt_column_commalist:
+ /* empty */ {$$ = SQL_NEW_RULE;}
+ | '(' column_commalist ')'
+ {$$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));}
+ ;
+
+privilege_def:
+ SQL_TOKEN_GRANT privileges SQL_TOKEN_ON table_node SQL_TOKEN_TO grantee_commalist
+ opt_with_grant_option
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ $$->append($6);
+ $$->append($7);}
+ ;
+
+opt_with_grant_option:
+ /* empty */ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_WITH SQL_TOKEN_GRANT SQL_TOKEN_OPTION
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);}
+ ;
+
+privileges:
+ SQL_TOKEN_ALL SQL_TOKEN_PRIVILEGES
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+ | operation_commalist
+ ;
+
+operation_commalist:
+ operation
+ {$$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);}
+ | operation_commalist ',' operation
+ {$1->append($3);
+ $$ = $1;}
+ ;
+
+operation:
+ SQL_TOKEN_SELECT
+ | SQL_TOKEN_INSERT opt_column_commalist
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+ | SQL_TOKEN_DELETE
+ | SQL_TOKEN_UPDATE opt_column_commalist
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+ | SQL_TOKEN_REFERENCES opt_column_commalist
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+ | SQL_TOKEN_USAGE
+ ;
+
+
+grantee_commalist:
+ grantee
+ {$$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);}
+ | grantee_commalist ',' grantee
+ {$1->append($3);
+ $$ = $1;}
+ ;
+
+grantee:
+ SQL_TOKEN_PUBLIC
+ | user
+ ;
+
+ /* module language */
+
+opt_order_by_clause:
+ /* empty */ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_ORDER SQL_TOKEN_BY ordering_spec_commalist
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);}
+ ;
+
+ordering_spec_commalist:
+ ordering_spec
+ {$$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);}
+ | ordering_spec_commalist ',' ordering_spec
+ {$1->append($3);
+ $$ = $1;}
+ ;
+
+ordering_spec:
+/* SQL_TOKEN_INTNUM opt_asc_desc
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+*/
+ predicate opt_asc_desc
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+
+ | row_value_constructor_elem opt_asc_desc
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+ ;
+
+opt_asc_desc:
+ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_ASC
+ | SQL_TOKEN_DESC
+ ;
+
+
+/***
+manipulative_statement_list:
+ manipulative_statement
+ {$$ = SQL_NEW_LISTRULE;
+ $$->append($1);}
+ | manipulative_statement_list manipulative_statement
+ {$1->append($2);
+ $$ = $1;}
+ ;
+***/
+
+sql_not:
+ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_NOT
+ ;
+
+/* manipulative statements */
+
+manipulative_statement:
+ commit_statement
+/* | delete_statement_positioned*/
+ | delete_statement_searched
+ | fetch_statement
+ | insert_statement
+ | rollback_statement
+ | select_statement_into
+/* | update_statement_positioned*/
+ | update_statement_searched
+ | union_statement
+ | '{' odbc_call_spec '}'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("{", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode("}", SQL_NODE_PUNCTUATION));
+ }
+ ;
+
+union_statement:
+ select_statement
+ | union_statement SQL_TOKEN_UNION all select_statement
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ ;
+commit_statement:
+ SQL_TOKEN_COMMIT SQL_TOKEN_WORK
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+ ;
+/*
+delete_statement_positioned:
+ SQL_TOKEN_DELETE SQL_TOKEN_FROM table_node SQL_TOKEN_WHERE SQL_TOKEN_CURRENT SQL_TOKEN_OF cursor
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ $$->append($6);
+ $$->append($7);}
+ ;
+*/
+delete_statement_searched:
+ SQL_TOKEN_DELETE SQL_TOKEN_FROM table_node opt_where_clause
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);}
+ ;
+
+fetch_statement:
+ SQL_TOKEN_FETCH cursor SQL_TOKEN_INTO target_commalist
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);}
+ ;
+
+insert_statement:
+ SQL_TOKEN_INSERT SQL_TOKEN_INTO table_node opt_column_commalist values_or_query_spec
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);}
+ ;
+values_or_query_spec:
+ SQL_TOKEN_VALUES '(' table_value_const_list ')'
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+
+table_value_const_list:
+ row_value_constructor
+ {$$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);}
+ | table_value_const_list ',' row_value_constructor
+ {$1->append($3);
+ $$ = $1;}
+ ;
+row_value_const_list:
+ row_value_constructor_elem
+ {$$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);}
+ | row_value_const_list ',' row_value_constructor_elem
+ {$1->append($3);
+ $$ = $1;}
+ ;
+row_value_constructor:
+ row_value_constructor_elem
+/* | '(' row_value_const_list ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ */
+ ;
+row_value_constructor_elem:
+ value_exp /*[^')']*/
+ | SQL_TOKEN_DEFAULT
+ ;
+
+
+rollback_statement:
+ SQL_TOKEN_ROLLBACK SQL_TOKEN_WORK
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+ ;
+
+
+ /* INTO target_commalist herausgenommen */
+select_statement_into:
+ SQL_TOKEN_SELECT opt_all_distinct selection SQL_TOKEN_INTO target_commalist table_exp
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ $$->append($6); }
+ ;
+
+opt_all_distinct:
+ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_ALL
+ | SQL_TOKEN_DISTINCT
+
+ ;
+/*
+update_statement_positioned:
+ SQL_TOKEN_UPDATE table_node SQL_TOKEN_SET assignment_commalist
+ SQL_TOKEN_WHERE SQL_TOKEN_CURRENT SQL_TOKEN_OF cursor
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ $$->append($6);
+ $$->append($7);
+ $$->append($8);}
+ ;
+*/
+assignment_commalist:
+ assignment
+ {$$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);}
+ | assignment_commalist ',' assignment
+ {$1->append($3);
+ $$ = $1;}
+ ;
+
+assignment:
+ column SQL_EQUAL update_source
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);}
+ ;
+update_source:
+ value_exp
+ | SQL_TOKEN_DEFAULT
+ ;
+update_statement_searched:
+ SQL_TOKEN_UPDATE table_node SQL_TOKEN_SET assignment_commalist opt_where_clause
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);}
+ ;
+
+target_commalist:
+ target
+ {$$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);}
+ | target_commalist ',' target
+ {$1->append($3);
+ $$ = $1;}
+ ;
+
+target:
+ parameter_ref
+ ;
+
+opt_where_clause:
+ /* empty */ {$$ = SQL_NEW_RULE;}
+ | where_clause
+ ;
+
+ /* query expressions */
+
+query_term:
+ non_join_query_term
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ ;
+/* SELECT STATEMENT */
+select_statement:
+ SQL_TOKEN_SELECT opt_all_distinct selection table_exp
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ ;
+
+selection:
+ '*'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("*", SQL_NODE_PUNCTUATION));
+ }
+ | scalar_exp_commalist
+ ;
+
+table_exp:
+ from_clause
+ opt_where_clause
+ opt_group_by_clause
+ opt_having_clause
+ opt_order_by_clause
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);}
+ ;
+
+from_clause:
+ SQL_TOKEN_FROM table_ref_commalist
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+ ;
+
+table_ref_commalist:
+
+ table_ref
+ {$$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);}
+ | table_ref_commalist ',' table_ref
+ {$1->append($3);
+ $$ = $1;}
+ ;
+
+opt_as:
+ /* empty */ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_AS
+ ;
+opt_row:
+ /* empty */ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_ROW
+ ;
+table_primary_as_range_column:
+ {$$ = SQL_NEW_RULE;}
+ | opt_as SQL_TOKEN_NAME op_column_commalist
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ ;
+table_ref:
+ table_node table_primary_as_range_column
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ | subquery range_variable op_column_commalist
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ | joined_table
+ | '{' SQL_TOKEN_OJ joined_table '}'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("{", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3);
+ $$->append($4 = newNode("}", SQL_NODE_PUNCTUATION));
+ }
+ | '(' joined_table ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+where_clause:
+ SQL_TOKEN_WHERE search_condition
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+ ;
+
+opt_group_by_clause:
+ /* empty */ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_GROUP SQL_TOKEN_BY column_ref_commalist
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);}
+ ;
+
+column_ref_commalist:
+ column_ref
+ {$$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);}
+ | set_fct_spec
+ {$$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);}
+ | column_ref_commalist ',' column_ref
+ {$1->append($3);
+ $$ = $1;}
+ | column_ref_commalist ',' set_fct_spec
+ {$1->append($3);
+ $$ = $1;}
+ ;
+
+opt_having_clause:
+ /* empty */ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_HAVING search_condition
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+ ;
+
+ /* search conditions */
+truth_value:
+ SQL_TOKEN_TRUE
+ | SQL_TOKEN_FALSE
+ | SQL_TOKEN_UNKNOWN
+ | SQL_TOKEN_NULL
+ ;
+boolean_primary:
+ predicate
+ | '(' search_condition ')'
+ { // boolean_primary: rule 2
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | row_value_constructor_elem /*[^')' ',']*/
+ {
+ if(xxx_pGLOBAL_SQLPARSER->inPredicateCheck())// boolean_primary: rule 3
+ {
+ $$ = SQL_NEW_RULE;
+ sal_Int16 nErg = xxx_pGLOBAL_SQLPARSER->buildComparsionRule($$,$1);
+ if(nErg == 1)
+ {
+ OSQLParseNode* pTemp = $$;
+ $$ = pTemp->removeAt((sal_uInt32)0);
+ delete pTemp;
+ }
+ else
+ {
+ delete $$;
+ if(nErg)
+ YYERROR;
+ else
+ YYABORT;
+ }
+ }
+ else
+ YYERROR;
+ }
+ ;
+parenthesized_boolean_value_expression:
+ '(' search_condition ')'
+ { // boolean_primary: rule 2
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+boolean_test:
+ boolean_primary
+ | boolean_primary SQL_TOKEN_IS sql_not truth_value
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ ;
+boolean_factor:
+ boolean_test
+ | SQL_TOKEN_NOT boolean_test
+ { // boolean_factor: rule 1
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+boolean_term:
+ boolean_factor
+ | boolean_term SQL_TOKEN_AND boolean_factor
+ {
+ $$ = SQL_NEW_RULE; // boolean_term: rule 1
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ ;
+search_condition:
+ boolean_term
+ | search_condition SQL_TOKEN_OR boolean_term
+ {
+ $$ = SQL_NEW_RULE; // search_condition
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ ;
+predicate:
+ comparison_predicate
+ | between_predicate
+ | all_or_any_predicate
+ | existence_test
+ | unique_test
+ | test_for_null
+ | in_predicate
+ | like_predicate
+ ;
+comparison_predicate_part_2:
+ comparison row_value_constructor
+ {
+ $$ = SQL_NEW_RULE; // comparison_predicate: rule 1
+ $$->append($1);
+ $$->append($2);
+ }
+comparison_predicate:
+ row_value_constructor comparison row_value_constructor
+ {
+ $$ = SQL_NEW_RULE; // comparison_predicate: rule 1
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ | comparison row_value_constructor
+ {
+ if(xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) // comparison_predicate: rule 2
+ {
+ $$ = SQL_NEW_RULE;
+ sal_Int16 nErg = xxx_pGLOBAL_SQLPARSER->buildPredicateRule($$,$2,$1);
+ if(nErg == 1)
+ {
+ OSQLParseNode* pTemp = $$;
+ $$ = pTemp->removeAt((sal_uInt32)0);
+ delete pTemp;
+ }
+ else
+ {
+ delete $$;
+ YYABORT;
+ }
+ }
+ else
+ {
+ YYERROR;
+ }
+ }
+ ;
+comparison:
+ SQL_LESS
+ | SQL_NOTEQUAL
+ | SQL_EQUAL
+ | SQL_GREAT
+ | SQL_LESSEQ
+ | SQL_GREATEQ
+ ;
+between_predicate_part_2:
+ sql_not SQL_TOKEN_BETWEEN row_value_constructor SQL_TOKEN_AND row_value_constructor
+ {
+ if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) // between_predicate: rule 2
+ {
+ $$ = SQL_NEW_RULE;
+
+ sal_Int16 nErg = xxx_pGLOBAL_SQLPARSER->buildPredicateRule($$,$3,$2,$5);
+ if(nErg == 1)
+ {
+ OSQLParseNode* pTemp = $$;
+ $$ = pTemp->removeAt((sal_uInt32)0);
+ OSQLParseNode* pColumnRef = $$->removeAt((sal_uInt32)0);
+ $$->insert(0,$1);
+ OSQLParseNode* pBetween_predicate = new OSQLInternalNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::between_predicate));
+ pBetween_predicate->append(pColumnRef);
+ pBetween_predicate->append($$);
+ $$ = pBetween_predicate;
+
+ delete pTemp;
+ delete $4;
+ }
+ else
+ {
+ delete $$;
+ YYABORT;
+ }
+ }
+ else
+ {
+ $$ = SQL_NEW_RULE; // between_predicate: rule 1
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ }
+ }
+between_predicate:
+ row_value_constructor between_predicate_part_2
+ {
+ $$ = SQL_NEW_RULE; // between_predicate: rule 1
+ $$->append($1);
+ $$->append($2);
+ }
+ | between_predicate_part_2
+ ;
+character_like_predicate_part_2:
+ sql_not SQL_TOKEN_LIKE string_value_exp opt_escape
+ {
+ $$ = SQL_NEW_RULE; // like_predicate: rule 1
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ ;
+other_like_predicate_part_2:
+ sql_not SQL_TOKEN_LIKE value_exp_primary opt_escape
+ {
+ $$ = SQL_NEW_RULE; // like_predicate: rule 1
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ ;
+like_predicate:
+ row_value_constructor character_like_predicate_part_2
+ {
+ $$ = SQL_NEW_RULE; // like_predicate: rule 1
+ $$->append($1);
+ $$->append($2);
+ }
+ | row_value_constructor other_like_predicate_part_2
+ {
+ $$ = SQL_NEW_RULE; // like_predicate: rule 3
+ $$->append($1);
+ $$->append($2);
+ }
+ | character_like_predicate_part_2
+ {
+ if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) // like_predicate: rule 5
+ {
+ OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref));
+ pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME));
+
+ $$ = SQL_NEW_RULE;
+ $$->append(pColumnRef);
+ $$->append($1);
+ OSQLParseNode* p2nd = $1->removeAt(2);
+ OSQLParseNode* p3rd = $1->removeAt(2);
+ if ( !xxx_pGLOBAL_SQLPARSER->buildLikeRule($1,p2nd,p3rd) )
+ {
+ delete $$;
+ YYABORT;
+ }
+ $1->append(p3rd);
+ }
+ else
+ YYERROR;
+ }
+ | other_like_predicate_part_2
+ {
+ if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) // like_predicate: rule 6
+ {
+ OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref));
+ pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME));
+
+ $$ = SQL_NEW_RULE;
+ $$->append(pColumnRef);
+ $$->append($1);
+ OSQLParseNode* p2nd = $1->removeAt(2);
+ OSQLParseNode* p3rd = $1->removeAt(2);
+ if ( !xxx_pGLOBAL_SQLPARSER->buildLikeRule($1,p2nd,p3rd) )
+ {
+ delete $$;
+ YYABORT;
+ }
+ $1->append(p3rd);
+ }
+ else
+ YYERROR;
+ }
+ ;
+
+opt_escape:
+ /* empty */ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_ESCAPE string_value_exp
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+ | '{' SQL_TOKEN_ESCAPE SQL_TOKEN_STRING '}'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("{", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3);
+ $$->append($4 = newNode("}", SQL_NODE_PUNCTUATION));
+ }
+ ;
+
+null_predicate_part_2:
+ SQL_TOKEN_IS sql_not SQL_TOKEN_NULL
+ {
+ $$ = SQL_NEW_RULE; // test_for_null: rule 1
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ ;
+test_for_null:
+ row_value_constructor null_predicate_part_2
+ {
+ $$ = SQL_NEW_RULE; // test_for_null: rule 1
+ $$->append($1);
+ $$->append($2);
+ }
+ | null_predicate_part_2
+ {
+ if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())// test_for_null: rule 2
+ {
+ OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref));
+ pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME));
+
+ $$ = SQL_NEW_RULE;
+ $$->append(pColumnRef);
+ $$->append($1);
+ }
+ else
+ YYERROR;
+ }
+ ;
+in_predicate_value:
+ subquery
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ | '(' value_exp_commalist ')'
+ {$$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+in_predicate_part_2:
+ sql_not SQL_TOKEN_IN in_predicate_value
+ {
+ $$ = SQL_NEW_RULE;// in_predicate: rule 1
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ ;
+in_predicate:
+ row_value_constructor in_predicate_part_2
+ {
+ $$ = SQL_NEW_RULE;// in_predicate: rule 1
+ $$->append($1);
+ $$->append($2);
+ }
+ | in_predicate_part_2
+ {
+ if ( xxx_pGLOBAL_SQLPARSER->inPredicateCheck() )// in_predicate: rule 2
+ {
+ OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref));
+ pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME));
+
+ $$ = SQL_NEW_RULE;
+ $$->append(pColumnRef);
+ $$->append($1);
+ }
+ else
+ YYERROR;
+ }
+ ;
+quantified_comparison_predicate_part_2:
+ comparison any_all_some subquery
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ ;
+all_or_any_predicate:
+ row_value_constructor quantified_comparison_predicate_part_2
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ | quantified_comparison_predicate_part_2
+ {
+ if(xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
+ {
+ OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref));
+ pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME));
+
+ $$ = SQL_NEW_RULE;
+ $$->append(pColumnRef);
+ $$->append($1);
+ }
+ else
+ YYERROR;
+ }
+ ;
+
+any_all_some:
+ SQL_TOKEN_ANY
+ | SQL_TOKEN_ALL
+ | SQL_TOKEN_SOME
+ ;
+
+existence_test:
+ SQL_TOKEN_EXISTS subquery
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+ ;
+unique_test:
+ SQL_TOKEN_UNIQUE subquery
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);}
+ ;
+subquery:
+ '(' query_exp ')'
+ {$$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));}
+ ;
+
+ /* scalar expressions */
+scalar_exp_commalist:
+ select_sublist
+ {
+ $$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);
+ }
+ | scalar_exp_commalist ',' select_sublist
+ {
+ $1->append($3);
+ $$ = $1;
+ }
+ ;
+select_sublist:
+/* table_node '.' '*'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
+ $$->append($3 = newNode("*", SQL_NODE_PUNCTUATION));
+ }
+*/
+ derived_column
+
+ ;
+
+parameter_ref:
+ parameter
+ ;
+
+/*
+op_like:
+ '*'
+ {
+ $$ = newNode("*", SQL_NODE_PUNCTUATION);
+ }
+ | '?'
+ {
+ $$ = newNode("?", SQL_NODE_PUNCTUATION);
+ }
+ | op_like '*'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("*", SQL_NODE_PUNCTUATION));
+ xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_False);
+ }
+ | op_like '?'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("?", SQL_NODE_PUNCTUATION));
+ xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_False);
+ }
+ ;
+*/
+
+literal:
+/* SQL_TOKEN_STRING
+ | */SQL_TOKEN_INT
+ | SQL_TOKEN_REAL_NUM
+ | SQL_TOKEN_INTNUM
+ | SQL_TOKEN_APPROXNUM
+ | SQL_TOKEN_ACCESS_DATE
+/* rules for predicate check */
+ | literal SQL_TOKEN_STRING
+ {
+ if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_True);
+ }
+ else
+ YYERROR;
+ }
+ | literal SQL_TOKEN_INT
+ {
+ if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_True);
+ }
+ else
+ YYERROR;
+ }
+ | literal SQL_TOKEN_REAL_NUM
+ {
+ if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_True);
+ }
+ else
+ YYERROR;
+ }
+ | literal SQL_TOKEN_APPROXNUM
+ {
+ if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_True);
+ }
+ else
+ YYERROR;
+ }
+ ;
+
+ /* miscellaneous */
+as_clause:
+ /* empty */ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_AS column
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ | column
+ ;
+position_exp:
+ SQL_TOKEN_POSITION '(' value_exp SQL_TOKEN_IN value_exp ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | SQL_TOKEN_POSITION '(' value_exp_commalist ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+num_value_fct:
+ position_exp
+ | extract_exp
+ | length_exp
+ ;
+char_length_exp:
+ SQL_TOKEN_CHAR_LENGTH '(' value_exp ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | SQL_TOKEN_SQL_TOKEN_INTNUM '(' value_exp ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+
+ ;
+octet_length_exp:
+ SQL_TOKEN_OCTET_LENGTH '(' value_exp ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+bit_length_exp:
+ SQL_TOKEN_BIT_LENGTH '(' value_exp ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+length_exp:
+ char_length_exp
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ | octet_length_exp
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ | bit_length_exp
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ ;
+datetime_field:
+ non_second_datetime_field
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ | SQL_TOKEN_SECOND
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ ;
+extract_field:
+ time_zone_field
+ | datetime_field
+ | value_exp
+ ;
+time_zone_field:
+ SQL_TOKEN_TIMEZONE_HOUR
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ | SQL_TOKEN_TIMEZONE_MINUTE
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ ;
+extract_source:
+ datetime_value_exp
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+/* | interval_value_exp
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ } */
+ ;
+extract_exp:
+ SQL_TOKEN_EXTRACT '(' extract_field SQL_TOKEN_FROM value_exp ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+unsigned_value_spec:
+ general_value_spec
+ | literal
+ ;
+general_value_spec:
+ parameter
+ | SQL_TOKEN_USER
+ /* | SQL_TOKEN_NULL*/
+ | SQL_TOKEN_FALSE
+ | SQL_TOKEN_TRUE
+ | SQL_TOKEN_VALUE
+ | SQL_TOKEN_CURRENT_CATALOG
+ | SQL_TOKEN_CURRENT_DEFAULT_TRANSFORM_GROUP
+ | SQL_TOKEN_CURRENT_PATH
+ | SQL_TOKEN_CURRENT_ROLE
+ | SQL_TOKEN_CURRENT_SCHEMA
+ | SQL_TOKEN_CURRENT_USER
+ | SQL_TOKEN_SESSION_USER
+ | SQL_TOKEN_SYSTEM_USER
+ ;
+set_fct_spec:
+ general_set_fct
+ | '{' odbc_fct_spec '}'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("{", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode("}", SQL_NODE_PUNCTUATION));
+ }
+ | function_name '(' ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | function_name0 '(' ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | function_name1 '(' function_arg ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | function_name2 '(' function_arg_commalist2 ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | function_name3 '(' function_arg_commalist3 ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | string_function_4Argument '(' function_arg_commalist4 ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | function_name '(' function_args_commalist ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | function_name12 '(' function_args_commalist ')'
+ {
+ if ( $3->count() == 1 || $3->count() == 2 )
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ else
+ YYERROR;
+ }
+ | function_name23 '(' function_args_commalist ')'
+ {
+ if ( $3->count() == 2 || $3->count() == 3)
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ else
+ YYERROR;
+ }
+ ;
+function_name0:
+ date_function_0Argument
+ | numeric_function_0Argument
+ ;
+function_name1:
+ string_function_1Argument
+ | date_function_1Argument
+ | numeric_function_1Argument
+ ;
+function_name2:
+ string_function_2Argument
+ | numeric_function_2Argument
+ ;
+function_name12:
+ SQL_TOKEN_ROUND
+ | SQL_TOKEN_WEEK
+ | SQL_TOKEN_LOGF
+ | SQL_TOKEN_LOG
+ ;
+function_name23:
+ SQL_TOKEN_LOCATE
+ ;
+function_name3:
+ string_function_3Argument
+ | date_function_3Argument
+ ;
+function_name:
+ string_function
+ | date_function
+ | numeric_function
+ | SQL_TOKEN_NAME
+ ;
+string_function_1Argument:
+ SQL_TOKEN_LENGTH
+ | SQL_TOKEN_ASCII
+ | SQL_TOKEN_LCASE
+ | SQL_TOKEN_LTRIM
+ | SQL_TOKEN_RTRIM
+ | SQL_TOKEN_SPACE
+ | SQL_TOKEN_UCASE
+ ;
+
+string_function_2Argument:
+ SQL_TOKEN_REPEAT
+ | SQL_TOKEN_LEFT
+ | SQL_TOKEN_RIGHT
+ ;
+string_function_3Argument:
+ SQL_TOKEN_REPLACE
+ ;
+string_function_4Argument:
+ SQL_TOKEN_INSERT
+ ;
+
+string_function:
+ SQL_TOKEN_CHAR
+ | SQL_TOKEN_CONCAT
+ | SQL_TOKEN_DIFFERENCE
+ | SQL_TOKEN_LOCATE_2
+ | SQL_TOKEN_SOUNDEX
+ ;
+date_function_0Argument:
+ SQL_TOKEN_CURDATE
+ | SQL_TOKEN_CURTIME
+ | SQL_TOKEN_NOW
+ ;
+date_function_1Argument:
+ SQL_TOKEN_DAYOFWEEK
+ | SQL_TOKEN_DAYOFMONTH
+ | SQL_TOKEN_DAYOFYEAR
+ | SQL_TOKEN_MONTH
+ | SQL_TOKEN_DAYNAME
+ | SQL_TOKEN_MONTHNAME
+ | SQL_TOKEN_QUARTER
+ | SQL_TOKEN_HOUR
+ | SQL_TOKEN_MINUTE
+ | SQL_TOKEN_SECOND
+ | SQL_TOKEN_YEAR
+ | SQL_TOKEN_DAY
+ | SQL_TOKEN_TIMEVALUE
+ | SQL_TOKEN_DATEVALUE
+ ;
+date_function_3Argument:
+ SQL_TOKEN_DATEDIFF
+
+date_function:
+ SQL_TOKEN_TIMESTAMPADD
+ | SQL_TOKEN_TIMESTAMPDIFF
+ ;
+numeric_function_0Argument:
+ SQL_TOKEN_PI
+ ;
+numeric_function_1Argument:
+ SQL_TOKEN_ABS
+ | SQL_TOKEN_ACOS
+ | SQL_TOKEN_ASIN
+ | SQL_TOKEN_ATAN
+ | SQL_TOKEN_CEILING
+ | SQL_TOKEN_COS
+ | SQL_TOKEN_COT
+ | SQL_TOKEN_DEGREES
+ | SQL_TOKEN_FLOOR
+ | SQL_TOKEN_SIGN
+ | SQL_TOKEN_SIN
+ | SQL_TOKEN_SQRT
+ | SQL_TOKEN_TAN
+ | SQL_TOKEN_EXP
+ | SQL_TOKEN_LOG10
+ | SQL_TOKEN_LN
+ | SQL_TOKEN_RADIANS
+ | SQL_TOKEN_ROUNDMAGIC
+ ;
+numeric_function_2Argument:
+ SQL_TOKEN_ATAN2
+ | SQL_TOKEN_MOD
+ | SQL_TOKEN_POWER
+ ;
+numeric_function:
+ SQL_TOKEN_RAND
+ | SQL_TOKEN_TRUNCATE
+ ;
+op_parameter:
+ {$$ = SQL_NEW_RULE;}
+ | '?' SQL_EQUAL
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("?", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ }
+ ;
+odbc_call_spec:
+ op_parameter SQL_TOKEN_CALL table_node op_odbc_call_parameter
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ ;
+
+op_odbc_call_parameter:
+ {$$ = SQL_NEW_RULE;}
+ | '(' odbc_parameter_commalist ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+
+odbc_parameter_commalist:
+ odbc_parameter
+ {$$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);}
+ | odbc_parameter_commalist ',' odbc_parameter
+ {
+ $1->append($3);
+ $$ = $1;
+ }
+ ;
+odbc_parameter:
+ /* empty */ {$$ = SQL_NEW_RULE;}
+ | literal
+ | parameter
+ ;
+
+odbc_fct_spec:
+ odbc_fct_type SQL_TOKEN_STRING
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+
+odbc_fct_type:
+ SQL_TOKEN_FN
+ | SQL_TOKEN_D
+ | SQL_TOKEN_T
+ | SQL_TOKEN_TS
+ ;
+
+general_set_fct:
+ set_fct_type '(' opt_all_distinct function_arg ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4);
+ $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | SQL_TOKEN_COUNT '(' '*' ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3 = newNode("*", SQL_NODE_PUNCTUATION));
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | SQL_TOKEN_COUNT '(' opt_all_distinct function_arg ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4);
+ $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | ordered_set_function
+ | array_aggregate_function
+ ;
+set_fct_type:
+ SQL_TOKEN_AVG
+ | SQL_TOKEN_MAX
+ | SQL_TOKEN_MIN
+ | SQL_TOKEN_SUM
+ | SQL_TOKEN_EVERY
+ | SQL_TOKEN_ANY
+ | SQL_TOKEN_SOME
+ | SQL_TOKEN_STDDEV_POP
+ | SQL_TOKEN_STDDEV_SAMP
+ | SQL_TOKEN_VAR_SAMP
+ | SQL_TOKEN_VAR_POP
+ | SQL_TOKEN_COLLECT
+ | SQL_TOKEN_FUSION
+ | SQL_TOKEN_INTERSECTION
+ ;
+
+ordered_set_function:
+ hypothetical_set_function
+ | inverse_distribution_function
+ ;
+hypothetical_set_function:
+ rank_function_type '(' hypothetical_set_function_value_expression_list ')' within_group_specification
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ $$->append($5);
+ }
+ | rank_function_type '(' hypothetical_set_function_value_expression_list SQL_TOKEN_BY value_exp_commalist ')' within_group_specification
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
+ $$->append($7);
+ }
+ ;
+
+within_group_specification:
+ {
+ $$ = SQL_NEW_RULE;
+ }
+ | SQL_TOKEN_WITHIN SQL_TOKEN_GROUP '(' opt_order_by_clause ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($4);
+ $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+hypothetical_set_function_value_expression_list:
+ value_exp_commalist
+ ;
+
+inverse_distribution_function:
+ inverse_distribution_function_type '('inverse_distribution_function_argument ')' within_group_specification
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+inverse_distribution_function_argument:
+ num_value_exp
+ ;
+inverse_distribution_function_type:
+ SQL_TOKEN_PERCENTILE_CONT
+ | SQL_TOKEN_PERCENTILE_DISC
+ ;
+
+array_aggregate_function:
+ SQL_TOKEN_ARRAY_AGG '(' value_exp opt_order_by_clause ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4);
+ $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+
+rank_function_type:
+ SQL_TOKEN_RANK
+ | SQL_TOKEN_DENSE_RANK
+ | SQL_TOKEN_PERCENT_RANK
+ | SQL_TOKEN_CUME_DIST
+ ;
+outer_join_type:
+ SQL_TOKEN_LEFT %prec SQL_TOKEN_LEFT
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ | SQL_TOKEN_RIGHT %prec SQL_TOKEN_RIGHT
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ | SQL_TOKEN_FULL %prec SQL_TOKEN_FULL
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ ;
+join_condition:
+ SQL_TOKEN_ON search_condition
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+join_spec:
+ join_condition
+ | named_columns_join
+ ;
+join_type:
+ /* empty */ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_INNER
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ | outer_join_type
+ | outer_join_type SQL_TOKEN_OUTER
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+cross_union:
+ table_ref SQL_TOKEN_CROSS SQL_TOKEN_JOIN table_ref
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ ;
+
+qualified_join:
+ /* wenn SQL_TOKEN_NATURAL, dann keine join_spec */
+ table_ref SQL_TOKEN_NATURAL join_type SQL_TOKEN_JOIN table_ref
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ }
+ | table_ref join_type SQL_TOKEN_JOIN table_ref join_spec
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ }
+ | cross_union
+ ;
+joined_table:
+ qualified_join
+ ;
+named_columns_join:
+ SQL_TOKEN_USING '(' column_commalist ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+simple_table:
+ select_statement
+ | values_or_query_spec
+ ;
+
+non_join_query_primary:
+ simple_table
+ | '(' non_join_query_exp ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+non_join_query_term:
+ non_join_query_primary
+ | query_term SQL_TOKEN_INTERSECT all query_primary
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ ;
+query_primary:
+ non_join_query_primary
+ ;
+non_join_query_exp:
+ non_join_query_term
+ | query_exp SQL_TOKEN_UNION all query_term
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ | query_exp SQL_TOKEN_EXCEPT all query_term
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ ;
+all:
+ /* empty*/ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_ALL
+ ;
+query_exp:
+ non_join_query_exp /*[^')']*/
+ ;
+scalar_subquery:
+ subquery
+ ;
+cast_operand:
+ value_exp
+ ;
+cast_target:
+ table_node
+ | data_type
+ ;
+cast_spec:
+ SQL_TOKEN_CAST '(' cast_operand SQL_TOKEN_AS cast_target ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+value_exp_primary:
+ unsigned_value_spec
+ | column_ref
+ | set_fct_spec
+ | scalar_subquery
+ | case_expression
+ | '(' value_exp ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | cast_spec
+ ;
+
+num_primary:
+ value_exp_primary
+ | num_value_fct
+ ;
+factor:
+ num_primary
+ | '-' num_primary %prec SQL_TOKEN_UMINUS
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("-", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ }
+ | '+' num_primary %prec SQL_TOKEN_UMINUS
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("+", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ }
+ ;
+
+term:
+ factor
+ | term '*' factor
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("*", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ }
+ | term '/' factor
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("/", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ }
+ ;
+
+num_value_exp:
+ term
+ | num_value_exp '+' term
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ }
+ | num_value_exp '-' term
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("-", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ }
+ ;
+datetime_primary:
+/* value_exp_primary
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ |*/ datetime_value_fct
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ ;
+datetime_value_fct:
+ SQL_TOKEN_CURRENT_DATE
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ | SQL_TOKEN_CURRENT_TIME
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ | SQL_TOKEN_CURRENT_TIMESTAMP
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ ;
+time_zone:
+ SQL_TOKEN_AT time_zone_specifier
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+time_zone_specifier:
+ SQL_TOKEN_LOCAL
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+/* | SQL_TOKEN_TIME SQL_TOKEN_ZONE interval_value_exp
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }*/
+ ;
+datetime_factor:
+ datetime_primary
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ | datetime_primary time_zone
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+datetime_term:
+ datetime_factor
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ ;
+/*
+interval_term:
+ literal
+ | interval_term '*' factor
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("*", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ }
+ | interval_term '/' factor
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("/", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ }
+ ;
+*/
+datetime_value_exp:
+ datetime_term
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+/* | interval_value_exp '+' datetime_term
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ }
+ | datetime_value_exp '+' interval_term
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ }
+ | datetime_value_exp '-' interval_term
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("-", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ }
+*/ ;
+/*
+interval_value_exp:
+ interval_term
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ | interval_value_exp '+' interval_term
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ }
+ | interval_value_exp '-' interval_term
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("-", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ }
+ | '(' datetime_value_exp '-' datetime_term ')' interval_qualifier
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode("-", SQL_NODE_PUNCTUATION));
+ $$->append($4);
+ $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
+ $$->append($6);
+ }
+ ;
+*/
+non_second_datetime_field:
+ SQL_TOKEN_YEAR
+ | SQL_TOKEN_MONTH
+ | SQL_TOKEN_DAY
+ | SQL_TOKEN_HOUR
+ | SQL_TOKEN_MINUTE
+ ;
+start_field:
+ non_second_datetime_field opt_paren_precision
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+end_field:
+ non_second_datetime_field
+ | SQL_TOKEN_SECOND opt_paren_precision
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+
+single_datetime_field:
+ non_second_datetime_field opt_paren_precision
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ | SQL_TOKEN_SECOND opt_paren_precision_scale
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+
+interval_qualifier:
+ start_field SQL_TOKEN_TO end_field
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ | single_datetime_field
+ ;
+
+function_arg_commalist2:
+ function_arg ',' function_arg
+ {$$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);
+ $$->append($3);}
+ ;
+function_arg_commalist3:
+ function_arg ',' function_arg ',' function_arg
+ {
+ $$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);
+ $$->append($3);
+ $$->append($5);
+ }
+ ;
+function_arg_commalist4:
+ function_arg ',' function_arg ',' function_arg ',' function_arg
+ {
+ $$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);
+ $$->append($3);
+ $$->append($5);
+ $$->append($7);
+ }
+ ;
+value_exp_commalist:
+ value_exp
+ {$$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);}
+ | value_exp_commalist ',' value_exp
+ {$1->append($3);
+ $$ = $1;}
+ /* this rule is only valid if we check predicates */
+ | value_exp_commalist ';' value_exp
+ {
+ if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
+ {
+ $1->append($3);
+ $$ = $1;
+ }
+ else
+ YYERROR;
+ }
+ ;
+function_arg:
+ value_exp
+ | value_exp comparison value_exp
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ | value_exp SQL_TOKEN_USING value_exp comparison value_exp
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ | value_exp SQL_TOKEN_BY value_exp_commalist
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ ;
+function_args_commalist:
+ function_arg
+ {$$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);}
+ | function_args_commalist ',' function_arg
+ {$1->append($3);
+ $$ = $1;}
+ /* this rule is only valid if we check predicates */
+ | function_args_commalist ';' function_arg
+ {
+ if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
+ {
+ $1->append($3);
+ $$ = $1;
+ }
+ else
+ YYERROR;
+ }
+ ;
+
+value_exp:
+ num_value_exp /*[^')']*/
+ | string_value_exp
+ | datetime_value_exp
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ ;
+string_value_exp:
+ char_value_exp
+/* | bit_value_exp
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+*/ ;
+char_value_exp:
+ char_factor
+ | concatenation
+ ;
+concatenation:
+ char_value_exp '+' char_factor
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ }
+ | value_exp SQL_CONCAT value_exp
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ ;
+
+char_primary:
+ SQL_TOKEN_STRING
+ | string_value_fct
+ ;
+collate_clause:
+ SQL_TOKEN_COLLATE table_node
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+char_factor:
+ char_primary
+ | char_primary collate_clause
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+string_value_fct:
+ char_value_fct
+ | bit_value_fct
+ ;
+bit_value_fct:
+ bit_substring_fct
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ ;
+bit_substring_fct:
+ SQL_TOKEN_SUBSTRING '(' bit_value_exp SQL_TOKEN_FROM string_value_exp for_length ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ $$->append($6);
+ $$->append($7 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+bit_value_exp:
+ bit_factor
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ ;
+/*
+ bit_concatenation
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ |
+bit_concatenation:
+ bit_value_exp '+' bit_factor
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ }
+ ;
+*/
+bit_factor:
+ bit_primary
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ ;
+bit_primary:
+ {$$ = SQL_NEW_RULE;}
+/* value_exp_primary
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ | string_value_fct
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }*/
+ ;
+char_value_fct:
+ char_substring_fct
+ | fold
+ | form_conversion
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ | char_translation
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ | trim_fct
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ }
+ ;
+for_length:
+ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_FOR value_exp
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+char_substring_fct:
+ SQL_TOKEN_SUBSTRING '(' value_exp SQL_TOKEN_FROM value_exp for_length ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ $$->append($6);
+ $$->append($7 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | SQL_TOKEN_SUBSTRING '(' value_exp_commalist ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+upper_lower:
+ SQL_TOKEN_UPPER
+ | SQL_TOKEN_LOWER
+ ;
+fold:
+ upper_lower '(' value_exp ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+form_conversion:
+ SQL_TOKEN_CONVERT '(' string_value_exp SQL_TOKEN_USING table_node ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | SQL_TOKEN_CONVERT '(' cast_operand ',' cast_target ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($2 = newNode(",", SQL_NODE_PUNCTUATION));
+ $$->append($5);
+ $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+char_translation:
+ SQL_TOKEN_TRANSLATE '(' string_value_exp SQL_TOKEN_USING table_node ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ $$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+trim_fct:
+ SQL_TOKEN_TRIM '(' trim_operands ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+trim_operands:
+ trim_spec value_exp SQL_TOKEN_FROM value_exp
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ | trim_spec SQL_TOKEN_FROM value_exp
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ | value_exp SQL_TOKEN_FROM value_exp
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ | SQL_TOKEN_FROM value_exp
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ | value_exp
+ ;
+
+trim_spec:
+ SQL_TOKEN_BOTH
+ | SQL_TOKEN_LEADING
+ | SQL_TOKEN_TRAILING
+ ;
+
+derived_column:
+ value_exp as_clause
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+/* Tabellenname */
+table_node:
+ table_name
+ | schema_name
+ | catalog_name
+;
+catalog_name:
+ SQL_TOKEN_NAME '.' schema_name
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ }
+ | SQL_TOKEN_NAME ':' schema_name
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode(":", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ }
+;
+schema_name:
+ SQL_TOKEN_NAME '.' table_name
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ }
+;
+
+table_name:
+ SQL_TOKEN_NAME
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);}
+;
+/* Columns */
+column_ref:
+ column
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);}
+/* | table_node '.' column_val %prec '.'
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
+ $$->append($3);}
+*/
+ | SQL_TOKEN_NAME '.' column_val %prec '.'
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ }
+ | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val %prec '.'
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(".", SQL_NODE_PUNCTUATION));
+ $$->append($5);}
+ | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val %prec '.'
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2= newNode(".", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(".", SQL_NODE_PUNCTUATION));
+ $$->append($5);
+ $$->append($6 = newNode(".", SQL_NODE_PUNCTUATION));
+ $$->append($7);
+ }
+ | SQL_TOKEN_NAME ':' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val %prec '.'
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2= newNode(":", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(".", SQL_NODE_PUNCTUATION));
+ $$->append($5);
+ $$->append($6 = newNode(".", SQL_NODE_PUNCTUATION));
+ $$->append($7);
+ }
+/* | SQL_TOKEN_NAME ';' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2= newNode(";", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(".", SQL_NODE_PUNCTUATION));
+ $$->append($5);
+ $$->append($6 = newNode(".", SQL_NODE_PUNCTUATION));
+ $$->append($7);
+ }
+*/ ;
+
+ /* data types */
+column_val:
+ column
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);}
+ | '*'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("*", SQL_NODE_PUNCTUATION));
+ }
+ ;
+data_type:
+ predefined_type
+ ;
+opt_char_set_spec:
+ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_CHARACTER SQL_TOKEN_SET SQL_TOKEN_NAME
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ ;
+opt_collate_clause:
+ {$$ = SQL_NEW_RULE;}
+ | collate_clause
+ ;
+predefined_type:
+ character_string_type opt_char_set_spec opt_collate_clause
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ | national_character_string_type opt_collate_clause
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ | binary_string_type
+ | numeric_type
+ | boolean_type
+ | datetime_type
+ | interval_type
+ ;
+character_string_type:
+ SQL_TOKEN_CHARACTER opt_paren_precision
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ | SQL_TOKEN_CHAR opt_paren_precision
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ | SQL_TOKEN_CHARACTER SQL_TOKEN_VARYING paren_char_length
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ | SQL_TOKEN_CHAR SQL_TOKEN_VARYING paren_char_length
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ | SQL_TOKEN_VARCHAR paren_char_length
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ | character_large_object_type
+ ;
+opt_paren_precision:
+ {$$ = SQL_NEW_RULE;}
+ | paren_char_length
+ ;
+paren_char_length:
+ '(' SQL_TOKEN_INTNUM ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+opt_paren_char_large_length:
+ {$$ = SQL_NEW_RULE;}
+ | paren_character_large_object_length
+ ;
+paren_character_large_object_length:
+ '(' large_object_length ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+
+large_object_length:
+ SQL_TOKEN_INTNUM opt_multiplier
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+opt_multiplier:
+ {$$ = SQL_NEW_RULE;}
+ | 'K'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("K", SQL_NODE_PUNCTUATION));
+ }
+ | 'M'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("M", SQL_NODE_PUNCTUATION));
+ }
+ | 'G'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("G", SQL_NODE_PUNCTUATION));
+ }
+ | 'T'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("T", SQL_NODE_PUNCTUATION));
+ }
+ | 'P'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("P", SQL_NODE_PUNCTUATION));
+ }
+ ;
+character_large_object_type:
+ SQL_TOKEN_CHARACTER SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ | SQL_TOKEN_CHAR SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ | SQL_TOKEN_CLOB opt_paren_char_large_length
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+national_character_string_type:
+ SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER opt_paren_precision
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ | SQL_TOKEN_NATIONAL SQL_TOKEN_CHAR opt_paren_precision
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ | SQL_TOKEN_NCHAR opt_paren_precision
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ | SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER SQL_TOKEN_VARYING paren_char_length
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ | SQL_TOKEN_NATIONAL SQL_TOKEN_CHAR SQL_TOKEN_VARYING paren_char_length
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ | SQL_TOKEN_NCHAR SQL_TOKEN_VARYING paren_char_length
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ | national_character_large_object_type
+ ;
+national_character_large_object_type:
+ SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ }
+ | SQL_TOKEN_NCHAR SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ | SQL_TOKEN_NCLOB opt_paren_char_large_length
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+binary_string_type:
+ SQL_TOKEN_BINARY opt_paren_precision
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ | SQL_TOKEN_BINARY SQL_TOKEN_VARYING paren_char_length
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ | SQL_TOKEN_VARBINARY paren_char_length
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ | binary_large_object_string_type
+ ;
+binary_large_object_string_type:
+ SQL_TOKEN_BINARY SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ | SQL_TOKEN_BLOB opt_paren_char_large_length
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+numeric_type:
+ exact_numeric_type
+ | approximate_numeric_type
+ ;
+opt_paren_precision_scale:
+ {$$ = SQL_NEW_RULE;}
+ | '(' SQL_TOKEN_INTNUM ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | '(' SQL_TOKEN_INTNUM ',' SQL_TOKEN_INTNUM ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode(",", SQL_NODE_PUNCTUATION));
+ $$->append($4);
+ $$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+exact_numeric_type:
+ SQL_TOKEN_NUMERIC opt_paren_precision_scale
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ | SQL_TOKEN_DECIMAL opt_paren_precision_scale
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ | SQL_TOKEN_DEC opt_paren_precision_scale
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ | SQL_TOKEN_SMALLINT
+ | SQL_TOKEN_INTEGER
+ | SQL_TOKEN_INT
+ | SQL_TOKEN_BIGINT
+ ;
+approximate_numeric_type:
+ SQL_TOKEN_FLOAT '(' SQL_TOKEN_INTNUM ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | SQL_TOKEN_FLOAT
+ | SQL_TOKEN_REAL
+ | SQL_TOKEN_DOUBLE
+ | SQL_TOKEN_DOUBLE SQL_TOKEN_PRECISION
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+boolean_type:
+ SQL_TOKEN_BOOLEAN
+;
+datetime_type:
+ SQL_TOKEN_DATE
+ | SQL_TOKEN_TIME opt_paren_precision opt_with_or_without_time_zone
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ | SQL_TOKEN_TIMESTAMP opt_paren_precision opt_with_or_without_time_zone
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ ;
+opt_with_or_without_time_zone:
+ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_WITH SQL_TOKEN_TIME SQL_TOKEN_ZONE
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ | SQL_TOKEN_WITHOUT SQL_TOKEN_TIME SQL_TOKEN_ZONE
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ ;
+interval_type:
+ SQL_TOKEN_INTERVAL interval_qualifier
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+ /* the various things you can name */
+
+column:
+ SQL_TOKEN_NAME
+ | SQL_TOKEN_POSITION
+ {
+ sal_uInt32 nNod = $$->getRuleID();
+ delete $$;
+ $$ = newNode(xxx_pGLOBAL_SQLPARSER->TokenIDToStr(nNod), SQL_NODE_NAME);
+ }
+ | SQL_TOKEN_CHAR_LENGTH
+ {
+ sal_uInt32 nNod = $$->getRuleID();
+ delete $$;
+ $$ = newNode(xxx_pGLOBAL_SQLPARSER->TokenIDToStr(nNod), SQL_NODE_NAME);
+ }
+ | SQL_TOKEN_EXTRACT
+ {
+ sal_uInt32 nNod = $$->getRuleID();
+ delete $$;
+ $$ = newNode(xxx_pGLOBAL_SQLPARSER->TokenIDToStr(nNod), SQL_NODE_NAME);
+ }
+ ;
+case_expression:
+ case_abbreviation
+ | case_specification
+ ;
+case_abbreviation:
+ SQL_TOKEN_NULLIF '(' value_exp_commalist ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | SQL_TOKEN_COALESCE '(' value_exp ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ | SQL_TOKEN_COALESCE '(' value_exp_commalist ')'
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append($3);
+ $$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ ;
+case_specification:
+ simple_case
+ | searched_case
+ ;
+simple_case:
+ SQL_TOKEN_CASE case_operand simple_when_clause_list else_clause SQL_TOKEN_END
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ }
+ ;
+searched_case:
+ SQL_TOKEN_CASE searched_when_clause_list else_clause SQL_TOKEN_END
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ ;
+simple_when_clause_list:
+ simple_when_clause
+ {
+ $$ = SQL_NEW_LISTRULE;
+ $$->append($1);
+ }
+ | searched_when_clause_list simple_when_clause
+ {
+ $1->append($2);
+ $$ = $1;
+ }
+ ;
+simple_when_clause:
+ SQL_TOKEN_WHEN when_operand_list SQL_TOKEN_THEN result
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ ;
+when_operand_list:
+ when_operand
+ {$$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);}
+ | when_operand_list ',' when_operand
+ {$1->append($3);
+ $$ = $1;}
+ ;
+when_operand:
+ row_value_constructor_elem
+ | comparison_predicate_part_2
+ | between_predicate_part_2
+ | in_predicate_part_2
+ | character_like_predicate_part_2
+ | null_predicate_part_2
+;
+searched_when_clause_list:
+ searched_when_clause
+ {
+ $$ = SQL_NEW_LISTRULE;
+ $$->append($1);
+ }
+ | searched_when_clause_list searched_when_clause
+ {
+ $1->append($2);
+ $$ = $1;
+ }
+ ;
+searched_when_clause:
+ SQL_TOKEN_WHEN search_condition SQL_TOKEN_THEN result
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ ;
+else_clause:
+ {$$ = SQL_NEW_RULE;}
+ | SQL_TOKEN_ELSE result
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+result:
+ result_expression
+ | SQL_TOKEN_NULL
+ ;
+result_expression:
+ value_exp
+ ;
+case_operand:
+ row_value_constructor_elem
+ ;
+
+cursor: SQL_TOKEN_NAME
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);}
+ ;
+
+/***
+module: SQL_TOKEN_NAME
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);}
+ ;
+***/
+
+parameter:
+ ':' SQL_TOKEN_NAME
+ {$$ = SQL_NEW_RULE;
+ $$->append($1 = newNode(":", SQL_NODE_PUNCTUATION));
+ $$->append($2);}
+ | '?'
+ {$$ = SQL_NEW_RULE; // test
+ $$->append($1 = newNode("?", SQL_NODE_PUNCTUATION));}
+ | '[' SQL_TOKEN_NAME ']'
+ {$$ = SQL_NEW_RULE;
+ $$->append($1 = newNode("[", SQL_NODE_PUNCTUATION));
+ $$->append($2);
+ $$->append($3 = newNode("]", SQL_NODE_PUNCTUATION));}
+ ;
+
+/***
+procedure: SQL_TOKEN_NAME
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);}
+ ;
+***/
+
+range_variable:
+ {$$ = SQL_NEW_RULE;}
+ | opt_as SQL_TOKEN_NAME
+ {$$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+
+user: SQL_TOKEN_NAME
+ ;
+
+/* PREDICATECHECK RULES */
+sql:
+ search_condition /* checking predicats */
+ {
+ if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) // sql: rule 1
+ {
+ $$ = $1;
+ if ( SQL_ISRULE($$,search_condition) )
+ {
+ $$->insert(0,newNode("(", SQL_NODE_PUNCTUATION));
+ $$->append(newNode(")", SQL_NODE_PUNCTUATION));
+ }
+ }
+ else
+ YYERROR;
+ }
+ | '(' sql ')' /* checking predicats */
+ ;
+trigger_definition:
+ SQL_TOKEN_CREATE SQL_TOKEN_TRIGGER trigger_name trigger_action_time trigger_event SQL_TOKEN_ON table_name op_referencing triggered_action
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ $$->append($5);
+ $$->append($6);
+ $$->append($7);
+ $$->append($8);
+ $$->append($9);
+ }
+ ;
+op_referencing:
+ {
+ $$ = SQL_NEW_RULE;
+ }
+ | SQL_TOKEN_REFERENCING transition_table_or_variable_list
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+trigger_action_time:
+ SQL_TOKEN_BEFORE
+ | SQL_TOKEN_AFTER
+ | SQL_TOKEN_INSTEAD SQL_TOKEN_OF
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+;
+trigger_event:
+ SQL_TOKEN_INSERT
+ | SQL_TOKEN_DELETE
+ | SQL_TOKEN_UPDATE op_trigger_columnlist
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+op_trigger_columnlist:
+ {
+ $$ = SQL_NEW_RULE;
+ }
+ | SQL_TOKEN_OF trigger_column_list
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+trigger_column_list:
+ column_commalist
+ ;
+triggered_action:
+ op_triggered_action_for triggered_when_clause triggered_SQL_statement
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ ;
+op_triggered_action_for:
+ {
+ $$ = SQL_NEW_RULE;
+ }
+ | SQL_TOKEN_FOR SQL_TOKEN_EACH trigger_for
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ }
+ ;
+trigger_for:
+ SQL_TOKEN_ROW
+ | SQL_TOKEN_STATEMENT
+ ;
+triggered_when_clause:
+ {
+ $$ = SQL_NEW_RULE;
+ }
+ | SQL_TOKEN_WHEN parenthesized_boolean_value_expression
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ }
+ ;
+triggered_SQL_statement:
+ SQL_procedure_statement
+ | SQL_TOKEN_BEGIN SQL_TOKEN_ATOMIC SQL_procedure_statement_list ';' SQL_TOKEN_END
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4 = newNode(";", SQL_NODE_PUNCTUATION));
+ $$->append($5);
+ }
+ ;
+SQL_procedure_statement_list:
+ SQL_procedure_statement
+ {
+ $$ = SQL_NEW_LISTRULE;
+ $$->append($1);
+ }
+ | SQL_procedure_statement_list ';' SQL_procedure_statement
+ {
+ $1->append($3);
+ $$ = $1;
+ }
+ ;
+SQL_procedure_statement:
+ sql
+ ;
+
+transition_table_or_variable_list:
+ transition_table_or_variable
+ {
+ $$ = SQL_NEW_LISTRULE;
+ $$->append($1);
+ }
+ | transition_table_or_variable_list transition_table_or_variable
+ {
+ $1->append($2);
+ $$ = $1;
+ }
+ ;
+
+transition_table_or_variable:
+ SQL_TOKEN_OLD opt_row opt_as old_transition_variable_name
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ | SQL_TOKEN_NEW opt_row opt_as new_transition_variable_name
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ | SQL_TOKEN_OLD SQL_TOKEN_TABLE opt_as old_transition_table_name
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+ | SQL_TOKEN_NEW SQL_TOKEN_TABLE opt_as new_transition_table_name
+ {
+ $$ = SQL_NEW_RULE;
+ $$->append($1);
+ $$->append($2);
+ $$->append($3);
+ $$->append($4);
+ }
+;
+old_transition_table_name:
+ transition_table_name
+;
+new_transition_table_name:
+ transition_table_name
+;
+transition_table_name:
+ SQL_TOKEN_NAME
+;
+old_transition_variable_name:
+ SQL_TOKEN_NAME
+;
+new_transition_variable_name:
+ SQL_TOKEN_NAME
+;
+trigger_name:
+ SQL_TOKEN_NAME
+;
+%%
+
+
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+using namespace ::osl;
+using namespace ::dbtools;
+// using namespace connectivity;
+
+//============================================================
+//= a helper for static ascii pseudo-unicode strings
+//============================================================
+// string constants
+struct _ConstAsciiString_
+{
+ sal_Int32 length;
+ sal_Char const* str;
+
+ operator rtl::OUString () const { return rtl::OUString(str, length, RTL_TEXTENCODING_ASCII_US); }
+// operator ::rtl::OUString () const { return ::rtl::OUString(str, length, RTL_TEXTENCODING_ASCII_US); }
+ operator const sal_Char * () const { return str; }
+ operator ::rtl::OString() const { return str; }
+};
+
+#define IMPLEMENT_CONSTASCII_STRING( name, string ) \
+ _ConstAsciiString_ const name = { sizeof(string)-1, string }
+
+IMPLEMENT_CONSTASCII_STRING(ERROR_STR_GENERAL, "Syntax error in SQL expression");
+IMPLEMENT_CONSTASCII_STRING(ERROR_STR_VALUE_NO_LIKE, "The value #1 can not be used with LIKE.");
+IMPLEMENT_CONSTASCII_STRING(ERROR_STR_FIELD_NO_LIKE, "LIKE can not be used with this field.");
+IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_COMPARE, "The entered criterion can not be compared with this field.");
+IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_DATE_COMPARE, "The field can not be compared with a date.");
+IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_REAL_COMPARE, "The field can not be compared with a floating point number.");
+IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_INT_COMPARE, "The field can not be compared with a number.");
+IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_TABLE, "The database does not contain a table named \"#\".");
+IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_TABLE_OR_QUERY, "The database does contain neither a table nor a query named \"#\".");
+IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_COLUMN, "The column \"#1\" is unknown in the table \"#2\".");
+IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_TABLE_EXIST, "The database already contains a table or view with name \"#\".");
+IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_QUERY_EXIST, "The database already contains a query with name \"#\".");
+
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_LIKE, "LIKE");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_NOT, "NOT");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_NULL, "NULL");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_TRUE, "True");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_FALSE, "False");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_IS, "IS");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_BETWEEN, "BETWEEN");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_OR, "OR");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_AND, "AND");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_AVG, "AVG");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_COUNT, "COUNT");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_MAX, "MAX");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_MIN, "MIN");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_SUM, "SUM");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_EVERY, "EVERY");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_ANY, "ANY");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_SOME, "SOME");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_STDDEV_POP, "STDDEV_POP");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_STDDEV_SAMP, "STDDEV_SAMP");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_VAR_SAMP, "VAR_SAMP");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_VAR_POP, "VAR_POP");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_COLLECT, "COLLECT");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_FUSION, "FUSION");
+IMPLEMENT_CONSTASCII_STRING(KEY_STR_INTERSECTION, "INTERSECTION");
+
+IMPLEMENT_CONSTASCII_STRING(FIELD_STR_NULLDATE, "NullDate");
+
+IMPLEMENT_CONSTASCII_STRING(STR_SQL_TOKEN, "SQL_TOKEN_");
+
+//==========================================================================
+//= OParseContext
+//==========================================================================
+//-----------------------------------------------------------------------------
+OParseContext::OParseContext()
+{
+}
+
+//-----------------------------------------------------------------------------
+OParseContext::~OParseContext()
+{
+}
+
+//-----------------------------------------------------------------------------
+::rtl::OUString OParseContext::getErrorMessage(ErrorCode _eCode) const
+{
+ ::rtl::OUString aMsg;
+ switch (_eCode)
+ {
+ case ERROR_GENERAL: aMsg = ERROR_STR_GENERAL; break;
+ case ERROR_VALUE_NO_LIKE: aMsg = ERROR_STR_VALUE_NO_LIKE; break;
+ case ERROR_FIELD_NO_LIKE: aMsg = ERROR_STR_FIELD_NO_LIKE; break;
+ case ERROR_INVALID_COMPARE: aMsg = ERROR_STR_INVALID_COMPARE; break;
+ case ERROR_INVALID_INT_COMPARE: aMsg = ERROR_STR_INVALID_INT_COMPARE; break;
+ case ERROR_INVALID_DATE_COMPARE: aMsg = ERROR_STR_INVALID_DATE_COMPARE; break;
+ case ERROR_INVALID_REAL_COMPARE: aMsg = ERROR_STR_INVALID_REAL_COMPARE; break;
+ case ERROR_INVALID_TABLE: aMsg = ERROR_STR_INVALID_TABLE; break;
+ case ERROR_INVALID_TABLE_OR_QUERY: aMsg = ERROR_STR_INVALID_TABLE_OR_QUERY; break;
+ case ERROR_INVALID_COLUMN: aMsg = ERROR_STR_INVALID_COLUMN; break;
+ case ERROR_INVALID_TABLE_EXIST: aMsg = ERROR_STR_INVALID_TABLE_EXIST; break;
+ case ERROR_INVALID_QUERY_EXIST: aMsg = ERROR_STR_INVALID_QUERY_EXIST; break;
+ default:
+ OSL_ENSURE( false, "OParseContext::getErrorMessage: unknown error code!" );
+ break;
+ }
+ return aMsg;
+}
+
+//-----------------------------------------------------------------------------
+::rtl::OString OParseContext::getIntlKeywordAscii(InternationalKeyCode _eKey) const
+{
+ ::rtl::OString aKeyword;
+ switch (_eKey)
+ {
+ case KEY_LIKE: aKeyword = KEY_STR_LIKE; break;
+ case KEY_NOT: aKeyword = KEY_STR_NOT; break;
+ case KEY_NULL: aKeyword = KEY_STR_NULL; break;
+ case KEY_TRUE: aKeyword = KEY_STR_TRUE; break;
+ case KEY_FALSE: aKeyword = KEY_STR_FALSE; break;
+ case KEY_IS: aKeyword = KEY_STR_IS; break;
+ case KEY_BETWEEN: aKeyword = KEY_STR_BETWEEN; break;
+ case KEY_OR: aKeyword = KEY_STR_OR; break;
+ case KEY_AND: aKeyword = KEY_STR_AND; break;
+ case KEY_AVG: aKeyword = KEY_STR_AVG; break;
+ case KEY_COUNT: aKeyword = KEY_STR_COUNT; break;
+ case KEY_MAX: aKeyword = KEY_STR_MAX; break;
+ case KEY_MIN: aKeyword = KEY_STR_MIN; break;
+ case KEY_SUM: aKeyword = KEY_STR_SUM; break;
+ case KEY_EVERY: aKeyword = KEY_STR_EVERY; break;
+ case KEY_ANY: aKeyword = KEY_STR_ANY; break;
+ case KEY_SOME: aKeyword = KEY_STR_SOME; break;
+ case KEY_STDDEV_POP: aKeyword = KEY_STR_STDDEV_POP; break;
+ case KEY_STDDEV_SAMP: aKeyword = KEY_STR_STDDEV_SAMP; break;
+ case KEY_VAR_SAMP: aKeyword = KEY_STR_VAR_SAMP; break;
+ case KEY_VAR_POP: aKeyword = KEY_STR_VAR_POP; break;
+ case KEY_COLLECT: aKeyword = KEY_STR_COLLECT; break;
+ case KEY_FUSION: aKeyword = KEY_STR_FUSION; break;
+ case KEY_INTERSECTION:aKeyword = KEY_STR_INTERSECTION; break;
+ case KEY_NONE: break;
+ default:
+ OSL_ENSURE( false, "OParseContext::getIntlKeywordAscii: unknown key!" );
+ break;
+ }
+ return aKeyword;
+}
+
+//-----------------------------------------------------------------------------
+IParseContext::InternationalKeyCode OParseContext::getIntlKeyCode(const ::rtl::OString& rToken) const
+{
+ static IParseContext::InternationalKeyCode Intl_TokenID[] =
+ {
+ KEY_LIKE, KEY_NOT, KEY_NULL, KEY_TRUE,
+ KEY_FALSE, KEY_IS, KEY_BETWEEN, KEY_OR,
+ KEY_AND, KEY_AVG, KEY_COUNT, KEY_MAX,
+ KEY_MIN, KEY_SUM, KEY_EVERY,KEY_ANY,KEY_SOME,
+ KEY_STDDEV_POP,KEY_STDDEV_SAMP,KEY_VAR_SAMP,
+ KEY_VAR_POP,KEY_COLLECT,KEY_FUSION,KEY_INTERSECTION
+ };
+
+ sal_uInt32 nCount = sizeof Intl_TokenID / sizeof Intl_TokenID[0];
+ for (sal_uInt32 i = 0; i < nCount; i++)
+ {
+ ::rtl::OString aKey = getIntlKeywordAscii(Intl_TokenID[i]);
+ if (rToken.equalsIgnoreAsciiCase(aKey))
+ return Intl_TokenID[i];
+ }
+
+ return KEY_NONE;
+}
+
+//------------------------------------------------------------------------------
+static Locale& impl_getLocaleInstance( )
+{
+ static Locale s_aLocale(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "en" ) ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "US" ) ),
+ ::rtl::OUString( )
+ );
+ return s_aLocale;
+}
+
+//------------------------------------------------------------------------------
+void OParseContext::setDefaultLocale( const ::com::sun::star::lang::Locale& _rLocale )
+{
+ impl_getLocaleInstance() = _rLocale;
+}
+
+//------------------------------------------------------------------------------
+Locale OParseContext::getPreferredLocale( ) const
+{
+ return getDefaultLocale();
+}
+
+//------------------------------------------------------------------------------
+const Locale& OParseContext::getDefaultLocale()
+{
+ return impl_getLocaleInstance();
+}
+
+//==========================================================================
+//= misc
+//==========================================================================
+// Der (leider globale) yylval fuer die Uebergabe von
+// Werten vom Scanner an den Parser. Die globale Variable
+// wird nur kurzzeitig verwendet, der Parser liest die Variable
+// sofort nach dem Scanner-Aufruf in eine gleichnamige eigene
+// Member-Variable.
+
+const double fMilliSecondsPerDay = 86400000.0;
+
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------
+::rtl::OUString ConvertLikeToken(const OSQLParseNode* pTokenNode, const OSQLParseNode* pEscapeNode, sal_Bool bInternational)
+{
+ ::rtl::OUStringBuffer aMatchStr;
+ if (pTokenNode->isToken())
+ {
+ sal_Unicode cEscape = 0;
+ if (pEscapeNode->count())
+ cEscape = pEscapeNode->getChild(1)->getTokenValue().toChar();
+
+ // Platzhalter austauschen
+ aMatchStr = pTokenNode->getTokenValue();
+ const sal_Int32 nLen = aMatchStr.getLength();
+ ::rtl::OUStringBuffer sSearch,sReplace;
+ if ( bInternational )
+ {
+ sSearch.appendAscii("%_",2);
+ sReplace.appendAscii("*?",2);
+ }
+ else
+ {
+ sSearch.appendAscii("*?",2);
+ sReplace.appendAscii("%_",2);
+ }
+
+ for (sal_Int32 i = 0; i < nLen; i++)
+ {
+ const sal_Unicode c = aMatchStr.charAt(i);
+ if (c == sSearch.charAt(0) || c == sSearch.charAt(1))
+ {
+ if (i > 0 && aMatchStr.charAt(i-1) == cEscape)
+ continue;
+ else
+ {
+ const sal_Unicode cCharacter = sReplace.charAt( (c == sSearch.charAt(0)) ? 0 : 1);
+ aMatchStr.setCharAt(i , cCharacter);
+ }
+ }
+ }
+ }
+ return aMatchStr.makeStringAndClear();
+}
+
+//==========================================================================
+//= OSQLParser
+//==========================================================================
+
+sal_uInt32 OSQLParser::s_nRuleIDs[OSQLParseNode::rule_count + 1];
+OSQLParser::RuleIDMap OSQLParser::s_aReverseRuleIDLookup;
+OParseContext OSQLParser::s_aDefaultContext;
+
+sal_Int32 OSQLParser::s_nRefCount = 0;
+// ::osl::Mutex OSQLParser::s_aMutex;
+OSQLScanner* OSQLParser::s_pScanner = 0;
+OSQLParseNodesGarbageCollector* OSQLParser::s_pGarbageCollector = 0;
+::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData> OSQLParser::s_xLocaleData = NULL;
+//-----------------------------------------------------------------------------
+void setParser(OSQLParser* _pParser)
+{
+ xxx_pGLOBAL_SQLPARSER = _pParser;
+}
+// -------------------------------------------------------------------------
+void OSQLParser::setParseTree(OSQLParseNode * pNewParseTree)
+{
+ ::osl::MutexGuard aGuard(getMutex());
+ m_pParseTree = pNewParseTree;
+}
+//-----------------------------------------------------------------------------
+OSQLParseNode* OSQLParser::parseTree(::rtl::OUString& rErrorMessage,
+ const ::rtl::OUString& rStatement,
+ sal_Bool bInternational)
+{
+
+
+ // Guard the parsing
+ ::osl::MutexGuard aGuard(getMutex());
+ // must be reset
+ setParser(this);
+
+ // defines how to scan
+ s_pScanner->SetRule(s_pScanner->GetSQLRule()); // initial
+ s_pScanner->prepareScan(rStatement, m_pContext, bInternational);
+
+ SQLyylval.pParseNode = NULL;
+ // SQLyypvt = NULL;
+ m_pParseTree = NULL;
+ m_sErrorMessage = ::rtl::OUString();
+
+ // ... und den Parser anwerfen ...
+ if (SQLyyparse() != 0)
+ {
+ // only set the error message, if it's not already set
+ if (!m_sErrorMessage.getLength())
+ m_sErrorMessage = s_pScanner->getErrorMessage();
+ if (!m_sErrorMessage.getLength())
+ m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_GENERAL);
+
+ rErrorMessage = m_sErrorMessage;
+
+ // clear the garbage collector
+ (*s_pGarbageCollector)->clearAndDelete();
+ return NULL;
+ }
+ else
+ {
+ (*s_pGarbageCollector)->clear();
+
+ // Das Ergebnis liefern (den Root Parse Node):
+
+ // OSL_ENSURE(Sdbyyval.pParseNode != NULL,"OSQLParser: Parser hat keinen ParseNode geliefert");
+ // return Sdbyyval.pParseNode;
+ // geht nicht wegen Bug in MKS YACC-erzeugtem Code (es wird ein falscher ParseNode
+ // geliefert).
+
+ // Stattdessen setzt die Parse-Routine jetzt den Member pParseTree
+ // - einfach diesen zurueckliefern:
+ OSL_ENSURE(m_pParseTree != NULL,"OSQLParser: Parser hat keinen ParseTree geliefert");
+ return m_pParseTree;
+ }
+}
+//-----------------------------------------------------------------------------
+::rtl::OString OSQLParser::TokenIDToStr(sal_uInt32 nTokenID, const IParseContext* pContext)
+{
+ ::rtl::OString aStr;
+ if (pContext)
+ {
+ IParseContext::InternationalKeyCode eKeyCode = IParseContext::KEY_NONE;
+ switch( nTokenID )
+ {
+ case SQL_TOKEN_LIKE: eKeyCode = IParseContext::KEY_LIKE; break;
+ case SQL_TOKEN_NOT: eKeyCode = IParseContext::KEY_NOT; break;
+ case SQL_TOKEN_NULL: eKeyCode = IParseContext::KEY_NULL; break;
+ case SQL_TOKEN_TRUE: eKeyCode = IParseContext::KEY_TRUE; break;
+ case SQL_TOKEN_FALSE: eKeyCode = IParseContext::KEY_FALSE; break;
+ case SQL_TOKEN_IS: eKeyCode = IParseContext::KEY_IS; break;
+ case SQL_TOKEN_BETWEEN: eKeyCode = IParseContext::KEY_BETWEEN; break;
+ case SQL_TOKEN_OR: eKeyCode = IParseContext::KEY_OR; break;
+ case SQL_TOKEN_AND: eKeyCode = IParseContext::KEY_AND; break;
+ case SQL_TOKEN_AVG: eKeyCode = IParseContext::KEY_AVG; break;
+ case SQL_TOKEN_COUNT: eKeyCode = IParseContext::KEY_COUNT; break;
+ case SQL_TOKEN_MAX: eKeyCode = IParseContext::KEY_MAX; break;
+ case SQL_TOKEN_MIN: eKeyCode = IParseContext::KEY_MIN; break;
+ case SQL_TOKEN_SUM: eKeyCode = IParseContext::KEY_SUM; break;
+ }
+ if ( eKeyCode != IParseContext::KEY_NONE )
+ aStr = pContext->getIntlKeywordAscii(eKeyCode);
+ }
+
+ if (!aStr.getLength())
+ {
+ aStr = yytname[YYTRANSLATE(nTokenID)];
+ if(!aStr.compareTo("SQL_TOKEN_",10))
+ aStr = aStr.copy(10);
+ }
+ return aStr;
+}
+
+//-----------------------------------------------------------------------------
+::rtl::OUString OSQLParser::RuleIDToStr(sal_uInt32 nRuleID)
+{
+ OSL_ENSURE(nRuleID < (sizeof yytname/sizeof yytname[0]), "OSQLParser::RuleIDToStr: Invalid nRuleId!");
+ return ::rtl::OUString::createFromAscii(yytname[nRuleID]);
+}
+
+//-----------------------------------------------------------------------------
+sal_uInt32 OSQLParser::StrToRuleID(const ::rtl::OString & rValue)
+{
+ // In yysvar nach dem angegebenen Namen suchen, den Index zurueckliefern
+ // (oder 0, wenn nicht gefunden)
+ static sal_uInt32 nLen = sizeof(yytname)/sizeof(yytname[0]);
+ for (sal_uInt32 i = YYTRANSLATE(SQL_TOKEN_INVALIDSYMBOL); i < (nLen-1); i++)
+ {
+ if (yytname && rValue == yytname[i])
+ return i;
+ }
+
+ // Nicht gefunden
+ return 0;
+}
+
+//-----------------------------------------------------------------------------
+OSQLParseNode::Rule OSQLParser::RuleIDToRule( sal_uInt32 _nRule )
+{
+ return s_aReverseRuleIDLookup[ _nRule ];
+}
+
+//-----------------------------------------------------------------------------
+sal_uInt32 OSQLParser::RuleID(OSQLParseNode::Rule eRule)
+{
+ return s_nRuleIDs[(sal_uInt16)eRule];
+}
+// -------------------------------------------------------------------------
+sal_Int16 OSQLParser::buildNode(OSQLParseNode*& pAppend,OSQLParseNode* pCompare,OSQLParseNode* pLiteral,OSQLParseNode* pLiteral2)
+{
+ OSQLParseNode* pColumnRef = new OSQLInternalNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref));
+ pColumnRef->append(new OSQLInternalNode(m_sFieldName,SQL_NODE_NAME));
+ OSQLParseNode* pComp = NULL;
+ if ( SQL_ISTOKEN( pCompare, BETWEEN) && pLiteral2 )
+ pComp = new OSQLInternalNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::between_predicate_part_2));
+ else
+ pComp = new OSQLInternalNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::comparison_predicate));
+
+ pComp->append(pColumnRef);
+ pComp->append(pCompare);
+ pComp->append(pLiteral);
+ if ( pLiteral2 )
+ {
+ pComp->append(new OSQLInternalNode(aEmptyString, SQL_NODE_KEYWORD,SQL_TOKEN_AND));
+ pComp->append(pLiteral2);
+ }
+ pAppend->append(pComp);
+ return 1;
+}
+//-----------------------------------------------------------------------------
+sal_Int16 OSQLParser::buildStringNodes(OSQLParseNode*& pLiteral)
+{
+ if(!pLiteral)
+ return 1;
+
+ if(SQL_ISRULE(pLiteral,set_fct_spec) || SQL_ISRULE(pLiteral,general_set_fct) || SQL_ISRULE(pLiteral,column_ref)
+ || SQL_ISRULE(pLiteral,subquery))
+ return 1; // here I have a function that I can't transform into a string
+
+ if(pLiteral->getNodeType() == SQL_NODE_INTNUM || pLiteral->getNodeType() == SQL_NODE_APPROXNUM || pLiteral->getNodeType() == SQL_NODE_ACCESS_DATE)
+ {
+ OSQLParseNode* pParent = pLiteral->getParent();
+
+ OSQLParseNode* pNewNode = new OSQLInternalNode(pLiteral->getTokenValue(), SQL_NODE_STRING);
+ pParent->replace(pLiteral, pNewNode);
+ delete pLiteral;
+ pLiteral = NULL;
+ return 1;
+ }
+
+ for(sal_uInt32 i=0;i<pLiteral->count();++i)
+ {
+ OSQLParseNode* pChild = pLiteral->getChild(i);
+ buildStringNodes(pChild);
+ }
+ if(SQL_ISRULE(pLiteral,term) || SQL_ISRULE(pLiteral,value_exp_primary))
+ {
+ m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_COMPARE);
+ return 0;
+ }
+ return 1;
+}
+//-----------------------------------------------------------------------------
+sal_Int16 OSQLParser::buildComparsionRule(OSQLParseNode*& pAppend,OSQLParseNode* pLiteral)
+{
+ OSQLParseNode* pComp = new OSQLInternalNode(::rtl::OUString::createFromAscii("="), SQL_NODE_EQUAL);
+ return buildPredicateRule(pAppend,pLiteral,pComp);
+}
+
+
+//-----------------------------------------------------------------------------
+void OSQLParser::reduceLiteral(OSQLParseNode*& pLiteral, sal_Bool bAppendBlank)
+{
+ OSL_ENSURE(pLiteral->isRule(), "This is no ::com::sun::star::chaos::Rule");
+ OSL_ENSURE(pLiteral->count() == 2, "OSQLParser::ReduceLiteral() Invalid count");
+ OSQLParseNode* pTemp = pLiteral;
+ ::rtl::OUStringBuffer aValue(pLiteral->getChild(0)->getTokenValue());
+ if (bAppendBlank)
+ {
+ aValue.appendAscii(" ");
+ }
+
+ aValue.append(pLiteral->getChild(1)->getTokenValue());
+
+ pLiteral = new OSQLInternalNode(aValue.makeStringAndClear(),SQL_NODE_STRING);
+ delete pTemp;
+}
+
+// -------------------------------------------------------------------------
+void OSQLParser::error(sal_Char *fmt)
+{
+ if(!m_sErrorMessage.getLength())
+ {
+ ::rtl::OUString sStr(fmt,strlen(fmt),RTL_TEXTENCODING_UTF8);
+ ::rtl::OUString sSQL_TOKEN(::rtl::OUString::createFromAscii("SQL_TOKEN_"));
+
+ sal_Int32 nPos1 = sStr.indexOf(sSQL_TOKEN);
+ if(nPos1 != -1)
+ {
+ ::rtl::OUString sFirst = sStr.copy(0,nPos1);
+ sal_Int32 nPos2 = sStr.indexOf(sSQL_TOKEN,nPos1+1);
+ if(nPos2 != -1)
+ {
+ ::rtl::OUString sSecond = sStr.copy(nPos1+sSQL_TOKEN.getLength(),nPos2-nPos1-sSQL_TOKEN.getLength());
+ sFirst += sSecond;
+ sFirst += sStr.copy(nPos2+sSQL_TOKEN.getLength());
+ }
+ else
+ sFirst += sStr.copy(nPos1+sSQL_TOKEN.getLength());
+
+ m_sErrorMessage = sFirst;
+ }
+ else
+ m_sErrorMessage = sStr;
+
+ ::rtl::OUString aError = s_pScanner->getErrorMessage();
+ if(aError.getLength())
+ {
+ m_sErrorMessage += ::rtl::OUString::createFromAscii(", ");
+ m_sErrorMessage += aError;
+ }
+ }
+}
+// -------------------------------------------------------------------------
+int OSQLParser::SQLlex()
+{
+ return s_pScanner->SQLlex();
+}
+
+#if defined __SUNPRO_CC
+#pragma enable_warn
+#elif defined _MSC_VER
+#pragma warning(pop)
+#endif
diff --git a/connectivity/source/parse/sqlflex.l b/connectivity/source/parse/sqlflex.l
new file mode 100644
index 000000000000..c6723dfd6869
--- /dev/null
+++ b/connectivity/source/parse/sqlflex.l
@@ -0,0 +1,809 @@
+%{
+
+//--------------------------------------------------------------------------
+//
+// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+//
+// Copyright 2000, 2010 Oracle and/or its affiliates.
+//
+// OpenOffice.org - a multi-platform office productivity suite
+//
+// This file is part of OpenOffice.org.
+//
+// OpenOffice.org is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License version 3
+// only, as published by the Free Software Foundation.
+//
+// OpenOffice.org is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License version 3 for more details
+// (a copy is included in the LICENSE file that accompanied this code).
+//
+// You should have received a copy of the GNU Lesser General Public License
+// version 3 along with OpenOffice.org. If not, see
+// <http://www.openoffice.org/license.html>
+// for a copy of the LGPLv3 License.
+//
+//--------------------------------------------------------------------------
+
+#define YY_EXIT 1 // YY_FATAL will not halt the application
+
+#ifndef _CSTDARG_
+#include <cstdarg> // std::va_list
+#endif
+
+#ifndef _INC_STRING
+#include <string.h>
+#endif
+
+#include "internalnode.hxx"
+
+#ifndef _CONNECTIVITY_SQLYACC_HXX
+#define _CONNECTIVITY_SQLYACC_HXX
+
+#ifndef SQLYYDEBUG
+#define SQLYYDEBUG 1
+#endif
+
+#include "sqlbison.hxx"
+#endif
+#include "sqlscan.hxx"
+#include <osl/diagnose.h>
+#include <rtl/strbuf.hxx>
+#include <connectivity/sqlparse.hxx>
+
+#if defined __GNUC__
+ #pragma GCC system_header
+#elif defined __SUNPRO_CC
+#pragma disable_warn
+#elif defined _MSC_VER
+#pragma warning(push, 1)
+/**/
+#ifdef yywrap
+#undef yywrap
+#define yywrap() 1
+#endif
+/**/
+#endif
+
+using namespace connectivity;
+
+//=============================================================================
+//
+// Erzeugung der Blaetter fuer die Token
+// Blaetter werden generell vom Lexer erzeugt
+
+static ::rtl::OUString aEmptyString;
+
+static sal_Int32 gatherString(sal_Int32 delim, sal_Int32 nTyp);
+static sal_Int32 gatherName(const sal_Char*);
+static sal_Int32 gatherNamePre(const sal_Char* );
+// has to be set before the parser starts
+OSQLScanner* xxx_pGLOBAL_SQLSCAN = NULL;
+
+#define SQL_NEW_NODE(text, token) \
+ SQLyylval.pParseNode = new OSQLInternalNode(text, token);
+
+#define SQL_NEW_KEYWORD(token) \
+ SQLyylval.pParseNode = new OSQLInternalNode(aEmptyString, SQL_NODE_KEYWORD, (token)); return token;
+
+#define SQL_NEW_INTNUM SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_INTNUM); return SQL_TOKEN_INTNUM;
+#define SQL_NEW_APPROXNUM SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_APPROXNUM); return SQL_TOKEN_APPROXNUM;
+#define SQL_NEW_DATE SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_ACCESS_DATE); return SQL_TOKEN_ACCESS_DATE;
+
+#define YY_INPUT(buf,result,max_size) \
+{ \
+ buf[0] = xxx_pGLOBAL_SQLSCAN->SQLyygetc(); \
+ result = buf[0] != -1; \
+}
+
+#define YY_FATAL_ERROR(msg) \
+{ \
+ xxx_pGLOBAL_SQLSCAN->SQLyyerror(msg); \
+}
+
+//
+//=============================================================================
+
+%}
+
+%s SQL
+%s PREDICATE_ENG
+%s PREDICATE_GER
+%s DATE
+%s STRING
+
+%option noyywrap
+%option never-interactive
+%%
+
+ABS {SQL_NEW_KEYWORD(SQL_TOKEN_ABS); }
+ACOS {SQL_NEW_KEYWORD(SQL_TOKEN_ACOS); }
+AFTER {SQL_NEW_KEYWORD(SQL_TOKEN_AFTER); }
+ALL {SQL_NEW_KEYWORD(SQL_TOKEN_ALL); }
+ALTER {SQL_NEW_KEYWORD(SQL_TOKEN_ALTER); }
+AND {SQL_NEW_KEYWORD(SQL_TOKEN_AND); }
+ANY {SQL_NEW_KEYWORD(SQL_TOKEN_ANY); }
+ARRAY_AGG {SQL_NEW_KEYWORD(SQL_TOKEN_ARRAY_AGG); }
+AS {SQL_NEW_KEYWORD(SQL_TOKEN_AS); }
+ASC {SQL_NEW_KEYWORD(SQL_TOKEN_ASC); }
+ASCII {SQL_NEW_KEYWORD(SQL_TOKEN_ASCII); }
+ASIN {SQL_NEW_KEYWORD(SQL_TOKEN_ASIN); }
+AT {SQL_NEW_KEYWORD(SQL_TOKEN_AT); }
+ATAN {SQL_NEW_KEYWORD(SQL_TOKEN_ATAN); }
+ATAN2 {SQL_NEW_KEYWORD(SQL_TOKEN_ATAN2); }
+ATOMIC {SQL_NEW_KEYWORD(SQL_TOKEN_ATOMIC); }
+AUTHORIZATION {SQL_NEW_KEYWORD(SQL_TOKEN_AUTHORIZATION); }
+AVG {SQL_NEW_KEYWORD(SQL_TOKEN_AVG); }
+
+BEFORE {SQL_NEW_KEYWORD(SQL_TOKEN_BEFORE); }
+BEGIN {SQL_NEW_KEYWORD(SQL_TOKEN_BEGIN); }
+BETWEEN {SQL_NEW_KEYWORD(SQL_TOKEN_BETWEEN); }
+BIGINT {SQL_NEW_KEYWORD(SQL_TOKEN_BIGINT); }
+BINARY {SQL_NEW_KEYWORD(SQL_TOKEN_BINARY); }
+BIT {SQL_NEW_KEYWORD(SQL_TOKEN_BIT); }
+BIT_LENGTH {SQL_NEW_KEYWORD(SQL_TOKEN_BIT_LENGTH); }
+BLOB {SQL_NEW_KEYWORD(SQL_TOKEN_BLOB); }
+BOTH {SQL_NEW_KEYWORD(SQL_TOKEN_BOTH); }
+BY {SQL_NEW_KEYWORD(SQL_TOKEN_BY); }
+
+CALL {SQL_NEW_KEYWORD(SQL_TOKEN_CALL); }
+CASE {SQL_NEW_KEYWORD(SQL_TOKEN_CASE); }
+CAST {SQL_NEW_KEYWORD(SQL_TOKEN_CAST); }
+CEILING {SQL_NEW_KEYWORD(SQL_TOKEN_CEILING); }
+CHAR {SQL_NEW_KEYWORD(SQL_TOKEN_CHAR); }
+CHARACTER {SQL_NEW_KEYWORD(SQL_TOKEN_CHARACTER); }
+CHAR(ACTER)?_LENGTH {SQL_NEW_KEYWORD(SQL_TOKEN_CHAR_LENGTH); }
+CHECK {SQL_NEW_KEYWORD(SQL_TOKEN_CHECK); }
+CLOB {SQL_NEW_KEYWORD(SQL_TOKEN_CLOB); }
+COALESCE {SQL_NEW_KEYWORD(SQL_TOKEN_COALESCE); }
+COLLATE {SQL_NEW_KEYWORD(SQL_TOKEN_COLLATE); }
+COLLECT {SQL_NEW_KEYWORD(SQL_TOKEN_COLLECT); }
+COMMIT {SQL_NEW_KEYWORD(SQL_TOKEN_COMMIT); }
+CONCAT {SQL_NEW_KEYWORD(SQL_TOKEN_CONCAT); }
+CONTINUE {SQL_NEW_KEYWORD(SQL_TOKEN_CONTINUE); }
+CONVERT {SQL_NEW_KEYWORD(SQL_TOKEN_CONVERT); }
+COS {SQL_NEW_KEYWORD(SQL_TOKEN_COS); }
+COT {SQL_NEW_KEYWORD(SQL_TOKEN_COT); }
+COUNT {SQL_NEW_KEYWORD(SQL_TOKEN_COUNT); }
+CREATE {SQL_NEW_KEYWORD(SQL_TOKEN_CREATE); }
+CROSS {SQL_NEW_KEYWORD(SQL_TOKEN_CROSS); }
+CUME_RANK {SQL_NEW_KEYWORD(SQL_TOKEN_CUME_DIST); }
+CURRENT {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT); }
+CURRENT_DATE {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_DATE); }
+CURRENT_CATALOG {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_CATALOG); }
+CURRENT_DEFAULT_TRANSFORM_GROUP {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_DEFAULT_TRANSFORM_GROUP); }
+CURRENT_PATH {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_PATH); }
+CURRENT_ROLE {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_ROLE); }
+CURRENT_SCHEMA {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_SCHEMA); }
+CURRENT_USER {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_USER); }
+CURDATE {SQL_NEW_KEYWORD(SQL_TOKEN_CURDATE); }
+CURRENT_TIME {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_TIME); }
+CURTIME {SQL_NEW_KEYWORD(SQL_TOKEN_CURTIME); }
+CURRENT_TIMESTAMP {SQL_NEW_KEYWORD(SQL_TOKEN_CURRENT_TIMESTAMP); }
+CURSOR {SQL_NEW_KEYWORD(SQL_TOKEN_CURSOR); }
+
+D {SQL_NEW_KEYWORD(SQL_TOKEN_D); }
+DATE {SQL_NEW_KEYWORD(SQL_TOKEN_DATE); }
+DATEDIFF {SQL_NEW_KEYWORD(SQL_TOKEN_DATEDIFF); }
+DATEVALUE {SQL_NEW_KEYWORD(SQL_TOKEN_DATEVALUE); }
+DAY {SQL_NEW_KEYWORD(SQL_TOKEN_DAY); }
+DAYNAME {SQL_NEW_KEYWORD(SQL_TOKEN_DAYNAME); }
+DAYOFMONTH {SQL_NEW_KEYWORD(SQL_TOKEN_DAYOFMONTH); }
+DAYOFWEEK {SQL_NEW_KEYWORD(SQL_TOKEN_DAYOFWEEK); }
+DAYOFYEAR {SQL_NEW_KEYWORD(SQL_TOKEN_DAYOFYEAR); }
+DEC {SQL_NEW_KEYWORD(SQL_TOKEN_DEC); }
+DECIMAL {SQL_NEW_KEYWORD(SQL_TOKEN_DECIMAL); }
+DECLARE {SQL_NEW_KEYWORD(SQL_TOKEN_DECLARE); }
+DEFAULT {SQL_NEW_KEYWORD(SQL_TOKEN_DEFAULT); }
+DEGREES {SQL_NEW_KEYWORD(SQL_TOKEN_DEGREES); }
+DELETE {SQL_NEW_KEYWORD(SQL_TOKEN_DELETE); }
+DENSE_RANK {SQL_NEW_KEYWORD(SQL_TOKEN_DENSE_RANK); }
+DESC {SQL_NEW_KEYWORD(SQL_TOKEN_DESC); }
+DIFFERENCE {SQL_NEW_KEYWORD(SQL_TOKEN_DIFFERENCE); }
+DISTINCT {SQL_NEW_KEYWORD(SQL_TOKEN_DISTINCT); }
+DOUBLE {SQL_NEW_KEYWORD(SQL_TOKEN_DOUBLE); }
+DROP {SQL_NEW_KEYWORD(SQL_TOKEN_DROP); }
+
+EACH {SQL_NEW_KEYWORD(SQL_TOKEN_EACH); }
+ELSE {SQL_NEW_KEYWORD(SQL_TOKEN_ELSE); }
+END {SQL_NEW_KEYWORD(SQL_TOKEN_END); }
+EVERY {SQL_NEW_KEYWORD(SQL_TOKEN_EVERY); }
+ESCAPE {SQL_NEW_KEYWORD(SQL_TOKEN_ESCAPE); }
+EXCEPT {SQL_NEW_KEYWORD(SQL_TOKEN_EXCEPT); }
+EXISTS {SQL_NEW_KEYWORD(SQL_TOKEN_EXISTS); }
+EXP {SQL_NEW_KEYWORD(SQL_TOKEN_EXP); }
+EXTRACT {SQL_NEW_KEYWORD(SQL_TOKEN_EXTRACT); }
+
+FALSE {SQL_NEW_KEYWORD(SQL_TOKEN_FALSE); }
+FETCH {SQL_NEW_KEYWORD(SQL_TOKEN_FETCH); }
+FLOAT {SQL_NEW_KEYWORD(SQL_TOKEN_FLOAT); }
+FLOOR {SQL_NEW_KEYWORD(SQL_TOKEN_FLOOR); }
+FN {SQL_NEW_KEYWORD(SQL_TOKEN_FN); }
+FOR {SQL_NEW_KEYWORD(SQL_TOKEN_FOR); }
+FOREIGN {SQL_NEW_KEYWORD(SQL_TOKEN_FOREIGN); }
+FOUND {SQL_NEW_KEYWORD(SQL_TOKEN_FOUND); }
+FROM {SQL_NEW_KEYWORD(SQL_TOKEN_FROM); }
+FULL {SQL_NEW_KEYWORD(SQL_TOKEN_FULL); }
+FUSION {SQL_NEW_KEYWORD(SQL_TOKEN_FUSION); }
+
+GRANT {SQL_NEW_KEYWORD(SQL_TOKEN_GRANT); }
+GROUP {SQL_NEW_KEYWORD(SQL_TOKEN_GROUP); }
+
+HAVING {SQL_NEW_KEYWORD(SQL_TOKEN_HAVING); }
+HOUR {SQL_NEW_KEYWORD(SQL_TOKEN_HOUR); }
+
+IN {SQL_NEW_KEYWORD(SQL_TOKEN_IN); }
+INNER {SQL_NEW_KEYWORD(SQL_TOKEN_INNER); }
+INSERT {SQL_NEW_KEYWORD(SQL_TOKEN_INSERT); }
+INSTEAD {SQL_NEW_KEYWORD(SQL_TOKEN_INSTEAD); }
+INT(EGER)? {SQL_NEW_KEYWORD(SQL_TOKEN_INTEGER); }
+INTERSECT {SQL_NEW_KEYWORD(SQL_TOKEN_INTERSECT); }
+INTERVAL {SQL_NEW_KEYWORD(SQL_TOKEN_INTERVAL); }
+INTERSECTION {SQL_NEW_KEYWORD(SQL_TOKEN_INTERSECTION); }
+INTO {SQL_NEW_KEYWORD(SQL_TOKEN_INTO); }
+IS {SQL_NEW_KEYWORD(SQL_TOKEN_IS); }
+
+JOIN {SQL_NEW_KEYWORD(SQL_TOKEN_JOIN); }
+
+KEY {SQL_NEW_KEYWORD(SQL_TOKEN_KEY); }
+
+LARGE {SQL_NEW_KEYWORD(SQL_TOKEN_LARGE); }
+LCASE {SQL_NEW_KEYWORD(SQL_TOKEN_LCASE); }
+LEADING {SQL_NEW_KEYWORD(SQL_TOKEN_LEADING); }
+LEFT {SQL_NEW_KEYWORD(SQL_TOKEN_LEFT); }
+LENGTH {SQL_NEW_KEYWORD(SQL_TOKEN_LENGTH); }
+LIKE {SQL_NEW_KEYWORD(SQL_TOKEN_LIKE); }
+LN {SQL_NEW_KEYWORD(SQL_TOKEN_LN); }
+LOCAL {SQL_NEW_KEYWORD(SQL_TOKEN_LOCAL); }
+LOCATE {SQL_NEW_KEYWORD(SQL_TOKEN_LOCATE); }
+LOG {SQL_NEW_KEYWORD(SQL_TOKEN_LOG); }
+LOGF {SQL_NEW_KEYWORD(SQL_TOKEN_LOGF); }
+LOG10 {SQL_NEW_KEYWORD(SQL_TOKEN_LOG10); }
+LOWER {SQL_NEW_KEYWORD(SQL_TOKEN_LOWER); }
+LTRIM {SQL_NEW_KEYWORD(SQL_TOKEN_LTRIM); }
+
+MAX {SQL_NEW_KEYWORD(SQL_TOKEN_MAX); }
+MIN {SQL_NEW_KEYWORD(SQL_TOKEN_MIN); }
+MINUTE {SQL_NEW_KEYWORD(SQL_TOKEN_MINUTE); }
+MOD {SQL_NEW_KEYWORD(SQL_TOKEN_MOD); }
+MONTH {SQL_NEW_KEYWORD(SQL_TOKEN_MONTH); }
+MONTHNAME {SQL_NEW_KEYWORD(SQL_TOKEN_MONTHNAME); }
+
+NATIONAL {SQL_NEW_KEYWORD(SQL_TOKEN_NATIONAL); }
+NATURAL {SQL_NEW_KEYWORD(SQL_TOKEN_NATURAL); }
+NCHAR {SQL_NEW_KEYWORD(SQL_TOKEN_NCHAR); }
+NCLOB {SQL_NEW_KEYWORD(SQL_TOKEN_NCLOB); }
+NEW {SQL_NEW_KEYWORD(SQL_TOKEN_NEW); }
+NOT {SQL_NEW_KEYWORD(SQL_TOKEN_NOT); }
+NOW {SQL_NEW_KEYWORD(SQL_TOKEN_NOW); }
+NULL {SQL_NEW_KEYWORD(SQL_TOKEN_NULL); }
+NULLIF {SQL_NEW_KEYWORD(SQL_TOKEN_NULLIF); }
+NUMERIC {SQL_NEW_KEYWORD(SQL_TOKEN_NUMERIC); }
+
+OBJECT {SQL_NEW_KEYWORD(SQL_TOKEN_OBJECT); }
+OCTET_LENGTH {SQL_NEW_KEYWORD(SQL_TOKEN_OCTET_LENGTH); }
+OF {SQL_NEW_KEYWORD(SQL_TOKEN_OF); }
+OJ {SQL_NEW_KEYWORD(SQL_TOKEN_OJ); }
+OLD {SQL_NEW_KEYWORD(SQL_TOKEN_OLD); }
+ON {SQL_NEW_KEYWORD(SQL_TOKEN_ON); }
+OPTION {SQL_NEW_KEYWORD(SQL_TOKEN_OPTION); }
+OR {SQL_NEW_KEYWORD(SQL_TOKEN_OR); }
+ORDER {SQL_NEW_KEYWORD(SQL_TOKEN_ORDER); }
+OUTER {SQL_NEW_KEYWORD(SQL_TOKEN_OUTER); }
+
+PERCENT_RANK {SQL_NEW_KEYWORD(SQL_TOKEN_PERCENT_RANK); }
+PERCENTILE_CONT {SQL_NEW_KEYWORD(SQL_TOKEN_PERCENTILE_CONT); }
+PERCENTILE_DISC {SQL_NEW_KEYWORD(SQL_TOKEN_PERCENTILE_DISC); }
+PI {SQL_NEW_KEYWORD(SQL_TOKEN_PI); }
+POSITION {SQL_NEW_KEYWORD(SQL_TOKEN_POSITION); }
+POWER {SQL_NEW_KEYWORD(SQL_TOKEN_POWER); }
+PRECISION {SQL_NEW_KEYWORD(SQL_TOKEN_PRECISION); }
+PRIMARY {SQL_NEW_KEYWORD(SQL_TOKEN_PRIMARY); }
+PRIVILEGES {SQL_NEW_KEYWORD(SQL_TOKEN_PRIVILEGES); }
+PROCEDURE {SQL_NEW_KEYWORD(SQL_TOKEN_PROCEDURE); }
+PUBLIC {SQL_NEW_KEYWORD(SQL_TOKEN_PUBLIC); }
+
+QUARTER {SQL_NEW_KEYWORD(SQL_TOKEN_QUARTER); }
+
+RADIANS {SQL_NEW_KEYWORD(SQL_TOKEN_RADIANS); }
+RAND {SQL_NEW_KEYWORD(SQL_TOKEN_RAND); }
+RANK {SQL_NEW_KEYWORD(SQL_TOKEN_RANK); }
+REAL {SQL_NEW_KEYWORD(SQL_TOKEN_REAL); }
+REFERENCES {SQL_NEW_KEYWORD(SQL_TOKEN_REFERENCES); }
+REFERENCING {SQL_NEW_KEYWORD(SQL_TOKEN_REFERENCING); }
+REPEAT {SQL_NEW_KEYWORD(SQL_TOKEN_REPEAT); }
+REPLACE {SQL_NEW_KEYWORD(SQL_TOKEN_REPLACE); }
+ROLLBACK {SQL_NEW_KEYWORD(SQL_TOKEN_ROLLBACK); }
+ROUND {SQL_NEW_KEYWORD(SQL_TOKEN_ROUND); }
+ROUNDMAGIC {SQL_NEW_KEYWORD(SQL_TOKEN_ROUNDMAGIC); }
+ROW {SQL_NEW_KEYWORD(SQL_TOKEN_ROW); }
+RIGHT {SQL_NEW_KEYWORD(SQL_TOKEN_RIGHT); }
+RTRIM {SQL_NEW_KEYWORD(SQL_TOKEN_RTRIM); }
+
+SCHEMA {SQL_NEW_KEYWORD(SQL_TOKEN_SCHEMA); }
+SECOND {SQL_NEW_KEYWORD(SQL_TOKEN_SECOND); }
+SELECT {SQL_NEW_KEYWORD(SQL_TOKEN_SELECT); }
+SET {SQL_NEW_KEYWORD(SQL_TOKEN_SET); }
+SIZE {SQL_NEW_KEYWORD(SQL_TOKEN_SIZE); }
+SIGN {SQL_NEW_KEYWORD(SQL_TOKEN_SIGN); }
+SIN {SQL_NEW_KEYWORD(SQL_TOKEN_SIN); }
+SMALLINT {SQL_NEW_KEYWORD(SQL_TOKEN_SMALLINT); }
+SOME {SQL_NEW_KEYWORD(SQL_TOKEN_SOME); }
+SOUNDEX {SQL_NEW_KEYWORD(SQL_TOKEN_SOUNDEX); }
+SPACE {SQL_NEW_KEYWORD(SQL_TOKEN_SPACE); }
+SQRT {SQL_NEW_KEYWORD(SQL_TOKEN_SQRT); }
+STDDEV_POP {SQL_NEW_KEYWORD(SQL_TOKEN_STDDEV_POP); }
+STDDEV_SAMP {SQL_NEW_KEYWORD(SQL_TOKEN_STDDEV_SAMP); }
+STATEMENT {SQL_NEW_KEYWORD(SQL_TOKEN_STATEMENT); }
+SUBSTRING {SQL_NEW_KEYWORD(SQL_TOKEN_SUBSTRING); }
+SUM {SQL_NEW_KEYWORD(SQL_TOKEN_SUM); }
+SESSION_USER {SQL_NEW_KEYWORD(SQL_TOKEN_SESSION_USER); }
+SYSTEM_USER {SQL_NEW_KEYWORD(SQL_TOKEN_SYSTEM_USER); }
+
+TABLE {SQL_NEW_KEYWORD(SQL_TOKEN_TABLE); }
+TAN {SQL_NEW_KEYWORD(SQL_TOKEN_TAN); }
+THEN {SQL_NEW_KEYWORD(SQL_TOKEN_THEN); }
+TIME {SQL_NEW_KEYWORD(SQL_TOKEN_TIME); }
+TIMESTAMP {SQL_NEW_KEYWORD(SQL_TOKEN_TIMESTAMP); }
+TIMESTAMPADD {SQL_NEW_KEYWORD(SQL_TOKEN_TIMESTAMPADD); }
+TIMESTAMPDIFF {SQL_NEW_KEYWORD(SQL_TOKEN_TIMESTAMPDIFF); }
+TIMEVALUE {SQL_NEW_KEYWORD(SQL_TOKEN_TIMEVALUE); }
+TIMEZONE_HOUR {SQL_NEW_KEYWORD(SQL_TOKEN_TIMEZONE_HOUR); }
+TIMEZONE_MINUTE {SQL_NEW_KEYWORD(SQL_TOKEN_TIMEZONE_MINUTE); }
+TO {SQL_NEW_KEYWORD(SQL_TOKEN_TO); }
+TRAILING {SQL_NEW_KEYWORD(SQL_TOKEN_TRAILING); }
+TRANSLATE {SQL_NEW_KEYWORD(SQL_TOKEN_TRANSLATE); }
+TRIGGER {SQL_NEW_KEYWORD(SQL_TOKEN_TRIGGER); }
+TRIM {SQL_NEW_KEYWORD(SQL_TOKEN_TRIM); }
+TRUE {SQL_NEW_KEYWORD(SQL_TOKEN_TRUE); }
+TRUNCATE {SQL_NEW_KEYWORD(SQL_TOKEN_TRUNCATE); }
+TS {SQL_NEW_KEYWORD(SQL_TOKEN_TS); }
+T {SQL_NEW_KEYWORD(SQL_TOKEN_T); }
+
+UCASE {SQL_NEW_KEYWORD(SQL_TOKEN_UCASE); }
+UNION {SQL_NEW_KEYWORD(SQL_TOKEN_UNION); }
+UNIQUE {SQL_NEW_KEYWORD(SQL_TOKEN_UNIQUE); }
+UNKNOWN {SQL_NEW_KEYWORD(SQL_TOKEN_UNKNOWN); }
+UPDATE {SQL_NEW_KEYWORD(SQL_TOKEN_UPDATE); }
+UPPER {SQL_NEW_KEYWORD(SQL_TOKEN_UPPER); }
+USAGE {SQL_NEW_KEYWORD(SQL_TOKEN_USAGE); }
+USER {SQL_NEW_KEYWORD(SQL_TOKEN_USER); }
+USING {SQL_NEW_KEYWORD(SQL_TOKEN_USING); }
+
+VARBINARY {SQL_NEW_KEYWORD(SQL_TOKEN_VARBINARY); }
+VARCHAR {SQL_NEW_KEYWORD(SQL_TOKEN_VARCHAR); }
+VARYING {SQL_NEW_KEYWORD(SQL_TOKEN_VARYING); }
+VAR_POP {SQL_NEW_KEYWORD(SQL_TOKEN_VAR_POP); }
+VAR_SAMP {SQL_NEW_KEYWORD(SQL_TOKEN_VAR_SAMP); }
+VALUE {SQL_NEW_KEYWORD(SQL_TOKEN_VALUE); }
+VALUES {SQL_NEW_KEYWORD(SQL_TOKEN_VALUES); }
+VIEW {SQL_NEW_KEYWORD(SQL_TOKEN_VIEW); }
+
+WEEK {SQL_NEW_KEYWORD(SQL_TOKEN_WEEK); }
+WHEN {SQL_NEW_KEYWORD(SQL_TOKEN_WHEN); }
+WHERE {SQL_NEW_KEYWORD(SQL_TOKEN_WHERE); }
+WITH {SQL_NEW_KEYWORD(SQL_TOKEN_WITH); }
+WITHIN {SQL_NEW_KEYWORD(SQL_TOKEN_WITHIN); }
+WITHOUT {SQL_NEW_KEYWORD(SQL_TOKEN_WITHOUT); }
+WORK {SQL_NEW_KEYWORD(SQL_TOKEN_WORK); }
+
+YEAR {SQL_NEW_KEYWORD(SQL_TOKEN_YEAR); }
+
+ZONE {SQL_NEW_KEYWORD(SQL_TOKEN_ZONE); }
+
+"<" { SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_LESS);return SQL_LESS;}
+">" { SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_GREAT);return SQL_GREAT;}
+"=" { SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_EQUAL);return SQL_EQUAL;}
+"<=" { SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_LESSEQ);return SQL_LESSEQ;}
+">=" { SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_GREATEQ);return SQL_GREATEQ;}
+"<>" { SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_NOTEQUAL);return SQL_NOTEQUAL;}
+"!=" { SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_NOTEQUAL);return SQL_NOTEQUAL;}
+"||" { SQL_NEW_NODE(::rtl::OUString(SQLyytext,strlen(SQLyytext),RTL_TEXTENCODING_UTF8), SQL_NODE_CONCAT);return SQL_CONCAT;}
+
+
+[-+*/:(),.;?{}] { return SQLyytext[0]; }
+
+
+<SQL>[A-Za-z\200-\277\300-\337\340-\357\360-\367\370-\373\374-\375][A-Za-z\200-\277\300-\337\340-\357\360-\367\370-\373\374-\375_0-9]* {return gatherName( SQLyytext);}
+
+<SQL>([0-9]+) |
+<SQL>([0-9]+"."[0-9]*) |
+<SQL>("."[0-9]*) {SQL_NEW_INTNUM; }
+
+<SQL>[0-9]+[eE][+-]?[0-9]+ |
+<SQL>[0-9]+"."[0-9]*[eE][+-]?[0-9]+ |
+<SQL>"."[0-9]*[eE][+-]?[0-9]+ {SQL_NEW_APPROXNUM; }
+
+<PREDICATE_GER,PREDICATE_ENG,DATE>[A-Za-z\200-\277\300-\337\340-\357\360-\367\370-\373\374-\375][A-Za-z0-9_%.,*?\200-\277\300-\337\340-\357\360-\367\370-\373\374-\375]* {return gatherNamePre(SQLyytext);}
+
+<PREDICATE_GER,PREDICATE_ENG>([0-9]+) {SQL_NEW_INTNUM; }
+<PREDICATE_ENG>([0-9]{1,3}(","[0-9]{3})+) {SQL_NEW_INTNUM; }
+<PREDICATE_GER>([0-9]{1,3}("."[0-9]{3})+) {SQL_NEW_INTNUM; }
+
+<PREDICATE_ENG>([0-9]+"."[0-9]+) |
+<PREDICATE_ENG>([0-9]{1,3}(","[0-9]{3})+"."[0-9]+) |
+<PREDICATE_ENG>("."[0-9]+) {SQL_NEW_APPROXNUM; }
+<PREDICATE_ENG>[0-9]+[eE][+-]?[0-9]+ |
+<PREDICATE_ENG>[0-9]+"."[0-9]*[eE][+-]?[0-9]+ |
+<PREDICATE_ENG>"."[0-9]*[eE][+-]?[0-9]+ {SQL_NEW_APPROXNUM; }
+
+<PREDICATE_GER>([0-9]+","[0-9]+) |
+<PREDICATE_GER>([0-9]{1,3}("."[0-9]{3})+","[0-9]+) |
+<PREDICATE_GER>(","[0-9]+) {SQL_NEW_APPROXNUM; }
+<PREDICATE_GER>[0-9]+[eE][+-]?[0-9]+ |
+<PREDICATE_GER>[0-9]+","[0-9]*[eE][+-]?[0-9]+ |
+<PREDICATE_GER>","[0-9]*[eE][+-]?[0-9]+ {SQL_NEW_APPROXNUM; }
+
+<PREDICATE_GER,PREDICATE_ENG>[0-9.,][A-Za-z0-9_.,%]* {return gatherNamePre(SQLyytext);}
+
+<SQL>\" { return gatherString('\"',0); }
+<SQL>` { return gatherString('`' ,0); }
+
+<PREDICATE_GER,PREDICATE_ENG,DATE,SQL>"[" { return gatherString(']' ,0);}
+
+\' { return gatherString('\'',1); }
+
+<PREDICATE_GER,PREDICATE_ENG,DATE># { return gatherString('#' ,2); }
+
+<DATE>[0-9]{1,4}[^ ]*[0-9] |
+<DATE>[0-9]{1,4}[^ ]*[0-9][ ][0-9]{1,4}[^ ]*[0-9] { SQL_NEW_DATE; }
+
+<STRING>["-""+""*""/"":""("")"",""."";""?""{""}"] { return SQLyytext[0]; } /* */
+<STRING>"[" { return gatherString(']' ,0); }
+<STRING>[^ ':["?"]* { return gatherNamePre(SQLyytext); }
+
+\n {}
+
+[ \t\r]+ {}
+
+"--".*$ {}
+
+. {YY_FATAL_ERROR("Invalid symbol"); return SQL_TOKEN_INVALIDSYMBOL;}
+
+%%
+
+// Kludge around a bug (well, Posix incompatibility) in flex 2.5.x
+// http://bugs.debian.org/cgi-bin/bugreport.cgi?archive=no&bug=189332
+#if YY_FLEX_MAJOR_VERSION >= 2 && YY_FLEX_MINOR_VERSION >= 5
+
+ #ifndef YY_FLUSH_BUFFER
+ #define YY_FLUSH_BUFFER SQLyy_flush_buffer(YY_CURRENT_BUFFER )
+ #endif
+
+ #ifndef yytext_ptr
+ #define yytext_ptr SQLyytext
+ #endif
+
+#endif
+
+// Versions of flex apparently differ in whether input() resp. yyinput() returns
+// zero or EOF upon end of file:
+inline bool checkeof(int c) { return c == 0 || c == EOF; }
+
+/*
+ * Read SQL string literal
+ * Valid strings:
+ * '' 'a string' 'quote '' within string'
+ * "" "a string" "quote "" within string"
+ * nTyp == 0 -> SQL_NODE_NAME
+ * nTyp == 1 -> SQL_NODE_STRING
+ * nTyp == 2 -> SQL_NODE_ACCESS_DATE
+ */
+sal_Int32 gatherString( sal_Int32 delim, sal_Int32 nTyp)
+{
+ sal_Char ch;
+ ::rtl::OStringBuffer sBuffer(256);
+
+ while (!checkeof(ch = yyinput()))
+ {
+ if (ch == delim)
+ {
+ if ((ch = yyinput()) != delim)
+ {
+ if (!checkeof(ch))
+ unput(ch);
+
+ switch(nTyp)
+ {
+ case 0:
+ SQL_NEW_NODE(::rtl::OStringToOUString(sBuffer.makeStringAndClear(),RTL_TEXTENCODING_UTF8), SQL_NODE_NAME);
+ return SQL_TOKEN_NAME;
+ case 1:
+ SQL_NEW_NODE(::rtl::OStringToOUString(sBuffer.makeStringAndClear(),RTL_TEXTENCODING_UTF8), SQL_NODE_STRING);
+ return SQL_TOKEN_STRING;
+ case 2:
+ SQL_NEW_NODE(::rtl::OStringToOUString(sBuffer.makeStringAndClear(),RTL_TEXTENCODING_UTF8), SQL_NODE_ACCESS_DATE);
+ return SQL_TOKEN_ACCESS_DATE;
+ }
+ }
+ else
+ {
+ sBuffer.append(ch);
+ }
+
+ }
+ else if (nTyp != 1 && (ch == '\r' || ch == '\n') )
+ break;
+ else
+ {
+ sBuffer.append(ch);
+ }
+ }
+ YY_FATAL_ERROR("Unterminated name string");
+ return SQL_TOKEN_INVALIDSYMBOL;
+}
+
+sal_Int32 mapEnumToToken(IParseContext::InternationalKeyCode _eKeyCode )
+{
+ sal_Int32 nTokenID = 0;
+ switch( _eKeyCode )
+ {
+ case IParseContext::KEY_LIKE: nTokenID = SQL_TOKEN_LIKE; break;
+ case IParseContext::KEY_NOT: nTokenID = SQL_TOKEN_NOT; break;
+ case IParseContext::KEY_NULL: nTokenID = SQL_TOKEN_NULL; break;
+ case IParseContext::KEY_TRUE: nTokenID = SQL_TOKEN_TRUE; break;
+ case IParseContext::KEY_FALSE: nTokenID = SQL_TOKEN_FALSE; break;
+ case IParseContext::KEY_IS: nTokenID = SQL_TOKEN_IS; break;
+ case IParseContext::KEY_BETWEEN: nTokenID = SQL_TOKEN_BETWEEN; break;
+ case IParseContext::KEY_OR: nTokenID = SQL_TOKEN_OR; break;
+ case IParseContext::KEY_AND: nTokenID = SQL_TOKEN_AND; break;
+ case IParseContext::KEY_AVG: nTokenID = SQL_TOKEN_AVG; break;
+ case IParseContext::KEY_COUNT: nTokenID = SQL_TOKEN_COUNT; break;
+ case IParseContext::KEY_MAX: nTokenID = SQL_TOKEN_MAX; break;
+ case IParseContext::KEY_MIN: nTokenID = SQL_TOKEN_MIN; break;
+ case IParseContext::KEY_SUM: nTokenID = SQL_TOKEN_SUM; break;
+ case IParseContext::KEY_EVERY: nTokenID = SQL_TOKEN_EVERY; break;
+ case IParseContext::KEY_ANY: nTokenID = SQL_TOKEN_ANY; break;
+ case IParseContext::KEY_SOME: nTokenID = SQL_TOKEN_SOME; break;
+ case IParseContext::KEY_STDDEV_POP: nTokenID = SQL_TOKEN_STDDEV_POP; break;
+ case IParseContext::KEY_STDDEV_SAMP: nTokenID = SQL_TOKEN_STDDEV_SAMP; break;
+ case IParseContext::KEY_VAR_SAMP: nTokenID = SQL_TOKEN_VAR_SAMP; break;
+ case IParseContext::KEY_VAR_POP: nTokenID = SQL_TOKEN_VAR_POP; break;
+ case IParseContext::KEY_COLLECT: nTokenID = SQL_TOKEN_COLLECT; break;
+ case IParseContext::KEY_FUSION: nTokenID = SQL_TOKEN_FUSION; break;
+ case IParseContext::KEY_INTERSECTION: nTokenID = SQL_TOKEN_INTERSECTION; break;
+ default:
+ OSL_ENSURE( false, "mapEnumToToken: unsupported key!" );
+ }
+ return nTokenID;
+}
+/*
+ * Read SQL Name literal
+ * Valid Names or internatioanl keywords:
+ * As we have international keywords, we test first on them
+ */
+sal_Int32 gatherName(const sal_Char* text)
+{
+ sal_Int32 nToken;
+ OSL_ENSURE(xxx_pGLOBAL_SQLSCAN,"You forgot to set the scanner!");
+ IParseContext::InternationalKeyCode eKeyCode = xxx_pGLOBAL_SQLSCAN->getInternationalTokenID(text);
+ switch (eKeyCode)
+ {
+ case IParseContext::KEY_LIKE:
+ case IParseContext::KEY_NOT:
+ case IParseContext::KEY_NULL:
+ case IParseContext::KEY_TRUE:
+ case IParseContext::KEY_FALSE:
+ case IParseContext::KEY_IS:
+ case IParseContext::KEY_BETWEEN:
+ case IParseContext::KEY_OR:
+ case IParseContext::KEY_AND:
+ case IParseContext::KEY_COUNT:
+ case IParseContext::KEY_AVG:
+ case IParseContext::KEY_MAX:
+ case IParseContext::KEY_MIN:
+ case IParseContext::KEY_SUM:
+ case IParseContext::KEY_EVERY:
+ case IParseContext::KEY_ANY:
+ case IParseContext::KEY_SOME:
+ case IParseContext::KEY_STDDEV_POP:
+ case IParseContext::KEY_STDDEV_SAMP:
+ case IParseContext::KEY_VAR_SAMP:
+ case IParseContext::KEY_VAR_POP:
+ case IParseContext::KEY_COLLECT:
+ case IParseContext::KEY_FUSION:
+ case IParseContext::KEY_INTERSECTION:
+ nToken = mapEnumToToken(eKeyCode);
+ SQL_NEW_KEYWORD(nToken);
+ break;
+ default:
+ SQL_NEW_NODE(::rtl::OUString(text,strlen(text),RTL_TEXTENCODING_UTF8), SQL_NODE_NAME);
+ return SQL_TOKEN_NAME;
+ }
+}
+/**
+ Read SQL Name literal for predicate check
+ Valid Names or internatioanl keywords:
+ As we have international keywords, we test first on them
+*/
+sal_Int32 gatherNamePre(const sal_Char* text)
+{
+ sal_Int32 nToken;
+ OSL_ENSURE(xxx_pGLOBAL_SQLSCAN,"You forgot to set the scanner!");
+ IParseContext::InternationalKeyCode eKeyCode = xxx_pGLOBAL_SQLSCAN->getInternationalTokenID(text);
+ switch (eKeyCode)
+ {
+ case IParseContext::KEY_LIKE:
+ case IParseContext::KEY_NOT:
+ case IParseContext::KEY_NULL:
+ case IParseContext::KEY_TRUE:
+ case IParseContext::KEY_FALSE:
+ case IParseContext::KEY_IS:
+ case IParseContext::KEY_BETWEEN:
+ case IParseContext::KEY_OR:
+ case IParseContext::KEY_AND:
+ case IParseContext::KEY_COUNT:
+ case IParseContext::KEY_AVG:
+ case IParseContext::KEY_MAX:
+ case IParseContext::KEY_MIN:
+ case IParseContext::KEY_SUM:
+ case IParseContext::KEY_EVERY:
+ case IParseContext::KEY_ANY:
+ case IParseContext::KEY_SOME:
+ case IParseContext::KEY_STDDEV_POP:
+ case IParseContext::KEY_STDDEV_SAMP:
+ case IParseContext::KEY_VAR_SAMP:
+ case IParseContext::KEY_VAR_POP:
+ case IParseContext::KEY_COLLECT:
+ case IParseContext::KEY_FUSION:
+ case IParseContext::KEY_INTERSECTION:
+ nToken = mapEnumToToken(eKeyCode);
+ SQL_NEW_KEYWORD(nToken);
+ break;
+ default:
+ // we need a special handling for parameter
+ {
+ ::rtl::OString sStmt = xxx_pGLOBAL_SQLSCAN->getStatement();
+ sal_Int32 nLength = strlen(text);
+ sal_Int32 nPos = xxx_pGLOBAL_SQLSCAN->GetCurrentPos() - nLength - 2;
+ if (sStmt.getStr()[nPos] == ':')
+ {
+ SQL_NEW_NODE(::rtl::OUString(text,nLength,RTL_TEXTENCODING_UTF8), SQL_NODE_NAME);
+ nToken = SQL_TOKEN_NAME;
+ }
+ else
+ {
+ SQL_NEW_NODE(::rtl::OUString(text,nLength,RTL_TEXTENCODING_UTF8), SQL_NODE_STRING);
+ nToken = SQL_TOKEN_STRING;
+ }
+ }
+ }
+ return nToken;
+}
+
+using namespace connectivity;
+
+static sal_uInt32 Intl_TokenID[] =
+{
+ SQL_TOKEN_LIKE, SQL_TOKEN_NOT, SQL_TOKEN_NULL, SQL_TOKEN_TRUE,
+ SQL_TOKEN_FALSE, SQL_TOKEN_IS, SQL_TOKEN_BETWEEN, SQL_TOKEN_OR,
+ SQL_TOKEN_AND, SQL_TOKEN_AVG, SQL_TOKEN_COUNT, SQL_TOKEN_MAX,
+ SQL_TOKEN_MIN, SQL_TOKEN_SUM
+};
+static bool IN_SQLyyerror;
+//------------------------------------------------------------------------------
+OSQLScanner::OSQLScanner()
+ : m_nCurrentPos(0)
+ , m_bInternational(sal_False)
+ , m_pContext(NULL)
+ , m_nRule(0) // 0 is INITIAL
+{
+ IN_SQLyyerror = false;
+}
+
+//------------------------------------------------------------------------------
+OSQLScanner::~OSQLScanner()
+{
+}
+//------------------------------------------------------------------------------
+void OSQLScanner::SQLyyerror(sal_Char *fmt)
+{
+
+ if(IN_SQLyyerror)
+ return;
+ IN_SQLyyerror = true;
+
+ OSL_ENSURE(m_pContext, "OSQLScanner::SQLyyerror: No Context set");
+ m_sErrorMessage = ::rtl::OUString(fmt,strlen(fmt),RTL_TEXTENCODING_UTF8);
+ if (m_nCurrentPos < m_sStatement.getLength())
+ {
+ m_sErrorMessage += ::rtl::OUString::createFromAscii(": ");
+
+ ::rtl::OUString aError;
+ static sal_Int32 BUFFERSIZE = 256;
+ static sal_Char* Buffer = 0;
+ if(!Buffer)
+ Buffer = new sal_Char[BUFFERSIZE];
+
+ sal_Char *s = Buffer;
+ sal_Int32 nPos = 1;
+ sal_Int32 ch = SQLyytext ? (SQLyytext[0] == 0 ? ' ' : SQLyytext[0]): ' ';
+ *s++ = ch;
+ while (!checkeof(ch = yyinput()))
+ {
+ if (ch == ' ')
+ {
+ if ((ch = yyinput()) != ' ')
+ {
+ if (!checkeof(ch))
+ unput(ch);
+ }
+ *s = '\0';
+ aError = ::rtl::OUString(Buffer,nPos,RTL_TEXTENCODING_UTF8);
+ break;
+ }
+ else
+ {
+ *s++ = ch;
+ if (++nPos == BUFFERSIZE)
+ {
+ ::rtl::OString aBuf(Buffer);
+ delete[] Buffer;
+ BUFFERSIZE *=2;
+ Buffer = new sal_Char[BUFFERSIZE];
+ for(sal_Int32 i=0;i<aBuf.getLength();++i,++Buffer)
+ *Buffer = aBuf.getStr()[i];
+ s = &Buffer[nPos];
+ }
+ }
+ }
+ m_sErrorMessage += aError;
+ delete[] Buffer;
+ Buffer = NULL;
+ }
+ IN_SQLyyerror = false;
+ YY_FLUSH_BUFFER;
+}
+
+//------------------------------------------------------------------------------
+void OSQLScanner::prepareScan(const ::rtl::OUString & rNewStatement, const IParseContext* pContext, sal_Bool bInternational)
+{
+ YY_FLUSH_BUFFER;
+ BEGIN(m_nRule);
+
+ m_sErrorMessage = ::rtl::OUString();
+ m_sStatement = ::rtl::OString(rNewStatement,rNewStatement.getLength(), RTL_TEXTENCODING_UTF8);
+ m_nCurrentPos = 0;
+ m_bInternational = bInternational;
+ m_pContext = pContext;
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 OSQLScanner::SQLyygetc(void)
+{
+ sal_Int32 nPos = (m_nCurrentPos >= m_sStatement.getLength()) ? -1 : m_sStatement.getStr()[m_nCurrentPos];
+ m_nCurrentPos++;
+ return nPos;
+}
+
+//------------------------------------------------------------------------------
+IParseContext::InternationalKeyCode OSQLScanner::getInternationalTokenID(const sal_Char* sToken) const
+{
+ OSL_ENSURE(m_pContext, "OSQLScanner::getInternationalTokenID: No Context set");
+ return (m_bInternational) ? m_pContext->getIntlKeyCode(::rtl::OString(sToken) ) : IParseContext::KEY_NONE;
+}
+// -------------------------------------------------------------------------
+sal_Int32 OSQLScanner::GetCurrentRule() const { return m_nRule; }
+sal_Int32 OSQLScanner::GetGERRule() const { return PREDICATE_GER; }
+sal_Int32 OSQLScanner::GetENGRule() const { return PREDICATE_ENG; }
+sal_Int32 OSQLScanner::GetSQLRule() const { return SQL; }
+sal_Int32 OSQLScanner::GetDATERule() const { return DATE; }
+sal_Int32 OSQLScanner::GetSTRINGRule() const { return STRING; }
+// -------------------------------------------------------------------------
+void OSQLScanner::setScanner(sal_Bool _bNull)
+{
+ xxx_pGLOBAL_SQLSCAN = _bNull ? NULL : this;
+}
+// -------------------------------------------------------------------------
+sal_Int32 OSQLScanner::SQLlex()
+{
+ return SQLyylex();
+}
+
+#if defined __SUNPRO_CC
+#pragma enable_warn
+#elif defined _MSC_VER
+#pragma warning(pop)
+#endif
diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx
new file mode 100644
index 000000000000..e1d805e9a1e5
--- /dev/null
+++ b/connectivity/source/parse/sqliterator.cxx
@@ -0,0 +1,2247 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/sqliterator.hxx"
+#include "connectivity/sdbcx/VTable.hxx"
+#include <connectivity/sqlparse.hxx>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/sqlerror.hxx>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdb/ErrorCondition.hpp>
+#ifdef SQL_TEST_PARSETREEITERATOR
+#include <iostream>
+#endif
+#include "connectivity/PColumn.hxx"
+#include "connectivity/dbtools.hxx"
+#include <tools/diagnose_ex.h>
+#include "TConnection.hxx"
+#include <comphelper/types.hxx>
+#include <connectivity/dbmetadata.hxx>
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+#include "diagnose_ex.h"
+#include <rtl/logfile.hxx>
+
+#define SQL_ISRULEOR2(pParseNode, e1,e2) ((pParseNode)->isRule() && (\
+ (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e1) || \
+ (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e2)))
+
+using namespace ::comphelper;
+using namespace ::connectivity;
+using namespace ::connectivity::sdbcx;
+using namespace ::dbtools;
+using namespace ::connectivity::parse;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+
+namespace connectivity
+{
+ struct OSQLParseTreeIteratorImpl
+ {
+ ::std::vector< TNodePair > m_aJoinConditions;
+ Reference< XConnection > m_xConnection;
+ Reference< XDatabaseMetaData > m_xDatabaseMetaData;
+ Reference< XNameAccess > m_xTableContainer;
+ Reference< XNameAccess > m_xQueryContainer;
+
+ ::boost::shared_ptr< OSQLTables > m_pTables; /// all tables which participate in the SQL statement
+ ::boost::shared_ptr< OSQLTables > m_pSubTables; /// all tables from sub queries not the tables from the select tables
+ ::boost::shared_ptr< QueryNameSet > m_pForbiddenQueryNames;
+
+ sal_uInt32 m_nIncludeMask;
+
+ bool m_bIsCaseSensitive;
+
+ OSQLParseTreeIteratorImpl( const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxTables )
+ :m_xConnection( _rxConnection )
+ ,m_nIncludeMask( OSQLParseTreeIterator::All )
+ ,m_bIsCaseSensitive( true )
+ {
+ OSL_PRECOND( m_xConnection.is(), "OSQLParseTreeIteratorImpl::OSQLParseTreeIteratorImpl: invalid connection!" );
+ m_xDatabaseMetaData = m_xConnection->getMetaData();
+
+ m_bIsCaseSensitive = m_xDatabaseMetaData.is() && m_xDatabaseMetaData->storesMixedCaseQuotedIdentifiers();
+ m_pTables.reset( new OSQLTables( m_bIsCaseSensitive ) );
+ m_pSubTables.reset( new OSQLTables( m_bIsCaseSensitive ) );
+
+ m_xTableContainer = _rxTables;
+
+ DatabaseMetaData aMetaData( m_xConnection );
+ if ( aMetaData.supportsSubqueriesInFrom() )
+ {
+ // connections might support the XQueriesSupplier interface, if they implement the css.sdb.Connection
+ // service
+ Reference< XQueriesSupplier > xSuppQueries( m_xConnection, UNO_QUERY );
+ if ( xSuppQueries.is() )
+ m_xQueryContainer = xSuppQueries->getQueries();
+ }
+ }
+
+ public:
+ inline bool isQueryAllowed( const ::rtl::OUString& _rQueryName )
+ {
+ if ( !m_pForbiddenQueryNames.get() )
+ return true;
+ if ( m_pForbiddenQueryNames->find( _rQueryName ) == m_pForbiddenQueryNames->end() )
+ return true;
+ return false;
+ }
+ };
+
+ //-------------------------------------------------------------------------
+ /** helper class for temporarily adding a query name to a list of forbidden query names
+ */
+ class ForbidQueryName
+ {
+ ::boost::shared_ptr< QueryNameSet >& m_rpAllForbiddenNames;
+ ::rtl::OUString m_sForbiddenQueryName;
+
+ public:
+ ForbidQueryName( OSQLParseTreeIteratorImpl& _rIteratorImpl, const ::rtl::OUString _rForbiddenQueryName )
+ :m_rpAllForbiddenNames( _rIteratorImpl.m_pForbiddenQueryNames )
+ ,m_sForbiddenQueryName( _rForbiddenQueryName )
+ {
+ if ( !m_rpAllForbiddenNames.get() )
+ m_rpAllForbiddenNames.reset( new QueryNameSet );
+ m_rpAllForbiddenNames->insert( m_sForbiddenQueryName );
+ }
+
+ ~ForbidQueryName()
+ {
+ m_rpAllForbiddenNames->erase( m_sForbiddenQueryName );
+ }
+ };
+}
+//-----------------------------------------------------------------------------
+OSQLParseTreeIterator::OSQLParseTreeIterator(const Reference< XConnection >& _rxConnection,
+ const Reference< XNameAccess >& _rxTables,
+ const OSQLParser& _rParser,
+ const OSQLParseNode* pRoot )
+ :m_rParser( _rParser )
+ ,m_pImpl( new OSQLParseTreeIteratorImpl( _rxConnection, _rxTables ) )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::OSQLParseTreeIterator" );
+ setParseTree(pRoot);
+}
+
+//-----------------------------------------------------------------------------
+OSQLParseTreeIterator::OSQLParseTreeIterator( const OSQLParseTreeIterator& _rParentIterator, const OSQLParser& _rParser, const OSQLParseNode* pRoot )
+ :m_rParser( _rParser )
+ ,m_pImpl( new OSQLParseTreeIteratorImpl( _rParentIterator.m_pImpl->m_xConnection, _rParentIterator.m_pImpl->m_xTableContainer ) )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::OSQLParseTreeIterator" );
+ m_pImpl->m_pForbiddenQueryNames = _rParentIterator.m_pImpl->m_pForbiddenQueryNames;
+ setParseTree( pRoot );
+}
+
+//-----------------------------------------------------------------------------
+OSQLParseTreeIterator::~OSQLParseTreeIterator()
+{
+ dispose();
+}
+
+// -----------------------------------------------------------------------------
+const OSQLTables& OSQLParseTreeIterator::getTables() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getTables" );
+ return *m_pImpl->m_pTables;
+}
+
+// -----------------------------------------------------------------------------
+bool OSQLParseTreeIterator::isCaseSensitive() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::isCaseSensitive" );
+ return m_pImpl->m_bIsCaseSensitive;
+}
+
+// -----------------------------------------------------------------------------
+void OSQLParseTreeIterator::dispose()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::dispose" );
+ m_aSelectColumns = NULL;
+ m_aGroupColumns = NULL;
+ m_aOrderColumns = NULL;
+ m_aParameters = NULL;
+ m_pImpl->m_xTableContainer = NULL;
+ m_pImpl->m_xDatabaseMetaData = NULL;
+ m_aCreateColumns = NULL;
+ m_pImpl->m_pTables->clear();
+ m_pImpl->m_pSubTables->clear();
+}
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::setParseTree(const OSQLParseNode * pNewParseTree)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::setParseTree" );
+ m_pImpl->m_pTables->clear();
+ m_pImpl->m_pSubTables->clear();
+
+ m_aSelectColumns = new OSQLColumns();
+ m_aGroupColumns = new OSQLColumns();
+ m_aOrderColumns = new OSQLColumns();
+ m_aParameters = new OSQLColumns();
+ m_aCreateColumns = new OSQLColumns();
+
+ m_pParseTree = pNewParseTree;
+ if (!m_pParseTree)
+ {
+ m_eStatementType = SQL_STATEMENT_UNKNOWN;
+ return;
+ }
+
+ // falls m_pParseTree aber keine Connection, dann Fehler
+ if ( !m_pImpl->m_xTableContainer.is() )
+ return;
+
+ m_aErrors = SQLException();
+
+
+ // Statement-Typ ermitteln ...
+ if (SQL_ISRULE(m_pParseTree,select_statement) || SQL_ISRULE(m_pParseTree,union_statement) )
+ {
+ m_eStatementType = SQL_STATEMENT_SELECT;
+ }
+ else if (SQL_ISRULE(m_pParseTree,insert_statement))
+ {
+ m_eStatementType = SQL_STATEMENT_INSERT;
+ }
+ else if (SQL_ISRULE(m_pParseTree,update_statement_searched))
+ {
+ m_eStatementType = SQL_STATEMENT_UPDATE;
+ }
+ else if (SQL_ISRULE(m_pParseTree,delete_statement_searched))
+ {
+ m_eStatementType = SQL_STATEMENT_DELETE;
+ }
+ else if (m_pParseTree->count() == 3 && SQL_ISRULE(m_pParseTree->getChild(1),odbc_call_spec))
+ {
+ m_eStatementType = SQL_STATEMENT_ODBC_CALL;
+ }
+ else if (SQL_ISRULE(m_pParseTree->getChild(0),base_table_def))
+ {
+ m_eStatementType = SQL_STATEMENT_CREATE_TABLE;
+ m_pParseTree = m_pParseTree->getChild(0);
+ }
+ else
+ {
+ m_eStatementType = SQL_STATEMENT_UNKNOWN;
+ //aIteratorStatus.setInvalidStatement();
+ return;
+ }
+}
+
+//-----------------------------------------------------------------------------
+namespace
+{
+ //.........................................................................
+ static void impl_getRowString( const Reference< XRow >& _rxRow, const sal_Int32 _nColumnIndex, ::rtl::OUString& _out_rString )
+ {
+ _out_rString = _rxRow->getString( _nColumnIndex );
+ if ( _rxRow->wasNull() )
+ _out_rString= ::rtl::OUString();
+ }
+
+ //.........................................................................
+ static ::rtl::OUString lcl_findTableInMetaData(
+ const Reference< XDatabaseMetaData >& _rxDBMeta, const ::rtl::OUString& _rCatalog,
+ const ::rtl::OUString& _rSchema, const ::rtl::OUString& _rTableName )
+ {
+ ::rtl::OUString sComposedName;
+
+ 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_sWildcard = ::rtl::OUString::createFromAscii("%");
+
+ // we want all catalogues, all schemas, all tables
+ Sequence< ::rtl::OUString > sTableTypes(3);
+ sTableTypes[0] = s_sTableTypeView;
+ sTableTypes[1] = s_sTableTypeTable;
+ sTableTypes[2] = s_sWildcard; // just to be sure to include anything else ....
+
+ if ( _rxDBMeta.is() )
+ {
+ sComposedName = ::rtl::OUString();
+
+ Reference< XResultSet> xRes = _rxDBMeta->getTables(
+ _rCatalog.getLength() ? makeAny( _rCatalog ) : Any(), _rSchema.getLength() ? _rSchema : s_sWildcard, _rTableName, sTableTypes );
+
+ Reference< XRow > xCurrentRow( xRes, UNO_QUERY );
+ if ( xCurrentRow.is() && xRes->next() )
+ {
+ ::rtl::OUString sCatalog, sSchema, sName;
+
+ impl_getRowString( xCurrentRow, 1, sCatalog );
+ impl_getRowString( xCurrentRow, 2, sSchema );
+ impl_getRowString( xCurrentRow, 3, sName );
+
+ sComposedName = ::dbtools::composeTableName(
+ _rxDBMeta,
+ sCatalog,
+ sSchema,
+ sName,
+ sal_False,
+ ::dbtools::eInDataManipulation
+ );
+ }
+ }
+ return sComposedName;
+ }
+}
+
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::impl_getQueryParameterColumns( const OSQLTable& _rQuery )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::impl_getQueryParameterColumns" );
+ if ( ( m_pImpl->m_nIncludeMask & Parameters ) != Parameters )
+ // parameters not to be included in the traversal
+ return;
+
+ ::vos::ORef< OSQLColumns > pSubQueryParameterColumns( new OSQLColumns() );
+
+ // get the command and the EscapeProcessing properties from the sub query
+ ::rtl::OUString sSubQueryCommand;
+ sal_Bool bEscapeProcessing = sal_False;
+ try
+ {
+ Reference< XPropertySet > xQueryProperties( _rQuery, UNO_QUERY_THROW );
+ OSL_VERIFY( xQueryProperties->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_COMMAND ) ) >>= sSubQueryCommand );
+ OSL_VERIFY( xQueryProperties->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_ESCAPEPROCESSING ) ) >>= bEscapeProcessing );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // parse the sub query
+ do {
+
+ if ( !bEscapeProcessing || ( sSubQueryCommand.getLength() == 0 ) )
+ break;
+
+ ::rtl::OUString sError;
+ ::std::auto_ptr< OSQLParseNode > pSubQueryNode( const_cast< OSQLParser& >( m_rParser ).parseTree( sError, sSubQueryCommand, sal_False ) );
+ if ( !pSubQueryNode.get() )
+ break;
+
+ OSQLParseTreeIterator aSubQueryIterator( *this, m_rParser, pSubQueryNode.get() );
+ aSubQueryIterator.traverseSome( Parameters | SelectColumns );
+ // SelectColumns might also contain parameters
+ // #i77635# - 2007-07-23 / frank.schoenheit@sun.com
+ pSubQueryParameterColumns = aSubQueryIterator.getParameters();
+ aSubQueryIterator.dispose();
+
+ } while ( false );
+
+ // copy the parameters of the sub query to our own parameter array
+ ::std::copy( pSubQueryParameterColumns->get().begin(), pSubQueryParameterColumns->get().end(),
+ ::std::insert_iterator< OSQLColumns::Vector >( m_aParameters->get(), m_aParameters->get().end() ) );
+}
+
+//-----------------------------------------------------------------------------
+OSQLTable OSQLParseTreeIterator::impl_locateRecordSource( const ::rtl::OUString& _rComposedName )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::impl_locateRecordSource" );
+ if ( !_rComposedName.getLength() )
+ {
+ OSL_ENSURE( false, "OSQLParseTreeIterator::impl_locateRecordSource: no object name at all?" );
+ return OSQLTable();
+ }
+
+ OSQLTable aReturn;
+ ::rtl::OUString sComposedName( _rComposedName );
+
+ try
+ {
+ ::rtl::OUString sCatalog, sSchema, sName;
+ qualifiedNameComponents( m_pImpl->m_xDatabaseMetaData, sComposedName, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
+
+ // check whether there is a query with the given name
+ bool bQueryDoesExist = m_pImpl->m_xQueryContainer.is() && m_pImpl->m_xQueryContainer->hasByName( sComposedName );
+
+ // check whether the table container contains an object with the given name
+ if ( !bQueryDoesExist && !m_pImpl->m_xTableContainer->hasByName( sComposedName ) )
+ sComposedName = lcl_findTableInMetaData( m_pImpl->m_xDatabaseMetaData, sCatalog, sSchema, sName );
+ bool bTableDoesExist = m_pImpl->m_xTableContainer->hasByName( sComposedName );
+
+ // now obtain the object
+
+ // if we're creating a table, and there already is a table or query with the same name,
+ // this is worth an error
+ if ( SQL_STATEMENT_CREATE_TABLE == m_eStatementType )
+ {
+ if ( bQueryDoesExist )
+ impl_appendError( IParseContext::ERROR_INVALID_QUERY_EXIST, &sName );
+ else if ( bTableDoesExist )
+ impl_appendError( IParseContext::ERROR_INVALID_TABLE_EXIST, &sName );
+ else
+ aReturn = impl_createTableObject( sName, sCatalog, sSchema );
+ }
+ else
+ {
+ // queries win over tables, so if there's a query with this name, take this, no matter if
+ // there's a table, too
+ if ( bQueryDoesExist )
+ {
+ if ( !m_pImpl->isQueryAllowed( sComposedName ) )
+ {
+ impl_appendError( m_rParser.getErrorHelper().getSQLException( sdb::ErrorCondition::PARSER_CYCLIC_SUB_QUERIES, NULL ) );
+ return NULL;
+ }
+
+ m_pImpl->m_xQueryContainer->getByName( sComposedName ) >>= aReturn;
+
+ // collect the parameters from the sub query
+ ForbidQueryName aForbidName( *m_pImpl, sComposedName );
+ impl_getQueryParameterColumns( aReturn );
+ }
+ else if ( bTableDoesExist )
+ m_pImpl->m_xTableContainer->getByName( sComposedName ) >>= aReturn;
+ else
+ {
+ if ( m_pImpl->m_xQueryContainer.is() )
+ // the connection on which we're working supports sub queries in from (else
+ // m_xQueryContainer would not have been set), so emit a better error message
+ impl_appendError( IParseContext::ERROR_INVALID_TABLE_OR_QUERY, &sName );
+ else
+ impl_appendError( IParseContext::ERROR_INVALID_TABLE, &sName );
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ impl_appendError( IParseContext::ERROR_INVALID_TABLE, &sComposedName );
+ }
+
+ return aReturn;
+}
+
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::traverseOneTableName( OSQLTables& _rTables,const OSQLParseNode * pTableName, const ::rtl::OUString & rTableRange )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseOneTableName" );
+ if ( ( m_pImpl->m_nIncludeMask & TableNames ) != TableNames )
+ // tables should not be included in the traversal
+ return;
+
+ OSL_ENSURE(pTableName != NULL,"OSQLParseTreeIterator::traverseOneTableName: pTableName == NULL");
+
+ Any aCatalog;
+ ::rtl::OUString aSchema,aTableName,aComposedName;
+ ::rtl::OUString aTableRange(rTableRange);
+
+ // Tabellenname abholen
+ OSQLParseNode::getTableComponents(pTableName,aCatalog,aSchema,aTableName,m_pImpl->m_xDatabaseMetaData);
+
+ // create the composed name like DOMAIN.USER.TABLE1
+ aComposedName = ::dbtools::composeTableName(m_pImpl->m_xDatabaseMetaData,
+ aCatalog.hasValue() ? ::comphelper::getString(aCatalog) : ::rtl::OUString(),
+ aSchema,
+ aTableName,
+ sal_False,
+ ::dbtools::eInDataManipulation);
+
+ // if there is no alias for the table name assign the orignal name to it
+ if ( !aTableRange.getLength() )
+ aTableRange = aComposedName;
+
+ // get the object representing this table/query
+ OSQLTable aTable = impl_locateRecordSource( aComposedName );
+ if ( aTable.is() )
+ _rTables[ aTableRange ] = aTable;
+}
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::impl_fillJoinConditions(const OSQLParseNode* i_pJoinCondition)
+{
+ if (i_pJoinCondition->count() == 3 && // Ausdruck is geklammert
+ SQL_ISPUNCTUATION(i_pJoinCondition->getChild(0),"(") &&
+ SQL_ISPUNCTUATION(i_pJoinCondition->getChild(2),")"))
+ {
+ impl_fillJoinConditions(i_pJoinCondition->getChild(1));
+ }
+ else if (SQL_ISRULEOR2(i_pJoinCondition,search_condition,boolean_term) && // AND/OR-Verknuepfung:
+ i_pJoinCondition->count() == 3)
+ {
+ // nur AND Verknüpfung zulassen
+ if ( SQL_ISTOKEN(i_pJoinCondition->getChild(1),AND) )
+ {
+ impl_fillJoinConditions(i_pJoinCondition->getChild(0));
+ impl_fillJoinConditions(i_pJoinCondition->getChild(1));
+ }
+ }
+ else if (SQL_ISRULE(i_pJoinCondition,comparison_predicate))
+ {
+ // only the comparison of columns is allowed
+ OSL_ENSURE(i_pJoinCondition->count() == 3,"OQueryDesignView::InsertJoinConnection: Fehler im Parse Tree");
+ if (SQL_ISRULE(i_pJoinCondition->getChild(0),column_ref) &&
+ SQL_ISRULE(i_pJoinCondition->getChild(2),column_ref) &&
+ i_pJoinCondition->getChild(1)->getNodeType() == SQL_NODE_EQUAL)
+ {
+ m_pImpl->m_aJoinConditions.push_back( TNodePair(i_pJoinCondition->getChild(0),i_pJoinCondition->getChild(2)) );
+ }
+ }
+}
+//-----------------------------------------------------------------------------
+::std::vector< TNodePair >& OSQLParseTreeIterator::getJoinConditions() const
+{
+ return m_pImpl->m_aJoinConditions;
+}
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::getQualified_join( OSQLTables& _rTables, const OSQLParseNode *pTableRef, ::rtl::OUString& aTableRange )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getQualified_join" );
+ OSL_PRECOND( SQL_ISRULE( pTableRef, cross_union ) || SQL_ISRULE( pTableRef, qualified_join ) ,
+ "OSQLParseTreeIterator::getQualified_join: illegal node!" );
+
+ aTableRange = ::rtl::OUString();
+
+ const OSQLParseNode* pNode = getTableNode(_rTables,pTableRef->getChild(0),aTableRange);
+ if ( isTableNode( pNode ) )
+ traverseOneTableName( _rTables, pNode, aTableRange );
+
+ sal_uInt32 nPos = 4;
+ if( SQL_ISRULE(pTableRef,cross_union) || pTableRef->getChild(1)->getTokenID() != SQL_TOKEN_NATURAL)
+ {
+ nPos = 3;
+ // join_condition,named_columns_join
+ if ( SQL_ISRULE( pTableRef, qualified_join ) )
+ {
+ const OSQLParseNode* pJoin_spec = pTableRef->getChild(4);
+ if ( SQL_ISRULE( pJoin_spec, join_condition ) )
+ {
+ impl_fillJoinConditions(pJoin_spec->getChild(1));
+ }
+ else
+ {
+ const OSQLParseNode* pColumnCommalist = pJoin_spec->getChild(2);
+ // Alle Columns in der column_commalist ...
+ for (sal_uInt32 i = 0; i < pColumnCommalist->count(); i++)
+ {
+ const OSQLParseNode * pCol = pColumnCommalist->getChild(i);
+ // add twice because the column must exists in both tables
+ m_pImpl->m_aJoinConditions.push_back( TNodePair(pCol,pCol) );
+ }
+ }
+ }
+ }
+
+ pNode = getTableNode(_rTables,pTableRef->getChild(nPos),aTableRange);
+ if ( isTableNode( pNode ) )
+ traverseOneTableName( _rTables, pNode, aTableRange );
+}
+//-----------------------------------------------------------------------------
+const OSQLParseNode* OSQLParseTreeIterator::getTableNode( OSQLTables& _rTables, const OSQLParseNode *pTableRef,::rtl::OUString& rTableRange )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getTableNode" );
+ OSL_PRECOND( SQL_ISRULE( pTableRef, table_ref ) || SQL_ISRULE( pTableRef, joined_table )
+ || SQL_ISRULE( pTableRef, qualified_join ) || SQL_ISRULE( pTableRef, cross_union ),
+ "OSQLParseTreeIterator::getTableNode: only to be called for table_ref nodes!" );
+
+ const OSQLParseNode* pTableNameNode = NULL;
+
+ if ( SQL_ISRULE( pTableRef, joined_table ) )
+ {
+ getQualified_join( _rTables, pTableRef->getChild(1), rTableRange );
+ }
+ if ( SQL_ISRULE( pTableRef, qualified_join ) || SQL_ISRULE( pTableRef, cross_union ) )
+ {
+ getQualified_join( _rTables, pTableRef, rTableRange );
+ }
+ else
+ {
+ rTableRange = OSQLParseNode::getTableRange(pTableRef);
+ if ( ( pTableRef->count() == 4 ) // '{' SQL_TOKEN_OJ joined_table '}'
+ || ( pTableRef->count() == 5 ) // '(' joined_table ')' range_variable op_column_commalist
+ )
+ {
+ getQualified_join( _rTables, pTableRef->getChild(6 - pTableRef->count()), rTableRange );
+ }
+ else if ( pTableRef->count() == 3 ) // subquery range_variable op_column_commalist || '(' joined_table ')'
+ {
+ const OSQLParseNode* pSubQuery = pTableRef->getChild(0);
+ if ( pSubQuery->isToken() )
+ {
+ getQualified_join( _rTables, pTableRef->getChild(1), rTableRange );
+ }
+ else
+ {
+ OSL_ENSURE( pSubQuery->count() == 3, "sub queries should have 3 children!" );
+ const OSQLParseNode* pQueryExpression = pSubQuery->getChild(1);
+ if ( SQL_ISRULE( pQueryExpression, select_statement ) )
+ {
+ getSelect_statement( *m_pImpl->m_pSubTables, pQueryExpression );
+ }
+ else
+ {
+ OSL_ENSURE( false, "OSQLParseTreeIterator::getTableNode: subquery which is no select_statement: not yet implemented!" );
+ }
+ }
+ }
+ else if ( pTableRef->count() == 2 ) // table_node table_primary_as_range_column
+ {
+ pTableNameNode = pTableRef->getChild(0);
+ }
+ else
+ OSL_ENSURE( false, "OSQLParseTreeIterator::getTableNode: unhandled case!" );
+ }
+
+ return pTableNameNode;
+}
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::getSelect_statement(OSQLTables& _rTables,const OSQLParseNode* pSelect)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getSelect_statement" );
+ if(SQL_ISRULE(pSelect,union_statement))
+ {
+ getSelect_statement(_rTables,pSelect->getChild(0));
+ //getSelect_statement(pSelect->getChild(3));
+ return;
+ }
+ OSQLParseNode * pTableRefCommalist = pSelect->getChild(3)->getChild(0)->getChild(1);
+
+ OSL_ENSURE(pTableRefCommalist != NULL,"OSQLParseTreeIterator: error in parse tree!");
+ OSL_ENSURE(SQL_ISRULE(pTableRefCommalist,table_ref_commalist),"OSQLParseTreeIterator: error in parse tree!");
+
+ const OSQLParseNode* pTableName = NULL;
+ ::rtl::OUString aTableRange;
+ for (sal_uInt32 i = 0; i < pTableRefCommalist->count(); i++)
+ { // from clause durchlaufen
+ aTableRange = ::rtl::OUString();
+
+ const OSQLParseNode* pTableListElement = pTableRefCommalist->getChild(i);
+ if ( isTableNode( pTableListElement ) )
+ {
+ traverseOneTableName( _rTables, pTableListElement, aTableRange );
+ }
+ else if ( SQL_ISRULE( pTableListElement, table_ref ) )
+ {
+ // Tabellenreferenz kann aus Tabellennamen, Tabellennamen (+),'('joined_table')'(+) bestehen
+ pTableName = pTableListElement->getChild(0);
+ if( isTableNode( pTableName ) )
+ { // Tabellennamen gefunden
+ aTableRange = OSQLParseNode::getTableRange(pTableListElement);
+ traverseOneTableName( _rTables, pTableName, aTableRange );
+ }
+ else if(SQL_ISPUNCTUATION(pTableName,"{"))
+ { // '{' SQL_TOKEN_OJ joined_table '}'
+ getQualified_join( _rTables, pTableListElement->getChild(2), aTableRange );
+ }
+ else
+ { // '(' joined_table ')' range_variable op_column_commalist
+ getTableNode( _rTables, pTableListElement, aTableRange );
+ }
+ }
+ else if (SQL_ISRULE( pTableListElement, qualified_join ) || SQL_ISRULE( pTableListElement, cross_union ) )
+ {
+ getQualified_join( _rTables, pTableListElement, aTableRange );
+ }
+ else if ( SQL_ISRULE( pTableListElement, joined_table ) )
+ {
+ getQualified_join( _rTables, pTableListElement->getChild(1), aTableRange );
+ }
+
+ // if (! aIteratorStatus.IsSuccessful()) break;
+ }
+}
+//-----------------------------------------------------------------------------
+bool OSQLParseTreeIterator::traverseTableNames(OSQLTables& _rTables)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseTableNames" );
+ if ( m_pParseTree == NULL )
+ return false;
+
+ OSQLParseNode* pTableName = NULL;
+
+ switch ( m_eStatementType )
+ {
+ case SQL_STATEMENT_SELECT:
+ getSelect_statement( _rTables, m_pParseTree );
+ break;
+
+ case SQL_STATEMENT_CREATE_TABLE:
+ case SQL_STATEMENT_INSERT:
+ case SQL_STATEMENT_DELETE:
+ pTableName = m_pParseTree->getChild(2);
+ break;
+
+ case SQL_STATEMENT_UPDATE:
+ pTableName = m_pParseTree->getChild(1);
+ break;
+ default:
+ break;
+ }
+
+ if ( pTableName )
+ {
+ ::rtl::OUString sTableRange;
+ traverseOneTableName( _rTables, pTableName, sTableRange );
+ }
+
+ return !hasErrors();
+}
+//-----------------------------------------------------------------------------
+::rtl::OUString OSQLParseTreeIterator::getColumnAlias(const OSQLParseNode* _pDerivedColumn)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getColumnAlias" );
+ OSL_ENSURE(SQL_ISRULE(_pDerivedColumn,derived_column),"No derived column!");
+ ::rtl::OUString sColumnAlias;
+ if(_pDerivedColumn->getChild(1)->count() == 2)
+ sColumnAlias = _pDerivedColumn->getChild(1)->getChild(1)->getTokenValue();
+ else if(!_pDerivedColumn->getChild(1)->isRule())
+ sColumnAlias = _pDerivedColumn->getChild(1)->getTokenValue();
+ return sColumnAlias;
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ void lcl_getColumnRange( const OSQLParseNode* _pColumnRef, const Reference< XConnection >& _rxConnection,
+ ::rtl::OUString& _out_rColumnName, ::rtl::OUString& _out_rTableRange,
+ const OSQLColumns* _pSelectColumns, ::rtl::OUString& _out_rColumnAliasIfPresent )
+ {
+ _out_rColumnName = _out_rTableRange = _out_rColumnAliasIfPresent = ::rtl::OUString();
+ if ( SQL_ISRULE( _pColumnRef, column_ref ) )
+ {
+ if( _pColumnRef->count() > 1 )
+ {
+ for ( sal_Int32 i=0; i<((sal_Int32)_pColumnRef->count())-2; ++i )
+ _pColumnRef->getChild(i)->parseNodeToStr( _out_rTableRange, _rxConnection, NULL, sal_False, sal_False );
+ _out_rColumnName = _pColumnRef->getChild( _pColumnRef->count()-1 )->getChild(0)->getTokenValue();
+ }
+ else
+ _out_rColumnName = _pColumnRef->getChild(0)->getTokenValue();
+
+ // look up the column in the select column, to find an possible alias
+ if ( _pSelectColumns )
+ {
+ for ( OSQLColumns::Vector::const_iterator lookupColumn = _pSelectColumns->get().begin();
+ lookupColumn != _pSelectColumns->get().end();
+ ++lookupColumn
+ )
+ {
+ Reference< XPropertySet > xColumn( *lookupColumn );
+ try
+ {
+ ::rtl::OUString sName, sTableName;
+ xColumn->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_REALNAME ) ) >>= sName;
+ xColumn->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_TABLENAME ) ) >>= sTableName;
+ if ( sName == _out_rColumnName && sTableName == _out_rTableRange )
+ xColumn->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_NAME ) ) >>= _out_rColumnAliasIfPresent;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ }
+ else if(SQL_ISRULE(_pColumnRef,general_set_fct) || SQL_ISRULE(_pColumnRef,set_fct_spec))
+ { // Funktion
+ _pColumnRef->parseNodeToStr( _out_rColumnName, _rxConnection );
+ }
+ else if(_pColumnRef->getNodeType() == SQL_NODE_NAME)
+ _out_rColumnName = _pColumnRef->getTokenValue();
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OSQLParseTreeIterator::getColumnRange( const OSQLParseNode* _pColumnRef,
+ ::rtl::OUString& _rColumnName,
+ ::rtl::OUString& _rTableRange) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getColumnRange" );
+ ::rtl::OUString sDummy;
+ lcl_getColumnRange( _pColumnRef, m_pImpl->m_xConnection, _rColumnName, _rTableRange, NULL, sDummy );
+}
+
+// -----------------------------------------------------------------------------
+void OSQLParseTreeIterator::getColumnRange( const OSQLParseNode* _pColumnRef,
+ ::rtl::OUString& _rColumnName,
+ ::rtl::OUString& _rTableRange,
+ ::rtl::OUString& _out_rColumnAliasIfPresent ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getColumnRange" );
+ lcl_getColumnRange( _pColumnRef, m_pImpl->m_xConnection, _rColumnName, _rTableRange, &*m_aSelectColumns, _out_rColumnAliasIfPresent );
+}
+
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::getColumnRange( const OSQLParseNode* _pColumnRef,
+ const Reference< XConnection >& _rxConnection, ::rtl::OUString& _out_rColumnName, ::rtl::OUString& _out_rTableRange )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getColumnRange" );
+ ::rtl::OUString sDummy;
+ lcl_getColumnRange( _pColumnRef, _rxConnection, _out_rColumnName, _out_rTableRange, NULL, sDummy );
+}
+
+//-----------------------------------------------------------------------------
+sal_Bool OSQLParseTreeIterator::getColumnTableRange(const OSQLParseNode* pNode, ::rtl::OUString &rTableRange) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getColumnTableRange" );
+ // Ermitteln ob alle Spalten zu einer Tabelle gehoeren
+ if (SQL_ISRULE(pNode,column_ref))
+ {
+ ::rtl::OUString aColName, aTableRange;
+ getColumnRange(pNode, aColName, aTableRange);
+ if (!aTableRange.getLength()) // keinen gefunden
+ {
+ // dann die Spalte in den Tabellen suchen
+ for (ConstOSQLTablesIterator aIter = m_pImpl->m_pTables->begin(); aIter != m_pImpl->m_pTables->end(); ++aIter)
+ {
+ if (aIter->second.is())
+ {
+ try
+ {
+ Reference< XNameAccess > xColumns = aIter->second->getColumns();
+ if(xColumns->hasByName(aColName))
+ {
+ Reference< XPropertySet > xColumn;
+ if (xColumns->getByName(aColName) >>= xColumn)
+ {
+ OSL_ENSURE(xColumn.is(),"Column isn't a propertyset!");
+ aTableRange = aIter->first;
+ break;
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ }
+ if (!aTableRange.getLength())
+ return sal_False;
+ }
+
+
+ if (!rTableRange.getLength())
+ rTableRange = aTableRange;
+ else if (rTableRange != aTableRange)
+ return sal_False;
+ }
+ else
+ {
+ for (sal_uInt32 i = 0, ncount = pNode->count(); i < ncount; i++)
+ {
+ if (!getColumnTableRange(pNode->getChild(i), rTableRange))
+ return sal_False;
+ }
+ }
+ return sal_True;
+}
+
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::traverseCreateColumns(const OSQLParseNode* pSelectNode)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseCreateColumns" );
+ // aIteratorStatus.Clear();
+
+ if (!pSelectNode || m_eStatementType != SQL_STATEMENT_CREATE_TABLE || m_pImpl->m_pTables->empty())
+ {
+ impl_appendError( IParseContext::ERROR_GENERAL );
+ return;
+ }
+ if (!SQL_ISRULE(pSelectNode,base_table_element_commalist))
+ return ;
+
+ for (sal_uInt32 i = 0; i < pSelectNode->count(); i++)
+ {
+ OSQLParseNode *pColumnRef = pSelectNode->getChild(i);
+
+ if (SQL_ISRULE(pColumnRef,column_def))
+ {
+ ::rtl::OUString aColumnName;
+ ::rtl::OUString aTypeName;
+ ::rtl::OUString aTableRange;
+ sal_Int32 nType = DataType::VARCHAR;
+ sal_Int32 nLen = 0;
+ aColumnName = pColumnRef->getChild(0)->getTokenValue();
+
+ OSQLParseNode *pDatatype = pColumnRef->getChild(1);
+ if (pDatatype && SQL_ISRULE(pDatatype,character_string_type))
+ {
+ const OSQLParseNode *pType = pDatatype->getChild(0);
+ aTypeName = pType->getTokenValue();
+ if (pDatatype->count() == 2 && (pType->getTokenID() == SQL_TOKEN_CHAR || pType->getTokenID() == SQL_TOKEN_CHARACTER ))
+ nType = DataType::CHAR;
+
+ const OSQLParseNode *pParams = pDatatype->getChild(pDatatype->count()-1);
+ if ( pParams->count() )
+ {
+ nLen = pParams->getChild(1)->getTokenValue().toInt32();
+ }
+ }
+ else if(pDatatype && pDatatype->getNodeType() == SQL_NODE_KEYWORD)
+ {
+ aTypeName = ::rtl::OUString::createFromAscii("VARCHAR");
+ }
+
+ if (aTypeName.getLength())
+ {
+ //TODO:Create a new class for create statement to handle field length
+ OParseColumn* pColumn = new OParseColumn(aColumnName,aTypeName,::rtl::OUString(),::rtl::OUString(),
+ ColumnValue::NULLABLE_UNKNOWN,0,0,nType,sal_False,sal_False,isCaseSensitive());
+ pColumn->setFunction(sal_False);
+ pColumn->setRealName(aColumnName);
+
+ Reference< XPropertySet> xCol = pColumn;
+ m_aCreateColumns->get().push_back(xCol);
+ }
+ }
+
+ }
+}
+//-----------------------------------------------------------------------------
+bool OSQLParseTreeIterator::traverseSelectColumnNames(const OSQLParseNode* pSelectNode)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseSelectColumnNames" );
+ if ( ( m_pImpl->m_nIncludeMask & SelectColumns ) != SelectColumns )
+ return true;
+
+ if (!pSelectNode || m_eStatementType != SQL_STATEMENT_SELECT || m_pImpl->m_pTables->empty())
+ {
+ impl_appendError( IParseContext::ERROR_GENERAL );
+ return false;
+ }
+
+ if(SQL_ISRULE(pSelectNode,union_statement))
+ {
+ return traverseSelectColumnNames( pSelectNode->getChild( 0 ) )
+ /*&& traverseSelectColumnNames( pSelectNode->getChild( 3 ) )*/;
+ }
+
+ static ::rtl::OUString aEmptyString;
+ // nyi: mehr Pruefung auf korrekte Struktur!
+ if (pSelectNode->getChild(2)->isRule() && SQL_ISPUNCTUATION(pSelectNode->getChild(2)->getChild(0),"*"))
+ {
+ // SELECT * ...
+ setSelectColumnName(m_aSelectColumns,::rtl::OUString::createFromAscii("*"), aEmptyString,aEmptyString);
+ }
+ else if (SQL_ISRULE(pSelectNode->getChild(2),scalar_exp_commalist))
+ {
+ // SELECT column[,column] oder SELECT COUNT(*) ...
+ OSQLParseNode * pSelection = pSelectNode->getChild(2);
+
+ for (sal_uInt32 i = 0; i < pSelection->count(); i++)
+ {
+ OSQLParseNode *pColumnRef = pSelection->getChild(i);
+
+ //if (SQL_ISRULE(pColumnRef,select_sublist))
+ if (SQL_ISRULE(pColumnRef,derived_column) &&
+ SQL_ISRULE(pColumnRef->getChild(0),column_ref) &&
+ pColumnRef->getChild(0)->count() == 3 &&
+ SQL_ISPUNCTUATION(pColumnRef->getChild(0)->getChild(2),"*"))
+ {
+ // alle Spalten der Tabelle
+ ::rtl::OUString aTableRange;
+ pColumnRef->getChild(0)->parseNodeToStr( aTableRange, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
+ setSelectColumnName(m_aSelectColumns,::rtl::OUString::createFromAscii("*"), aEmptyString,aTableRange);
+ continue;
+ }
+ else if (SQL_ISRULE(pColumnRef,derived_column))
+ {
+ ::rtl::OUString aColumnAlias(getColumnAlias(pColumnRef)); // kann leer sein
+ ::rtl::OUString sColumnName;
+ ::rtl::OUString aTableRange;
+ sal_Int32 nType = DataType::VARCHAR;
+ sal_Bool bFkt(sal_False);
+ pColumnRef = pColumnRef->getChild(0);
+ if (
+ pColumnRef->count() == 3 &&
+ SQL_ISPUNCTUATION(pColumnRef->getChild(0),"(") &&
+ SQL_ISPUNCTUATION(pColumnRef->getChild(2),")")
+ )
+ pColumnRef = pColumnRef->getChild(1);
+
+ if (SQL_ISRULE(pColumnRef,column_ref))
+ {
+ getColumnRange(pColumnRef,sColumnName,aTableRange);
+ OSL_ENSURE(sColumnName.getLength(),"Columnname darf nicht leer sein");
+ }
+ else /*if (SQL_ISRULE(pColumnRef,general_set_fct) || SQL_ISRULE(pColumnRef,set_fct_spec) ||
+ SQL_ISRULE(pColumnRef,position_exp) || SQL_ISRULE(pColumnRef,extract_exp) ||
+ SQL_ISRULE(pColumnRef,length_exp) || SQL_ISRULE(pColumnRef,char_value_fct)||
+ SQL_ISRULE(pColumnRef,num_value_exp) || SQL_ISRULE(pColumnRef,term))*/
+ {
+ /* Funktionsaufruf vorhanden */
+ pColumnRef->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_True );
+ ::rtl::OUString sTableRange;
+ // check if the column is also a parameter
+ traverseORCriteria(pColumnRef); // num_value_exp
+
+ // gehoeren alle beteiligten Spalten der Funktion zu einer Tabelle
+ if (m_pImpl->m_pTables->size() == 1)
+ {
+ aTableRange = m_pImpl->m_pTables->begin()->first;
+ }
+ else
+ {
+ getColumnTableRange(pColumnRef,aTableRange);
+ }
+ if ( pColumnRef->isRule() )
+ {
+ bFkt = sal_True;
+ nType = getFunctionReturnType(pColumnRef);
+ }
+ }
+ /*
+ else
+ {
+ aIteratorStatus.setStatementTooComplex();
+ return;
+ }
+ */
+ if(!aColumnAlias.getLength())
+ aColumnAlias = sColumnName;
+ setSelectColumnName(m_aSelectColumns,sColumnName,aColumnAlias,aTableRange,bFkt,nType,SQL_ISRULE(pColumnRef,general_set_fct) || SQL_ISRULE(pColumnRef,set_fct_spec));
+ }
+ }
+ }
+
+ return !hasErrors();
+}
+
+
+//-----------------------------------------------------------------------------
+bool OSQLParseTreeIterator::traverseOrderByColumnNames(const OSQLParseNode* pSelectNode)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseOrderByColumnNames" );
+ traverseByColumnNames( pSelectNode, sal_True );
+ return !hasErrors();
+}
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::traverseByColumnNames(const OSQLParseNode* pSelectNode,sal_Bool _bOrder)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseByColumnNames" );
+ // aIteratorStatus.Clear();
+
+ if (pSelectNode == NULL)
+ {
+ //aIteratorStatus.setInvalidStatement();
+ return;
+ }
+
+ if (m_eStatementType != SQL_STATEMENT_SELECT)
+ {
+ //aIteratorStatus.setInvalidStatement();
+ return;
+ }
+
+ if(SQL_ISRULE(pSelectNode,union_statement))
+ {
+ traverseByColumnNames(pSelectNode->getChild(0),_bOrder);
+ return;
+ }
+
+ OSL_ENSURE(pSelectNode->count() >= 4,"OSQLParseTreeIterator: error in parse tree!");
+
+ OSQLParseNode * pTableExp = pSelectNode->getChild(3);
+ OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!");
+ OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator:table_exp error in parse tree!");
+ OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!");
+
+ sal_uInt32 nPos = ( _bOrder ? 4 : 2 );
+
+ OSQLParseNode * pOptByClause = pTableExp->getChild(nPos);
+ OSL_ENSURE(pOptByClause != NULL,"OSQLParseTreeIterator: error in parse tree!");
+ if ( pOptByClause->count() == 0 )
+ return;
+
+ OSL_ENSURE(pOptByClause->count() == 3,"OSQLParseTreeIterator: error in parse tree!");
+
+ OSQLParseNode * pOrderingSpecCommalist = pOptByClause->getChild(2);
+ OSL_ENSURE(pOrderingSpecCommalist != NULL,"OSQLParseTreeIterator: error in parse tree!");
+ OSL_ENSURE(!_bOrder || SQL_ISRULE(pOrderingSpecCommalist,ordering_spec_commalist),"OSQLParseTreeIterator:ordering_spec_commalist error in parse tree!");
+ OSL_ENSURE(pOrderingSpecCommalist->count() > 0,"OSQLParseTreeIterator: error in parse tree!");
+
+ ::rtl::OUString sColumnName,aColumnAlias;
+ ::rtl::OUString aTableRange;
+ sal_uInt32 nCount = pOrderingSpecCommalist->count();
+ for (sal_uInt32 i = 0; i < nCount; ++i)
+ {
+ OSQLParseNode* pColumnRef = pOrderingSpecCommalist->getChild(i);
+ OSL_ENSURE(pColumnRef != NULL,"OSQLParseTreeIterator: error in parse tree!");
+ if ( _bOrder )
+ {
+ OSL_ENSURE(SQL_ISRULE(pColumnRef,ordering_spec),"OSQLParseTreeIterator:ordering_spec error in parse tree!");
+ OSL_ENSURE(pColumnRef->count() == 2,"OSQLParseTreeIterator: error in parse tree!");
+
+ pColumnRef = pColumnRef->getChild(0);
+ }
+ aTableRange = ::rtl::OUString();
+ sColumnName = ::rtl::OUString();
+ if ( SQL_ISRULE(pColumnRef,column_ref) )
+ {
+ // Column-Name (und TableRange):
+ if(SQL_ISRULE(pColumnRef,column_ref))
+ getColumnRange(pColumnRef,sColumnName,aTableRange);
+ else // eine Expression
+ pColumnRef->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
+
+ OSL_ENSURE(sColumnName.getLength(),"sColumnName darf nicht leer sein");
+ }
+ else
+ { // here I found a predicate
+ pColumnRef->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
+ }
+ OSL_ENSURE(pColumnRef != NULL,"OSQLParseTreeIterator: error in parse tree!");
+ if ( _bOrder )
+ {
+ // Ascending/Descending
+ OSQLParseNode * pOptAscDesc = pColumnRef->getParent()->getChild(1);
+ OSL_ENSURE(pOptAscDesc != NULL,"OSQLParseTreeIterator: error in parse tree!");
+
+ sal_Bool bAscending = pOptAscDesc && SQL_ISTOKEN(pOptAscDesc,ASC);
+ setOrderByColumnName(sColumnName, aTableRange,bAscending);
+ }
+ else
+ setGroupByColumnName(sColumnName, aTableRange);
+ }
+}
+//-----------------------------------------------------------------------------
+bool OSQLParseTreeIterator::traverseGroupByColumnNames(const OSQLParseNode* pSelectNode)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseGroupByColumnNames" );
+ traverseByColumnNames( pSelectNode, sal_False );
+ return !hasErrors();
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ ::rtl::OUString lcl_generateParameterName( const OSQLParseNode& _rParentNode, const OSQLParseNode& _rParamNode )
+ {
+ ::rtl::OUString sColumnName( RTL_CONSTASCII_USTRINGPARAM( "param" ) );
+ const sal_Int32 nCount = (sal_Int32)_rParentNode.count();
+ for ( sal_Int32 i = 0; i < nCount; ++i )
+ {
+ if ( _rParentNode.getChild(i) == &_rParamNode )
+ {
+ sColumnName += ::rtl::OUString::valueOf( i+1 );
+ break;
+ }
+ }
+ return sColumnName;
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OSQLParseTreeIterator::traverseParameters(const OSQLParseNode* _pNode)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseParameters" );
+ if ( _pNode == NULL )
+ return;
+
+ ::rtl::OUString sColumnName, sTableRange, aColumnAlias;
+ const OSQLParseNode* pParent = _pNode->getParent();
+ if ( pParent != NULL )
+ {
+ if ( SQL_ISRULE(pParent,comparison_predicate) ) // x = X
+ {
+ sal_uInt32 nPos = 0;
+ if ( pParent->getChild(nPos) == _pNode )
+ nPos = 2;
+ const OSQLParseNode* pOther = pParent->getChild(nPos);
+ if ( SQL_ISRULE( pOther, column_ref ) )
+ getColumnRange( pOther, sColumnName, sTableRange, aColumnAlias);
+ else
+ pOther->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
+ } // if ( SQL_ISRULE(pParent,comparison_predicate) ) // x = X
+ else if ( SQL_ISRULE(pParent,other_like_predicate_part_2) )
+ {
+ const OSQLParseNode* pOther = pParent->getParent()->getChild(0);
+ if ( SQL_ISRULE( pOther, column_ref ) )
+ getColumnRange( pOther, sColumnName, sTableRange, aColumnAlias);
+ else
+ pOther->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
+ }
+ else if ( SQL_ISRULE(pParent,between_predicate_part_2) )
+ {
+ const OSQLParseNode* pOther = pParent->getParent()->getChild(0);
+ if ( SQL_ISRULE( pOther, column_ref ) )
+ getColumnRange( pOther, sColumnName, sTableRange, aColumnAlias);
+ else
+ {
+ pOther->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
+ lcl_generateParameterName( *pParent, *_pNode );
+ }
+ }
+ else if ( pParent->getNodeType() == SQL_NODE_COMMALISTRULE )
+ {
+ lcl_generateParameterName( *pParent, *_pNode );
+ }
+ }
+ traverseParameter( _pNode, pParent, sColumnName, sTableRange, aColumnAlias );
+ const sal_uInt32 nCount = _pNode->count();
+ for (sal_uInt32 i = 0; i < nCount; ++i)
+ {
+ const OSQLParseNode* pChild = _pNode->getChild(i);
+ traverseParameters( pChild );
+ }
+}
+//-----------------------------------------------------------------------------
+bool OSQLParseTreeIterator::traverseSelectionCriteria(const OSQLParseNode* pSelectNode)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseSelectionCriteria" );
+ if ( pSelectNode == NULL )
+ return false;
+
+
+ // Parse Tree analysieren (je nach Statement-Typ)
+ // und Zeiger auf WHERE-Klausel setzen:
+ OSQLParseNode * pWhereClause = NULL;
+
+ if (m_eStatementType == SQL_STATEMENT_SELECT)
+ {
+ if(SQL_ISRULE(pSelectNode,union_statement))
+ {
+ return traverseSelectionCriteria( pSelectNode->getChild( 0 ) )
+ && traverseSelectionCriteria( pSelectNode->getChild( 3 ) );
+ }
+ OSL_ENSURE(pSelectNode->count() >= 4,"OSQLParseTreeIterator: error in parse tree!");
+
+ OSQLParseNode * pTableExp = pSelectNode->getChild(3);
+ OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!");
+ OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!");
+ OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!");
+
+ pWhereClause = pTableExp->getChild(1);
+ } else if (SQL_ISRULE(pSelectNode,update_statement_searched)) {
+ OSL_ENSURE(pSelectNode->count() == 5,"OSQLParseTreeIterator: error in parse tree!");
+ pWhereClause = pSelectNode->getChild(4);
+ } else if (SQL_ISRULE(pSelectNode,delete_statement_searched)) {
+ OSL_ENSURE(pSelectNode->count() == 4,"OSQLParseTreeIterator: error in parse tree!");
+ pWhereClause = pSelectNode->getChild(3);
+ } else if (SQL_ISRULE(pSelectNode,delete_statement_positioned)) {
+ // nyi
+ OSL_ASSERT("OSQLParseTreeIterator::getSelectionCriteria: positioned nyi");
+ } else {
+ // Anderes Statement. Keine Selektionskriterien.
+ return false;
+ }
+
+ if (! SQL_ISRULE(pWhereClause,where_clause)) {
+ // Die Where Clause ist meistens optional, d. h. es koennte sich auch
+ // um "optional_where_clause" handeln.
+ OSL_ENSURE(SQL_ISRULE(pWhereClause,opt_where_clause),"OSQLParseTreeIterator: error in parse tree!");
+ return false;
+ }
+
+ // Wenn es aber eine where_clause ist, dann darf sie nicht leer sein:
+ OSL_ENSURE(pWhereClause->count() == 2,"OSQLParseTreeIterator: error in parse tree!");
+
+ OSQLParseNode * pComparisonPredicate = pWhereClause->getChild(1);
+ OSL_ENSURE(pComparisonPredicate != NULL,"OSQLParseTreeIterator: error in parse tree!");
+
+ //
+ // Und nun die Vergleichskriterien abarbeiten (rekursiv, alles ist erstmal ein OR-Kriterium):
+ //
+
+ traverseORCriteria(pComparisonPredicate);
+
+ return !hasErrors();
+}
+
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::traverseORCriteria(OSQLParseNode * pSearchCondition)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseORCriteria" );
+
+
+ if (
+ pSearchCondition->count() == 3 &&
+ SQL_ISPUNCTUATION(pSearchCondition->getChild(0),"(") &&
+ SQL_ISPUNCTUATION(pSearchCondition->getChild(2),")")
+ )
+ {
+ // Runde Klammern um den Ausdruck
+ traverseORCriteria(pSearchCondition->getChild(1));
+ } else if (SQL_ISRULE(pSearchCondition,search_condition) &&
+ pSearchCondition->count() == 3 &&
+ SQL_ISTOKEN(pSearchCondition->getChild(1),OR))
+ {
+ // OR-Verknuepfung:
+
+ for (int i = 0; i < 3; i++) {
+ if (i == 1) continue; // Schluesselwort OR ueberspringen
+
+ // Ist das erste Element wieder eine OR-Verknuepfung?
+ if (i == 0 &&
+ SQL_ISRULE(pSearchCondition->getChild(0),search_condition) &&
+ pSearchCondition->getChild(0)->count() == 3 &&
+ SQL_ISTOKEN(pSearchCondition->getChild(0)->getChild(1),OR))
+ {
+ // Dann rekursiv absteigen ...
+ traverseORCriteria(pSearchCondition->getChild(0));
+
+ } else {
+ // AND-Kriterien ...
+ traverseANDCriteria(pSearchCondition->getChild(i));
+ // if (! aIteratorStatus.IsSuccessful()) break;
+ }
+
+ // if (! aIteratorStatus.IsSuccessful()) break;
+ }
+ } else {
+ // Nur *ein* Kriterium oder eine AND-Verknuepfung von Kriterien.
+ // Direkt die AND-Kriterien behandeln.
+ traverseANDCriteria(pSearchCondition);
+ // if (! aIteratorStatus.IsSuccessful()) return;
+ }
+
+ // Fehler einfach weiterreichen.
+}
+
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::traverseANDCriteria(OSQLParseNode * pSearchCondition)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseANDCriteria" );
+
+
+ if (
+ SQL_ISRULE(pSearchCondition,boolean_primary) &&
+ pSearchCondition->count() == 3 &&
+ SQL_ISPUNCTUATION(pSearchCondition->getChild(0),"(") &&
+ SQL_ISPUNCTUATION(pSearchCondition->getChild(2),")")
+ )
+ {
+ // Runde Klammern
+ traverseANDCriteria(pSearchCondition->getChild(1));
+ }
+ // Das erste Element ist eine OR-Verknuepfung
+ else if ( SQL_ISRULE(pSearchCondition,search_condition) && pSearchCondition->count() == 3 )
+ {
+ // Dann rekursiv absteigen (dieselbe Row benutzen) ...
+ traverseORCriteria(pSearchCondition->getChild(0));
+// if (! aIteratorStatus.IsSuccessful())
+// return;
+
+ // Und mit dem rechten Child weitermachen:
+ traverseANDCriteria(pSearchCondition->getChild(2));
+ }
+ // Das erste Element ist (wieder) eine AND-Verknuepfung
+ else if ( SQL_ISRULE(pSearchCondition,boolean_term) && pSearchCondition->count() == 3 )
+ {
+ // Dann rekursiv absteigen (dieselbe Row benutzen) ...
+ traverseANDCriteria(pSearchCondition->getChild(0));
+// if (! aIteratorStatus.IsSuccessful())
+// return;
+
+ // Und mit dem rechten Child weitermachen:
+ traverseANDCriteria(pSearchCondition->getChild(2));
+ }
+ // Sonst einzelne Suchkriterien wie =, !=, ..., LIKE, IS NULL usw. behandeln:
+ else if (SQL_ISRULE(pSearchCondition,comparison_predicate) )
+ {
+ ::rtl::OUString aValue;
+ pSearchCondition->getChild(2)->parseNodeToStr( aValue, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
+ traverseOnePredicate(pSearchCondition->getChild(0),aValue,pSearchCondition->getChild(2));
+ impl_fillJoinConditions(pSearchCondition);
+// if (! aIteratorStatus.IsSuccessful())
+// return;
+ }
+ else if (SQL_ISRULE(pSearchCondition,like_predicate) /*&& SQL_ISRULE(pSearchCondition->getChild(0),column_ref)*/)
+ {
+ OSL_ENSURE(pSearchCondition->count() == 2,"OSQLParseTreeIterator: error in parse tree!");
+ const OSQLParseNode* pPart2 = pSearchCondition->getChild(1);
+
+ sal_Int32 nCurentPos = pPart2->count()-2;
+
+ OSQLParseNode * pNum_value_exp = pPart2->getChild(nCurentPos);
+ OSQLParseNode * pOptEscape = pPart2->getChild(nCurentPos+1);
+
+ OSL_ENSURE(pNum_value_exp != NULL,"OSQLParseTreeIterator: error in parse tree!");
+ OSL_ENSURE(pOptEscape != NULL,"OSQLParseTreeIterator: error in parse tree!");
+
+ if (pOptEscape->count() != 0)
+ {
+ // aIteratorStatus.setStatementTooComplex();
+ return;
+ }
+
+ ::rtl::OUString aValue;
+ OSQLParseNode * pParam = NULL;
+ if (SQL_ISRULE(pNum_value_exp,parameter))
+ pParam = pNum_value_exp;
+ else if(pNum_value_exp->isToken())
+ // Normaler Wert
+ aValue = pNum_value_exp->getTokenValue();
+ else
+ {
+ pNum_value_exp->parseNodeToStr( aValue, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
+ pParam = pNum_value_exp;
+ }
+
+ traverseOnePredicate(pSearchCondition->getChild(0),aValue,pParam);
+// if (! aIteratorStatus.IsSuccessful())
+// return;
+ }
+ else if (SQL_ISRULE(pSearchCondition,in_predicate))
+ {
+ OSL_ENSURE(pSearchCondition->count() == 2,"OSQLParseTreeIterator: error in parse tree!");
+ const OSQLParseNode* pPart2 = pSearchCondition->getChild(1);
+
+ traverseORCriteria(pSearchCondition->getChild(0));
+ // if (! aIteratorStatus.IsSuccessful()) return;
+
+ OSQLParseNode* pChild = pPart2->getChild(2);
+ if ( SQL_ISRULE(pChild->getChild(0),subquery) )
+ {
+ traverseTableNames( *m_pImpl->m_pSubTables );
+ traverseSelectionCriteria(pChild->getChild(0)->getChild(1));
+ }
+ else
+ { // '(' value_exp_commalist ')'
+ pChild = pChild->getChild(1);
+ sal_Int32 nCount = pChild->count();
+ for (sal_Int32 i=0; i < nCount; ++i)
+ {
+ traverseANDCriteria(pChild->getChild(i));
+ }
+ }
+ }
+ else if (SQL_ISRULE(pSearchCondition,test_for_null) /*&& SQL_ISRULE(pSearchCondition->getChild(0),column_ref)*/)
+ {
+ OSL_ENSURE(pSearchCondition->count() == 2,"OSQLParseTreeIterator: error in parse tree!");
+ const OSQLParseNode* pPart2 = pSearchCondition->getChild(1);
+ (void)pPart2;
+ OSL_ENSURE(SQL_ISTOKEN(pPart2->getChild(0),IS),"OSQLParseTreeIterator: error in parse tree!");
+
+ ::rtl::OUString aString;
+ traverseOnePredicate(pSearchCondition->getChild(0),aString,NULL);
+ // if (! aIteratorStatus.IsSuccessful()) return;
+ }
+ else if (SQL_ISRULE(pSearchCondition,num_value_exp) || SQL_ISRULE(pSearchCondition,term))
+ {
+ ::rtl::OUString aString;
+ traverseOnePredicate(pSearchCondition->getChild(0),aString,pSearchCondition->getChild(0));
+ traverseOnePredicate(pSearchCondition->getChild(2),aString,pSearchCondition->getChild(2));
+ }
+ // Fehler einfach weiterreichen.
+}
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::traverseParameter(const OSQLParseNode* _pParseNode
+ ,const OSQLParseNode* _pColumnRef
+ ,const ::rtl::OUString& _aColumnName
+ ,const ::rtl::OUString& _aTableRange
+ ,const ::rtl::OUString& _rColumnAlias)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseParameter" );
+ if ( !SQL_ISRULE( _pParseNode, parameter ) )
+ return;
+
+ if ( ( m_pImpl->m_nIncludeMask & Parameters ) != Parameters )
+ // parameters not to be included in the traversal
+ return;
+
+ OSL_ENSURE(_pParseNode->count() > 0,"OSQLParseTreeIterator: error in parse tree!");
+ OSQLParseNode * pMark = _pParseNode->getChild(0);
+ ::rtl::OUString sParameterName;
+
+ if (SQL_ISPUNCTUATION(pMark,"?"))
+ {
+ sParameterName = _rColumnAlias.getLength()
+ ? _rColumnAlias
+ : _aColumnName.getLength()
+ ? _aColumnName
+ : ::rtl::OUString::createFromAscii("?");
+ }
+ else if (SQL_ISPUNCTUATION(pMark,":"))
+ {
+ sParameterName = _pParseNode->getChild(1)->getTokenValue();
+ }
+ else if (SQL_ISPUNCTUATION(pMark,"["))
+ {
+ sParameterName = _pParseNode->getChild(1)->getTokenValue();
+ }
+ else
+ {
+ OSL_ASSERT("OSQLParseTreeIterator: error in parse tree!");
+ }
+
+ // found a parameter
+ if ( _pColumnRef && (SQL_ISRULE(_pColumnRef,general_set_fct) || SQL_ISRULE(_pColumnRef,set_fct_spec)) )
+ {// found a function as column_ref
+ ::rtl::OUString sFunctionName;
+ _pColumnRef->getChild(0)->parseNodeToStr( sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
+ const sal_uInt32 nCount = _pColumnRef->count();
+ sal_uInt32 i = 0;
+ for(; i < nCount;++i)
+ {
+ if ( _pColumnRef->getChild(i) == _pParseNode )
+ break;
+ }
+ sal_Int32 nType = ::connectivity::OSQLParser::getFunctionParameterType( _pColumnRef->getParent()->getChild(0)->getTokenID(), i+1);
+
+ OParseColumn* pColumn = new OParseColumn( sParameterName,
+ ::rtl::OUString(),
+ ::rtl::OUString(),
+ ::rtl::OUString(),
+ ColumnValue::NULLABLE_UNKNOWN,
+ 0,
+ 0,
+ nType,
+ sal_False,
+ sal_False,
+ isCaseSensitive());
+ pColumn->setFunction(sal_True);
+ pColumn->setAggregateFunction(sal_True);
+ pColumn->setRealName(sFunctionName);
+ m_aParameters->get().push_back(pColumn);
+ }
+ else
+ {
+ sal_Bool bNotFound = sal_True;
+ OSQLColumns::Vector::const_iterator aIter = ::connectivity::find(
+ m_aSelectColumns->get().begin(),
+ m_aSelectColumns->get().end(),
+ _aColumnName,::comphelper::UStringMixEqual( isCaseSensitive() )
+ );
+ if(aIter != m_aSelectColumns->get().end())
+ {
+ OParseColumn* pNewColumn = new OParseColumn(*aIter,isCaseSensitive());
+ pNewColumn->setName(sParameterName);
+ pNewColumn->setRealName(_aColumnName);
+ m_aParameters->get().push_back(pNewColumn);
+ bNotFound = sal_False;
+ }
+ else if(_aColumnName.getLength())// search in the tables for the right one
+ {
+
+ Reference<XPropertySet> xColumn = findColumn( _aColumnName, _aTableRange, true );
+
+ if ( xColumn.is() )
+ {
+ OParseColumn* pNewColumn = new OParseColumn(xColumn,isCaseSensitive());
+ pNewColumn->setName(sParameterName);
+ pNewColumn->setRealName(_aColumnName);
+ m_aParameters->get().push_back(pNewColumn);
+ bNotFound = sal_False;
+ }
+ }
+ if ( bNotFound )
+ {
+ sal_Int32 nType = DataType::VARCHAR;
+ OSQLParseNode* pParent = _pColumnRef ? _pColumnRef->getParent() : NULL;
+ if ( pParent && (SQL_ISRULE(pParent,general_set_fct) || SQL_ISRULE(pParent,set_fct_spec)) )
+ {
+ const sal_uInt32 nCount = _pColumnRef->count();
+ sal_uInt32 i = 0;
+ for(; i < nCount;++i)
+ {
+ if ( _pColumnRef->getChild(i) == _pParseNode )
+ break;
+ }
+ nType = ::connectivity::OSQLParser::getFunctionParameterType( pParent->getChild(0)->getTokenID(), i+1);
+ }
+
+ ::rtl::OUString aNewColName( getUniqueColumnName( sParameterName ) );
+
+ OParseColumn* pColumn = new OParseColumn(aNewColName,
+ ::rtl::OUString(),
+ ::rtl::OUString(),
+ ::rtl::OUString(),
+ ColumnValue::NULLABLE_UNKNOWN,
+ 0,
+ 0,
+ nType,
+ sal_False,
+ sal_False,
+ isCaseSensitive() );
+ pColumn->setName(aNewColName);
+ pColumn->setRealName(sParameterName);
+ m_aParameters->get().push_back(pColumn);
+ }
+ }
+}
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::traverseOnePredicate(
+ OSQLParseNode * pColumnRef,
+ ::rtl::OUString& rValue,
+ OSQLParseNode * pParseNode)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseOnePredicate" );
+ if ( !pParseNode )
+ return;
+
+ // Column-Name (und TableRange):
+ ::rtl::OUString aColumnName, aTableRange, sColumnAlias;
+ getColumnRange( pColumnRef, aColumnName, aTableRange, sColumnAlias);
+
+ ::rtl::OUString aName;
+
+ /*if (SQL_ISRULE(pParseNode,parameter))
+ traverseParameter( pParseNode, pColumnRef, aColumnName, aTableRange, sColumnAlias );
+ else */if (SQL_ISRULE(pParseNode,column_ref))// Column-Name (und TableRange):
+ getColumnRange(pParseNode,aName,rValue);
+ else
+ {
+ traverseORCriteria(pParseNode);
+ // if (! aIteratorStatus.IsSuccessful()) return;
+ }
+}
+
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::traverseSome( sal_uInt32 _nIncludeMask )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseSome" );
+ impl_traverse( _nIncludeMask );
+}
+
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::traverseAll()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseAll" );
+ impl_traverse( All );
+}
+
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::impl_traverse( sal_uInt32 _nIncludeMask )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::impl_traverse" );
+ impl_resetErrors();
+ m_pImpl->m_nIncludeMask = _nIncludeMask;
+
+ if ( !traverseTableNames( *m_pImpl->m_pTables ) )
+ return;
+
+ switch ( m_eStatementType )
+ {
+ case SQL_STATEMENT_SELECT:
+ {
+ const OSQLParseNode* pSelectNode = m_pParseTree;
+ traverseParameters( pSelectNode );
+ if ( !traverseSelectColumnNames( pSelectNode )
+ || !traverseOrderByColumnNames( pSelectNode )
+ || !traverseGroupByColumnNames( pSelectNode )
+ || !traverseSelectionCriteria( pSelectNode )
+ )
+ return;
+ }
+ break;
+ case SQL_STATEMENT_CREATE_TABLE:
+ {
+ //0 | 1 | 2 |3| 4 |5
+ //create table sc.foo ( a char(20), b char )
+ const OSQLParseNode* pCreateNode = m_pParseTree->getChild(4);
+ traverseCreateColumns(pCreateNode);
+ }
+ break;
+ case SQL_STATEMENT_INSERT:
+ break;
+ default:
+ break;
+ }
+}
+
+// Dummy-Implementationen:
+
+//-----------------------------------------------------------------------------
+OSQLTable OSQLParseTreeIterator::impl_createTableObject( const ::rtl::OUString& rTableName,
+ const ::rtl::OUString& rCatalogName, const ::rtl::OUString& rSchemaName )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::impl_createTableObject" );
+ OSL_PRECOND( m_eStatementType == SQL_STATEMENT_CREATE_TABLE,
+ "OSQLParseTreeIterator::impl_createTableObject: only to be called for CREATE TABLE statements!" );
+ // (in all other cases, m_pTables is to contain the table objects as obtained from the tables
+ // container of the connection (m_xTablesContainer)
+
+ OSQLTable aReturnTable = new OTable(
+ NULL,
+ sal_False,
+ rTableName,
+ ::rtl::OUString::createFromAscii("Table"),
+ ::rtl::OUString::createFromAscii("New Created Table"),
+ rSchemaName,
+ rCatalogName
+ );
+ return aReturnTable;
+}
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::appendColumns(::vos::ORef<OSQLColumns>& _rColumns,const ::rtl::OUString& _rTableAlias,const OSQLTable& _rTable)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::appendColumns" );
+
+ if (!_rTable.is())
+ return;
+
+ Reference<XNameAccess> xColumns = _rTable->getColumns();
+ if ( !xColumns.is() )
+ return;
+
+ Sequence< ::rtl::OUString > aColNames = xColumns->getElementNames();
+ const ::rtl::OUString* pBegin = aColNames.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + aColNames.getLength();
+
+ for(;pBegin != pEnd;++pBegin)
+ {
+
+ ::rtl::OUString aName(getUniqueColumnName(*pBegin));
+ Reference< XPropertySet > xColumn;
+ if(xColumns->hasByName(*pBegin) && (xColumns->getByName(*pBegin) >>= xColumn) && xColumn.is())
+ {
+ OParseColumn* pColumn = new OParseColumn(aName
+ , getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)))
+ , getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)))
+ , getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION)))
+ , getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))
+ , getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))
+ , getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))
+ , getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))
+ , getBOOL(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)))
+ , getBOOL(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))
+ , isCaseSensitive() );
+
+ pColumn->setTableName(_rTableAlias);
+ pColumn->setRealName(*pBegin);
+ Reference< XPropertySet> xCol = pColumn;
+ _rColumns->get().push_back(xCol);
+ }
+ else
+ impl_appendError( IParseContext::ERROR_INVALID_COLUMN, pBegin, &_rTableAlias );
+ }
+}
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::setSelectColumnName(::vos::ORef<OSQLColumns>& _rColumns,const ::rtl::OUString & rColumnName,const ::rtl::OUString & rColumnAlias, const ::rtl::OUString & rTableRange,sal_Bool bFkt,sal_Int32 _nType,sal_Bool bAggFkt)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::setSelectColumnName" );
+ if(rColumnName.toChar() == '*' && !rTableRange.getLength())
+ { // SELECT * ...
+ OSL_ENSURE(_rColumns == m_aSelectColumns,"Invalid columns used here!");
+ for(ConstOSQLTablesIterator aIter = m_pImpl->m_pTables->begin(); aIter != m_pImpl->m_pTables->end();++aIter)
+ appendColumns(_rColumns,aIter->first,aIter->second);
+ }
+ else if( rColumnName.toChar() == '*' && rTableRange.getLength() )
+ { // SELECT <table>.*
+ OSL_ENSURE(_rColumns == m_aSelectColumns,"Invalid columns used here!");
+ ConstOSQLTablesIterator aFind = m_pImpl->m_pTables->find(rTableRange);
+
+ if(aFind != m_pImpl->m_pTables->end())
+ appendColumns(_rColumns,rTableRange,aFind->second);
+ }
+ else if ( !rTableRange.getLength() )
+ { // SELECT <something> ...
+ // without table specified
+ if ( !bFkt )
+ {
+ Reference< XPropertySet> xNewColumn;
+
+ for ( OSQLTablesIterator aIter = m_pImpl->m_pTables->begin(); aIter != m_pImpl->m_pTables->end(); ++aIter )
+ {
+ if ( !aIter->second.is() )
+ continue;
+
+ Reference<XNameAccess> xColumns = aIter->second->getColumns();
+ Reference< XPropertySet > xColumn;
+ if ( !xColumns->hasByName( rColumnName )
+ || !( xColumns->getByName( rColumnName ) >>= xColumn )
+ )
+ continue;
+
+ ::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias));
+
+ OParseColumn* pColumn = new OParseColumn(xColumn,isCaseSensitive());
+ xNewColumn = pColumn;
+ pColumn->setTableName(aIter->first);
+ pColumn->setName(aNewColName);
+ pColumn->setRealName(rColumnName);
+
+ break;
+ }
+
+ if ( !xNewColumn.is() )
+ {
+ // no function (due to the above !bFkt), no existing column
+ // => assume an expression
+ ::rtl::OUString aNewColName( getUniqueColumnName( rColumnAlias ) );
+ // did not find a column with this name in any of the tables
+ OParseColumn* pColumn = new OParseColumn(
+ aNewColName,
+ ::rtl::OUString::createFromAscii( "VARCHAR" ),
+ // TODO: does this match with _nType?
+ // Or should be fill this from the getTypeInfo of the connection?
+ ::rtl::OUString(),
+ ::rtl::OUString(),
+ ColumnValue::NULLABLE_UNKNOWN,
+ 0,
+ 0,
+ _nType,
+ sal_False,
+ sal_False,
+ isCaseSensitive()
+ );
+
+ xNewColumn = pColumn;
+ pColumn->setRealName( rColumnName );
+ }
+
+ _rColumns->get().push_back( xNewColumn );
+ }
+ else
+ {
+ ::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias));
+
+ OParseColumn* pColumn = new OParseColumn(aNewColName,::rtl::OUString(),::rtl::OUString(),::rtl::OUString(),
+ ColumnValue::NULLABLE_UNKNOWN,0,0,_nType,sal_False,sal_False,isCaseSensitive());
+ pColumn->setFunction(sal_True);
+ pColumn->setAggregateFunction(bAggFkt);
+ pColumn->setRealName(rColumnName);
+
+ Reference< XPropertySet> xCol = pColumn;
+ _rColumns->get().push_back(xCol);
+ }
+ }
+ else // ColumnName und Tablename vorhanden
+ {
+ ConstOSQLTablesIterator aFind = m_pImpl->m_pTables->find(rTableRange);
+
+ sal_Bool bError = sal_False;
+ if (aFind != m_pImpl->m_pTables->end() && aFind->second.is())
+ {
+ if (bFkt)
+ {
+ ::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias));
+
+ OParseColumn* pColumn = new OParseColumn(aNewColName,::rtl::OUString(),::rtl::OUString(),::rtl::OUString(),
+ ColumnValue::NULLABLE_UNKNOWN,0,0,_nType,sal_False,sal_False,isCaseSensitive());
+ pColumn->setFunction(sal_True);
+ pColumn->setAggregateFunction(bAggFkt);
+ pColumn->setRealName(rColumnName);
+ pColumn->setTableName(aFind->first);
+
+ Reference< XPropertySet> xCol = pColumn;
+ _rColumns->get().push_back(xCol);
+ }
+ else
+ {
+ Reference< XPropertySet > xColumn;
+ if (aFind->second->getColumns()->hasByName(rColumnName) && (aFind->second->getColumns()->getByName(rColumnName) >>= xColumn))
+ {
+ ::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias));
+
+ OParseColumn* pColumn = new OParseColumn(xColumn,isCaseSensitive());
+ pColumn->setName(aNewColName);
+ pColumn->setRealName(rColumnName);
+ pColumn->setTableName(aFind->first);
+
+ Reference< XPropertySet> xCol = pColumn;
+ _rColumns->get().push_back(xCol);
+ }
+ else
+ bError = sal_True;
+ }
+ }
+ else
+ bError = sal_True;
+
+ // Tabelle existiert nicht oder Feld nicht vorhanden
+ if (bError)
+ {
+ ::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias));
+
+ OParseColumn* pColumn = new OParseColumn(aNewColName,::rtl::OUString(),::rtl::OUString(),::rtl::OUString(),
+ ColumnValue::NULLABLE_UNKNOWN,0,0,DataType::VARCHAR,sal_False,sal_False,isCaseSensitive());
+ pColumn->setFunction(sal_True);
+ pColumn->setAggregateFunction(bAggFkt);
+
+ Reference< XPropertySet> xCol = pColumn;
+ _rColumns->get().push_back(xCol);
+ }
+ }
+}
+//-----------------------------------------------------------------------------
+::rtl::OUString OSQLParseTreeIterator::getUniqueColumnName(const ::rtl::OUString & rColumnName) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getUniqueColumnName" );
+ ::rtl::OUString aAlias(rColumnName);
+
+ OSQLColumns::Vector::const_iterator aIter = find(
+ m_aSelectColumns->get().begin(),
+ m_aSelectColumns->get().end(),
+ aAlias,
+ ::comphelper::UStringMixEqual( isCaseSensitive() )
+ );
+ sal_Int32 i=1;
+ while(aIter != m_aSelectColumns->get().end())
+ {
+ (aAlias = rColumnName) += ::rtl::OUString::valueOf(i++);
+ aIter = find(
+ m_aSelectColumns->get().begin(),
+ m_aSelectColumns->get().end(),
+ aAlias,
+ ::comphelper::UStringMixEqual( isCaseSensitive() )
+ );
+ }
+ return aAlias;
+}
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::setOrderByColumnName(const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange,sal_Bool bAscending)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::setOrderByColumnName" );
+ Reference<XPropertySet> xColumn = findColumn( rColumnName, rTableRange, false );
+ if ( xColumn.is() )
+ m_aOrderColumns->get().push_back(new OOrderColumn(xColumn,isCaseSensitive(),bAscending));
+ else
+ {
+ sal_Int32 nId = rColumnName.toInt32();
+ if ( nId > 0 && nId < static_cast<sal_Int32>(m_aSelectColumns->get().size()) )
+ m_aOrderColumns->get().push_back(new OOrderColumn((m_aSelectColumns->get())[nId-1],isCaseSensitive(),bAscending));
+ }
+
+#ifdef SQL_TEST_PARSETREEITERATOR
+ cout << "OSQLParseTreeIterator::setOrderByColumnName: "
+ << (const char *) rColumnName << ", "
+ << (const char *) rTableRange << ", "
+ << (bAscending ? "sal_True" : "sal_False")
+ << "\n";
+#endif
+}
+//-----------------------------------------------------------------------------
+void OSQLParseTreeIterator::setGroupByColumnName(const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::setGroupByColumnName" );
+ Reference<XPropertySet> xColumn = findColumn( rColumnName, rTableRange, false );
+ if ( xColumn.is() )
+ m_aGroupColumns->get().push_back(new OParseColumn(xColumn,isCaseSensitive()));
+ else
+ {
+ sal_Int32 nId = rColumnName.toInt32();
+ if ( nId > 0 && nId < static_cast<sal_Int32>(m_aSelectColumns->get().size()) )
+ m_aGroupColumns->get().push_back(new OParseColumn((m_aSelectColumns->get())[nId-1],isCaseSensitive()));
+ }
+
+#ifdef SQL_TEST_PARSETREEITERATOR
+ cout << "OSQLParseTreeIterator::setOrderByColumnName: "
+ << (const char *) rColumnName << ", "
+ << (const char *) rTableRange << ", "
+ << (bAscending ? "sal_True" : "sal_False")
+ << "\n";
+#endif
+}
+
+//-----------------------------------------------------------------------------
+const OSQLParseNode* OSQLParseTreeIterator::getWhereTree() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getWhereTree" );
+
+
+ if (!m_pParseTree)
+ return NULL;
+
+ // Parse Tree analysieren (je nach Statement-Typ)
+ // und Zeiger auf WHERE-Klausel setzen:
+ OSQLParseNode * pWhereClause = NULL;
+ if(getStatementType() == SQL_STATEMENT_SELECT)
+ {
+ OSL_ENSURE(m_pParseTree->count() >= 4,"ParseTreeIterator: error in parse tree!");
+ OSQLParseNode * pTableExp = m_pParseTree->getChild(3);
+ OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!");
+ OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!");
+ OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!");
+
+ pWhereClause = pTableExp->getChild(1);
+ }
+ else if (SQL_ISRULE(m_pParseTree,update_statement_searched) ||
+ SQL_ISRULE(m_pParseTree,delete_statement_searched))
+ {
+ pWhereClause = m_pParseTree->getChild(m_pParseTree->count()-1);
+ }
+ if(pWhereClause->count() != 2)
+ pWhereClause = NULL;
+ return pWhereClause;
+}
+
+//-----------------------------------------------------------------------------
+const OSQLParseNode* OSQLParseTreeIterator::getOrderTree() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getOrderTree" );
+
+
+ if (!m_pParseTree || getStatementType() != SQL_STATEMENT_SELECT)
+ return NULL;
+
+ // Parse Tree analysieren (je nach Statement-Typ)
+ // und Zeiger auf ORDER-Klausel setzen:
+ OSQLParseNode * pOrderClause = NULL;
+ OSL_ENSURE(m_pParseTree->count() >= 4,"ParseTreeIterator: error in parse tree!");
+ OSQLParseNode * pTableExp = m_pParseTree->getChild(3);
+ OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!");
+ OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!");
+ OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!");
+
+ pOrderClause = pTableExp->getChild(4);
+ // Wenn es aber eine order_by ist, dann darf sie nicht leer sein:
+ if(pOrderClause->count() != 3)
+ pOrderClause = NULL;
+ return pOrderClause;
+}
+//-----------------------------------------------------------------------------
+const OSQLParseNode* OSQLParseTreeIterator::getGroupByTree() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getGroupByTree" );
+ if (!m_pParseTree || getStatementType() != SQL_STATEMENT_SELECT)
+ return NULL;
+
+ // Parse Tree analysieren (je nach Statement-Typ)
+ // und Zeiger auf ORDER-Klausel setzen:
+ OSQLParseNode * pGroupClause = NULL;
+ OSL_ENSURE(m_pParseTree->count() >= 4,"ParseTreeIterator: error in parse tree!");
+ OSQLParseNode * pTableExp = m_pParseTree->getChild(3);
+ OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!");
+ OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!");
+ OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!");
+
+ pGroupClause = pTableExp->getChild(2);
+ // Wenn es aber eine order_by ist, dann darf sie nicht leer sein:
+ if(pGroupClause->count() != 3)
+ pGroupClause = NULL;
+ return pGroupClause;
+}
+//-----------------------------------------------------------------------------
+const OSQLParseNode* OSQLParseTreeIterator::getHavingTree() const
+{
+ if (!m_pParseTree || getStatementType() != SQL_STATEMENT_SELECT)
+ return NULL;
+
+ // Parse Tree analysieren (je nach Statement-Typ)
+ // und Zeiger auf ORDER-Klausel setzen:
+ OSQLParseNode * pHavingClause = NULL;
+ OSL_ENSURE(m_pParseTree->count() >= 4,"ParseTreeIterator: error in parse tree!");
+ OSQLParseNode * pTableExp = m_pParseTree->getChild(3);
+ OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!");
+ OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!");
+ OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!");
+
+ pHavingClause = pTableExp->getChild(3);
+ // Wenn es aber eine order_by ist, dann darf sie nicht leer sein:
+ if(pHavingClause->count() < 1)
+ pHavingClause = NULL;
+ return pHavingClause;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OSQLParseTreeIterator::isTableNode(const OSQLParseNode* _pTableNode) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::isTableNode" );
+ return _pTableNode && (SQL_ISRULE(_pTableNode,catalog_name) ||
+ SQL_ISRULE(_pTableNode,schema_name) ||
+ SQL_ISRULE(_pTableNode,table_name));
+}
+// -----------------------------------------------------------------------------
+const OSQLParseNode* OSQLParseTreeIterator::getSimpleWhereTree() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getSimpleWhereTree" );
+ const OSQLParseNode* pNode = getWhereTree();
+ return pNode ? pNode->getChild(1) : NULL;
+}
+// -----------------------------------------------------------------------------
+const OSQLParseNode* OSQLParseTreeIterator::getSimpleOrderTree() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getSimpleOrderTree" );
+ const OSQLParseNode* pNode = getOrderTree();
+ return pNode ? pNode->getChild(2) : NULL;
+}
+// -----------------------------------------------------------------------------
+const OSQLParseNode* OSQLParseTreeIterator::getSimpleGroupByTree() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getSimpleGroupByTree" );
+ const OSQLParseNode* pNode = getGroupByTree();
+ return pNode ? pNode->getChild(2) : NULL;
+}
+// -----------------------------------------------------------------------------
+const OSQLParseNode* OSQLParseTreeIterator::getSimpleHavingTree() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getSimpleHavingTree" );
+ const OSQLParseNode* pNode = getHavingTree();
+ return pNode ? pNode->getChild(1) : NULL;
+}
+
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > OSQLParseTreeIterator::findColumn( const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange, bool _bLookInSubTables )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::findColumn" );
+ Reference< XPropertySet > xColumn = findColumn( *m_pImpl->m_pTables, rColumnName, rTableRange );
+ if ( !xColumn.is() && _bLookInSubTables )
+ xColumn = findColumn( *m_pImpl->m_pSubTables, rColumnName, rTableRange );
+ return xColumn;
+}
+
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > OSQLParseTreeIterator::findColumn(const OSQLTables& _rTables,const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::findColumn" );
+ Reference< XPropertySet > xColumn;
+ if ( rTableRange.getLength() )
+ {
+ ConstOSQLTablesIterator aFind = _rTables.find(rTableRange);
+
+ if ( aFind != _rTables.end()
+ && aFind->second.is()
+ && aFind->second->getColumns().is()
+ && aFind->second->getColumns()->hasByName(rColumnName) )
+ aFind->second->getColumns()->getByName(rColumnName) >>= xColumn;
+ }
+ if ( !xColumn.is() )
+ {
+ OSQLTables::const_iterator aEnd = _rTables.end();
+ for(OSQLTables::const_iterator aIter = _rTables.begin(); aIter != aEnd; ++aIter)
+ {
+ if ( aIter->second.is() )
+ {
+ Reference<XNameAccess> xColumns = aIter->second->getColumns();
+ if( xColumns.is() && xColumns->hasByName(rColumnName) && (xColumns->getByName(rColumnName) >>= xColumn) )
+ {
+ OSL_ENSURE(xColumn.is(),"Column isn't a propertyset!");
+ break; // diese Column darf nur einmal vorkommen
+ }
+ }
+ }
+ }
+ return xColumn;
+}
+
+// -----------------------------------------------------------------------------
+void OSQLParseTreeIterator::impl_appendError( IParseContext::ErrorCode _eError, const ::rtl::OUString* _pReplaceToken1, const ::rtl::OUString* _pReplaceToken2 )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::impl_appendError" );
+ ::rtl::OUString sErrorMessage = m_rParser.getContext().getErrorMessage( _eError );
+ if ( _pReplaceToken1 )
+ {
+ bool bTwoTokens = ( _pReplaceToken2 != NULL );
+ const sal_Char* pPlaceHolder1 = bTwoTokens ? "#1" : "#";
+ const ::rtl::OUString sPlaceHolder1 = ::rtl::OUString::createFromAscii( pPlaceHolder1 );
+
+ sErrorMessage = sErrorMessage.replaceAt( sErrorMessage.indexOf( sPlaceHolder1 ), sPlaceHolder1.getLength(), *_pReplaceToken1 );
+ if ( _pReplaceToken2 )
+ sErrorMessage = sErrorMessage.replaceAt( sErrorMessage.indexOf( ::rtl::OUString::createFromAscii( "#2" ) ), 2, *_pReplaceToken2 );
+ }
+
+ impl_appendError( SQLException(
+ sErrorMessage, NULL, getStandardSQLState( SQL_GENERAL_ERROR ), 1000, Any() ) );
+}
+
+// -----------------------------------------------------------------------------
+void OSQLParseTreeIterator::impl_appendError( const SQLException& _rError )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::impl_appendError" );
+ if ( m_aErrors.Message.getLength() )
+ {
+ SQLException* pErrorChain = &m_aErrors;
+ while ( pErrorChain->NextException.hasValue() )
+ pErrorChain = static_cast< SQLException* >( pErrorChain->NextException.pData );
+ pErrorChain->NextException <<= _rError;
+ }
+ else
+ m_aErrors = _rError;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OSQLParseTreeIterator::getFunctionReturnType(const OSQLParseNode* _pNode )
+{
+ sal_Int32 nType = DataType::OTHER;
+ ::rtl::OUString sFunctionName;
+ if ( SQL_ISRULE(_pNode,length_exp) )
+ {
+ _pNode->getChild(0)->getChild(0)->parseNodeToStr(sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
+ nType = ::connectivity::OSQLParser::getFunctionReturnType( sFunctionName, &m_rParser.getContext() );
+ }
+ else if ( SQL_ISRULE(_pNode,num_value_exp) || SQL_ISRULE(_pNode,term) || SQL_ISRULE(_pNode,factor) )
+ {
+ nType = DataType::DOUBLE;
+ }
+ else
+ {
+ _pNode->getChild(0)->parseNodeToStr(sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
+
+ // MIN and MAX have another return type, we have to check the expression itself.
+ // @see http://qa.openoffice.org/issues/show_bug.cgi?id=99566
+ if ( SQL_ISRULE(_pNode,general_set_fct) && (SQL_ISTOKEN(_pNode->getChild(0),MIN) || SQL_ISTOKEN(_pNode->getChild(0),MAX) ))
+ {
+ const OSQLParseNode* pValueExp = _pNode->getChild(3);
+ if (SQL_ISRULE(pValueExp,column_ref))
+ {
+ ::rtl::OUString sColumnName;
+ ::rtl::OUString aTableRange;
+ getColumnRange(pValueExp,sColumnName,aTableRange);
+ OSL_ENSURE(sColumnName.getLength(),"Columnname darf nicht leer sein");
+ Reference<XPropertySet> xColumn = findColumn( sColumnName, aTableRange, true );
+
+ if ( xColumn.is() )
+ {
+ xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_TYPE)) >>= nType;
+ }
+ }
+ else
+ {
+ if ( SQL_ISRULE(pValueExp,num_value_exp) || SQL_ISRULE(pValueExp,term) || SQL_ISRULE(pValueExp,factor) )
+ {
+ nType = DataType::DOUBLE;
+ }
+ else if ( SQL_ISRULE(pValueExp,datetime_primary) )
+ {
+ switch(pValueExp->getChild(0)->getTokenID() )
+ {
+ case SQL_TOKEN_CURRENT_DATE:
+ nType = DataType::DATE;
+ break;
+ case SQL_TOKEN_CURRENT_TIME:
+ nType = DataType::TIME;
+ break;
+ case SQL_TOKEN_CURRENT_TIMESTAMP:
+ nType = DataType::TIMESTAMP;
+ break;
+ }
+ }
+ else if ( SQL_ISRULE(pValueExp,value_exp_primary) )
+ {
+ nType = getFunctionReturnType(pValueExp->getChild(1));
+ }
+ else if ( SQL_ISRULE(pValueExp,concatenation)
+ || SQL_ISRULE(pValueExp,char_factor)
+ || SQL_ISRULE(pValueExp,bit_value_fct)
+ || SQL_ISRULE(pValueExp,char_value_fct)
+ || SQL_ISRULE(pValueExp,char_substring_fct)
+ || SQL_ISRULE(pValueExp,fold)
+ || SQL_ISTOKEN(pValueExp,STRING) )
+ {
+ nType = DataType::VARCHAR;
+ }
+ }
+ if ( nType == DataType::OTHER )
+ nType = DataType::DOUBLE;
+ }
+ else
+ nType = ::connectivity::OSQLParser::getFunctionReturnType( sFunctionName, &m_rParser.getContext() );
+ }
+
+ return nType;
+}
+
diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx
new file mode 100644
index 000000000000..b8bcd5334787
--- /dev/null
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -0,0 +1,2826 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/sqlnode.hxx>
+#include <connectivity/sqlerror.hxx>
+#include <internalnode.hxx>
+#define YYBISON 1
+#ifndef BISON_INCLUDED
+#define BISON_INCLUDED
+#include <sqlbison.hxx>
+#endif
+#include <connectivity/sqlparse.hxx>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <com/sun/star/i18n/NumberFormatIndex.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdb/ErrorCondition.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/util/XNumberFormats.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/i18n/KParseType.hpp>
+#include <com/sun/star/i18n/KParseTokens.hpp>
+#include "connectivity/dbconversion.hxx"
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include "TConnection.hxx"
+#include "sqlscan.hxx"
+#include <comphelper/numbers.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/stl_types.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbmetadata.hxx"
+#include "connectivity/sqlerror.hxx"
+#include <tools/diagnose_ex.h>
+#include <string.h>
+#include <boost/bind.hpp>
+#include <algorithm>
+#include <functional>
+#include <rtl/logfile.hxx>
+#include <rtl/ustrbuf.hxx>
+
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star;
+using namespace ::osl;
+using namespace ::dbtools;
+using namespace ::comphelper;
+
+
+extern int SQLyyparse (void);
+extern ::rtl::OUString ConvertLikeToken(const ::connectivity::OSQLParseNode* pTokenNode, const ::connectivity::OSQLParseNode* pEscapeNode, sal_Bool bInternational);
+extern void setParser( ::connectivity::OSQLParser* );
+
+namespace
+{
+ // -----------------------------------------------------------------------------
+ sal_Bool lcl_saveConvertToNumber(const Reference< XNumberFormatter > & _xFormatter,sal_Int32 _nKey,const ::rtl::OUString& _sValue,double& _nrValue)
+ {
+ sal_Bool bRet = sal_False;
+ try
+ {
+ _nrValue = _xFormatter->convertStringToNumber(_nKey, _sValue);
+ bRet = sal_True;
+ }
+ catch(Exception&)
+ {
+ }
+ return bRet;
+ }
+ // -----------------------------------------------------------------------------
+ void replaceAndReset(connectivity::OSQLParseNode*& _pResetNode,connectivity::OSQLParseNode* _pNewNode)
+ {
+ _pResetNode->getParent()->replace(_pResetNode, _pNewNode);
+ delete _pResetNode;
+ _pResetNode = _pNewNode;
+ }
+ // -----------------------------------------------------------------------------
+ /** quotes a string and search for quotes inside the string and replace them with the new quote
+ @param rValue
+ The value to be quoted.
+ @param rQuot
+ The quote
+ @param rQuotToReplace
+ The quote to replace with
+ @return
+ The quoted string.
+ */
+ ::rtl::OUString SetQuotation(const ::rtl::OUString& rValue, const ::rtl::OUString& rQuot, const ::rtl::OUString& rQuotToReplace)
+ {
+ ::rtl::OUString rNewValue = rQuot;
+ rNewValue += rValue;
+ sal_Int32 nIndex = (sal_Int32)-1; // Quotes durch zweifache Quotes ersetzen, sonst kriegt der Parser Probleme
+
+ if (rQuot.getLength())
+ {
+ do
+ {
+ nIndex += 2;
+ nIndex = rNewValue.indexOf(rQuot,nIndex);
+ if(nIndex != -1)
+ rNewValue = rNewValue.replaceAt(nIndex,rQuot.getLength(),rQuotToReplace);
+ } while (nIndex != -1);
+ }
+
+ rNewValue += rQuot;
+ return rNewValue;
+ }
+}
+
+namespace connectivity
+{
+
+//=============================================================================
+struct OSQLParser_Data
+{
+ ::com::sun::star::lang::Locale aLocale;
+ ::connectivity::SQLError aErrors;
+
+ OSQLParser_Data( const Reference< XMultiServiceFactory >& _xServiceFactory )
+ :aErrors( _xServiceFactory )
+ {
+ }
+};
+
+//=============================================================================
+//= SQLParseNodeParameter
+//=============================================================================
+//-----------------------------------------------------------------------------
+SQLParseNodeParameter::SQLParseNodeParameter( const Reference< XConnection >& _rxConnection,
+ const Reference< XNumberFormatter >& _xFormatter, const Reference< XPropertySet >& _xField,
+ const Locale& _rLocale, const IParseContext* _pContext,
+ bool _bIntl, bool _bQuote, sal_Char _cDecSep, bool _bPredicate, bool _bParseToSDBC )
+ :rLocale(_rLocale)
+ ,aMetaData( _rxConnection )
+ ,pParser( NULL )
+ ,pSubQueryHistory( new QueryNameSet )
+ ,xFormatter(_xFormatter)
+ ,xField(_xField)
+ ,m_rContext( _pContext ? (const IParseContext&)(*_pContext) : (const IParseContext&)OSQLParser::s_aDefaultContext )
+ ,cDecSep(_cDecSep)
+ ,bQuote(_bQuote)
+ ,bInternational(_bIntl)
+ ,bPredicate(_bPredicate)
+ ,bParseToSDBCLevel( _bParseToSDBC )
+{
+}
+
+//-----------------------------------------------------------------------------
+SQLParseNodeParameter::~SQLParseNodeParameter()
+{
+}
+
+//=============================================================================
+//= OSQLParseNode
+//=============================================================================
+//-----------------------------------------------------------------------------
+::rtl::OUString OSQLParseNode::convertDateString(const SQLParseNodeParameter& rParam, const ::rtl::OUString& rString) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::convertDateString" );
+ Date aDate = DBTypeConversion::toDate(rString);
+ Reference< XNumberFormatsSupplier > xSupplier(rParam.xFormatter->getNumberFormatsSupplier());
+ Reference< XNumberFormatTypes > xTypes(xSupplier->getNumberFormats(), UNO_QUERY);
+
+ double fDate = DBTypeConversion::toDouble(aDate,DBTypeConversion::getNULLDate(xSupplier));
+ sal_Int32 nKey = xTypes->getStandardIndex(rParam.rLocale) + 36; // XXX hack
+ return rParam.xFormatter->convertNumberToString(nKey, fDate);
+}
+
+//-----------------------------------------------------------------------------
+::rtl::OUString OSQLParseNode::convertDateTimeString(const SQLParseNodeParameter& rParam, const ::rtl::OUString& rString) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::convertDateTimeString" );
+ DateTime aDate = DBTypeConversion::toDateTime(rString);
+ Reference< XNumberFormatsSupplier > xSupplier(rParam.xFormatter->getNumberFormatsSupplier());
+ Reference< XNumberFormatTypes > xTypes(xSupplier->getNumberFormats(), UNO_QUERY);
+
+ double fDateTime = DBTypeConversion::toDouble(aDate,DBTypeConversion::getNULLDate(xSupplier));
+ sal_Int32 nKey = xTypes->getStandardIndex(rParam.rLocale) + 51; // XXX hack
+ return rParam.xFormatter->convertNumberToString(nKey, fDateTime);
+}
+
+//-----------------------------------------------------------------------------
+::rtl::OUString OSQLParseNode::convertTimeString(const SQLParseNodeParameter& rParam, const ::rtl::OUString& rString) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::convertTimeString" );
+ Time aTime = DBTypeConversion::toTime(rString);
+ Reference< XNumberFormatsSupplier > xSupplier(rParam.xFormatter->getNumberFormatsSupplier());
+
+ Reference< XNumberFormatTypes > xTypes(xSupplier->getNumberFormats(), UNO_QUERY);
+
+ double fTime = DBTypeConversion::toDouble(aTime);
+ sal_Int32 nKey = xTypes->getStandardIndex(rParam.rLocale) + 41; // XXX hack
+ return rParam.xFormatter->convertNumberToString(nKey, fTime);
+}
+
+//-----------------------------------------------------------------------------
+void OSQLParseNode::parseNodeToStr(::rtl::OUString& rString,
+ const Reference< XConnection >& _rxConnection,
+ const IParseContext* pContext,
+ sal_Bool _bIntl,
+ sal_Bool _bQuote) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::parseNodeToStr" );
+
+ parseNodeToStr(
+ rString, _rxConnection, NULL, NULL,
+ pContext ? pContext->getPreferredLocale() : OParseContext::getDefaultLocale(),
+ pContext, _bIntl, _bQuote, '.', false, false );
+}
+
+//-----------------------------------------------------------------------------
+void OSQLParseNode::parseNodeToPredicateStr(::rtl::OUString& rString,
+ const Reference< XConnection >& _rxConnection,
+ const Reference< XNumberFormatter > & xFormatter,
+ const ::com::sun::star::lang::Locale& rIntl,
+ sal_Char _cDec,
+ const IParseContext* pContext ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::parseNodeToPredicateStr" );
+
+ OSL_ENSURE(xFormatter.is(), "OSQLParseNode::parseNodeToPredicateStr:: no formatter!");
+
+ if (xFormatter.is())
+ parseNodeToStr(rString, _rxConnection, xFormatter, NULL, rIntl, pContext, sal_True, sal_True, _cDec, true, false);
+}
+
+//-----------------------------------------------------------------------------
+void OSQLParseNode::parseNodeToPredicateStr(::rtl::OUString& rString,
+ const Reference< XConnection > & _rxConnection,
+ const Reference< XNumberFormatter > & xFormatter,
+ const Reference< XPropertySet > & _xField,
+ const ::com::sun::star::lang::Locale& rIntl,
+ sal_Char _cDec,
+ const IParseContext* pContext ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::parseNodeToPredicateStr" );
+
+ OSL_ENSURE(xFormatter.is(), "OSQLParseNode::parseNodeToPredicateStr:: no formatter!");
+
+ if (xFormatter.is())
+ parseNodeToStr( rString, _rxConnection, xFormatter, _xField, rIntl, pContext, true, true, _cDec, true, false );
+}
+
+//-----------------------------------------------------------------------------
+void OSQLParseNode::parseNodeToStr(::rtl::OUString& rString,
+ const Reference< XConnection > & _rxConnection,
+ const Reference< XNumberFormatter > & xFormatter,
+ const Reference< XPropertySet > & _xField,
+ const ::com::sun::star::lang::Locale& rIntl,
+ const IParseContext* pContext,
+ bool _bIntl,
+ bool _bQuote,
+ sal_Char _cDecSep,
+ bool _bPredicate,
+ bool _bSubstitute) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::parseNodeToStr" );
+
+ OSL_ENSURE( _rxConnection.is(), "OSQLParseNode::parseNodeToStr: invalid connection!" );
+
+ if ( _rxConnection.is() )
+ {
+ ::rtl::OUStringBuffer sBuffer = rString;
+ try
+ {
+ OSQLParseNode::impl_parseNodeToString_throw( sBuffer,
+ SQLParseNodeParameter(
+ _rxConnection, xFormatter, _xField, rIntl, pContext,
+ _bIntl, _bQuote, _cDecSep, _bPredicate, _bSubstitute
+ ) );
+ }
+ catch( const SQLException& )
+ {
+ OSL_ENSURE( false, "OSQLParseNode::parseNodeToStr: this should not throw!" );
+ // our callers don't expect this method to throw anything. The only known situation
+ // where impl_parseNodeToString_throw can throw is when there is a cyclic reference
+ // in the sub queries, but this cannot be the case here, as we do not parse to
+ // SDBC level.
+ }
+ rString = sBuffer.makeStringAndClear();
+ }
+}
+//-----------------------------------------------------------------------------
+bool OSQLParseNode::parseNodeToExecutableStatement( ::rtl::OUString& _out_rString, const Reference< XConnection >& _rxConnection,
+ OSQLParser& _rParser, ::com::sun::star::sdbc::SQLException* _pErrorHolder ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::parseNodeToExecutableStatement" );
+ OSL_PRECOND( _rxConnection.is(), "OSQLParseNode::parseNodeToExecutableStatement: invalid connection!" );
+ SQLParseNodeParameter aParseParam( _rxConnection,
+ NULL, NULL, OParseContext::getDefaultLocale(), NULL, false, true, '.', false, true );
+
+ if ( aParseParam.aMetaData.supportsSubqueriesInFrom() )
+ {
+ Reference< XQueriesSupplier > xSuppQueries( _rxConnection, UNO_QUERY );
+ OSL_ENSURE( xSuppQueries.is(), "OSQLParseNode::parseNodeToExecutableStatement: cannot substitute everything without a QueriesSupplier!" );
+ if ( xSuppQueries.is() )
+ aParseParam.xQueries = xSuppQueries->getQueries();
+ }
+
+ aParseParam.pParser = &_rParser;
+
+ _out_rString = ::rtl::OUString();
+ ::rtl::OUStringBuffer sBuffer;
+ bool bSuccess = false;
+ try
+ {
+ impl_parseNodeToString_throw( sBuffer, aParseParam );
+ bSuccess = true;
+ }
+ catch( const SQLException& e )
+ {
+ if ( _pErrorHolder )
+ *_pErrorHolder = e;
+ }
+ _out_rString = sBuffer.makeStringAndClear();
+ return bSuccess;
+}
+
+//-----------------------------------------------------------------------------
+namespace
+{
+ bool lcl_isAliasNamePresent( const OSQLParseNode& _rTableNameNode )
+ {
+ return OSQLParseNode::getTableRange(_rTableNameNode.getParent()).getLength() != 0;
+ }
+}
+
+//-----------------------------------------------------------------------------
+void OSQLParseNode::impl_parseNodeToString_throw(::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::getTableRange" );
+ if ( isToken() )
+ {
+ parseLeaf(rString,rParam);
+ return;
+ }
+
+ // einmal auswerten wieviel Subtrees dieser Knoten besitzt
+ sal_uInt32 nCount = count();
+
+ bool bHandled = false;
+ switch ( getKnownRuleID() )
+ {
+ // special handling for parameters
+ case parameter:
+ {
+ if(rString.getLength())
+ rString.appendAscii(" ");
+ if (nCount == 1) // ?
+ m_aChildren[0]->impl_parseNodeToString_throw( rString, rParam );
+ else if (nCount == 2) // :Name
+ {
+ m_aChildren[0]->impl_parseNodeToString_throw( rString, rParam );
+ rString.append(m_aChildren[1]->m_aNodeValue);
+ } // [Name]
+ else
+ {
+ m_aChildren[0]->impl_parseNodeToString_throw( rString, rParam );
+ rString.append(m_aChildren[1]->m_aNodeValue);
+ rString.append(m_aChildren[2]->m_aNodeValue);
+ }
+ bHandled = true;
+ }
+ break;
+
+ // table refs
+ case table_ref:
+ if ( ( nCount == 2 ) || ( nCount == 3 ) || ( nCount == 5 ) )
+ {
+ impl_parseTableRangeNodeToString_throw( rString, rParam );
+ bHandled = true;
+ }
+ break;
+
+ // table name - might be a query name
+ case table_name:
+ bHandled = impl_parseTableNameNodeToString_throw( rString, rParam );
+ break;
+
+ case as:
+ if ( rParam.aMetaData.generateASBeforeCorrelationName() )
+ rString.append(::rtl::OUString::createFromAscii( " AS" ));
+ bHandled = true;
+ break;
+
+ case like_predicate:
+ // je nachdem ob international angegeben wird oder nicht wird like anders behandelt
+ // interanational: *, ? sind Platzhalter
+ // sonst SQL92 konform: %, _
+ impl_parseLikeNodeToString_throw( rString, rParam );
+ bHandled = true;
+ break;
+
+ case general_set_fct:
+ case set_fct_spec:
+ case position_exp:
+ case extract_exp:
+ case length_exp:
+ case char_value_fct:
+ {
+ if (!addDateValue(rString, rParam))
+ {
+ // Funktionsname nicht quoten
+ SQLParseNodeParameter aNewParam(rParam);
+ aNewParam.bQuote = ( SQL_ISRULE(this,length_exp) || SQL_ISRULE(this,char_value_fct) );
+
+ m_aChildren[0]->impl_parseNodeToString_throw( rString, aNewParam );
+ aNewParam.bQuote = rParam.bQuote;
+ //aNewParam.bPredicate = sal_False; // disable [ ] around names // look at i73215
+ ::rtl::OUStringBuffer aStringPara;
+ for (sal_uInt32 i=1; i<nCount; i++)
+ {
+ const OSQLParseNode * pSubTree = m_aChildren[i];
+ if (pSubTree)
+ {
+ pSubTree->impl_parseNodeToString_throw( aStringPara, aNewParam );
+
+ // bei den CommaListen zwischen alle Subtrees Commas setzen
+ if ((m_eNodeType == SQL_NODE_COMMALISTRULE) && (i < (nCount - 1)))
+ aStringPara.appendAscii(",");
+ }
+ else
+ i++;
+ }
+ rString.append(aStringPara.makeStringAndClear());
+ }
+ bHandled = true;
+ }
+ break;
+ default:
+ break;
+ } // switch ( getKnownRuleID() )
+
+ if ( !bHandled )
+ {
+ for (OSQLParseNodes::const_iterator i = m_aChildren.begin();
+ i != m_aChildren.end();)
+ {
+ const OSQLParseNode* pSubTree = *i;
+ if ( !pSubTree )
+ {
+ ++i;
+ continue;
+ }
+
+ SQLParseNodeParameter aNewParam(rParam);
+
+ // don't replace the field for subqueries
+ if (rParam.xField.is() && SQL_ISRULE(pSubTree,subquery))
+ aNewParam.xField = NULL;
+
+ // if there is a field given we don't display the fieldname, if there is any
+ if (rParam.xField.is() && SQL_ISRULE(pSubTree,column_ref))
+ {
+ sal_Bool bFilter = sal_False;
+ // retrieve the fields name
+ ::rtl::OUString aFieldName;
+ try
+ {
+ sal_Int32 nNamePropertyId = PROPERTY_ID_NAME;
+ if ( rParam.xField->getPropertySetInfo()->hasPropertyByName( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_REALNAME ) ) )
+ nNamePropertyId = PROPERTY_ID_REALNAME;
+ rParam.xField->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( nNamePropertyId ) ) >>= aFieldName;
+ }
+ catch ( Exception& )
+ {
+ }
+
+ if(pSubTree->count())
+ {
+ const OSQLParseNode* pCol = pSubTree->m_aChildren[pSubTree->count()-1];
+ if ( ( SQL_ISRULE(pCol,column_val)
+ && pCol->getChild(0)->getTokenValue().equalsIgnoreAsciiCase(aFieldName)
+ )
+ || pCol->getTokenValue().equalsIgnoreAsciiCase(aFieldName)
+ )
+ bFilter = sal_True;
+ }
+
+ // ok we found the field, if the following node is the
+ // comparision operator '=' we filter it as well
+ if (bFilter)
+ {
+ if (SQL_ISRULE(this, comparison_predicate))
+ {
+ ++i;
+ if(i != m_aChildren.end())
+ {
+ pSubTree = *i;
+ if (pSubTree && pSubTree->getNodeType() == SQL_NODE_EQUAL)
+ i++;
+ }
+ }
+ else
+ i++;
+ }
+ else
+ {
+ pSubTree->impl_parseNodeToString_throw( rString, aNewParam );
+ i++;
+
+ // bei den CommaListen zwischen alle Subtrees Commas setzen
+ if ((m_eNodeType == SQL_NODE_COMMALISTRULE) && (i != m_aChildren.end()))
+ rString.appendAscii(",");
+ }
+ }
+ else
+ {
+ pSubTree->impl_parseNodeToString_throw( rString, aNewParam );
+ i++;
+
+ // bei den CommaListen zwischen alle Subtrees Commas setzen
+ if ((m_eNodeType == SQL_NODE_COMMALISTRULE) && (i != m_aChildren.end()))
+ {
+ if (SQL_ISRULE(this,value_exp_commalist) && rParam.bPredicate)
+ rString.appendAscii(";");
+ else
+ rString.appendAscii(",");
+ }
+ }
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------
+bool OSQLParseNode::impl_parseTableNameNodeToString_throw( ::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::impl_parseTableNameNodeToString_throw" );
+ // is the table_name part of a table_ref?
+ OSL_ENSURE( getParent(), "OSQLParseNode::impl_parseTableNameNodeToString_throw: table_name without parent?" );
+ if ( !getParent() || ( getParent()->getKnownRuleID() != table_ref ) )
+ return false;
+
+ // if it's a query, maybe we need to substitute the SQL statement ...
+ if ( !rParam.bParseToSDBCLevel )
+ return false;
+
+ if ( !rParam.xQueries.is() )
+ // connection does not support queries in queries, or was no query supplier
+ return false;
+
+ try
+ {
+ ::rtl::OUString sTableOrQueryName( getChild(0)->getTokenValue() );
+ bool bIsQuery = rParam.xQueries->hasByName( sTableOrQueryName );
+ if ( !bIsQuery )
+ return false;
+
+ // avoid recursion (e.g. "foo" defined as "SELECT * FROM bar" and "bar" defined as "SELECT * FROM foo".
+ if ( rParam.pSubQueryHistory->find( sTableOrQueryName ) != rParam.pSubQueryHistory->end() )
+ {
+ ::rtl::OUString sMessage( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cyclic sub queries" ) ) );
+ OSL_ENSURE( rParam.pParser, "OSQLParseNode::impl_parseTableNameNodeToString_throw: no parser?" );
+ if ( rParam.pParser )
+ {
+ const SQLError& rErrors( rParam.pParser->getErrorHelper() );
+ rErrors.raiseException( sdb::ErrorCondition::PARSER_CYCLIC_SUB_QUERIES );
+ }
+ else
+ {
+ SQLError aErrors( ::comphelper::getProcessServiceFactory() );
+ aErrors.raiseException( sdb::ErrorCondition::PARSER_CYCLIC_SUB_QUERIES );
+ }
+ }
+ rParam.pSubQueryHistory->insert( sTableOrQueryName );
+
+ Reference< XPropertySet > xQuery( rParam.xQueries->getByName( sTableOrQueryName ), UNO_QUERY_THROW );
+
+ // substitute the query name with the constituting command
+ ::rtl::OUString sCommand;
+ OSL_VERIFY( xQuery->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_COMMAND ) ) >>= sCommand );
+
+ sal_Bool bEscapeProcessing = sal_False;
+ OSL_VERIFY( xQuery->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_ESCAPEPROCESSING ) ) >>= bEscapeProcessing );
+
+ // the query we found here might itself be based on another query, so parse it recursively
+ OSL_ENSURE( rParam.pParser, "OSQLParseNode::impl_parseTableNameNodeToString_throw: cannot analyze sub queries without a parser!" );
+ if ( bEscapeProcessing && rParam.pParser )
+ {
+ ::rtl::OUString sError;
+ ::std::auto_ptr< OSQLParseNode > pSubQueryNode( rParam.pParser->parseTree( sError, sCommand, sal_False ) );
+ if ( pSubQueryNode.get() )
+ {
+ // parse the sub-select to SDBC level, too
+ ::rtl::OUStringBuffer sSubSelect;
+ pSubQueryNode->impl_parseNodeToString_throw( sSubSelect, rParam );
+ if ( sSubSelect.getLength() )
+ sCommand = sSubSelect.makeStringAndClear();
+ }
+ }
+
+ rString.appendAscii( " ( " );
+ rString.append(sCommand);
+ rString.appendAscii( " )" );
+
+ // append the query name as table alias, since it might be referenced in other
+ // parts of the statement - but only if there's no other alias name present
+ if ( !lcl_isAliasNamePresent( *this ) )
+ {
+ rString.appendAscii( " AS " );
+ if ( rParam.bQuote )
+ rString.append(SetQuotation( sTableOrQueryName,
+ rParam.aMetaData.getIdentifierQuoteString(), rParam.aMetaData.getIdentifierQuoteString() ));
+ }
+
+ // don't forget to remove the query name from the history, else multiple inclusions
+ // won't work
+ // #i69227# / 2006-10-10 / frank.schoenheit@sun.com
+ rParam.pSubQueryHistory->erase( sTableOrQueryName );
+
+ return true;
+ }
+ catch( const SQLException& )
+ {
+ throw;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false;
+}
+
+//-----------------------------------------------------------------------------
+void OSQLParseNode::impl_parseTableRangeNodeToString_throw(::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::impl_parseTableRangeNodeToString_throw" );
+ OSL_PRECOND( ( count() == 2 ) || ( count() == 3 ) || ( count() == 5 ) ,"Illegal count");
+
+ // rString += ::rtl::OUString::createFromAscii(" ");
+ ::std::for_each(m_aChildren.begin(),m_aChildren.end(),
+ boost::bind( &OSQLParseNode::impl_parseNodeToString_throw, _1, boost::ref( rString ), boost::cref( rParam ) ));
+}
+
+//-----------------------------------------------------------------------------
+void OSQLParseNode::impl_parseLikeNodeToString_throw( ::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::impl_parseLikeNodeToString_throw" );
+ OSL_ENSURE(count() == 2,"count != 2: Prepare for GPF");
+
+ const OSQLParseNode* pEscNode = NULL;
+ const OSQLParseNode* pParaNode = NULL;
+
+ SQLParseNodeParameter aNewParam(rParam);
+ //aNewParam.bQuote = sal_True; // why setting this to true? @see http://www.openoffice.org/issues/show_bug.cgi?id=75557
+
+ // if there is a field given we don't display the fieldname, if there are any
+ sal_Bool bAddName = sal_True;
+ if (rParam.xField.is())
+ {
+ // retrieve the fields name
+ ::rtl::OUString aFieldName;
+ try
+ {
+ // retrieve the fields name
+ rtl::OUString aString;
+ rParam.xField->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aString;
+ aFieldName = aString.getStr();
+ }
+ catch ( Exception& )
+ {
+ OSL_ENSURE( false, "OSQLParseNode::impl_parseLikeNodeToString_throw Exception occured!" );
+ }
+ if ( !m_aChildren[0]->isLeaf() )
+ {
+ const OSQLParseNode* pCol = m_aChildren[0]->getChild(m_aChildren[0]->count()-1);
+ if ((SQL_ISRULE(pCol,column_val) && pCol->getChild(0)->getTokenValue().equalsIgnoreAsciiCase(aFieldName)) ||
+ pCol->getTokenValue().equalsIgnoreAsciiCase(aFieldName) )
+ bAddName = sal_False;
+ }
+ }
+
+ if (bAddName)
+ m_aChildren[0]->impl_parseNodeToString_throw( rString, aNewParam );
+
+ const OSQLParseNode* pPart2 = m_aChildren[1];
+ pPart2->getChild(0)->impl_parseNodeToString_throw( rString, aNewParam );
+ pPart2->getChild(1)->impl_parseNodeToString_throw( rString, aNewParam );
+ pParaNode = pPart2->getChild(2);
+ pEscNode = pPart2->getChild(3);
+
+ if (pParaNode->isToken())
+ {
+ ::rtl::OUString aStr = ConvertLikeToken(pParaNode, pEscNode, rParam.bInternational);
+ rString.appendAscii(" ");
+ rString.append(SetQuotation(aStr,::rtl::OUString::createFromAscii("\'"),::rtl::OUString::createFromAscii("\'\'")));
+ }
+ else
+ pParaNode->impl_parseNodeToString_throw( rString, aNewParam );
+
+ pEscNode->impl_parseNodeToString_throw( rString, aNewParam );
+}
+
+
+// -----------------------------------------------------------------------------
+sal_Bool OSQLParseNode::getTableComponents(const OSQLParseNode* _pTableNode,
+ ::com::sun::star::uno::Any &_rCatalog,
+ ::rtl::OUString &_rSchema,
+ ::rtl::OUString &_rTable,
+ const Reference< XDatabaseMetaData >& _xMetaData)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::getTableComponents" );
+ OSL_ENSURE(_pTableNode,"Wrong use of getTableComponents! _pTableNode is not allowed to be null!");
+ if(_pTableNode)
+ {
+ const sal_Bool bSupportsCatalog = _xMetaData.is() && _xMetaData->supportsCatalogsInDataManipulation();
+ const sal_Bool bSupportsSchema = _xMetaData.is() && _xMetaData->supportsSchemasInDataManipulation();
+ const OSQLParseNode* pTableNode = _pTableNode;
+ // clear the parameter given
+ _rCatalog = Any();
+ _rSchema = _rTable = ::rtl::OUString();
+ // see rule catalog_name: in sqlbison.y
+ if (SQL_ISRULE(pTableNode,catalog_name))
+ {
+ OSL_ENSURE(pTableNode->getChild(0) && pTableNode->getChild(0)->isToken(),"Invalid parsenode!");
+ _rCatalog <<= pTableNode->getChild(0)->getTokenValue();
+ pTableNode = pTableNode->getChild(2);
+ }
+ // check if we have schema_name rule
+ if(SQL_ISRULE(pTableNode,schema_name))
+ {
+ if ( bSupportsCatalog && !bSupportsSchema )
+ _rCatalog <<= pTableNode->getChild(0)->getTokenValue();
+ else
+ _rSchema = pTableNode->getChild(0)->getTokenValue();
+ pTableNode = pTableNode->getChild(2);
+ }
+ // check if we have table_name rule
+ if(SQL_ISRULE(pTableNode,table_name))
+ {
+ _rTable = pTableNode->getChild(0)->getTokenValue();
+ }
+ else
+ {
+ OSL_ENSURE(0,"Error in parse tree!");
+ }
+ }
+ return _rTable.getLength() != 0;
+}
+// -----------------------------------------------------------------------------
+void OSQLParser::killThousandSeparator(OSQLParseNode* pLiteral)
+{
+ if ( pLiteral )
+ {
+ if ( s_xLocaleData->getLocaleItem( m_pData->aLocale ).decimalSeparator.toChar() == ',' )
+ {
+ pLiteral->m_aNodeValue = pLiteral->m_aNodeValue.replace('.', sal_Unicode());
+ // and replace decimal
+ pLiteral->m_aNodeValue = pLiteral->m_aNodeValue.replace(',', '.');
+ }
+ else
+ pLiteral->m_aNodeValue = pLiteral->m_aNodeValue.replace(',', sal_Unicode());
+ }
+}
+// -----------------------------------------------------------------------------
+OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral)
+{
+ if ( !pLiteral )
+ return NULL;
+
+ OSQLParseNode* pReturn = pLiteral;
+
+ if ( ( pLiteral->isRule() && !SQL_ISRULE(pLiteral,value_exp) ) || SQL_ISTOKEN(pLiteral,FALSE) || SQL_ISTOKEN(pLiteral,TRUE) )
+ {
+ switch(nType)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ case DataType::CLOB:
+ if ( !SQL_ISRULE(pReturn,char_value_exp) && !buildStringNodes(pReturn) )
+ pReturn = NULL;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ switch(pLiteral->getNodeType())
+ {
+ case SQL_NODE_STRING:
+ switch(nType)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ case DataType::CLOB:
+ break;
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ if (m_xFormatter.is())
+ pReturn = buildDate( nType, pReturn);
+ break;
+ default:
+ m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_COMPARE);
+ break;
+ }
+ break;
+ case SQL_NODE_ACCESS_DATE:
+ switch(nType)
+ {
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ if ( m_xFormatter.is() )
+ pReturn = buildDate( nType, pReturn);
+ else
+ m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_DATE_COMPARE);
+ break;
+ default:
+ m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_COMPARE);
+ break;
+ }
+ break;
+ case SQL_NODE_INTNUM:
+ switch(nType)
+ {
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::BIGINT:
+ case DataType::FLOAT:
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ // kill thousand seperators if any
+ killThousandSeparator(pReturn);
+ break;
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ case DataType::CLOB:
+ pReturn = buildNode_STR_NUM(pReturn);
+ break;
+ default:
+ m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_INT_COMPARE);
+ break;
+ }
+ break;
+ case SQL_NODE_APPROXNUM:
+ switch(nType)
+ {
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::FLOAT:
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ // kill thousand seperators if any
+ killThousandSeparator(pReturn);
+ break;
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ case DataType::CLOB:
+ pReturn = buildNode_STR_NUM(pReturn);
+ break;
+ case DataType::INTEGER:
+ default:
+ m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_REAL_COMPARE);
+ break;
+ }
+ break;
+ default:
+ ;
+ }
+ }
+ return pReturn;
+}
+// -----------------------------------------------------------------------------
+sal_Int16 OSQLParser::buildPredicateRule(OSQLParseNode*& pAppend,OSQLParseNode* pLiteral,OSQLParseNode*& pCompare,OSQLParseNode* pLiteral2)
+{
+ OSL_ENSURE(inPredicateCheck(),"Only in predicate check allowed!");
+ sal_Int16 nErg = 0;
+ if ( m_xField.is() )
+ {
+ sal_Int32 nType = 0;
+ try
+ {
+ m_xField->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nType;
+ }
+ catch( Exception& )
+ {
+ return nErg;
+ }
+
+ OSQLParseNode* pNode1 = convertNode(nType,pLiteral);
+ if ( pNode1 )
+ {
+ OSQLParseNode* pNode2 = convertNode(nType,pLiteral2);
+ if ( !m_sErrorMessage.getLength() )
+ nErg = buildNode(pAppend,pCompare,pNode1,pNode2);
+ }
+ }
+ if (!pCompare->getParent()) // I have no parent so I was not used and I must die :-)
+ delete pCompare;
+ return nErg;
+}
+// -----------------------------------------------------------------------------
+sal_Int16 OSQLParser::buildLikeRule(OSQLParseNode*& pAppend, OSQLParseNode*& pLiteral, const OSQLParseNode* pEscape)
+{
+ sal_Int16 nErg = 0;
+ sal_Int32 nType = 0;
+
+ if (!m_xField.is())
+ return nErg;
+ try
+ {
+ Any aValue;
+ {
+ aValue = m_xField->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE));
+ aValue >>= nType;
+ }
+ }
+ catch( Exception& )
+ {
+ return nErg;
+ }
+
+ switch (nType)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ case DataType::CLOB:
+ if(pLiteral->isRule())
+ {
+ pAppend->append(pLiteral);
+ nErg = 1;
+ }
+ else
+ {
+ switch(pLiteral->getNodeType())
+ {
+ case SQL_NODE_STRING:
+ pLiteral->m_aNodeValue = ConvertLikeToken(pLiteral, pEscape, sal_False);
+ pAppend->append(pLiteral);
+ nErg = 1;
+ break;
+ case SQL_NODE_APPROXNUM:
+ if (m_xFormatter.is() && m_nFormatKey)
+ {
+ sal_Int16 nScale = 0;
+ try
+ {
+ Any aValue = getNumberFormatProperty( m_xFormatter, m_nFormatKey, ::rtl::OUString::createFromAscii("Decimals") );
+ aValue >>= nScale;
+ }
+ catch( Exception& )
+ {
+ }
+
+ pAppend->append(new OSQLInternalNode(stringToDouble(pLiteral->getTokenValue(),nScale),SQL_NODE_STRING));
+ }
+ else
+ pAppend->append(new OSQLInternalNode(pLiteral->getTokenValue(),SQL_NODE_STRING));
+
+ delete pLiteral;
+ nErg = 1;
+ break;
+ default:
+ m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_VALUE_NO_LIKE);
+ m_sErrorMessage = m_sErrorMessage.replaceAt(m_sErrorMessage.indexOf(::rtl::OUString::createFromAscii("#1")),2,pLiteral->getTokenValue());
+ break;
+ }
+ }
+ break;
+ default:
+ m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_FIELD_NO_LIKE);
+ break;
+ }
+ return nErg;
+}
+//-----------------------------------------------------------------------------
+OSQLParseNode* OSQLParser::buildNode_Date(const double& fValue, sal_Int32 nType)
+{
+ ::rtl::OUString aEmptyString;
+ OSQLParseNode* pNewNode = new OSQLInternalNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::set_fct_spec));
+ pNewNode->append(new OSQLInternalNode(::rtl::OUString::createFromAscii("{"), SQL_NODE_PUNCTUATION));
+ OSQLParseNode* pDateNode = new OSQLInternalNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::odbc_fct_spec));
+ pNewNode->append(pDateNode);
+ pNewNode->append(new OSQLInternalNode(::rtl::OUString::createFromAscii("}"), SQL_NODE_PUNCTUATION));
+
+ switch (nType)
+ {
+ case DataType::DATE:
+ {
+ Date aDate = DBTypeConversion::toDate(fValue,DBTypeConversion::getNULLDate(m_xFormatter->getNumberFormatsSupplier()));
+ ::rtl::OUString aString = DBTypeConversion::toDateString(aDate);
+ pDateNode->append(new OSQLInternalNode(aEmptyString, SQL_NODE_KEYWORD, SQL_TOKEN_D));
+ pDateNode->append(new OSQLInternalNode(aString, SQL_NODE_STRING));
+ break;
+ }
+ case DataType::TIME:
+ {
+ Time aTime = DBTypeConversion::toTime(fValue);
+ ::rtl::OUString aString = DBTypeConversion::toTimeString(aTime);
+ pDateNode->append(new OSQLInternalNode(aEmptyString, SQL_NODE_KEYWORD, SQL_TOKEN_T));
+ pDateNode->append(new OSQLInternalNode(aString, SQL_NODE_STRING));
+ break;
+ }
+ case DataType::TIMESTAMP:
+ {
+ DateTime aDateTime = DBTypeConversion::toDateTime(fValue,DBTypeConversion::getNULLDate(m_xFormatter->getNumberFormatsSupplier()));
+ if (aDateTime.Seconds || aDateTime.Minutes || aDateTime.Hours)
+ {
+ ::rtl::OUString aString = DBTypeConversion::toDateTimeString(aDateTime);
+ pDateNode->append(new OSQLInternalNode(aEmptyString, SQL_NODE_KEYWORD, SQL_TOKEN_TS));
+ pDateNode->append(new OSQLInternalNode(aString, SQL_NODE_STRING));
+ }
+ else
+ {
+ Date aDate(aDateTime.Day,aDateTime.Month,aDateTime.Year);
+ pDateNode->append(new OSQLInternalNode(aEmptyString, SQL_NODE_KEYWORD, SQL_TOKEN_D));
+ pDateNode->append(new OSQLInternalNode(DBTypeConversion::toDateString(aDate), SQL_NODE_STRING));
+ }
+ break;
+ }
+ }
+
+ return pNewNode;
+}
+// -----------------------------------------------------------------------------
+OSQLParseNode* OSQLParser::buildNode_STR_NUM(OSQLParseNode*& _pLiteral)
+{
+ OSQLParseNode* pReturn = NULL;
+ if ( _pLiteral )
+ {
+ if (m_nFormatKey)
+ {
+ sal_Int16 nScale = 0;
+ ::rtl::OUString aDec;
+ try
+ {
+ Any aValue = getNumberFormatProperty( m_xFormatter, m_nFormatKey, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Decimals")) );
+ aValue >>= nScale;
+ }
+ catch( Exception& )
+ {
+ }
+
+ pReturn = new OSQLInternalNode(stringToDouble(_pLiteral->getTokenValue(),nScale),SQL_NODE_STRING);
+ }
+ else
+ pReturn = new OSQLInternalNode(_pLiteral->getTokenValue(),SQL_NODE_STRING);
+
+ delete _pLiteral;
+ _pLiteral = NULL;
+ }
+ return pReturn;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OSQLParser::stringToDouble(const ::rtl::OUString& _rValue,sal_Int16 _nScale)
+{
+ ::rtl::OUString aValue;
+ if(!m_xCharClass.is())
+ m_xCharClass = Reference<XCharacterClassification>(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.i18n.CharacterClassification")),UNO_QUERY);
+ if(m_xCharClass.is() && s_xLocaleData.is())
+ {
+ try
+ {
+ ParseResult aResult = m_xCharClass->parsePredefinedToken(KParseType::ANY_NUMBER,_rValue,0,m_pData->aLocale,0,::rtl::OUString(),KParseType::ANY_NUMBER,::rtl::OUString());
+ if((aResult.TokenType & KParseType::IDENTNAME) && aResult.EndPos == _rValue.getLength())
+ {
+ aValue = ::rtl::OUString::valueOf(aResult.Value);
+ sal_Int32 nPos = aValue.lastIndexOf(::rtl::OUString::createFromAscii("."));
+ if((nPos+_nScale) < aValue.getLength())
+ aValue = aValue.replaceAt(nPos+_nScale,aValue.getLength()-nPos-_nScale,::rtl::OUString());
+ aValue = aValue.replaceAt(aValue.lastIndexOf(::rtl::OUString::createFromAscii(".")),1,s_xLocaleData->getLocaleItem(m_pData->aLocale).decimalSeparator);
+ return aValue;
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ return aValue;
+}
+// -----------------------------------------------------------------------------
+
+::osl::Mutex& OSQLParser::getMutex()
+{
+ static ::osl::Mutex aMutex;
+ return aMutex;
+}
+
+//-----------------------------------------------------------------------------
+OSQLParseNode* OSQLParser::predicateTree(::rtl::OUString& rErrorMessage, const ::rtl::OUString& rStatement,
+ const Reference< ::com::sun::star::util::XNumberFormatter > & xFormatter,
+ const Reference< XPropertySet > & xField)
+{
+
+
+ // mutex for parsing
+ static ::osl::Mutex aMutex;
+
+ // Guard the parsing
+ ::osl::MutexGuard aGuard(getMutex());
+ // must be reset
+ setParser(this);
+
+
+ // reset the parser
+ m_xField = xField;
+ m_xFormatter = xFormatter;
+
+ if (m_xField.is())
+ {
+ sal_Int32 nType=0;
+ try
+ {
+ // get the field name
+ rtl::OUString aString;
+
+ // retrieve the fields name
+ // #75243# use the RealName of the column if there is any otherwise the name which could be the alias
+ // of the field
+ Reference< XPropertySetInfo> xInfo = m_xField->getPropertySetInfo();
+ if ( xInfo->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME)))
+ m_xField->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME)) >>= aString;
+ else
+ m_xField->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aString;
+
+ m_sFieldName = aString;
+
+ // get the field format key
+ if ( xInfo->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FORMATKEY)))
+ m_xField->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FORMATKEY)) >>= m_nFormatKey;
+ else
+ m_nFormatKey = 0;
+
+ // get the field type
+ m_xField->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nType;
+ }
+ catch ( Exception& )
+ {
+ OSL_ASSERT(0);
+ }
+
+ if (m_nFormatKey && m_xFormatter.is())
+ {
+ Any aValue = getNumberFormatProperty( m_xFormatter, m_nFormatKey, OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_LOCALE) );
+ OSL_ENSURE(aValue.getValueType() == ::getCppuType((const ::com::sun::star::lang::Locale*)0), "OSQLParser::PredicateTree : invalid language property !");
+
+ if (aValue.getValueType() == ::getCppuType((const ::com::sun::star::lang::Locale*)0))
+ aValue >>= m_pData->aLocale;
+ }
+ else
+ m_pData->aLocale = m_pContext->getPreferredLocale();
+
+ if ( m_xFormatter.is() )
+ {
+ try
+ {
+ Reference< ::com::sun::star::util::XNumberFormatsSupplier > xFormatSup = m_xFormatter->getNumberFormatsSupplier();
+ if ( xFormatSup.is() )
+ {
+ Reference< ::com::sun::star::util::XNumberFormats > xFormats = xFormatSup->getNumberFormats();
+ if ( xFormats.is() )
+ {
+ ::com::sun::star::lang::Locale aLocale;
+ aLocale.Language = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en"));
+ aLocale.Country = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("US"));
+ ::rtl::OUString sFormat(RTL_CONSTASCII_USTRINGPARAM("YYYY-MM-DD"));
+ m_nDateFormatKey = xFormats->queryKey(sFormat,aLocale,sal_False);
+ if ( m_nDateFormatKey == sal_Int32(-1) )
+ m_nDateFormatKey = xFormats->addNew(sFormat, aLocale);
+ }
+ }
+ }
+ catch ( Exception& )
+ {
+ OSL_ENSURE(0,"DateFormatKey");
+ }
+ }
+
+ switch (nType)
+ {
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ s_pScanner->SetRule(s_pScanner->GetDATERule());
+ break;
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ case DataType::CLOB:
+ s_pScanner->SetRule(s_pScanner->GetSTRINGRule());
+ break;
+ default:
+ if ( s_xLocaleData->getLocaleItem( m_pData->aLocale ).decimalSeparator.toChar() == ',' )
+ s_pScanner->SetRule(s_pScanner->GetGERRule());
+ else
+ s_pScanner->SetRule(s_pScanner->GetENGRule());
+ }
+
+ }
+ else
+ s_pScanner->SetRule(s_pScanner->GetSQLRule());
+
+ s_pScanner->prepareScan(rStatement, m_pContext, sal_True);
+
+ SQLyylval.pParseNode = NULL;
+ // SQLyypvt = NULL;
+ m_pParseTree = NULL;
+ m_sErrorMessage= ::rtl::OUString();
+
+ // ... und den Parser anwerfen ...
+ if (SQLyyparse() != 0)
+ {
+ m_sFieldName= ::rtl::OUString();
+ m_xField.clear();
+ m_xFormatter.clear();
+ m_nFormatKey = 0;
+ m_nDateFormatKey = 0;
+
+ if (!m_sErrorMessage.getLength())
+ m_sErrorMessage = s_pScanner->getErrorMessage();
+ if (!m_sErrorMessage.getLength())
+ m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_GENERAL);
+
+ rErrorMessage = m_sErrorMessage;
+
+ // clear the garbage collector
+ (*s_pGarbageCollector)->clearAndDelete();
+ return NULL;
+ }
+ else
+ {
+ (*s_pGarbageCollector)->clear();
+
+ m_sFieldName= ::rtl::OUString();
+ m_xField.clear();
+ m_xFormatter.clear();
+ m_nFormatKey = 0;
+ m_nDateFormatKey = 0;
+
+ // Das Ergebnis liefern (den Root Parse Node):
+
+ // Stattdessen setzt die Parse-Routine jetzt den Member pParseTree
+ // - einfach diesen zurueckliefern:
+ OSL_ENSURE(m_pParseTree != NULL,"OSQLParser: Parser hat keinen ParseTree geliefert");
+ return m_pParseTree;
+ }
+}
+
+//=============================================================================
+//-----------------------------------------------------------------------------
+OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xServiceFactory,const IParseContext* _pContext)
+ :m_pContext(_pContext)
+ ,m_pParseTree(NULL)
+ ,m_pData( new OSQLParser_Data( _xServiceFactory ) )
+ ,m_nFormatKey(0)
+ ,m_nDateFormatKey(0)
+ ,m_xServiceFactory(_xServiceFactory)
+{
+
+
+ setParser(this);
+
+#ifdef SQLYYDEBUG
+#ifdef SQLYYDEBUG_ON
+ SQLyydebug = 1;
+#endif
+#endif
+
+ ::osl::MutexGuard aGuard(getMutex());
+ // do we have to initialize the data
+ if (s_nRefCount == 0)
+ {
+ s_pScanner = new OSQLScanner();
+ s_pScanner->setScanner();
+ s_pGarbageCollector = new OSQLParseNodesGarbageCollector();
+
+ if(!s_xLocaleData.is())
+ s_xLocaleData = Reference<XLocaleData>(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.i18n.LocaleData")),UNO_QUERY);
+
+ // auf 0 zuruecksetzen
+ memset(OSQLParser::s_nRuleIDs,0,sizeof(OSQLParser::s_nRuleIDs[0]) * (OSQLParseNode::rule_count+1));
+
+ struct
+ {
+ OSQLParseNode::Rule eRule; // the parse node's ID for the rule
+ ::rtl::OString sRuleName; // the name of the rule ("select_statement")
+ } aRuleDescriptions[] =
+ {
+ { OSQLParseNode::select_statement, "select_statement" },
+ { OSQLParseNode::table_exp, "table_exp" },
+ { OSQLParseNode::table_ref_commalist, "table_ref_commalist" },
+ { OSQLParseNode::table_ref, "table_ref" },
+ { OSQLParseNode::catalog_name, "catalog_name" },
+ { OSQLParseNode::schema_name, "schema_name" },
+ { OSQLParseNode::table_name, "table_name" },
+ { OSQLParseNode::opt_column_commalist, "opt_column_commalist" },
+ { OSQLParseNode::column_commalist, "column_commalist" },
+ { OSQLParseNode::column_ref_commalist, "column_ref_commalist" },
+ { OSQLParseNode::column_ref, "column_ref" },
+ { OSQLParseNode::opt_order_by_clause, "opt_order_by_clause" },
+ { OSQLParseNode::ordering_spec_commalist, "ordering_spec_commalist" },
+ { OSQLParseNode::ordering_spec, "ordering_spec" },
+ { OSQLParseNode::opt_asc_desc, "opt_asc_desc" },
+ { OSQLParseNode::where_clause, "where_clause" },
+ { OSQLParseNode::opt_where_clause, "opt_where_clause" },
+ { OSQLParseNode::search_condition, "search_condition" },
+ { OSQLParseNode::comparison_predicate, "comparison_predicate" },
+ { OSQLParseNode::between_predicate, "between_predicate" },
+ { OSQLParseNode::like_predicate, "like_predicate" },
+ { OSQLParseNode::opt_escape, "opt_escape" },
+ { OSQLParseNode::test_for_null, "test_for_null" },
+ { OSQLParseNode::scalar_exp_commalist, "scalar_exp_commalist" },
+ { OSQLParseNode::scalar_exp, "scalar_exp" },
+ { OSQLParseNode::parameter_ref, "parameter_ref" },
+ { OSQLParseNode::parameter, "parameter" },
+ { OSQLParseNode::general_set_fct, "general_set_fct" },
+ { OSQLParseNode::range_variable, "range_variable" },
+ { OSQLParseNode::column, "column" },
+ { OSQLParseNode::delete_statement_positioned, "delete_statement_positioned" },
+ { OSQLParseNode::delete_statement_searched, "delete_statement_searched" },
+ { OSQLParseNode::update_statement_positioned, "update_statement_positioned" },
+ { OSQLParseNode::update_statement_searched, "update_statement_searched" },
+ { OSQLParseNode::assignment_commalist, "assignment_commalist" },
+ { OSQLParseNode::assignment, "assignment" },
+ { OSQLParseNode::values_or_query_spec, "values_or_query_spec" },
+ { OSQLParseNode::insert_statement, "insert_statement" },
+ { OSQLParseNode::insert_atom_commalist, "insert_atom_commalist" },
+ { OSQLParseNode::insert_atom, "insert_atom" },
+ { OSQLParseNode::predicate_check, "predicate_check" },
+ { OSQLParseNode::from_clause, "from_clause" },
+ { OSQLParseNode::qualified_join, "qualified_join" },
+ { OSQLParseNode::cross_union, "cross_union" },
+ { OSQLParseNode::select_sublist, "select_sublist" },
+ { OSQLParseNode::derived_column, "derived_column" },
+ { OSQLParseNode::column_val, "column_val" },
+ { OSQLParseNode::set_fct_spec, "set_fct_spec" },
+ { OSQLParseNode::boolean_term, "boolean_term" },
+ { OSQLParseNode::boolean_primary, "boolean_primary" },
+ { OSQLParseNode::num_value_exp, "num_value_exp" },
+ { OSQLParseNode::join_type, "join_type" },
+ { OSQLParseNode::position_exp, "position_exp" },
+ { OSQLParseNode::extract_exp, "extract_exp" },
+ { OSQLParseNode::length_exp, "length_exp" },
+ { OSQLParseNode::char_value_fct, "char_value_fct" },
+ { OSQLParseNode::odbc_call_spec, "odbc_call_spec" },
+ { OSQLParseNode::in_predicate, "in_predicate" },
+ { OSQLParseNode::existence_test, "existence_test" },
+ { OSQLParseNode::unique_test, "unique_test" },
+ { OSQLParseNode::all_or_any_predicate, "all_or_any_predicate" },
+ { OSQLParseNode::named_columns_join, "named_columns_join" },
+ { OSQLParseNode::join_condition, "join_condition" },
+ { OSQLParseNode::joined_table, "joined_table" },
+ { OSQLParseNode::boolean_factor, "boolean_factor" },
+ { OSQLParseNode::sql_not, "sql_not" },
+ { OSQLParseNode::boolean_test, "boolean_test" },
+ { OSQLParseNode::manipulative_statement, "manipulative_statement" },
+ { OSQLParseNode::subquery, "subquery" },
+ { OSQLParseNode::value_exp_commalist, "value_exp_commalist" },
+ { OSQLParseNode::odbc_fct_spec, "odbc_fct_spec" },
+ { OSQLParseNode::union_statement, "union_statement" },
+ { OSQLParseNode::outer_join_type, "outer_join_type" },
+ { OSQLParseNode::char_value_exp, "char_value_exp" },
+ { OSQLParseNode::term, "term" },
+ { OSQLParseNode::value_exp_primary, "value_exp_primary" },
+ { OSQLParseNode::value_exp, "value_exp" },
+ { OSQLParseNode::selection, "selection" },
+ { OSQLParseNode::fold, "fold" },
+ { OSQLParseNode::char_substring_fct, "char_substring_fct" },
+ { OSQLParseNode::factor, "factor" },
+ { OSQLParseNode::base_table_def, "base_table_def" },
+ { OSQLParseNode::base_table_element_commalist, "base_table_element_commalist" },
+ { OSQLParseNode::data_type, "data_type" },
+ { OSQLParseNode::column_def, "column_def" },
+ { OSQLParseNode::table_node, "table_node" },
+ { OSQLParseNode::as, "as" },
+ { OSQLParseNode::op_column_commalist, "op_column_commalist" },
+ { OSQLParseNode::table_primary_as_range_column, "table_primary_as_range_column" },
+ { OSQLParseNode::datetime_primary, "datetime_primary" },
+ { OSQLParseNode::concatenation, "concatenation" },
+ { OSQLParseNode::char_factor, "char_factor" },
+ { OSQLParseNode::bit_value_fct, "bit_value_fct" },
+ { OSQLParseNode::comparison_predicate_part_2, "comparison_predicate_part_2" },
+ { OSQLParseNode::parenthesized_boolean_value_expression, "parenthesized_boolean_value_expression" },
+ { OSQLParseNode::character_string_type, "character_string_type" },
+ { OSQLParseNode::other_like_predicate_part_2, "other_like_predicate_part_2" },
+ { OSQLParseNode::between_predicate_part_2, "between_predicate_part_2" }
+ };
+ size_t nRuleMapCount = sizeof( aRuleDescriptions ) / sizeof( aRuleDescriptions[0] );
+ OSL_ENSURE( nRuleMapCount == size_t( OSQLParseNode::rule_count ), "OSQLParser::OSQLParser: added a new rule? Adjust this map!" );
+
+ for ( size_t mapEntry = 0; mapEntry < nRuleMapCount; ++mapEntry )
+ {
+ // look up the rule description in the our identifier map
+ sal_uInt32 nParserRuleID = StrToRuleID( aRuleDescriptions[ mapEntry ].sRuleName );
+ // map the parser's rule ID to the OSQLParseNode::Rule
+ s_aReverseRuleIDLookup[ nParserRuleID ] = aRuleDescriptions[ mapEntry ].eRule;
+ // and map the OSQLParseNode::Rule to the parser's rule ID
+ s_nRuleIDs[ aRuleDescriptions[ mapEntry ].eRule ] = nParserRuleID;
+ }
+ }
+ ++s_nRefCount;
+
+ if (m_pContext == NULL)
+ // take the default context
+ m_pContext = &s_aDefaultContext;
+
+ m_pData->aLocale = m_pContext->getPreferredLocale();
+}
+
+//-----------------------------------------------------------------------------
+OSQLParser::~OSQLParser()
+{
+ {
+ ::osl::MutexGuard aGuard(getMutex());
+ OSL_ENSURE(s_nRefCount > 0, "OSQLParser::~OSQLParser() : suspicious call : have a refcount of 0 !");
+ if (!--s_nRefCount)
+ {
+ s_pScanner->setScanner(sal_True);
+ delete s_pScanner;
+ s_pScanner = NULL;
+
+ delete s_pGarbageCollector;
+ s_pGarbageCollector = NULL;
+ // is only set the first time so we should delete it only when there no more instances
+ s_xLocaleData = NULL;
+
+ RuleIDMap aEmpty;
+ s_aReverseRuleIDLookup.swap( aEmpty );
+ }
+ m_pParseTree = NULL;
+ }
+}
+// -----------------------------------------------------------------------------
+void OSQLParseNode::substituteParameterNames(OSQLParseNode* _pNode)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::substituteParameterNames" );
+ 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);
+ sal_Int32 nChildCount = pChildNode->count();
+ for(sal_Int32 j=1;j < nChildCount;++j)
+ delete pChildNode->removeAt(1);
+ }
+ else
+ substituteParameterNames(pChildNode);
+
+ }
+}
+// -----------------------------------------------------------------------------
+bool OSQLParser::extractDate(OSQLParseNode* pLiteral,double& _rfValue)
+{
+ Reference< XNumberFormatsSupplier > xFormatSup = m_xFormatter->getNumberFormatsSupplier();
+ Reference< XNumberFormatTypes > xFormatTypes;
+ if ( xFormatSup.is() )
+ xFormatTypes = xFormatTypes.query( xFormatSup->getNumberFormats() );
+
+ // if there is no format key, yet, make sure we have a feasible one for our locale
+ try
+ {
+ if ( !m_nFormatKey && xFormatTypes.is() )
+ m_nFormatKey = ::dbtools::getDefaultNumberFormat( m_xField, xFormatTypes, m_pData->aLocale );
+ }
+ catch( Exception& ) { }
+ ::rtl::OUString sValue = pLiteral->getTokenValue();
+ sal_Int32 nTryFormat = m_nFormatKey;
+ bool bSuccess = lcl_saveConvertToNumber( m_xFormatter, nTryFormat, sValue, _rfValue );
+
+ // If our format key didn't do, try the default date format for our locale.
+ if ( !bSuccess && xFormatTypes.is() )
+ {
+ try
+ {
+ nTryFormat = xFormatTypes->getStandardFormat( NumberFormat::DATE, m_pData->aLocale );
+ }
+ catch( Exception& ) { }
+ bSuccess = lcl_saveConvertToNumber( m_xFormatter, nTryFormat, sValue, _rfValue );
+ }
+
+ // if this also didn't do, try ISO format
+ if ( !bSuccess && xFormatTypes.is() )
+ {
+ try
+ {
+ nTryFormat = xFormatTypes->getFormatIndex( NumberFormatIndex::DATE_DIN_YYYYMMDD, m_pData->aLocale );
+ }
+ catch( Exception& ) { }
+ bSuccess = lcl_saveConvertToNumber( m_xFormatter, nTryFormat, sValue, _rfValue );
+ }
+
+ // if this also didn't do, try fallback date format (en-US)
+ if ( !bSuccess )
+ {
+ nTryFormat = m_nDateFormatKey;
+ bSuccess = lcl_saveConvertToNumber( m_xFormatter, nTryFormat, sValue, _rfValue );
+ }
+ return bSuccess;
+}
+// -----------------------------------------------------------------------------
+OSQLParseNode* OSQLParser::buildDate(sal_Int32 _nType,OSQLParseNode*& pLiteral)
+{
+ // try converting the string into a date, according to our format key
+ double fValue = 0.0;
+ OSQLParseNode* pFCTNode = NULL;
+
+ if ( extractDate(pLiteral,fValue) )
+ pFCTNode = buildNode_Date( fValue, _nType);
+
+ delete pLiteral;
+ pLiteral = NULL;
+
+ if ( !pFCTNode )
+ m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_DATE_COMPARE);
+
+ return pFCTNode;
+}
+// -----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+OSQLParseNode::OSQLParseNode(const sal_Char * pNewValue,
+ SQLNodeType eNewNodeType,
+ sal_uInt32 nNewNodeID)
+ :m_pParent(NULL)
+ ,m_aNodeValue(pNewValue,strlen(pNewValue),RTL_TEXTENCODING_UTF8)
+ ,m_eNodeType(eNewNodeType)
+ ,m_nNodeID(nNewNodeID)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::OSQLParseNode" );
+
+ OSL_ENSURE(m_eNodeType >= SQL_NODE_RULE && m_eNodeType <= SQL_NODE_CONCAT,"OSQLParseNode: mit unzulaessigem NodeType konstruiert");
+}
+//-----------------------------------------------------------------------------
+OSQLParseNode::OSQLParseNode(const ::rtl::OString &_rNewValue,
+ SQLNodeType eNewNodeType,
+ sal_uInt32 nNewNodeID)
+ :m_pParent(NULL)
+ ,m_aNodeValue(_rNewValue,_rNewValue.getLength(),RTL_TEXTENCODING_UTF8)
+ ,m_eNodeType(eNewNodeType)
+ ,m_nNodeID(nNewNodeID)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::OSQLParseNode" );
+
+ OSL_ENSURE(m_eNodeType >= SQL_NODE_RULE && m_eNodeType <= SQL_NODE_CONCAT,"OSQLParseNode: mit unzulaessigem NodeType konstruiert");
+}
+//-----------------------------------------------------------------------------
+OSQLParseNode::OSQLParseNode(const sal_Unicode * pNewValue,
+ SQLNodeType eNewNodeType,
+ sal_uInt32 nNewNodeID)
+ :m_pParent(NULL)
+ ,m_aNodeValue(pNewValue)
+ ,m_eNodeType(eNewNodeType)
+ ,m_nNodeID(nNewNodeID)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::OSQLParseNode" );
+
+ OSL_ENSURE(m_eNodeType >= SQL_NODE_RULE && m_eNodeType <= SQL_NODE_CONCAT,"OSQLParseNode: mit unzulaessigem NodeType konstruiert");
+}
+//-----------------------------------------------------------------------------
+OSQLParseNode::OSQLParseNode(const ::rtl::OUString &_rNewValue,
+ SQLNodeType eNewNodeType,
+ sal_uInt32 nNewNodeID)
+ :m_pParent(NULL)
+ ,m_aNodeValue(_rNewValue)
+ ,m_eNodeType(eNewNodeType)
+ ,m_nNodeID(nNewNodeID)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::OSQLParseNode" );
+
+ OSL_ENSURE(m_eNodeType >= SQL_NODE_RULE && m_eNodeType <= SQL_NODE_CONCAT,"OSQLParseNode: mit unzulaessigem NodeType konstruiert");
+}
+//-----------------------------------------------------------------------------
+OSQLParseNode::OSQLParseNode(const OSQLParseNode& rParseNode)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::OSQLParseNode" );
+
+ // klemm den getParent auf NULL
+ m_pParent = NULL;
+
+ // kopiere die member
+ m_aNodeValue = rParseNode.m_aNodeValue;
+ m_eNodeType = rParseNode.m_eNodeType;
+ m_nNodeID = rParseNode.m_nNodeID;
+
+
+ // denk dran, dass von Container abgeleitet wurde, laut SV-Help erzeugt
+ // copy-Constructor des Containers einen neuen Container mit den gleichen
+ // Zeigern als Inhalt -> d.h. nach dem Kopieren des Container wird fuer
+ // alle Zeiger ungleich NULL eine Kopie hergestellt und anstelle des alten
+ // Zeigers wieder eingehangen.
+
+ // wenn kein Blatt, dann SubTrees bearbeiten
+ for (OSQLParseNodes::const_iterator i = rParseNode.m_aChildren.begin();
+ i != rParseNode.m_aChildren.end(); i++)
+ append(new OSQLParseNode(**i));
+}
+// -----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+OSQLParseNode& OSQLParseNode::operator=(const OSQLParseNode& rParseNode)
+{
+ if (this != &rParseNode)
+ {
+ // kopiere die member - pParent bleibt der alte
+ m_aNodeValue = rParseNode.m_aNodeValue;
+ m_eNodeType = rParseNode.m_eNodeType;
+ m_nNodeID = rParseNode.m_nNodeID;
+
+ for (OSQLParseNodes::const_iterator i = m_aChildren.begin();
+ i != m_aChildren.end(); i++)
+ delete *i;
+
+ m_aChildren.clear();
+
+ for (OSQLParseNodes::const_iterator j = rParseNode.m_aChildren.begin();
+ j != rParseNode.m_aChildren.end(); j++)
+ append(new OSQLParseNode(**j));
+ }
+ return *this;
+}
+
+//-----------------------------------------------------------------------------
+sal_Bool OSQLParseNode::operator==(OSQLParseNode& rParseNode) const
+{
+ // die member muessen gleich sein
+ sal_Bool bResult = (m_nNodeID == rParseNode.m_nNodeID) &&
+ (m_eNodeType == rParseNode.m_eNodeType) &&
+ (m_aNodeValue == rParseNode.m_aNodeValue) &&
+ count() == rParseNode.count();
+
+ // Parameters are not equal!
+ bResult = bResult && !SQL_ISRULE(this, parameter);
+
+ // compare childs
+ for (sal_uInt32 i=0; bResult && i < count(); i++)
+ bResult = *getChild(i) == *rParseNode.getChild(i);
+
+ return bResult;
+}
+
+//-----------------------------------------------------------------------------
+OSQLParseNode::~OSQLParseNode()
+{
+ for (OSQLParseNodes::const_iterator i = m_aChildren.begin();
+ i != m_aChildren.end(); i++)
+ delete *i;
+ m_aChildren.clear();
+}
+
+//-----------------------------------------------------------------------------
+void OSQLParseNode::append(OSQLParseNode* pNewNode)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::append" );
+
+ OSL_ENSURE(pNewNode != NULL, "OSQLParseNode: ungueltiger NewSubTree");
+ OSL_ENSURE(pNewNode->getParent() == NULL, "OSQLParseNode: Knoten ist kein Waise");
+ OSL_ENSURE(::std::find(m_aChildren.begin(), m_aChildren.end(), pNewNode) == m_aChildren.end(),
+ "OSQLParseNode::append() Node already element of parent");
+
+ // stelle Verbindung zum getParent her:
+ pNewNode->setParent( this );
+ // und haenge den SubTree hinten an
+ m_aChildren.push_back(pNewNode);
+}
+// -----------------------------------------------------------------------------
+sal_Bool OSQLParseNode::addDateValue(::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::addDateValue" );
+ // special display for date/time values
+ if (SQL_ISRULE(this,set_fct_spec) && SQL_ISPUNCTUATION(m_aChildren[0],"{"))
+ {
+ const OSQLParseNode* pODBCNode = m_aChildren[1];
+ const OSQLParseNode* pODBCNodeChild = pODBCNode->m_aChildren[0];
+
+ if (pODBCNodeChild->getNodeType() == SQL_NODE_KEYWORD && (
+ SQL_ISTOKEN(pODBCNodeChild, D) ||
+ SQL_ISTOKEN(pODBCNodeChild, T) ||
+ SQL_ISTOKEN(pODBCNodeChild, TS) ))
+ {
+ ::rtl::OUString suQuote(::rtl::OUString::createFromAscii("'"));
+ if (rParam.bPredicate)
+ {
+ if (rParam.aMetaData.shouldEscapeDateTime())
+ {
+ suQuote = ::rtl::OUString::createFromAscii("#");
+ }
+ }
+ else
+ {
+ if (rParam.aMetaData.shouldEscapeDateTime())
+ {
+ // suQuote = ::rtl::OUString::createFromAscii("'");
+ return sal_False;
+ }
+ }
+
+ if (rString.getLength())
+ rString.appendAscii(" ");
+ rString.append(suQuote);
+ const ::rtl::OUString sTokenValue = pODBCNode->m_aChildren[1]->getTokenValue();
+ if (SQL_ISTOKEN(pODBCNodeChild, D))
+ {
+ rString.append(rParam.bPredicate ? convertDateString(rParam, sTokenValue) : sTokenValue);
+ }
+ else if (SQL_ISTOKEN(pODBCNodeChild, T))
+ {
+ rString.append(rParam.bPredicate ? convertTimeString(rParam, sTokenValue) : sTokenValue);
+ }
+ else
+ {
+ rString.append(rParam.bPredicate ? convertDateTimeString(rParam, sTokenValue) : sTokenValue);
+ }
+ rString.append(suQuote);
+ return sal_True;
+ }
+ }
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+void OSQLParseNode::replaceNodeValue(const ::rtl::OUString& rTableAlias,const ::rtl::OUString& rColumnName)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::replaceNodeValue" );
+ for (sal_uInt32 i=0;i<count();++i)
+ {
+ if (SQL_ISRULE(this,column_ref) && count() == 1 && getChild(0)->getTokenValue() == rColumnName)
+ {
+ OSQLParseNode * pCol = removeAt((sal_uInt32)0);
+ append(new OSQLParseNode(rTableAlias,SQL_NODE_NAME));
+ append(new OSQLParseNode(::rtl::OUString::createFromAscii("."),SQL_NODE_PUNCTUATION));
+ append(pCol);
+ }
+ else
+ getChild(i)->replaceNodeValue(rTableAlias,rColumnName);
+ }
+}
+//-----------------------------------------------------------------------------
+OSQLParseNode* OSQLParseNode::getByRule(OSQLParseNode::Rule eRule) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::getByRule" );
+ OSQLParseNode* pRetNode = 0;
+ if (isRule() && OSQLParser::RuleID(eRule) == getRuleID())
+ pRetNode = (OSQLParseNode*)this;
+ else
+ {
+ for (OSQLParseNodes::const_iterator i = m_aChildren.begin();
+ !pRetNode && i != m_aChildren.end(); i++)
+ pRetNode = (*i)->getByRule(eRule);
+ }
+ return pRetNode;
+}
+//-----------------------------------------------------------------------------
+OSQLParseNode* MakeANDNode(OSQLParseNode *pLeftLeaf,OSQLParseNode *pRightLeaf)
+{
+ OSQLParseNode* pNewNode = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_term));
+ pNewNode->append(pLeftLeaf);
+ pNewNode->append(new OSQLParseNode(::rtl::OUString::createFromAscii("AND"),SQL_NODE_KEYWORD,SQL_TOKEN_AND));
+ pNewNode->append(pRightLeaf);
+ return pNewNode;
+}
+//-----------------------------------------------------------------------------
+OSQLParseNode* MakeORNode(OSQLParseNode *pLeftLeaf,OSQLParseNode *pRightLeaf)
+{
+ OSQLParseNode* pNewNode = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::search_condition));
+ pNewNode->append(pLeftLeaf);
+ pNewNode->append(new OSQLParseNode(::rtl::OUString::createFromAscii("OR"),SQL_NODE_KEYWORD,SQL_TOKEN_OR));
+ pNewNode->append(pRightLeaf);
+ return pNewNode;
+}
+//-----------------------------------------------------------------------------
+void OSQLParseNode::disjunctiveNormalForm(OSQLParseNode*& pSearchCondition)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::disjunctiveNormalForm" );
+ if(!pSearchCondition) // no where condition at entry point
+ return;
+
+ OSQLParseNode::absorptions(pSearchCondition);
+ // '(' search_condition ')'
+ if (SQL_ISRULE(pSearchCondition,boolean_primary))
+ {
+ OSQLParseNode* pLeft = pSearchCondition->getChild(1);
+ disjunctiveNormalForm(pLeft);
+ }
+ // search_condition SQL_TOKEN_OR boolean_term
+ else if (SQL_ISRULE(pSearchCondition,search_condition))
+ {
+ OSQLParseNode* pLeft = pSearchCondition->getChild(0);
+ disjunctiveNormalForm(pLeft);
+
+ OSQLParseNode* pRight = pSearchCondition->getChild(2);
+ disjunctiveNormalForm(pRight);
+ }
+ // boolean_term SQL_TOKEN_AND boolean_factor
+ else if (SQL_ISRULE(pSearchCondition,boolean_term))
+ {
+ OSQLParseNode* pLeft = pSearchCondition->getChild(0);
+ disjunctiveNormalForm(pLeft);
+
+ OSQLParseNode* pRight = pSearchCondition->getChild(2);
+ disjunctiveNormalForm(pRight);
+
+ OSQLParseNode* pNewNode = NULL;
+ // '(' search_condition ')' on left side
+ if(pLeft->count() == 3 && SQL_ISRULE(pLeft,boolean_primary) && SQL_ISRULE(pLeft->getChild(1),search_condition))
+ {
+ // and-or tree on left side
+ OSQLParseNode* pOr = pLeft->getChild(1);
+ OSQLParseNode* pNewLeft = NULL;
+ OSQLParseNode* pNewRight = NULL;
+
+ // cut right from parent
+ pSearchCondition->removeAt(2);
+
+ pNewRight = MakeANDNode(pOr->removeAt(2) ,pRight);
+ pNewLeft = MakeANDNode(pOr->removeAt((sal_uInt32)0) ,new OSQLParseNode(*pRight));
+ pNewNode = MakeORNode(pNewLeft,pNewRight);
+ // and append new Node
+ replaceAndReset(pSearchCondition,pNewNode);
+
+ disjunctiveNormalForm(pSearchCondition);
+ }
+ else if(pRight->count() == 3 && SQL_ISRULE(pRight,boolean_primary) && SQL_ISRULE(pRight->getChild(1),search_condition))
+ { // '(' search_condition ')' on right side
+ // and-or tree on right side
+ // a and (b or c)
+ OSQLParseNode* pOr = pRight->getChild(1);
+ OSQLParseNode* pNewLeft = NULL;
+ OSQLParseNode* pNewRight = NULL;
+
+ // cut left from parent
+ pSearchCondition->removeAt((sal_uInt32)0);
+
+ pNewRight = MakeANDNode(pLeft,pOr->removeAt(2));
+ pNewLeft = MakeANDNode(new OSQLParseNode(*pLeft),pOr->removeAt((sal_uInt32)0));
+ pNewNode = MakeORNode(pNewLeft,pNewRight);
+
+ // and append new Node
+ replaceAndReset(pSearchCondition,pNewNode);
+ disjunctiveNormalForm(pSearchCondition);
+ }
+ else if(SQL_ISRULE(pLeft,boolean_primary) && (!SQL_ISRULE(pLeft->getChild(1),search_condition) || !SQL_ISRULE(pLeft->getChild(1),boolean_term)))
+ pSearchCondition->replace(pLeft, pLeft->removeAt(1));
+ else if(SQL_ISRULE(pRight,boolean_primary) && (!SQL_ISRULE(pRight->getChild(1),search_condition) || !SQL_ISRULE(pRight->getChild(1),boolean_term)))
+ pSearchCondition->replace(pRight, pRight->removeAt(1));
+ }
+}
+//-----------------------------------------------------------------------------
+void OSQLParseNode::negateSearchCondition(OSQLParseNode*& pSearchCondition,sal_Bool bNegate)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::negateSearchCondition" );
+ if(!pSearchCondition) // no where condition at entry point
+ return;
+ // '(' search_condition ')'
+ if (pSearchCondition->count() == 3 && SQL_ISRULE(pSearchCondition,boolean_primary))
+ {
+ OSQLParseNode* pRight = pSearchCondition->getChild(1);
+ negateSearchCondition(pRight,bNegate);
+ }
+ // search_condition SQL_TOKEN_OR boolean_term
+ else if (SQL_ISRULE(pSearchCondition,search_condition))
+ {
+ OSQLParseNode* pLeft = pSearchCondition->getChild(0);
+ OSQLParseNode* pRight = pSearchCondition->getChild(2);
+ if(bNegate)
+ {
+ OSQLParseNode* pNewNode = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_term));
+ pNewNode->append(pSearchCondition->removeAt((sal_uInt32)0));
+ pNewNode->append(new OSQLParseNode(::rtl::OUString::createFromAscii("AND"),SQL_NODE_KEYWORD,SQL_TOKEN_AND));
+ pNewNode->append(pSearchCondition->removeAt((sal_uInt32)1));
+ replaceAndReset(pSearchCondition,pNewNode);
+
+ pLeft = pNewNode->getChild(0);
+ pRight = pNewNode->getChild(2);
+ }
+
+ negateSearchCondition(pLeft,bNegate);
+ negateSearchCondition(pRight,bNegate);
+ }
+ // boolean_term SQL_TOKEN_AND boolean_factor
+ else if (SQL_ISRULE(pSearchCondition,boolean_term))
+ {
+ OSQLParseNode* pLeft = pSearchCondition->getChild(0);
+ OSQLParseNode* pRight = pSearchCondition->getChild(2);
+ if(bNegate)
+ {
+ OSQLParseNode* pNewNode = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::search_condition));
+ pNewNode->append(pSearchCondition->removeAt((sal_uInt32)0));
+ pNewNode->append(new OSQLParseNode(::rtl::OUString::createFromAscii("OR"),SQL_NODE_KEYWORD,SQL_TOKEN_OR));
+ pNewNode->append(pSearchCondition->removeAt((sal_uInt32)1));
+ replaceAndReset(pSearchCondition,pNewNode);
+
+ pLeft = pNewNode->getChild(0);
+ pRight = pNewNode->getChild(2);
+ }
+
+ negateSearchCondition(pLeft,bNegate);
+ negateSearchCondition(pRight,bNegate);
+ }
+ // SQL_TOKEN_NOT ( boolean_test )
+ else if (SQL_ISRULE(pSearchCondition,boolean_factor))
+ {
+ OSQLParseNode *pNot = pSearchCondition->removeAt((sal_uInt32)0);
+ delete pNot;
+ OSQLParseNode *pBooleanTest = pSearchCondition->removeAt((sal_uInt32)0);
+ // TODO is this needed // pBooleanTest->setParent(NULL);
+ replaceAndReset(pSearchCondition,pBooleanTest);
+
+ if (!bNegate)
+ negateSearchCondition(pSearchCondition,sal_True); // negate all deeper values
+ }
+ // row_value_constructor comparison row_value_constructor
+ // row_value_constructor comparison any_all_some subquery
+ else if(bNegate && (SQL_ISRULE(pSearchCondition,comparison_predicate) || SQL_ISRULE(pSearchCondition,all_or_any_predicate)))
+ {
+ OSQLParseNode* pComparison = pSearchCondition->getChild(1);
+ OSQLParseNode* pNewComparison = NULL;
+ switch(pComparison->getNodeType())
+ {
+ case SQL_NODE_EQUAL:
+ pNewComparison = new OSQLParseNode(::rtl::OUString::createFromAscii("<>"),SQL_NODE_NOTEQUAL,SQL_NOTEQUAL);
+ break;
+ case SQL_NODE_LESS:
+ pNewComparison = new OSQLParseNode(::rtl::OUString::createFromAscii(">="),SQL_NODE_GREATEQ,SQL_GREATEQ);
+ break;
+ case SQL_NODE_GREAT:
+ pNewComparison = new OSQLParseNode(::rtl::OUString::createFromAscii("<="),SQL_NODE_LESSEQ,SQL_LESSEQ);
+ break;
+ case SQL_NODE_LESSEQ:
+ pNewComparison = new OSQLParseNode(::rtl::OUString::createFromAscii(">"),SQL_NODE_GREAT,SQL_GREAT);
+ break;
+ case SQL_NODE_GREATEQ:
+ pNewComparison = new OSQLParseNode(::rtl::OUString::createFromAscii("<"),SQL_NODE_LESS,SQL_LESS);
+ break;
+ case SQL_NODE_NOTEQUAL:
+ pNewComparison = new OSQLParseNode(::rtl::OUString::createFromAscii("="),SQL_NODE_EQUAL,SQL_EQUAL);
+ break;
+ default:
+ OSL_ENSURE( false, "OSQLParseNode::negateSearchCondition: unexpected node type!" );
+ break;
+ }
+ pSearchCondition->replace(pComparison, pNewComparison);
+ delete pComparison;
+ }
+
+ else if(bNegate && (SQL_ISRULE(pSearchCondition,test_for_null) || SQL_ISRULE(pSearchCondition,in_predicate) ||
+ SQL_ISRULE(pSearchCondition,between_predicate) || SQL_ISRULE(pSearchCondition,boolean_test) ))
+ {
+ OSQLParseNode* pPart2 = pSearchCondition;
+ if ( !SQL_ISRULE(pSearchCondition,boolean_test) )
+ pPart2 = pSearchCondition->getChild(1);
+ sal_uInt32 nNotPos = 0;
+ if ( SQL_ISRULE( pSearchCondition, test_for_null ) )
+ nNotPos = 1;
+ else if ( SQL_ISRULE( pSearchCondition, boolean_test ) )
+ nNotPos = 2;
+
+ OSQLParseNode* pNot = pPart2->getChild(nNotPos);
+ OSQLParseNode* pNotNot = NULL;
+ if(pNot->isRule())
+ pNotNot = new OSQLParseNode(::rtl::OUString::createFromAscii("NOT"),SQL_NODE_KEYWORD,SQL_TOKEN_NOT);
+ else
+ pNotNot = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::sql_not));
+ pPart2->replace(pNot, pNotNot);
+ delete pNot;
+ }
+ else if(bNegate && (SQL_ISRULE(pSearchCondition,like_predicate)))
+ {
+ OSQLParseNode* pNot = pSearchCondition->getChild( 1 )->getChild( 0 );
+ OSQLParseNode* pNotNot = NULL;
+ if(pNot->isRule())
+ pNotNot = new OSQLParseNode(::rtl::OUString::createFromAscii("NOT"),SQL_NODE_KEYWORD,SQL_TOKEN_NOT);
+ else
+ pNotNot = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::sql_not));
+ pSearchCondition->getChild( 1 )->replace(pNot, pNotNot);
+ delete pNot;
+ }
+}
+//-----------------------------------------------------------------------------
+void OSQLParseNode::eraseBraces(OSQLParseNode*& pSearchCondition)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::eraseBraces" );
+ if (pSearchCondition && (SQL_ISRULE(pSearchCondition,boolean_primary) || (pSearchCondition->count() == 3 && SQL_ISPUNCTUATION(pSearchCondition->getChild(0),"(") &&
+ SQL_ISPUNCTUATION(pSearchCondition->getChild(2),")"))))
+ {
+ OSQLParseNode* pRight = pSearchCondition->getChild(1);
+ absorptions(pRight);
+ // if child is not a or or and tree then delete () around child
+ if(!(SQL_ISRULE(pSearchCondition->getChild(1),boolean_term) || SQL_ISRULE(pSearchCondition->getChild(1),search_condition)) ||
+ SQL_ISRULE(pSearchCondition->getChild(1),boolean_term) || // and can always stand without ()
+ (SQL_ISRULE(pSearchCondition->getChild(1),search_condition) && SQL_ISRULE(pSearchCondition->getParent(),search_condition)))
+ {
+ OSQLParseNode* pNode = pSearchCondition->removeAt(1);
+ replaceAndReset(pSearchCondition,pNode);
+ }
+ }
+}
+//-----------------------------------------------------------------------------
+void OSQLParseNode::absorptions(OSQLParseNode*& pSearchCondition)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::absorptions" );
+ if(!pSearchCondition) // no where condition at entry point
+ return;
+
+ eraseBraces(pSearchCondition);
+
+ if(SQL_ISRULE(pSearchCondition,boolean_term) || SQL_ISRULE(pSearchCondition,search_condition))
+ {
+ OSQLParseNode* pLeft = pSearchCondition->getChild(0);
+ absorptions(pLeft);
+ OSQLParseNode* pRight = pSearchCondition->getChild(2);
+ absorptions(pRight);
+ }
+
+ sal_uInt32 nPos = 0;
+ // a and a || a or a
+ OSQLParseNode* pNewNode = NULL;
+ if(( SQL_ISRULE(pSearchCondition,boolean_term) || SQL_ISRULE(pSearchCondition,search_condition))
+ && *pSearchCondition->getChild(0) == *pSearchCondition->getChild(2))
+ {
+ pNewNode = pSearchCondition->removeAt((sal_uInt32)0);
+ replaceAndReset(pSearchCondition,pNewNode);
+ }
+ // (a or b) and a || ( b or c ) and a
+ // a and ( a or b) || a and ( b or c )
+ else if ( SQL_ISRULE(pSearchCondition,boolean_term)
+ && (
+ ( SQL_ISRULE(pSearchCondition->getChild(nPos = 0),boolean_primary)
+ || SQL_ISRULE(pSearchCondition->getChild(nPos),search_condition)
+ )
+ || ( SQL_ISRULE(pSearchCondition->getChild(nPos = 2),boolean_primary)
+ || SQL_ISRULE(pSearchCondition->getChild(nPos),search_condition)
+ )
+ )
+ )
+ {
+ OSQLParseNode* p2ndSearch = pSearchCondition->getChild(nPos);
+ if ( SQL_ISRULE(p2ndSearch,boolean_primary) )
+ p2ndSearch = p2ndSearch->getChild(1);
+
+ if ( *p2ndSearch->getChild(0) == *pSearchCondition->getChild(2-nPos) ) // a and ( a or b) -> a or b
+ {
+ pNewNode = pSearchCondition->removeAt((sal_uInt32)0);
+ replaceAndReset(pSearchCondition,pNewNode);
+
+ }
+ else if ( *p2ndSearch->getChild(2) == *pSearchCondition->getChild(2-nPos) ) // a and ( b or a) -> a or b
+ {
+ pNewNode = pSearchCondition->removeAt((sal_uInt32)2);
+ replaceAndReset(pSearchCondition,pNewNode);
+ }
+ else if ( p2ndSearch->getByRule(OSQLParseNode::search_condition) )
+ {
+ // a and ( b or c ) -> ( a and b ) or ( a and c )
+ // ( b or c ) and a -> ( a and b ) or ( a and c )
+ OSQLParseNode* pC = p2ndSearch->removeAt((sal_uInt32)2);
+ OSQLParseNode* pB = p2ndSearch->removeAt((sal_uInt32)0);
+ OSQLParseNode* pA = pSearchCondition->removeAt((sal_uInt32)2-nPos);
+
+ OSQLParseNode* p1stAnd = MakeANDNode(pA,pB);
+ OSQLParseNode* p2ndAnd = MakeANDNode(new OSQLParseNode(*pA),pC);
+ pNewNode = MakeORNode(p1stAnd,p2ndAnd);
+ OSQLParseNode* pNode = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_primary));
+ pNode->append(new OSQLParseNode(::rtl::OUString::createFromAscii("("),SQL_NODE_PUNCTUATION));
+ pNode->append(pNewNode);
+ pNode->append(new OSQLParseNode(::rtl::OUString::createFromAscii(")"),SQL_NODE_PUNCTUATION));
+ OSQLParseNode::eraseBraces(p1stAnd);
+ OSQLParseNode::eraseBraces(p2ndAnd);
+ replaceAndReset(pSearchCondition,pNode);
+ }
+ }
+ // a or a and b || a or b and a
+ else if(SQL_ISRULE(pSearchCondition,search_condition) && SQL_ISRULE(pSearchCondition->getChild(2),boolean_term))
+ {
+ if(*pSearchCondition->getChild(2)->getChild(0) == *pSearchCondition->getChild(0))
+ {
+ pNewNode = pSearchCondition->removeAt((sal_uInt32)0);
+ replaceAndReset(pSearchCondition,pNewNode);
+ }
+ else if(*pSearchCondition->getChild(2)->getChild(2) == *pSearchCondition->getChild(0))
+ {
+ pNewNode = pSearchCondition->removeAt((sal_uInt32)0);
+ replaceAndReset(pSearchCondition,pNewNode);
+ }
+ }
+ // a and b or a || b and a or a
+ else if(SQL_ISRULE(pSearchCondition,search_condition) && SQL_ISRULE(pSearchCondition->getChild(0),boolean_term))
+ {
+ if(*pSearchCondition->getChild(0)->getChild(0) == *pSearchCondition->getChild(2))
+ {
+ pNewNode = pSearchCondition->removeAt((sal_uInt32)2);
+ replaceAndReset(pSearchCondition,pNewNode);
+ }
+ else if(*pSearchCondition->getChild(0)->getChild(2) == *pSearchCondition->getChild(2))
+ {
+ pNewNode = pSearchCondition->removeAt((sal_uInt32)2);
+ replaceAndReset(pSearchCondition,pNewNode);
+ }
+ }
+ eraseBraces(pSearchCondition);
+}
+//-----------------------------------------------------------------------------
+void OSQLParseNode::compress(OSQLParseNode *&pSearchCondition)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::compress" );
+ if(!pSearchCondition) // no where condition at entry point
+ return;
+
+ OSQLParseNode::eraseBraces(pSearchCondition);
+
+ if(SQL_ISRULE(pSearchCondition,boolean_term) || SQL_ISRULE(pSearchCondition,search_condition))
+ {
+ OSQLParseNode* pLeft = pSearchCondition->getChild(0);
+ compress(pLeft);
+
+ OSQLParseNode* pRight = pSearchCondition->getChild(2);
+ compress(pRight);
+ }
+ else if( SQL_ISRULE(pSearchCondition,boolean_primary) || (pSearchCondition->count() == 3 && SQL_ISPUNCTUATION(pSearchCondition->getChild(0),"(") &&
+ SQL_ISPUNCTUATION(pSearchCondition->getChild(2),")")))
+ {
+ OSQLParseNode* pRight = pSearchCondition->getChild(1);
+ compress(pRight);
+ // if child is not a or or and tree then delete () around child
+ if(!(SQL_ISRULE(pSearchCondition->getChild(1),boolean_term) || SQL_ISRULE(pSearchCondition->getChild(1),search_condition)) ||
+ (SQL_ISRULE(pSearchCondition->getChild(1),boolean_term) && SQL_ISRULE(pSearchCondition->getParent(),boolean_term)) ||
+ (SQL_ISRULE(pSearchCondition->getChild(1),search_condition) && SQL_ISRULE(pSearchCondition->getParent(),search_condition)))
+ {
+ OSQLParseNode* pNode = pSearchCondition->removeAt(1);
+ replaceAndReset(pSearchCondition,pNode);
+ }
+ }
+
+ // or with two and trees where one element of the and trees are equal
+ if(SQL_ISRULE(pSearchCondition,search_condition) && SQL_ISRULE(pSearchCondition->getChild(0),boolean_term) && SQL_ISRULE(pSearchCondition->getChild(2),boolean_term))
+ {
+ if(*pSearchCondition->getChild(0)->getChild(0) == *pSearchCondition->getChild(2)->getChild(0))
+ {
+ OSQLParseNode* pLeft = pSearchCondition->getChild(0)->removeAt(2);
+ OSQLParseNode* pRight = pSearchCondition->getChild(2)->removeAt(2);
+ OSQLParseNode* pNode = MakeORNode(pLeft,pRight);
+
+ OSQLParseNode* pNewRule = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_primary));
+ pNewRule->append(new OSQLParseNode(::rtl::OUString::createFromAscii("("),SQL_NODE_PUNCTUATION));
+ pNewRule->append(pNode);
+ pNewRule->append(new OSQLParseNode(::rtl::OUString::createFromAscii(")"),SQL_NODE_PUNCTUATION));
+
+ OSQLParseNode::eraseBraces(pLeft);
+ OSQLParseNode::eraseBraces(pRight);
+
+ pNode = MakeANDNode(pSearchCondition->getChild(0)->removeAt((sal_uInt32)0),pNewRule);
+ replaceAndReset(pSearchCondition,pNode);
+ }
+ else if(*pSearchCondition->getChild(0)->getChild(2) == *pSearchCondition->getChild(2)->getChild(0))
+ {
+ OSQLParseNode* pLeft = pSearchCondition->getChild(0)->removeAt((sal_uInt32)0);
+ OSQLParseNode* pRight = pSearchCondition->getChild(2)->removeAt(2);
+ OSQLParseNode* pNode = MakeORNode(pLeft,pRight);
+
+ OSQLParseNode* pNewRule = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_primary));
+ pNewRule->append(new OSQLParseNode(::rtl::OUString::createFromAscii("("),SQL_NODE_PUNCTUATION));
+ pNewRule->append(pNode);
+ pNewRule->append(new OSQLParseNode(::rtl::OUString::createFromAscii(")"),SQL_NODE_PUNCTUATION));
+
+ OSQLParseNode::eraseBraces(pLeft);
+ OSQLParseNode::eraseBraces(pRight);
+
+ pNode = MakeANDNode(pSearchCondition->getChild(0)->removeAt(1),pNewRule);
+ replaceAndReset(pSearchCondition,pNode);
+ }
+ else if(*pSearchCondition->getChild(0)->getChild(0) == *pSearchCondition->getChild(2)->getChild(2))
+ {
+ OSQLParseNode* pLeft = pSearchCondition->getChild(0)->removeAt(2);
+ OSQLParseNode* pRight = pSearchCondition->getChild(2)->removeAt((sal_uInt32)0);
+ OSQLParseNode* pNode = MakeORNode(pLeft,pRight);
+
+ OSQLParseNode* pNewRule = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_primary));
+ pNewRule->append(new OSQLParseNode(::rtl::OUString::createFromAscii("("),SQL_NODE_PUNCTUATION));
+ pNewRule->append(pNode);
+ pNewRule->append(new OSQLParseNode(::rtl::OUString::createFromAscii(")"),SQL_NODE_PUNCTUATION));
+
+ OSQLParseNode::eraseBraces(pLeft);
+ OSQLParseNode::eraseBraces(pRight);
+
+ pNode = MakeANDNode(pSearchCondition->getChild(0)->removeAt((sal_uInt32)0),pNewRule);
+ replaceAndReset(pSearchCondition,pNode);
+ }
+ else if(*pSearchCondition->getChild(0)->getChild(2) == *pSearchCondition->getChild(2)->getChild(2))
+ {
+ OSQLParseNode* pLeft = pSearchCondition->getChild(0)->removeAt((sal_uInt32)0);
+ OSQLParseNode* pRight = pSearchCondition->getChild(2)->removeAt((sal_uInt32)0);
+ OSQLParseNode* pNode = MakeORNode(pLeft,pRight);
+
+ OSQLParseNode* pNewRule = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_primary));
+ pNewRule->append(new OSQLParseNode(::rtl::OUString::createFromAscii("("),SQL_NODE_PUNCTUATION));
+ pNewRule->append(pNode);
+ pNewRule->append(new OSQLParseNode(::rtl::OUString::createFromAscii(")"),SQL_NODE_PUNCTUATION));
+
+ OSQLParseNode::eraseBraces(pLeft);
+ OSQLParseNode::eraseBraces(pRight);
+
+ pNode = MakeANDNode(pSearchCondition->getChild(0)->removeAt(1),pNewRule);
+ replaceAndReset(pSearchCondition,pNode);
+ }
+ }
+}
+#if OSL_DEBUG_LEVEL > 0
+// -----------------------------------------------------------------------------
+void OSQLParseNode::showParseTree( ::rtl::OUString& rString ) const
+{
+ ::rtl::OUStringBuffer aBuf;
+ showParseTree( aBuf, 0 );
+ rString = aBuf.makeStringAndClear();
+}
+
+// -----------------------------------------------------------------------------
+void OSQLParseNode::showParseTree( ::rtl::OUStringBuffer& _inout_rBuffer, sal_uInt32 nLevel ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::showParseTree" );
+
+ for ( sal_uInt32 j=0; j<nLevel; ++j)
+ _inout_rBuffer.appendAscii( " " );
+
+ if ( !isToken() )
+ {
+ // Regelnamen als rule: ...
+ _inout_rBuffer.appendAscii( "RULE_ID: " );
+ _inout_rBuffer.append( (sal_Int32)getRuleID() );
+ _inout_rBuffer.append( sal_Unicode( '(' ) );
+ _inout_rBuffer.append( OSQLParser::RuleIDToStr( getRuleID() ) );
+ _inout_rBuffer.append( sal_Unicode( ')' ) );
+ _inout_rBuffer.append( sal_Unicode( '\n' ) );
+
+ // hol dir den ersten Subtree
+ for ( OSQLParseNodes::const_iterator i = m_aChildren.begin();
+ i != m_aChildren.end();
+ ++i
+ )
+ (*i)->showParseTree( _inout_rBuffer, nLevel+1 );
+ }
+ else
+ {
+ // ein Token gefunden
+ switch (m_eNodeType)
+ {
+
+ case SQL_NODE_KEYWORD:
+ _inout_rBuffer.appendAscii( "SQL_KEYWORD: " );
+ _inout_rBuffer.append( ::rtl::OStringToOUString( OSQLParser::TokenIDToStr( getTokenID() ), RTL_TEXTENCODING_UTF8 ) );
+ _inout_rBuffer.append( sal_Unicode( '\n' ) );
+ break;
+
+ case SQL_NODE_COMPARISON:
+ _inout_rBuffer.appendAscii( "SQL_COMPARISON: " );
+ _inout_rBuffer.append( m_aNodeValue );
+ _inout_rBuffer.append( sal_Unicode( '\n' ) );
+ break;
+
+ case SQL_NODE_NAME:
+ _inout_rBuffer.appendAscii( "SQL_NAME: " );
+ _inout_rBuffer.append( sal_Unicode( '"' ) );
+ _inout_rBuffer.append( m_aNodeValue );
+ _inout_rBuffer.append( sal_Unicode( '"' ) );
+ _inout_rBuffer.append( sal_Unicode( '\n' ) );
+ break;
+
+ case SQL_NODE_STRING:
+ _inout_rBuffer.appendAscii( "SQL_STRING: " );
+ _inout_rBuffer.append( sal_Unicode( '\'' ) );
+ _inout_rBuffer.append( m_aNodeValue );
+ _inout_rBuffer.append( sal_Unicode( '\'' ) );
+ _inout_rBuffer.append( sal_Unicode( '\n' ) );
+ break;
+
+ case SQL_NODE_INTNUM:
+ _inout_rBuffer.appendAscii( "SQL_INTNUM: " );
+ _inout_rBuffer.append( m_aNodeValue );
+ _inout_rBuffer.append( sal_Unicode( '\n' ) );
+ break;
+
+ case SQL_NODE_APPROXNUM:
+ _inout_rBuffer.appendAscii( "SQL_APPROXNUM: " );
+ _inout_rBuffer.append( m_aNodeValue );
+ _inout_rBuffer.append( sal_Unicode( '\n' ) );
+ break;
+
+ case SQL_NODE_PUNCTUATION:
+ _inout_rBuffer.appendAscii( "SQL_PUNCTUATION: " );
+ _inout_rBuffer.append( m_aNodeValue );
+ _inout_rBuffer.append( sal_Unicode( '\n' ) );
+ break;
+
+ case SQL_NODE_AMMSC:
+ _inout_rBuffer.appendAscii( "SQL_AMMSC: " );
+ _inout_rBuffer.append( m_aNodeValue );
+ _inout_rBuffer.append( sal_Unicode( '\n' ) );
+ break;
+
+ case SQL_NODE_EQUAL:
+ case SQL_NODE_LESS:
+ case SQL_NODE_GREAT:
+ case SQL_NODE_LESSEQ:
+ case SQL_NODE_GREATEQ:
+ case SQL_NODE_NOTEQUAL:
+ _inout_rBuffer.append( m_aNodeValue );
+ _inout_rBuffer.append( sal_Unicode( '\n' ) );
+ break;
+
+ case SQL_NODE_ACCESS_DATE:
+ _inout_rBuffer.appendAscii( "SQL_ACCESS_DATE: " );
+ _inout_rBuffer.append( m_aNodeValue );
+ _inout_rBuffer.append( sal_Unicode( '\n' ) );
+ break;
+
+ case SQL_NODE_DATE:
+ _inout_rBuffer.appendAscii( "SQL_DATE: " );
+ _inout_rBuffer.append( m_aNodeValue );
+ _inout_rBuffer.append( sal_Unicode( '\n' ) );
+ break;
+
+ case SQL_NODE_CONCAT:
+ _inout_rBuffer.appendAscii( "||" );
+ _inout_rBuffer.append( sal_Unicode( '\n' ) );
+ break;
+
+ default:
+ OSL_TRACE( "-- %i", int( m_eNodeType ) );
+ OSL_ENSURE( false, "OSQLParser::ShowParseTree: unzulaessiger NodeType" );
+ }
+ }
+}
+#endif // OSL_DEBUG_LEVEL > 0
+// -----------------------------------------------------------------------------
+// Insert-Methoden
+//-----------------------------------------------------------------------------
+void OSQLParseNode::insert(sal_uInt32 nPos, OSQLParseNode* pNewSubTree)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::insert" );
+ OSL_ENSURE(pNewSubTree != NULL, "OSQLParseNode: ungueltiger NewSubTree");
+ OSL_ENSURE(pNewSubTree->getParent() == NULL, "OSQLParseNode: Knoten ist kein Waise");
+
+ // stelle Verbindung zum getParent her:
+ pNewSubTree->setParent( this );
+ m_aChildren.insert(m_aChildren.begin() + nPos, pNewSubTree);
+}
+
+// removeAt-Methoden
+//-----------------------------------------------------------------------------
+OSQLParseNode* OSQLParseNode::removeAt(sal_uInt32 nPos)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::removeAt" );
+ OSL_ENSURE(nPos < m_aChildren.size(),"Illegal position for removeAt");
+ OSQLParseNodes::iterator aPos(m_aChildren.begin() + nPos);
+ OSQLParseNode* pNode = *aPos;
+
+ // setze den getParent des removeten auf NULL
+ pNode->setParent( NULL );
+
+ m_aChildren.erase(aPos);
+ return pNode;
+}
+//-----------------------------------------------------------------------------
+OSQLParseNode* OSQLParseNode::remove(OSQLParseNode* pSubTree)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::remove" );
+ OSL_ENSURE(pSubTree != NULL, "OSQLParseNode: ungueltiger SubTree");
+ OSQLParseNodes::iterator aPos = ::std::find(m_aChildren.begin(), m_aChildren.end(), pSubTree);
+ if (aPos != m_aChildren.end())
+ {
+ // setze den getParent des removeten auf NULL
+ pSubTree->setParent( NULL );
+ m_aChildren.erase(aPos);
+ return pSubTree;
+ }
+ else
+ return NULL;
+}
+
+// Replace-Methoden
+//-----------------------------------------------------------------------------
+OSQLParseNode* OSQLParseNode::replaceAt(sal_uInt32 nPos, OSQLParseNode* pNewSubNode)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::replaceAt" );
+ OSL_ENSURE(pNewSubNode != NULL, "OSQLParseNode: invalid nodes");
+ OSL_ENSURE(pNewSubNode->getParent() == NULL, "OSQLParseNode: node already has getParent");
+ OSL_ENSURE(nPos < m_aChildren.size(), "OSQLParseNode: invalid position");
+ OSL_ENSURE(::std::find(m_aChildren.begin(), m_aChildren.end(), pNewSubNode) == m_aChildren.end(),
+ "OSQLParseNode::Replace() Node already element of parent");
+
+ OSQLParseNode* pOldSubNode = m_aChildren[nPos];
+
+ // stelle Verbindung zum getParent her:
+ pNewSubNode->setParent( this );
+ pOldSubNode->setParent( NULL );
+
+ m_aChildren[nPos] = pNewSubNode;
+ return pOldSubNode;
+}
+
+//-----------------------------------------------------------------------------
+OSQLParseNode* OSQLParseNode::replace (OSQLParseNode* pOldSubNode, OSQLParseNode* pNewSubNode )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::replace " );
+ OSL_ENSURE(pOldSubNode != NULL && pNewSubNode != NULL, "OSQLParseNode: invalid nodes");
+ OSL_ENSURE(pNewSubNode->getParent() == NULL, "OSQLParseNode: node already has getParent");
+ OSL_ENSURE(::std::find(m_aChildren.begin(), m_aChildren.end(), pOldSubNode) != m_aChildren.end(),
+ "OSQLParseNode::Replace() Node not element of parent");
+ OSL_ENSURE(::std::find(m_aChildren.begin(), m_aChildren.end(), pNewSubNode) == m_aChildren.end(),
+ "OSQLParseNode::Replace() Node already element of parent");
+
+ pOldSubNode->setParent( NULL );
+ pNewSubNode->setParent( this );
+ ::std::replace(m_aChildren.begin(), m_aChildren.end(), pOldSubNode, pNewSubNode);
+ return pOldSubNode;
+}
+// -----------------------------------------------------------------------------
+void OSQLParseNode::parseLeaf(::rtl::OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::parseLeaf" );
+ // ein Blatt ist gefunden
+ // Inhalt dem Ausgabestring anfuegen
+ switch (m_eNodeType)
+ {
+ case SQL_NODE_KEYWORD:
+ {
+ if (rString.getLength())
+ rString.appendAscii(" ");
+
+ const ::rtl::OString sT = OSQLParser::TokenIDToStr(m_nNodeID, &rParam.m_rContext);
+ rString.append(::rtl::OUString(sT,sT.getLength(),RTL_TEXTENCODING_UTF8));
+ } break;
+ case SQL_NODE_STRING:
+ if (rString.getLength())
+ rString.appendAscii(" ");
+ rString.append(SetQuotation(m_aNodeValue,::rtl::OUString::createFromAscii("\'"),::rtl::OUString::createFromAscii("\'\'")));
+ break;
+ case SQL_NODE_NAME:
+ if (rString.getLength())
+ {
+ switch(rString.charAt(rString.getLength()-1) )
+ {
+ case ' ' :
+ case '.' : break;
+ default :
+ if ( !rParam.aMetaData.getCatalogSeparator().getLength()
+ || rString.charAt( rString.getLength()-1 ) != rParam.aMetaData.getCatalogSeparator().toChar()
+ )
+ rString.appendAscii(" "); break;
+ }
+ }
+ if (rParam.bQuote)
+ {
+ if (rParam.bPredicate)
+ {
+ rString.appendAscii("[");
+ rString.append(m_aNodeValue);
+ rString.appendAscii("]");
+ }
+ else
+ rString.append(SetQuotation(m_aNodeValue,
+ rParam.aMetaData.getIdentifierQuoteString(), rParam.aMetaData.getIdentifierQuoteString() ));
+ }
+ else
+ rString.append(m_aNodeValue);
+ break;
+ case SQL_NODE_ACCESS_DATE:
+ if (rString.getLength())
+ rString.appendAscii(" ");
+ rString.appendAscii("#");
+ rString.append(m_aNodeValue);
+ rString.appendAscii("#");
+ break;
+ case SQL_NODE_INTNUM:
+ case SQL_NODE_APPROXNUM:
+ {
+ ::rtl::OUString aTmp = m_aNodeValue;
+ if (rParam.bInternational && rParam.bPredicate && rParam.cDecSep != '.')
+ aTmp = aTmp.replace('.', rParam.cDecSep);
+
+ if (rString.getLength())
+ rString.appendAscii(" ");
+ rString.append(aTmp);
+
+ } break;
+ // fall through
+ default:
+ if (rString.getLength() && m_aNodeValue.toChar() != '.' && m_aNodeValue.toChar() != ':' )
+ {
+ switch( rString.charAt(rString.getLength()-1) )
+ {
+ case ' ' :
+ case '.' : break;
+ default :
+ if ( !rParam.aMetaData.getCatalogSeparator().getLength()
+ || rString.charAt( rString.getLength()-1 ) != rParam.aMetaData.getCatalogSeparator().toChar()
+ )
+ rString.appendAscii(" "); break;
+ }
+ }
+ rString.append(m_aNodeValue);
+ }
+}
+
+// -----------------------------------------------------------------------------
+sal_Int32 OSQLParser::getFunctionReturnType(const ::rtl::OUString& _sFunctionName, const IParseContext* pContext)
+{
+ sal_Int32 nType = DataType::VARCHAR;
+ ::rtl::OString sFunctionName(_sFunctionName,_sFunctionName.getLength(),RTL_TEXTENCODING_UTF8);
+
+ if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_ASCII,pContext))) nType = DataType::INTEGER;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_BIT_LENGTH,pContext))) nType = DataType::INTEGER;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_CHAR,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_CHAR_LENGTH,pContext))) nType = DataType::INTEGER;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_CONCAT,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_DIFFERENCE,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_INSERT,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_LCASE,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_LEFT,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_LENGTH,pContext))) nType = DataType::INTEGER;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_LOCATE,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_LOCATE_2,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_LTRIM,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_OCTET_LENGTH,pContext))) nType = DataType::INTEGER;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_POSITION,pContext))) nType = DataType::INTEGER;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_REPEAT,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_REPLACE,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_RIGHT,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_RTRIM,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_SOUNDEX,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_SPACE,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_SUBSTRING,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_UCASE,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_CURRENT_DATE,pContext))) nType = DataType::DATE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_CURRENT_TIME,pContext))) nType = DataType::TIME;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_CURRENT_TIMESTAMP,pContext))) nType = DataType::TIMESTAMP;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_CURDATE,pContext))) nType = DataType::DATE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_DATEDIFF,pContext))) nType = DataType::INTEGER;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_DATEVALUE,pContext))) nType = DataType::DATE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_CURTIME,pContext))) nType = DataType::TIME;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_DAYNAME,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_DAYOFMONTH,pContext))) nType = DataType::INTEGER;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_DAYOFWEEK,pContext))) nType = DataType::INTEGER;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_DAYOFYEAR,pContext))) nType = DataType::INTEGER;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_EXTRACT,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_HOUR,pContext))) nType = DataType::INTEGER;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_MINUTE,pContext))) nType = DataType::INTEGER;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_MONTH,pContext))) nType = DataType::INTEGER;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_MONTHNAME,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_NOW,pContext))) nType = DataType::TIMESTAMP;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_QUARTER,pContext))) nType = DataType::INTEGER;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_SECOND,pContext))) nType = DataType::INTEGER;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_TIMESTAMPADD,pContext))) nType = DataType::TIMESTAMP;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_TIMESTAMPDIFF,pContext))) nType = DataType::TIMESTAMP;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_TIMEVALUE,pContext))) nType = DataType::TIMESTAMP;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_WEEK,pContext))) nType = DataType::INTEGER;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_YEAR,pContext))) nType = DataType::INTEGER;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_ABS,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_ACOS,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_ASIN,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_ATAN,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_ATAN2,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_CEILING,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_COS,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_COT,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_DEGREES,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_EXP,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_FLOOR,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_LOGF,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_LOG,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_LOG10,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_LN,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_MOD,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_PI,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_POWER,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_RADIANS,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_RAND,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_ROUND,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_ROUNDMAGIC,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_SIGN,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_SIN,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_SQRT,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_TAN,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_TRUNCATE,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_COUNT,pContext))) nType = DataType::INTEGER;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_MAX,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_MIN,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_AVG,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_SUM,pContext))) nType = DataType::DOUBLE;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_LOWER,pContext))) nType = DataType::VARCHAR;
+ else if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_UPPER,pContext))) nType = DataType::VARCHAR;
+
+ return nType;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OSQLParser::getFunctionParameterType(sal_uInt32 _nTokenId, sal_uInt32 _nPos)
+{
+ sal_Int32 nType = DataType::VARCHAR;
+
+ if(_nTokenId == SQL_TOKEN_CHAR) nType = DataType::INTEGER;
+ else if(_nTokenId == SQL_TOKEN_INSERT)
+ {
+ if ( _nPos == 2 || _nPos == 3 )
+ nType = DataType::INTEGER;
+ }
+ else if(_nTokenId == SQL_TOKEN_LEFT)
+ {
+ if ( _nPos == 2 )
+ nType = DataType::INTEGER;
+ }
+ else if(_nTokenId == SQL_TOKEN_LOCATE)
+ {
+ if ( _nPos == 3 )
+ nType = DataType::INTEGER;
+ }
+ else if(_nTokenId == SQL_TOKEN_LOCATE_2)
+ {
+ if ( _nPos == 3 )
+ nType = DataType::INTEGER;
+ }
+ else if( _nTokenId == SQL_TOKEN_REPEAT || _nTokenId == SQL_TOKEN_RIGHT )
+ {
+ if ( _nPos == 2 )
+ nType = DataType::INTEGER;
+ }
+ else if(_nTokenId == SQL_TOKEN_SPACE )
+ {
+ nType = DataType::INTEGER;
+ }
+ else if(_nTokenId == SQL_TOKEN_SUBSTRING)
+ {
+ if ( _nPos != 1 )
+ nType = DataType::INTEGER;
+ }
+ else if(_nTokenId == SQL_TOKEN_DATEDIFF)
+ {
+ if ( _nPos != 1 )
+ nType = DataType::TIMESTAMP;
+ }
+ else if(_nTokenId == SQL_TOKEN_DATEVALUE)
+ nType = DataType::DATE;
+ else if(_nTokenId == SQL_TOKEN_DAYNAME)
+ nType = DataType::DATE;
+ else if(_nTokenId == SQL_TOKEN_DAYOFMONTH)
+ nType = DataType::DATE;
+ else if(_nTokenId == SQL_TOKEN_DAYOFWEEK)
+ nType = DataType::DATE;
+ else if(_nTokenId == SQL_TOKEN_DAYOFYEAR)
+ nType = DataType::DATE;
+ else if(_nTokenId == SQL_TOKEN_EXTRACT) nType = DataType::VARCHAR;
+ else if(_nTokenId == SQL_TOKEN_HOUR) nType = DataType::TIME;
+ else if(_nTokenId == SQL_TOKEN_MINUTE) nType = DataType::TIME;
+ else if(_nTokenId == SQL_TOKEN_MONTH) nType = DataType::DATE;
+ else if(_nTokenId == SQL_TOKEN_MONTHNAME) nType = DataType::DATE;
+ else if(_nTokenId == SQL_TOKEN_NOW) nType = DataType::TIMESTAMP;
+ else if(_nTokenId == SQL_TOKEN_QUARTER) nType = DataType::DATE;
+ else if(_nTokenId == SQL_TOKEN_SECOND) nType = DataType::TIME;
+ else if(_nTokenId == SQL_TOKEN_TIMESTAMPADD) nType = DataType::TIMESTAMP;
+ else if(_nTokenId == SQL_TOKEN_TIMESTAMPDIFF) nType = DataType::TIMESTAMP;
+ else if(_nTokenId == SQL_TOKEN_TIMEVALUE) nType = DataType::TIMESTAMP;
+ else if(_nTokenId == SQL_TOKEN_WEEK) nType = DataType::DATE;
+ else if(_nTokenId == SQL_TOKEN_YEAR) nType = DataType::DATE;
+
+ else if(_nTokenId == SQL_TOKEN_ABS) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_ACOS) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_ASIN) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_ATAN) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_ATAN2) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_CEILING) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_COS) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_COT) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_DEGREES) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_EXP) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_FLOOR) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_LOGF) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_LOG) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_LOG10) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_LN) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_MOD) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_PI) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_POWER) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_RADIANS) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_RAND) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_ROUND) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_ROUNDMAGIC) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_SIGN) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_SIN) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_SQRT) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_TAN) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_TRUNCATE) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_COUNT) nType = DataType::INTEGER;
+ else if(_nTokenId == SQL_TOKEN_MAX) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_MIN) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_AVG) nType = DataType::DOUBLE;
+ else if(_nTokenId == SQL_TOKEN_SUM) nType = DataType::DOUBLE;
+
+ else if(_nTokenId == SQL_TOKEN_LOWER) nType = DataType::VARCHAR;
+ else if(_nTokenId == SQL_TOKEN_UPPER) nType = DataType::VARCHAR;
+
+ return nType;
+}
+
+// -----------------------------------------------------------------------------
+const SQLError& OSQLParser::getErrorHelper() const
+{
+ return m_pData->aErrors;
+}
+
+// -----------------------------------------------------------------------------
+OSQLParseNode::Rule OSQLParseNode::getKnownRuleID() const
+{
+ if ( !isRule() )
+ return UNKNOWN_RULE;
+ return OSQLParser::RuleIDToRule( getRuleID() );
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OSQLParseNode::getTableRange(const OSQLParseNode* _pTableRef)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::getTableRange" );
+ OSL_ENSURE(_pTableRef && _pTableRef->count() > 1 && _pTableRef->getKnownRuleID() == OSQLParseNode::table_ref,"Invalid node give, only table ref is allowed!");
+ const sal_uInt32 nCount = _pTableRef->count();
+ ::rtl::OUString sTableRange;
+ if ( nCount == 2 || (nCount == 3 && !_pTableRef->getChild(0)->isToken()) || nCount == 5 )
+ {
+ const OSQLParseNode* pNode = _pTableRef->getChild(nCount - (nCount == 2 ? 1 : 2));
+ OSL_ENSURE(pNode && (pNode->getKnownRuleID() == OSQLParseNode::table_primary_as_range_column
+ || pNode->getKnownRuleID() == OSQLParseNode::range_variable)
+ ,"SQL grammar changed!");
+ if ( !pNode->isLeaf() )
+ sTableRange = pNode->getChild(1)->getTokenValue();
+ } // if ( nCount == 2 || nCount == 3 || nCount == 5)
+
+ return sTableRange;
+}
+// -----------------------------------------------------------------------------
+OSQLParseNodesContainer::OSQLParseNodesContainer()
+{
+}
+// -----------------------------------------------------------------------------
+OSQLParseNodesContainer::~OSQLParseNodesContainer()
+{
+}
+// -----------------------------------------------------------------------------
+void OSQLParseNodesContainer::push_back(OSQLParseNode* _pNode)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ m_aNodes.push_back(_pNode);
+}
+// -----------------------------------------------------------------------------
+void OSQLParseNodesContainer::erase(OSQLParseNode* _pNode)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ if ( !m_aNodes.empty() )
+ {
+ ::std::vector< OSQLParseNode* >::iterator aFind = ::std::find(m_aNodes.begin(), m_aNodes.end(),_pNode);
+ if ( aFind != m_aNodes.end() )
+ m_aNodes.erase(aFind);
+ }
+}
+// -----------------------------------------------------------------------------
+bool OSQLParseNodesContainer::empty() const
+{
+ return m_aNodes.empty();
+}
+// -----------------------------------------------------------------------------
+void OSQLParseNodesContainer::clear()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ m_aNodes.clear();
+}
+// -----------------------------------------------------------------------------
+void OSQLParseNodesContainer::clearAndDelete()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ // clear the garbage collector
+ while ( !m_aNodes.empty() )
+ {
+ OSQLParseNode* pNode = m_aNodes[0];
+ while ( pNode->getParent() )
+ {
+ pNode = pNode->getParent();
+ }
+ delete pNode;
+ }
+}
+} // namespace connectivity
diff --git a/connectivity/source/parse/wrap_sqlbison.cxx b/connectivity/source/parse/wrap_sqlbison.cxx
new file mode 100644
index 000000000000..17993a194bc5
--- /dev/null
+++ b/connectivity/source/parse/wrap_sqlbison.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "sqlbison.cxx"
diff --git a/connectivity/source/parse/wrap_sqlflex.cxx b/connectivity/source/parse/wrap_sqlflex.cxx
new file mode 100644
index 000000000000..2cb5ad64ee5b
--- /dev/null
+++ b/connectivity/source/parse/wrap_sqlflex.cxx
@@ -0,0 +1,35 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.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:4505)
+#endif
+
+#include "sqlflex.cxx"
diff --git a/connectivity/source/resource/conn_error_message.src b/connectivity/source/resource/conn_error_message.src
new file mode 100644
index 000000000000..7a5267f33058
--- /dev/null
+++ b/connectivity/source/resource/conn_error_message.src
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// note: the resource IDs of the strings herein *must* correspond to the
+// com::sun::star::sdb::ErrorCondition values.
+//
+// For a given error condition value n, the message string must have ID
+// <code>256 + 2*n</code>, and the SQL state string (if applicable) must
+// have ID <code>256 + 2*n + 1</code>.
+//
+// The messages must be localized, the SQL states must *not*.
+
+// ROW_SET_OPERATION_VETOED = 100
+String 256 + 2*100 + 0
+{
+ Text [ en-US ] = "The record operation has been vetoed.";
+};
+
+// PARSER_CYCLIC_SUB_QUERIES = 200
+String 256 + 2*200 + 0
+{
+ Text [ en-US ] = "The statement contains a cyclic reference to one or more sub queries.";
+};
+
+// DB_OBJECT_NAME_WITH_SLASHES = 300
+String 256 + 2*300 + 0
+{
+ Text [ en-US ] = "The name must not contain any slashes ('/').";
+};
+
+// DB_INVALID_SQL_NAME = 301
+String 256 + 2*301 + 0
+{
+ Text [ en-US ] = "$1$ is no SQL conform identifier.";
+};
+
+// DB_QUERY_NAME_WITH_QUOTES = 302
+String 256 + 2*302 + 0
+{
+ Text [ en-US ] = "Query names must not contain quote characters.";
+};
+
+// DB_OBJECT_NAME_IS_USED = 303
+String 256 + 2*303 + 0
+{
+ Text [ en-US ] = "The name '$1$' is already in use in the database.";
+};
+
+// DB_NOT_CONNECTED = 304
+String 256 + 2*304 + 0
+{
+ Text [ en-US ] = "No connection to the database exists.";
+};
+
+String 256 + 2*304 + 1
+{
+ Text = "08003";
+};
+
+String 256 + 2*500 + 0
+{
+ Text [ en-US ] = "No $1$ exists.";
+};
+
+// DATA_CANNOT_SELECT_UNFILTERED = 550
+String 256 + 2*550 + 0
+{
+ Text [ en-US ] = "Unable to display the complete table content. Please apply a filter.";
+};
+
+String 256 + 2*550 + 1
+{
+ Text = "IM001";
+};
+
diff --git a/connectivity/source/resource/conn_log_res.src b/connectivity/source/resource/conn_log_res.src
new file mode 100644
index 000000000000..ea5bb9d00072
--- /dev/null
+++ b/connectivity/source/resource/conn_log_res.src
@@ -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.
+ *
+ ************************************************************************/
+
+#include "resource/jdbc_log.hrc"
+
+// ============================================================================
+// = log messages for the JDBC driver
+// ============================================================================
+
+String STR_LOG_DRIVER_CONNECTING_URL
+{
+ Text = "jdbcBridge: connecting to URL '$1$'";
+};
+
+String STR_LOG_DRIVER_SUCCESS
+{
+ Text = "jdbcBridge: success";
+};
+
+String STR_LOG_CREATE_STATEMENT
+{
+ Text = "c$1$: creating statement";
+};
+
+String STR_LOG_CREATED_STATEMENT_ID
+{
+ Text = "c$1$: created statement, statement id: s$2$";
+};
+
+String STR_LOG_PREPARE_STATEMENT
+{
+ Text = "c$1$: preparing statement: $2$";
+};
+
+String STR_LOG_PREPARED_STATEMENT_ID
+{
+ Text = "c$1$: prepared statement, statement id: s$2$";
+};
+
+String STR_LOG_PREPARE_CALL
+{
+ Text = "c$1$: preparing call: $2$";
+};
+
+String STR_LOG_PREPARED_CALL_ID
+{
+ Text = "c$1$: prepared call, statement id: s$2$";
+};
+
+String STR_LOG_NATIVE_SQL
+{
+ Text = "c$1$: native SQL: $2$ -> $3$";
+};
+
+String STR_LOG_LOADING_DRIVER
+{
+ Text = "c$1$: attempting to load driver class $2$";
+};
+
+String STR_LOG_NO_DRIVER_CLASS
+{
+ Text = "c$1$: no Java Driver Class was provided";
+};
+
+String STR_LOG_CONN_SUCCESS
+{
+ Text = "c$1$: success";
+};
+
+String STR_LOG_NO_SYSTEM_CONNECTION
+{
+ Text = "c$1$: JDBC driver did not provide a JDBC connection";
+};
+
+String STR_LOG_GOT_JDBC_CONNECTION
+{
+ Text = "c$1$: obtained a JDBC connection for $2$";
+};
+
+String STR_LOG_SHUTDOWN_CONNECTION
+{
+ Text = "c$1$: shutting down connection";
+};
+
+String STR_LOG_GENERATED_VALUES
+{
+ Text = "s$1$: retrieving generated values";
+};
+
+String STR_LOG_GENERATED_VALUES_FALLBACK
+{
+ Text = "s$1$: getGeneratedValues: falling back to statement: $2$";
+};
+
+String STR_LOG_EXECUTE_STATEMENT
+{
+ Text = "s$1$: going to execute: $2$";
+};
+
+String STR_LOG_EXECUTE_QUERY
+{
+ Text = "s$1$: going to execute query: $2$";
+};
+
+String STR_LOG_CLOSING_STATEMENT
+{
+ Text = "s$1$: closing/disposing statement";
+};
+
+String STR_LOG_EXECUTE_UPDATE
+{
+ Text = "s$1$: going to execute update: $2$";
+};
+
+String STR_LOG_UPDATE_COUNT
+{
+ Text = "s$1$: update count: $2$";
+};
+
+String STR_LOG_RESULT_SET_CONCURRENCY
+{
+ Text = "s$1$: going to set result set concurrency: $2$";
+};
+
+String STR_LOG_RESULT_SET_TYPE
+{
+ Text = "s$1$: going to set result set type: $2$";
+};
+
+String STR_LOG_FETCH_DIRECTION
+{
+ Text = "s$1$: fetch direction: $2$";
+};
+
+String STR_LOG_FETCH_SIZE
+{
+ Text = "s$1$: fetch size: $2$";
+};
+
+String STR_LOG_SET_ESCAPE_PROCESSING
+{
+ Text = "s$1$: going to set escape processing: $2$";
+};
+
+String STR_LOG_EXECUTING_PREPARED
+{
+ Text = "s$1$: executing previously prepared statement";
+};
+
+String STR_LOG_EXECUTING_PREPARED_UPDATE
+{
+ Text = "s$1$: executing previously prepared update statement";
+};
+
+String STR_LOG_EXECUTING_PREPARED_QUERY
+{
+ Text = "s$1$: executing previously prepared query";
+};
+
+String STR_LOG_STRING_PARAMETER
+{
+ Text = "s$1$: parameter no. $2$: type: string; value: $3$";
+};
+
+String STR_LOG_BOOLEAN_PARAMETER
+{
+ Text = "s$1$: parameter no. $2$: type: boolean; value: $3$";
+};
+
+String STR_LOG_BYTE_PARAMETER
+{
+ Text = "s$1$: parameter no. $2$: type: byte; value: $3$";
+};
+
+String STR_LOG_DATE_PARAMETER
+{
+ Text = "s$1$: parameter no. $2$: type: date; value: $3$";
+};
+
+String STR_LOG_TIME_PARAMETER
+{
+ Text = "s$1$: parameter no. $2$: type: time; value: $3$";
+};
+
+String STR_LOG_TIMESTAMP_PARAMETER
+{
+ Text = "s$1$: parameter no. $2$: type: timestamp; value: $3$";
+};
+
+String STR_LOG_DOUBLE_PARAMETER
+{
+ Text = "s$1$: parameter no. $2$: type: double; value: $3$";
+};
+
+String STR_LOG_FLOAT_PARAMETER
+{
+ Text = "s$1$: parameter no. $2$: type: float; value: $3$";
+};
+
+String STR_LOG_INT_PARAMETER
+{
+ Text = "s$1$: parameter no. $2$: type: int; value: $3$";
+};
+
+String STR_LOG_LONG_PARAMETER
+{
+ Text = "s$1$: parameter no. $2$: type: long; value: $3$";
+};
+
+String STR_LOG_NULL_PARAMETER
+{
+ Text = "s$1$: parameter no. $2$: sql-type: $3$; value: null";
+};
+
+String STR_LOG_OBJECT_NULL_PARAMETER
+{
+ Text = "s$1$: parameter no. $2$: setting to null";
+};
+
+String STR_LOG_SHORT_PARAMETER
+{
+ Text = "s$1$: parameter no. $2$: type: short; value: $3$";
+};
+
+String STR_LOG_BYTES_PARAMETER
+{
+ Text = "s$1$: parameter no. $2$: type: byte[]";
+};
+
+String STR_LOG_CHARSTREAM_PARAMETER
+{
+ Text = "s$1$: parameter no. $2$: type: character stream";
+};
+
+String STR_LOG_BINARYSTREAM_PARAMETER
+{
+ Text = "s$1$: parameter no. $2$: type: binary stream";
+};
+
+String STR_LOG_CLEAR_PARAMETERS
+{
+ Text = "s$1$: clearing all parameters";
+};
+
+String STR_LOG_META_DATA_METHOD
+{
+ Text = "c$1$: entering XDatabaseMetaData::$2$";
+};
+
+String STR_LOG_META_DATA_METHOD_ARG1
+{
+ Text = "c$1$: entering XDatabaseMetaData::$2$( '$3$' )";
+};
+
+String STR_LOG_META_DATA_METHOD_ARG2
+{
+ Text = "c$1$: entering XDatabaseMetaData::$2$( '$3$', '$4$' )";
+};
+
+String STR_LOG_META_DATA_METHOD_ARG3
+{
+ Text = "c$1$: entering XDatabaseMetaData::$2$( '$3$', '$4$', '$5$' )";
+};
+
+String STR_LOG_META_DATA_METHOD_ARG4
+{
+ Text = "c$1$: entering XDatabaseMetaData::$2$( '$3$', '$4$', '$5$', '$6$' )";
+};
+
+String STR_LOG_META_DATA_RESULT
+{
+ Text = "c$1$: leaving XDatabaseMetaData::$2$: success-with-result: $3$";
+};
+
+String STR_LOG_META_DATA_SUCCESS
+{
+ Text = "c$1$: leaving XDatabaseMetaData::$2$: success";
+};
+
+String STR_LOG_THROWING_EXCEPTION
+{
+ Text = "SQLException to be thrown: message: '$1$', SQLState: $2$, ErrorCode: $3$";
+};
+
+String STR_LOG_SETTING_SYSTEM_PROPERTY
+{
+ Text = "setting system property \"$1$\" to value \"$2$\"";
+}; \ No newline at end of file
diff --git a/connectivity/source/resource/conn_shared_res.src b/connectivity/source/resource/conn_shared_res.src
new file mode 100644
index 000000000000..87f69a4aabd0
--- /dev/null
+++ b/connectivity/source/resource/conn_shared_res.src
@@ -0,0 +1,649 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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 "resource/mozab_res.hrc"
+#include "resource/macab_res.hrc"
+#include "resource/calc_res.hrc"
+#include "resource/ado_res.hrc"
+#include "resource/dbase_res.hrc"
+#include "resource/file_res.hrc"
+#include "resource/evoab2_res.hrc"
+#include "resource/kab_res.hrc"
+#include "resource/adabas_res.hrc"
+#include "resource/hsqldb_res.hrc"
+
+// ============================================================================
+// = the mozab driver's resource strings
+// ============================================================================
+
+String STR_MOZILLA_ADDRESSBOOKS
+{
+ Text [ en-US ] = "Mozilla/Seamonkey Addressbook Directory";
+ Text [ x-comment ] = "This must be the term referring to address books in the user's "
+ "Mozilla/Seamonkey profile in the system.";
+};
+
+String STR_THUNDERBIRD_ADDRESSBOOKS
+{
+ Text [ en-US ] = "Thunderbird Addressbook Directory";
+ Text [ x-comment ] = "This must be the term referring to address books in the user's "
+ "Thunderbird profile in the system.";
+};
+
+String STR_OE_ADDRESSBOOK
+{
+ Text [ en-US ] = "Outlook Express Addressbook";
+};
+
+String STR_OUTLOOK_MAPI_ADDRESSBOOK
+{
+ Text [ en-US ] = "Outlook (MAPI) Addressbook";
+};
+
+String STR_NO_TABLE_CREATION_SUPPORT
+{
+ Text [ en-US ] = "Creating tables is not supported for this kind of address books.";
+};
+
+String STR_MOZILLA_IS_RUNNING
+{
+ Text [ en-US ] = "Cannot create new address books while Mozilla is running.";
+};
+
+String STR_COULD_NOT_RETRIEVE_AB_ENTRY
+{
+ Text [ en-US ] = "An address book entry could not be retrieved, an unknown error occurred.";
+};
+
+String STR_COULD_NOT_GET_DIRECTORY_NAME
+{
+ Text [ en-US ] = "An address book directory name could not be retrieved, an unknown error occurred.";
+};
+
+String STR_TIMEOUT_WAITING
+{
+ Text [ en-US ] = "Timed out while waiting for the result.";
+};
+
+String STR_ERR_EXECUTING_QUERY
+{
+ Text [ en-US ] = "An error occurred while executing the query.";
+};
+
+String STR_MOZILLA_IS_RUNNIG_NO_CHANGES
+{
+ Text [ en-US ] = "You can't make any changes to mozilla address book when mozilla is running.";
+};
+
+String STR_FOREIGN_PROCESS_CHANGED_AB
+{
+ Text [ en-US ] = "Mozilla Address Book has been changed out of this process, we can't modify it in this condition.";
+};
+
+String STR_CANT_FIND_ROW
+{
+ Text [ en-US ] = "Can't find the requested row.";
+};
+
+String STR_CANT_FIND_CARD_FOR_ROW
+{
+ Text [ en-US ] = "Can't find the card for the requested row.";
+};
+
+String STR_QUERY_AT_LEAST_ONE_TABLES
+{
+ Text [ en-US ] = "The query can not be executed. It needs at least one table.";
+};
+
+String STR_NO_COUNT_SUPPORT
+{
+ Text [ en-US ] = "The driver does not support the 'COUNT' function.";
+};
+
+String STR_STMT_TYPE_NOT_SUPPORTED
+{
+ Text [ en-US ] = "This statement type not supported by this database driver.";
+};
+
+String STR_UNSPECIFIED_ERROR
+{
+ Text [ en-US ] = "An unknown error occured.";
+};
+
+String STR_COULD_NOT_CREATE_ADDRESSBOOK
+{
+ Text [ en-US ] = "Could not create a new address book. Mozilla error code is $1$.";
+};
+
+String STR_COULD_NOT_LOAD_LIB
+{
+ Text [ en-US ] = "The library '$libname$' could not be loaded.";
+};
+
+String STR_ERROR_REFRESH_ROW
+{
+ Text [ en-US ] = "An error occured while refreshing the current row.";
+};
+
+String STR_ERROR_GET_ROW
+{
+ Text [ en-US ] = "An error occured while getting the current row.";
+};
+
+String STR_CAN_NOT_CANCEL_ROW_UPDATE
+{
+ Text [ en-US ] = "The row update can not be canceled.";
+};
+
+String STR_CAN_NOT_CREATE_ROW
+{
+ Text [ en-US ] = "A new row can not be created.";
+};
+
+String STR_QUERY_INVALID_IS_NULL_COLUMN
+{
+ Text [ en-US ] = "The query can not be executed. The 'IS NULL' can only be used with a column name.";
+};
+
+String STR_ILLEGAL_MOVEMENT
+{
+ Text [ en-US ] = "Illegal cursor movement occured.";
+};
+
+String STR_COMMIT_ROW
+{
+ Text [ en-US ] = "Please commit row '$position$' before update rows or insert new rows.";
+};
+
+String STR_INVALID_ROW_UPDATE
+{
+ Text [ en-US ] = "The update call can not be executed. The row is invalid.";
+};
+
+String STR_ROW_CAN_NOT_SAVE
+{
+ Text [ en-US ] = "The current row can not be saved.";
+};
+
+String STR_NO_HOSTNAME
+{
+ Text [ en-US ] = "No hostname was provided.";
+};
+
+String STR_NO_BASEDN
+{
+ Text [ en-US ] = "No Base DN was provided.";
+};
+
+String STR_COULD_NOT_CONNECT_LDAP
+{
+ Text [ en-US ] = "The connection to the LDAP server could not be established.";
+};
+
+// ============================================================================
+// = common strings
+// ============================================================================
+String STR_NO_CONNECTION_GIVEN
+{
+ Text [ en-US ] = "It doesn't exist a connection to the database.";
+};
+String STR_WRONG_PARAM_INDEX
+{
+ Text [ en-US ] = "You tried to set a parameter at position '$pos$' but there is/are only '$count$' parameter(s) allowed. One reason may be that the property \"ParameterNameSubstitution\" is not set to TRUE in the data source.";
+};
+String STR_INPUTSTREAM_WRONG_LEN
+{
+ Text [ en-US ] = "End of InputStream reached before satisfying length specified when InputStream was set.";
+};
+String STR_NO_INPUTSTREAM
+{
+ Text [ en-US ] = "The input stream was not set.";
+};
+String STR_NO_ELEMENT_NAME
+{
+ Text [ en-US ] = "There is no element named '$name$'.";
+};
+String STR_INVALID_BOOKMARK
+{
+ Text [ en-US ] = "Invalid bookmark value";
+};
+String STR_PRIVILEGE_NOT_GRANTED
+{
+ Text [ en-US ] = "Privilege not granted: Only table privileges can be granted.";
+};
+String STR_PRIVILEGE_NOT_REVOKED
+{
+ Text [ en-US ] = "Privilege not revoked: Only table privileges can be revoked.";
+};
+
+String STR_UNKNOWN_COLUMN_NAME
+{
+ Text [ en-US ] = "The column name '$columnname$' is unknown.";
+};
+String STR_ERRORMSG_SEQUENCE
+{
+ Text [ en-US ] = "Function sequence error.";
+};
+String STR_INVALID_INDEX
+{
+ Text [ en-US ] = "Invalid descriptor index.";
+};
+String STR_UNSUPPORTED_FUNCTION
+{
+ Text [ en-US ] = "The driver does not support the function '$functionname$'.";
+};
+String STR_UNSUPPORTED_FEATURE
+{
+ Text [ en-US ] = "The driver does not support the functionality for '$featurename$'. It is not implemented.";
+};
+String STR_FORMULA_WRONG
+{
+ Text [ en-US ] = "The formula for TypeInfoSettings is wrong!";
+};
+String STR_STRING_LENGTH_EXCEEDED
+{
+ Text [ en-US ] = "The string '$string$' exceeds the maximum length of $maxlen$ characters when converted to the target character set '$charset$'.";
+};
+
+String STR_CANNOT_CONVERT_STRING
+{
+ Text [ en-US ] = "The string '$string$' cannot be converted using the encoding '$charset$'.";
+};
+
+String STR_URI_SYNTAX_ERROR
+{
+ Text [ en-US ] = "The connection URL is invalid.";
+};
+
+String STR_QUERY_TOO_COMPLEX
+{
+ Text [ en-US ] = "The query can not be executed. It is too complex.";
+};
+String STR_OPERATOR_TOO_COMPLEX
+{
+ Text [ en-US ] = "The query can not be executed. The operator is too complex.";
+};
+String STR_QUERY_INVALID_LIKE_COLUMN
+{
+ Text [ en-US ] = "The query can not be executed. You cannot use 'LIKE' with columns of this type.";
+};
+String STR_QUERY_INVALID_LIKE_STRING
+{
+ Text [ en-US ] = "The query can not be executed. 'LIKE' can be used with a string argument only.";
+};
+String STR_QUERY_NOT_LIKE_TOO_COMPLEX
+{
+ Text [ en-US ] = "The query can not be executed. The 'NOT LIKE' condition is too complex.";
+};
+String STR_QUERY_LIKE_WILDCARD
+{
+ Text [ en-US ] = "The query can not be executed. The 'LIKE' condition contains wildcard in the middle.";
+};
+String STR_QUERY_LIKE_WILDCARD_MANY
+{
+ Text [ en-US ] = "The query can not be executed. The 'LIKE' condition contains too many wildcards.";
+};
+String STR_INVALID_COLUMNNAME
+{
+ Text [ en-US ] = "The column name '$columnname$' is not valid.";
+};
+String STR_INVALID_COLUMN_SELECTION
+{
+ Text [ en-US ] = "The statement contains an invalid selection of columns.";
+};
+String STR_COLUMN_NOT_UPDATEABLE
+{
+ Text [ en-US ] = "The column at position '$position$' could not be updated.";
+};
+
+String STR_COULD_NOT_LOAD_FILE
+{
+ Text [ en-US ] = "The file $filename$ could not be loaded.";
+};
+
+String STR_LOAD_FILE_ERROR_MESSAGE
+{
+ Text [ en-US ] = "The attempt to load the file resulted in the following error message ($exception_type$):\n\n$error_message$";
+};
+
+// ============================================================================
+// = the ado driver's resource strings
+// ============================================================================
+String STR_TYPE_NOT_CONVERT
+{
+ Text [ en-US ] = "The type could not be converted.";
+};
+String STR_INVALID_COLUMN_DESCRIPTOR_ERROR
+{
+ Text [ en-US ] = "Could not append column: invalid column descriptor.";
+};
+
+String STR_INVALID_GROUP_DESCRIPTOR_ERROR
+{
+ Text [ en-US ] = "Could not create group: invalid object descriptor.";
+};
+String STR_INVALID_INDEX_DESCRIPTOR_ERROR
+{
+ Text [ en-US ] = "Could not create index: invalid object descriptor.";
+};
+String STR_INVALID_KEY_DESCRIPTOR_ERROR
+{
+ Text [ en-US ] = "Could not create key: invalid object descriptor.";
+};
+
+String STR_INVALID_TABLE_DESCRIPTOR_ERROR
+{
+ Text [ en-US ] = "Could not create table: invalid object descriptor.";
+};
+
+String STR_INVALID_USER_DESCRIPTOR_ERROR
+{
+ Text [ en-US ] = "Could not create user: invalid object descriptor.";
+};
+
+String STR_INVALID_VIEW_DESCRIPTOR_ERROR
+{
+ Text [ en-US ] = "Could not create view: invalid object descriptor.";
+};
+
+String STR_VIEW_NO_COMMAND_ERROR
+{
+ Text [ en-US ] = "Could not create view: no command object.";
+};
+
+String STR_NO_CONNECTION
+{
+ Text [ en-US ] = "The connection could not be created. May be the necessary data provider is not installed.";
+};
+
+// dbase
+String STR_COULD_NOT_DELETE_INDEX
+{
+ Text [ en-US ] = "The index could not be deleted. An unknown error while accessing the file system occured.";
+};
+String STR_ONL_ONE_COLUMN_PER_INDEX
+{
+ Text [ en-US ] = "The index could not be created. Only one column per index is allowed.";
+};
+String STR_COULD_NOT_CREATE_INDEX_NOT_UNIQUE
+{
+ Text [ en-US ] = "The index could not be created. The values are not unique.";
+};
+
+String STR_COULD_NOT_CREATE_INDEX
+{
+ Text [ en-US ] = "The index could not be created. An unknown error appeared.";
+};
+String STR_COULD_NOT_CREATE_INDEX_NAME
+{
+ Text [ en-US ] = "The index could not be created. The file '$filename$' is used by an other index.";
+};
+String STR_COULD_NOT_CREATE_INDEX_KEYSIZE
+{
+ Text [ en-US ] = "The index could not be created. The size of the chosen column is to big.";
+};
+
+String STR_SQL_NAME_ERROR
+{
+ Text [ en-US ] = "The name '$name$' doesn't match SQL naming constraints.";
+};
+String STR_COULD_NOT_DELETE_FILE
+{
+ Text [ en-US ] = "The file $filename$ could not be deleted.";
+};
+
+String STR_INVALID_COLUMN_TYPE
+{
+ Text [ en-US ] = "Invalid column type for column '$columnname$'.";
+};
+String STR_INVALID_COLUMN_PRECISION
+{
+ Text [ en-US ] = "Invalid precision for column '$columnname$'.";
+};
+
+String STR_INVALID_PRECISION_SCALE
+{
+ Text [ en-US ] = "Precision is less than scale for column '$columnname$'.";
+};
+
+String STR_INVALID_COLUMN_NAME_LENGTH
+{
+ Text [ en-US ] = "Invalid column name length for column '$columnname$'.";
+};
+
+String STR_DUPLICATE_VALUE_IN_COLUMN
+{
+ Text [ en-US ] = "Duplicate value found in column '$columnname$'.";
+};
+
+String STR_INVALID_COLUMN_DECIMAL_VALUE
+{
+ Text [ en-US ] = "The '$columnname$' column has been defined as a \"Decimal\" type, the max. length is $precision$ characters (with $scale$ decimal places).\n\nThe specified value \"$value$ is longer than the number of digits allowed.";
+};
+
+String STR_COLUMN_NOT_ALTERABLE
+{
+ Text [ en-US ] = "The column '$columnname$' could not be altered. May be the file system is write protected.";
+};
+String STR_INVALID_COLUMN_VALUE
+{
+ Text [ en-US ] = "The column '$columnname$' could not be updated. The value is invalid for that column.";
+};
+String STR_COLUMN_NOT_ADDABLE
+{
+ Text [ en-US ] = "The column '$columnname$' could not be added. May be the file system is write protected.";
+};
+String STR_COLUMN_NOT_DROP
+{
+ Text [ en-US ] = "The column at position '$position$' could not be dropped. May be the file system is write protected.";
+};
+String STR_TABLE_NOT_DROP
+{
+ Text [ en-US ] = "The table '$tablename$' could not be dropped. May be the file system is write protected.";
+};
+String STR_COULD_NOT_ALTER_TABLE
+{
+ Text [ en-US ] = "The table could not be altered.";
+};
+
+String STR_INVALID_DBASE_FILE
+{
+ Text [ en-US ] = "The file '$filename$' is an invalid (or unrecognized) dBase file.";
+};
+
+// Evoab2
+
+String STR_CANNOT_OPEN_BOOK
+{
+ Text [ en-US ] = "Cannot open Evolution address book.";
+};
+
+String STR_SORT_BY_COL_ONLY
+{
+ Text [ en-US ] = "Can only sort by table columns.";
+};
+
+// File
+String STR_QUERY_COMPLEX_COUNT
+{
+ Text [ en-US ] = "The query can not be executed. It is too complex. Only \"COUNT(*)\" is supported.";
+};
+String STR_QUERY_INVALID_BETWEEN
+{
+ Text [ en-US ] = "The query can not be executed. The 'BETWEEN' arguments are not correct.";
+};
+String STR_QUERY_FUNCTION_NOT_SUPPORTED
+{
+ Text [ en-US ] = "The query can not be executed. The function is not supported.";
+};
+String STR_TABLE_READONLY
+{
+ Text [ en-US ] = "The table can not be changed. It is read only.";
+};
+String STR_DELETE_ROW
+{
+ Text [ en-US ] = "The row could not be deleted. The option \"Display inactive records\" is set.";
+};
+String STR_ROW_ALREADY_DELETED
+{
+ Text [ en-US ] = "The row could not be deleted. It is already deleted.";
+};
+String STR_QUERY_MORE_TABLES
+{
+ Text [ en-US ] = "The query can not be executed. It contains more than one table.";
+};
+String STR_QUERY_NO_TABLE
+{
+ Text [ en-US ] = "The query can not be executed. It contains no valid table.";
+};
+String STR_QUERY_NO_COLUMN
+{
+ Text [ en-US ] = "The query can not be executed. It contains no valid columns.";
+};
+String STR_INVALID_PARA_COUNT
+{
+ Text [ en-US ] = "The count of the given parameter values doesn't match the parameters.";
+};
+String STR_NO_VALID_FILE_URL
+{
+ Text [ en-US ] = "The URL '$URL$' is not valid. A connection can not be created.";
+};
+
+
+String STR_NO_CLASSNAME
+{
+ Text [ en-US ] = "The driver class '$classname$' could not be loaded.";
+};
+String STR_NO_JAVA
+{
+ Text [ en-US ] = "No Java installation could be found. Please check your installation.";
+};
+String STR_NO_RESULTSET
+{
+ Text [ en-US ] = "The execution of the query doesn't return a valid result set.";
+};
+String STR_NO_ROWCOUNT
+{
+ Text [ en-US ] = "The execution of the update statement doesn't effect any rows.";
+};
+
+String STR_NO_CLASSNAME_PATH
+{
+ Text [ en-US ] = "The additional driver class path is '$classpath$'.";
+};
+String STR_UNKNOWN_PARA_TYPE
+{
+ Text [ en-US ] = "The type of parameter at position '$position$' is unknown.";
+};
+String STR_UNKNOWN_COLUMN_TYPE
+{
+ Text [ en-US ] = "The type of column at position '$position$' is unknown.";
+};
+
+// KAB
+
+String STR_NO_KDE_INST
+{
+ Text [ en-US ] = "No suitable KDE installation was found.";
+};
+
+String STR_KDE_VERSION_TOO_OLD
+{
+ Text [ en-US ] = "KDE version $major$.$minor$ or higher is required to access the KDE Address Book.";
+};
+String STR_KDE_VERSION_TOO_NEW
+{
+ Text [ en-US ] = "The found KDE version is too new. Only KDE up to version $major$.$minor$ is known to work with this product.\n";
+};
+String STR_KDE_VERSION_TOO_NEW_WORK_AROUND
+{
+ Text [ en-US ] = "If you are sure that your KDE version works, you might execute the following Basic macro to disable this version check:\n\n";
+};
+String STR_PARA_ONLY_PREPARED
+{
+ Text [ en-US ] = "Parameters can appear only in prepared statements.";
+};
+
+// MACAB
+String STR_NO_TABLE
+{
+ Text [ en-US ] = "No such table!";
+};
+
+String STR_NO_MAC_OS_FOUND
+{
+ Text [ en-US ] = "No suitable Mac OS installation was found.";
+};
+
+// ADABAS D
+String STR_NO_DISK_SPACE
+{
+ Text [ en-US ] = "The database file '$filename$' could not be created. Please check your disk space.";
+};
+
+String STR_COMMAND_NOT_FOUND
+{
+ Text [ en-US ] = "The database '$databasename$' could not be started because the command '$progname$' could not be executed.";
+};
+String STR_DATABASE_NEEDS_CONVERTING
+{
+ Text [ en-US ] = "The current database need to be converted. Please insert control user and password.";
+};
+String STR_USER_NO_DELETE
+{
+ Text [ en-US ] = "This user couldn't be deleted. Otherwise the database stays in a inconsistent state.";
+};
+// hsqldb
+String STR_NO_STROAGE
+{
+ Text [ en-US ] = "The connection can not be established. No storage or URL was given.";
+};
+String STR_INVALID_FILE_URL
+{
+ Text [ en-US ] = "The given URL contains no valid local file system path. Please check the location of your database file.";
+};
+String STR_NO_TABLE_CONTAINER
+{
+ Text [ en-US ] = "An error occured while obtaining the connection's table container.";
+};
+String STR_NO_TABLE_EDITOR_DIALOG
+{
+ Text [ en-US ] = "An error occured while creating the table editor dialog.";
+};
+String STR_NO_TABLENAME
+{
+ Text [ en-US ] = "There is no table named '$tablename$'.";
+};
+String STR_NO_DOCUMENTUI
+{
+ Text [ en-US ] = "The provided DocumentUI is not allowed to be NULL.";
+};
+String STR_ERROR_NEW_VERSION
+{
+ Text = "The connection could not be established. The database was created by a newer version of %PRODUCTNAME.";
+};
+
diff --git a/connectivity/source/resource/makefile.mk b/connectivity/source/resource/makefile.mk
new file mode 100644
index 000000000000..3ccb8ffd164b
--- /dev/null
+++ b/connectivity/source/resource/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
+# common resources in connectivity
+TARGET=cnr
+# resources used for logging in the various SDBC drivers
+TARGET2=sdbcl
+# resources used for ::com::sun::star::sdb::ErrorCondition messages
+TARGET3=sdberr
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+CDEFS+=-DCONN_SHARED_RESOURCE_FILE=$(TARGET)
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/dbtools.pmk
+.INCLUDE : $(PRJ)$/version.mk
+
+
+# --- Files -------------------------------------
+
+EXCEPTIONSFILES=\
+ $(SLO)$/sharedresources.obj
+
+SLOFILES=\
+ $(EXCEPTIONSFILES)
+
+# ...............................................
+
+SRS1NAME=conn_shared_res
+SRC1FILES= \
+ $(SRS1NAME).src
+
+# ...............................................
+
+SRS2NAME=conn_log_res
+SRC2FILES= \
+ $(SRS2NAME).src
+
+# ...............................................
+
+SRS3NAME=conn_error_message
+SRC3FILES= \
+ $(SRS3NAME).src
+
+# === .res file ==========================================================
+
+# ...............................................
+
+RES1FILELIST=\
+ $(SRS)$/$(SRS1NAME).srs \
+
+RESLIB1NAME=$(TARGET)
+RESLIB1SRSFILES=$(RES1FILELIST)
+
+# ...............................................
+
+RES2FILELIST=\
+ $(SRS)$/$(SRS2NAME).srs \
+
+RESLIB2NAME=$(TARGET2)
+RESLIB2SRSFILES=$(RES2FILELIST)
+
+# ...............................................
+
+RES3FILELIST=\
+ $(SRS)$/$(SRS3NAME).srs \
+
+RESLIB3NAME=$(TARGET3)
+RESLIB3SRSFILES=$(RES3FILELIST)
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/connectivity/source/resource/sharedresources.cxx b/connectivity/source/resource/sharedresources.cxx
new file mode 100644
index 000000000000..1c27207223c0
--- /dev/null
+++ b/connectivity/source/resource/sharedresources.cxx
@@ -0,0 +1,242 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "resource/sharedresources.hxx"
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/officeresourcebundle.hxx>
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::uno::Exception;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= SharedResources_Impl
+ //====================================================================
+ class SharedResources_Impl
+ {
+ private:
+ static SharedResources_Impl* s_pInstance;
+ static oslInterlockedCount s_nClients;
+
+ private:
+ ::std::auto_ptr< ::comphelper::OfficeResourceBundle >
+ m_pResourceBundle;
+
+ public:
+ static void registerClient();
+ static void revokeClient();
+
+ static SharedResources_Impl&
+ getInstance();
+
+ ::rtl::OUString getResourceString( ResourceId _nId );
+
+ private:
+ SharedResources_Impl();
+
+ static ::osl::Mutex& getMutex()
+ {
+ static ::osl::Mutex s_aMutex;
+ return s_aMutex;
+ }
+ };
+
+ //--------------------------------------------------------------------
+ SharedResources_Impl* SharedResources_Impl::s_pInstance( NULL );
+ oslInterlockedCount SharedResources_Impl::s_nClients( 0 );
+
+ //--------------------------------------------------------------------
+ SharedResources_Impl::SharedResources_Impl()
+ {
+ try
+ {
+ Reference< XPropertySet > xFactoryProps(
+ ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
+ Reference< XComponentContext > xContext(
+ xFactoryProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ),
+ UNO_QUERY_THROW
+ );
+ m_pResourceBundle.reset( new ::comphelper::OfficeResourceBundle( xContext, "cnr" ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SharedResources_Impl::getResourceString( ResourceId _nId )
+ {
+ if ( m_pResourceBundle.get() == NULL )
+ // this should never happen, but we gracefully ignore it. It has been reported
+ // in the constructor in non-product builds.
+ return ::rtl::OUString();
+
+ return m_pResourceBundle->loadString( _nId );
+ }
+
+ //--------------------------------------------------------------------
+ void SharedResources_Impl::registerClient()
+ {
+ osl_incrementInterlockedCount( &s_nClients );
+ }
+
+ //--------------------------------------------------------------------
+ void SharedResources_Impl::revokeClient()
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ if ( 0 == osl_decrementInterlockedCount( &s_nClients ) )
+ {
+ delete s_pInstance;
+ s_pInstance = NULL;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ SharedResources_Impl& SharedResources_Impl::getInstance()
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ OSL_ENSURE( s_nClients > 0, "SharedResources_Impl::getInstance: no active clients!" );
+
+ if ( !s_pInstance )
+ s_pInstance = new SharedResources_Impl;
+
+ return *s_pInstance;
+ }
+
+ //====================================================================
+ //= helpers
+ //====================================================================
+ namespace
+ {
+ size_t lcl_substitute( ::rtl::OUString& _inout_rString,
+ const sal_Char* _pAsciiPattern, const ::rtl::OUString& _rReplace )
+ {
+ size_t nOccurences = 0;
+
+ ::rtl::OUString sPattern( ::rtl::OUString::createFromAscii( _pAsciiPattern ) );
+ sal_Int32 nIndex = 0;
+ while ( ( nIndex = _inout_rString.indexOf( sPattern ) ) > -1 )
+ {
+ ++nOccurences;
+ _inout_rString = _inout_rString.replaceAt( nIndex, sPattern.getLength(), _rReplace );
+ }
+
+ return nOccurences;
+ }
+ }
+
+ //====================================================================
+ //= SharedResources
+ //====================================================================
+ //--------------------------------------------------------------------
+ SharedResources::SharedResources()
+ {
+ SharedResources_Impl::registerClient();
+ }
+
+ //--------------------------------------------------------------------
+ SharedResources::~SharedResources()
+ {
+ SharedResources_Impl::revokeClient();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SharedResources::getResourceString( ResourceId _nResId ) const
+ {
+ return SharedResources_Impl::getInstance().getResourceString( _nResId );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SharedResources::getResourceStringWithSubstitution( ResourceId _nResId,
+ const sal_Char* _pAsciiPatternToReplace, const ::rtl::OUString& _rStringToSubstitute ) const
+ {
+ ::rtl::OUString sString( SharedResources_Impl::getInstance().getResourceString( _nResId ) );
+ OSL_VERIFY( lcl_substitute( sString, _pAsciiPatternToReplace, _rStringToSubstitute ) );
+ return sString;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SharedResources::getResourceStringWithSubstitution( ResourceId _nResId,
+ const sal_Char* _pAsciiPatternToReplace1, const ::rtl::OUString& _rStringToSubstitute1,
+ const sal_Char* _pAsciiPatternToReplace2, const ::rtl::OUString& _rStringToSubstitute2 ) const
+ {
+ ::rtl::OUString sString( SharedResources_Impl::getInstance().getResourceString( _nResId ) );
+ OSL_VERIFY( lcl_substitute( sString, _pAsciiPatternToReplace1, _rStringToSubstitute1 ) );
+ OSL_VERIFY( lcl_substitute( sString, _pAsciiPatternToReplace2, _rStringToSubstitute2 ) );
+ return sString;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SharedResources::getResourceStringWithSubstitution( ResourceId _nResId,
+ const sal_Char* _pAsciiPatternToReplace1, const ::rtl::OUString& _rStringToSubstitute1,
+ const sal_Char* _pAsciiPatternToReplace2, const ::rtl::OUString& _rStringToSubstitute2,
+ const sal_Char* _pAsciiPatternToReplace3, const ::rtl::OUString& _rStringToSubstitute3 ) const
+ {
+ ::rtl::OUString sString( SharedResources_Impl::getInstance().getResourceString( _nResId ) );
+ OSL_VERIFY( lcl_substitute( sString, _pAsciiPatternToReplace1, _rStringToSubstitute1 ) );
+ OSL_VERIFY( lcl_substitute( sString, _pAsciiPatternToReplace2, _rStringToSubstitute2 ) );
+ OSL_VERIFY( lcl_substitute( sString, _pAsciiPatternToReplace3, _rStringToSubstitute3 ) );
+ return sString;
+ }
+ //--------------------------------------------------------------------
+ ::rtl::OUString SharedResources::getResourceStringWithSubstitution( ResourceId _nResId,
+ const ::std::list< ::std::pair<const sal_Char* , ::rtl::OUString > > _aStringToSubstitutes) const
+ {
+ ::rtl::OUString sString( SharedResources_Impl::getInstance().getResourceString( _nResId ) );
+ ::std::list< ::std::pair<const sal_Char* , ::rtl::OUString > >::const_iterator aIter = _aStringToSubstitutes.begin();
+ ::std::list< ::std::pair<const sal_Char* , ::rtl::OUString > >::const_iterator aEnd = _aStringToSubstitutes.end();
+ for(;aIter != aEnd; ++aIter)
+ OSL_VERIFY( lcl_substitute( sString, aIter->first, aIter->second ) );
+
+ return sString;
+ }
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
diff --git a/connectivity/source/sdbcx/VCatalog.cxx b/connectivity/source/sdbcx/VCatalog.cxx
new file mode 100644
index 000000000000..c9576d5b3d35
--- /dev/null
+++ b/connectivity/source/sdbcx/VCatalog.cxx
@@ -0,0 +1,241 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/sdbcx/VCatalog.hxx"
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "connectivity/sdbcx/VCollection.hxx"
+#include "connectivity/sdbcx/VDescriptor.hxx"
+#include "TConnection.hxx"
+#include <comphelper/uno3.hxx>
+#include "connectivity/dbtools.hxx"
+
+using namespace connectivity;
+using namespace connectivity::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+//------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OCatalog,"com.sun.star.comp.connectivity.OCatalog","com.sun.star.sdbcx.DatabaseDefinition")
+//------------------------------------------------------------------------------
+OCatalog::OCatalog(const Reference< XConnection> &_xConnection) : OCatalog_BASE(m_aMutex)
+ ,connectivity::OSubComponent<OCatalog, OCatalog_BASE>(_xConnection, this)
+ ,m_pTables(NULL)
+ ,m_pViews(NULL)
+ ,m_pGroups(NULL)
+ ,m_pUsers(NULL)
+{
+ try
+ {
+ m_xMetaData = _xConnection->getMetaData();
+ }
+ catch(const Exception&)
+ {
+ OSL_ENSURE(0,"No Metadata available!");
+ }
+}
+//-----------------------------------------------------------------------------
+OCatalog::~OCatalog()
+{
+ delete m_pTables;
+ delete m_pViews;
+ delete m_pGroups;
+ delete m_pUsers;
+}
+//-----------------------------------------------------------------------------
+void SAL_CALL OCatalog::acquire() throw()
+{
+ OCatalog_BASE::acquire();
+}
+//------------------------------------------------------------------------------
+void SAL_CALL OCatalog::release() throw()
+{
+ relase_ChildImpl();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OCatalog::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ if(m_pTables)
+ m_pTables->disposing();
+ if(m_pViews)
+ m_pViews->disposing();
+ if(m_pGroups)
+ m_pGroups->disposing();
+ if(m_pUsers)
+ m_pUsers->disposing();
+
+ dispose_ChildImpl();
+ OCatalog_BASE::disposing();
+}
+//------------------------------------------------------------------------------
+// XTablesSupplier
+Reference< XNameAccess > SAL_CALL OCatalog::getTables( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OCatalog_BASE::rBHelper.bDisposed);
+
+ try
+ {
+ if(!m_pTables)
+ refreshTables();
+ }
+ catch( const RuntimeException& )
+ {
+ // allowed to leave this method
+ throw;
+ }
+ catch( const Exception& )
+ {
+ // allowed
+ }
+
+ return const_cast<OCatalog*>(this)->m_pTables;
+}
+// -------------------------------------------------------------------------
+// XViewsSupplier
+Reference< XNameAccess > SAL_CALL OCatalog::getViews( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OCatalog_BASE::rBHelper.bDisposed);
+
+ try
+ {
+ if(!m_pViews)
+ refreshViews();
+ }
+ catch( const RuntimeException& )
+ {
+ // allowed to leave this method
+ throw;
+ }
+ catch( const Exception& )
+ {
+ // allowed
+ }
+
+ return const_cast<OCatalog*>(this)->m_pViews;
+}
+// -------------------------------------------------------------------------
+// XUsersSupplier
+Reference< XNameAccess > SAL_CALL OCatalog::getUsers( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OCatalog_BASE::rBHelper.bDisposed);
+
+ try
+ {
+ if(!m_pUsers)
+ refreshUsers();
+ }
+ catch( const RuntimeException& )
+ {
+ // allowed to leave this method
+ throw;
+ }
+ catch( const Exception& )
+ {
+ // allowed
+ }
+
+ return const_cast<OCatalog*>(this)->m_pUsers;
+}
+// -------------------------------------------------------------------------
+// XGroupsSupplier
+Reference< XNameAccess > SAL_CALL OCatalog::getGroups( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OCatalog_BASE::rBHelper.bDisposed);
+
+ try
+ {
+ if(!m_pGroups)
+ refreshGroups();
+ }
+ catch( const RuntimeException& )
+ {
+ // allowed to leave this method
+ throw;
+ }
+ catch( const Exception& )
+ {
+ // allowed
+ }
+
+ return const_cast<OCatalog*>(this)->m_pGroups;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OCatalog::buildName(const Reference< XRow >& _xRow)
+{
+ ::rtl::OUString sCatalog = _xRow->getString(1);
+ if ( _xRow->wasNull() )
+ sCatalog = ::rtl::OUString();
+ ::rtl::OUString sSchema = _xRow->getString(2);
+ if ( _xRow->wasNull() )
+ sSchema = ::rtl::OUString();
+ ::rtl::OUString sTable = _xRow->getString(3);
+ if ( _xRow->wasNull() )
+ sTable = ::rtl::OUString();
+
+ ::rtl::OUString sComposedName(
+ ::dbtools::composeTableName( m_xMetaData, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation ) );
+ return sComposedName;
+}
+// -----------------------------------------------------------------------------
+void OCatalog::fillNames(Reference< XResultSet >& _xResult,TStringVector& _rNames)
+{
+ if ( _xResult.is() )
+ {
+ _rNames.reserve(20);
+ Reference< XRow > xRow(_xResult,UNO_QUERY);
+ while ( _xResult->next() )
+ {
+ _rNames.push_back( buildName(xRow) );
+ }
+ xRow.clear();
+ ::comphelper::disposeComponent(_xResult);
+ }
+}
+// -------------------------------------------------------------------------
+void ODescriptor::construct()
+{
+ sal_Int32 nAttrib = isNew() ? 0 : ::com::sun::star::beans::PropertyAttribute::READONLY;
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME), PROPERTY_ID_NAME ,nAttrib,&m_Name,::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+}
+// -------------------------------------------------------------------------
+ODescriptor::~ODescriptor()
+{
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/sdbcx/VCollection.cxx b/connectivity/source/sdbcx/VCollection.cxx
new file mode 100644
index 000000000000..46ecc3f134d7
--- /dev/null
+++ b/connectivity/source/sdbcx/VCollection.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 <algorithm>
+#include <stdio.h>
+#include "connectivity/sdbcx/VCollection.hxx"
+#include "connectivity/sdbcx/VDescriptor.hxx"
+#include "connectivity/dbexception.hxx"
+#include <comphelper/enumhelper.hxx>
+#include <comphelper/container.hxx>
+#include <comphelper/types.hxx>
+#include <comphelper/property.hxx>
+#include "TConnection.hxx"
+#include <rtl/ustrbuf.hxx>
+#include "resource/common_res.hrc"
+#include "resource/sharedresources.hxx"
+
+using namespace connectivity::sdbcx;
+using namespace connectivity;
+using namespace comphelper;
+using namespace ::cppu;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+
+namespace
+{
+ template < typename T> class OHardRefMap : public connectivity::sdbcx::IObjectCollection
+ {
+ typedef ::std::multimap< ::rtl::OUString, T , ::comphelper::UStringMixLess> ObjectMap;
+ typedef typename ObjectMap::iterator ObjectIter;
+ typedef typename ObjectMap::value_type ObjectEntry;
+
+ // private:
+ // this combination of map and vector is used to have a fast name and index access
+ ::std::vector< ObjectIter > m_aElements; // hold the iterators which point to map
+ ObjectMap m_aNameMap; // hold the elements and a name
+ public:
+ OHardRefMap(sal_Bool _bCase)
+ : m_aNameMap(_bCase ? true : false)
+ {
+ }
+ virtual ~OHardRefMap()
+ {
+ }
+
+ virtual void reserve(size_t nLength)
+ {
+ m_aElements.reserve(nLength);
+ }
+ // -----------------------------------------------------------------------------
+ virtual bool exists(const ::rtl::OUString& _sName )
+ {
+ return m_aNameMap.find(_sName) != m_aNameMap.end();
+ }
+ // -----------------------------------------------------------------------------
+ virtual bool empty()
+ {
+ return m_aNameMap.empty();
+ }
+ // -----------------------------------------------------------------------------
+ virtual void swapAll()
+ {
+ ::std::vector< ObjectIter >(m_aElements).swap(m_aElements);
+ ObjectMap(m_aNameMap).swap(m_aNameMap);
+ }
+ // -----------------------------------------------------------------------------
+ virtual void swap()
+ {
+ ::std::vector< ObjectIter >().swap(m_aElements);
+
+ OSL_ENSURE( m_aNameMap.empty(), "swap: what did disposeElements do?" );
+ ObjectMap( m_aNameMap ).swap( m_aNameMap );
+ // Note that it's /important/ to construct the new ObjectMap from m_aNameMap before
+ // swapping. This way, it's ensured that the compare object held by these maps is preserved
+ // during the swap. If we would not do this, the UStringMixLess instance which is used would be
+ // default constructed (instead of being constructed from the same instance in m_aNameMap), and
+ // it's case-sensitive flag would have an unpredictable value.
+ // 2002-01-09 - #106589# - fs@openoffice.org
+ }
+ // -----------------------------------------------------------------------------
+ virtual void clear()
+ {
+ m_aElements.clear();
+ m_aNameMap.clear();
+ }
+ // -----------------------------------------------------------------------------
+ virtual void insert(const ::rtl::OUString& _sName,const ObjectType& _xObject)
+ {
+ m_aElements.push_back(m_aNameMap.insert(m_aNameMap.begin(), ObjectEntry(_sName,_xObject)));
+ }
+ // -----------------------------------------------------------------------------
+ virtual void reFill(const TStringVector &_rVector)
+ {
+ OSL_ENSURE(!m_aNameMap.size(),"OCollection::reFill: collection isn't empty");
+ m_aElements.reserve(_rVector.size());
+
+ for(TStringVector::const_iterator i=_rVector.begin(); i != _rVector.end();++i)
+ m_aElements.push_back(m_aNameMap.insert(m_aNameMap.begin(), ObjectEntry(*i,ObjectType())));
+ }
+ // -----------------------------------------------------------------------------
+ virtual bool rename(const ::rtl::OUString _sOldName,const ::rtl::OUString _sNewName)
+ {
+ bool bRet = false;
+ ObjectIter aIter = m_aNameMap.find(_sOldName);
+ if ( aIter != m_aNameMap.end() )
+ {
+ typename ::std::vector< ObjectIter >::iterator aFind = ::std::find(m_aElements.begin(),m_aElements.end(),aIter);
+ if(m_aElements.end() != aFind)
+ {
+ (*aFind) = m_aNameMap.insert(m_aNameMap.begin(), ObjectEntry(_sNewName,(*aFind)->second));
+ m_aNameMap.erase(aIter);
+
+ bRet = true;
+ }
+ }
+ return bRet;
+ }
+ // -----------------------------------------------------------------------------
+ virtual sal_Int32 size()
+ {
+ return static_cast<sal_Int32>(m_aNameMap.size());
+ }
+ // -----------------------------------------------------------------------------
+ virtual Sequence< ::rtl::OUString > getElementNames()
+ {
+ Sequence< ::rtl::OUString > aNameList(m_aElements.size());
+
+ ::rtl::OUString* pStringArray = aNameList.getArray();
+ typename ::std::vector< ObjectIter >::const_iterator aEnd = m_aElements.end();
+ for(typename ::std::vector< ObjectIter >::const_iterator aIter = m_aElements.begin(); aIter != aEnd;++aIter,++pStringArray)
+ *pStringArray = (*aIter)->first;
+
+ return aNameList;
+ }
+ // -----------------------------------------------------------------------------
+ virtual ::rtl::OUString getName(sal_Int32 _nIndex)
+ {
+ return m_aElements[_nIndex]->first;
+ }
+ // -----------------------------------------------------------------------------
+ virtual void disposeAndErase(sal_Int32 _nIndex)
+ {
+ OSL_ENSURE(_nIndex >= 0 && _nIndex < static_cast<sal_Int32>(m_aElements.size()),"Illegal argument!");
+ Reference<XComponent> xComp(m_aElements[_nIndex]->second.get(),UNO_QUERY);
+ ::comphelper::disposeComponent(xComp);
+ m_aElements[_nIndex]->second = T();
+
+ ::rtl::OUString sName = m_aElements[_nIndex]->first;
+ m_aElements.erase(m_aElements.begin()+_nIndex);
+ m_aNameMap.erase(sName);
+ }
+ // -----------------------------------------------------------------------------
+ virtual void disposeElements()
+ {
+ for( ObjectIter aIter = m_aNameMap.begin(); aIter != m_aNameMap.end(); ++aIter)
+ {
+ Reference<XComponent> xComp(aIter->second.get(),UNO_QUERY);
+ if ( xComp.is() )
+ {
+ ::comphelper::disposeComponent(xComp);
+ (*aIter).second = T();
+ }
+ }
+ m_aElements.clear();
+ m_aNameMap.clear();
+ }
+ // -----------------------------------------------------------------------------
+ virtual sal_Int32 findColumn( const ::rtl::OUString& columnName )
+ {
+ ObjectIter aIter = m_aNameMap.find(columnName);
+ OSL_ENSURE(aIter != m_aNameMap.end(),"findColumn:: Illegal name!");
+ return m_aElements.size() - (m_aElements.end() - ::std::find(m_aElements.begin(),m_aElements.end(),aIter));
+ }
+ // -----------------------------------------------------------------------------
+ virtual ::rtl::OUString findColumnAtIndex( sal_Int32 _nIndex)
+ {
+ OSL_ENSURE(_nIndex >= 0 && _nIndex < static_cast<sal_Int32>(m_aElements.size()),"Illegal argument!");
+ return m_aElements[_nIndex]->first;
+ }
+ // -----------------------------------------------------------------------------
+ virtual ObjectType getObject(sal_Int32 _nIndex)
+ {
+ OSL_ENSURE(_nIndex >= 0 && _nIndex < static_cast<sal_Int32>(m_aElements.size()),"Illegal argument!");
+ return m_aElements[_nIndex]->second;
+ }
+ // -----------------------------------------------------------------------------
+ virtual ObjectType getObject(const ::rtl::OUString& columnName)
+ {
+ return m_aNameMap.find(columnName)->second;
+ }
+ // -----------------------------------------------------------------------------
+ virtual void setObject(sal_Int32 _nIndex,const ObjectType& _xObject)
+ {
+ OSL_ENSURE(_nIndex >= 0 && _nIndex < static_cast<sal_Int32>(m_aElements.size()),"Illegal argument!");
+ m_aElements[_nIndex]->second = _xObject;
+ }
+ // -----------------------------------------------------------------------------
+ sal_Bool isCaseSensitive() const
+ {
+ return m_aNameMap.key_comp().isCaseSensitive();
+ }
+ // -----------------------------------------------------------------------------
+ };
+}
+// -----------------------------------------------------------------------------
+
+IMPLEMENT_SERVICE_INFO(OCollection,"com.sun.star.sdbcx.VContainer" , "com.sun.star.sdbcx.Container")
+
+OCollection::OCollection(::cppu::OWeakObject& _rParent
+ , sal_Bool _bCase
+ , ::osl::Mutex& _rMutex
+ , const TStringVector &_rVector
+ , sal_Bool _bUseIndexOnly
+ , sal_Bool _bUseHardRef)
+ :m_aContainerListeners(_rMutex)
+ ,m_aRefreshListeners(_rMutex)
+ ,m_rParent(_rParent)
+ ,m_rMutex(_rMutex)
+ ,m_bUseIndexOnly(_bUseIndexOnly)
+{
+ if ( _bUseHardRef )
+ {
+ m_pElements.reset(new OHardRefMap< ObjectType >(_bCase));
+ }
+ else
+ {
+ m_pElements.reset(new OHardRefMap< WeakReference< XPropertySet> >(_bCase));
+ }
+ m_pElements->reFill(_rVector);
+}
+// -------------------------------------------------------------------------
+OCollection::~OCollection()
+{
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL OCollection::queryInterface( const Type & rType ) throw (RuntimeException)
+{
+ if ( m_bUseIndexOnly && rType == ::getCppuType(static_cast< Reference< XNameAccess > *> (NULL)) )
+ {
+ return Any();
+ }
+ return OCollectionBase::queryInterface( rType );
+}
+// -----------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OCollection::getTypes() throw (RuntimeException)
+{
+ if ( m_bUseIndexOnly )
+ {
+ Sequence< Type > aTypes(OCollectionBase::getTypes());
+ Type* pBegin = aTypes.getArray();
+ Type* pEnd = pBegin + aTypes.getLength();
+
+ ::std::vector<Type> aOwnTypes;
+ aOwnTypes.reserve(aTypes.getLength());
+ Type aType = ::getCppuType(static_cast< Reference<XNameAccess> *>(NULL));
+ for(;pBegin != pEnd; ++pBegin)
+ {
+ if ( *pBegin != aType )
+ aOwnTypes.push_back(*pBegin);
+ }
+ Type* pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
+ return Sequence< Type >(pTypes,aOwnTypes.size());
+ }
+ return OCollectionBase::getTypes( );
+}
+// -------------------------------------------------------------------------
+void OCollection::clear_NoDispose()
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+
+ m_pElements->clear();
+ m_pElements->swapAll();
+}
+
+// -------------------------------------------------------------------------
+void OCollection::disposing(void)
+{
+ m_aContainerListeners.disposeAndClear(EventObject(static_cast<XTypeProvider*>(this)));
+ m_aRefreshListeners.disposeAndClear(EventObject(static_cast<XTypeProvider*>(this)));
+
+ ::osl::MutexGuard aGuard(m_rMutex);
+
+ disposeElements();
+
+ m_pElements->swap();
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OCollection::getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+ if (Index < 0 || Index >= m_pElements->size() )
+ throw IndexOutOfBoundsException(::rtl::OUString::valueOf(Index),static_cast<XTypeProvider*>(this));
+
+ return makeAny(getObject(Index));
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OCollection::getByName( const ::rtl::OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+
+ if ( !m_pElements->exists(aName) )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_NO_ELEMENT_NAME,
+ "$name$", aName
+ ) );
+ throw NoSuchElementException( sError, static_cast< XTypeProvider* >( this ) );
+ }
+
+ return makeAny(getObject(m_pElements->findColumn(aName)));
+}
+// -------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OCollection::getElementNames( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+ return m_pElements->getElementNames();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OCollection::refresh( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+
+ disposeElements();
+
+ impl_refresh();
+ EventObject aEvt(static_cast<XTypeProvider*>(this));
+ m_aRefreshListeners.notifyEach( &XRefreshListener::refreshed, aEvt );
+}
+// -----------------------------------------------------------------------------
+void OCollection::reFill(const TStringVector &_rVector)
+{
+ m_pElements->reFill(_rVector);
+}
+// -------------------------------------------------------------------------
+// XDataDescriptorFactory
+Reference< XPropertySet > SAL_CALL OCollection::createDataDescriptor( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+
+ return createDescriptor();
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OCollection::getNameForObject(const ObjectType& _xObject)
+{
+ OSL_ENSURE(_xObject.is(),"OCollection::getNameForObject: Object is NULL!");
+ ::rtl::OUString sName;
+ _xObject->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sName;
+ return sName;
+}
+// -------------------------------------------------------------------------
+// XAppend
+void SAL_CALL OCollection::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException)
+{
+ ::osl::ClearableMutexGuard aGuard(m_rMutex);
+
+ ::rtl::OUString sName = getNameForObject( descriptor );
+
+ if ( m_pElements->exists(sName) )
+ throw ElementExistException(sName,static_cast<XTypeProvider*>(this));
+
+ ObjectType xNewlyCreated = appendObject( sName, descriptor );
+ if ( !xNewlyCreated.is() )
+ throw RuntimeException();
+
+ ODescriptor* pDescriptor = ODescriptor::getImplementation( xNewlyCreated );
+ if ( pDescriptor )
+ pDescriptor->setNew( sal_False );
+
+ sName = getNameForObject( xNewlyCreated );
+ if ( !m_pElements->exists( sName ) ) // this may happen when the drived class included it itself
+ m_pElements->insert( sName, xNewlyCreated );
+
+ // notify our container listeners
+ ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(sName), makeAny(xNewlyCreated), Any());
+ aGuard.clear();
+ m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvent );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void SAL_CALL OCollection::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+
+ if ( !m_pElements->exists(elementName) )
+ throw NoSuchElementException(elementName,static_cast<XTypeProvider*>(this));
+
+ dropImpl(m_pElements->findColumn(elementName));
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OCollection::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+ if(index <0 || index >= getCount())
+ throw IndexOutOfBoundsException(::rtl::OUString::valueOf(index),static_cast<XTypeProvider*>(this));
+
+ dropImpl(index);
+}
+// -----------------------------------------------------------------------------
+void OCollection::dropImpl(sal_Int32 _nIndex,sal_Bool _bReallyDrop)
+{
+ ::rtl::OUString elementName = m_pElements->getName(_nIndex);
+
+ if ( _bReallyDrop )
+ dropObject(_nIndex,elementName);
+
+ m_pElements->disposeAndErase(_nIndex);
+
+ // notify our container listeners
+ notifyElementRemoved(elementName);
+}
+// -----------------------------------------------------------------------------
+void OCollection::notifyElementRemoved(const ::rtl::OUString& _sName)
+{
+ ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_sName), Any(), Any());
+ // note that xExistent may be empty, in case somebody removed the data source while it is not alive at this moment
+ OInterfaceIteratorHelper aListenerLoop(m_aContainerListeners);
+ while (aListenerLoop.hasMoreElements())
+ static_cast<XContainerListener*>(aListenerLoop.next())->elementRemoved(aEvent);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OCollection::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
+{
+ if ( !m_pElements->exists(columnName) )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_UNKNOWN_COLUMN_NAME,
+ "$columnname$", columnName
+ ) );
+ ::dbtools::throwGenericSQLException(sError,static_cast< XIndexAccess*>(this));
+ }
+
+ return m_pElements->findColumn(columnName) + 1; // because columns start at one
+}
+// -------------------------------------------------------------------------
+Reference< XEnumeration > SAL_CALL OCollection::createEnumeration( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+ return new OEnumerationByIndex( static_cast< XIndexAccess*>(this));
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OCollection::addContainerListener( const Reference< XContainerListener >& _rxListener ) throw(RuntimeException)
+{
+ m_aContainerListeners.addInterface(_rxListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OCollection::removeContainerListener( const Reference< XContainerListener >& _rxListener ) throw(RuntimeException)
+{
+ m_aContainerListeners.removeInterface(_rxListener);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OCollection::acquire() throw()
+{
+ m_rParent.acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OCollection::release() throw()
+{
+ m_rParent.release();
+}
+// -----------------------------------------------------------------------------
+Type SAL_CALL OCollection::getElementType( ) throw(RuntimeException)
+{
+ return::getCppuType(static_cast< Reference< XPropertySet>*>(NULL));
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OCollection::hasElements( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+ return !m_pElements->empty();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OCollection::getCount( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+ return m_pElements->size();
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OCollection::hasByName( const ::rtl::OUString& aName ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+ return m_pElements->exists(aName);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OCollection::addRefreshListener( const Reference< XRefreshListener >& l ) throw(RuntimeException)
+{
+ m_aRefreshListeners.addInterface(l);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OCollection::removeRefreshListener( const Reference< XRefreshListener >& l ) throw(RuntimeException)
+{
+ m_aRefreshListeners.removeInterface(l);
+}
+// -----------------------------------------------------------------------------
+void OCollection::insertElement(const ::rtl::OUString& _sElementName,const ObjectType& _xElement)
+{
+ OSL_ENSURE(!m_pElements->exists(_sElementName),"Element already exists");
+ if ( !m_pElements->exists(_sElementName) )
+ m_pElements->insert(_sElementName,_xElement);
+}
+// -----------------------------------------------------------------------------
+void OCollection::renameObject(const ::rtl::OUString _sOldName,const ::rtl::OUString _sNewName)
+{
+ OSL_ENSURE(m_pElements->exists(_sOldName),"Element doesn't exist");
+ OSL_ENSURE(!m_pElements->exists(_sNewName),"Element already exists");
+ OSL_ENSURE(_sNewName.getLength(),"New name must not be empty!");
+ OSL_ENSURE(_sOldName.getLength(),"New name must not be empty!");
+
+ if ( m_pElements->rename(_sOldName,_sNewName) )
+ {
+ ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_sNewName), makeAny(m_pElements->getObject(_sNewName)),makeAny(_sOldName));
+ // note that xExistent may be empty, in case somebody removed the data source while it is not alive at this moment
+ OInterfaceIteratorHelper aListenerLoop(m_aContainerListeners);
+ while (aListenerLoop.hasMoreElements())
+ static_cast<XContainerListener*>(aListenerLoop.next())->elementReplaced(aEvent);
+ }
+}
+// -----------------------------------------------------------------------------
+ObjectType OCollection::getObject(sal_Int32 _nIndex)
+{
+ ObjectType xName = m_pElements->getObject(_nIndex);
+ if ( !xName.is() )
+ {
+ try
+ {
+ xName = createObject(m_pElements->getName(_nIndex));
+ }
+ catch(const SQLException& e)
+ {
+ try
+ {
+ dropImpl(_nIndex,sal_False);
+ }
+ catch(const Exception& )
+ {
+ }
+ throw WrappedTargetException(e.Message,static_cast<XTypeProvider*>(this),makeAny(e));
+ }
+ m_pElements->setObject(_nIndex,xName);
+ }
+ return xName;
+}
+// -----------------------------------------------------------------------------
+void OCollection::disposeElements()
+{
+ m_pElements->disposeElements();
+}
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > OCollection::createDescriptor()
+{
+ OSL_ASSERT(!"Need to be overloaded when used!");
+ throw SQLException();
+}
+// -----------------------------------------------------------------------------
+ObjectType OCollection::cloneDescriptor( const ObjectType& _descriptor )
+{
+ ObjectType xNewDescriptor( createDescriptor() );
+ ::comphelper::copyProperties( _descriptor, xNewDescriptor );
+ return xNewDescriptor;
+}
+// -----------------------------------------------------------------------------
+ObjectType OCollection::appendObject( const ::rtl::OUString& /*_rForName*/, const Reference< XPropertySet >& descriptor )
+{
+ return cloneDescriptor( descriptor );
+}
+// -----------------------------------------------------------------------------
+void OCollection::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString /*_sElementName*/)
+{
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/sdbcx/VColumn.cxx b/connectivity/source/sdbcx/VColumn.cxx
new file mode 100644
index 000000000000..65bc1b368b1e
--- /dev/null
+++ b/connectivity/source/sdbcx/VColumn.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 "connectivity/sdbcx/VColumn.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/sequence.hxx>
+#include "TConnection.hxx"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+// -------------------------------------------------------------------------
+using namespace connectivity;
+using namespace connectivity::sdbcx;
+using namespace cppu;
+using namespace connectivity;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OColumn::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ if(isNew())
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VColumnDescription");
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VColumn");
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OColumn::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1);
+ if(isNew())
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ColumnDescription");
+ else
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Column");
+
+ return aSupported;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OColumn::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;
+}
+// -------------------------------------------------------------------------
+OColumn::OColumn(sal_Bool _bCase)
+ :OColumnDescriptor_BASE(m_aMutex)
+ ,ODescriptor(OColumnDescriptor_BASE::rBHelper,_bCase,sal_True)
+ ,m_IsNullable(ColumnValue::NULLABLE)
+ ,m_Precision(0)
+ ,m_Scale(0)
+ ,m_Type(0)
+ ,m_IsAutoIncrement(sal_False)
+ ,m_IsRowVersion(sal_False)
+ ,m_IsCurrency(sal_False)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+OColumn::OColumn( const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _TypeName,
+ const ::rtl::OUString& _DefaultValue,
+ const ::rtl::OUString& _Description,
+ sal_Int32 _IsNullable,
+ sal_Int32 _Precision,
+ sal_Int32 _Scale,
+ sal_Int32 _Type,
+ sal_Bool _IsAutoIncrement,
+ sal_Bool _IsRowVersion,
+ sal_Bool _IsCurrency,
+ sal_Bool _bCase)
+ :OColumnDescriptor_BASE(m_aMutex)
+ ,ODescriptor(OColumnDescriptor_BASE::rBHelper,_bCase)
+ ,m_TypeName(_TypeName)
+ ,m_Description(_Description)
+ ,m_DefaultValue(_DefaultValue)
+ ,m_IsNullable(_IsNullable)
+ ,m_Precision(_Precision)
+ ,m_Scale(_Scale)
+ ,m_Type(_Type)
+ ,m_IsAutoIncrement(_IsAutoIncrement)
+ ,m_IsRowVersion(_IsRowVersion)
+ ,m_IsCurrency(_IsCurrency)
+{
+ m_Name = _Name;
+
+ construct();
+}
+// -------------------------------------------------------------------------
+OColumn::~OColumn()
+{
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OColumn::createArrayHelper( sal_Int32 /*_nId*/ ) const
+{
+ return doCreateArrayHelper();
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& SAL_CALL OColumn::getInfoHelper()
+{
+ return *OColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OColumn::acquire() throw()
+{
+ OColumnDescriptor_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OColumn::release() throw()
+{
+ OColumnDescriptor_BASE::release();
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL OColumn::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = ODescriptor::queryInterface( rType);
+ if(!aRet.hasValue())
+ {
+ if(!isNew())
+ aRet = OColumn_BASE::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OColumnDescriptor_BASE::queryInterface( rType);
+ }
+ return aRet;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OColumn::getTypes( ) throw(RuntimeException)
+{
+ if(isNew())
+ return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumnDescriptor_BASE::getTypes());
+
+ return ::comphelper::concatSequences(ODescriptor::getTypes(),OColumn_BASE::getTypes(),OColumnDescriptor_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+void OColumn::construct()
+{
+ ODescriptor::construct();
+
+ sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
+
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME), PROPERTY_ID_TYPENAME, nAttrib,&m_TypeName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION), PROPERTY_ID_DESCRIPTION, nAttrib,&m_Description, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE), PROPERTY_ID_DEFAULTVALUE, nAttrib,&m_DefaultValue, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION), PROPERTY_ID_PRECISION, nAttrib,&m_Precision, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE), PROPERTY_ID_TYPE, nAttrib,&m_Type, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE), PROPERTY_ID_SCALE, nAttrib,&m_Scale, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE), PROPERTY_ID_ISNULLABLE, nAttrib,&m_IsNullable, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT), PROPERTY_ID_ISAUTOINCREMENT, nAttrib,&m_IsAutoIncrement, ::getBooleanCppuType());
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISROWVERSION), PROPERTY_ID_ISROWVERSION, nAttrib,&m_IsRowVersion, ::getBooleanCppuType());
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY), PROPERTY_ID_ISCURRENCY, nAttrib,&m_IsCurrency, ::getBooleanCppuType());
+}
+// -------------------------------------------------------------------------
+void OColumn::disposing(void)
+{
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OColumnDescriptor_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > SAL_CALL OColumn::createDataDescriptor( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OColumnDescriptor_BASE::rBHelper.bDisposed);
+
+
+ OColumn* pNewColumn = new OColumn( m_Name,
+ m_TypeName,
+ m_DefaultValue,
+ m_Description,
+ m_IsNullable,
+ m_Precision,
+ m_Scale,
+ m_Type,
+ m_IsAutoIncrement,
+ m_IsRowVersion,
+ m_IsCurrency,
+ isCaseSensitive());
+ pNewColumn->setNew(sal_True);
+ return pNewColumn;
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OColumn::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+// XNamed
+::rtl::OUString SAL_CALL OColumn::getName( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return m_Name;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OColumn::setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException)
+{
+ m_Name = aName;
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/sdbcx/VDescriptor.cxx b/connectivity/source/sdbcx/VDescriptor.cxx
new file mode 100644
index 000000000000..539726339809
--- /dev/null
+++ b/connectivity/source/sdbcx/VDescriptor.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 <connectivity/sdbcx/VDescriptor.hxx>
+#include <cppuhelper/queryinterface.hxx>
+
+#include <functional>
+#include <algorithm>
+
+namespace connectivity
+{
+ namespace sdbcx
+ {
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+
+ // =========================================================================
+ // = ODescriptor
+ // =========================================================================
+ // -------------------------------------------------------------------------
+ ODescriptor::ODescriptor(::cppu::OBroadcastHelper& _rBHelper,sal_Bool _bCase, sal_Bool _bNew)
+ :ODescriptor_PBASE(_rBHelper)
+ ,m_aCase(_bCase)
+ ,m_bNew(_bNew)
+ {
+ }
+
+ // -------------------------------------------------------------------------
+ // com::sun::star::lang::XUnoTunnel
+ sal_Int64 SAL_CALL ODescriptor::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 )
+ : 0;
+ }
+
+ // -----------------------------------------------------------------------------
+ ODescriptor* ODescriptor::getImplementation( const Reference< XInterface >& _rxSomeComp )
+ {
+ Reference< XUnoTunnel > xTunnel( _rxSomeComp, UNO_QUERY );
+ if ( xTunnel.is() )
+ return reinterpret_cast< ODescriptor* >( xTunnel->getSomething( getUnoTunnelImplementationId() ) );
+ return NULL;
+ }
+
+ // -----------------------------------------------------------------------------
+ namespace
+ {
+ struct ResetROAttribute : public ::std::unary_function< Property, void >
+ {
+ void operator ()( Property& _rProperty ) const
+ {
+ _rProperty.Attributes &= ~PropertyAttribute::READONLY;
+ }
+ };
+ struct SetROAttribute : public ::std::unary_function< Property, void >
+ {
+ void operator ()( Property& _rProperty ) const
+ {
+ _rProperty.Attributes |= PropertyAttribute::READONLY;
+ }
+ };
+ }
+
+ // -----------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* ODescriptor::doCreateArrayHelper() const
+ {
+ Sequence< Property > aProperties;
+ describeProperties( aProperties );
+
+ if ( isNew() )
+ ::std::for_each( aProperties.getArray(), aProperties.getArray() + aProperties.getLength(), ResetROAttribute() );
+ else
+ ::std::for_each( aProperties.getArray(), aProperties.getArray() + aProperties.getLength(), SetROAttribute() );
+
+ return new ::cppu::OPropertyArrayHelper( aProperties );
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool ODescriptor::isNew( const Reference< XInterface >& _rxDescriptor )
+ {
+ ODescriptor* pImplementation = getImplementation( _rxDescriptor );
+ return pImplementation != NULL ? pImplementation->isNew() : sal_False;
+ }
+
+ // -----------------------------------------------------------------------------
+ Sequence< sal_Int8 > ODescriptor::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();
+ }
+
+ // -----------------------------------------------------------------------------
+ Any SAL_CALL ODescriptor::queryInterface( const Type & rType ) throw(RuntimeException)
+ {
+ Any aRet = ::cppu::queryInterface(rType,static_cast< XUnoTunnel*> (this));
+ return aRet.hasValue() ? aRet : ODescriptor_PBASE::queryInterface(rType);
+ }
+
+ // -----------------------------------------------------------------------------
+ void ODescriptor::setNew(sal_Bool _bNew)
+ {
+ m_bNew = _bNew;
+ }
+
+ // -----------------------------------------------------------------------------
+ Sequence< Type > SAL_CALL ODescriptor::getTypes( ) throw(RuntimeException)
+ {
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XFastPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XUnoTunnel > *)0 ));
+ return aTypes.getTypes();
+ }
+
+ }
+}
+
+
diff --git a/connectivity/source/sdbcx/VGroup.cxx b/connectivity/source/sdbcx/VGroup.cxx
new file mode 100644
index 000000000000..bb8d49bb7499
--- /dev/null
+++ b/connectivity/source/sdbcx/VGroup.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <stdio.h>
+#include "connectivity/sdbcx/VGroup.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/PrivilegeObject.hpp>
+#include <comphelper/sequence.hxx>
+#include <connectivity/dbexception.hxx>
+
+// -------------------------------------------------------------------------
+using namespace ::connectivity::sdbcx;
+using namespace ::connectivity;
+using namespace ::dbtools;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+
+IMPLEMENT_SERVICE_INFO(OGroup,"com.sun.star.sdbcx.VGroup","com.sun.star.sdbcx.Group");
+// -------------------------------------------------------------------------
+OGroup::OGroup(sal_Bool _bCase) : OGroup_BASE(m_aMutex)
+ , ODescriptor(OGroup_BASE::rBHelper,_bCase)
+ , m_pUsers(NULL)
+{
+}
+// -------------------------------------------------------------------------
+OGroup::OGroup(const ::rtl::OUString& _Name,sal_Bool _bCase) : OGroup_BASE(m_aMutex)
+ ,ODescriptor(OGroup_BASE::rBHelper,_bCase)
+ ,m_pUsers(NULL)
+{
+ m_Name = _Name;
+}
+// -------------------------------------------------------------------------
+OGroup::~OGroup()
+{
+ delete m_pUsers;
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OGroup::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = ODescriptor::queryInterface( rType);
+ return aRet.hasValue() ? aRet : OGroup_BASE::queryInterface( rType);
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OGroup::getTypes( ) throw(RuntimeException)
+{
+ return ::comphelper::concatSequences(ODescriptor::getTypes(),OGroup_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+void OGroup::disposing(void)
+{
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ if(m_pUsers)
+ m_pUsers->disposing();
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OGroup::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & OGroup::getInfoHelper()
+{
+ return *const_cast<OGroup*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+Reference< XNameAccess > SAL_CALL OGroup::getUsers( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OGroup_BASE::rBHelper.bDisposed);
+
+ try
+ {
+ if ( !m_pUsers )
+ refreshUsers();
+ }
+ catch( const RuntimeException& )
+ {
+ // allowed to leave this method
+ throw;
+ }
+ catch( const Exception& )
+ {
+ // allowed
+ }
+
+ return const_cast<OGroup*>(this)->m_pUsers;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OGroup::getPrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OGroup_BASE::rBHelper.bDisposed);
+
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OGroup::getGrantablePrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OGroup_BASE::rBHelper.bDisposed);
+
+ return 0;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OGroup::grantPrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OGroup_BASE::rBHelper.bDisposed);
+ throwFeatureNotImplementedException( "XAuthorizable::grantPrivileges", *this );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OGroup::revokePrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OGroup_BASE::rBHelper.bDisposed);
+ throwFeatureNotImplementedException( "XAuthorizable::revokePrivileges", *this );
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OGroup::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OGroup::getName( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return m_Name;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OGroup::setName( const ::rtl::OUString& /*aName*/ ) throw(::com::sun::star::uno::RuntimeException)
+{
+ throwFeatureNotImplementedException( "XNamed::setName", *this );
+}
+// -----------------------------------------------------------------------------
+// XInterface
+void SAL_CALL OGroup::acquire() throw()
+{
+ OGroup_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OGroup::release() throw()
+{
+ OGroup_BASE::release();
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/sdbcx/VIndex.cxx b/connectivity/source/sdbcx/VIndex.cxx
new file mode 100644
index 000000000000..a9ae6eaa1538
--- /dev/null
+++ b/connectivity/source/sdbcx/VIndex.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 "connectivity/sdbcx/VIndex.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "connectivity/sdbcx/VColumn.hxx"
+#include <connectivity/dbexception.hxx>
+#include <comphelper/sequence.hxx>
+#include "connectivity/sdbcx/VCollection.hxx"
+#include "TConnection.hxx"
+// -------------------------------------------------------------------------
+using namespace ::connectivity;
+using namespace ::connectivity;
+using namespace ::dbtools;
+using namespace ::connectivity::sdbcx;
+using namespace ::cppu;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OIndex::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ if(isNew())
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VIndexDescriptor");
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VIndex");
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OIndex::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1);
+ if(isNew())
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.IndexDescriptor");
+ else
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Index");
+
+ return aSupported;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OIndex::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;
+}
+// -------------------------------------------------------------------------
+OIndex::OIndex(sal_Bool _bCase) : ODescriptor_BASE(m_aMutex)
+ , ODescriptor(ODescriptor_BASE::rBHelper,_bCase,sal_True)
+ ,m_IsUnique(sal_False)
+ ,m_IsPrimaryKeyIndex(sal_False)
+ ,m_IsClustered(sal_False)
+ ,m_pColumns(NULL)
+{
+}
+// -------------------------------------------------------------------------
+OIndex::OIndex( const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Catalog,
+ sal_Bool _isUnique,
+ sal_Bool _isPrimaryKeyIndex,
+ sal_Bool _isClustered,
+ sal_Bool _bCase) : ODescriptor_BASE(m_aMutex)
+ ,ODescriptor(ODescriptor_BASE::rBHelper,_bCase)
+ ,m_Catalog(_Catalog)
+ ,m_IsUnique(_isUnique)
+ ,m_IsPrimaryKeyIndex(_isPrimaryKeyIndex)
+ ,m_IsClustered(_isClustered)
+ ,m_pColumns(NULL)
+{
+ m_Name = _Name;
+}
+// -------------------------------------------------------------------------
+OIndex::~OIndex( )
+{
+ delete m_pColumns;
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OIndex::createArrayHelper( sal_Int32 /*_nId*/ ) const
+{
+ return doCreateArrayHelper();
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& SAL_CALL OIndex::getInfoHelper()
+{
+ return *OIndex_PROP::getArrayHelper(isNew() ? 1 : 0);
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OIndex::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = ODescriptor::queryInterface( rType);
+ if(!aRet.hasValue())
+ {
+ if(!isNew())
+ aRet = OIndex_BASE::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = ODescriptor_BASE::queryInterface( rType);
+ }
+ return aRet;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OIndex::getTypes( ) throw(RuntimeException)
+{
+ if(isNew())
+ return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes());
+ return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes(),OIndex_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+void OIndex::construct()
+{
+ ODescriptor::construct();
+
+ sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
+
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOG), PROPERTY_ID_CATALOG, nAttrib,&m_Catalog, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE), PROPERTY_ID_ISUNIQUE, nAttrib,&m_IsUnique, ::getBooleanCppuType());
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISPRIMARYKEYINDEX),PROPERTY_ID_ISPRIMARYKEYINDEX, nAttrib,&m_IsPrimaryKeyIndex, ::getBooleanCppuType());
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCLUSTERED), PROPERTY_ID_ISCLUSTERED, nAttrib,&m_IsClustered, ::getBooleanCppuType());
+}
+// -------------------------------------------------------------------------
+void OIndex::disposing(void)
+{
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ if(m_pColumns)
+ m_pColumns->disposing();
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OIndex::getColumns( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(ODescriptor_BASE::rBHelper.bDisposed);
+
+ try
+ {
+ if ( !m_pColumns )
+ refreshColumns();
+ }
+ catch( const RuntimeException& )
+ {
+ // allowed to leave this method
+ throw;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( false, "OIndex::getColumns: caught an exception!" );
+ }
+
+ return const_cast<OIndex*>(this)->m_pColumns;
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > SAL_CALL OIndex::createDataDescriptor( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(ODescriptor_BASE::rBHelper.bDisposed);
+
+
+ return this;
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OIndex::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OIndex::getName( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return m_Name;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OIndex::setName( const ::rtl::OUString& /*aName*/ ) throw(::com::sun::star::uno::RuntimeException)
+{
+}
+// -----------------------------------------------------------------------------
+// XInterface
+void SAL_CALL OIndex::acquire() throw()
+{
+ ODescriptor_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OIndex::release() throw()
+{
+ ODescriptor_BASE::release();
+}
+// -----------------------------------------------------------------------------
+void OIndex::refreshColumns()
+{
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/sdbcx/VIndexColumn.cxx b/connectivity/source/sdbcx/VIndexColumn.cxx
new file mode 100644
index 000000000000..ca1649b06384
--- /dev/null
+++ b/connectivity/source/sdbcx/VIndexColumn.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 "connectivity/sdbcx/VIndexColumn.hxx"
+#include "TConnection.hxx"
+
+using namespace connectivity;
+using namespace connectivity::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OIndexColumn::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ if(isNew())
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VIndexColumnDescription");
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VIndex");
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OIndexColumn::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1);
+ if(isNew())
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.IndexDescription");
+ else
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Index");
+
+ return aSupported;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OIndexColumn::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;
+}
+// -----------------------------------------------------------------------------
+OIndexColumn::OIndexColumn(sal_Bool _bCase) : OColumn(_bCase), m_IsAscending(sal_True)
+{
+ construct();
+}
+
+// -------------------------------------------------------------------------
+OIndexColumn::OIndexColumn( sal_Bool _IsAscending,
+ 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,
+ sal_Bool _IsRowVersion,
+ sal_Bool _IsCurrency,
+ sal_Bool _bCase
+ ) : OColumn(_Name,
+ _TypeName,
+ _DefaultValue,
+ ::rtl::OUString(),
+ _IsNullable,
+ _Precision,
+ _Scale,
+ _Type,
+ _IsAutoIncrement,
+ _IsRowVersion,
+ _IsCurrency,
+ _bCase)
+ , m_IsAscending(_IsAscending)
+{
+ construct();
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OIndexColumn::createArrayHelper( sal_Int32 /*_nId*/ ) const
+{
+ return doCreateArrayHelper();
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& SAL_CALL OIndexColumn::getInfoHelper()
+{
+ return *OIndexColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
+}
+// -------------------------------------------------------------------------
+void OIndexColumn::construct()
+{
+ sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISASCENDING), PROPERTY_ID_ISASCENDING, nAttrib,&m_IsAscending, ::getBooleanCppuType());
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/sdbcx/VKey.cxx b/connectivity/source/sdbcx/VKey.cxx
new file mode 100644
index 000000000000..b73d8721f88e
--- /dev/null
+++ b/connectivity/source/sdbcx/VKey.cxx
@@ -0,0 +1,228 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/sdbcx/VKey.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <comphelper/sequence.hxx>
+#include "connectivity/sdbcx/VColumn.hxx"
+#include "connectivity/sdbcx/VCollection.hxx"
+#include "TConnection.hxx"
+// -------------------------------------------------------------------------
+using namespace connectivity;
+using namespace connectivity::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OKey::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ if(isNew())
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VKeyDescription");
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VKey");
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OKey::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1);
+ if(isNew())
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.KeyDescription");
+ else
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Key");
+
+ return aSupported;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OKey::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;
+}
+// -------------------------------------------------------------------------
+OKey::OKey(sal_Bool _bCase) : ODescriptor_BASE(m_aMutex)
+ , ODescriptor(ODescriptor_BASE::rBHelper,_bCase,sal_True)
+ , m_aProps(new KeyProperties())
+ , m_pColumns(NULL)
+{
+}
+// -------------------------------------------------------------------------
+OKey::OKey(const ::rtl::OUString& _Name,const TKeyProperties& _rProps,sal_Bool _bCase)
+: ODescriptor_BASE(m_aMutex)
+ ,ODescriptor(ODescriptor_BASE::rBHelper,_bCase)
+ ,m_aProps(_rProps)
+ ,m_pColumns(NULL)
+{
+ m_Name = _Name;
+}
+//OKey::OKey( const ::rtl::OUString& _Name,
+// const ::rtl::OUString& _ReferencedTable,
+// sal_Int32 _Type,
+// sal_Int32 _UpdateRule,
+// sal_Int32 _DeleteRule,
+// sal_Bool _bCase) : ODescriptor_BASE(m_aMutex)
+// ,ODescriptor(ODescriptor_BASE::rBHelper,_bCase)
+// ,m_ReferencedTable(_ReferencedTable)
+// ,m_Type(_Type)
+// ,m_UpdateRule(_UpdateRule)
+// ,m_DeleteRule(_DeleteRule)
+// ,m_pColumns(NULL)
+//{
+// m_Name = _Name;
+//}
+// -------------------------------------------------------------------------
+OKey::~OKey( )
+{
+ delete m_pColumns;
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OKey::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = ODescriptor::queryInterface( rType);
+ if(!aRet.hasValue())
+ {
+ if(!isNew())
+ aRet = OKey_BASE::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = ODescriptor_BASE::queryInterface( rType);
+ }
+
+ return aRet;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OKey::getTypes( ) throw(RuntimeException)
+{
+ if(isNew())
+ return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes());
+
+ return ::comphelper::concatSequences(ODescriptor::getTypes(),ODescriptor_BASE::getTypes(),OKey_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+void OKey::construct()
+{
+ ODescriptor::construct();
+
+ sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
+
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REFERENCEDTABLE), PROPERTY_ID_REFERENCEDTABLE, nAttrib,&m_aProps->m_ReferencedTable, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE), PROPERTY_ID_TYPE, nAttrib,&m_aProps->m_Type, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_UPDATERULE), PROPERTY_ID_UPDATERULE, nAttrib,&m_aProps->m_UpdateRule, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELETERULE), PROPERTY_ID_DELETERULE, nAttrib,&m_aProps->m_DeleteRule, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OKey::disposing()
+{
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ if(m_pColumns)
+ m_pColumns->disposing();
+
+ ODescriptor_BASE::disposing();
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OKey::createArrayHelper( sal_Int32 /*_nId*/ ) const
+{
+ return doCreateArrayHelper();
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & OKey::getInfoHelper()
+{
+ return *const_cast<OKey*>(this)->getArrayHelper(isNew() ? 1 : 0);
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OKey::getColumns( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(ODescriptor_BASE::rBHelper.bDisposed);
+
+ try
+ {
+ if ( !m_pColumns )
+ refreshColumns();
+ }
+ catch( const RuntimeException& )
+ {
+ // allowed to leave this method
+ throw;
+ }
+ catch( const Exception& )
+ {
+ // allowed
+ }
+
+ return const_cast<OKey*>(this)->m_pColumns;
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > SAL_CALL OKey::createDataDescriptor( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(ODescriptor_BASE::rBHelper.bDisposed);
+
+
+ return this;
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OKey::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OKey::getName( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return m_Name;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OKey::setName( const ::rtl::OUString& /*aName*/ ) throw(::com::sun::star::uno::RuntimeException)
+{
+}
+// -----------------------------------------------------------------------------
+// XInterface
+void SAL_CALL OKey::acquire() throw()
+{
+ ODescriptor_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OKey::release() throw()
+{
+ ODescriptor_BASE::release();
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/sdbcx/VKeyColumn.cxx b/connectivity/source/sdbcx/VKeyColumn.cxx
new file mode 100644
index 000000000000..97e83f5c633a
--- /dev/null
+++ b/connectivity/source/sdbcx/VKeyColumn.cxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/sdbcx/VKeyColumn.hxx"
+#include "TConnection.hxx"
+
+using namespace connectivity;
+using namespace connectivity::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace cppu;
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OKeyColumn::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ if(isNew())
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VKeyColumnDescription");
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VKeyColumn");
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OKeyColumn::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1);
+ if(isNew())
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.KeyColumnDescription");
+ else
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.KeyColumn");
+
+ return aSupported;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OKeyColumn::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;
+}
+// -------------------------------------------------------------------------
+OKeyColumn::OKeyColumn(sal_Bool _bCase) : OColumn(_bCase)
+{
+ 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,
+ sal_Bool _IsRowVersion,
+ sal_Bool _IsCurrency,
+ sal_Bool _bCase
+ ) : OColumn(_Name,
+ _TypeName,
+ _DefaultValue,
+ ::rtl::OUString(),
+ _IsNullable,
+ _Precision,
+ _Scale,
+ _Type,
+ _IsAutoIncrement,
+ _IsRowVersion,
+ _IsCurrency,
+ _bCase)
+ , m_ReferencedColumn(_ReferencedColumn)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+OKeyColumn::~OKeyColumn()
+{
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OKeyColumn::createArrayHelper( sal_Int32 /*_nId*/ ) const
+{
+ return doCreateArrayHelper();
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& SAL_CALL OKeyColumn::getInfoHelper()
+{
+ return *OKeyColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
+}
+// -------------------------------------------------------------------------
+void OKeyColumn::construct()
+{
+ sal_Int32 nAttrib = isNew() ? 0 : 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/sdbcx/VTable.cxx b/connectivity/source/sdbcx/VTable.cxx
new file mode 100644
index 000000000000..743980a345ce
--- /dev/null
+++ b/connectivity/source/sdbcx/VTable.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 "connectivity/sdbcx/VTable.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "connectivity/sdbcx/VIndex.hxx"
+#include <comphelper/sequence.hxx>
+#include "connectivity/sdbcx/VCollection.hxx"
+#include "TConnection.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include "connectivity/sdbcx/VKey.hxx"
+#include "connectivity/dbtools.hxx"
+#include <connectivity/dbexception.hxx>
+
+// -------------------------------------------------------------------------
+using namespace ::connectivity;
+using namespace ::connectivity::sdbcx;
+using namespace ::dbtools;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OTable::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ if(isNew())
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.VTableDescriptor");
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Table");
+}
+
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OTable::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1);
+ if(isNew())
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.TableDescriptor");
+ else
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Table");
+
+ return aSupported;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OTable::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;
+}
+// -------------------------------------------------------------------------
+OTable::OTable(OCollection* _pTables,
+ sal_Bool _bCase)
+ : OTableDescriptor_BASE(m_aMutex)
+ ,ODescriptor(OTableDescriptor_BASE::rBHelper,_bCase,sal_True)
+ ,m_pKeys(NULL)
+ ,m_pColumns(NULL)
+ ,m_pIndexes(NULL)
+ ,m_pTables(_pTables)
+{
+}
+// -----------------------------------------------------------------------------
+OTable::OTable( OCollection* _pTables,
+ sal_Bool _bCase,
+ const ::rtl::OUString& _Name, const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description,const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _CatalogName) : OTableDescriptor_BASE(m_aMutex)
+ ,ODescriptor(OTableDescriptor_BASE::rBHelper,_bCase)
+ ,m_CatalogName(_CatalogName)
+ ,m_SchemaName(_SchemaName)
+ ,m_Description(_Description)
+ ,m_Type(_Type)
+ ,m_pKeys(NULL)
+ ,m_pColumns(NULL)
+ ,m_pIndexes(NULL)
+ ,m_pTables(_pTables)
+{
+ m_Name = _Name;
+}
+// -------------------------------------------------------------------------
+OTable::~OTable()
+{
+ delete m_pKeys;
+ delete m_pColumns;
+ delete m_pIndexes;
+}
+// -------------------------------------------------------------------------
+void OTable::construct()
+{
+ ODescriptor::construct();
+
+ sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
+
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME), PROPERTY_ID_CATALOGNAME,nAttrib,&m_CatalogName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME), PROPERTY_ID_SCHEMANAME, nAttrib,&m_SchemaName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION), PROPERTY_ID_DESCRIPTION,nAttrib,&m_Description, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE), PROPERTY_ID_TYPE, nAttrib,&m_Type, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OTable::acquire() throw()
+{
+ OTableDescriptor_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OTable::release() throw()
+{
+ OTableDescriptor_BASE::release();
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL OTable::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = ODescriptor::queryInterface( rType);
+ if(!aRet.hasValue())
+ {
+ if(!isNew())
+ aRet = OTable_BASE::queryInterface( rType);
+ if(isNew() && (rType == getCppuType( (Reference<XIndexesSupplier>*)0)))
+ return Any();
+ if(!aRet.hasValue())
+ aRet = OTableDescriptor_BASE::queryInterface( rType);
+ }
+ return aRet;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OTable::getTypes( ) throw(RuntimeException)
+{
+ if(isNew())
+ return ::comphelper::concatSequences(ODescriptor::getTypes(),OTableDescriptor_BASE::getTypes());
+ return ::comphelper::concatSequences(ODescriptor::getTypes(),OTableDescriptor_BASE::getTypes(),OTable_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OTable::disposing(void)
+{
+ ODescriptor::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ if(m_pKeys)
+ m_pKeys->disposing();
+ if(m_pColumns)
+ m_pColumns->disposing();
+ if(m_pIndexes)
+ m_pIndexes->disposing();
+
+ m_pTables = NULL;
+}
+// -----------------------------------------------------------------------------
+// XColumnsSupplier
+Reference< XNameAccess > SAL_CALL OTable::getColumns( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
+
+ try
+ {
+ if ( !m_pColumns )
+ refreshColumns();
+ }
+ catch( const RuntimeException& )
+ {
+ // allowed to leave this method
+ throw;
+ }
+ catch( const Exception& )
+ {
+ // allowed
+ }
+
+ return m_pColumns;
+}
+
+// -------------------------------------------------------------------------
+// XKeysSupplier
+Reference< XIndexAccess > SAL_CALL OTable::getKeys( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
+
+ Reference< XIndexAccess > xKeys;
+
+ try
+ {
+ if ( !m_pKeys )
+ refreshKeys();
+ xKeys = m_pKeys;
+ }
+ catch( const RuntimeException& )
+ {
+ // allowed to leave this method
+ throw;
+ }
+ catch( const Exception& )
+ {
+ // allowed
+ }
+
+ return xKeys;
+}
+// -----------------------------------------------------------------------------
+cppu::IPropertyArrayHelper* OTable::createArrayHelper( sal_Int32 /*_nId*/ ) const
+{
+ return doCreateArrayHelper();
+}
+// -------------------------------------------------------------------------
+cppu::IPropertyArrayHelper & OTable::getInfoHelper()
+{
+ return *const_cast<OTable*>(this)->getArrayHelper(isNew() ? 1 : 0);
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > SAL_CALL OTable::createDataDescriptor( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
+
+ OTable* pTable = new OTable(m_pTables,isCaseSensitive(),m_Name,m_Type,m_Description,m_SchemaName,m_CatalogName);
+ pTable->setNew(sal_True);
+ return pTable;
+}
+// -------------------------------------------------------------------------
+// XIndexesSupplier
+Reference< XNameAccess > SAL_CALL OTable::getIndexes( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
+
+ try
+ {
+ if ( !m_pIndexes )
+ refreshIndexes();
+ }
+ catch( const RuntimeException& )
+ {
+ // allowed to leave this method
+ throw;
+ }
+ catch( const Exception& )
+ {
+ // allowed
+ }
+
+ return m_pIndexes;
+}
+// -------------------------------------------------------------------------
+// XRename
+void SAL_CALL OTable::rename( const ::rtl::OUString& newName ) throw(SQLException, ElementExistException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
+
+ const ::rtl::OUString sOldComposedName = getName();
+ const Reference< XDatabaseMetaData> xMetaData = getMetaData();
+ if ( xMetaData.is() )
+ ::dbtools::qualifiedNameComponents(xMetaData,newName,m_CatalogName,m_SchemaName,m_Name,::dbtools::eInDataManipulation);
+ else
+ m_Name = newName;
+
+ m_pTables->renameObject(sOldComposedName,newName);
+}
+// -----------------------------------------------------------------------------
+Reference< XDatabaseMetaData> OTable::getMetaData() const
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+// XAlterTable
+void SAL_CALL OTable::alterColumnByName( const ::rtl::OUString& /*colName*/, const Reference< XPropertySet >& /*descriptor*/ ) throw(SQLException, NoSuchElementException, RuntimeException)
+{
+ throwFeatureNotImplementedException( "XAlterTable::alterColumnByName", *this );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OTable::alterColumnByIndex( sal_Int32 /*index*/, const Reference< XPropertySet >& /*descriptor*/ ) throw(SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, RuntimeException)
+{
+ throwFeatureNotImplementedException( "XAlterTable::alterColumnByIndex", *this );
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OTable::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OTable::getName() throw(::com::sun::star::uno::RuntimeException)
+{
+ // this is only correct for tables who haven't a schema or catalog name
+ OSL_ENSURE(!m_CatalogName.getLength(),"getName(): forgot to overload getName()!");
+ OSL_ENSURE(!m_SchemaName.getLength(),"getName(): forgot to overload getName()!");
+ return m_Name;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OTable::setName( const ::rtl::OUString& /*aName*/ ) throw(::com::sun::star::uno::RuntimeException)
+{
+}
+// -----------------------------------------------------------------------------
+void OTable::refreshColumns()
+{
+}
+// -----------------------------------------------------------------------------
+void OTable::refreshKeys()
+{
+}
+// -----------------------------------------------------------------------------
+void OTable::refreshIndexes()
+{
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/sdbcx/VUser.cxx b/connectivity/source/sdbcx/VUser.cxx
new file mode 100644
index 000000000000..ee05eb1b2139
--- /dev/null
+++ b/connectivity/source/sdbcx/VUser.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 <stdio.h>
+#include "connectivity/sdbcx/VUser.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/PrivilegeObject.hpp>
+#include "TConnection.hxx"
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <connectivity/dbexception.hxx>
+#include <comphelper/sequence.hxx>
+
+// -------------------------------------------------------------------------
+using namespace connectivity;
+using namespace connectivity::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+IMPLEMENT_SERVICE_INFO(OUser,"com.sun.star.sdbcx.VUser","com.sun.star.sdbcx.User");
+// -------------------------------------------------------------------------
+OUser::OUser(sal_Bool _bCase) : OUser_BASE(m_aMutex)
+ , ODescriptor(OUser_BASE::rBHelper,_bCase,sal_True)
+ , m_pGroups(NULL)
+{
+}
+// -------------------------------------------------------------------------
+OUser::OUser(const ::rtl::OUString& _Name,sal_Bool _bCase) : OUser_BASE(m_aMutex)
+ ,ODescriptor(OUser_BASE::rBHelper,_bCase)
+ ,m_pGroups(NULL)
+{
+ m_Name = _Name;
+}
+// -------------------------------------------------------------------------
+OUser::~OUser( )
+{
+ delete m_pGroups;
+}
+// -------------------------------------------------------------------------
+void OUser::disposing(void)
+{
+ OPropertySetHelper::disposing();
+ ::osl::MutexGuard aGuard(m_aMutex);
+ if(m_pGroups)
+ m_pGroups->disposing();
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OUser::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = ODescriptor::queryInterface( rType);
+ return aRet.hasValue() ? aRet : OUser_BASE::queryInterface( rType);
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OUser::getTypes( ) throw(RuntimeException)
+{
+ return ::comphelper::concatSequences(ODescriptor::getTypes(),OUser_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OUser::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & OUser::getInfoHelper()
+{
+ return *const_cast<OUser*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+// XUser
+void SAL_CALL OUser::changePassword( const ::rtl::OUString& /*objPassword*/, const ::rtl::OUString& /*newPassword*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE::rBHelper.bDisposed);
+ ::dbtools::throwFeatureNotImplementedException( "XUser::changePassword", *this );
+}
+// -------------------------------------------------------------------------
+// XGroupsSupplier
+Reference< XNameAccess > SAL_CALL OUser::getGroups( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE::rBHelper.bDisposed);
+
+ try
+ {
+ if ( !m_pGroups )
+ refreshGroups();
+ }
+ catch( const RuntimeException& )
+ {
+ // allowed to leave this method
+ throw;
+ }
+ catch( const Exception& )
+ {
+ // allowed
+ }
+
+ return const_cast<OUser*>(this)->m_pGroups;
+}
+// -------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OUser::getPrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE::rBHelper.bDisposed);
+ ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::changePassword", *this );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OUser::getGrantablePrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE::rBHelper.bDisposed);
+ ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::getGrantablePrivileges", *this );
+ return 0;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OUser::grantPrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE::rBHelper.bDisposed);
+ ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::grantPrivileges", *this );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OUser::revokePrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE::rBHelper.bDisposed);
+ ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::revokePrivileges", *this );
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OUser::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OUser::getName( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return m_Name;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OUser::setName( const ::rtl::OUString& /*aName*/ ) throw(::com::sun::star::uno::RuntimeException)
+{
+ OSL_ENSURE( false, "OUser::setName: not implemented!" );
+ // not allowed to throw an SQLException here ...
+}
+// -----------------------------------------------------------------------------
+// XInterface
+void SAL_CALL OUser::acquire() throw()
+{
+ OUser_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OUser::release() throw()
+{
+ OUser_BASE::release();
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/sdbcx/VView.cxx b/connectivity/source/sdbcx/VView.cxx
new file mode 100644
index 000000000000..281566162db7
--- /dev/null
+++ b/connectivity/source/sdbcx/VView.cxx
@@ -0,0 +1,150 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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/sdbcx/VView.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/sequence.hxx>
+#include "connectivity/dbtools.hxx"
+#include "TConnection.hxx"
+
+// -------------------------------------------------------------------------
+using namespace connectivity;
+using namespace connectivity::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+IMPLEMENT_SERVICE_INFO(OView,"com.sun.star.sdbcx.VView","com.sun.star.sdbcx.View");
+// -------------------------------------------------------------------------
+OView::OView(sal_Bool _bCase,
+ const ::rtl::OUString& _Name,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _xMetaData,
+ sal_Int32 _CheckOption,
+ const ::rtl::OUString& _Command,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _CatalogName) : ODescriptor(::comphelper::OMutexAndBroadcastHelper::m_aBHelper,_bCase)
+ ,m_CatalogName(_CatalogName)
+ ,m_SchemaName(_SchemaName)
+ ,m_Command(_Command)
+ ,m_CheckOption(_CheckOption)
+ ,m_xMetaData(_xMetaData)
+
+{
+ m_Name = _Name;
+ construct();
+}
+// -------------------------------------------------------------------------
+OView::OView(sal_Bool _bCase,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _xMetaData)
+ : ODescriptor(::comphelper::OMutexAndBroadcastHelper::m_aBHelper,_bCase,sal_True)
+ ,m_xMetaData(_xMetaData)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+OView::~OView()
+{
+}
+// -------------------------------------------------------------------------
+void OView::construct()
+{
+ ODescriptor::construct();
+
+ sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
+
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME), PROPERTY_ID_CATALOGNAME,nAttrib,&m_CatalogName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME), PROPERTY_ID_SCHEMANAME, nAttrib,&m_SchemaName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND), PROPERTY_ID_COMMAND, nAttrib,&m_Command, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CHECKOPTION), PROPERTY_ID_CHECKOPTION,nAttrib,&m_CheckOption, ::getCppuType(reinterpret_cast< sal_Int32*>(NULL)));
+}
+// -------------------------------------------------------------------------
+void OView::disposing(void)
+{
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OView::getTypes( ) throw(RuntimeException)
+{
+ return ::comphelper::concatSequences(ODescriptor::getTypes(),OView_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OView::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OView_BASE::queryInterface( rType);
+ return aRet.hasValue() ? aRet : ODescriptor::queryInterface( rType);
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OView::createArrayHelper( sal_Int32 /*_nId*/ ) const
+{
+ return doCreateArrayHelper();
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & OView::getInfoHelper()
+{
+ return *const_cast<OView*>(this)->getArrayHelper(isNew() ? 1 : 0);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OView::getName() throw(::com::sun::star::uno::RuntimeException)
+{
+ ::rtl::OUString sComposedName;
+ if(m_xMetaData.is())
+ sComposedName = ::dbtools::composeTableName( m_xMetaData, m_CatalogName, m_SchemaName, m_Name, sal_False, ::dbtools::eInDataManipulation );
+ else
+ {
+ Any aValue;
+ getFastPropertyValue(aValue,PROPERTY_ID_NAME);
+ aValue >>= sComposedName;
+ }
+ return sComposedName;
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OView::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OView::setName( const ::rtl::OUString& ) throw(::com::sun::star::uno::RuntimeException)
+{
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OView::acquire() throw()
+{
+ OView_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OView::release() throw()
+{
+ OView_BASE::release();
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/sdbcx/makefile.mk b/connectivity/source/sdbcx/makefile.mk
new file mode 100644
index 000000000000..c036e83db58b
--- /dev/null
+++ b/connectivity/source/sdbcx/makefile.mk
@@ -0,0 +1,63 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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=sdbcx
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/dbtools.pmk
+
+# --- Files -------------------------------------
+
+SLOFILES=\
+ $(SLO)$/VDescriptor.obj \
+ $(SLO)$/VCollection.obj \
+ $(SLO)$/VColumn.obj \
+ $(SLO)$/VIndexColumn.obj \
+ $(SLO)$/VKeyColumn.obj \
+ $(SLO)$/VUser.obj \
+ $(SLO)$/VGroup.obj \
+ $(SLO)$/VTable.obj \
+ $(SLO)$/VKey.obj \
+ $(SLO)$/VIndex.obj \
+ $(SLO)$/VCatalog.obj \
+ $(SLO)$/VView.obj
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/connectivity/source/simpledbt/charset_s.cxx b/connectivity/source/simpledbt/charset_s.cxx
new file mode 100644
index 000000000000..ac07c6fb9a08
--- /dev/null
+++ b/connectivity/source/simpledbt/charset_s.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 "charset_s.hxx"
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ using namespace ::dbtools;
+
+ //====================================================================
+ //= ODataAccessCharSet
+ //====================================================================
+ //----------------------------------------------------------------
+ oslInterlockedCount SAL_CALL ODataAccessCharSet::acquire()
+ {
+ return ORefBase::acquire();
+ }
+
+ //----------------------------------------------------------------
+ oslInterlockedCount SAL_CALL ODataAccessCharSet::release()
+ {
+ return ORefBase::release();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 ODataAccessCharSet::getSupportedTextEncodings( ::std::vector< rtl_TextEncoding >& _rEncs ) const
+ {
+ _rEncs.clear();
+
+ OCharsetMap::const_iterator aLoop = m_aCharsetInfo.begin();
+ OCharsetMap::const_iterator aLoopEnd = m_aCharsetInfo.end();
+ while (aLoop != aLoopEnd)
+ {
+ _rEncs.push_back( (*aLoop).getEncoding() );
+ ++aLoop;
+ }
+
+ return _rEncs.size();
+ }
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
diff --git a/connectivity/source/simpledbt/charset_s.hxx b/connectivity/source/simpledbt/charset_s.hxx
new file mode 100644
index 000000000000..40bf9d9dcb0c
--- /dev/null
+++ b/connectivity/source/simpledbt/charset_s.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_DBTOOLS_CHARSET_S_HXX
+#define CONNECTIVITY_DBTOOLS_CHARSET_S_HXX
+
+#include <connectivity/virtualdbtools.hxx>
+#include "refbase.hxx"
+#include <connectivity/dbcharset.hxx>
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ //====================================================================
+ //= ODataAccessCharSet
+ //====================================================================
+ class ODataAccessCharSet
+ :public simple::IDataAccessCharSet
+ ,public ORefBase
+ {
+ protected:
+ ::dbtools::OCharsetMap m_aCharsetInfo;
+
+ public:
+ ODataAccessCharSet() { }
+
+ // IDataAccessCharSet
+ sal_Int32 getSupportedTextEncodings(
+ ::std::vector< rtl_TextEncoding >& /* [out] */ _rEncs
+ ) const;
+
+ // disambiguate IReference
+ virtual oslInterlockedCount SAL_CALL acquire();
+ virtual oslInterlockedCount SAL_CALL release();
+ };
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
+#endif // CONNECTIVITY_DBTOOLS_CHARSET_S_HXX
+
diff --git a/connectivity/source/simpledbt/dbtfactory.cxx b/connectivity/source/simpledbt/dbtfactory.cxx
new file mode 100644
index 000000000000..148a5270b6d2
--- /dev/null
+++ b/connectivity/source/simpledbt/dbtfactory.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <connectivity/virtualdbtools.hxx>
+#include <connectivity/formattedcolumnvalue.hxx>
+#include "dbtfactory.hxx"
+#include "parser_s.hxx"
+#include "staticdbtools_s.hxx"
+#include "charset_s.hxx"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+//================================================================
+// the entry point for load-on-call usage of the DBTOOLS lib
+extern "C" void* SAL_CALL createDataAccessToolsFactory()
+{
+ ::connectivity::ODataAccessToolsFactory* pFactory = new ::connectivity::ODataAccessToolsFactory;
+ pFactory->acquire();
+ return pFactory;
+}
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ //================================================================
+ //= ODataAccessToolsFactory
+ //================================================================
+ //----------------------------------------------------------------
+ ODataAccessToolsFactory::ODataAccessToolsFactory()
+ {
+ ODataAccessStaticTools* pStaticTools = new ODataAccessStaticTools;
+ m_xTypeConversionHelper = pStaticTools;
+ m_xToolsHelper = pStaticTools;
+ }
+
+ //----------------------------------------------------------------
+ oslInterlockedCount SAL_CALL ODataAccessToolsFactory::acquire()
+ {
+ return ORefBase::acquire();
+ }
+
+ //----------------------------------------------------------------
+ oslInterlockedCount SAL_CALL ODataAccessToolsFactory::release()
+ {
+ return ORefBase::release();
+ }
+
+ //----------------------------------------------------------------
+ ::rtl::Reference< simple::IDataAccessTypeConversion > ODataAccessToolsFactory::getTypeConversionHelper()
+ {
+ return m_xTypeConversionHelper;
+ }
+
+ //----------------------------------------------------------------
+ ::rtl::Reference< simple::IDataAccessCharSet > ODataAccessToolsFactory::createCharsetHelper( ) const
+ {
+ return new ODataAccessCharSet;
+ }
+
+ //----------------------------------------------------------------
+ ::rtl::Reference< simple::IDataAccessTools > ODataAccessToolsFactory::getDataAccessTools()
+ {
+ return m_xToolsHelper;
+ }
+
+ //----------------------------------------------------------------
+ ::std::auto_ptr< ::dbtools::FormattedColumnValue > ODataAccessToolsFactory::createFormattedColumnValue( const ::comphelper::ComponentContext& _rContext,
+ const Reference< ::com::sun::star::sdbc::XRowSet >& _rxRowSet, const Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn )
+ {
+ ::std::auto_ptr< ::dbtools::FormattedColumnValue > pValue( new ::dbtools::FormattedColumnValue( _rContext, _rxRowSet, _rxColumn ) );
+ return pValue;
+ }
+
+ //----------------------------------------------------------------
+ ::rtl::Reference< simple::ISQLParser > ODataAccessToolsFactory::createSQLParser(const Reference< XMultiServiceFactory >& _rxServiceFactory,const IParseContext* _pContext) const
+ {
+ return new OSimpleSQLParser(_rxServiceFactory,_pContext);
+ }
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
+
diff --git a/connectivity/source/simpledbt/dbtfactory.hxx b/connectivity/source/simpledbt/dbtfactory.hxx
new file mode 100644
index 000000000000..3ce0be0762d2
--- /dev/null
+++ b/connectivity/source/simpledbt/dbtfactory.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_DBTOOLS_DBTFACTORY_HXX
+#define CONNECTIVITY_DBTOOLS_DBTFACTORY_HXX
+
+#include <connectivity/virtualdbtools.hxx>
+#include "refbase.hxx"
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ //================================================================
+ //= ODataAccessToolsFactory
+ //================================================================
+ class ODataAccessToolsFactory
+ :public simple::IDataAccessToolsFactory
+ ,public ORefBase
+ {
+ protected:
+ ::rtl::Reference< simple::IDataAccessTypeConversion > m_xTypeConversionHelper;
+ ::rtl::Reference< simple::IDataAccessTools > m_xToolsHelper;
+
+ public:
+ ODataAccessToolsFactory();
+
+ // IDataAccessToolsFactory
+ virtual ::rtl::Reference< simple::ISQLParser > createSQLParser(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxServiceFactory,
+ const IParseContext* _pContext
+ ) const;
+
+ virtual ::rtl::Reference< simple::IDataAccessCharSet > createCharsetHelper( ) const;
+
+ virtual ::rtl::Reference< simple::IDataAccessTypeConversion > getTypeConversionHelper();
+
+ virtual ::rtl::Reference< simple::IDataAccessTools > getDataAccessTools();
+
+ virtual ::std::auto_ptr< ::dbtools::FormattedColumnValue > createFormattedColumnValue(
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& _rxRowSet,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn
+ );
+
+ // IReference
+ virtual oslInterlockedCount SAL_CALL acquire();
+ virtual oslInterlockedCount SAL_CALL release();
+ };
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
+#endif // CONNECTIVITY_DBTOOLS_DBTFACTORY_HXX
+
diff --git a/connectivity/source/simpledbt/makefile.mk b/connectivity/source/simpledbt/makefile.mk
new file mode 100644
index 000000000000..49409e2f8672
--- /dev/null
+++ b/connectivity/source/simpledbt/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=connectivity
+TARGET=simpledbt
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/dbtools.pmk
+
+# --- Files --------------------------------------------------------
+
+EXCEPTIONSFILES=\
+ $(SLO)$/charset_s.obj \
+ $(SLO)$/staticdbtools_s.obj \
+ $(SLO)$/parsenode_s.obj \
+ $(SLO)$/parser_s.obj
+
+SLOFILES=\
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/refbase.obj \
+ $(SLO)$/dbtfactory.obj \
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/connectivity/source/simpledbt/parsenode_s.cxx b/connectivity/source/simpledbt/parsenode_s.cxx
new file mode 100644
index 000000000000..7a7b54307589
--- /dev/null
+++ b/connectivity/source/simpledbt/parsenode_s.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 <connectivity/virtualdbtools.hxx>
+#include "parsenode_s.hxx"
+#include <connectivity/sqlnode.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ //================================================================
+ //= OSimpleParseNode
+ //================================================================
+ //----------------------------------------------------------------
+ OSimpleParseNode::OSimpleParseNode(const OSQLParseNode* _pNode, sal_Bool _bTakeOwnership)
+ :m_pFullNode(_pNode)
+ ,m_bOwner(_bTakeOwnership)
+ {
+ OSL_ENSURE(m_pFullNode, "OSimpleParseNode::OSimpleParseNode: invalid node given!");
+ }
+
+ //----------------------------------------------------------------
+ OSimpleParseNode::~OSimpleParseNode()
+ {
+ if (m_bOwner)
+ delete m_pFullNode;
+ }
+
+ //----------------------------------------------------------------
+ oslInterlockedCount SAL_CALL OSimpleParseNode::acquire()
+ {
+ return ORefBase::acquire();
+ }
+
+ //----------------------------------------------------------------
+ oslInterlockedCount SAL_CALL OSimpleParseNode::release()
+ {
+ return ORefBase::release();
+ }
+
+ //----------------------------------------------------------------
+ void OSimpleParseNode::parseNodeToStr(::rtl::OUString& _rString, const Reference< XConnection >& _rxConnection,const IParseContext* _pContext) const
+ {
+ m_pFullNode->parseNodeToStr( _rString, _rxConnection, _pContext );
+ }
+
+ //----------------------------------------------------------------
+ void OSimpleParseNode::parseNodeToPredicateStr(::rtl::OUString& _rString, const Reference< XConnection >& _rxConnection,
+ const Reference< XNumberFormatter >& _rxFormatter, const Reference< XPropertySet >& _rxField,
+ const Locale& _rIntl, const sal_Char _cDecSeparator,const IParseContext* _pContext) const
+ {
+ m_pFullNode->parseNodeToPredicateStr( _rString, _rxConnection, _rxFormatter, _rxField, _rIntl, _cDecSeparator, _pContext );
+ }
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
+
diff --git a/connectivity/source/simpledbt/parsenode_s.hxx b/connectivity/source/simpledbt/parsenode_s.hxx
new file mode 100644
index 000000000000..b580c4e383a2
--- /dev/null
+++ b/connectivity/source/simpledbt/parsenode_s.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_PARSENODE_SIMPLE_HXX
+#define CONNECTIVITY_PARSENODE_SIMPLE_HXX
+
+#include <connectivity/virtualdbtools.hxx>
+#include "refbase.hxx"
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ class OSQLParseNode;
+ //================================================================
+ //= OSimpleParseNode
+ //================================================================
+ class OSimpleParseNode
+ :public simple::ISQLParseNode
+ ,public ORefBase
+ {
+ protected:
+ const OSQLParseNode* m_pFullNode;
+ sal_Bool m_bOwner;
+
+ public:
+ OSimpleParseNode(const OSQLParseNode* _pNode, sal_Bool _bTakeOwnership = sal_True);
+ ~OSimpleParseNode();
+
+ // ISQLParseNode
+ virtual void parseNodeToStr(::rtl::OUString& _rString,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const IParseContext* _pContext
+ ) const;
+
+ virtual void parseNodeToPredicateStr(::rtl::OUString& _rString,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField,
+ const ::com::sun::star::lang::Locale& _rIntl,
+ const sal_Char _cDecSeparator,
+ const IParseContext* _pContext
+ ) const;
+
+ // disambiguate IReference
+ virtual oslInterlockedCount SAL_CALL acquire();
+ virtual oslInterlockedCount SAL_CALL release();
+ };
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
+#endif // CONNECTIVITY_PARSENODE_SIMPLE_HXX
+
+
diff --git a/connectivity/source/simpledbt/parser_s.cxx b/connectivity/source/simpledbt/parser_s.cxx
new file mode 100644
index 000000000000..2903776f0d3d
--- /dev/null
+++ b/connectivity/source/simpledbt/parser_s.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 <connectivity/virtualdbtools.hxx>
+#include "parser_s.hxx"
+#include "parsenode_s.hxx"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ //================================================================
+ //= OSimpleSQLParser
+ //================================================================
+ //----------------------------------------------------------------
+ OSimpleSQLParser::OSimpleSQLParser(const Reference< XMultiServiceFactory >& _rxServiceFactory,const IParseContext* _pContext)
+ :m_aFullParser(_rxServiceFactory,_pContext)
+ {
+ }
+
+ //----------------------------------------------------------------
+ oslInterlockedCount SAL_CALL OSimpleSQLParser::acquire()
+ {
+ return ORefBase::acquire();
+ }
+
+ //----------------------------------------------------------------
+ oslInterlockedCount SAL_CALL OSimpleSQLParser::release()
+ {
+ return ORefBase::release();
+ }
+
+ //----------------------------------------------------------------
+ const IParseContext& OSimpleSQLParser::getContext() const
+ {
+ return m_aFullParser.getContext();
+ }
+
+ //----------------------------------------------------------------
+ ::rtl::Reference< simple::ISQLParseNode > OSimpleSQLParser::predicateTree(::rtl::OUString& rErrorMessage, const ::rtl::OUString& rStatement,
+ const Reference< XNumberFormatter >& _rxFormatter, const Reference< XPropertySet >& _rxField) const
+ {
+ OSimpleParseNode* pReturn = NULL;
+ OSQLParseNode* pFullNode = const_cast<OSimpleSQLParser*>(this)->m_aFullParser.predicateTree(rErrorMessage, rStatement, _rxFormatter, _rxField);
+ if (pFullNode)
+ pReturn = new OSimpleParseNode(pFullNode, sal_True);
+ return pReturn;
+ }
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
+
diff --git a/connectivity/source/simpledbt/parser_s.hxx b/connectivity/source/simpledbt/parser_s.hxx
new file mode 100644
index 000000000000..6756c703a045
--- /dev/null
+++ b/connectivity/source/simpledbt/parser_s.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_DBTOOLS_PARSER_SIMPLE_HXX
+#define CONNECTIVITY_DBTOOLS_PARSER_SIMPLE_HXX
+
+#include <connectivity/virtualdbtools.hxx>
+#include "refbase.hxx"
+#include <connectivity/sqlparse.hxx>
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ //================================================================
+ //= OSimpleSQLParser
+ //================================================================
+ class OSimpleSQLParser
+ :public simple::ISQLParser
+ ,public ORefBase
+ {
+ protected:
+ OSQLParser m_aFullParser;
+
+ public:
+ OSimpleSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxServiceFactory,const IParseContext* _pContext);
+
+ // ISQLParser
+ virtual ::rtl::Reference< simple::ISQLParseNode > predicateTree(
+ ::rtl::OUString& rErrorMessage,
+ const ::rtl::OUString& rStatement,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField
+ ) const;
+
+ virtual const IParseContext& getContext() const;
+
+ // disambiguate IReference
+ virtual oslInterlockedCount SAL_CALL acquire();
+ virtual oslInterlockedCount SAL_CALL release();
+ };
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
+#endif // CONNECTIVITY_DBTOOLS_PARSER_SIMPLE_HXX
+
+
diff --git a/connectivity/source/simpledbt/refbase.cxx b/connectivity/source/simpledbt/refbase.cxx
new file mode 100644
index 000000000000..6047732bffd5
--- /dev/null
+++ b/connectivity/source/simpledbt/refbase.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 "refbase.hxx"
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ //================================================================
+ //= ORefBase
+ //================================================================
+ //----------------------------------------------------------------
+ ORefBase::~ORefBase()
+ {
+ }
+
+ //----------------------------------------------------------------
+ oslInterlockedCount SAL_CALL ORefBase::acquire()
+ {
+ return osl_incrementInterlockedCount(&m_refCount);
+ }
+
+ //----------------------------------------------------------------
+ oslInterlockedCount SAL_CALL ORefBase::release()
+ {
+ oslInterlockedCount nNewRefCount = osl_decrementInterlockedCount(&m_refCount);
+ if (0 == nNewRefCount)
+ delete this;
+
+ return nNewRefCount;
+ }
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
diff --git a/connectivity/source/simpledbt/refbase.hxx b/connectivity/source/simpledbt/refbase.hxx
new file mode 100644
index 000000000000..1ceb43a4555d
--- /dev/null
+++ b/connectivity/source/simpledbt/refbase.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_DBTOOLS_REFBASE_HXX
+#define CONNECTIVITY_DBTOOLS_REFBASE_HXX
+
+#include <rtl/ref.hxx>
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ //================================================================
+ //= ORefBase
+ //================================================================
+ /// base class for all objects implementing the ::rtl::IReference interface
+ class ORefBase : public ::rtl::IReference
+ {
+ protected:
+ oslInterlockedCount m_refCount;
+
+ protected:
+ ORefBase() : m_refCount(0) { }
+ virtual ~ORefBase();
+
+ virtual oslInterlockedCount SAL_CALL acquire();
+ virtual oslInterlockedCount SAL_CALL release();
+ };
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
+#endif // CONNECTIVITY_DBTOOLS_REFBASE_HXX
+
+
diff --git a/connectivity/source/simpledbt/staticdbtools_s.cxx b/connectivity/source/simpledbt/staticdbtools_s.cxx
new file mode 100644
index 000000000000..17d052a35b6b
--- /dev/null
+++ b/connectivity/source/simpledbt/staticdbtools_s.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/virtualdbtools.hxx>
+#include "staticdbtools_s.hxx"
+#include <connectivity/dbconversion.hxx>
+#include <connectivity/dbtools.hxx>
+#include <com/sun/star/sdb/SQLContext.hpp>
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+
+ //================================================================
+ //= ODataAccessStaticTools
+ //================================================================
+ //----------------------------------------------------------------
+ ODataAccessStaticTools::ODataAccessStaticTools()
+ {
+ }
+
+ //----------------------------------------------------------------
+ Date ODataAccessStaticTools::getStandardDate() const
+ {
+ return ::dbtools::DBTypeConversion::getStandardDate();
+ }
+
+ //----------------------------------------------------------------
+ double ODataAccessStaticTools::getValue(const Reference< XColumn>& _rxVariant, const Date& rNullDate, sal_Int16 nKeyType) const
+ {
+ return ::dbtools::DBTypeConversion::getValue(_rxVariant, rNullDate, nKeyType);
+ }
+
+ //----------------------------------------------------------------
+ ::rtl::OUString ODataAccessStaticTools::getValue(const Reference< XColumn >& _rxColumn, const Reference< XNumberFormatter >& _rxFormatter,
+ const Date& _rNullDate, sal_Int32 _nKey, sal_Int16 _nKeyType) const
+ {
+ return ::dbtools::DBTypeConversion::getValue(_rxColumn, _rxFormatter, _rNullDate, _nKey, _nKeyType);
+ }
+
+ //----------------------------------------------------------------
+ ::rtl::OUString ODataAccessStaticTools::getValue( const Reference< XPropertySet>& _rxColumn, const Reference< XNumberFormatter>& _rxFormatter,
+ const Locale& _rLocale, const Date& _rNullDate ) const
+ {
+ return ::dbtools::DBTypeConversion::getValue( _rxColumn, _rxFormatter, _rLocale, _rNullDate );
+ }
+
+ //----------------------------------------------------------------
+ oslInterlockedCount SAL_CALL ODataAccessStaticTools::acquire()
+ {
+ return ORefBase::acquire();
+ }
+
+ //----------------------------------------------------------------
+ oslInterlockedCount SAL_CALL ODataAccessStaticTools::release()
+ {
+ return ORefBase::release();
+ }
+
+ //----------------------------------------------------------------
+ Reference< XConnection> ODataAccessStaticTools::getConnection_withFeedback(const ::rtl::OUString& _rDataSourceName, const ::rtl::OUString& _rUser,
+ const ::rtl::OUString& _rPwd, const Reference< XMultiServiceFactory>& _rxFactory) const SAL_THROW ( (SQLException) )
+ {
+ return ::dbtools::getConnection_withFeedback(_rDataSourceName, _rUser, _rPwd, _rxFactory);
+ }
+
+ //----------------------------------------------------------------
+ Reference< XConnection> ODataAccessStaticTools::connectRowset(const Reference< XRowSet>& _rxRowSet, const Reference< XMultiServiceFactory>& _rxFactory, sal_Bool _bSetAsActiveConnection) const
+ SAL_THROW ( (SQLException, WrappedTargetException, RuntimeException) )
+ {
+ return ::dbtools::connectRowset( _rxRowSet, _rxFactory, _bSetAsActiveConnection);
+ }
+
+ // ------------------------------------------------
+ Reference< XConnection> ODataAccessStaticTools::getRowSetConnection(
+ const Reference< XRowSet>& _rxRowSet)
+ const SAL_THROW ( (RuntimeException) )
+ {
+ return ::dbtools::getConnection(_rxRowSet);
+ }
+
+ //----------------------------------------------------------------
+ Reference< XNumberFormatsSupplier> ODataAccessStaticTools::getNumberFormats(const Reference< XConnection>& _rxConn, sal_Bool _bAllowDefault) const
+ {
+ return ::dbtools::getNumberFormats(_rxConn, _bAllowDefault);
+ }
+
+ //----------------------------------------------------------------
+ sal_Int32 ODataAccessStaticTools::getDefaultNumberFormat( const Reference< XPropertySet >& _rxColumn, const Reference< XNumberFormatTypes >& _rxTypes,
+ const Locale& _rLocale ) const
+ {
+ return ::dbtools::getDefaultNumberFormat( _rxColumn, _rxTypes, _rLocale );
+ }
+
+ //----------------------------------------------------------------
+ void ODataAccessStaticTools::TransferFormComponentProperties(const Reference< XPropertySet>& _rxOld, const Reference< XPropertySet>& _rxNew, const Locale& _rLocale) const
+ {
+ ::dbtools::TransferFormComponentProperties(_rxOld, _rxNew, _rLocale);
+ }
+
+ //----------------------------------------------------------------
+ ::rtl::OUString ODataAccessStaticTools::quoteName(const ::rtl::OUString& _rQuote, const ::rtl::OUString& _rName) const
+ {
+ return ::dbtools::quoteName(_rQuote, _rName);
+ }
+
+ //----------------------------------------------------------------
+ ::rtl::OUString ODataAccessStaticTools::composeTableNameForSelect( const Reference< XConnection >& _rxConnection, const ::rtl::OUString& _rCatalog, const ::rtl::OUString& _rSchema, const ::rtl::OUString& _rName ) const
+ {
+ return ::dbtools::composeTableNameForSelect( _rxConnection, _rCatalog, _rSchema, _rName );
+ }
+
+ //----------------------------------------------------------------
+ ::rtl::OUString ODataAccessStaticTools::composeTableNameForSelect( const Reference< XConnection >& _rxConnection, const Reference< XPropertySet>& _xTable ) const
+ {
+ return ::dbtools::composeTableNameForSelect( _rxConnection, _xTable );
+ }
+
+ //----------------------------------------------------------------
+ SQLContext ODataAccessStaticTools::prependContextInfo(SQLException& _rException, const Reference< XInterface >& _rxContext,
+ const ::rtl::OUString& _rContextDescription, const ::rtl::OUString& _rContextDetails) const
+ {
+ return ::dbtools::prependContextInfo(_rException, _rxContext, _rContextDescription, _rContextDetails);
+ }
+
+ //----------------------------------------------------------------
+ Reference< XDataSource > ODataAccessStaticTools::getDataSource( const ::rtl::OUString& _rsRegisteredName, const Reference< XMultiServiceFactory>& _rxFactory ) const
+ {
+ return ::dbtools::getDataSource( _rsRegisteredName, _rxFactory );
+ }
+
+ //----------------------------------------------------------------
+ sal_Bool ODataAccessStaticTools::canInsert(const Reference< XPropertySet>& _rxCursorSet) const
+ {
+ return ::dbtools::canInsert( _rxCursorSet );
+ }
+
+ //----------------------------------------------------------------
+ sal_Bool ODataAccessStaticTools::canUpdate(const Reference< XPropertySet>& _rxCursorSet) const
+ {
+ return ::dbtools::canUpdate( _rxCursorSet );
+ }
+
+ //----------------------------------------------------------------
+ sal_Bool ODataAccessStaticTools::canDelete(const Reference< XPropertySet>& _rxCursorSet) const
+ {
+ return ::dbtools::canDelete( _rxCursorSet );
+ }
+
+ //----------------------------------------------------------------
+ Reference< XNameAccess > ODataAccessStaticTools::getFieldsByCommandDescriptor( const Reference< XConnection >& _rxConnection,
+ const sal_Int32 _nCommandType, const ::rtl::OUString& _rCommand,
+ Reference< XComponent >& _rxKeepFieldsAlive, ::dbtools::SQLExceptionInfo* _pErrorInfo ) SAL_THROW( ( ) )
+ {
+ return ::dbtools::getFieldsByCommandDescriptor( _rxConnection, _nCommandType, _rCommand,
+ _rxKeepFieldsAlive, _pErrorInfo );
+ }
+
+ //----------------------------------------------------------------
+ Sequence< ::rtl::OUString > ODataAccessStaticTools::getFieldNamesByCommandDescriptor(
+ const Reference< XConnection >& _rxConnection, const sal_Int32 _nCommandType,
+ const ::rtl::OUString& _rCommand, ::dbtools::SQLExceptionInfo* _pErrorInfo ) SAL_THROW( ( ) )
+ {
+ return ::dbtools::getFieldNamesByCommandDescriptor( _rxConnection, _nCommandType,
+ _rCommand, _pErrorInfo );
+ }
+
+ // ------------------------------------------------
+ bool ODataAccessStaticTools::isEmbeddedInDatabase( const Reference< XInterface >& _rxComponent, Reference< XConnection >& _rxActualConnection )
+ {
+ return ::dbtools::isEmbeddedInDatabase( _rxComponent, _rxActualConnection );
+ }
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
diff --git a/connectivity/source/simpledbt/staticdbtools_s.hxx b/connectivity/source/simpledbt/staticdbtools_s.hxx
new file mode 100644
index 000000000000..6746ad7a0918
--- /dev/null
+++ b/connectivity/source/simpledbt/staticdbtools_s.hxx
@@ -0,0 +1,207 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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_STATIC_DBTOOLS_SIMPLE_HXX
+#define CONNECTIVITY_STATIC_DBTOOLS_SIMPLE_HXX
+
+#include <connectivity/virtualdbtools.hxx>
+#include "refbase.hxx"
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ //================================================================
+ //= ODataAccessStaticTools
+ //================================================================
+ class ODataAccessStaticTools
+ :public simple::IDataAccessTypeConversion
+ ,public simple::IDataAccessTools
+ ,public ORefBase
+ {
+ public:
+ ODataAccessStaticTools();
+
+ // IDataAccessTypeConversion
+ // ------------------------------------------------
+ virtual ::com::sun::star::util::Date getStandardDate() const;
+
+ // ------------------------------------------------
+ virtual double getValue(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn>& _rxVariant,
+ const ::com::sun::star::util::Date& rNullDate,
+ sal_Int16 nKeyType) const;
+
+ // ------------------------------------------------
+ virtual ::rtl::OUString getValue(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxColumn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
+ const ::com::sun::star::util::Date& _rNullDate,
+ sal_Int32 _nKey,
+ sal_Int16 _nKeyType) const;
+
+ // ------------------------------------------------
+ virtual ::rtl::OUString getValue(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxColumn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter>& _rxFormatter,
+ const ::com::sun::star::lang::Locale& _rLocale,
+ const ::com::sun::star::util::Date& _rNullDate
+ ) const;
+
+ // IDataAccessTools
+ // ------------------------------------------------
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection_withFeedback(
+ const ::rtl::OUString& _rDataSourceName,
+ const ::rtl::OUString& _rUser,
+ const ::rtl::OUString& _rPwd,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory
+ ) const SAL_THROW ( (::com::sun::star::sdbc::SQLException) );
+
+ // ------------------------------------------------
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> connectRowset(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory,
+ sal_Bool _bSetAsActiveConnection
+ ) const SAL_THROW ( ( ::com::sun::star::sdbc::SQLException
+ , ::com::sun::star::lang::WrappedTargetException
+ , ::com::sun::star::uno::RuntimeException ) );
+
+ // ------------------------------------------------
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getRowSetConnection(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet)
+ const SAL_THROW ( (::com::sun::star::uno::RuntimeException) );
+
+ // ------------------------------------------------
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> getNumberFormats(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConn,
+ sal_Bool _bAllowDefault
+ ) const;
+
+ // ------------------------------------------------
+ virtual sal_Int32 getDefaultNumberFormat(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatTypes >& _rxTypes,
+ const ::com::sun::star::lang::Locale& _rLocale
+ ) const;
+
+ // ------------------------------------------------
+ virtual void TransferFormComponentProperties(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxOld,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxNew,
+ const ::com::sun::star::lang::Locale& _rLocale
+ ) const;
+
+ // ------------------------------------------------
+ virtual ::rtl::OUString quoteName(
+ const ::rtl::OUString& _rQuote,
+ const ::rtl::OUString& _rName
+ ) const;
+
+ // ------------------------------------------------
+ virtual ::rtl::OUString composeTableNameForSelect(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::rtl::OUString& _rCatalog,
+ const ::rtl::OUString& _rSchema,
+ const ::rtl::OUString& _rName
+ ) const;
+
+ // ------------------------------------------------
+ virtual ::rtl::OUString composeTableNameForSelect(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable
+ ) const;
+
+ // ------------------------------------------------
+ virtual ::com::sun::star::sdb::SQLContext prependContextInfo(
+ ::com::sun::star::sdbc::SQLException& _rException,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext,
+ const ::rtl::OUString& _rContextDescription,
+ const ::rtl::OUString& _rContextDetails
+ ) const;
+
+ // ------------------------------------------------
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource > getDataSource(
+ const ::rtl::OUString& _rsRegisteredName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory
+ ) const;
+
+ // ------------------------------------------------
+ /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::INSERT
+ @param _rxCursorSet the property set
+ */
+ virtual sal_Bool canInsert(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const;
+
+ // ------------------------------------------------
+ /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::UPDATE
+ @param _rxCursorSet the property set
+ */
+ virtual sal_Bool canUpdate(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const;
+
+ // ------------------------------------------------
+ /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::DELETE
+ @param _rxCursorSet the property set
+ */
+ virtual sal_Bool canDelete(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const;
+
+ // ------------------------------------------------
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ getFieldsByCommandDescriptor(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const sal_Int32 _nCommandType,
+ const ::rtl::OUString& _rCommand,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _rxKeepFieldsAlive,
+ ::dbtools::SQLExceptionInfo* _pErrorInfo = NULL
+ ) SAL_THROW( ( ) );
+
+ // ------------------------------------------------
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getFieldNamesByCommandDescriptor(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const sal_Int32 _nCommandType,
+ const ::rtl::OUString& _rCommand,
+ ::dbtools::SQLExceptionInfo* _pErrorInfo = NULL
+ ) SAL_THROW( ( ) );
+
+ // ------------------------------------------------
+ virtual bool isEmbeddedInDatabase(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent,
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxActualConnection
+ );
+
+ // disambiguate IReference
+ // ------------------------------------------------
+ virtual oslInterlockedCount SAL_CALL acquire();
+ virtual oslInterlockedCount SAL_CALL release();
+ };
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
+#endif // CONNECTIVITY_STATIC_DBTOOLS_SIMPLE_HXX
+
diff --git a/connectivity/target.pmk b/connectivity/target.pmk
new file mode 100755
index 000000000000..e6e240a1ba4a
--- /dev/null
+++ b/connectivity/target.pmk
@@ -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.
+#
+#*************************************************************************
+
+.INCLUDE : target.mk
+
+COMPONENT_CONFIG_SCHEMA*=$(TARGET).xcs
+
+ALLTAR: "$(PWD)$/$(MISC)$/registry$/schema$/$(PACKAGEDIR)$/$(COMPONENT_CONFIG_SCHEMA)"
+"$(PWD)$/$(MISC)$/registry$/schema$/$(PACKAGEDIR)$/$(COMPONENT_CONFIG_SCHEMA)" : $(SOLARXMLDIR)$/registry$/schema$/$(PACKAGEDIR)$/Drivers.xcs
+ @@-$(MKDIRHIER) $(@:d)
+ $(COPY) $< $@
+
diff --git a/connectivity/util/makefile.mk b/connectivity/util/makefile.mk
new file mode 100755
index 000000000000..d92fe00bba24
--- /dev/null
+++ b/connectivity/util/makefile.mk
@@ -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.
+#
+#***********************************************************************/
+
+PRJ = ..
+PRJNAME = connectivity
+TARGET = connectivity
+
+.INCLUDE : settings.mk
+.INCLUDE : target.mk
+
+# For any given platform, for each driver .xcu (in $(MY_XCUS)) built on that
+# platform (in $(MISC)/registry/data/org/openoffice/Office/DataAccess) there are
+# corresponding language-specific .xcu files (in
+# $(MISC)/registry/res/%/org/openoffice/Office/DataAccess). For each language,
+# all language-specific .xcu files for that language are assembled into
+# $(BIN)$/fcfg_drivers_%.zip. To meet the requirements of dmake percent rules,
+# the first item from $(MY_XCUS) is arbitrarily taken to be the main
+# prerequisite while all the items from $(MY_XCUS) are made into indirect
+# prerequisites (harmlessly doubling the first item).
+
+MY_XCUS := \
+ $(shell cd $(MISC)/registry/data/org/openoffice/Office/DataAccess && \
+ ls *.xcu)
+
+.IF "$(MY_XCUS)" != ""
+
+ALLTAR : $(BIN)/fcfg_drivers_{$(alllangiso)}.zip
+
+$(BIN)/fcfg_drivers_{$(alllangiso)}.zip : \
+ $(MISC)/registry/res/$$(@:b:s/fcfg_drivers_//)/org/openoffice/Office/DataAccess/{$(MY_XCUS)}
+
+$(BIN)/fcfg_drivers_%.zip : \
+ $(MISC)/registry/res/%/org/openoffice/Office/DataAccess/$(MY_XCUS:1)
+ zip -j $@ \
+ $(foreach,i,$(MY_XCUS) \
+ $(MISC)/registry/res/$*/org/openoffice/Office/DataAccess/$i)
+
+.ENDIF
diff --git a/connectivity/version.mk b/connectivity/version.mk
new file mode 100644
index 000000000000..fd2235cfd182
--- /dev/null
+++ b/connectivity/version.mk
@@ -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.
+#
+#*************************************************************************
+
+# ----------------------------ADO settings------------------------------------#
+# target
+ADO_TARGET=ado
+
+# ----------------------------ODBC BASE settings-----------------------------------#
+# target
+ODBC2_TARGET=odbcbase
+
+# ----------------------------ODBC settings-----------------------------------#
+# target
+ODBC_TARGET=odbc
+
+# ----------------------------JDBC settings-----------------------------------#
+# target
+JDBC_TARGET=jdbc
+
+# ----------------------------dbtools settings-----------------------------------#
+# target
+DBTOOLS_TARGET=dbtools
+
+# -----------------------DRIVER MANAGER settings--------------------------------#
+# target
+SDBC_TARGET=sdbc
+
+# the major
+SDBC_MAJOR=2
+# the minor
+SDBC_MINOR=0
+# the micro
+SDBC_MICRO=0
+
+
+# -----------------------Connection Pool settings--------------------------------#
+# target
+DBPOOL_TARGET=dbpool
+
+# the major
+DBPOOL_MAJOR=2
+# the minor
+DBPOOL_MINOR=0
+# the micro
+DBPOOL_MICRO=0
+
+
+# ----------------------------DBASE settings-----------------------------------#
+# target
+DBASE_TARGET=dbase
+
+# ----------------------------MOZAB settings-----------------------------------#
+# the major
+MOZAB_MAJOR=2
+# the minor
+MOZAB_MINOR=0
+# the micro
+MOZAB_MICRO=0
+
+# ----------------------------MySQL settings-----------------------------------#
+# target
+MYSQL_TARGET=mysql
+
+
+# ----------------------------Evoab settings-----------------------------------#
+# target
+EVOAB_TARGET=evoab
+
+# ----------------------------Kab settings-------------------------------------#
+# target
+KAB_TARGET=kab
+
+# the major
+KAB_MAJOR=1
+# the minor
+KAB_MINOR=0
+# the micro
+KAB_MICRO=0
+
+
+# ----------------------------Macab settings-------------------------------------#
+# target
+MACAB_TARGET=macab
+
+# the major
+MACAB_MAJOR=1
+# the minor
+MACAB_MINOR=0
+# the micro
+MACAB_MICRO=0
+
+# ----------------------------HSQLDB settings-----------------------------------#
+# target
+HSQLDB_TARGET=hsqldb
+
diff --git a/connectivity/workben/TT/StartTest.class b/connectivity/workben/TT/StartTest.class
new file mode 100644
index 000000000000..28791c43eb9c
--- /dev/null
+++ b/connectivity/workben/TT/StartTest.class
Binary files differ
diff --git a/connectivity/workben/TT/StartTest.java b/connectivity/workben/TT/StartTest.java
new file mode 100644
index 000000000000..305f1fc4da9a
--- /dev/null
+++ b/connectivity/workben/TT/StartTest.java
@@ -0,0 +1,293 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package workben.tt;
+
+import java.lang.Object;
+import java.io.*;
+import workben.odbc.*;
+
+import com.sun.star.comp.servicemanager.ServiceManager;
+// import java.io.IOException;
+
+//import com.sun.star.beans.PropertyValue;
+//import com.sun.star.beans.PropertyState;
+import com.sun.star.connection.XConnector;
+import com.sun.star.connection.XConnection;
+import com.sun.star.bridge.XBridge;
+
+// import com.sun.star.comp.bootstrap.Bootstrap;
+
+// import com.sun.star.io.XInputStream;
+// import com.sun.star.io.XOutputStream;
+
+// import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+
+import com.sun.star.uno.IBridge;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.XNamingService;
+
+import com.sun.star.sdbc.*;
+// import com.sun.star.sdbc.XConnection;
+// import com.sun.star.uno.Enum;
+
+// import com.sun.star.lib.uno.typeinfo.ParameterTypeInfo;
+// import com.sun.star.lib.uno.typeinfo.TypeInfo;
+
+public class StartTest
+{
+ //###########################################################
+ //# allgemeine Variablen #
+ //###########################################################
+ private static java.util.Hashtable ConfigItems = new java.util.Hashtable();
+ //###########################################################
+ //# ResultSetToStringBuffer #
+ //###########################################################
+ static StringBuffer ResultSetToStringBuffer(com.sun.star.sdbc.XResultSet results)
+ {
+ com.sun.star.sdbc.XRow Row;
+ com.sun.star.sdbc.XResultSetMetaDataSupplier rsmds;
+ com.sun.star.sdbc.XResultSetMetaData rsmd;
+
+ StringBuffer buf = new StringBuffer();
+
+ try
+ {
+ rsmds = (com.sun.star.sdbc.XResultSetMetaDataSupplier)UnoRuntime.queryInterface(com.sun.star.sdbc.XResultSetMetaDataSupplier.class,results);
+ rsmd = rsmds.getMetaData();
+ int numCols = rsmd.getColumnCount();
+ int i;
+
+ // get column header info
+ for (i=1; i <= numCols; i++)
+ {
+ if (i == 1) buf.append("\"");
+ if (i > 1) buf.append("\"\t\"");
+ buf.append(rsmd.getColumnLabel(i));
+ }
+ buf.append("\"\r\n");
+
+
+
+ while (results.next())
+ {
+ Row = (com.sun.star.sdbc.XRow)UnoRuntime.queryInterface(com.sun.star.sdbc.XRow.class, results);
+ for (i=1; i <= numCols; i++)
+ {
+ if (i == 1) buf.append("\"");
+ if (i > 1) buf.append("\"\t\"");
+ buf.append(Row.getString(i));
+ }
+ buf.append("\"\r\n");
+ }
+ return(buf);
+ }
+ catch (Exception e)
+ {
+ System.out.println("Exception at ResultSetToStringBuffer : " + e);
+ return(buf);
+ }
+ }
+
+ //###########################################################
+ //# printStringBuffer #
+ //###########################################################
+
+ static void printStringBuffer(StringBuffer buf)
+ {
+ FileWriter f1;
+ try
+ {
+ f1 = new FileWriter("d:\\data\\sdbc\\test.log",true);
+ int maxStrings = buf.length() - 1;
+ //System.out.println(maxStrings);
+ for(int i=0 ; i<=maxStrings ; i++)
+ {
+ f1.write(buf.charAt(i));
+ }
+ f1.close();
+ }
+ catch( IOException e )
+ {
+ System.out.println("Error: can't create logfile");
+ }
+ }
+
+ //###########################################################
+ //# neededServices #
+ //###########################################################
+ static String neededServices[] = new String[] {
+ "com.sun.star.comp.servicemanager.ServiceManager",
+ "com.sun.star.comp.loader.JavaLoader",
+ "com.sun.star.comp.connections.Connector",
+ "com.sun.star.comp.connections.Acceptor"
+ };
+
+ //###########################################################
+ //# readConfigFile #
+ //###########################################################
+ static void readConfigFile(String sFileName)
+ {
+ BufferedReader confFile;
+ try
+ {
+ confFile = new BufferedReader(new FileReader(sFileName));
+ ConfigItems.put("ConnectString",confFile.readLine());
+ ConfigItems.put("user",confFile.readLine());
+ ConfigItems.put("password",confFile.readLine());
+ ConfigItems.put("ToTest",confFile.readLine());
+ ConfigItems.put("LogFile",confFile.readLine());
+ confFile.close();
+ }
+ catch(Exception e)
+ {
+ System.out.println(e);
+ }
+ }
+
+ //###########################################################
+ //# MAIN #
+ //###########################################################
+
+ public static void main(String argv[]) throws Exception
+ {
+
+ //Die Parameter auslesen
+
+// if(argv.length == 0)
+// {
+// System.out.println("missing parameter");
+// System.exit(0);
+// }
+
+ //readConfigFile(argv[0]);
+
+ ////////////////////////
+
+ com.sun.star.comp.servicemanager.ServiceManager smgr = new com.sun.star.comp.servicemanager.ServiceManager();
+ smgr.addFactories(neededServices);
+
+ XConnector xConnector = (XConnector)smgr.createInstance("com.sun.star.connection.Connector");
+ if(xConnector == null) System.err.println("no connector!");
+
+ XConnection xConn = xConnector.connect("socket,host=localhost,port=6001");
+ if(xConn == null) System.err.println("no XConnection!");
+
+ IBridge iBridge = UnoRuntime.getBridgeByName("java", null, "remote", null, new Object[]{"iiop", xConn, null});
+
+ Object rInitialObject = iBridge.mapInterfaceFrom("classic_uno", XInterface.class);
+
+ if(rInitialObject != null)
+ {
+ System.err.println("got the remote object");
+ System.out.println("before naming service !");
+ try
+ {
+ XNamingService rName = (XNamingService)UnoRuntime.queryInterface(XNamingService.class, rInitialObject );
+ try
+ {
+ if(rName != null)
+ {
+ System.err.println("got the remote naming service !");
+ Object rXsmgr = rName.getRegisteredObject("StarOffice.ServiceManager");
+ XMultiServiceFactory rSmgr = (XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, rXsmgr);
+ if(rSmgr != null)
+ {
+ System.out.println("got the remote service manager !");
+ Object rDriver = rSmgr.createInstance("com.sun.star.sdbc.ADriver");
+ if(rDriver != null)
+ {
+ System.out.println("got a com.sun.star.sdbc.Driver !");
+ com.sun.star.sdbc.XDriver xDriver = (XDriver)UnoRuntime.queryInterface(com.sun.star.sdbc.XDriver.class,rDriver);
+ if(xDriver != null)
+ {
+ com.sun.star.sdbc.XConnection xConnection = null;
+ try
+ {
+ com.sun.star.beans.PropertyValue [] ConInfo = new com.sun.star.beans.PropertyValue[]
+ {
+ new com.sun.star.beans.PropertyValue("user",0,"qsuser",com.sun.star.beans.PropertyState.DIRECT_VALUE),
+ new com.sun.star.beans.PropertyValue("password",0,"qsuser",com.sun.star.beans.PropertyState.DIRECT_VALUE)
+ };
+ xConnection = xDriver.connect("sdbc:ado:PROVIDER=SQLOLEDB;DATA SOURCE=sqllab2",ConInfo);
+
+ if(xConnection != null)
+ {
+ System.out.println("got a connection!");
+ com.sun.star.sdbc.XDatabaseMetaData dmd;
+ com.sun.star.sdbc.XStatement stmt;
+ com.sun.star.sdbc.XResultSet result;
+ com.sun.star.sdbc.XRow row;
+ try
+ {
+ stmt = xConnection.createStatement();
+ stmt.executeUpdate("insert into testtab values(4,'vier')");
+ result = stmt.executeQuery("select * from testtab where int = 4");
+ com.sun.star.sdbc.XResultSetMetaDataSupplier rsmds;
+
+ rsmds = (com.sun.star.sdbc.XResultSetMetaDataSupplier)UnoRuntime.queryInterface(com.sun.star.sdbc.XResultSetMetaDataSupplier.class,result);
+ com.sun.star.sdbc.XResultSetMetaData xMD = rsmds.getMetaData();
+ System.out.println("Anzahl Spalten = " + xMD.getColumnCount());
+ if(result.next())
+ {
+ row = (com.sun.star.sdbc.XRow)UnoRuntime.queryInterface(com.sun.star.sdbc.XRow.class,result);
+ String xx = row.getString(1);
+ }
+ }
+ catch (Exception e)
+ {
+ System.out.println("Exception beim Aufruf der Tests");
+ }
+ }
+ }
+ catch(Exception e)
+ {
+ System.out.println("exception while connecting!");
+ e.printStackTrace();
+ }
+ xConnection.close();
+ }
+ }
+ }
+ }
+ }
+ catch(Exception t)
+ {
+ }
+ }
+ catch(Exception e1)
+ {
+ System.err.println("exception from getRegisteredObject!");
+ }
+ }
+ System.out.println("FERTIG");
+ System.exit(0);
+ }
+ }// die Klammer der ganzen Klasse
+
diff --git a/connectivity/workben/iniParser/main.cxx b/connectivity/workben/iniParser/main.cxx
new file mode 100644
index 000000000000..9ec90e7888f9
--- /dev/null
+++ b/connectivity/workben/iniParser/main.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 <rtl/ustring.hxx>
+#include <stdio.h>
+#include <com/sun/star/io/IOException.hpp>
+#include <osl/process.h>
+using namespace rtl;
+
+#include <map>
+#include <list>
+
+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;};
+ ini_Section * getSection(OUString const & secName)
+ {
+ if (mAllSection.find(secName) != mAllSection.end())
+ return &mAllSection[secName];
+ return NULL;
+ }
+ IniParser(OUString const & rIniName) throw(com::sun::star::io::IOException )
+ {
+ OUString curDirPth;
+ OUString iniUrl;
+ osl_getProcessWorkingDir( &curDirPth.pData );
+ if (osl_getAbsoluteFileURL( curDirPth.pData, rIniName.pData, &iniUrl.pData ))
+ throw ::com::sun::star::io::IOException();
+
+
+#if OSL_DEBUG_LEVEL > 1
+ OString sFile = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US);
+ OSL_TRACE(__FILE__" -- parser() - %s\n", sFile.getStr());
+#endif
+ oslFileHandle handle=NULL;
+ if (iniUrl.getLength() &&
+ osl_File_E_None == osl_openFile(iniUrl.pData, &handle, osl_File_OpenFlag_Read))
+ {
+ 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 > 1
+ else
+ {
+ OString file_tmp = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US);
+ OSL_TRACE( __FILE__" -- couldn't open file: %s", file_tmp.getStr() );
+ throw ::com::sun::star::io::IOException();
+ }
+#endif
+ }
+#if OSL_DEBUG_LEVEL > 1
+ void 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
+
+};
+
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int _cdecl main( int argc, char * argv[] )
+#endif
+
+{
+
+ IniParser parser(OUString::createFromAscii("test.ini"));
+ parser.Dump();
+ return 0;
+}
diff --git a/connectivity/workben/iniParser/makefile.mk b/connectivity/workben/iniParser/makefile.mk
new file mode 100644
index 000000000000..c1caaecf67de
--- /dev/null
+++ b/connectivity/workben/iniParser/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=connectivity
+TARGET=iniparser
+TARGETTYPE=CUI
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+OBJFILES= $(OBJ)$/main.obj
+
+
+APPSTDLIBS=$(SALLIB) \
+ $(VOSLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(UCBHELPERLIB) \
+ $(DBTOOLSLIB) \
+ $(COMPHELPERLIB)
+
+
+# ... cfgapi ..............................
+
+APP1TARGET= $(TARGET)
+APP1OBJS= $(OBJFILES)
+APP1STDLIBS = $(APPSTDLIBS)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/connectivity/workben/little/main.cxx b/connectivity/workben/little/main.cxx
new file mode 100644
index 000000000000..3d89fb2c28ea
--- /dev/null
+++ b/connectivity/workben/little/main.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <connectivity/sqlparse.hxx>
+#include "connectivity/sqliterator.hxx"
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/PropertyState.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <unotools/processfactory.hxx>
+#include <cppuhelper/servicefactory.hxx>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include "connectivity/sqlnode.hxx"
+
+using namespace connectivity;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::beans;
+using namespace rtl;
+using namespace cppu;
+
+
+#if (defined UNX) || (defined OS2)
+void main( int argc, char * argv[] )
+#else
+void _cdecl main( int argc, char * argv[] )
+#endif
+
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver> m_xDriver;
+
+ try{
+ Reference< ::com::sun::star::lang::XMultiServiceFactory > xFac =
+ createRegistryServiceFactory(OUString::createFromAscii("g:\\office50\\program\\applicat.rdb"),OUString());
+ if(!xFac.is())
+ return;
+
+ m_xDriver = Reference<XDriver>(xFac->createInstance(OUString::createFromAscii("com.sun.star.sdbc.driver.dbase.Driver")),UNO_QUERY);
+ if(m_xDriver.is())
+ {
+
+ Sequence<PropertyValue> aValue;
+ // aValue.getArray()[0] = PropertyValue( OUString::createFromAscii("user"),0,makeAny(OUString::createFromAscii("TEST1")),PropertyState_DIRECT_VALUE);
+ // aValue.getArray()[1] = PropertyValue( OUString::createFromAscii("password"),0,makeAny(OUString::createFromAscii("TEST1")),PropertyState_DIRECT_VALUE);
+ //
+ m_xConnection = m_xDriver->connect(OUString::createFromAscii("sdbc:dbase:g:\\"),aValue);
+ if(m_xConnection.is())
+ {
+ Reference<XStatement> xStmt = m_xConnection->createStatement();
+ if(xStmt.is())
+ {
+ Reference<XResultSet> xRes = xStmt->executeQuery(OUString::createFromAscii("SELECT * FROM Tele"));
+ if(xRes.is())
+ {
+ ::rtl::OUString aPat = ::rtl::OUString::createFromAscii("%s\t");
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ Reference<XResultSetMetaData> xMeta = Reference<XResultSetMetaDataSupplier>(xRes,UNO_QUERY)->getMetaData();
+ for(sal_Int32 i=1;i<xMeta->getColumnCount();++i)
+ {
+ wprintf(aPat.getStr(), xMeta->getColumnName(i).getStr());
+ }
+ printf("----------------------------------------------------------------------\n");
+ while(xRes->next())
+ {
+ for(sal_Int32 j=1;j<xMeta->getColumnCount();++j)
+ wprintf(aPat.getStr(), xRow->getString(j).getStr());
+ printf("\n");
+ }
+ }
+ }
+ }
+
+ }
+ }
+ catch(...)
+ {
+ printf("Exception thrown!\n");
+
+ }
+ sal_Int32 d;
+ scanf("%d",&d);
+}
+
diff --git a/connectivity/workben/little/makefile.mk b/connectivity/workben/little/makefile.mk
new file mode 100644
index 000000000000..5d3d6516f311
--- /dev/null
+++ b/connectivity/workben/little/makefile.mk
@@ -0,0 +1,60 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General 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=..\..
+
+PRJNAME=connectivity
+TARGET=little
+TARGETTYPE=CUI
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+OBJFILES= $(OBJ)$/main.obj
+
+APP1TARGET= $(TARGET)
+APP1OBJS= $(OBJFILES)
+APPSTDLIBS=$(SALLIB) \
+ $(VOSLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SLB)$/sql.lib
+
+
+# ... cfgapi ..............................
+APP1STDLIBS = $(APPSTDLIBS)
+
+APP1STDLIBS+=$(STDLIBCPP)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/connectivity/workben/skeleton/SResultSet.hxx b/connectivity/workben/skeleton/SResultSet.hxx
new file mode 100644
index 000000000000..2eaa5c8b2e97
--- /dev/null
+++ b/connectivity/workben/skeleton/SResultSet.hxx
@@ -0,0 +1,246 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General 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/sdbc/XRowUpdate.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#include <cppuhelper/compbase12.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include "SStatement.hxx"
+#include "connectivity/CommonTools.hxx"
+#include "connectivity/FValue.hxx"
+
+namespace connectivity
+{
+ namespace skeleton
+ {
+
+ /*
+ ** 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::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> 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:
+ TVoidVector m_aBindVector;
+ ::std::vector<sal_Int32> m_aLengthVector;
+ ::std::vector<sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 everytime
+ ::std::vector< ORowSetValue> m_aRow; // only used when SQLGetData can't be called in any order
+ OStatement_Base* m_pStatement;
+ ::com::sun::star::uno::WeakReferenceHelper m_aStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData;
+ rtl_TextEncoding m_nTextEncoding;
+ sal_Int32 m_nRowPos;
+ sal_Int32 m_nLastColumnPos; // used for m_aRow just to know where we are
+ sal_Bool m_bWasNull;
+ sal_Bool m_bBOF; // before first record
+ sal_Bool m_bEOF; // after last record
+ sal_Bool m_bLastRecord;
+ sal_Bool m_bFreeHandle;
+ sal_Bool m_bInserting;
+ sal_Bool m_bFetchData; // true when SQLGetaData can be called in any order or when fetching data for m_aRow
+
+ sal_Bool isBookmarkable() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ ::rtl::OUString getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ void setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+
+ void fillRow(sal_Int32 _nToColumn);
+ void allocBuffer(sal_Bool _bAllocRow);
+ void releaseBuffer();
+
+
+
+ // 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( OStatement_Base* pStmt);
+
+
+ ::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(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL release() 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);
+ // 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);
+ // 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& 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);
+ };
+ }
+}
+#endif // CONNECTIVITY_SRESULTSET_HXX
diff --git a/connectivity/workben/skeleton/how_to_write_a_driver.txt b/connectivity/workben/skeleton/how_to_write_a_driver.txt
new file mode 100644
index 000000000000..596a9349026e
--- /dev/null
+++ b/connectivity/workben/skeleton/how_to_write_a_driver.txt
@@ -0,0 +1,51 @@
+How to write my own sdbc driver
+
+all example files can be found in connectivity/workben/skeleton
+
+Pre implementation steps
+- copy all files from connectivity/workben/skeleton into your new created directory under
+ connectivity/source/drivers and rename the first char of the files to one which isn't used so far
+ ( please have a look at the other drivers )
+- search all occurances of skeleton and replace them to a name which you prefer
+
+1. Implement a class called driver or modify the existing skeleton -> have a look at SDriver.?xx
+2. Implement a class called connection -> have a look at SConnection.?xx
+3. Have a look at the DatabaseMetaData -> see SDatabaseMetaData.cxx
+ The methods which should be implemented at least are
+ - getTableTypes
+ - getTables
+ - getTypeInfo
+ - getColumns
+
+4. You need a statement to show/access some data -> have a look at SStatement.cxx
+ -> especially executeQuery()
+
+5. The ResultSet: without you see nothing -> look at SResultSet.cxx
+6. The ResultSetMetaData needed to get some information about what are waiting for us
+ -> look at SResultSetMetaData.cxx
+
+7. The prepared statement is the last class we have to implement now
+ -> you have to allow statements like "SELECT * FROM table WHERE id = ?"
+
+
+8. insert entry in version.mk
+# ----------------------------SKELETON settings-----------------------------------#
+# target
+SKELETON_TARGET=skeleton
+
+# the major
+SKELETON_MAJOR=2
+# the minor
+SKELETON_MINOR=0
+# the micro
+SKELETON_MICRO=0
+
+# this is a c++ compatible library
+SKELETON_CPP=1
+
+SKELETON=$(SKELETON_TARGET_TARGET)_$(CMPEXT)
+
+
+9. copy dll to program dir of office and register the dll
+
+10. congratulations you have now implement your own driver :-)
diff --git a/connectivity/workben/testmoz/initUNO.cxx b/connectivity/workben/testmoz/initUNO.cxx
new file mode 100644
index 000000000000..67d1c07cc19d
--- /dev/null
+++ b/connectivity/workben/testmoz/initUNO.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "rtl/bootstrap.hxx"
+#include "cppuhelper/bootstrap.hxx"
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+using namespace cppu;
+using namespace com::sun::star::lang;
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+Reference< XMultiServiceFactory > InitializeFac( void )
+{
+ Reference<XComponentContext> xComponentContext = ::cppu::defaultBootstrap_InitialComponentContext();
+ Reference<XMultiServiceFactory> xMS(xComponentContext->getServiceManager(), UNO_QUERY);
+ return xMS;
+}
diff --git a/connectivity/workben/testmoz/main.cxx b/connectivity/workben/testmoz/main.cxx
new file mode 100644
index 000000000000..af6ec282353b
--- /dev/null
+++ b/connectivity/workben/testmoz/main.cxx
@@ -0,0 +1,724 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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 "connectivity/sqliterator.hxx"
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/PropertyState.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <unotools/processfactory.hxx>
+#include <cppuhelper/servicefactory.hxx>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#include <com/sun/star/sdb/XDatabaseEnvironment.hpp>
+#include <com/sun/star/uno/Any.hxx>
+
+#include "connectivity/sqlnode.hxx"
+#include <ucbhelper/contentbroker.hxx>
+#include <comphelper/regpathhelper.hxx>
+#include <rtl/ustring.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <osl/process.h>
+
+#include <cppuhelper/bootstrap.hxx>
+#include <cppuhelper/servicefactory.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+#include <com/sun/star/ucb/XContentProviderManager.hpp>
+
+#include <ucbhelper/content.hxx>
+#include <osl/module.h>
+#include <tools/config.hxx>
+
+#include <stdio.h>
+
+using namespace comphelper;
+using namespace cppu;
+using namespace rtl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::beans;
+
+//using namespace com::sun::star;
+using namespace connectivity;
+using namespace com::sun::star::sdb;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace com::sun::star::registry;
+
+#define OUtoCStr( x ) (OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US ).getStr())
+Reference< XContentProviderManager > globalUcb;
+#define PRINTSTR(x) printf("%s",x);
+
+int autoTest(Reference<XResultSet> &xRes);
+
+void printColumns( Reference<XResultSet> &xRes )
+{
+ if(xRes.is()) {
+ char* aPat = " %-22s ";
+ char* aPat_Short = " %-12s ";
+ Reference<XResultSetMetaData> xMeta = Reference<XResultSetMetaDataSupplier>(xRes,UNO_QUERY)->getMetaData();
+ printf( "ColumnCount = %d\n", xMeta->getColumnCount());
+ for(sal_Int32 i=1;i<=xMeta->getColumnCount();++i)
+ {
+ // printf(aPat.getStr(), xMeta->getColumnName(i).getStr());
+ const char *str = OUtoCStr(xMeta->getColumnName(i));
+// if ( i < 3 ) {
+// printf( aPat_Short, str );
+// } else {
+ printf( aPat, str );
+// }
+ }
+ printf("\n");
+ printf("------------------------------------------------------------------------------------------\n");
+ } else {
+ printf(": FAILED to get a ResultSet \n");
+ }
+}
+void printXResultSet( Reference<XResultSet> &xRes )
+{
+ if(xRes.is()) {
+ char* aPat = " %-22s ";
+ char* aPat_Short = " %-12s ";
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ Reference<XResultSetMetaData> xMeta = Reference<XResultSetMetaDataSupplier>(xRes,UNO_QUERY)->getMetaData();
+ for(sal_Int32 j=1;j<=xMeta->getColumnCount();++j)
+ {
+ try {
+ const char *str = OUtoCStr(xRow->getString(j));
+// if ( j < 3 ) {
+// printf( aPat_Short, str );
+// } else {
+ printf( aPat_Short, str );
+// }
+ } catch (...) {
+ printf(" Ex ");
+ }
+ }
+ printf("\n");
+ } else {
+ printf(": FAILED to get a ResultSet \n");
+ }
+}
+
+void printXResultSets( Reference<XResultSet> &xRes )
+{
+ if(xRes.is()) {
+ printColumns(xRes);
+ sal_Int32 nRows = 0;
+ while( xRes.is() && xRes->next())
+ {
+ printXResultSet(xRes);
+ nRows++;
+ }
+ printf( "%d Row(s)\n", nRows);
+ } else {
+ printf(": FAILED to get a ResultSet \n");
+ }
+}
+
+//#define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
+static const char * const components[] =
+{
+ SAL_MODULENAME( "ucb1" ) // KSO, ABI
+ , SAL_MODULENAME( "ucpfile1" )
+ , SAL_MODULENAME( "cfgmgr2" )
+ , "sax.uno" SAL_DLLEXTENSION
+ , "stocservices.uno" SAL_DLLEXTENSION
+ , SAL_MODULENAME( "fileacc" )
+ , SAL_MODULENAME( "mcnttype" ) //Clipboard Ask Oliver Braun
+ , "i18npool.uno" SAL_DLLEXTENSION
+ // Reading of files in specific encodings like UTF-8 using
+ // createUnoService( "com.sun.star.io.TextInputStream" ) and such
+ , "textinstream.uno" SAL_DLLEXTENSION
+ , "textoutstream.uno" SAL_DLLEXTENSION
+ , "introspection.uno" SAL_DLLEXTENSION
+ , "corereflection.uno" SAL_DLLEXTENSION
+ // RemoteUno
+ , "connector.uno" SAL_DLLEXTENSION
+ , "bridgefac.uno" SAL_DLLEXTENSION
+ , "remotebridge.uno" SAL_DLLEXTENSION
+ , "dbtools2" SAL_DLLEXTENSION
+ , "mozab2" SAL_DLLEXTENSION
+ , "mozabdrv2" SAL_DLLEXTENSION
+ , "sdbc2" SAL_DLLEXTENSION
+ , "dbpool2" SAL_DLLEXTENSION
+#ifdef SAL_UNX
+ , SVLIBRARY( "dtransX11" ) // OBR
+#endif
+#ifdef SAL_W32
+ , SAL_MODULENAME( "sysdtrans" )
+ , SAL_MODULENAME( "ftransl" )
+ , SAL_MODULENAME( "dnd" )
+#endif
+ , 0
+};
+
+Reference< XMultiServiceFactory > InitializeFac( void )
+{
+ OUString path;
+ if( osl_Process_E_None != osl_getExecutableFile( (rtl_uString**)&path ) )
+ {
+ printf("Exit.\n");
+ exit( 1 );
+ }
+ OSL_ASSERT( path.lastIndexOf( '/' ) >= 0 );
+
+
+ ::rtl::OUStringBuffer bufServices( path.copy( 0, path.lastIndexOf( '/' )+1 ) );
+ bufServices.appendAscii("services.rdb");
+ OUString services = bufServices.makeStringAndClear();
+
+ ::rtl::OUStringBuffer bufTypes( path.copy( 0, path.lastIndexOf( '/' )+1 ) );
+ bufTypes.appendAscii("types.rdb");
+ OUString types = bufTypes.makeStringAndClear();
+
+ printf("Create Registry.\n");
+
+ Reference< XMultiServiceFactory > xSMgr;
+ try
+ {
+ xSMgr = createRegistryServiceFactory( types, services, sal_True );
+ }
+ catch( com::sun::star::uno::Exception & )
+ {
+ try
+ {
+ {
+ Reference< XMultiServiceFactory > interimSmgr =
+ createRegistryServiceFactory( types, sal_True );
+ Reference< XImplementationRegistration > xIR(
+ interimSmgr->createInstance(
+ OUString::createFromAscii(
+ "com.sun.star.registry.ImplementationRegistration" ) ), UNO_QUERY );
+
+ Reference< XSimpleRegistry > xReg(
+ interimSmgr->createInstance(
+ OUString::createFromAscii(
+ "com.sun.star.registry.SimpleRegistry" ) ), UNO_QUERY );
+ if ( xReg.is() )
+ {
+ xReg->open(services, sal_False, sal_True);
+ if ( xReg->isValid() )
+ {
+ OUString loader( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.loader.SharedLibrary" ));
+ for( sal_Int32 i = 0; components[i] ; i ++ )
+ {
+ printf("Registering %s ... ", components[i]);
+ xIR->registerImplementation(
+ loader, OUString::createFromAscii(components[i]),xReg);
+ printf("done\n");
+ }
+ xReg->close();
+ } else
+ {
+ printf("Cannot open Registry. Terminating Program\n");
+ exit (1);
+ }
+ }
+
+ Reference< XComponent > xComp( interimSmgr, UNO_QUERY );
+ if( xComp.is() )
+ xComp->dispose();
+ }
+
+ // now try it again readonly
+ printf("Opening Registry readonly\n");
+ xSMgr = createRegistryServiceFactory( types, services, sal_True );
+ }
+ catch( com::sun::star::uno::Exception & exc )
+ {
+ fprintf( stderr, "Couldn't bootstrap uno servicemanager for reason : %s\n" ,
+ OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ }
+ }
+
+ printf("set global factory.\n");
+
+ //////////////////////////////////////////////////////////////////////
+ // set global factory
+ setProcessServiceFactory( xSMgr );
+
+/* // Create simple ConfigManager
+ Sequence< Any > aConfArgs(3);
+ aConfArgs[0] <<= PropertyValue( OUString::createFromAscii("servertype"), 0, makeAny( OUString::createFromAscii("local") ), ::com::sun::star::beans::PropertyState_DIRECT_VALUE );
+ aConfArgs[1] <<= PropertyValue( OUString::createFromAscii("sourcepath"), 0, makeAny( OUString::createFromAscii("g:\\") ), ::com::sun::star::beans::PropertyState_DIRECT_VALUE );
+ aConfArgs[2] <<= PropertyValue( OUString::createFromAscii("updatepath"), 0, makeAny( OUString::createFromAscii("g:\\") ), ::com::sun::star::beans::PropertyState_DIRECT_VALUE );
+
+ Reference< XContentProvider > xConfProvider
+ ( xSMgr->createInstanceWithArguments( OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" ), aConfArgs), UNO_QUERY );
+*/
+
+
+// Create unconfigured Ucb:
+/* Sequence< Any > aArgs(1);
+ aArgs[1] = makeAny ( xConfProvider );*/
+ Sequence< Any > aArgs;
+ ::ucb::ContentBroker::initialize( xSMgr, aArgs );
+ Reference< XContentProviderManager > xUcb =
+ ucb::ContentBroker::get()->getContentProviderManagerInterface();
+
+ Reference< XContentProvider > xFileProvider
+ ( xSMgr->createInstance( OUString::createFromAscii( "com.sun.star.ucb.FileContentProvider" ) ), UNO_QUERY );
+ xUcb->registerContentProvider( xFileProvider, OUString::createFromAscii( "file" ), sal_True );
+
+
+/* Reference< XContentProvider > xPackageProvider
+ ( xSMgr->createInstance( OUString::createFromAscii( "com.sun.star.ucb.PackageContentProvider" ) ), UNO_QUERY );
+ xUcb->registerContentProvider( xPackageProvider, OUString::createFromAscii( "vnd.sun.star.pkg" ), sal_True );
+ */
+ globalUcb = xUcb;
+ return xSMgr;
+}
+
+int TestMetaData(Reference< ::com::sun::star::sdbc::XConnection> &pConnection)
+{
+ // Test some metadata
+ Reference< XDatabaseMetaData > xDmd = pConnection->getMetaData();
+ if ( xDmd.is() ) {
+ printf(": got DatabaseMetaData \n");
+
+ OUString sQuoteStr = xDmd->getIdentifierQuoteString();
+ printf( "Quote String : '%s'\n", OUtoCStr( sQuoteStr ) );
+
+ OUString sSQLCmds = xDmd->getSQLKeywords();
+ printf( "SQL Commands : '%s'\n", OUtoCStr( sSQLCmds ) );
+
+ printf("Testing getColumns() : START\n");
+ {
+ Reference<XResultSet> xRes = xDmd->getColumns(
+ makeAny(OUString::createFromAscii("")), // Catalog
+ OUString::createFromAscii("%"), // Schema
+ OUString::createFromAscii("%"), // TabName
+ OUString::createFromAscii("%")
+ );
+ printXResultSets( xRes );
+ }
+ printf("Testing getColumns() : END\n");
+
+ printf("Testing getTypeInfo() : START\n");
+ {
+ Reference<XResultSet> xRes = xDmd-> getTypeInfo();
+ printXResultSets( xRes );
+ }
+ printf("Testing getTypeInfo() : END\n");
+
+ printf("Testing getTables() : START\n");
+ {
+ Reference<XResultSet> xRes = xDmd->getTables(
+ makeAny(OUString::createFromAscii("")), // Catalog
+ OUString::createFromAscii("%"), // Schema
+ OUString::createFromAscii("%"), // TabName
+ Sequence<rtl::OUString>()
+ );
+ printXResultSets( xRes );
+ }
+ printf("Testing getTables() : END\n");
+
+ } else {
+ printf(": FAILED to get DatabaseMetaData \n");
+ }
+
+ return 0;
+}
+int TestBookMark(Reference<XResultSet> &xRes);
+int TestRowUpdate(Reference<XResultSet> &xRes);
+
+Reference<XResultSet> TestQuery(Reference< ::com::sun::star::sdbc::XConnection> &pConnection,sal_Int32 choice)
+{
+ // Try a query
+ printf("Testing createStatement() & executeQuery() : START\n");
+ Reference<XStatement> xStmt = pConnection->createStatement();
+ Reference<XResultSet> xRes;
+ if(xStmt.is())
+ {
+ printf(": got statement\n");
+ printf(": excuteQuery() : START \n");
+// SELECT "First Name", "Display Name", "E-mail" FROM "addr" "addr"
+ char sql[256]="SELECT \"First Name\", \"Display Name\", \"E-mail\" FROM \"addr\"";
+ if (choice!=-1)
+ {
+ printf("Please input a query,end by \";\" and less then 256 char plz:\n");
+ char ch=0;
+ int index=0;
+ while (ch != ';')
+ {
+ scanf("%c",&ch);
+ sql[index++] = ch;
+ }
+ sql[index]= 0;
+ printf("SQL:%s\n",sql);
+ }
+ try
+ {
+ sal_Int32 times=0;
+ for (times = 0;times< 100;times ++)
+ {
+ Reference<XResultSet> tmpRes =
+ //xStmt->executeQuery(OUString::createFromAscii("SELECT * FROM \"addr\""));
+ xStmt->executeQuery(OUString::createFromAscii(sql));
+ // xStmt->executeQuery(OUString::createFromAscii("SELECT * FROM \"Personal Address Book\" WHERE ( PrimaryEmail IS NULL )"));
+ // xStmt->executeQuery(OUString::createFromAscii("SELECT * FROM \"Personal Address Book\" WHERE ( PrimaryEmail LIKE \"Darren\" )"));
+ // xStmt->executeQuery(OUString::createFromAscii("SELECT * FROM \"Personal Address Book\""));
+ // xStmt->executeQuery(OUString::createFromAscii("SELECT * FROM \"myldap\" WHERE ( PrimaryEmail LIKE \"%Darren%\" OR DisplayName LIKE \"%Darren%\" )"));
+
+ autoTest( tmpRes );
+ Reference<XCloseable> clsRes(tmpRes,UNO_QUERY);
+ clsRes->close();
+ printf("Current Times:%d\n",times);
+ }
+ TestBookMark(xRes);
+ TestRowUpdate(xRes);
+ } catch ( Exception &e ) {
+ printf( "Exception caught : %s\n", OUtoCStr( e.Message) );
+ } catch (...) {
+ printf( "Non-UNO Exception caught\n" );
+ }
+ printf(": excuteQuery() : END \n");
+ }
+ else
+ {
+ printf(": FAILED to get statement\n");
+ }
+ printf("Testing createStatement() & executeQuery() : END\n");
+ return xRes;
+}
+Reference< ::com::sun::star::sdbc::XConnection> TestConnected
+ (Reference< ::com::sun::star::sdbc::XDriver> &pDriver,sal_Int32 choice)
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> pConnection;
+ printf("Begin Connect!\n");
+ OUString url;
+ Sequence<PropertyValue> aValue;
+
+ switch (choice)
+ {
+ case -1:
+ case 1: //mozilla
+ url=OUString::createFromAscii("sdbc:address:mozilla://");
+ break;
+ case 2:
+ url=OUString::createFromAscii("sdbc:address:ldap://");
+ char hostname[40],basedn[40];
+ scanf("%s %s",hostname,basedn);
+ aValue.realloc(2);
+ aValue[0].Name = ::rtl::OUString::createFromAscii("HostName");
+ aValue[0].Value <<= rtl::OUString::createFromAscii(hostname);
+ aValue[1].Name = ::rtl::OUString::createFromAscii("BaseDN");
+ aValue[1].Value <<= rtl::OUString::createFromAscii(basedn);
+ break;
+ case 3:
+ case 4:
+ break;
+ case 5:
+ //Default LDAP AB
+ url=OUString::createFromAscii("sdbc:address:ldap://");
+ aValue.realloc(2);
+ aValue[0].Name = ::rtl::OUString::createFromAscii("HostName");
+ aValue[0].Value <<= rtl::OUString::createFromAscii("sun-ds");
+ aValue[1].Name = ::rtl::OUString::createFromAscii("BaseDN");
+ aValue[1].Value <<= rtl::OUString::createFromAscii("dc=sun,dc=com");
+ break;
+ default:
+ return pConnection;
+ break;
+ }
+ pConnection =
+ pDriver->connect(url,aValue);
+ return pConnection;
+ }
+
+void menuBookmark()
+{
+ PRINTSTR("0 Exit\n")
+ PRINTSTR("1 Show Max rowcount\n")
+ PRINTSTR("2 Move First\n")
+ PRINTSTR("3 Record bookmark 1\n")
+ PRINTSTR("4 Record bookmark 2\n")
+ PRINTSTR("5 Move to bookmark. Usage: 5 bookid\n")
+ PRINTSTR("6 moveRelativeToBookmark, follow bookid rows plz\n")
+ PRINTSTR("7 compareBookmark\n")
+ PRINTSTR("8 print boomark hash. Usage: 8 bookid\n")
+ PRINTSTR("9 print current row\n")
+ PRINTSTR("10 Auto test\n")
+
+ PRINTSTR("Please Input you choice:")
+}
+int autoTest(Reference<XResultSet> &xRes)
+{
+ sal_Int32 nRows = 0;
+ printColumns(xRes);
+ if(xRes.is()) {
+ while( xRes.is() && xRes->next())
+ {
+ nRows++;
+ }
+ printf( "%d Row(s)\n", nRows);
+ sal_Int32 times;
+ sal_Int32 pos;
+ for(times = 1;times < 100; times ++)
+ {
+ pos= rand() % nRows+1;
+ printf("pos:%d\n",pos);
+ xRes->absolute(pos);
+ printXResultSet(xRes);
+ }
+ } else {
+ printf(": FAILED to get a ResultSet \n");
+ }
+ return 0;
+}
+int TestBookMark(Reference<XResultSet> &xRes)
+{
+ Reference<XResultSet> mRes(xRes);
+ if (!mRes.is() || !mRes->first())
+ {
+ return sal_False;
+ }
+
+ Reference<XRow> mRow(xRes,UNO_QUERY);
+ Reference<XResultSetMetaData> xMeta = Reference<XResultSetMetaDataSupplier>(mRes,UNO_QUERY)->getMetaData();
+ printXResultSet(mRes);
+ Reference< ::com::sun::star::sdbcx::XRowLocate> xRowLocate(xRes, UNO_QUERY);
+ ::com::sun::star::uno::Any xBookMark[2];
+ int index;
+ if (xRowLocate.is())
+ {
+ int choice=-1;
+ while (choice)
+ {
+ menuBookmark();
+
+ scanf("%d",&choice);
+ printf("Your choice is:%d\n",choice);
+ switch (choice)
+ {
+ case 1:
+ printf("Rowcount:Current don't know\n");
+ break;
+ case 2:
+ if (!mRes->isFirst()) mRes->first();
+ break;
+ case 3:
+ xBookMark[0] = xRowLocate->getBookmark();
+ break;
+ case 4:
+ xBookMark[1] = xRowLocate->getBookmark();
+ break;
+ case 5:
+ scanf("%d",&index);
+ if (index == 1 || index == 2)
+ xRowLocate->moveToBookmark(xBookMark[index-1]);
+ break;
+ case 6:
+ int rows;
+ scanf("%d %d",&index,&rows);
+ if (index == 1 || index == 2)
+ xRowLocate->moveRelativeToBookmark(xBookMark[index-1],rows);
+ break;
+ case 7:
+ printf("compareBookmarks:%d\n",xRowLocate->compareBookmarks(xBookMark[0],xBookMark[1]));
+ break;
+ case 8:
+ scanf("%d",&index);
+ printf("HashBookmark[%d]:%d\n",index,xRowLocate->hashBookmark(xBookMark[index-1]));
+ break;
+ case 9:
+ printXResultSet(mRes);
+ break;
+ case 10:
+ autoTest(mRes);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ return 0;
+}
+void menuRowUpdate()
+{
+ PRINTSTR("0 Exit\n")
+ PRINTSTR("1 Print Columns\n")
+ PRINTSTR("2 Move to row. Usage:2 rowid\n")
+ PRINTSTR("3 Print Row values\n")
+ PRINTSTR("4 Change Column Value: 4 columnid newvalue\n")
+ PRINTSTR("5 Commit changes\n")
+ PRINTSTR("6 Delete Current Row\n")
+ PRINTSTR("Please Input Your choice:")
+}
+int TestRowUpdate(Reference<XResultSet> &xRes)
+{
+ if (!xRes.is() || !xRes->first())
+ {
+ return sal_False;
+ }
+ printf("Test XRowUpdate START\n");
+ Reference< ::com::sun::star::sdbc::XRowUpdate> xRowUpdate(xRes, UNO_QUERY);
+ Reference< ::com::sun::star::sdbc::XResultSetUpdate> xResultSetUpdate(xRes, UNO_QUERY);
+ int index;
+ if (xRowUpdate.is())
+ {
+ int choice=-1;
+ char newString[256];
+ while (choice)
+ {
+ menuRowUpdate();
+
+ scanf("%d",&choice);
+ printf("Your choice is:%d\n",choice);
+ switch (choice)
+ {
+ case 1:
+ printColumns(xRes);
+ break;
+ case 2:
+ scanf("%d",&index);
+ xRes->absolute(index);
+ break;
+ case 3:
+ printXResultSet(xRes);
+ break;
+ case 4:
+ scanf("%d %s",&index,newString);
+ xRowUpdate->updateString(index,OUString::createFromAscii(newString));
+ printXResultSet(xRes);
+ break;
+ case 5:
+ if (xResultSetUpdate.is())
+ {
+ xResultSetUpdate->updateRow();
+ printXResultSet(xRes);
+ }
+ else
+ printf("Can't update!\n");
+ break;
+ case 6:
+ if (xResultSetUpdate.is())
+ {
+ xResultSetUpdate->deleteRow();
+ printXResultSet(xRes);
+ }
+ else
+ printf("Can't update!\n");
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ printf("Test XRowUpdate END\n");
+ return 0;
+}
+
+void menuMain()
+{
+ PRINTSTR("0 Exit\n")
+ PRINTSTR("1 Open Mozilla Address Book\n")
+ PRINTSTR("2 Open LDAP. Pleae follow hostname and base dn.\n")
+ PRINTSTR("3 Open Outlook Address Book\n")
+ PRINTSTR("4 Open OE Address Book\n")
+ PRINTSTR("Please Input your choice:")
+}
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int _cdecl main( int argc, char * argv[] )
+#endif
+
+{
+ Reference< XMultiServiceFactory > xMgr = InitializeFac();
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection;
+ try
+ {
+ Reference< ::com::sun::star::sdbc::XDriver>
+ m_xDriver(xMgr->createInstance(
+ OUString::createFromAscii("com.sun.star.comp.sdbc.MozabDriver")),
+ UNO_QUERY);
+ if(m_xDriver.is())
+ {
+ int choice=-1;
+ if (argc > 1 )
+ {
+ menuMain();
+ scanf("%d",&choice);
+ }
+
+ while (choice)
+ {
+
+ m_xConnection = TestConnected(m_xDriver,choice);
+ if(m_xConnection.is())
+ {
+ if (!TestMetaData(m_xConnection))
+ {
+ Reference<XResultSet> xRes=TestQuery(m_xConnection,choice);
+ if (xRes.is())
+ {
+ }
+ }
+ }else printf("Can't connected!\n");
+
+ if (argc > 1)
+ {
+ menuMain();
+ scanf("%d",&choice);
+ }
+ else
+ choice = 0;
+
+ }
+ } else {
+ printf("No driver!\n");
+ }
+ }
+ catch(...)
+ {
+ printf("Exception thrown!\n");
+ }
+ printf("Exiting...\n");
+ return 0;
+}
+
diff --git a/connectivity/workben/testmoz/makefile.mk b/connectivity/workben/testmoz/makefile.mk
new file mode 100644
index 000000000000..387d2e4a2014
--- /dev/null
+++ b/connectivity/workben/testmoz/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=connectivity
+TARGET=testmoz
+TARGETTYPE=CUI
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+OBJFILES= $(OBJ)$/main.obj
+
+
+APPSTDLIBS=$(SALLIB) \
+ $(VOSLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(UCBHELPERLIB) \
+ $(DBTOOLSLIB) \
+ $(COMPHELPERLIB)
+
+
+# ... cfgapi ..............................
+
+APP1TARGET= $(TARGET)
+APP1OBJS= $(OBJFILES)
+APP1STDLIBS = $(APPSTDLIBS)
+
+
+
+APP2TARGET = mozThread
+APP2OBJS = $(OBJ)$/initUNO.obj \
+ $(OBJ)$/mozthread.obj
+
+APP2STDLIBS = $(APPSTDLIBS)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/connectivity/workben/testmoz/mozthread.cxx b/connectivity/workben/testmoz/mozthread.cxx
new file mode 100644
index 000000000000..c61e5d8a0e06
--- /dev/null
+++ b/connectivity/workben/testmoz/mozthread.cxx
@@ -0,0 +1,477 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/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 "connectivity/sqliterator.hxx"
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/PropertyState.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <unotools/processfactory.hxx>
+#include <cppuhelper/servicefactory.hxx>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#include <com/sun/star/sdb/XDatabaseEnvironment.hpp>
+#include <com/sun/star/uno/Any.hxx>
+
+#include "connectivity/sqlnode.hxx"
+#include <ucbhelper/contentbroker.hxx>
+#include <comphelper/regpathhelper.hxx>
+#include <rtl/ustring.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <osl/process.h>
+
+#include <cppuhelper/bootstrap.hxx>
+#include <cppuhelper/servicefactory.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/registry/XImplementationRegistration.hpp>
+#include <com/sun/star/ucb/XContentProviderManager.hpp>
+
+#include <ucbhelper/content.hxx>
+#include <osl/module.h>
+#include <tools/config.hxx>
+
+#include <stdio.h>
+#include <osl/thread.hxx>
+#include <osl/diagnose.h>
+#include <osl/conditn.hxx>
+#include <time.h>
+
+
+using namespace comphelper;
+using namespace cppu;
+using namespace rtl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::beans;
+
+//using namespace com::sun::star;
+using namespace connectivity;
+using namespace com::sun::star::sdb;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace ::com::sun::star::container;
+using namespace com::sun::star::registry;
+
+extern Reference< XMultiServiceFactory > InitializeFac( void );
+Reference< XMultiServiceFactory > mMgr;
+
+#define OUtoCStr( x ) (OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US ).getStr())
+#define PRINTSTR(x) printf("%s",x);
+#define PRINTLN(x) printf("%s\n",x);
+
+const int testLDAP=0;
+const int testMozilla=1;
+const int testOp=2;
+const int testOe=3;
+
+static int testCount = 0;
+static int testList[4] = {0,0,0,0};
+
+int autoTest(Reference<XResultSet> &xRes);
+
+void printColumns( Reference<XResultSet> &xRes )
+{
+ if(xRes.is())
+ {
+ char* aPat = " %-22s ";
+ char* aPat_Short = " %-12s ";
+ Reference<XResultSetMetaData> xMeta = Reference<XResultSetMetaDataSupplier>(xRes,UNO_QUERY)->getMetaData();
+ OSL_TRACE( "ColumnCount = %d\n", xMeta->getColumnCount());
+ for(sal_Int32 i=1;i<=xMeta->getColumnCount();++i)
+ {
+ const char *str = OUtoCStr(xMeta->getColumnName(i));
+ OSL_TRACE( aPat, str );
+ }
+ OSL_TRACE("\n");
+ OSL_TRACE("------------------------------------------------------------------------------------------\n");
+ }
+ else
+ {
+ OSL_TRACE(": FAILED to get a ResultSet \n");
+ }
+}
+void printXResultSet( Reference<XResultSet> &xRes )
+{
+ if(xRes.is())
+ {
+ char* aPat = " %-22s ";
+ char* aPat_Short = " %-12s ";
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ Reference<XResultSetMetaData> xMeta = Reference<XResultSetMetaDataSupplier>(xRes,UNO_QUERY)->getMetaData();
+ for(sal_Int32 j=1;j<=xMeta->getColumnCount();++j)
+ {
+ try
+ {
+ const char *str = OUtoCStr(xRow->getString(j));
+ OSL_TRACE( aPat_Short, str );
+ } catch (...) {
+ OSL_TRACE(" Ex ");
+ }
+ }
+ OSL_TRACE("\n");
+ }
+ else
+ OSL_TRACE("FAILED to get a ResultSet \n");
+}
+
+void printXResultSets( Reference<XResultSet> &xRes )
+{
+ if(xRes.is())
+ {
+ printColumns(xRes);
+ sal_Int32 nRows = 0;
+ while( xRes.is() && xRes->next())
+ {
+ printXResultSet(xRes);
+ nRows++;
+ }
+ OSL_TRACE( "%d Row(s)\n", nRows);
+ }else
+ OSL_TRACE("FAILED to get a ResultSet \n");
+}
+
+
+
+int TestMetaData(Reference< ::com::sun::star::sdbc::XConnection> &pConnection)
+{
+ // Test some metadata
+ Reference< XDatabaseMetaData > xDmd = pConnection->getMetaData();
+ if ( xDmd.is() )
+ {
+ OSL_TRACE(": got DatabaseMetaData \n");
+
+ OUString sQuoteStr = xDmd->getIdentifierQuoteString();
+ OSL_TRACE( "Quote String : '%s'\n", OUtoCStr( sQuoteStr ) );
+
+ OUString sSQLCmds = xDmd->getSQLKeywords();
+ OSL_TRACE( "SQL Commands : '%s'\n", OUtoCStr( sSQLCmds ) );
+
+ OSL_TRACE("Testing getColumns() : START\n");
+ {
+ Reference<XResultSet> xRes = xDmd->getColumns(
+ makeAny(OUString::createFromAscii("")), // Catalog
+ OUString::createFromAscii("%"), // Schema
+ OUString::createFromAscii("%"), // TabName
+ OUString::createFromAscii("%")
+ );
+ printXResultSets( xRes );
+ }
+ OSL_TRACE("Testing getColumns() : END\n");
+
+ OSL_TRACE("Testing getTypeInfo() : START\n");
+ {
+ Reference<XResultSet> xRes = xDmd-> getTypeInfo();
+ printXResultSets( xRes );
+ }
+ OSL_TRACE("Testing getTypeInfo() : END\n");
+
+ OSL_TRACE("Testing getTables() : START\n");
+ {
+ Reference<XResultSet> xRes = xDmd->getTables(
+ makeAny(OUString::createFromAscii("")), // Catalog
+ OUString::createFromAscii("%"), // Schema
+ OUString::createFromAscii("%"), // TabName
+ Sequence<rtl::OUString>() );
+ printXResultSets( xRes );
+ }
+ OSL_TRACE("Testing getTables() : END\n");
+
+ }
+ else
+ OSL_TRACE(": FAILED to get DatabaseMetaData \n");
+ return 0;
+}
+
+void TestQuery(Reference< ::com::sun::star::sdbc::XConnection> &pConnection)
+{
+ // Try a query
+ OSL_TRACE("Testing createStatement() & executeQuery() : START\n");
+ Reference<XStatement> xStmt = pConnection->createStatement();
+ Reference<XResultSet> xRes;
+ if(xStmt.is())
+ {
+ OSL_TRACE(": got statement\n");
+ OSL_TRACE(": excuteQuery() : START \n");
+// SELECT "First Name", "Display Name", "E-mail" FROM tablename
+ OUString sqlPrefix= OUString::createFromAscii("SELECT \"First Name\", \"Display Name\", \"E-mail\" FROM ");
+ try
+ {
+ sal_Int32 times=0;
+ Reference< XDatabaseMetaData > xDmd = pConnection->getMetaData();
+ if ( xDmd.is() )
+ {
+ OSL_TRACE("getTables() : START\n");
+ OUString qut = xDmd->getIdentifierQuoteString();
+
+ Reference<XResultSet> xRes = xDmd->getTables(
+ makeAny(OUString::createFromAscii("")), // Catalog
+ OUString::createFromAscii("%"), // Schema
+ OUString::createFromAscii("%"), // TabName
+ Sequence<rtl::OUString>() );
+ sal_Int32 nTables = 0;
+ while( xRes.is() && xRes->next())
+ {
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ const char *strTableName = OUtoCStr(xRow->getString(3));
+ OSL_TRACE("Testing Table:%s\n",strTableName);
+
+ Reference<XResultSet> tmpRes =
+ xStmt->executeQuery(sqlPrefix + qut + xRow->getString(3) + qut);
+ autoTest( tmpRes );
+ Reference<XCloseable> clsRes(tmpRes,UNO_QUERY);
+ clsRes->close();
+ nTables++;
+ }
+ OSL_TRACE("Tested Tables:%d\n",nTables);
+ }
+ } catch ( Exception &e ) {
+ OSL_TRACE( "Exception caught : %s\n", OUtoCStr( e.Message) );
+ }
+// catch (...) {
+// OSL_TRACE( "Non-UNO Exception caught\n" );
+// }
+ OSL_TRACE("excuteQuery() : END \n");
+ }
+ else
+ {
+ OSL_TRACE(": FAILED to get statement\n");
+ }
+ OSL_TRACE("Testing createStatement() & executeQuery() : END\n");
+}
+Reference< ::com::sun::star::sdbc::XConnection> TestConnected
+ (Reference< ::com::sun::star::sdbc::XDriver> &pDriver)
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> pConnection;
+ OSL_TRACE("Begin Connect!\n");
+ OUString url;
+ Sequence<PropertyValue> aValue;
+ int nType=0;
+ srand( (unsigned)time( NULL ) );
+ nType = rand() % testCount + 1;
+ int nIndex=0,nCount=0;
+ for ( nIndex = 0; nIndex< 4;nIndex++)
+ {
+ if (testList[nIndex])
+ nCount++;
+ if (nCount == nType)
+ break;
+ }
+ switch( nIndex)
+ {
+ case testLDAP:
+ url=OUString::createFromAscii("sdbc:address:ldap://");
+ aValue.realloc(2);
+ aValue[0].Name = ::rtl::OUString::createFromAscii("HostName");
+ aValue[0].Value <<= rtl::OUString::createFromAscii("sun-ds");
+ aValue[1].Name = ::rtl::OUString::createFromAscii("BaseDN");
+ aValue[1].Value <<= rtl::OUString::createFromAscii("dc=sun,dc=com");
+ break;
+ case testMozilla:
+ url=OUString::createFromAscii("sdbc:address:mozilla://");
+ break;
+ case testOp:
+ url=OUString::createFromAscii("sdbc:address:outlook://");
+ break;
+ case testOe:
+ url=OUString::createFromAscii("sdbc:address:outlookexp://");
+ break;
+ default:
+ url=OUString::createFromAscii("sdbc:address:mozilla://");
+ break;
+ }
+ pConnection =
+ pDriver->connect(url,aValue);
+ return pConnection;
+ }
+
+int autoTest(Reference<XResultSet> &xRes)
+{
+ sal_Int32 nRows = 0;
+ printColumns(xRes);
+ if(xRes.is())
+ {
+ while( xRes.is() && xRes->next())
+ {
+ nRows++;
+ }
+ OSL_TRACE( "%d Row(s)\n", nRows);
+ sal_Int32 times;
+ sal_Int32 pos;
+ if (nRows)
+ {
+ for(times = 1;times < 10; times ++)
+ {
+ pos= rand() % nRows+1;
+ OSL_TRACE("pos:%d\n",pos);
+ xRes->absolute(pos);
+ printXResultSet(xRes);
+ }
+ }
+ }
+ else
+ {
+ OSL_TRACE(": FAILED to get a ResultSet \n");
+ }
+ TimeValue timeValue = { 1, 0 }; //sleep 1 Seconds to give time to other threads
+ osl_waitThread(&timeValue);
+ return 0;
+}
+void SAL_CALL mozThread(void*)
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection;
+ try
+ {
+ Reference< ::com::sun::star::sdbc::XDriver>
+ m_xDriver(mMgr->createInstance(
+ OUString::createFromAscii("com.sun.star.comp.sdbc.MozabDriver")),
+ UNO_QUERY);
+ if(m_xDriver.is())
+ {
+
+ m_xConnection = TestConnected(m_xDriver);
+ if(m_xConnection.is())
+ {
+ if (!TestMetaData(m_xConnection))
+ {
+ TestQuery(m_xConnection);
+ }
+ }
+ else
+ OSL_TRACE("Can't connected!\n");
+
+ }
+ else
+ {
+ OSL_TRACE("No driver!\n");
+ }
+ } catch ( Exception &e ) {
+ OSL_TRACE( "Exception caught : %s\n", OUtoCStr( e.Message) );
+ }
+// catch (...) {
+// OSL_TRACE( "Non-UNO Exception caught\n" );
+// }
+}
+const int THREAD_COUNT=100;
+
+
+void usage()
+{
+ PRINTLN("mozThread [opts] threadcount");
+ PRINTLN("opts:");
+ PRINTLN("-l test ldap");
+ PRINTLN("-m test mozilla");
+ PRINTLN("-p test outlook");
+ PRINTLN("-e test outlook express");
+ PRINTLN("0 < threadcount <= 100, default 100");
+}
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int _cdecl main( int argc, char * argv[] )
+#endif
+
+{
+ OSL_TRACE("Init UNO\n");
+ Reference< XMultiServiceFactory > xMgr =InitializeFac();
+ int threadCount=THREAD_COUNT;
+ int nAc;
+ for (nAc = 1; nAc < argc; nAc ++)
+ {
+ if (strcmp(argv[nAc],"-l") ==0)
+ {
+ testList[testLDAP] = 1;
+ }else if(strcmp(argv[nAc],"-m") ==0)
+ {
+ testList[testMozilla]=1;
+ }else if(strcmp(argv[nAc],"-p") ==0)
+ {
+ testList[testOp]=1;
+ }else if(strcmp(argv[nAc],"-e") ==0)
+ {
+ testList[testOe]=1;
+ }else if(strcmp(argv[nAc],"-h") ==0 || strcmp(argv[nAc],"--help") ==0)
+ {
+ usage();
+ return 0;
+ }else
+ {
+ int tmpCount = atoi(argv[nAc]);
+ if (tmpCount > 0 && tmpCount < threadCount)
+ {
+ threadCount = tmpCount;
+ }
+ }
+ }
+ testCount = testList[testLDAP] + testList[testMozilla] + testList[testOp] + testList[testOe];
+ if ( testCount == 0)
+ {
+ testList[testLDAP] = 1;
+ testCount = 1;
+ }
+
+ if (!xMgr.is())
+ {
+ OSL_TRACE("Error init UNO\n");
+ return 1;
+ }
+ else
+ OSL_TRACE("UNO initted\n");
+
+ mMgr = xMgr;
+ oslThread xThreads[THREAD_COUNT];
+ int index=0;
+ for(index=0;index < threadCount; index++)
+ {
+ xThreads[index] = osl_createThread(mozThread,(void*)NULL);
+ TimeValue timeValue = { 1, 0 }; //sleep 1 Seconds to give time to other threads
+ osl_waitThread(&timeValue);
+ }
+ for(index=0;index < threadCount; index++)
+ {
+ if (osl_isThreadRunning(xThreads[index]))
+ osl_joinWithThread(xThreads[index]);
+ }
+ OSL_TRACE("Exiting...\n");
+ return 0;
+}
+