From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- connectivity/AllLangMoTarget_cnr.mk | 13 + connectivity/Configuration_ado.mk | 20 + connectivity/Configuration_calc.mk | 20 + connectivity/Configuration_dbase.mk | 20 + connectivity/Configuration_evoab.mk | 20 + connectivity/Configuration_firebird.mk | 20 + connectivity/Configuration_flat.mk | 20 + connectivity/Configuration_hsqldb.mk | 20 + connectivity/Configuration_jdbc.mk | 20 + connectivity/Configuration_macab.mk | 20 + connectivity/Configuration_mork.mk | 20 + connectivity/Configuration_mysql.mk | 20 + connectivity/Configuration_mysql_jdbc.mk | 20 + connectivity/Configuration_odbc.mk | 20 + connectivity/Configuration_postgresql.mk | 20 + connectivity/Configuration_writer.mk | 20 + connectivity/CppunitTest_connectivity_ado.mk | 69 + .../CppunitTest_connectivity_commontools.mk | 42 + connectivity/CppunitTest_connectivity_mork.mk | 56 + .../CppunitTest_connectivity_mysql_test.mk | 66 + .../CppunitTest_connectivity_sharedresources.mk | 43 + connectivity/Executable_mork_helper.mk | 30 + connectivity/IwyuFilter_connectivity.yaml | 75 + connectivity/Jar_ConnectivityTools.mk | 42 + connectivity/Jar_sdbc_hsqldb.mk | 37 + connectivity/JunitTest_complex.mk | 51 + connectivity/Library_ado.mk | 85 + connectivity/Library_calc.mk | 51 + connectivity/Library_dbase.mk | 64 + connectivity/Library_dbpool2.mk | 44 + connectivity/Library_dbtools.mk | 129 + connectivity/Library_evoab.mk | 59 + connectivity/Library_file.mk | 71 + connectivity/Library_firebird_sdbc.mk | 67 + connectivity/Library_flat.mk | 56 + connectivity/Library_hsqldb.mk | 62 + connectivity/Library_jdbc.mk | 77 + connectivity/Library_macab1.mk | 41 + connectivity/Library_macabdrv1.mk | 58 + connectivity/Library_mork.mk | 62 + connectivity/Library_mozbootstrap.mk | 35 + connectivity/Library_mysql_jdbc.mk | 48 + connectivity/Library_mysqlc.mk | 67 + connectivity/Library_odbc.mk | 61 + connectivity/Library_postgresql-sdbc-impl.mk | 106 + connectivity/Library_postgresql-sdbc.mk | 34 + connectivity/Library_sdbc2.mk | 39 + connectivity/Library_writer.mk | 49 + connectivity/Makefile | 7 + connectivity/Module_connectivity.mk | 149 + connectivity/Package_postgresql-sdbc.mk | 12 + connectivity/README | 24 + connectivity/Rdb_postgresql-sdbc.mk | 17 + .../sdbcx/comp/hsqldb/NativeInputStreamHelper.java | 62 + .../star/sdbcx/comp/hsqldb/NativeLibraries.java | 71 + .../comp/hsqldb/NativeOutputStreamHelper.java | 60 + .../sdbcx/comp/hsqldb/NativeStorageAccess.java | 62 + .../sun/star/sdbcx/comp/hsqldb/StorageAccess.java | 126 + .../star/sdbcx/comp/hsqldb/StorageFileAccess.java | 90 + .../comp/hsqldb/StorageNativeInputStream.java | 34 + .../comp/hsqldb/StorageNativeOutputStream.java | 145 + connectivity/inc/ParameterCont.hxx | 49 + connectivity/inc/SQLStatementHelper.hxx | 43 + connectivity/inc/TIndex.hxx | 46 + connectivity/inc/TIndexColumns.hxx | 41 + connectivity/inc/TKey.hxx | 44 + connectivity/inc/TKeyColumns.hxx | 41 + connectivity/inc/bitmaps.hlst | 17 + connectivity/inc/pch/precompiled_ado.cxx | 12 + connectivity/inc/pch/precompiled_ado.hxx | 116 + connectivity/inc/pch/precompiled_calc.cxx | 12 + connectivity/inc/pch/precompiled_calc.hxx | 77 + connectivity/inc/pch/precompiled_dbase.cxx | 12 + connectivity/inc/pch/precompiled_dbase.hxx | 228 + connectivity/inc/pch/precompiled_dbpool2.cxx | 12 + connectivity/inc/pch/precompiled_dbpool2.hxx | 93 + connectivity/inc/pch/precompiled_dbtools.cxx | 12 + connectivity/inc/pch/precompiled_dbtools.hxx | 212 + connectivity/inc/pch/precompiled_file.cxx | 12 + connectivity/inc/pch/precompiled_file.hxx | 222 + connectivity/inc/pch/precompiled_firebird_sdbc.cxx | 12 + connectivity/inc/pch/precompiled_firebird_sdbc.hxx | 82 + connectivity/inc/pch/precompiled_flat.cxx | 12 + connectivity/inc/pch/precompiled_flat.hxx | 208 + connectivity/inc/pch/precompiled_mysql_jdbc.cxx | 12 + connectivity/inc/pch/precompiled_mysql_jdbc.hxx | 64 + connectivity/inc/pch/precompiled_odbc.cxx | 12 + connectivity/inc/pch/precompiled_odbc.hxx | 91 + .../inc/pch/precompiled_postgresql-sdbc-impl.cxx | 12 + .../inc/pch/precompiled_postgresql-sdbc-impl.hxx | 61 + connectivity/inc/sdbcx/VCatalog.hxx | 118 + connectivity/inc/sdbcx/VGroup.hxx | 97 + connectivity/inc/sdbcx/VIndex.hxx | 100 + connectivity/inc/sdbcx/VIndexColumn.hxx | 60 + connectivity/inc/sdbcx/VKey.hxx | 111 + connectivity/inc/sdbcx/VKeyColumn.hxx | 62 + connectivity/inc/sdbcx/VTypeDef.hxx | 37 + connectivity/inc/sdbcx/VUser.hxx | 98 + connectivity/inc/strings.hrc | 144 + connectivity/inc/strings.hxx | 77 + .../org/hsqldb/lib/FileSystemRuntimeException.java | 38 + .../qa/complex/connectivity/DBaseDriverTest.java | 70 + .../qa/complex/connectivity/FlatFileAccess.java | 245 + .../qa/complex/connectivity/HsqlDriverTest.java | 145 + .../complex/connectivity/JdbcLongVarCharTest.java | 125 + .../qa/complex/connectivity/SubTestCase.java | 41 + connectivity/qa/complex/connectivity/TestCase.java | 27 + .../connectivity/dbase/DBaseDateFunctions.java | 296 ++ .../connectivity/dbase/DBaseNumericFunctions.java | 388 ++ .../complex/connectivity/dbase/DBaseSqlTests.java | 80 + .../connectivity/dbase/DBaseStringFunctions.java | 310 ++ .../complex/connectivity/hsqldb/TestCacheSize.java | 591 +++ connectivity/qa/connectivity/ado/DriverTest.cxx | 141 + connectivity/qa/connectivity/ado/TS001018407.mdb | Bin 0 -> 2789376 bytes .../qa/connectivity/commontools/FValue_test.cxx | 366 ++ connectivity/qa/connectivity/mork/DriverTest.cxx | 199 + .../qa/connectivity/mork/abook_10_john_does.mab | 159 + connectivity/qa/connectivity/mysql/mysql.cxx | 501 ++ .../connectivity/resource/sharedresources_test.cxx | 107 + .../qa/connectivity/tools/AbstractDatabase.java | 208 + .../qa/connectivity/tools/CRMDatabase.java | 277 ++ .../qa/connectivity/tools/CsvDatabase.java | 31 + connectivity/qa/connectivity/tools/DataSource.java | 150 + .../qa/connectivity/tools/DatabaseAccess.java | 50 + .../qa/connectivity/tools/DbaseDatabase.java | 32 + .../qa/connectivity/tools/FlatFileDatabase.java | 74 + .../connectivity/tools/HsqlColumnDescriptor.java | 75 + .../qa/connectivity/tools/HsqlDatabase.java | 202 + .../qa/connectivity/tools/HsqlTableDescriptor.java | 93 + .../qa/connectivity/tools/QueryDefinition.java | 49 + connectivity/qa/connectivity/tools/RowSet.java | 288 ++ .../qa/connectivity/tools/sdb/Connection.java | 80 + connectivity/qa/scenarios.sce | 21 + connectivity/registry/README | 25 + .../org/openoffice/Office/DataAccess/Drivers.xcu | 369 ++ .../org/openoffice/Office/DataAccess/Drivers.xcu | 61 + .../org/openoffice/Office/DataAccess/Drivers.xcu | 101 + .../org/openoffice/Office/DataAccess/Drivers.xcu | 88 + .../org/openoffice/Office/DataAccess/Drivers.xcu | 130 + .../org/openoffice/Office/DataAccess/Drivers.xcu | 116 + .../org/openoffice/Office/DataAccess/Drivers.xcu | 103 + .../org/openoffice/Office/DataAccess/Drivers.xcu | 297 ++ .../org/openoffice/Office/DataAccess/Drivers.xcu | 44 + .../org/openoffice/Office/DataAccess/Drivers.xcu | 51 + .../org/openoffice/Office/DataAccess/Drivers.xcu | 264 ++ .../org/openoffice/Office/DataAccess/Drivers.xcu | 128 + .../org/openoffice/Office/DataAccess/Drivers.xcu | 261 ++ .../org/openoffice/Office/DataAccess/Drivers.xcu | 94 + .../org/openoffice/Office/DataAccess/Drivers.xcu | 51 + .../source/commontools/AutoRetrievingBase.cxx | 51 + connectivity/source/commontools/BlobHelper.cxx | 71 + connectivity/source/commontools/CommonTools.cxx | 235 + .../source/commontools/ConnectionWrapper.cxx | 239 + connectivity/source/commontools/DateConversion.cxx | 526 +++ connectivity/source/commontools/DriversConfig.cxx | 237 + .../commontools/FDatabaseMetaDataResultSet.cxx | 894 ++++ .../FDatabaseMetaDataResultSetMetaData.cxx | 357 ++ connectivity/source/commontools/FValue.cxx | 2473 ++++++++++ .../source/commontools/ParameterSubstitution.cxx | 114 + .../source/commontools/RowFunctionParser.cxx | 441 ++ connectivity/source/commontools/TColumnsHelper.cxx | 208 + connectivity/source/commontools/TConnection.cxx | 89 + .../source/commontools/TDatabaseMetaDataBase.cxx | 326 ++ connectivity/source/commontools/TIndex.cxx | 100 + connectivity/source/commontools/TIndexColumns.cxx | 115 + connectivity/source/commontools/TIndexes.cxx | 248 + connectivity/source/commontools/TKey.cxx | 107 + connectivity/source/commontools/TKeyColumns.cxx | 133 + connectivity/source/commontools/TKeys.cxx | 311 ++ .../source/commontools/TPrivilegesResultSet.cxx | 143 + .../source/commontools/TSkipDeletedSet.cxx | 255 ++ connectivity/source/commontools/TSortIndex.cxx | 152 + connectivity/source/commontools/TTableHelper.cxx | 605 +++ connectivity/source/commontools/conncleanup.cxx | 230 + connectivity/source/commontools/dbcharset.cxx | 190 + connectivity/source/commontools/dbconversion.cxx | 461 ++ connectivity/source/commontools/dbexception.cxx | 481 ++ connectivity/source/commontools/dbmetadata.cxx | 448 ++ connectivity/source/commontools/dbtools.cxx | 2086 +++++++++ connectivity/source/commontools/dbtools2.cxx | 1028 +++++ connectivity/source/commontools/filtermanager.cxx | 254 + .../source/commontools/formattedcolumnvalue.cxx | 292 ++ connectivity/source/commontools/parameters.cxx | 1118 +++++ connectivity/source/commontools/paramwrapper.cxx | 354 ++ connectivity/source/commontools/predicateinput.cxx | 420 ++ connectivity/source/commontools/propertyids.cxx | 103 + connectivity/source/commontools/sqlerror.cxx | 300 ++ .../source/commontools/statementcomposer.cxx | 304 ++ .../source/commontools/warningscontainer.cxx | 110 + connectivity/source/cpool/ZConnectionPool.cxx | 301 ++ connectivity/source/cpool/ZConnectionPool.hxx | 150 + connectivity/source/cpool/ZConnectionWrapper.cxx | 241 + connectivity/source/cpool/ZConnectionWrapper.hxx | 79 + connectivity/source/cpool/ZDriverWrapper.cxx | 114 + connectivity/source/cpool/ZDriverWrapper.hxx | 78 + connectivity/source/cpool/ZPoolCollection.cxx | 482 ++ connectivity/source/cpool/ZPoolCollection.hxx | 141 + connectivity/source/cpool/ZPooledConnection.cxx | 72 + connectivity/source/cpool/ZPooledConnection.hxx | 61 + connectivity/source/cpool/Zregistration.cxx | 63 + connectivity/source/cpool/dbpool2.component | 25 + connectivity/source/dbtools/dbtools.component | 28 + .../source/drivers/ado/ACallableStatement.cxx | 223 + connectivity/source/drivers/ado/ACatalog.cxx | 115 + connectivity/source/drivers/ado/AColumn.cxx | 254 + connectivity/source/drivers/ado/AColumns.cxx | 130 + connectivity/source/drivers/ado/AConnection.cxx | 587 +++ .../source/drivers/ado/ADatabaseMetaData.cxx | 1073 +++++ .../source/drivers/ado/ADatabaseMetaDataImpl.cxx | 585 +++ .../drivers/ado/ADatabaseMetaDataResultSet.cxx | 1204 +++++ .../ado/ADatabaseMetaDataResultSetMetaData.cxx | 222 + connectivity/source/drivers/ado/ADriver.cxx | 278 ++ connectivity/source/drivers/ado/AGroup.cxx | 157 + connectivity/source/drivers/ado/AGroups.cxx | 76 + connectivity/source/drivers/ado/AIndex.cxx | 124 + connectivity/source/drivers/ado/AIndexes.cxx | 82 + connectivity/source/drivers/ado/AKey.cxx | 137 + connectivity/source/drivers/ado/AKeys.cxx | 97 + .../source/drivers/ado/APreparedStatement.cxx | 460 ++ connectivity/source/drivers/ado/AResultSet.cxx | 1155 +++++ .../source/drivers/ado/AResultSetMetaData.cxx | 243 + connectivity/source/drivers/ado/AStatement.cxx | 832 ++++ connectivity/source/drivers/ado/ATable.cxx | 229 + connectivity/source/drivers/ado/ATables.cxx | 103 + connectivity/source/drivers/ado/AUser.cxx | 193 + connectivity/source/drivers/ado/AUsers.cxx | 76 + connectivity/source/drivers/ado/AView.cxx | 94 + connectivity/source/drivers/ado/AViews.cxx | 94 + connectivity/source/drivers/ado/Aolevariant.cxx | 745 +++ connectivity/source/drivers/ado/Aservices.cxx | 105 + connectivity/source/drivers/ado/Awrapado.cxx | 2153 +++++++++ connectivity/source/drivers/ado/ado.component | 27 + connectivity/source/drivers/ado/adoimp.cxx | 325 ++ connectivity/source/drivers/calc/CCatalog.cxx | 64 + connectivity/source/drivers/calc/CConnection.cxx | 268 ++ .../source/drivers/calc/CDatabaseMetaData.cxx | 220 + connectivity/source/drivers/calc/CDriver.cxx | 94 + connectivity/source/drivers/calc/CTable.cxx | 657 +++ connectivity/source/drivers/calc/CTables.cxx | 49 + connectivity/source/drivers/calc/Cservices.cxx | 106 + connectivity/source/drivers/calc/calc.component | 27 + connectivity/source/drivers/component/CColumns.cxx | 44 + .../source/drivers/component/CDatabaseMetaData.cxx | 244 + .../drivers/component/CPreparedStatement.cxx | 34 + .../source/drivers/component/CResultSet.cxx | 172 + .../source/drivers/component/CStatement.cxx | 34 + connectivity/source/drivers/component/CTable.cxx | 190 + connectivity/source/drivers/dbase/DCatalog.cxx | 59 + connectivity/source/drivers/dbase/DColumns.cxx | 77 + connectivity/source/drivers/dbase/DConnection.cxx | 115 + .../source/drivers/dbase/DDatabaseMetaData.cxx | 388 ++ connectivity/source/drivers/dbase/DDriver.cxx | 119 + connectivity/source/drivers/dbase/DIndex.cxx | 611 +++ .../source/drivers/dbase/DIndexColumns.cxx | 82 + connectivity/source/drivers/dbase/DIndexIter.cxx | 302 ++ connectivity/source/drivers/dbase/DIndexes.cxx | 116 + .../source/drivers/dbase/DPreparedStatement.cxx | 34 + connectivity/source/drivers/dbase/DResultSet.cxx | 211 + connectivity/source/drivers/dbase/DStatement.cxx | 35 + connectivity/source/drivers/dbase/DTable.cxx | 2732 +++++++++++ connectivity/source/drivers/dbase/DTables.cxx | 128 + connectivity/source/drivers/dbase/Dservices.cxx | 106 + connectivity/source/drivers/dbase/dbase.component | 26 + connectivity/source/drivers/dbase/dindexnode.cxx | 1046 +++++ connectivity/source/drivers/evoab2/EApi.cxx | 186 + connectivity/source/drivers/evoab2/EApi.h | 162 + connectivity/source/drivers/evoab2/NCatalog.cxx | 87 + connectivity/source/drivers/evoab2/NCatalog.hxx | 48 + connectivity/source/drivers/evoab2/NColumns.cxx | 88 + connectivity/source/drivers/evoab2/NColumns.hxx | 50 + connectivity/source/drivers/evoab2/NConnection.cxx | 245 + connectivity/source/drivers/evoab2/NConnection.hxx | 112 + .../source/drivers/evoab2/NDatabaseMetaData.cxx | 1218 +++++ .../source/drivers/evoab2/NDatabaseMetaData.hxx | 221 + connectivity/source/drivers/evoab2/NDriver.cxx | 166 + connectivity/source/drivers/evoab2/NDriver.hxx | 87 + .../source/drivers/evoab2/NPreparedStatement.cxx | 319 ++ .../source/drivers/evoab2/NPreparedStatement.hxx | 114 + connectivity/source/drivers/evoab2/NResultSet.cxx | 1142 +++++ connectivity/source/drivers/evoab2/NResultSet.hxx | 187 + .../source/drivers/evoab2/NResultSetMetaData.cxx | 183 + .../source/drivers/evoab2/NResultSetMetaData.hxx | 81 + connectivity/source/drivers/evoab2/NServices.cxx | 108 + connectivity/source/drivers/evoab2/NStatement.cxx | 632 +++ connectivity/source/drivers/evoab2/NStatement.hxx | 278 ++ connectivity/source/drivers/evoab2/NTable.cxx | 76 + connectivity/source/drivers/evoab2/NTable.hxx | 58 + connectivity/source/drivers/evoab2/NTables.cxx | 80 + connectivity/source/drivers/evoab2/NTables.hxx | 47 + connectivity/source/drivers/evoab2/evoab.component | 25 + connectivity/source/drivers/file/FCatalog.cxx | 103 + connectivity/source/drivers/file/FColumns.cxx | 81 + connectivity/source/drivers/file/FConnection.cxx | 435 ++ .../source/drivers/file/FDatabaseMetaData.cxx | 1055 +++++ .../source/drivers/file/FDateFunctions.cxx | 280 ++ connectivity/source/drivers/file/FDriver.cxx | 227 + connectivity/source/drivers/file/FNoException.cxx | 102 + .../source/drivers/file/FNumericFunctions.cxx | 243 + .../source/drivers/file/FPreparedStatement.cxx | 554 +++ connectivity/source/drivers/file/FResultSet.cxx | 1595 +++++++ .../source/drivers/file/FResultSetMetaData.cxx | 187 + connectivity/source/drivers/file/FStatement.cxx | 710 +++ .../source/drivers/file/FStringFunctions.cxx | 233 + connectivity/source/drivers/file/FTable.cxx | 191 + connectivity/source/drivers/file/FTables.cxx | 54 + connectivity/source/drivers/file/fanalyzer.cxx | 207 + connectivity/source/drivers/file/fcode.cxx | 391 ++ connectivity/source/drivers/file/fcomp.cxx | 890 ++++ connectivity/source/drivers/file/quotedstring.cxx | 146 + connectivity/source/drivers/firebird/Blob.cxx | 388 ++ connectivity/source/drivers/firebird/Blob.hxx | 103 + connectivity/source/drivers/firebird/Catalog.cxx | 95 + connectivity/source/drivers/firebird/Catalog.hxx | 42 + connectivity/source/drivers/firebird/Clob.cxx | 155 + connectivity/source/drivers/firebird/Clob.hxx | 69 + connectivity/source/drivers/firebird/Column.cxx | 51 + connectivity/source/drivers/firebird/Column.hxx | 36 + connectivity/source/drivers/firebird/Columns.cxx | 41 + connectivity/source/drivers/firebird/Columns.hxx | 37 + .../source/drivers/firebird/Connection.cxx | 959 ++++ .../source/drivers/firebird/Connection.hxx | 246 + .../source/drivers/firebird/DatabaseMetaData.cxx | 1810 ++++++++ .../source/drivers/firebird/DatabaseMetaData.hxx | 205 + connectivity/source/drivers/firebird/Driver.cxx | 242 + connectivity/source/drivers/firebird/Driver.hxx | 102 + connectivity/source/drivers/firebird/Indexes.cxx | 32 + connectivity/source/drivers/firebird/Indexes.hxx | 45 + connectivity/source/drivers/firebird/Keys.cxx | 54 + connectivity/source/drivers/firebird/Keys.hxx | 41 + .../source/drivers/firebird/PreparedStatement.cxx | 1018 +++++ .../source/drivers/firebird/PreparedStatement.hxx | 156 + connectivity/source/drivers/firebird/ResultSet.cxx | 909 ++++ connectivity/source/drivers/firebird/ResultSet.hxx | 220 + .../source/drivers/firebird/ResultSetMetaData.cxx | 296 ++ .../source/drivers/firebird/ResultSetMetaData.hxx | 84 + connectivity/source/drivers/firebird/Services.cxx | 109 + connectivity/source/drivers/firebird/Statement.cxx | 175 + connectivity/source/drivers/firebird/Statement.hxx | 89 + .../drivers/firebird/StatementCommonBase.cxx | 463 ++ .../drivers/firebird/StatementCommonBase.hxx | 136 + .../source/drivers/firebird/SubComponent.hxx | 131 + connectivity/source/drivers/firebird/Table.cxx | 262 ++ connectivity/source/drivers/firebird/Table.hxx | 87 + connectivity/source/drivers/firebird/Tables.cxx | 211 + connectivity/source/drivers/firebird/Tables.hxx | 65 + connectivity/source/drivers/firebird/User.cxx | 51 + connectivity/source/drivers/firebird/User.hxx | 53 + connectivity/source/drivers/firebird/Users.cxx | 78 + connectivity/source/drivers/firebird/Users.hxx | 60 + connectivity/source/drivers/firebird/Util.cxx | 436 ++ connectivity/source/drivers/firebird/Util.hxx | 130 + .../drivers/firebird/firebird_sdbc.component | 18 + connectivity/source/drivers/flat/ECatalog.cxx | 60 + connectivity/source/drivers/flat/EColumns.cxx | 44 + connectivity/source/drivers/flat/EConnection.cxx | 182 + .../source/drivers/flat/EDatabaseMetaData.cxx | 245 + connectivity/source/drivers/flat/EDriver.cxx | 135 + .../source/drivers/flat/EPreparedStatement.cxx | 35 + connectivity/source/drivers/flat/EResultSet.cxx | 169 + connectivity/source/drivers/flat/EStatement.cxx | 34 + connectivity/source/drivers/flat/ETable.cxx | 964 ++++ connectivity/source/drivers/flat/ETables.cxx | 45 + connectivity/source/drivers/flat/Eservices.cxx | 106 + connectivity/source/drivers/flat/flat.component | 26 + connectivity/source/drivers/hsqldb/HCatalog.cxx | 150 + connectivity/source/drivers/hsqldb/HColumns.cxx | 76 + connectivity/source/drivers/hsqldb/HConnection.cxx | 340 ++ connectivity/source/drivers/hsqldb/HDriver.cxx | 870 ++++ .../source/drivers/hsqldb/HStorageAccess.cxx | 508 ++ connectivity/source/drivers/hsqldb/HStorageMap.cxx | 360 ++ connectivity/source/drivers/hsqldb/HTable.cxx | 390 ++ connectivity/source/drivers/hsqldb/HTables.cxx | 180 + .../source/drivers/hsqldb/HTerminateListener.cxx | 52 + .../source/drivers/hsqldb/HTerminateListener.hxx | 54 + connectivity/source/drivers/hsqldb/HTools.cxx | 53 + connectivity/source/drivers/hsqldb/HUser.cxx | 328 ++ connectivity/source/drivers/hsqldb/HUsers.cxx | 99 + connectivity/source/drivers/hsqldb/HView.cxx | 217 + connectivity/source/drivers/hsqldb/HViews.cxx | 149 + connectivity/source/drivers/hsqldb/Hservices.cxx | 108 + .../source/drivers/hsqldb/StorageFileAccess.cxx | 168 + .../drivers/hsqldb/StorageNativeInputStream.cxx | 291 ++ .../drivers/hsqldb/StorageNativeOutputStream.cxx | 195 + connectivity/source/drivers/hsqldb/accesslog.cxx | 78 + connectivity/source/drivers/hsqldb/accesslog.hxx | 138 + .../source/drivers/hsqldb/hsqldb.component | 26 + connectivity/source/drivers/jdbc/Array.cxx | 132 + connectivity/source/drivers/jdbc/Blob.cxx | 144 + connectivity/source/drivers/jdbc/Boolean.cxx | 43 + .../source/drivers/jdbc/CallableStatement.cxx | 354 ++ connectivity/source/drivers/jdbc/Class.cxx | 70 + connectivity/source/drivers/jdbc/Clob.cxx | 132 + connectivity/source/drivers/jdbc/ConnectionLog.cxx | 110 + .../source/drivers/jdbc/ContextClassLoader.cxx | 111 + .../source/drivers/jdbc/DatabaseMetaData.cxx | 1459 ++++++ connectivity/source/drivers/jdbc/Date.cxx | 41 + .../source/drivers/jdbc/DriverPropertyInfo.cxx | 44 + connectivity/source/drivers/jdbc/Exception.cxx | 39 + connectivity/source/drivers/jdbc/InputStream.cxx | 113 + connectivity/source/drivers/jdbc/JBigDecimal.cxx | 79 + connectivity/source/drivers/jdbc/JConnection.cxx | 804 ++++ connectivity/source/drivers/jdbc/JDriver.cxx | 246 + connectivity/source/drivers/jdbc/JStatement.cxx | 823 ++++ connectivity/source/drivers/jdbc/Object.cxx | 483 ++ .../source/drivers/jdbc/PreparedStatement.cxx | 697 +++ connectivity/source/drivers/jdbc/Reader.cxx | 179 + connectivity/source/drivers/jdbc/Ref.cxx | 52 + connectivity/source/drivers/jdbc/ResultSet.cxx | 998 ++++ .../source/drivers/jdbc/ResultSetMetaData.cxx | 200 + connectivity/source/drivers/jdbc/SQLException.cxx | 87 + connectivity/source/drivers/jdbc/SQLWarning.cxx | 39 + connectivity/source/drivers/jdbc/String.cxx | 53 + connectivity/source/drivers/jdbc/Throwable.cxx | 66 + connectivity/source/drivers/jdbc/Timestamp.cxx | 189 + connectivity/source/drivers/jdbc/jdbc.component | 36 + connectivity/source/drivers/jdbc/jservices.cxx | 106 + connectivity/source/drivers/jdbc/tools.cxx | 262 ++ .../source/drivers/macab/MacabAddressBook.cxx | 242 + .../source/drivers/macab/MacabAddressBook.hxx | 65 + connectivity/source/drivers/macab/MacabCatalog.cxx | 112 + connectivity/source/drivers/macab/MacabCatalog.hxx | 57 + connectivity/source/drivers/macab/MacabColumns.cxx | 95 + connectivity/source/drivers/macab/MacabColumns.hxx | 48 + .../source/drivers/macab/MacabConnection.cxx | 318 ++ .../source/drivers/macab/MacabConnection.hxx | 118 + .../source/drivers/macab/MacabDatabaseMetaData.cxx | 1076 +++++ .../source/drivers/macab/MacabDatabaseMetaData.hxx | 201 + connectivity/source/drivers/macab/MacabDriver.cxx | 322 ++ connectivity/source/drivers/macab/MacabDriver.hxx | 177 + connectivity/source/drivers/macab/MacabGroup.cxx | 93 + connectivity/source/drivers/macab/MacabGroup.hxx | 44 + connectivity/source/drivers/macab/MacabHeader.cxx | 334 ++ connectivity/source/drivers/macab/MacabHeader.hxx | 64 + .../drivers/macab/MacabPreparedStatement.cxx | 343 ++ .../drivers/macab/MacabPreparedStatement.hxx | 117 + connectivity/source/drivers/macab/MacabRecord.cxx | 336 ++ connectivity/source/drivers/macab/MacabRecord.hxx | 77 + connectivity/source/drivers/macab/MacabRecords.cxx | 1164 +++++ connectivity/source/drivers/macab/MacabRecords.hxx | 131 + .../source/drivers/macab/MacabResultSet.cxx | 1074 +++++ .../source/drivers/macab/MacabResultSet.hxx | 219 + .../drivers/macab/MacabResultSetMetaData.cxx | 215 + .../drivers/macab/MacabResultSetMetaData.hxx | 87 + .../source/drivers/macab/MacabServices.cxx | 107 + .../source/drivers/macab/MacabStatement.cxx | 594 +++ .../source/drivers/macab/MacabStatement.hxx | 174 + connectivity/source/drivers/macab/MacabTable.cxx | 86 + connectivity/source/drivers/macab/MacabTable.hxx | 60 + connectivity/source/drivers/macab/MacabTables.cxx | 81 + connectivity/source/drivers/macab/MacabTables.hxx | 55 + connectivity/source/drivers/macab/macab1.component | 25 + .../source/drivers/macab/macabcondition.cxx | 242 + .../source/drivers/macab/macabcondition.hxx | 167 + connectivity/source/drivers/macab/macaborder.cxx | 75 + connectivity/source/drivers/macab/macaborder.hxx | 69 + .../source/drivers/macab/macabutilities.hxx | 143 + connectivity/source/drivers/mork/MCatalog.cxx | 104 + connectivity/source/drivers/mork/MCatalog.hxx | 52 + connectivity/source/drivers/mork/MColumnAlias.cxx | 133 + connectivity/source/drivers/mork/MColumnAlias.hxx | 72 + connectivity/source/drivers/mork/MColumns.cxx | 80 + connectivity/source/drivers/mork/MColumns.hxx | 48 + connectivity/source/drivers/mork/MConnection.cxx | 377 ++ connectivity/source/drivers/mork/MConnection.hxx | 98 + .../source/drivers/mork/MDatabaseMetaData.cxx | 957 ++++ .../source/drivers/mork/MDatabaseMetaData.hxx | 191 + .../drivers/mork/MDatabaseMetaDataHelper.cxx | 123 + .../drivers/mork/MDatabaseMetaDataHelper.hxx | 39 + connectivity/source/drivers/mork/MDriver.cxx | 133 + connectivity/source/drivers/mork/MDriver.hxx | 79 + .../source/drivers/mork/MErrorResource.hxx | 56 + .../source/drivers/mork/MPreparedStatement.cxx | 486 ++ .../source/drivers/mork/MPreparedStatement.hxx | 134 + connectivity/source/drivers/mork/MQueryHelper.cxx | 321 ++ connectivity/source/drivers/mork/MQueryHelper.hxx | 184 + connectivity/source/drivers/mork/MResultSet.cxx | 1710 +++++++ connectivity/source/drivers/mork/MResultSet.hxx | 350 ++ .../source/drivers/mork/MResultSetMetaData.cxx | 192 + .../source/drivers/mork/MResultSetMetaData.hxx | 88 + connectivity/source/drivers/mork/MStatement.cxx | 471 ++ connectivity/source/drivers/mork/MStatement.hxx | 184 + connectivity/source/drivers/mork/MTable.cxx | 57 + connectivity/source/drivers/mork/MTable.hxx | 61 + connectivity/source/drivers/mork/MTables.cxx | 70 + connectivity/source/drivers/mork/MTables.hxx | 47 + connectivity/source/drivers/mork/MorkParser.cxx | 757 +++ connectivity/source/drivers/mork/MorkParser.hxx | 152 + connectivity/source/drivers/mork/README | 41 + connectivity/source/drivers/mork/dllapi.h | 25 + connectivity/source/drivers/mork/license.txt | 31 + connectivity/source/drivers/mork/mork.component | 17 + connectivity/source/drivers/mork/mork_helper.cxx | 54 + .../drivers/mozab/bootstrap/MMozillaBootstrap.cxx | 183 + .../drivers/mozab/bootstrap/MMozillaBootstrap.hxx | 87 + .../source/drivers/mozab/bootstrap/MNSFolders.cxx | 159 + .../source/drivers/mozab/bootstrap/MNSFolders.hxx | 31 + .../drivers/mozab/bootstrap/MNSINIParser.cxx | 93 + .../drivers/mozab/bootstrap/MNSINIParser.hxx | 57 + .../drivers/mozab/bootstrap/MNSProfileDiscover.cxx | 209 + .../drivers/mozab/bootstrap/MNSProfileDiscover.hxx | 90 + .../drivers/mozab/bootstrap/mozbootstrap.component | 25 + .../source/drivers/mysql_jdbc/YCatalog.cxx | 133 + .../source/drivers/mysql_jdbc/YColumns.cxx | 72 + connectivity/source/drivers/mysql_jdbc/YDriver.cxx | 418 ++ connectivity/source/drivers/mysql_jdbc/YTable.cxx | 330 ++ connectivity/source/drivers/mysql_jdbc/YTables.cxx | 210 + connectivity/source/drivers/mysql_jdbc/YUser.cxx | 325 ++ connectivity/source/drivers/mysql_jdbc/YUsers.cxx | 95 + connectivity/source/drivers/mysql_jdbc/YViews.cxx | 138 + .../source/drivers/mysql_jdbc/Yservices.cxx | 66 + .../source/drivers/mysql_jdbc/mysql_jdbc.component | 26 + connectivity/source/drivers/mysqlc/DataAccess.xcu | 35 + .../source/drivers/mysqlc/mysqlc.component | 15 + .../source/drivers/mysqlc/mysqlc_connection.cxx | 489 ++ .../source/drivers/mysqlc/mysqlc_connection.hxx | 187 + .../drivers/mysqlc/mysqlc_databasemetadata.cxx | 1076 +++++ .../drivers/mysqlc/mysqlc_databasemetadata.hxx | 239 + .../source/drivers/mysqlc/mysqlc_driver.cxx | 139 + .../source/drivers/mysqlc/mysqlc_driver.hxx | 94 + .../source/drivers/mysqlc/mysqlc_general.cxx | 340 ++ .../source/drivers/mysqlc/mysqlc_general.hxx | 119 + .../drivers/mysqlc/mysqlc_prepared_resultset.cxx | 1084 +++++ .../drivers/mysqlc/mysqlc_prepared_resultset.hxx | 257 ++ .../drivers/mysqlc/mysqlc_preparedstatement.cxx | 578 +++ .../drivers/mysqlc/mysqlc_preparedstatement.hxx | 161 + .../source/drivers/mysqlc/mysqlc_propertyids.hxx | 49 + .../source/drivers/mysqlc/mysqlc_resultset.cxx | 1114 +++++ .../source/drivers/mysqlc/mysqlc_resultset.hxx | 279 ++ .../drivers/mysqlc/mysqlc_resultsetmetadata.cxx | 211 + .../drivers/mysqlc/mysqlc_resultsetmetadata.hxx | 109 + .../source/drivers/mysqlc/mysqlc_services.cxx | 110 + .../source/drivers/mysqlc/mysqlc_statement.cxx | 404 ++ .../source/drivers/mysqlc/mysqlc_statement.hxx | 180 + .../source/drivers/mysqlc/mysqlc_subcomponent.hxx | 160 + .../source/drivers/mysqlc/mysqlc_types.cxx | 679 +++ .../source/drivers/mysqlc/mysqlc_types.hxx | 48 + connectivity/source/drivers/odbc/OConnection.cxx | 547 +++ .../source/drivers/odbc/ODatabaseMetaData.cxx | 1717 +++++++ .../drivers/odbc/ODatabaseMetaDataResultSet.cxx | 1309 ++++++ connectivity/source/drivers/odbc/ODriver.cxx | 208 + connectivity/source/drivers/odbc/OFunctions.cxx | 243 + .../source/drivers/odbc/OPreparedStatement.cxx | 925 ++++ connectivity/source/drivers/odbc/ORealDriver.cxx | 292 ++ connectivity/source/drivers/odbc/ORealDriver.hxx | 42 + connectivity/source/drivers/odbc/OResultSet.cxx | 1803 ++++++++ .../source/drivers/odbc/OResultSetMetaData.cxx | 291 ++ connectivity/source/drivers/odbc/OStatement.cxx | 1102 +++++ connectivity/source/drivers/odbc/OTools.cxx | 797 ++++ connectivity/source/drivers/odbc/odbc.component | 25 + connectivity/source/drivers/odbc/oservices.cxx | 108 + .../postgresql/postgresql-sdbc-impl.component | 17 + .../drivers/postgresql/postgresql-sdbc.component | 16 + .../source/drivers/postgresql/pq_array.cxx | 122 + .../source/drivers/postgresql/pq_array.hxx | 100 + .../source/drivers/postgresql/pq_baseresultset.cxx | 613 +++ .../source/drivers/postgresql/pq_baseresultset.hxx | 205 + .../source/drivers/postgresql/pq_connection.cxx | 609 +++ .../source/drivers/postgresql/pq_connection.hxx | 197 + .../drivers/postgresql/pq_databasemetadata.cxx | 2510 ++++++++++ .../drivers/postgresql/pq_databasemetadata.hxx | 240 + .../source/drivers/postgresql/pq_driver.cxx | 314 ++ .../source/drivers/postgresql/pq_driver.hxx | 120 + .../postgresql/pq_fakedupdateableresultset.cxx | 214 + .../postgresql/pq_fakedupdateableresultset.hxx | 108 + .../drivers/postgresql/pq_preparedstatement.cxx | 737 +++ .../drivers/postgresql/pq_preparedstatement.hxx | 223 + .../source/drivers/postgresql/pq_resultset.cxx | 308 ++ .../source/drivers/postgresql/pq_resultset.hxx | 96 + .../drivers/postgresql/pq_resultsetmetadata.cxx | 441 ++ .../drivers/postgresql/pq_resultsetmetadata.hxx | 130 + .../drivers/postgresql/pq_sequenceresultset.cxx | 125 + .../drivers/postgresql/pq_sequenceresultset.hxx | 94 + .../postgresql/pq_sequenceresultsetmetadata.cxx | 191 + .../postgresql/pq_sequenceresultsetmetadata.hxx | 92 + .../source/drivers/postgresql/pq_statement.cxx | 891 ++++ .../source/drivers/postgresql/pq_statement.hxx | 195 + .../source/drivers/postgresql/pq_statics.cxx | 672 +++ .../source/drivers/postgresql/pq_statics.hxx | 244 + .../source/drivers/postgresql/pq_tools.cxx | 1247 +++++ .../source/drivers/postgresql/pq_tools.hxx | 169 + .../drivers/postgresql/pq_updateableresultset.cxx | 551 +++ .../drivers/postgresql/pq_updateableresultset.hxx | 172 + .../source/drivers/postgresql/pq_xbase.cxx | 214 + .../source/drivers/postgresql/pq_xbase.hxx | 134 + .../source/drivers/postgresql/pq_xcolumn.cxx | 90 + .../source/drivers/postgresql/pq_xcolumn.hxx | 85 + .../source/drivers/postgresql/pq_xcolumns.cxx | 555 +++ .../source/drivers/postgresql/pq_xcolumns.hxx | 118 + .../source/drivers/postgresql/pq_xcontainer.cxx | 408 ++ .../source/drivers/postgresql/pq_xcontainer.hxx | 188 + .../source/drivers/postgresql/pq_xindex.cxx | 185 + .../source/drivers/postgresql/pq_xindex.hxx | 126 + .../source/drivers/postgresql/pq_xindexcolumn.cxx | 91 + .../source/drivers/postgresql/pq_xindexcolumn.hxx | 86 + .../source/drivers/postgresql/pq_xindexcolumns.cxx | 266 ++ .../source/drivers/postgresql/pq_xindexcolumns.hxx | 112 + .../source/drivers/postgresql/pq_xindexes.cxx | 300 ++ .../source/drivers/postgresql/pq_xindexes.hxx | 104 + connectivity/source/drivers/postgresql/pq_xkey.cxx | 181 + connectivity/source/drivers/postgresql/pq_xkey.hxx | 122 + .../source/drivers/postgresql/pq_xkeycolumn.cxx | 90 + .../source/drivers/postgresql/pq_xkeycolumn.hxx | 85 + .../source/drivers/postgresql/pq_xkeycolumns.cxx | 239 + .../source/drivers/postgresql/pq_xkeycolumns.hxx | 103 + .../source/drivers/postgresql/pq_xkeys.cxx | 290 ++ .../source/drivers/postgresql/pq_xkeys.hxx | 103 + .../source/drivers/postgresql/pq_xtable.cxx | 395 ++ .../source/drivers/postgresql/pq_xtable.hxx | 169 + .../source/drivers/postgresql/pq_xtables.cxx | 369 ++ .../source/drivers/postgresql/pq_xtables.hxx | 87 + .../source/drivers/postgresql/pq_xuser.cxx | 171 + .../source/drivers/postgresql/pq_xuser.hxx | 101 + .../source/drivers/postgresql/pq_xusers.cxx | 201 + .../source/drivers/postgresql/pq_xusers.hxx | 84 + .../source/drivers/postgresql/pq_xview.cxx | 218 + .../source/drivers/postgresql/pq_xview.hxx | 101 + .../source/drivers/postgresql/pq_xviews.cxx | 218 + .../source/drivers/postgresql/pq_xviews.hxx | 84 + connectivity/source/drivers/writer/WCatalog.cxx | 60 + connectivity/source/drivers/writer/WConnection.cxx | 248 + .../source/drivers/writer/WDatabaseMetaData.cxx | 112 + connectivity/source/drivers/writer/WDriver.cxx | 80 + connectivity/source/drivers/writer/WTable.cxx | 253 + connectivity/source/drivers/writer/WTables.cxx | 45 + connectivity/source/drivers/writer/Wservices.cxx | 90 + .../source/drivers/writer/writer.component | 17 + connectivity/source/inc/AutoRetrievingBase.hxx | 51 + .../source/inc/FDatabaseMetaDataResultSet.hxx | 277 ++ .../inc/FDatabaseMetaDataResultSetMetaData.hxx | 98 + connectivity/source/inc/OColumn.hxx | 121 + connectivity/source/inc/OTypeInfo.hxx | 53 + connectivity/source/inc/ParameterSubstitution.hxx | 72 + connectivity/source/inc/RowFunctionParser.hxx | 114 + connectivity/source/inc/TConnection.hxx | 83 + connectivity/source/inc/TDatabaseMetaDataBase.hxx | 135 + connectivity/source/inc/TKeyValue.hxx | 62 + connectivity/source/inc/TPrivilegesResultSet.hxx | 48 + connectivity/source/inc/TResultSetHelper.hxx | 54 + connectivity/source/inc/TSkipDeletedSet.hxx | 82 + connectivity/source/inc/TSortIndex.hxx | 112 + connectivity/source/inc/ado/ACallableStatement.hxx | 81 + connectivity/source/inc/ado/ACatalog.hxx | 54 + connectivity/source/inc/ado/AColumn.hxx | 60 + connectivity/source/inc/ado/AColumns.hxx | 61 + connectivity/source/inc/ado/AConnection.hxx | 138 + connectivity/source/inc/ado/ADatabaseMetaData.hxx | 226 + .../source/inc/ado/ADatabaseMetaDataResultSet.hxx | 230 + .../inc/ado/ADatabaseMetaDataResultSetMetaData.hxx | 107 + connectivity/source/inc/ado/ADriver.hxx | 90 + connectivity/source/inc/ado/AGroup.hxx | 67 + connectivity/source/inc/ado/AGroups.hxx | 57 + connectivity/source/inc/ado/AIndex.hxx | 54 + connectivity/source/inc/ado/AIndexes.hxx | 59 + connectivity/source/inc/ado/AKey.hxx | 64 + connectivity/source/inc/ado/AKeys.hxx | 59 + connectivity/source/inc/ado/APreparedStatement.hxx | 115 + connectivity/source/inc/ado/AResultSet.hxx | 239 + connectivity/source/inc/ado/AResultSetMetaData.hxx | 84 + connectivity/source/inc/ado/AStatement.hxx | 221 + connectivity/source/inc/ado/ATable.hxx | 77 + connectivity/source/inc/ado/ATables.hxx | 57 + connectivity/source/inc/ado/AUser.hxx | 91 + connectivity/source/inc/ado/AUsers.hxx | 59 + connectivity/source/inc/ado/AView.hxx | 57 + connectivity/source/inc/ado/AViews.hxx | 56 + connectivity/source/inc/ado/Aolevariant.hxx | 154 + connectivity/source/inc/ado/Aolewrap.hxx | 225 + connectivity/source/inc/ado/Awrapado.hxx | 376 ++ connectivity/source/inc/ado/Awrapadox.hxx | 138 + connectivity/source/inc/ado/WrapCatalog.hxx | 52 + connectivity/source/inc/ado/WrapColumn.hxx | 64 + connectivity/source/inc/ado/WrapIndex.hxx | 54 + connectivity/source/inc/ado/WrapKey.hxx | 56 + connectivity/source/inc/ado/WrapTable.hxx | 59 + connectivity/source/inc/ado/WrapTypeDefs.hxx | 47 + connectivity/source/inc/ado/adoimp.hxx | 106 + connectivity/source/inc/calc/CCatalog.hxx | 40 + connectivity/source/inc/calc/CConnection.hxx | 150 + connectivity/source/inc/calc/CDatabaseMetaData.hxx | 44 + connectivity/source/inc/calc/CDriver.hxx | 55 + connectivity/source/inc/calc/CTable.hxx | 78 + connectivity/source/inc/calc/CTables.hxx | 42 + connectivity/source/inc/component/CColumns.hxx | 47 + .../source/inc/component/CDatabaseMetaData.hxx | 52 + .../source/inc/component/CPreparedStatement.hxx | 44 + connectivity/source/inc/component/CResultSet.hxx | 84 + connectivity/source/inc/component/CStatement.hxx | 44 + connectivity/source/inc/component/CTable.hxx | 71 + connectivity/source/inc/dbase/DCatalog.hxx | 42 + connectivity/source/inc/dbase/DColumns.hxx | 48 + connectivity/source/inc/dbase/DConnection.hxx | 50 + .../source/inc/dbase/DDatabaseMetaData.hxx | 61 + connectivity/source/inc/dbase/DDriver.hxx | 55 + connectivity/source/inc/dbase/DIndex.hxx | 145 + connectivity/source/inc/dbase/DIndexColumns.hxx | 53 + connectivity/source/inc/dbase/DIndexIter.hxx | 71 + connectivity/source/inc/dbase/DIndexes.hxx | 54 + .../source/inc/dbase/DPreparedStatement.hxx | 43 + connectivity/source/inc/dbase/DResultSet.hxx | 82 + connectivity/source/inc/dbase/DStatement.hxx | 43 + connectivity/source/inc/dbase/DTable.hxx | 198 + connectivity/source/inc/dbase/DTables.hxx | 50 + connectivity/source/inc/dbase/dindexnode.hxx | 314 ++ connectivity/source/inc/file/FCatalog.hxx | 64 + connectivity/source/inc/file/FColumns.hxx | 51 + connectivity/source/inc/file/FConnection.hxx | 135 + connectivity/source/inc/file/FDatabaseMetaData.hxx | 190 + connectivity/source/inc/file/FDateFunctions.hxx | 233 + connectivity/source/inc/file/FDriver.hxx | 82 + connectivity/source/inc/file/FNumericFunctions.hxx | 367 ++ .../source/inc/file/FPreparedStatement.hxx | 125 + connectivity/source/inc/file/FResultSet.hxx | 308 ++ .../source/inc/file/FResultSetMetaData.hxx | 81 + connectivity/source/inc/file/FStatement.hxx | 200 + connectivity/source/inc/file/FStringFunctions.hxx | 274 ++ connectivity/source/inc/file/FTable.hxx | 107 + connectivity/source/inc/file/FTables.hxx | 48 + connectivity/source/inc/file/fanalyzer.hxx | 74 + connectivity/source/inc/file/fcode.hxx | 333 ++ connectivity/source/inc/file/fcomp.hxx | 112 + connectivity/source/inc/file/filedllapi.hxx | 35 + connectivity/source/inc/file/quotedstring.hxx | 49 + connectivity/source/inc/flat/ECatalog.hxx | 42 + connectivity/source/inc/flat/EColumns.hxx | 45 + connectivity/source/inc/flat/EConnection.hxx | 66 + connectivity/source/inc/flat/EDatabaseMetaData.hxx | 48 + connectivity/source/inc/flat/EDriver.hxx | 55 + .../source/inc/flat/EPreparedStatement.hxx | 43 + connectivity/source/inc/flat/EResultSet.hxx | 74 + connectivity/source/inc/flat/EStatement.hxx | 43 + connectivity/source/inc/flat/ETable.hxx | 108 + connectivity/source/inc/flat/ETables.hxx | 44 + connectivity/source/inc/hsqldb/HCatalog.hxx | 64 + connectivity/source/inc/hsqldb/HColumns.hxx | 60 + connectivity/source/inc/hsqldb/HConnection.hxx | 149 + connectivity/source/inc/hsqldb/HDriver.hxx | 139 + connectivity/source/inc/hsqldb/HStorageAccess.hxx | 39 + connectivity/source/inc/hsqldb/HStorageMap.hxx | 97 + connectivity/source/inc/hsqldb/HTable.hxx | 115 + connectivity/source/inc/hsqldb/HTables.hxx | 56 + connectivity/source/inc/hsqldb/HTools.hxx | 52 + connectivity/source/inc/hsqldb/HUser.hxx | 77 + connectivity/source/inc/hsqldb/HUsers.hxx | 55 + connectivity/source/inc/hsqldb/HView.hxx | 91 + connectivity/source/inc/hsqldb/HViews.hxx | 55 + .../source/inc/java/ContextClassLoader.hxx | 82 + connectivity/source/inc/java/GlobalRef.hxx | 105 + connectivity/source/inc/java/LocalRef.hxx | 92 + connectivity/source/inc/java/io/InputStream.hxx | 53 + connectivity/source/inc/java/io/Reader.hxx | 54 + connectivity/source/inc/java/lang/Boolean.hxx | 46 + connectivity/source/inc/java/lang/Class.hxx | 48 + connectivity/source/inc/java/lang/Exception.hxx | 44 + connectivity/source/inc/java/lang/Object.hxx | 149 + connectivity/source/inc/java/lang/String.hxx | 46 + connectivity/source/inc/java/lang/Throwable.hxx | 51 + connectivity/source/inc/java/math/BigDecimal.hxx | 44 + connectivity/source/inc/java/sql/Array.hxx | 56 + connectivity/source/inc/java/sql/Blob.hxx | 56 + .../source/inc/java/sql/CallableStatement.hxx | 84 + connectivity/source/inc/java/sql/Clob.hxx | 56 + connectivity/source/inc/java/sql/Connection.hxx | 137 + connectivity/source/inc/java/sql/ConnectionLog.hxx | 130 + .../source/inc/java/sql/DatabaseMetaData.hxx | 218 + connectivity/source/inc/java/sql/Driver.hxx | 70 + .../source/inc/java/sql/DriverPropertyInfo.hxx | 44 + connectivity/source/inc/java/sql/JStatement.hxx | 236 + .../source/inc/java/sql/PreparedStatement.hxx | 105 + connectivity/source/inc/java/sql/Ref.hxx | 51 + connectivity/source/inc/java/sql/ResultSet.hxx | 212 + .../source/inc/java/sql/ResultSetMetaData.hxx | 72 + connectivity/source/inc/java/sql/SQLException.hxx | 58 + connectivity/source/inc/java/sql/SQLWarning.hxx | 51 + connectivity/source/inc/java/sql/Timestamp.hxx | 90 + connectivity/source/inc/java/tools.hxx | 58 + connectivity/source/inc/java/util/Date.hxx | 47 + connectivity/source/inc/java/util/Property.hxx | 41 + connectivity/source/inc/mysql/YCatalog.hxx | 64 + connectivity/source/inc/mysql/YColumns.hxx | 60 + connectivity/source/inc/mysql/YDriver.hxx | 117 + connectivity/source/inc/mysql/YTable.hxx | 115 + connectivity/source/inc/mysql/YTables.hxx | 66 + connectivity/source/inc/mysql/YUser.hxx | 77 + connectivity/source/inc/mysql/YUsers.hxx | 55 + connectivity/source/inc/mysql/YViews.hxx | 55 + connectivity/source/inc/odbc/OBoundParam.hxx | 131 + connectivity/source/inc/odbc/OConnection.hxx | 129 + connectivity/source/inc/odbc/ODatabaseMetaData.hxx | 207 + .../source/inc/odbc/ODatabaseMetaDataResultSet.hxx | 263 ++ connectivity/source/inc/odbc/ODriver.hxx | 87 + connectivity/source/inc/odbc/OFunctions.hxx | 603 +++ .../source/inc/odbc/OPreparedStatement.hxx | 153 + connectivity/source/inc/odbc/OResultSet.hxx | 358 ++ .../source/inc/odbc/OResultSetMetaData.hxx | 120 + connectivity/source/inc/odbc/OStatement.hxx | 247 + connectivity/source/inc/odbc/OTools.hxx | 250 + connectivity/source/inc/odbc/odbcbasedllapi.hxx | 35 + connectivity/source/inc/propertyids.hxx | 112 + .../source/inc/resource/sharedresources.hxx | 152 + connectivity/source/inc/writer/WCatalog.hxx | 43 + connectivity/source/inc/writer/WConnection.hxx | 169 + .../source/inc/writer/WDatabaseMetaData.hxx | 49 + connectivity/source/inc/writer/WDriver.hxx | 72 + connectivity/source/inc/writer/WTable.hxx | 91 + connectivity/source/inc/writer/WTables.hxx | 49 + connectivity/source/manager/mdrivermanager.cxx | 681 +++ connectivity/source/manager/mdrivermanager.hxx | 135 + connectivity/source/manager/mregistration.cxx | 61 + connectivity/source/manager/sdbc2.component | 25 + connectivity/source/parse/PColumn.cxx | 271 ++ connectivity/source/parse/internalnode.cxx | 64 + connectivity/source/parse/sqlbison.y | 4829 ++++++++++++++++++++ connectivity/source/parse/sqlflex.l | 808 ++++ connectivity/source/parse/sqliterator.cxx | 2102 +++++++++ connectivity/source/parse/sqlnode.cxx | 2787 +++++++++++ connectivity/source/resource/sharedresources.cxx | 191 + connectivity/source/sdbcx/VCatalog.cxx | 211 + connectivity/source/sdbcx/VCollection.cxx | 583 +++ connectivity/source/sdbcx/VColumn.cxx | 220 + connectivity/source/sdbcx/VDescriptor.cxx | 128 + connectivity/source/sdbcx/VGroup.cxx | 166 + connectivity/source/sdbcx/VIndex.cxx | 199 + connectivity/source/sdbcx/VIndexColumn.cxx | 102 + connectivity/source/sdbcx/VKey.cxx | 202 + connectivity/source/sdbcx/VKeyColumn.cxx | 106 + connectivity/source/sdbcx/VTable.cxx | 304 ++ connectivity/source/sdbcx/VUser.cxx | 180 + connectivity/source/sdbcx/VView.cxx | 132 + connectivity/workben/iniParser/main.cxx | 160 + connectivity/workben/iniParser/makefile.mk | 52 + connectivity/workben/little/main.cxx | 101 + connectivity/workben/little/makefile.mk | 50 + connectivity/workben/skeleton/SResultSet.hxx | 239 + .../workben/skeleton/how_to_write_a_driver.txt | 69 + 834 files changed, 181321 insertions(+) create mode 100644 connectivity/AllLangMoTarget_cnr.mk create mode 100644 connectivity/Configuration_ado.mk create mode 100644 connectivity/Configuration_calc.mk create mode 100644 connectivity/Configuration_dbase.mk create mode 100644 connectivity/Configuration_evoab.mk create mode 100644 connectivity/Configuration_firebird.mk create mode 100644 connectivity/Configuration_flat.mk create mode 100644 connectivity/Configuration_hsqldb.mk create mode 100644 connectivity/Configuration_jdbc.mk create mode 100644 connectivity/Configuration_macab.mk create mode 100644 connectivity/Configuration_mork.mk create mode 100644 connectivity/Configuration_mysql.mk create mode 100644 connectivity/Configuration_mysql_jdbc.mk create mode 100644 connectivity/Configuration_odbc.mk create mode 100644 connectivity/Configuration_postgresql.mk create mode 100644 connectivity/Configuration_writer.mk create mode 100644 connectivity/CppunitTest_connectivity_ado.mk create mode 100644 connectivity/CppunitTest_connectivity_commontools.mk create mode 100644 connectivity/CppunitTest_connectivity_mork.mk create mode 100644 connectivity/CppunitTest_connectivity_mysql_test.mk create mode 100644 connectivity/CppunitTest_connectivity_sharedresources.mk create mode 100644 connectivity/Executable_mork_helper.mk create mode 100644 connectivity/IwyuFilter_connectivity.yaml create mode 100644 connectivity/Jar_ConnectivityTools.mk create mode 100644 connectivity/Jar_sdbc_hsqldb.mk create mode 100644 connectivity/JunitTest_complex.mk create mode 100644 connectivity/Library_ado.mk create mode 100644 connectivity/Library_calc.mk create mode 100644 connectivity/Library_dbase.mk create mode 100644 connectivity/Library_dbpool2.mk create mode 100644 connectivity/Library_dbtools.mk create mode 100644 connectivity/Library_evoab.mk create mode 100644 connectivity/Library_file.mk create mode 100644 connectivity/Library_firebird_sdbc.mk create mode 100644 connectivity/Library_flat.mk create mode 100644 connectivity/Library_hsqldb.mk create mode 100644 connectivity/Library_jdbc.mk create mode 100644 connectivity/Library_macab1.mk create mode 100644 connectivity/Library_macabdrv1.mk create mode 100644 connectivity/Library_mork.mk create mode 100644 connectivity/Library_mozbootstrap.mk create mode 100644 connectivity/Library_mysql_jdbc.mk create mode 100644 connectivity/Library_mysqlc.mk create mode 100644 connectivity/Library_odbc.mk create mode 100644 connectivity/Library_postgresql-sdbc-impl.mk create mode 100644 connectivity/Library_postgresql-sdbc.mk create mode 100644 connectivity/Library_sdbc2.mk create mode 100644 connectivity/Library_writer.mk create mode 100644 connectivity/Makefile create mode 100644 connectivity/Module_connectivity.mk create mode 100644 connectivity/Package_postgresql-sdbc.mk create mode 100644 connectivity/README create mode 100644 connectivity/Rdb_postgresql-sdbc.mk create mode 100644 connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java create mode 100644 connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java create mode 100644 connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java create mode 100644 connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java create mode 100644 connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java create mode 100644 connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java create mode 100644 connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java create mode 100644 connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java create mode 100644 connectivity/inc/ParameterCont.hxx create mode 100644 connectivity/inc/SQLStatementHelper.hxx create mode 100644 connectivity/inc/TIndex.hxx create mode 100644 connectivity/inc/TIndexColumns.hxx create mode 100644 connectivity/inc/TKey.hxx create mode 100644 connectivity/inc/TKeyColumns.hxx create mode 100644 connectivity/inc/bitmaps.hlst create mode 100644 connectivity/inc/pch/precompiled_ado.cxx create mode 100644 connectivity/inc/pch/precompiled_ado.hxx create mode 100644 connectivity/inc/pch/precompiled_calc.cxx create mode 100644 connectivity/inc/pch/precompiled_calc.hxx create mode 100644 connectivity/inc/pch/precompiled_dbase.cxx create mode 100644 connectivity/inc/pch/precompiled_dbase.hxx create mode 100644 connectivity/inc/pch/precompiled_dbpool2.cxx create mode 100644 connectivity/inc/pch/precompiled_dbpool2.hxx create mode 100644 connectivity/inc/pch/precompiled_dbtools.cxx create mode 100644 connectivity/inc/pch/precompiled_dbtools.hxx create mode 100644 connectivity/inc/pch/precompiled_file.cxx create mode 100644 connectivity/inc/pch/precompiled_file.hxx create mode 100644 connectivity/inc/pch/precompiled_firebird_sdbc.cxx create mode 100644 connectivity/inc/pch/precompiled_firebird_sdbc.hxx create mode 100644 connectivity/inc/pch/precompiled_flat.cxx create mode 100644 connectivity/inc/pch/precompiled_flat.hxx create mode 100644 connectivity/inc/pch/precompiled_mysql_jdbc.cxx create mode 100644 connectivity/inc/pch/precompiled_mysql_jdbc.hxx create mode 100644 connectivity/inc/pch/precompiled_odbc.cxx create mode 100644 connectivity/inc/pch/precompiled_odbc.hxx create mode 100644 connectivity/inc/pch/precompiled_postgresql-sdbc-impl.cxx create mode 100644 connectivity/inc/pch/precompiled_postgresql-sdbc-impl.hxx create mode 100644 connectivity/inc/sdbcx/VCatalog.hxx create mode 100644 connectivity/inc/sdbcx/VGroup.hxx create mode 100644 connectivity/inc/sdbcx/VIndex.hxx create mode 100644 connectivity/inc/sdbcx/VIndexColumn.hxx create mode 100644 connectivity/inc/sdbcx/VKey.hxx create mode 100644 connectivity/inc/sdbcx/VKeyColumn.hxx create mode 100644 connectivity/inc/sdbcx/VTypeDef.hxx create mode 100644 connectivity/inc/sdbcx/VUser.hxx create mode 100644 connectivity/inc/strings.hrc create mode 100644 connectivity/inc/strings.hxx create mode 100644 connectivity/org/hsqldb/lib/FileSystemRuntimeException.java create mode 100644 connectivity/qa/complex/connectivity/DBaseDriverTest.java create mode 100644 connectivity/qa/complex/connectivity/FlatFileAccess.java create mode 100644 connectivity/qa/complex/connectivity/HsqlDriverTest.java create mode 100644 connectivity/qa/complex/connectivity/JdbcLongVarCharTest.java create mode 100644 connectivity/qa/complex/connectivity/SubTestCase.java create mode 100644 connectivity/qa/complex/connectivity/TestCase.java create mode 100644 connectivity/qa/complex/connectivity/dbase/DBaseDateFunctions.java create mode 100644 connectivity/qa/complex/connectivity/dbase/DBaseNumericFunctions.java create mode 100644 connectivity/qa/complex/connectivity/dbase/DBaseSqlTests.java create mode 100644 connectivity/qa/complex/connectivity/dbase/DBaseStringFunctions.java create mode 100644 connectivity/qa/complex/connectivity/hsqldb/TestCacheSize.java create mode 100644 connectivity/qa/connectivity/ado/DriverTest.cxx create mode 100644 connectivity/qa/connectivity/ado/TS001018407.mdb create mode 100644 connectivity/qa/connectivity/commontools/FValue_test.cxx create mode 100644 connectivity/qa/connectivity/mork/DriverTest.cxx create mode 100644 connectivity/qa/connectivity/mork/abook_10_john_does.mab create mode 100644 connectivity/qa/connectivity/mysql/mysql.cxx create mode 100644 connectivity/qa/connectivity/resource/sharedresources_test.cxx create mode 100644 connectivity/qa/connectivity/tools/AbstractDatabase.java create mode 100644 connectivity/qa/connectivity/tools/CRMDatabase.java create mode 100644 connectivity/qa/connectivity/tools/CsvDatabase.java create mode 100644 connectivity/qa/connectivity/tools/DataSource.java create mode 100644 connectivity/qa/connectivity/tools/DatabaseAccess.java create mode 100644 connectivity/qa/connectivity/tools/DbaseDatabase.java create mode 100644 connectivity/qa/connectivity/tools/FlatFileDatabase.java create mode 100644 connectivity/qa/connectivity/tools/HsqlColumnDescriptor.java create mode 100644 connectivity/qa/connectivity/tools/HsqlDatabase.java create mode 100644 connectivity/qa/connectivity/tools/HsqlTableDescriptor.java create mode 100644 connectivity/qa/connectivity/tools/QueryDefinition.java create mode 100644 connectivity/qa/connectivity/tools/RowSet.java create mode 100644 connectivity/qa/connectivity/tools/sdb/Connection.java create mode 100644 connectivity/qa/scenarios.sce create mode 100644 connectivity/registry/README create mode 100644 connectivity/registry/ado/org/openoffice/Office/DataAccess/Drivers.xcu create mode 100644 connectivity/registry/calc/org/openoffice/Office/DataAccess/Drivers.xcu create mode 100644 connectivity/registry/dbase/org/openoffice/Office/DataAccess/Drivers.xcu create mode 100644 connectivity/registry/evoab2/org/openoffice/Office/DataAccess/Drivers.xcu create mode 100644 connectivity/registry/firebird/org/openoffice/Office/DataAccess/Drivers.xcu create mode 100644 connectivity/registry/flat/org/openoffice/Office/DataAccess/Drivers.xcu create mode 100644 connectivity/registry/hsqldb/org/openoffice/Office/DataAccess/Drivers.xcu create mode 100644 connectivity/registry/jdbc/org/openoffice/Office/DataAccess/Drivers.xcu create mode 100644 connectivity/registry/macab/org/openoffice/Office/DataAccess/Drivers.xcu create mode 100644 connectivity/registry/mork/org/openoffice/Office/DataAccess/Drivers.xcu create mode 100644 connectivity/registry/mysql_jdbc/org/openoffice/Office/DataAccess/Drivers.xcu create mode 100644 connectivity/registry/mysqlc/org/openoffice/Office/DataAccess/Drivers.xcu create mode 100644 connectivity/registry/odbc/org/openoffice/Office/DataAccess/Drivers.xcu create mode 100644 connectivity/registry/postgresql/org/openoffice/Office/DataAccess/Drivers.xcu create mode 100644 connectivity/registry/writer/org/openoffice/Office/DataAccess/Drivers.xcu create mode 100644 connectivity/source/commontools/AutoRetrievingBase.cxx create mode 100644 connectivity/source/commontools/BlobHelper.cxx create mode 100644 connectivity/source/commontools/CommonTools.cxx create mode 100644 connectivity/source/commontools/ConnectionWrapper.cxx create mode 100644 connectivity/source/commontools/DateConversion.cxx create mode 100644 connectivity/source/commontools/DriversConfig.cxx create mode 100644 connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx create mode 100644 connectivity/source/commontools/FDatabaseMetaDataResultSetMetaData.cxx create mode 100644 connectivity/source/commontools/FValue.cxx create mode 100644 connectivity/source/commontools/ParameterSubstitution.cxx create mode 100644 connectivity/source/commontools/RowFunctionParser.cxx create mode 100644 connectivity/source/commontools/TColumnsHelper.cxx create mode 100644 connectivity/source/commontools/TConnection.cxx create mode 100644 connectivity/source/commontools/TDatabaseMetaDataBase.cxx create mode 100644 connectivity/source/commontools/TIndex.cxx create mode 100644 connectivity/source/commontools/TIndexColumns.cxx create mode 100644 connectivity/source/commontools/TIndexes.cxx create mode 100644 connectivity/source/commontools/TKey.cxx create mode 100644 connectivity/source/commontools/TKeyColumns.cxx create mode 100644 connectivity/source/commontools/TKeys.cxx create mode 100644 connectivity/source/commontools/TPrivilegesResultSet.cxx create mode 100644 connectivity/source/commontools/TSkipDeletedSet.cxx create mode 100644 connectivity/source/commontools/TSortIndex.cxx create mode 100644 connectivity/source/commontools/TTableHelper.cxx create mode 100644 connectivity/source/commontools/conncleanup.cxx create mode 100644 connectivity/source/commontools/dbcharset.cxx create mode 100644 connectivity/source/commontools/dbconversion.cxx create mode 100644 connectivity/source/commontools/dbexception.cxx create mode 100644 connectivity/source/commontools/dbmetadata.cxx create mode 100644 connectivity/source/commontools/dbtools.cxx create mode 100644 connectivity/source/commontools/dbtools2.cxx create mode 100644 connectivity/source/commontools/filtermanager.cxx create mode 100644 connectivity/source/commontools/formattedcolumnvalue.cxx create mode 100644 connectivity/source/commontools/parameters.cxx create mode 100644 connectivity/source/commontools/paramwrapper.cxx create mode 100644 connectivity/source/commontools/predicateinput.cxx create mode 100644 connectivity/source/commontools/propertyids.cxx create mode 100644 connectivity/source/commontools/sqlerror.cxx create mode 100644 connectivity/source/commontools/statementcomposer.cxx create mode 100644 connectivity/source/commontools/warningscontainer.cxx create mode 100644 connectivity/source/cpool/ZConnectionPool.cxx create mode 100644 connectivity/source/cpool/ZConnectionPool.hxx create mode 100644 connectivity/source/cpool/ZConnectionWrapper.cxx create mode 100644 connectivity/source/cpool/ZConnectionWrapper.hxx create mode 100644 connectivity/source/cpool/ZDriverWrapper.cxx create mode 100644 connectivity/source/cpool/ZDriverWrapper.hxx create mode 100644 connectivity/source/cpool/ZPoolCollection.cxx create mode 100644 connectivity/source/cpool/ZPoolCollection.hxx create mode 100644 connectivity/source/cpool/ZPooledConnection.cxx create mode 100644 connectivity/source/cpool/ZPooledConnection.hxx create mode 100644 connectivity/source/cpool/Zregistration.cxx create mode 100644 connectivity/source/cpool/dbpool2.component create mode 100644 connectivity/source/dbtools/dbtools.component create mode 100644 connectivity/source/drivers/ado/ACallableStatement.cxx create mode 100644 connectivity/source/drivers/ado/ACatalog.cxx create mode 100644 connectivity/source/drivers/ado/AColumn.cxx create mode 100644 connectivity/source/drivers/ado/AColumns.cxx create mode 100644 connectivity/source/drivers/ado/AConnection.cxx create mode 100644 connectivity/source/drivers/ado/ADatabaseMetaData.cxx create mode 100644 connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx create mode 100644 connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx create mode 100644 connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx create mode 100644 connectivity/source/drivers/ado/ADriver.cxx create mode 100644 connectivity/source/drivers/ado/AGroup.cxx create mode 100644 connectivity/source/drivers/ado/AGroups.cxx create mode 100644 connectivity/source/drivers/ado/AIndex.cxx create mode 100644 connectivity/source/drivers/ado/AIndexes.cxx create mode 100644 connectivity/source/drivers/ado/AKey.cxx create mode 100644 connectivity/source/drivers/ado/AKeys.cxx create mode 100644 connectivity/source/drivers/ado/APreparedStatement.cxx create mode 100644 connectivity/source/drivers/ado/AResultSet.cxx create mode 100644 connectivity/source/drivers/ado/AResultSetMetaData.cxx create mode 100644 connectivity/source/drivers/ado/AStatement.cxx create mode 100644 connectivity/source/drivers/ado/ATable.cxx create mode 100644 connectivity/source/drivers/ado/ATables.cxx create mode 100644 connectivity/source/drivers/ado/AUser.cxx create mode 100644 connectivity/source/drivers/ado/AUsers.cxx create mode 100644 connectivity/source/drivers/ado/AView.cxx create mode 100644 connectivity/source/drivers/ado/AViews.cxx create mode 100644 connectivity/source/drivers/ado/Aolevariant.cxx create mode 100644 connectivity/source/drivers/ado/Aservices.cxx create mode 100644 connectivity/source/drivers/ado/Awrapado.cxx create mode 100644 connectivity/source/drivers/ado/ado.component create mode 100644 connectivity/source/drivers/ado/adoimp.cxx create mode 100644 connectivity/source/drivers/calc/CCatalog.cxx create mode 100644 connectivity/source/drivers/calc/CConnection.cxx create mode 100644 connectivity/source/drivers/calc/CDatabaseMetaData.cxx create mode 100644 connectivity/source/drivers/calc/CDriver.cxx create mode 100644 connectivity/source/drivers/calc/CTable.cxx create mode 100644 connectivity/source/drivers/calc/CTables.cxx create mode 100644 connectivity/source/drivers/calc/Cservices.cxx create mode 100644 connectivity/source/drivers/calc/calc.component create mode 100644 connectivity/source/drivers/component/CColumns.cxx create mode 100644 connectivity/source/drivers/component/CDatabaseMetaData.cxx create mode 100644 connectivity/source/drivers/component/CPreparedStatement.cxx create mode 100644 connectivity/source/drivers/component/CResultSet.cxx create mode 100644 connectivity/source/drivers/component/CStatement.cxx create mode 100644 connectivity/source/drivers/component/CTable.cxx create mode 100644 connectivity/source/drivers/dbase/DCatalog.cxx create mode 100644 connectivity/source/drivers/dbase/DColumns.cxx create mode 100644 connectivity/source/drivers/dbase/DConnection.cxx create mode 100644 connectivity/source/drivers/dbase/DDatabaseMetaData.cxx create mode 100644 connectivity/source/drivers/dbase/DDriver.cxx create mode 100644 connectivity/source/drivers/dbase/DIndex.cxx create mode 100644 connectivity/source/drivers/dbase/DIndexColumns.cxx create mode 100644 connectivity/source/drivers/dbase/DIndexIter.cxx create mode 100644 connectivity/source/drivers/dbase/DIndexes.cxx create mode 100644 connectivity/source/drivers/dbase/DPreparedStatement.cxx create mode 100644 connectivity/source/drivers/dbase/DResultSet.cxx create mode 100644 connectivity/source/drivers/dbase/DStatement.cxx create mode 100644 connectivity/source/drivers/dbase/DTable.cxx create mode 100644 connectivity/source/drivers/dbase/DTables.cxx create mode 100644 connectivity/source/drivers/dbase/Dservices.cxx create mode 100644 connectivity/source/drivers/dbase/dbase.component create mode 100644 connectivity/source/drivers/dbase/dindexnode.cxx create mode 100644 connectivity/source/drivers/evoab2/EApi.cxx create mode 100644 connectivity/source/drivers/evoab2/EApi.h create mode 100644 connectivity/source/drivers/evoab2/NCatalog.cxx create mode 100644 connectivity/source/drivers/evoab2/NCatalog.hxx create mode 100644 connectivity/source/drivers/evoab2/NColumns.cxx create mode 100644 connectivity/source/drivers/evoab2/NColumns.hxx create mode 100644 connectivity/source/drivers/evoab2/NConnection.cxx create mode 100644 connectivity/source/drivers/evoab2/NConnection.hxx create mode 100644 connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx create mode 100644 connectivity/source/drivers/evoab2/NDatabaseMetaData.hxx create mode 100644 connectivity/source/drivers/evoab2/NDriver.cxx create mode 100644 connectivity/source/drivers/evoab2/NDriver.hxx create mode 100644 connectivity/source/drivers/evoab2/NPreparedStatement.cxx create mode 100644 connectivity/source/drivers/evoab2/NPreparedStatement.hxx create mode 100644 connectivity/source/drivers/evoab2/NResultSet.cxx create mode 100644 connectivity/source/drivers/evoab2/NResultSet.hxx create mode 100644 connectivity/source/drivers/evoab2/NResultSetMetaData.cxx create mode 100644 connectivity/source/drivers/evoab2/NResultSetMetaData.hxx create mode 100644 connectivity/source/drivers/evoab2/NServices.cxx create mode 100644 connectivity/source/drivers/evoab2/NStatement.cxx create mode 100644 connectivity/source/drivers/evoab2/NStatement.hxx create mode 100644 connectivity/source/drivers/evoab2/NTable.cxx create mode 100644 connectivity/source/drivers/evoab2/NTable.hxx create mode 100644 connectivity/source/drivers/evoab2/NTables.cxx create mode 100644 connectivity/source/drivers/evoab2/NTables.hxx create mode 100644 connectivity/source/drivers/evoab2/evoab.component create mode 100644 connectivity/source/drivers/file/FCatalog.cxx create mode 100644 connectivity/source/drivers/file/FColumns.cxx create mode 100644 connectivity/source/drivers/file/FConnection.cxx create mode 100644 connectivity/source/drivers/file/FDatabaseMetaData.cxx create mode 100644 connectivity/source/drivers/file/FDateFunctions.cxx create mode 100644 connectivity/source/drivers/file/FDriver.cxx create mode 100644 connectivity/source/drivers/file/FNoException.cxx create mode 100644 connectivity/source/drivers/file/FNumericFunctions.cxx create mode 100644 connectivity/source/drivers/file/FPreparedStatement.cxx create mode 100644 connectivity/source/drivers/file/FResultSet.cxx create mode 100644 connectivity/source/drivers/file/FResultSetMetaData.cxx create mode 100644 connectivity/source/drivers/file/FStatement.cxx create mode 100644 connectivity/source/drivers/file/FStringFunctions.cxx create mode 100644 connectivity/source/drivers/file/FTable.cxx create mode 100644 connectivity/source/drivers/file/FTables.cxx create mode 100644 connectivity/source/drivers/file/fanalyzer.cxx create mode 100644 connectivity/source/drivers/file/fcode.cxx create mode 100644 connectivity/source/drivers/file/fcomp.cxx create mode 100644 connectivity/source/drivers/file/quotedstring.cxx create mode 100644 connectivity/source/drivers/firebird/Blob.cxx create mode 100644 connectivity/source/drivers/firebird/Blob.hxx create mode 100644 connectivity/source/drivers/firebird/Catalog.cxx create mode 100644 connectivity/source/drivers/firebird/Catalog.hxx create mode 100644 connectivity/source/drivers/firebird/Clob.cxx create mode 100644 connectivity/source/drivers/firebird/Clob.hxx create mode 100644 connectivity/source/drivers/firebird/Column.cxx create mode 100644 connectivity/source/drivers/firebird/Column.hxx create mode 100644 connectivity/source/drivers/firebird/Columns.cxx create mode 100644 connectivity/source/drivers/firebird/Columns.hxx create mode 100644 connectivity/source/drivers/firebird/Connection.cxx create mode 100644 connectivity/source/drivers/firebird/Connection.hxx create mode 100644 connectivity/source/drivers/firebird/DatabaseMetaData.cxx create mode 100644 connectivity/source/drivers/firebird/DatabaseMetaData.hxx create mode 100644 connectivity/source/drivers/firebird/Driver.cxx create mode 100644 connectivity/source/drivers/firebird/Driver.hxx create mode 100644 connectivity/source/drivers/firebird/Indexes.cxx create mode 100644 connectivity/source/drivers/firebird/Indexes.hxx create mode 100644 connectivity/source/drivers/firebird/Keys.cxx create mode 100644 connectivity/source/drivers/firebird/Keys.hxx create mode 100644 connectivity/source/drivers/firebird/PreparedStatement.cxx create mode 100644 connectivity/source/drivers/firebird/PreparedStatement.hxx create mode 100644 connectivity/source/drivers/firebird/ResultSet.cxx create mode 100644 connectivity/source/drivers/firebird/ResultSet.hxx create mode 100644 connectivity/source/drivers/firebird/ResultSetMetaData.cxx create mode 100644 connectivity/source/drivers/firebird/ResultSetMetaData.hxx create mode 100644 connectivity/source/drivers/firebird/Services.cxx create mode 100644 connectivity/source/drivers/firebird/Statement.cxx create mode 100644 connectivity/source/drivers/firebird/Statement.hxx create mode 100644 connectivity/source/drivers/firebird/StatementCommonBase.cxx create mode 100644 connectivity/source/drivers/firebird/StatementCommonBase.hxx create mode 100644 connectivity/source/drivers/firebird/SubComponent.hxx create mode 100644 connectivity/source/drivers/firebird/Table.cxx create mode 100644 connectivity/source/drivers/firebird/Table.hxx create mode 100644 connectivity/source/drivers/firebird/Tables.cxx create mode 100644 connectivity/source/drivers/firebird/Tables.hxx create mode 100644 connectivity/source/drivers/firebird/User.cxx create mode 100644 connectivity/source/drivers/firebird/User.hxx create mode 100644 connectivity/source/drivers/firebird/Users.cxx create mode 100644 connectivity/source/drivers/firebird/Users.hxx create mode 100644 connectivity/source/drivers/firebird/Util.cxx create mode 100644 connectivity/source/drivers/firebird/Util.hxx create mode 100644 connectivity/source/drivers/firebird/firebird_sdbc.component create mode 100644 connectivity/source/drivers/flat/ECatalog.cxx create mode 100644 connectivity/source/drivers/flat/EColumns.cxx create mode 100644 connectivity/source/drivers/flat/EConnection.cxx create mode 100644 connectivity/source/drivers/flat/EDatabaseMetaData.cxx create mode 100644 connectivity/source/drivers/flat/EDriver.cxx create mode 100644 connectivity/source/drivers/flat/EPreparedStatement.cxx create mode 100644 connectivity/source/drivers/flat/EResultSet.cxx create mode 100644 connectivity/source/drivers/flat/EStatement.cxx create mode 100644 connectivity/source/drivers/flat/ETable.cxx create mode 100644 connectivity/source/drivers/flat/ETables.cxx create mode 100644 connectivity/source/drivers/flat/Eservices.cxx create mode 100644 connectivity/source/drivers/flat/flat.component create mode 100644 connectivity/source/drivers/hsqldb/HCatalog.cxx create mode 100644 connectivity/source/drivers/hsqldb/HColumns.cxx create mode 100644 connectivity/source/drivers/hsqldb/HConnection.cxx create mode 100644 connectivity/source/drivers/hsqldb/HDriver.cxx create mode 100644 connectivity/source/drivers/hsqldb/HStorageAccess.cxx create mode 100644 connectivity/source/drivers/hsqldb/HStorageMap.cxx create mode 100644 connectivity/source/drivers/hsqldb/HTable.cxx create mode 100644 connectivity/source/drivers/hsqldb/HTables.cxx create mode 100644 connectivity/source/drivers/hsqldb/HTerminateListener.cxx create mode 100644 connectivity/source/drivers/hsqldb/HTerminateListener.hxx create mode 100644 connectivity/source/drivers/hsqldb/HTools.cxx create mode 100644 connectivity/source/drivers/hsqldb/HUser.cxx create mode 100644 connectivity/source/drivers/hsqldb/HUsers.cxx create mode 100644 connectivity/source/drivers/hsqldb/HView.cxx create mode 100644 connectivity/source/drivers/hsqldb/HViews.cxx create mode 100644 connectivity/source/drivers/hsqldb/Hservices.cxx create mode 100644 connectivity/source/drivers/hsqldb/StorageFileAccess.cxx create mode 100644 connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx create mode 100644 connectivity/source/drivers/hsqldb/StorageNativeOutputStream.cxx create mode 100644 connectivity/source/drivers/hsqldb/accesslog.cxx create mode 100644 connectivity/source/drivers/hsqldb/accesslog.hxx create mode 100644 connectivity/source/drivers/hsqldb/hsqldb.component create mode 100644 connectivity/source/drivers/jdbc/Array.cxx create mode 100644 connectivity/source/drivers/jdbc/Blob.cxx create mode 100644 connectivity/source/drivers/jdbc/Boolean.cxx create mode 100644 connectivity/source/drivers/jdbc/CallableStatement.cxx create mode 100644 connectivity/source/drivers/jdbc/Class.cxx create mode 100644 connectivity/source/drivers/jdbc/Clob.cxx create mode 100644 connectivity/source/drivers/jdbc/ConnectionLog.cxx create mode 100644 connectivity/source/drivers/jdbc/ContextClassLoader.cxx create mode 100644 connectivity/source/drivers/jdbc/DatabaseMetaData.cxx create mode 100644 connectivity/source/drivers/jdbc/Date.cxx create mode 100644 connectivity/source/drivers/jdbc/DriverPropertyInfo.cxx create mode 100644 connectivity/source/drivers/jdbc/Exception.cxx create mode 100644 connectivity/source/drivers/jdbc/InputStream.cxx create mode 100644 connectivity/source/drivers/jdbc/JBigDecimal.cxx create mode 100644 connectivity/source/drivers/jdbc/JConnection.cxx create mode 100644 connectivity/source/drivers/jdbc/JDriver.cxx create mode 100644 connectivity/source/drivers/jdbc/JStatement.cxx create mode 100644 connectivity/source/drivers/jdbc/Object.cxx create mode 100644 connectivity/source/drivers/jdbc/PreparedStatement.cxx create mode 100644 connectivity/source/drivers/jdbc/Reader.cxx create mode 100644 connectivity/source/drivers/jdbc/Ref.cxx create mode 100644 connectivity/source/drivers/jdbc/ResultSet.cxx create mode 100644 connectivity/source/drivers/jdbc/ResultSetMetaData.cxx create mode 100644 connectivity/source/drivers/jdbc/SQLException.cxx create mode 100644 connectivity/source/drivers/jdbc/SQLWarning.cxx create mode 100644 connectivity/source/drivers/jdbc/String.cxx create mode 100644 connectivity/source/drivers/jdbc/Throwable.cxx create mode 100644 connectivity/source/drivers/jdbc/Timestamp.cxx create mode 100644 connectivity/source/drivers/jdbc/jdbc.component create mode 100644 connectivity/source/drivers/jdbc/jservices.cxx create mode 100644 connectivity/source/drivers/jdbc/tools.cxx create mode 100644 connectivity/source/drivers/macab/MacabAddressBook.cxx create mode 100644 connectivity/source/drivers/macab/MacabAddressBook.hxx create mode 100644 connectivity/source/drivers/macab/MacabCatalog.cxx create mode 100644 connectivity/source/drivers/macab/MacabCatalog.hxx create mode 100644 connectivity/source/drivers/macab/MacabColumns.cxx create mode 100644 connectivity/source/drivers/macab/MacabColumns.hxx create mode 100644 connectivity/source/drivers/macab/MacabConnection.cxx create mode 100644 connectivity/source/drivers/macab/MacabConnection.hxx create mode 100644 connectivity/source/drivers/macab/MacabDatabaseMetaData.cxx create mode 100644 connectivity/source/drivers/macab/MacabDatabaseMetaData.hxx create mode 100644 connectivity/source/drivers/macab/MacabDriver.cxx create mode 100644 connectivity/source/drivers/macab/MacabDriver.hxx create mode 100644 connectivity/source/drivers/macab/MacabGroup.cxx create mode 100644 connectivity/source/drivers/macab/MacabGroup.hxx create mode 100644 connectivity/source/drivers/macab/MacabHeader.cxx create mode 100644 connectivity/source/drivers/macab/MacabHeader.hxx create mode 100644 connectivity/source/drivers/macab/MacabPreparedStatement.cxx create mode 100644 connectivity/source/drivers/macab/MacabPreparedStatement.hxx create mode 100644 connectivity/source/drivers/macab/MacabRecord.cxx create mode 100644 connectivity/source/drivers/macab/MacabRecord.hxx create mode 100644 connectivity/source/drivers/macab/MacabRecords.cxx create mode 100644 connectivity/source/drivers/macab/MacabRecords.hxx create mode 100644 connectivity/source/drivers/macab/MacabResultSet.cxx create mode 100644 connectivity/source/drivers/macab/MacabResultSet.hxx create mode 100644 connectivity/source/drivers/macab/MacabResultSetMetaData.cxx create mode 100644 connectivity/source/drivers/macab/MacabResultSetMetaData.hxx create mode 100644 connectivity/source/drivers/macab/MacabServices.cxx create mode 100644 connectivity/source/drivers/macab/MacabStatement.cxx create mode 100644 connectivity/source/drivers/macab/MacabStatement.hxx create mode 100644 connectivity/source/drivers/macab/MacabTable.cxx create mode 100644 connectivity/source/drivers/macab/MacabTable.hxx create mode 100644 connectivity/source/drivers/macab/MacabTables.cxx create mode 100644 connectivity/source/drivers/macab/MacabTables.hxx create mode 100644 connectivity/source/drivers/macab/macab1.component create mode 100644 connectivity/source/drivers/macab/macabcondition.cxx create mode 100644 connectivity/source/drivers/macab/macabcondition.hxx create mode 100644 connectivity/source/drivers/macab/macaborder.cxx create mode 100644 connectivity/source/drivers/macab/macaborder.hxx create mode 100644 connectivity/source/drivers/macab/macabutilities.hxx create mode 100644 connectivity/source/drivers/mork/MCatalog.cxx create mode 100644 connectivity/source/drivers/mork/MCatalog.hxx create mode 100644 connectivity/source/drivers/mork/MColumnAlias.cxx create mode 100644 connectivity/source/drivers/mork/MColumnAlias.hxx create mode 100644 connectivity/source/drivers/mork/MColumns.cxx create mode 100644 connectivity/source/drivers/mork/MColumns.hxx create mode 100644 connectivity/source/drivers/mork/MConnection.cxx create mode 100644 connectivity/source/drivers/mork/MConnection.hxx create mode 100644 connectivity/source/drivers/mork/MDatabaseMetaData.cxx create mode 100644 connectivity/source/drivers/mork/MDatabaseMetaData.hxx create mode 100644 connectivity/source/drivers/mork/MDatabaseMetaDataHelper.cxx create mode 100644 connectivity/source/drivers/mork/MDatabaseMetaDataHelper.hxx create mode 100644 connectivity/source/drivers/mork/MDriver.cxx create mode 100644 connectivity/source/drivers/mork/MDriver.hxx create mode 100644 connectivity/source/drivers/mork/MErrorResource.hxx create mode 100644 connectivity/source/drivers/mork/MPreparedStatement.cxx create mode 100644 connectivity/source/drivers/mork/MPreparedStatement.hxx create mode 100644 connectivity/source/drivers/mork/MQueryHelper.cxx create mode 100644 connectivity/source/drivers/mork/MQueryHelper.hxx create mode 100644 connectivity/source/drivers/mork/MResultSet.cxx create mode 100644 connectivity/source/drivers/mork/MResultSet.hxx create mode 100644 connectivity/source/drivers/mork/MResultSetMetaData.cxx create mode 100644 connectivity/source/drivers/mork/MResultSetMetaData.hxx create mode 100644 connectivity/source/drivers/mork/MStatement.cxx create mode 100644 connectivity/source/drivers/mork/MStatement.hxx create mode 100644 connectivity/source/drivers/mork/MTable.cxx create mode 100644 connectivity/source/drivers/mork/MTable.hxx create mode 100644 connectivity/source/drivers/mork/MTables.cxx create mode 100644 connectivity/source/drivers/mork/MTables.hxx create mode 100644 connectivity/source/drivers/mork/MorkParser.cxx create mode 100644 connectivity/source/drivers/mork/MorkParser.hxx create mode 100644 connectivity/source/drivers/mork/README create mode 100644 connectivity/source/drivers/mork/dllapi.h create mode 100644 connectivity/source/drivers/mork/license.txt create mode 100644 connectivity/source/drivers/mork/mork.component create mode 100644 connectivity/source/drivers/mork/mork_helper.cxx create mode 100644 connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx create mode 100644 connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx create mode 100644 connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx create mode 100644 connectivity/source/drivers/mozab/bootstrap/MNSFolders.hxx create mode 100644 connectivity/source/drivers/mozab/bootstrap/MNSINIParser.cxx create mode 100644 connectivity/source/drivers/mozab/bootstrap/MNSINIParser.hxx create mode 100644 connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx create mode 100644 connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx create mode 100644 connectivity/source/drivers/mozab/bootstrap/mozbootstrap.component create mode 100644 connectivity/source/drivers/mysql_jdbc/YCatalog.cxx create mode 100644 connectivity/source/drivers/mysql_jdbc/YColumns.cxx create mode 100644 connectivity/source/drivers/mysql_jdbc/YDriver.cxx create mode 100644 connectivity/source/drivers/mysql_jdbc/YTable.cxx create mode 100644 connectivity/source/drivers/mysql_jdbc/YTables.cxx create mode 100644 connectivity/source/drivers/mysql_jdbc/YUser.cxx create mode 100644 connectivity/source/drivers/mysql_jdbc/YUsers.cxx create mode 100644 connectivity/source/drivers/mysql_jdbc/YViews.cxx create mode 100644 connectivity/source/drivers/mysql_jdbc/Yservices.cxx create mode 100644 connectivity/source/drivers/mysql_jdbc/mysql_jdbc.component create mode 100644 connectivity/source/drivers/mysqlc/DataAccess.xcu create mode 100644 connectivity/source/drivers/mysqlc/mysqlc.component create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_connection.cxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_connection.hxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.hxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_driver.cxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_driver.hxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_general.cxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_general.hxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.hxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.hxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_propertyids.hxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_resultsetmetadata.cxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_resultsetmetadata.hxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_services.cxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_statement.cxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_statement.hxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_subcomponent.hxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_types.cxx create mode 100644 connectivity/source/drivers/mysqlc/mysqlc_types.hxx create mode 100644 connectivity/source/drivers/odbc/OConnection.cxx create mode 100644 connectivity/source/drivers/odbc/ODatabaseMetaData.cxx create mode 100644 connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx create mode 100644 connectivity/source/drivers/odbc/ODriver.cxx create mode 100644 connectivity/source/drivers/odbc/OFunctions.cxx create mode 100644 connectivity/source/drivers/odbc/OPreparedStatement.cxx create mode 100644 connectivity/source/drivers/odbc/ORealDriver.cxx create mode 100644 connectivity/source/drivers/odbc/ORealDriver.hxx create mode 100644 connectivity/source/drivers/odbc/OResultSet.cxx create mode 100644 connectivity/source/drivers/odbc/OResultSetMetaData.cxx create mode 100644 connectivity/source/drivers/odbc/OStatement.cxx create mode 100644 connectivity/source/drivers/odbc/OTools.cxx create mode 100644 connectivity/source/drivers/odbc/odbc.component create mode 100644 connectivity/source/drivers/odbc/oservices.cxx create mode 100644 connectivity/source/drivers/postgresql/postgresql-sdbc-impl.component create mode 100644 connectivity/source/drivers/postgresql/postgresql-sdbc.component create mode 100644 connectivity/source/drivers/postgresql/pq_array.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_array.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_baseresultset.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_baseresultset.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_connection.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_connection.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_databasemetadata.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_databasemetadata.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_driver.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_driver.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_fakedupdateableresultset.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_fakedupdateableresultset.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_preparedstatement.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_preparedstatement.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_resultset.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_resultset.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_resultsetmetadata.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_sequenceresultset.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_sequenceresultset.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_sequenceresultsetmetadata.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_sequenceresultsetmetadata.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_statement.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_statement.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_statics.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_statics.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_tools.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_tools.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_updateableresultset.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_updateableresultset.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_xbase.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_xbase.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_xcolumn.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_xcolumn.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_xcolumns.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_xcolumns.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_xcontainer.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_xcontainer.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_xindex.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_xindex.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_xindexcolumn.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_xindexcolumn.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_xindexcolumns.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_xindexes.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_xindexes.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_xkey.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_xkey.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_xkeycolumn.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_xkeycolumn.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_xkeycolumns.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_xkeys.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_xkeys.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_xtable.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_xtable.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_xtables.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_xtables.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_xuser.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_xuser.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_xusers.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_xusers.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_xview.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_xview.hxx create mode 100644 connectivity/source/drivers/postgresql/pq_xviews.cxx create mode 100644 connectivity/source/drivers/postgresql/pq_xviews.hxx create mode 100644 connectivity/source/drivers/writer/WCatalog.cxx create mode 100644 connectivity/source/drivers/writer/WConnection.cxx create mode 100644 connectivity/source/drivers/writer/WDatabaseMetaData.cxx create mode 100644 connectivity/source/drivers/writer/WDriver.cxx create mode 100644 connectivity/source/drivers/writer/WTable.cxx create mode 100644 connectivity/source/drivers/writer/WTables.cxx create mode 100644 connectivity/source/drivers/writer/Wservices.cxx create mode 100644 connectivity/source/drivers/writer/writer.component create mode 100644 connectivity/source/inc/AutoRetrievingBase.hxx create mode 100644 connectivity/source/inc/FDatabaseMetaDataResultSet.hxx create mode 100644 connectivity/source/inc/FDatabaseMetaDataResultSetMetaData.hxx create mode 100644 connectivity/source/inc/OColumn.hxx create mode 100644 connectivity/source/inc/OTypeInfo.hxx create mode 100644 connectivity/source/inc/ParameterSubstitution.hxx create mode 100644 connectivity/source/inc/RowFunctionParser.hxx create mode 100644 connectivity/source/inc/TConnection.hxx create mode 100644 connectivity/source/inc/TDatabaseMetaDataBase.hxx create mode 100644 connectivity/source/inc/TKeyValue.hxx create mode 100644 connectivity/source/inc/TPrivilegesResultSet.hxx create mode 100644 connectivity/source/inc/TResultSetHelper.hxx create mode 100644 connectivity/source/inc/TSkipDeletedSet.hxx create mode 100644 connectivity/source/inc/TSortIndex.hxx create mode 100644 connectivity/source/inc/ado/ACallableStatement.hxx create mode 100644 connectivity/source/inc/ado/ACatalog.hxx create mode 100644 connectivity/source/inc/ado/AColumn.hxx create mode 100644 connectivity/source/inc/ado/AColumns.hxx create mode 100644 connectivity/source/inc/ado/AConnection.hxx create mode 100644 connectivity/source/inc/ado/ADatabaseMetaData.hxx create mode 100644 connectivity/source/inc/ado/ADatabaseMetaDataResultSet.hxx create mode 100644 connectivity/source/inc/ado/ADatabaseMetaDataResultSetMetaData.hxx create mode 100644 connectivity/source/inc/ado/ADriver.hxx create mode 100644 connectivity/source/inc/ado/AGroup.hxx create mode 100644 connectivity/source/inc/ado/AGroups.hxx create mode 100644 connectivity/source/inc/ado/AIndex.hxx create mode 100644 connectivity/source/inc/ado/AIndexes.hxx create mode 100644 connectivity/source/inc/ado/AKey.hxx create mode 100644 connectivity/source/inc/ado/AKeys.hxx create mode 100644 connectivity/source/inc/ado/APreparedStatement.hxx create mode 100644 connectivity/source/inc/ado/AResultSet.hxx create mode 100644 connectivity/source/inc/ado/AResultSetMetaData.hxx create mode 100644 connectivity/source/inc/ado/AStatement.hxx create mode 100644 connectivity/source/inc/ado/ATable.hxx create mode 100644 connectivity/source/inc/ado/ATables.hxx create mode 100644 connectivity/source/inc/ado/AUser.hxx create mode 100644 connectivity/source/inc/ado/AUsers.hxx create mode 100644 connectivity/source/inc/ado/AView.hxx create mode 100644 connectivity/source/inc/ado/AViews.hxx create mode 100644 connectivity/source/inc/ado/Aolevariant.hxx create mode 100644 connectivity/source/inc/ado/Aolewrap.hxx create mode 100644 connectivity/source/inc/ado/Awrapado.hxx create mode 100644 connectivity/source/inc/ado/Awrapadox.hxx create mode 100644 connectivity/source/inc/ado/WrapCatalog.hxx create mode 100644 connectivity/source/inc/ado/WrapColumn.hxx create mode 100644 connectivity/source/inc/ado/WrapIndex.hxx create mode 100644 connectivity/source/inc/ado/WrapKey.hxx create mode 100644 connectivity/source/inc/ado/WrapTable.hxx create mode 100644 connectivity/source/inc/ado/WrapTypeDefs.hxx create mode 100644 connectivity/source/inc/ado/adoimp.hxx create mode 100644 connectivity/source/inc/calc/CCatalog.hxx create mode 100644 connectivity/source/inc/calc/CConnection.hxx create mode 100644 connectivity/source/inc/calc/CDatabaseMetaData.hxx create mode 100644 connectivity/source/inc/calc/CDriver.hxx create mode 100644 connectivity/source/inc/calc/CTable.hxx create mode 100644 connectivity/source/inc/calc/CTables.hxx create mode 100644 connectivity/source/inc/component/CColumns.hxx create mode 100644 connectivity/source/inc/component/CDatabaseMetaData.hxx create mode 100644 connectivity/source/inc/component/CPreparedStatement.hxx create mode 100644 connectivity/source/inc/component/CResultSet.hxx create mode 100644 connectivity/source/inc/component/CStatement.hxx create mode 100644 connectivity/source/inc/component/CTable.hxx create mode 100644 connectivity/source/inc/dbase/DCatalog.hxx create mode 100644 connectivity/source/inc/dbase/DColumns.hxx create mode 100644 connectivity/source/inc/dbase/DConnection.hxx create mode 100644 connectivity/source/inc/dbase/DDatabaseMetaData.hxx create mode 100644 connectivity/source/inc/dbase/DDriver.hxx create mode 100644 connectivity/source/inc/dbase/DIndex.hxx create mode 100644 connectivity/source/inc/dbase/DIndexColumns.hxx create mode 100644 connectivity/source/inc/dbase/DIndexIter.hxx create mode 100644 connectivity/source/inc/dbase/DIndexes.hxx create mode 100644 connectivity/source/inc/dbase/DPreparedStatement.hxx create mode 100644 connectivity/source/inc/dbase/DResultSet.hxx create mode 100644 connectivity/source/inc/dbase/DStatement.hxx create mode 100644 connectivity/source/inc/dbase/DTable.hxx create mode 100644 connectivity/source/inc/dbase/DTables.hxx create mode 100644 connectivity/source/inc/dbase/dindexnode.hxx create mode 100644 connectivity/source/inc/file/FCatalog.hxx create mode 100644 connectivity/source/inc/file/FColumns.hxx create mode 100644 connectivity/source/inc/file/FConnection.hxx create mode 100644 connectivity/source/inc/file/FDatabaseMetaData.hxx create mode 100644 connectivity/source/inc/file/FDateFunctions.hxx create mode 100644 connectivity/source/inc/file/FDriver.hxx create mode 100644 connectivity/source/inc/file/FNumericFunctions.hxx create mode 100644 connectivity/source/inc/file/FPreparedStatement.hxx create mode 100644 connectivity/source/inc/file/FResultSet.hxx create mode 100644 connectivity/source/inc/file/FResultSetMetaData.hxx create mode 100644 connectivity/source/inc/file/FStatement.hxx create mode 100644 connectivity/source/inc/file/FStringFunctions.hxx create mode 100644 connectivity/source/inc/file/FTable.hxx create mode 100644 connectivity/source/inc/file/FTables.hxx create mode 100644 connectivity/source/inc/file/fanalyzer.hxx create mode 100644 connectivity/source/inc/file/fcode.hxx create mode 100644 connectivity/source/inc/file/fcomp.hxx create mode 100644 connectivity/source/inc/file/filedllapi.hxx create mode 100644 connectivity/source/inc/file/quotedstring.hxx create mode 100644 connectivity/source/inc/flat/ECatalog.hxx create mode 100644 connectivity/source/inc/flat/EColumns.hxx create mode 100644 connectivity/source/inc/flat/EConnection.hxx create mode 100644 connectivity/source/inc/flat/EDatabaseMetaData.hxx create mode 100644 connectivity/source/inc/flat/EDriver.hxx create mode 100644 connectivity/source/inc/flat/EPreparedStatement.hxx create mode 100644 connectivity/source/inc/flat/EResultSet.hxx create mode 100644 connectivity/source/inc/flat/EStatement.hxx create mode 100644 connectivity/source/inc/flat/ETable.hxx create mode 100644 connectivity/source/inc/flat/ETables.hxx create mode 100644 connectivity/source/inc/hsqldb/HCatalog.hxx create mode 100644 connectivity/source/inc/hsqldb/HColumns.hxx create mode 100644 connectivity/source/inc/hsqldb/HConnection.hxx create mode 100644 connectivity/source/inc/hsqldb/HDriver.hxx create mode 100644 connectivity/source/inc/hsqldb/HStorageAccess.hxx create mode 100644 connectivity/source/inc/hsqldb/HStorageMap.hxx create mode 100644 connectivity/source/inc/hsqldb/HTable.hxx create mode 100644 connectivity/source/inc/hsqldb/HTables.hxx create mode 100644 connectivity/source/inc/hsqldb/HTools.hxx create mode 100644 connectivity/source/inc/hsqldb/HUser.hxx create mode 100644 connectivity/source/inc/hsqldb/HUsers.hxx create mode 100644 connectivity/source/inc/hsqldb/HView.hxx create mode 100644 connectivity/source/inc/hsqldb/HViews.hxx create mode 100644 connectivity/source/inc/java/ContextClassLoader.hxx create mode 100644 connectivity/source/inc/java/GlobalRef.hxx create mode 100644 connectivity/source/inc/java/LocalRef.hxx create mode 100644 connectivity/source/inc/java/io/InputStream.hxx create mode 100644 connectivity/source/inc/java/io/Reader.hxx create mode 100644 connectivity/source/inc/java/lang/Boolean.hxx create mode 100644 connectivity/source/inc/java/lang/Class.hxx create mode 100644 connectivity/source/inc/java/lang/Exception.hxx create mode 100644 connectivity/source/inc/java/lang/Object.hxx create mode 100644 connectivity/source/inc/java/lang/String.hxx create mode 100644 connectivity/source/inc/java/lang/Throwable.hxx create mode 100644 connectivity/source/inc/java/math/BigDecimal.hxx create mode 100644 connectivity/source/inc/java/sql/Array.hxx create mode 100644 connectivity/source/inc/java/sql/Blob.hxx create mode 100644 connectivity/source/inc/java/sql/CallableStatement.hxx create mode 100644 connectivity/source/inc/java/sql/Clob.hxx create mode 100644 connectivity/source/inc/java/sql/Connection.hxx create mode 100644 connectivity/source/inc/java/sql/ConnectionLog.hxx create mode 100644 connectivity/source/inc/java/sql/DatabaseMetaData.hxx create mode 100644 connectivity/source/inc/java/sql/Driver.hxx create mode 100644 connectivity/source/inc/java/sql/DriverPropertyInfo.hxx create mode 100644 connectivity/source/inc/java/sql/JStatement.hxx create mode 100644 connectivity/source/inc/java/sql/PreparedStatement.hxx create mode 100644 connectivity/source/inc/java/sql/Ref.hxx create mode 100644 connectivity/source/inc/java/sql/ResultSet.hxx create mode 100644 connectivity/source/inc/java/sql/ResultSetMetaData.hxx create mode 100644 connectivity/source/inc/java/sql/SQLException.hxx create mode 100644 connectivity/source/inc/java/sql/SQLWarning.hxx create mode 100644 connectivity/source/inc/java/sql/Timestamp.hxx create mode 100644 connectivity/source/inc/java/tools.hxx create mode 100644 connectivity/source/inc/java/util/Date.hxx create mode 100644 connectivity/source/inc/java/util/Property.hxx create mode 100644 connectivity/source/inc/mysql/YCatalog.hxx create mode 100644 connectivity/source/inc/mysql/YColumns.hxx create mode 100644 connectivity/source/inc/mysql/YDriver.hxx create mode 100644 connectivity/source/inc/mysql/YTable.hxx create mode 100644 connectivity/source/inc/mysql/YTables.hxx create mode 100644 connectivity/source/inc/mysql/YUser.hxx create mode 100644 connectivity/source/inc/mysql/YUsers.hxx create mode 100644 connectivity/source/inc/mysql/YViews.hxx create mode 100644 connectivity/source/inc/odbc/OBoundParam.hxx create mode 100644 connectivity/source/inc/odbc/OConnection.hxx create mode 100644 connectivity/source/inc/odbc/ODatabaseMetaData.hxx create mode 100644 connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx create mode 100644 connectivity/source/inc/odbc/ODriver.hxx create mode 100644 connectivity/source/inc/odbc/OFunctions.hxx create mode 100644 connectivity/source/inc/odbc/OPreparedStatement.hxx create mode 100644 connectivity/source/inc/odbc/OResultSet.hxx create mode 100644 connectivity/source/inc/odbc/OResultSetMetaData.hxx create mode 100644 connectivity/source/inc/odbc/OStatement.hxx create mode 100644 connectivity/source/inc/odbc/OTools.hxx create mode 100644 connectivity/source/inc/odbc/odbcbasedllapi.hxx create mode 100644 connectivity/source/inc/propertyids.hxx create mode 100644 connectivity/source/inc/resource/sharedresources.hxx create mode 100644 connectivity/source/inc/writer/WCatalog.hxx create mode 100644 connectivity/source/inc/writer/WConnection.hxx create mode 100644 connectivity/source/inc/writer/WDatabaseMetaData.hxx create mode 100644 connectivity/source/inc/writer/WDriver.hxx create mode 100644 connectivity/source/inc/writer/WTable.hxx create mode 100644 connectivity/source/inc/writer/WTables.hxx create mode 100644 connectivity/source/manager/mdrivermanager.cxx create mode 100644 connectivity/source/manager/mdrivermanager.hxx create mode 100644 connectivity/source/manager/mregistration.cxx create mode 100644 connectivity/source/manager/sdbc2.component create mode 100644 connectivity/source/parse/PColumn.cxx create mode 100644 connectivity/source/parse/internalnode.cxx create mode 100644 connectivity/source/parse/sqlbison.y create mode 100644 connectivity/source/parse/sqlflex.l create mode 100644 connectivity/source/parse/sqliterator.cxx create mode 100644 connectivity/source/parse/sqlnode.cxx create mode 100644 connectivity/source/resource/sharedresources.cxx create mode 100644 connectivity/source/sdbcx/VCatalog.cxx create mode 100644 connectivity/source/sdbcx/VCollection.cxx create mode 100644 connectivity/source/sdbcx/VColumn.cxx create mode 100644 connectivity/source/sdbcx/VDescriptor.cxx create mode 100644 connectivity/source/sdbcx/VGroup.cxx create mode 100644 connectivity/source/sdbcx/VIndex.cxx create mode 100644 connectivity/source/sdbcx/VIndexColumn.cxx create mode 100644 connectivity/source/sdbcx/VKey.cxx create mode 100644 connectivity/source/sdbcx/VKeyColumn.cxx create mode 100644 connectivity/source/sdbcx/VTable.cxx create mode 100644 connectivity/source/sdbcx/VUser.cxx create mode 100644 connectivity/source/sdbcx/VView.cxx create mode 100644 connectivity/workben/iniParser/main.cxx create mode 100644 connectivity/workben/iniParser/makefile.mk create mode 100644 connectivity/workben/little/main.cxx create mode 100644 connectivity/workben/little/makefile.mk create mode 100644 connectivity/workben/skeleton/SResultSet.hxx create mode 100644 connectivity/workben/skeleton/how_to_write_a_driver.txt (limited to 'connectivity') diff --git a/connectivity/AllLangMoTarget_cnr.mk b/connectivity/AllLangMoTarget_cnr.mk new file mode 100644 index 000000000..a960ce0b9 --- /dev/null +++ b/connectivity/AllLangMoTarget_cnr.mk @@ -0,0 +1,13 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +$(eval $(call gb_AllLangMoTarget_AllLangMoTarget,cnr)) + +$(eval $(call gb_AllLangMoTarget_set_polocation,cnr,connectivity)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Configuration_ado.mk b/connectivity/Configuration_ado.mk new file mode 100644 index 000000000..44673c42f --- /dev/null +++ b/connectivity/Configuration_ado.mk @@ -0,0 +1,20 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Configuration_Configuration,driver_ado)) + +$(eval $(call gb_Configuration_add_spool_modules,driver_ado,connectivity/registry/ado,\ + org/openoffice/Office/DataAccess/Drivers-ado.xcu \ +)) + +$(eval $(call gb_Configuration_add_localized_datas,driver_ado,connectivity/registry/ado,\ + org/openoffice/Office/DataAccess/Drivers.xcu \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Configuration_calc.mk b/connectivity/Configuration_calc.mk new file mode 100644 index 000000000..fe26cc979 --- /dev/null +++ b/connectivity/Configuration_calc.mk @@ -0,0 +1,20 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Configuration_Configuration,driver_calc)) + +$(eval $(call gb_Configuration_add_spool_modules,driver_calc,connectivity/registry/calc,\ + org/openoffice/Office/DataAccess/Drivers-calc.xcu \ +)) + +$(eval $(call gb_Configuration_add_localized_datas,driver_calc,connectivity/registry/calc,\ + org/openoffice/Office/DataAccess/Drivers.xcu \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Configuration_dbase.mk b/connectivity/Configuration_dbase.mk new file mode 100644 index 000000000..e6af965c9 --- /dev/null +++ b/connectivity/Configuration_dbase.mk @@ -0,0 +1,20 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Configuration_Configuration,driver_dbase)) + +$(eval $(call gb_Configuration_add_spool_modules,driver_dbase,connectivity/registry/dbase,\ + org/openoffice/Office/DataAccess/Drivers-dbase.xcu \ +)) + +$(eval $(call gb_Configuration_add_localized_datas,driver_dbase,connectivity/registry/dbase,\ + org/openoffice/Office/DataAccess/Drivers.xcu \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Configuration_evoab.mk b/connectivity/Configuration_evoab.mk new file mode 100644 index 000000000..55de8dbd2 --- /dev/null +++ b/connectivity/Configuration_evoab.mk @@ -0,0 +1,20 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Configuration_Configuration,driver_evoab)) + +$(eval $(call gb_Configuration_add_spool_modules,driver_evoab,connectivity/registry/evoab2,\ + org/openoffice/Office/DataAccess/Drivers-evoab2.xcu \ +)) + +$(eval $(call gb_Configuration_add_localized_datas,driver_evoab,connectivity/registry/evoab2,\ + org/openoffice/Office/DataAccess/Drivers.xcu \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Configuration_firebird.mk b/connectivity/Configuration_firebird.mk new file mode 100644 index 000000000..47873c7df --- /dev/null +++ b/connectivity/Configuration_firebird.mk @@ -0,0 +1,20 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Configuration_Configuration,driver_firebird_sdbc)) + +$(eval $(call gb_Configuration_add_spool_modules,driver_firebird_sdbc,connectivity/registry/firebird,\ + org/openoffice/Office/DataAccess/Drivers-firebird.xcu \ +)) + +$(eval $(call gb_Configuration_add_localized_datas,driver_firebird_sdbc,connectivity/registry/firebird,\ + org/openoffice/Office/DataAccess/Drivers.xcu \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Configuration_flat.mk b/connectivity/Configuration_flat.mk new file mode 100644 index 000000000..8fe5c3af0 --- /dev/null +++ b/connectivity/Configuration_flat.mk @@ -0,0 +1,20 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Configuration_Configuration,driver_flat)) + +$(eval $(call gb_Configuration_add_spool_modules,driver_flat,connectivity/registry/flat,\ + org/openoffice/Office/DataAccess/Drivers-flat.xcu \ +)) + +$(eval $(call gb_Configuration_add_localized_datas,driver_flat,connectivity/registry/flat,\ + org/openoffice/Office/DataAccess/Drivers.xcu \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Configuration_hsqldb.mk b/connectivity/Configuration_hsqldb.mk new file mode 100644 index 000000000..a9528cf49 --- /dev/null +++ b/connectivity/Configuration_hsqldb.mk @@ -0,0 +1,20 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Configuration_Configuration,driver_hsqldb)) + +$(eval $(call gb_Configuration_add_spool_modules,driver_hsqldb,connectivity/registry/hsqldb,\ + org/openoffice/Office/DataAccess/Drivers-hsqldb.xcu \ +)) + +$(eval $(call gb_Configuration_add_localized_datas,driver_hsqldb,connectivity/registry/hsqldb,\ + org/openoffice/Office/DataAccess/Drivers.xcu \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Configuration_jdbc.mk b/connectivity/Configuration_jdbc.mk new file mode 100644 index 000000000..d1320f47c --- /dev/null +++ b/connectivity/Configuration_jdbc.mk @@ -0,0 +1,20 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Configuration_Configuration,driver_jdbc)) + +$(eval $(call gb_Configuration_add_spool_modules,driver_jdbc,connectivity/registry/jdbc,\ + org/openoffice/Office/DataAccess/Drivers-jdbc.xcu \ +)) + +$(eval $(call gb_Configuration_add_localized_datas,driver_jdbc,connectivity/registry/jdbc,\ + org/openoffice/Office/DataAccess/Drivers.xcu \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Configuration_macab.mk b/connectivity/Configuration_macab.mk new file mode 100644 index 000000000..2403a2dc3 --- /dev/null +++ b/connectivity/Configuration_macab.mk @@ -0,0 +1,20 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Configuration_Configuration,driver_macab)) + +$(eval $(call gb_Configuration_add_spool_modules,driver_macab,connectivity/registry/macab,\ + org/openoffice/Office/DataAccess/Drivers-macab.xcu \ +)) + +$(eval $(call gb_Configuration_add_localized_datas,driver_macab,connectivity/registry/macab,\ + org/openoffice/Office/DataAccess/Drivers.xcu \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Configuration_mork.mk b/connectivity/Configuration_mork.mk new file mode 100644 index 000000000..dc36ca83e --- /dev/null +++ b/connectivity/Configuration_mork.mk @@ -0,0 +1,20 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Configuration_Configuration,driver_mork)) + +$(eval $(call gb_Configuration_add_spool_modules,driver_mork,connectivity/registry/mork,\ + org/openoffice/Office/DataAccess/Drivers-mork.xcu \ +)) + +$(eval $(call gb_Configuration_add_localized_datas,driver_mork,connectivity/registry/mork,\ + org/openoffice/Office/DataAccess/Drivers.xcu \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Configuration_mysql.mk b/connectivity/Configuration_mysql.mk new file mode 100644 index 000000000..5ef54c70a --- /dev/null +++ b/connectivity/Configuration_mysql.mk @@ -0,0 +1,20 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Configuration_Configuration,driver_mysqlc)) + +$(eval $(call gb_Configuration_add_spool_modules,driver_mysqlc,connectivity/registry/mysqlc,\ + org/openoffice/Office/DataAccess/Drivers-mysqlc.xcu \ +)) + +$(eval $(call gb_Configuration_add_localized_datas,driver_mysqlc,connectivity/registry/mysqlc,\ + org/openoffice/Office/DataAccess/Drivers.xcu \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Configuration_mysql_jdbc.mk b/connectivity/Configuration_mysql_jdbc.mk new file mode 100644 index 000000000..27a672aad --- /dev/null +++ b/connectivity/Configuration_mysql_jdbc.mk @@ -0,0 +1,20 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Configuration_Configuration,driver_mysql_jdbc)) + +$(eval $(call gb_Configuration_add_spool_modules,driver_mysql_jdbc,connectivity/registry/mysql_jdbc,\ + org/openoffice/Office/DataAccess/Drivers-mysql_jdbc.xcu \ +)) + +$(eval $(call gb_Configuration_add_localized_datas,driver_mysql_jdbc,connectivity/registry/mysql_jdbc,\ + org/openoffice/Office/DataAccess/Drivers.xcu \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Configuration_odbc.mk b/connectivity/Configuration_odbc.mk new file mode 100644 index 000000000..bb5df1f3b --- /dev/null +++ b/connectivity/Configuration_odbc.mk @@ -0,0 +1,20 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Configuration_Configuration,driver_odbc)) + +$(eval $(call gb_Configuration_add_spool_modules,driver_odbc,connectivity/registry/odbc,\ + org/openoffice/Office/DataAccess/Drivers-odbc.xcu \ +)) + +$(eval $(call gb_Configuration_add_localized_datas,driver_odbc,connectivity/registry/odbc,\ + org/openoffice/Office/DataAccess/Drivers.xcu \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Configuration_postgresql.mk b/connectivity/Configuration_postgresql.mk new file mode 100644 index 000000000..d2e804d84 --- /dev/null +++ b/connectivity/Configuration_postgresql.mk @@ -0,0 +1,20 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Configuration_Configuration,driver_postgresql)) + +$(eval $(call gb_Configuration_add_spool_modules,driver_postgresql,connectivity/registry/postgresql,\ + org/openoffice/Office/DataAccess/Drivers-postgresql.xcu \ +)) + +$(eval $(call gb_Configuration_add_localized_datas,driver_postgresql,connectivity/registry/postgresql,\ + org/openoffice/Office/DataAccess/Drivers.xcu \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Configuration_writer.mk b/connectivity/Configuration_writer.mk new file mode 100644 index 000000000..c14030b11 --- /dev/null +++ b/connectivity/Configuration_writer.mk @@ -0,0 +1,20 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Configuration_Configuration,driver_writer)) + +$(eval $(call gb_Configuration_add_spool_modules,driver_writer,connectivity/registry/writer,\ + org/openoffice/Office/DataAccess/Drivers-writer.xcu \ +)) + +$(eval $(call gb_Configuration_add_localized_datas,driver_writer,connectivity/registry/writer,\ + org/openoffice/Office/DataAccess/Drivers.xcu \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/CppunitTest_connectivity_ado.mk b/connectivity/CppunitTest_connectivity_ado.mk new file mode 100644 index 000000000..3dd953561 --- /dev/null +++ b/connectivity/CppunitTest_connectivity_ado.mk @@ -0,0 +1,69 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,connectivity_ado)) + +$(eval $(call gb_CppunitTest_set_include,connectivity_ado,\ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ + -I$(SRCDIR)/connectivity/source/drivers/ado \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_external,connectivity_ado,boost_headers)) + +$(eval $(call gb_CppunitTest_use_sdk_api,connectivity_ado)) + +$(eval $(call gb_CppunitTest_use_ure,connectivity_ado)) +$(eval $(call gb_CppunitTest_use_vcl,connectivity_ado)) + +$(eval $(call gb_CppunitTest_use_sdk_api,connectivity_ado)) + +ifeq ($(COM),GCC) +$(eval $(call gb_CppunitTest_add_cxxflags,connectivity_ado,\ + -fpermissive \ +)) +endif + +$(eval $(call gb_CppunitTest_add_exception_objects,connectivity_ado, \ + connectivity/qa/connectivity/ado/DriverTest \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,connectivity_ado, \ + comphelper \ + cppu \ + cppuhelper \ + dbtools \ + i18nlangtag \ + ado \ + sal \ + salhelper \ + sb \ + test \ + unotest \ + ucbhelper \ + utl \ +)) + +$(eval $(call gb_CppunitTest_use_components,connectivity_ado,\ + configmgr/source/configmgr \ + i18npool/util/i18npool \ + connectivity/source/drivers/ado/ado \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,connectivity_ado)) + +$(call gb_CppunitTest_get_target,connectivity_ado) : $(WORKDIR)/CppunitTest/TS001018407.mdb +$(WORKDIR)/CppunitTest/TS001018407.mdb : $(SRCDIR)/connectivity/qa/connectivity/ado/TS001018407.mdb + mkdir -p $(dir $@) + $(call gb_Deliver_deliver,$<,$@) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/CppunitTest_connectivity_commontools.mk b/connectivity/CppunitTest_connectivity_commontools.mk new file mode 100644 index 000000000..81dfe9e68 --- /dev/null +++ b/connectivity/CppunitTest_connectivity_commontools.mk @@ -0,0 +1,42 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,connectivity_commontools)) + +$(eval $(call gb_CppunitTest_set_include,connectivity_commontools,\ + -I$(SRCDIR)/connectivity/source/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_external,connectivity_commontools,boost_headers)) + +$(eval $(call gb_CppunitTest_use_ure,connectivity_commontools)) +$(eval $(call gb_CppunitTest_use_vcl,connectivity_commontools)) + +$(eval $(call gb_CppunitTest_use_sdk_api,connectivity_commontools)) + +$(eval $(call gb_CppunitTest_add_exception_objects,connectivity_commontools, \ + connectivity/qa/connectivity/commontools/FValue_test \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,connectivity_commontools, \ + cppu \ + dbtools \ + sal \ + test \ + unotest \ +)) + +$(eval $(call gb_CppunitTest_use_components,connectivity_commontools,\ + configmgr/source/configmgr \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,connectivity_commontools)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/CppunitTest_connectivity_mork.mk b/connectivity/CppunitTest_connectivity_mork.mk new file mode 100644 index 000000000..6504adef8 --- /dev/null +++ b/connectivity/CppunitTest_connectivity_mork.mk @@ -0,0 +1,56 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,connectivity_mork)) + +$(eval $(call gb_CppunitTest_set_include,connectivity_mork,\ + -I$(SRCDIR)/connectivity/source/inc \ + -I$(SRCDIR)/connectivity/source/drivers/mork \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_external,connectivity_mork,boost_headers)) + +$(eval $(call gb_CppunitTest_use_sdk_api,connectivity_mork)) + +$(eval $(call gb_CppunitTest_use_ure,connectivity_mork)) +$(eval $(call gb_CppunitTest_use_vcl,connectivity_mork)) + +$(eval $(call gb_CppunitTest_use_sdk_api,connectivity_mork)) + +$(eval $(call gb_CppunitTest_add_exception_objects,connectivity_mork, \ + connectivity/qa/connectivity/mork/DriverTest \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,connectivity_mork, \ + comphelper \ + cppu \ + cppuhelper \ + i18nlangtag \ + mork \ + sal \ + salhelper \ + sb \ + test \ + unotest \ + ucbhelper \ + utl \ +)) + +$(eval $(call gb_CppunitTest_use_components,connectivity_mork,\ + configmgr/source/configmgr \ + i18npool/util/i18npool \ + connectivity/source/drivers/mork/mork \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,connectivity_mork)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/CppunitTest_connectivity_mysql_test.mk b/connectivity/CppunitTest_connectivity_mysql_test.mk new file mode 100644 index 000000000..8733315f4 --- /dev/null +++ b/connectivity/CppunitTest_connectivity_mysql_test.mk @@ -0,0 +1,66 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,connectivity_mysql_test)) + +$(eval $(call gb_CppunitTest_use_external,connectivity_mysql_test,boost_headers)) + +$(eval $(call gb_CppunitTest_add_exception_objects,connectivity_mysql_test, \ + connectivity/qa/connectivity/mysql/mysql \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,connectivity_mysql_test, \ + comphelper \ + cppu \ + dbaxml \ + sal \ + subsequenttest \ + svt \ + test \ + unotest \ + utl \ + xo \ +)) + +$(eval $(call gb_CppunitTest_use_api,connectivity_mysql_test,\ + offapi \ + oovbaapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,connectivity_mysql_test)) +$(eval $(call gb_CppunitTest_use_vcl,connectivity_mysql_test)) + +$(eval $(call gb_CppunitTest_use_components,connectivity_mysql_test,\ + basic/util/sb \ + comphelper/util/comphelp \ + configmgr/source/configmgr \ + connectivity/source/drivers/mysqlc/mysqlc \ + connectivity/source/manager/sdbc2 \ + filter/source/config/cache/filterconfig1 \ + framework/util/fwk \ + i18npool/util/i18npool \ + linguistic/source/lng \ + package/source/xstor/xstor \ + package/util/package2 \ + sax/source/expatwrap/expwrap \ + sfx2/util/sfx \ + svl/source/fsstor/fsstorage \ + svl/util/svl \ + toolkit/util/tk \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ + unotools/util/utl \ + uui/util/uui \ + xmloff/util/xo \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,connectivity_mysql_test)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/CppunitTest_connectivity_sharedresources.mk b/connectivity/CppunitTest_connectivity_sharedresources.mk new file mode 100644 index 000000000..9af3f8ca2 --- /dev/null +++ b/connectivity/CppunitTest_connectivity_sharedresources.mk @@ -0,0 +1,43 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,connectivity_sharedresources)) + +$(eval $(call gb_CppunitTest_set_include,connectivity_sharedresources,\ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_external,connectivity_sharedresources,boost_headers)) + +$(eval $(call gb_CppunitTest_use_ure,connectivity_sharedresources)) +$(eval $(call gb_CppunitTest_use_vcl,connectivity_sharedresources)) + +$(eval $(call gb_CppunitTest_use_sdk_api,connectivity_sharedresources)) + +$(eval $(call gb_CppunitTest_add_exception_objects,connectivity_sharedresources, \ + connectivity/qa/connectivity/resource/sharedresources_test \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,connectivity_sharedresources, \ + dbtools \ + sal \ + test \ + unotest \ +)) + +$(eval $(call gb_CppunitTest_use_components,connectivity_sharedresources,\ + configmgr/source/configmgr \ + i18npool/util/i18npool \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,connectivity_sharedresources)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Executable_mork_helper.mk b/connectivity/Executable_mork_helper.mk new file mode 100644 index 000000000..2c80a0ad5 --- /dev/null +++ b/connectivity/Executable_mork_helper.mk @@ -0,0 +1,30 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Executable_Executable,mork_helper)) + +$(eval $(call gb_Executable_set_include,mork_helper,\ + -I$(SRCDIR)/connectivity/source/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_Executable_use_sdk_api,mork_helper)) + +$(eval $(call gb_Executable_use_libraries,mork_helper,\ + cppu \ + cppuhelper \ + mork \ + sal \ +)) + +$(eval $(call gb_Executable_add_exception_objects,mork_helper,\ + connectivity/source/drivers/mork/mork_helper \ +)) + +# vim:set noet sw=4 ts=4: diff --git a/connectivity/IwyuFilter_connectivity.yaml b/connectivity/IwyuFilter_connectivity.yaml new file mode 100644 index 000000000..969f545b3 --- /dev/null +++ b/connectivity/IwyuFilter_connectivity.yaml @@ -0,0 +1,75 @@ +--- +assumeFilename: connectivity/source/commontools/dbtools.cxx +blacklist: + connectivity/source/commontools/ConnectionWrapper.cxx: + # Actually used + - com/sun/star/beans/PropertyValue.hpp + - com/sun/star/sdbc/XConnection.hpp + connectivity/source/commontools/RowFunctionParser.cxx: + # Boost header needed + - boost/spirit/include/classic_core.hpp + connectivity/source/commontools/conncleanup.cxx: + # Actually used + - com/sun/star/sdbc/XRowSet.hpp + - com/sun/star/sdbc/XConnection.hpp + connectivity/source/commontools/dbconversion.cxx: + # Needed for rtl::math::round + - rtl/math.hxx + connectivity/source/commontools/dbexception.cxx: + # Actually used + - com/sun/star/sdb/SQLErrorEvent.hpp + connectivity/source/commontools/paramwrapper.cxx: + # Actually used + - com/sun/star/sdbc/XParameters.hpp + connectivity/source/commontools/warningscontainer.cxx: + # Actually used + - com/sun/star/sdb/SQLContext.hpp + - com/sun/star/sdbc/XWarningsSupplier.hpp + connectivity/source/commontools/predicateinput.cxx: + # Actually used + - com/sun/star/sdbc/XConnection.hpp + connectivity/source/commontools/statementcomposer.cxx: + # Actually used + - com/sun/star/sdbc/XConnection.hpp + connectivity/source/commontools/parameters.cxx: + # Actually used + - com/sun/star/form/XDatabaseParameterListener.hpp + - com/sun/star/sdbc/XParameters.hpp + - com/sun/star/task/XInteractionHandler.hpp + connectivity/source/cpool/ZPoolCollection.cxx: + # Actually used + - com/sun/star/beans/PropertyValue.hpp + connectivity/source/parse/PColumn.cxx: + # Actually used + - com/sun/star/sdbc/XResultSetMetaData.hpp + connectivity/source/drivers/file/FCatalog.cxx: + # Actually used + - com/sun/star/sdbc/XRow.hpp + connectivity/source/drivers/hsqldb/HStorageAccess.cxx: + # Needed for HSQLDB_DBG + - accesslog.hxx + connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx: + # Needed for HSQLDB_DBG + - accesslog.hxx + connectivity/source/drivers/hsqldb/StorageNativeOutputStream.cxx: + # Needed for HSQLDB_DBG + - accesslog.hxx + connectivity/source/drivers/jdbc/ConnectionLog.cxx: + # Actually used + - com/sun/star/util/Date.hpp + - com/sun/star/util/Time.hpp + - com/sun/star/util/DateTime.hpp + connectivity/source/drivers/mork/MorkParser.cxx: + # Needed for std::ifstream + - fstream + connectivity/source/drivers/mork/MDriver.cxx: + # Actually used + - com/sun/star/uno/XComponentContext.hpp + connectivity/source/drivers/mysql_jdbc/YDriver.cxx: + # Actually used + - com/sun/star/uno/XComponentContext.hpp + connectivity/source/drivers/odbc/OTools.cxx: + # OSL_BIGENDIAN is being checked + - osl/endian.h + connectivity/source/drivers/writer/WDatabaseMetaData.cxx: + - com/sun/star/text/XTextDocument.hpp diff --git a/connectivity/Jar_ConnectivityTools.mk b/connectivity/Jar_ConnectivityTools.mk new file mode 100644 index 000000000..250b2ff3a --- /dev/null +++ b/connectivity/Jar_ConnectivityTools.mk @@ -0,0 +1,42 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Jar_Jar,ConnectivityTools)) + +$(eval $(call gb_Jar_use_jars,ConnectivityTools,\ + ridl \ + juh \ + java_uno \ + OOoRunner \ +)) + +$(eval $(call gb_Jar_use_system_jars,ConnectivityTools, \ + $(OOO_JUNIT_JAR) \ +)) + +$(eval $(call gb_Jar_set_packageroot,ConnectivityTools,connectivity)) + +$(eval $(call gb_Jar_add_sourcefiles,ConnectivityTools,\ + connectivity/qa/connectivity/tools/AbstractDatabase \ + connectivity/qa/connectivity/tools/CRMDatabase \ + connectivity/qa/connectivity/tools/CsvDatabase \ + connectivity/qa/connectivity/tools/DatabaseAccess \ + connectivity/qa/connectivity/tools/DataSource \ + connectivity/qa/connectivity/tools/DbaseDatabase \ + connectivity/qa/connectivity/tools/FlatFileDatabase \ + connectivity/qa/connectivity/tools/HsqlColumnDescriptor \ + connectivity/qa/connectivity/tools/HsqlDatabase \ + connectivity/qa/connectivity/tools/HsqlTableDescriptor \ + connectivity/qa/connectivity/tools/QueryDefinition \ + connectivity/qa/connectivity/tools/RowSet \ + connectivity/qa/connectivity/tools/sdb/Connection \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Jar_sdbc_hsqldb.mk b/connectivity/Jar_sdbc_hsqldb.mk new file mode 100644 index 000000000..20cd1f8ae --- /dev/null +++ b/connectivity/Jar_sdbc_hsqldb.mk @@ -0,0 +1,37 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Jar_Jar,sdbc_hsqldb)) + +$(eval $(call gb_Jar_use_externals,sdbc_hsqldb,\ + hsqldb \ +)) + +$(eval $(call gb_Jar_add_manifest_classpath,sdbc_hsqldb,\ + $(if $(filter MACOSX,$(OS)),../../Frameworks/,..) \ +)) + +$(eval $(call gb_Jar_set_packageroot,sdbc_hsqldb,com)) + +$(eval $(call gb_Jar_add_packagedir,sdbc_hsqldb,org)) + +$(eval $(call gb_Jar_add_sourcefiles,sdbc_hsqldb,\ + connectivity/org/hsqldb/lib/FileSystemRuntimeException \ + connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper \ + connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries \ + connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper \ + connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess \ + connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess \ + connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess \ + connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream \ + connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/JunitTest_complex.mk b/connectivity/JunitTest_complex.mk new file mode 100644 index 000000000..9b257d4c1 --- /dev/null +++ b/connectivity/JunitTest_complex.mk @@ -0,0 +1,51 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_JunitTest_JunitTest,connectivity_complex)) + +$(eval $(call gb_JunitTest_use_unoapi_jars,connectivity_complex)) +$(eval $(call gb_JunitTest_use_unoapi_test_class,connectivity_complex)) + +$(eval $(call gb_JunitTest_set_defs,connectivity_complex,\ + $$(DEFS) \ + -Dorg.openoffice.test.arg.sce=$(SRCDIR)/connectivity/qa/scenarios.sce \ +)) + +$(eval $(call gb_JunitTest_use_externals,connectivity_complex,\ + hsqldb \ +)) + +$(eval $(call gb_JunitTest_add_sourcefiles,connectivity_complex,\ + connectivity/qa/complex/connectivity/DBaseDriverTest \ + connectivity/qa/complex/connectivity/FlatFileAccess \ + connectivity/qa/complex/connectivity/HsqlDriverTest \ + connectivity/qa/complex/connectivity/JdbcLongVarCharTest \ + connectivity/qa/complex/connectivity/SubTestCase \ + connectivity/qa/complex/connectivity/TestCase \ + connectivity/qa/complex/connectivity/dbase/DBaseDateFunctions \ + connectivity/qa/complex/connectivity/dbase/DBaseNumericFunctions \ + connectivity/qa/complex/connectivity/dbase/DBaseSqlTests \ + connectivity/qa/complex/connectivity/dbase/DBaseStringFunctions \ + connectivity/qa/complex/connectivity/hsqldb/TestCacheSize \ + connectivity/qa/connectivity/tools/AbstractDatabase \ + connectivity/qa/connectivity/tools/CRMDatabase \ + connectivity/qa/connectivity/tools/CsvDatabase \ + connectivity/qa/connectivity/tools/DataSource \ + connectivity/qa/connectivity/tools/DatabaseAccess \ + connectivity/qa/connectivity/tools/DbaseDatabase \ + connectivity/qa/connectivity/tools/FlatFileDatabase \ + connectivity/qa/connectivity/tools/HsqlColumnDescriptor \ + connectivity/qa/connectivity/tools/HsqlDatabase \ + connectivity/qa/connectivity/tools/HsqlTableDescriptor \ + connectivity/qa/connectivity/tools/QueryDefinition \ + connectivity/qa/connectivity/tools/RowSet \ + connectivity/qa/connectivity/tools/sdb/Connection \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_ado.mk b/connectivity/Library_ado.mk new file mode 100644 index 000000000..f371c2780 --- /dev/null +++ b/connectivity/Library_ado.mk @@ -0,0 +1,85 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,ado)) + +$(eval $(call gb_Library_set_componentfile,ado,connectivity/source/drivers/ado/ado)) + +$(eval $(call gb_Library_set_include,ado,\ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ + $$(INCLUDE) \ + -I$(WORKDIR)/YaccTarget/connectivity/source/parse \ +)) + +$(eval $(call gb_Library_use_external,ado,boost_headers)) + +$(eval $(call gb_Library_set_precompiled_header,ado,connectivity/inc/pch/precompiled_ado)) + +$(eval $(call gb_Library_use_sdk_api,ado)) + +ifeq ($(COM),GCC) +$(eval $(call gb_Library_add_cxxflags,ado,\ + -fpermissive \ +)) +endif + +$(eval $(call gb_Library_use_system_win32_libs,ado,\ + ole32 \ + oleaut32 \ + uuid \ +)) + +$(eval $(call gb_Library_use_libraries,ado,\ + cppu \ + cppuhelper \ + sal \ + salhelper \ + dbtools \ + comphelper \ +)) + +$(eval $(call gb_Library_add_exception_objects,ado,\ + connectivity/source/drivers/ado/ADatabaseMetaDataImpl \ + connectivity/source/drivers/ado/Aolevariant \ + connectivity/source/drivers/ado/ADatabaseMetaData \ + connectivity/source/drivers/ado/AColumn \ + connectivity/source/drivers/ado/AColumns \ + connectivity/source/drivers/ado/AIndex \ + connectivity/source/drivers/ado/AIndexes \ + connectivity/source/drivers/ado/AKey \ + connectivity/source/drivers/ado/AKeys \ + connectivity/source/drivers/ado/AUser \ + connectivity/source/drivers/ado/AUsers \ + connectivity/source/drivers/ado/AGroup \ + connectivity/source/drivers/ado/AGroups \ + connectivity/source/drivers/ado/ACatalog \ + connectivity/source/drivers/ado/AView \ + connectivity/source/drivers/ado/AViews \ + connectivity/source/drivers/ado/ATable \ + connectivity/source/drivers/ado/ATables \ + connectivity/source/drivers/ado/ACallableStatement \ + connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData \ + connectivity/source/drivers/ado/ADatabaseMetaDataResultSet \ + connectivity/source/drivers/ado/AResultSet \ + connectivity/source/drivers/ado/AConnection \ + connectivity/source/drivers/ado/AStatement \ + connectivity/source/drivers/ado/APreparedStatement \ + connectivity/source/drivers/ado/AResultSetMetaData \ + connectivity/source/drivers/ado/ADriver \ + connectivity/source/drivers/ado/Aservices \ + connectivity/source/drivers/ado/Awrapado \ + connectivity/source/drivers/ado/adoimp \ +)) + +# Runtime dependency for unit-tests +$(call gb_Library_get_target,ado) :| $(call gb_Library_get_target,affine_uno_uno) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_calc.mk b/connectivity/Library_calc.mk new file mode 100644 index 000000000..1741d01ee --- /dev/null +++ b/connectivity/Library_calc.mk @@ -0,0 +1,51 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,calc)) + +$(eval $(call gb_Library_set_componentfile,calc,connectivity/source/drivers/calc/calc)) + +$(eval $(call gb_Library_use_external,calc,boost_headers)) + +$(eval $(call gb_Library_use_sdk_api,calc)) + +$(eval $(call gb_Library_set_include,calc,\ + $$(INCLUDE) \ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ + -I$(WORKDIR)/YaccTarget/connectivity/source/parse \ +)) + +$(eval $(call gb_Library_set_precompiled_header,calc,connectivity/inc/pch/precompiled_calc)) + +$(eval $(call gb_Library_use_libraries,calc,\ + cppu \ + cppuhelper \ + svl \ + tl \ + utl \ + sal \ + salhelper \ + dbtools \ + file \ + comphelper \ +)) + +$(eval $(call gb_Library_add_exception_objects,calc,\ + connectivity/source/drivers/calc/CDatabaseMetaData \ + connectivity/source/drivers/calc/CCatalog \ + connectivity/source/drivers/calc/CTable \ + connectivity/source/drivers/calc/CTables \ + connectivity/source/drivers/calc/CConnection \ + connectivity/source/drivers/calc/Cservices \ + connectivity/source/drivers/calc/CDriver \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_dbase.mk b/connectivity/Library_dbase.mk new file mode 100644 index 000000000..6f897391e --- /dev/null +++ b/connectivity/Library_dbase.mk @@ -0,0 +1,64 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,dbase)) + +$(eval $(call gb_Library_set_componentfile,dbase,connectivity/source/drivers/dbase/dbase)) + +$(eval $(call gb_Library_use_external,dbase,boost_headers)) + +$(eval $(call gb_Library_use_sdk_api,dbase)) + +$(eval $(call gb_Library_set_include,dbase,\ + $$(INCLUDE) \ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ + -I$(WORKDIR)/YaccTarget/connectivity/source/parse \ +)) + +$(eval $(call gb_Library_set_precompiled_header,dbase,connectivity/inc/pch/precompiled_dbase)) + +$(eval $(call gb_Library_use_libraries,dbase,\ + cppu \ + cppuhelper \ + svl \ + tl \ + ucbhelper \ + sal \ + salhelper \ + dbtools \ + file \ + utl \ + comphelper \ + svt \ +)) + +$(eval $(call gb_Library_add_exception_objects,dbase,\ + connectivity/source/drivers/dbase/DResultSet \ + connectivity/source/drivers/dbase/DStatement \ + connectivity/source/drivers/dbase/DPreparedStatement \ + connectivity/source/drivers/dbase/dindexnode \ + connectivity/source/drivers/dbase/DIndexIter \ + connectivity/source/drivers/dbase/DDatabaseMetaData \ + connectivity/source/drivers/dbase/DCatalog \ + connectivity/source/drivers/dbase/DColumns \ + connectivity/source/drivers/dbase/DIndexColumns \ + connectivity/source/drivers/dbase/DIndex \ + connectivity/source/drivers/dbase/DIndexes \ + connectivity/source/drivers/dbase/DTables \ + connectivity/source/drivers/dbase/DConnection \ + connectivity/source/drivers/dbase/Dservices \ + connectivity/source/drivers/dbase/DDriver \ + connectivity/source/drivers/dbase/DTable \ +)) + +#connectivity/source/drivers/dbase/DTable disable optimization? + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_dbpool2.mk b/connectivity/Library_dbpool2.mk new file mode 100644 index 000000000..d4c60675f --- /dev/null +++ b/connectivity/Library_dbpool2.mk @@ -0,0 +1,44 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,dbpool2)) + +$(eval $(call gb_Library_set_componentfile,dbpool2,connectivity/source/cpool/dbpool2)) + +$(eval $(call gb_Library_set_include,dbpool2,\ + $$(INCLUDE) \ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ +)) + +$(eval $(call gb_Library_set_precompiled_header,dbpool2,connectivity/inc/pch/precompiled_dbpool2)) + +$(eval $(call gb_Library_use_sdk_api,dbpool2)) + +$(eval $(call gb_Library_use_libraries,dbpool2,\ + comphelper \ + cppu \ + cppuhelper \ + dbtools \ + sal \ + salhelper \ + tl \ +)) + +$(eval $(call gb_Library_add_exception_objects,dbpool2,\ + connectivity/source/cpool/ZConnectionWrapper \ + connectivity/source/cpool/ZDriverWrapper \ + connectivity/source/cpool/ZPooledConnection \ + connectivity/source/cpool/ZConnectionPool \ + connectivity/source/cpool/ZPoolCollection \ + connectivity/source/cpool/Zregistration \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_dbtools.mk b/connectivity/Library_dbtools.mk new file mode 100644 index 000000000..6869cd0bb --- /dev/null +++ b/connectivity/Library_dbtools.mk @@ -0,0 +1,129 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,dbtools)) + +$(eval $(call gb_Library_add_defs,dbtools,\ + -DOOO_DLLIMPLEMENTATION_DBTOOLS \ +)) + +$(eval $(call gb_Library_set_componentfile,dbtools,connectivity/source/dbtools/dbtools)) + +$(eval $(call gb_Library_set_include,dbtools,\ + $$(INCLUDE) \ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ +)) + +#$(eval $(call gb_Library_set_precompiled_header,dbtools,connectivity/inc/pch/precompiled_dbtools)) + +$(eval $(call gb_Library_use_external,dbtools,boost_headers)) + +$(eval $(call gb_Library_use_sdk_api,dbtools)) + +$(eval $(call gb_Library_use_libraries,dbtools,\ + cppu \ + cppuhelper \ + sal \ + salhelper \ + $(if $(ENABLE_JAVA), \ + jvmaccess) \ + utl \ + tl \ + comphelper \ + i18nlangtag \ + svt \ + vcl \ +)) + +ifeq ($(filter-out NETBSD MACOSX,$(OS)),) +$(eval $(call gb_Library_use_libraries,dbtools,\ + ucbhelper \ +)) +endif + +#connectivity/source/commontools/RowFunctionParser.cxx disable optimization? + +$(eval $(call gb_Library_add_exception_objects,dbtools,\ +)) + +$(eval $(call gb_Library_add_grammars,dbtools,\ + connectivity/source/parse/sqlbison \ +)) + +$(call gb_YaccTarget_get_target,connectivity/source/parse/sqlbison) : T_YACCFLAGS := -d -l -pSQLyy -bsql + +$(eval $(call gb_Library_add_scanners,dbtools,\ +connectivity/source/parse/sqlflex \ +)) + +$(call gb_LexTarget_get_scanner_target,connectivity/source/parse/sqlflex) : T_LEXFLAGS := -i -8 -PSQLyy -L + +$(eval $(call gb_Library_add_exception_objects,dbtools,\ + connectivity/source/commontools/AutoRetrievingBase \ + connectivity/source/commontools/BlobHelper \ + connectivity/source/commontools/CommonTools \ + connectivity/source/commontools/ConnectionWrapper \ + connectivity/source/commontools/DateConversion \ + connectivity/source/commontools/DriversConfig \ + connectivity/source/commontools/FDatabaseMetaDataResultSet \ + connectivity/source/commontools/FDatabaseMetaDataResultSetMetaData \ + connectivity/source/commontools/FValue \ + connectivity/source/commontools/ParameterSubstitution \ + connectivity/source/commontools/RowFunctionParser \ + connectivity/source/commontools/TColumnsHelper \ + connectivity/source/commontools/TConnection \ + connectivity/source/commontools/TDatabaseMetaDataBase \ + connectivity/source/commontools/TIndex \ + connectivity/source/commontools/TIndexColumns \ + connectivity/source/commontools/TIndexes \ + connectivity/source/commontools/TKey \ + connectivity/source/commontools/TKeyColumns \ + connectivity/source/commontools/TKeys \ + connectivity/source/commontools/TPrivilegesResultSet \ + connectivity/source/commontools/TSkipDeletedSet \ + connectivity/source/commontools/TSortIndex \ + connectivity/source/commontools/TTableHelper \ + connectivity/source/commontools/conncleanup \ + connectivity/source/commontools/dbcharset \ + connectivity/source/commontools/dbconversion \ + connectivity/source/commontools/dbexception \ + connectivity/source/commontools/dbmetadata \ + connectivity/source/commontools/dbtools \ + connectivity/source/commontools/dbtools2 \ + connectivity/source/commontools/filtermanager \ + connectivity/source/commontools/formattedcolumnvalue \ + connectivity/source/commontools/parameters \ + connectivity/source/commontools/paramwrapper \ + connectivity/source/commontools/predicateinput \ + connectivity/source/commontools/propertyids \ + connectivity/source/commontools/sqlerror \ + connectivity/source/commontools/statementcomposer \ + connectivity/source/commontools/warningscontainer \ + connectivity/source/parse/PColumn \ + connectivity/source/parse/internalnode \ + connectivity/source/parse/sqliterator \ + connectivity/source/parse/sqlnode \ + connectivity/source/resource/sharedresources \ + connectivity/source/sdbcx/VCatalog \ + connectivity/source/sdbcx/VCollection \ + connectivity/source/sdbcx/VColumn \ + connectivity/source/sdbcx/VDescriptor \ + connectivity/source/sdbcx/VGroup \ + connectivity/source/sdbcx/VIndex \ + connectivity/source/sdbcx/VIndexColumn \ + connectivity/source/sdbcx/VKey \ + connectivity/source/sdbcx/VKeyColumn \ + connectivity/source/sdbcx/VTable \ + connectivity/source/sdbcx/VUser \ + connectivity/source/sdbcx/VView \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_evoab.mk b/connectivity/Library_evoab.mk new file mode 100644 index 000000000..ee325f446 --- /dev/null +++ b/connectivity/Library_evoab.mk @@ -0,0 +1,59 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,evoab)) + +$(eval $(call gb_Library_set_include,evoab,\ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ + $$(INCLUDE) \ + -I$(WORKDIR)/YaccTarget/connectivity/source/parse \ +)) + +$(eval $(call gb_Library_use_externals,evoab,\ + boost_headers \ + gobject \ +)) + +$(eval $(call gb_Library_set_componentfile,evoab,connectivity/source/drivers/evoab2/evoab)) + +$(eval $(call gb_Library_use_sdk_api,evoab)) + +$(eval $(call gb_Library_use_libraries,evoab,\ + comphelper \ + cppu \ + cppuhelper \ + svl \ + tl \ + utl \ + ucbhelper \ + sal \ + salhelper \ + dbtools \ + file \ +)) + +$(eval $(call gb_Library_add_exception_objects,evoab,\ + connectivity/source/drivers/evoab2/NDriver \ + connectivity/source/drivers/evoab2/NTable \ + connectivity/source/drivers/evoab2/NColumns \ + connectivity/source/drivers/evoab2/NTables \ + connectivity/source/drivers/evoab2/NCatalog \ + connectivity/source/drivers/evoab2/NConnection \ + connectivity/source/drivers/evoab2/NDatabaseMetaData \ + connectivity/source/drivers/evoab2/NStatement \ + connectivity/source/drivers/evoab2/NPreparedStatement \ + connectivity/source/drivers/evoab2/NServices \ + connectivity/source/drivers/evoab2/NResultSet \ + connectivity/source/drivers/evoab2/NResultSetMetaData \ + connectivity/source/drivers/evoab2/EApi \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_file.mk b/connectivity/Library_file.mk new file mode 100644 index 000000000..2ed564a2e --- /dev/null +++ b/connectivity/Library_file.mk @@ -0,0 +1,71 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,file)) + +$(eval $(call gb_Library_add_defs,file,\ + -DOOO_DLLIMPLEMENTATION_FILE \ +)) + +$(eval $(call gb_Library_set_precompiled_header,file,connectivity/inc/pch/precompiled_file)) + +$(eval $(call gb_Library_set_include,file,\ + $$(INCLUDE) \ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ + -I$(WORKDIR)/YaccTarget/connectivity/source/parse \ +)) + +$(eval $(call gb_Library_use_external,file,boost_headers)) + +$(eval $(call gb_Library_use_sdk_api,file)) + +$(eval $(call gb_Library_use_libraries,file,\ + cppu \ + cppuhelper \ + svl \ + tl \ + ucbhelper \ + sal \ + salhelper \ + dbtools \ + utl \ + comphelper \ +)) + +$(eval $(call gb_Library_add_exception_objects,file,\ + connectivity/source/drivers/component/CColumns \ + connectivity/source/drivers/component/CDatabaseMetaData \ + connectivity/source/drivers/component/CPreparedStatement \ + connectivity/source/drivers/component/CResultSet \ + connectivity/source/drivers/component/CStatement \ + connectivity/source/drivers/component/CTable \ + connectivity/source/drivers/file/FCatalog \ + connectivity/source/drivers/file/FColumns \ + connectivity/source/drivers/file/FConnection \ + connectivity/source/drivers/file/FDatabaseMetaData \ + connectivity/source/drivers/file/FDateFunctions \ + connectivity/source/drivers/file/FDriver \ + connectivity/source/drivers/file/FNoException \ + connectivity/source/drivers/file/FNumericFunctions \ + connectivity/source/drivers/file/FPreparedStatement \ + connectivity/source/drivers/file/FResultSet \ + connectivity/source/drivers/file/FResultSetMetaData \ + connectivity/source/drivers/file/FStatement \ + connectivity/source/drivers/file/FStringFunctions \ + connectivity/source/drivers/file/FTable \ + connectivity/source/drivers/file/FTables \ + connectivity/source/drivers/file/fanalyzer \ + connectivity/source/drivers/file/fcode \ + connectivity/source/drivers/file/fcomp \ + connectivity/source/drivers/file/quotedstring \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_firebird_sdbc.mk b/connectivity/Library_firebird_sdbc.mk new file mode 100644 index 000000000..2c6eb559b --- /dev/null +++ b/connectivity/Library_firebird_sdbc.mk @@ -0,0 +1,67 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,firebird_sdbc)) + +$(eval $(call gb_Library_use_sdk_api,firebird_sdbc)) + +$(eval $(call gb_Library_use_externals,firebird_sdbc,\ + boost_headers \ + libfbembed \ +)) + +$(eval $(call gb_Library_set_include,firebird_sdbc,\ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ + $$(INCLUDE) \ + -I$(WORKDIR)/YaccTarget/connectivity/source/parse \ +)) + +$(eval $(call gb_Library_set_precompiled_header,firebird_sdbc,connectivity/inc/pch/precompiled_firebird_sdbc)) + +$(eval $(call gb_Library_use_libraries,firebird_sdbc, \ + comphelper \ + cppu \ + cppuhelper \ + dbtools \ + sal \ + salhelper \ + utl \ + svt \ + tl \ + vcl \ +)) + +$(eval $(call gb_Library_set_componentfile,firebird_sdbc,connectivity/source/drivers/firebird/firebird_sdbc)) + +$(eval $(call gb_Library_add_exception_objects,firebird_sdbc,\ + connectivity/source/drivers/firebird/Blob \ + connectivity/source/drivers/firebird/Clob \ + connectivity/source/drivers/firebird/Catalog \ + connectivity/source/drivers/firebird/Column \ + connectivity/source/drivers/firebird/Columns \ + connectivity/source/drivers/firebird/Connection \ + connectivity/source/drivers/firebird/DatabaseMetaData \ + connectivity/source/drivers/firebird/Driver \ + connectivity/source/drivers/firebird/Indexes \ + connectivity/source/drivers/firebird/Keys \ + connectivity/source/drivers/firebird/PreparedStatement \ + connectivity/source/drivers/firebird/ResultSet \ + connectivity/source/drivers/firebird/ResultSetMetaData \ + connectivity/source/drivers/firebird/Services \ + connectivity/source/drivers/firebird/Statement \ + connectivity/source/drivers/firebird/StatementCommonBase \ + connectivity/source/drivers/firebird/Table \ + connectivity/source/drivers/firebird/Tables \ + connectivity/source/drivers/firebird/User \ + connectivity/source/drivers/firebird/Users \ + connectivity/source/drivers/firebird/Util \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_flat.mk b/connectivity/Library_flat.mk new file mode 100644 index 000000000..c37b6ae5e --- /dev/null +++ b/connectivity/Library_flat.mk @@ -0,0 +1,56 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,flat)) + +$(eval $(call gb_Library_set_componentfile,flat,connectivity/source/drivers/flat/flat)) + +$(eval $(call gb_Library_use_external,flat,boost_headers)) + +$(eval $(call gb_Library_use_sdk_api,flat)) + +$(eval $(call gb_Library_set_precompiled_header,flat,connectivity/inc/pch/precompiled_flat)) + +$(eval $(call gb_Library_set_include,flat,\ + $$(INCLUDE) \ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ + -I$(WORKDIR)/YaccTarget/connectivity/source/parse \ +)) + +$(eval $(call gb_Library_use_libraries,flat,\ + cppu \ + cppuhelper \ + tl \ + svl \ + utl \ + i18nlangtag \ + sal \ + salhelper \ + dbtools \ + file \ + comphelper \ +)) + +$(eval $(call gb_Library_add_exception_objects,flat,\ + connectivity/source/drivers/flat/EResultSet \ + connectivity/source/drivers/flat/EStatement \ + connectivity/source/drivers/flat/EPreparedStatement \ + connectivity/source/drivers/flat/ETable \ + connectivity/source/drivers/flat/EDatabaseMetaData \ + connectivity/source/drivers/flat/ECatalog \ + connectivity/source/drivers/flat/EColumns \ + connectivity/source/drivers/flat/ETables \ + connectivity/source/drivers/flat/EConnection \ + connectivity/source/drivers/flat/Eservices \ + connectivity/source/drivers/flat/EDriver \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_hsqldb.mk b/connectivity/Library_hsqldb.mk new file mode 100644 index 000000000..068540214 --- /dev/null +++ b/connectivity/Library_hsqldb.mk @@ -0,0 +1,62 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,hsqldb)) + +$(eval $(call gb_Library_set_include,hsqldb,\ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_Library_use_externals,hsqldb,\ + boost_headers \ + hsqldb \ +)) + +$(eval $(call gb_Library_use_sdk_api,hsqldb)) + +$(eval $(call gb_Library_use_libraries,hsqldb,\ + comphelper \ + cppu \ + cppuhelper \ + dbtools \ + jvmfwk \ + sal \ + salhelper \ + tl \ + utl \ + i18nlangtag \ +)) + +$(eval $(call gb_Library_set_componentfile,hsqldb,connectivity/source/drivers/hsqldb/hsqldb)) + +$(eval $(call gb_Library_add_exception_objects,hsqldb,\ + connectivity/source/drivers/hsqldb/HCatalog \ + connectivity/source/drivers/hsqldb/HColumns \ + connectivity/source/drivers/hsqldb/HConnection \ + connectivity/source/drivers/hsqldb/HDriver \ + connectivity/source/drivers/hsqldb/HStorageAccess \ + connectivity/source/drivers/hsqldb/HStorageMap \ + connectivity/source/drivers/hsqldb/HTable \ + connectivity/source/drivers/hsqldb/HTables \ + connectivity/source/drivers/hsqldb/HTerminateListener \ + connectivity/source/drivers/hsqldb/HTools \ + connectivity/source/drivers/hsqldb/HUser \ + connectivity/source/drivers/hsqldb/HUsers \ + connectivity/source/drivers/hsqldb/HView \ + connectivity/source/drivers/hsqldb/HViews \ + connectivity/source/drivers/hsqldb/Hservices \ + connectivity/source/drivers/hsqldb/StorageFileAccess \ + connectivity/source/drivers/hsqldb/StorageNativeInputStream \ + connectivity/source/drivers/hsqldb/StorageNativeOutputStream \ + connectivity/source/drivers/hsqldb/accesslog \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_jdbc.mk b/connectivity/Library_jdbc.mk new file mode 100644 index 000000000..fea943cd7 --- /dev/null +++ b/connectivity/Library_jdbc.mk @@ -0,0 +1,77 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,jdbc)) + +$(eval $(call gb_Library_set_componentfile,jdbc,connectivity/source/drivers/jdbc/jdbc)) + +$(eval $(call gb_Library_use_external,jdbc,boost_headers)) + +$(eval $(call gb_Library_use_sdk_api,jdbc)) + +$(eval $(call gb_Library_set_include,jdbc,\ + $$(INCLUDE) \ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ + -I$(WORKDIR)/YaccTarget/connectivity/source/parse \ +)) + +$(eval $(call gb_Library_use_common_precompiled_header,jdbc)) + +$(eval $(call gb_Library_use_libraries,jdbc,\ + cppu \ + cppuhelper \ + sal \ + salhelper \ + jvmaccess \ + dbtools \ + tl \ + utl \ + jvmfwk \ + comphelper \ +)) + +$(eval $(call gb_Library_add_exception_objects,jdbc,\ + connectivity/source/drivers/jdbc/Array \ + connectivity/source/drivers/jdbc/Blob \ + connectivity/source/drivers/jdbc/Boolean \ + connectivity/source/drivers/jdbc/CallableStatement \ + connectivity/source/drivers/jdbc/Class \ + connectivity/source/drivers/jdbc/Clob \ + connectivity/source/drivers/jdbc/ConnectionLog \ + connectivity/source/drivers/jdbc/DatabaseMetaData \ + connectivity/source/drivers/jdbc/Date \ + connectivity/source/drivers/jdbc/DriverPropertyInfo \ + connectivity/source/drivers/jdbc/Exception \ + connectivity/source/drivers/jdbc/InputStream \ + connectivity/source/drivers/jdbc/JConnection \ + connectivity/source/drivers/jdbc/JDriver \ + connectivity/source/drivers/jdbc/JStatement \ + connectivity/source/drivers/jdbc/Object \ + connectivity/source/drivers/jdbc/PreparedStatement \ + connectivity/source/drivers/jdbc/Reader \ + connectivity/source/drivers/jdbc/Ref \ + connectivity/source/drivers/jdbc/ResultSet \ + connectivity/source/drivers/jdbc/ResultSetMetaData \ + connectivity/source/drivers/jdbc/SQLException \ + connectivity/source/drivers/jdbc/SQLWarning \ + connectivity/source/drivers/jdbc/String \ + connectivity/source/drivers/jdbc/Throwable \ + connectivity/source/drivers/jdbc/Timestamp \ + connectivity/source/drivers/jdbc/jservices \ + connectivity/source/drivers/jdbc/JBigDecimal \ + connectivity/source/drivers/jdbc/tools \ + connectivity/source/drivers/jdbc/ContextClassLoader \ +)) + +# Runtime dependency for unit-tests +$(call gb_Library_get_target,jdbc) :| $(call gb_Library_get_target,affine_uno_uno) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_macab1.mk b/connectivity/Library_macab1.mk new file mode 100644 index 000000000..263d0b10e --- /dev/null +++ b/connectivity/Library_macab1.mk @@ -0,0 +1,41 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,macab1)) + +$(eval $(call gb_Library_set_componentfile,macab1,connectivity/source/drivers/macab/macab1)) + +$(eval $(call gb_Library_use_external,macab1,boost_headers)) + +$(eval $(call gb_Library_use_sdk_api,macab1)) + +$(eval $(call gb_Library_use_libraries,macab1,\ + comphelper \ + cppu \ + cppuhelper \ + dbtools \ + sal \ + salhelper \ + tl \ +)) + +$(eval $(call gb_Library_set_include,macab1,\ + $$(INCLUDE) \ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ + -I$(WORKDIR)/YaccTarget/connectivity/source/parse \ +)) + +$(eval $(call gb_Library_add_exception_objects,macab1,\ + connectivity/source/drivers/macab/MacabDriver \ + connectivity/source/drivers/macab/MacabServices \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_macabdrv1.mk b/connectivity/Library_macabdrv1.mk new file mode 100644 index 000000000..1baf464a6 --- /dev/null +++ b/connectivity/Library_macabdrv1.mk @@ -0,0 +1,58 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,macabdrv1)) + +$(eval $(call gb_Library_use_external,macabdrv1,boost_headers)) + +$(eval $(call gb_Library_use_sdk_api,macabdrv1)) + +$(eval $(call gb_Library_use_system_darwin_frameworks,macabdrv1,\ + Carbon \ + AddressBook \ +)) + +$(eval $(call gb_Library_use_libraries,macabdrv1,\ + comphelper \ + cppu \ + cppuhelper \ + dbtools \ + sal \ + salhelper \ +)) + +$(eval $(call gb_Library_set_include,macabdrv1,\ + $$(INCLUDE) \ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ + -I$(WORKDIR)/YaccTarget/connectivity/source/parse \ +)) + +$(eval $(call gb_Library_add_exception_objects,macabdrv1,\ + connectivity/source/drivers/macab/MacabColumns \ + connectivity/source/drivers/macab/MacabTable \ + connectivity/source/drivers/macab/MacabTables \ + connectivity/source/drivers/macab/MacabCatalog \ + connectivity/source/drivers/macab/MacabResultSet \ + connectivity/source/drivers/macab/MacabStatement \ + connectivity/source/drivers/macab/MacabPreparedStatement \ + connectivity/source/drivers/macab/MacabDatabaseMetaData \ + connectivity/source/drivers/macab/MacabConnection \ + connectivity/source/drivers/macab/MacabResultSetMetaData \ + connectivity/source/drivers/macab/macabcondition \ + connectivity/source/drivers/macab/macaborder \ + connectivity/source/drivers/macab/MacabRecord \ + connectivity/source/drivers/macab/MacabRecords \ + connectivity/source/drivers/macab/MacabHeader \ + connectivity/source/drivers/macab/MacabGroup \ + connectivity/source/drivers/macab/MacabAddressBook \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_mork.mk b/connectivity/Library_mork.mk new file mode 100644 index 000000000..7c0a89b56 --- /dev/null +++ b/connectivity/Library_mork.mk @@ -0,0 +1,62 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,mork)) + +$(eval $(call gb_Library_set_componentfile,mork,connectivity/source/drivers/mork/mork)) + +$(eval $(call gb_Library_add_defs,mork,\ + -DLO_DLLIMPLEMENTATION_MORK \ +)) + +$(eval $(call gb_Library_set_include,mork,\ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ + $$(INCLUDE) \ + -I$(WORKDIR)/YaccTarget/connectivity/source/parse \ +)) + +$(eval $(call gb_Library_use_custom_headers,mork,\ + officecfg/registry \ +)) + +$(eval $(call gb_Library_use_external,mork,boost_headers)) + +$(eval $(call gb_Library_use_libraries,mork, \ + comphelper \ + cppu \ + cppuhelper \ + dbtools \ + sal \ + salhelper \ + tl \ + utl \ +)) + +$(eval $(call gb_Library_use_sdk_api,mork)) + +$(eval $(call gb_Library_add_exception_objects,mork, \ + connectivity/source/drivers/mork/MColumns \ + connectivity/source/drivers/mork/MColumnAlias \ + connectivity/source/drivers/mork/MorkParser \ + connectivity/source/drivers/mork/MCatalog \ + connectivity/source/drivers/mork/MConnection \ + connectivity/source/drivers/mork/MDatabaseMetaData \ + connectivity/source/drivers/mork/MDatabaseMetaDataHelper \ + connectivity/source/drivers/mork/MDriver \ + connectivity/source/drivers/mork/MStatement \ + connectivity/source/drivers/mork/MResultSet \ + connectivity/source/drivers/mork/MResultSetMetaData \ + connectivity/source/drivers/mork/MPreparedStatement \ + connectivity/source/drivers/mork/MQueryHelper \ + connectivity/source/drivers/mork/MTable \ + connectivity/source/drivers/mork/MTables \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_mozbootstrap.mk b/connectivity/Library_mozbootstrap.mk new file mode 100644 index 000000000..237726caf --- /dev/null +++ b/connectivity/Library_mozbootstrap.mk @@ -0,0 +1,35 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,mozbootstrap)) + +$(eval $(call gb_Library_set_componentfile,mozbootstrap,connectivity/source/drivers/mozab/bootstrap/mozbootstrap)) + +$(eval $(call gb_Library_set_include,mozbootstrap,\ + -I$(SRCDIR)/connectivity/source/drivers/mozab \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_Library_use_sdk_api,mozbootstrap)) + +$(eval $(call gb_Library_use_libraries,mozbootstrap,\ + comphelper \ + cppu \ + cppuhelper \ + sal \ +)) + +$(eval $(call gb_Library_add_exception_objects,mozbootstrap,\ + connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap \ + connectivity/source/drivers/mozab/bootstrap/MNSFolders \ + connectivity/source/drivers/mozab/bootstrap/MNSINIParser \ + connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_mysql_jdbc.mk b/connectivity/Library_mysql_jdbc.mk new file mode 100644 index 000000000..43c1c81b3 --- /dev/null +++ b/connectivity/Library_mysql_jdbc.mk @@ -0,0 +1,48 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,mysql_jdbc)) + +$(eval $(call gb_Library_set_componentfile,mysql_jdbc,connectivity/source/drivers/mysql_jdbc/mysql_jdbc)) + +$(eval $(call gb_Library_use_external,mysql_jdbc,boost_headers)) + +$(eval $(call gb_Library_use_sdk_api,mysql_jdbc)) + +$(eval $(call gb_Library_set_include,mysql_jdbc,\ + $$(INCLUDE) \ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ +)) + +$(eval $(call gb_Library_set_precompiled_header,mysql_jdbc,connectivity/inc/pch/precompiled_mysql_jdbc)) + +$(eval $(call gb_Library_use_libraries,mysql_jdbc,\ + cppu \ + cppuhelper \ + sal \ + salhelper \ + dbtools \ + comphelper \ +)) + +$(eval $(call gb_Library_add_exception_objects,mysql_jdbc,\ + connectivity/source/drivers/mysql_jdbc/YDriver \ + connectivity/source/drivers/mysql_jdbc/YTables \ + connectivity/source/drivers/mysql_jdbc/YTable \ + connectivity/source/drivers/mysql_jdbc/YViews \ + connectivity/source/drivers/mysql_jdbc/YCatalog \ + connectivity/source/drivers/mysql_jdbc/YColumns \ + connectivity/source/drivers/mysql_jdbc/YUser \ + connectivity/source/drivers/mysql_jdbc/YUsers \ + connectivity/source/drivers/mysql_jdbc/Yservices \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_mysqlc.mk b/connectivity/Library_mysqlc.mk new file mode 100644 index 000000000..f765fb1e3 --- /dev/null +++ b/connectivity/Library_mysqlc.mk @@ -0,0 +1,67 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,mysqlc)) + +$(eval $(call gb_Library_use_externals,mysqlc,\ + boost_headers \ + mariadb-connector-c \ + openssl \ +)) + +$(eval $(call gb_Library_set_include,mysqlc,\ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ + $$(INCLUDE) \ + -I$(WORKDIR)/YaccTarget/connectivity/source/parse \ +)) + +$(eval $(call gb_Library_add_libs,mysqlc,\ + $(if $(filter-out WNT,$(OS)),$(if $(filter HAIKU MACOSX SOLARIS,$(OS)),\ + -lz -lm,-rdynamic -lz -lcrypt -lm)) \ + $(if $(filter LINUX,$(OS)),-ldl,) \ +)) + +$(eval $(call gb_Library_use_sdk_api,mysqlc)) + +$(eval $(call gb_Library_use_libraries,mysqlc,\ + cppu \ + dbtools \ + sal \ + salhelper \ + comphelper \ + cppuhelper \ +)) + +$(eval $(call gb_Library_add_defs,mysqlc,\ + -DCPPDBC_EXPORTS \ + -DCPPCONN_LIB_BUILD \ + -DMARIADBC_VERSION_MAJOR=$(MARIADBC_MAJOR) \ + -DMARIADBC_VERSION_MINOR=$(MARIADBC_MINOR) \ + -DMARIADBC_VERSION_MICRO=$(MARIADBC_MICRO) \ + $(if $(BUNDLE_MARIADB_CONNECTOR_C),-DBUNDLE_MARIADB=\"$(LIBMARIADB)\") \ +)) + +$(eval $(call gb_Library_add_exception_objects,mysqlc,\ + connectivity/source/drivers/mysqlc/mysqlc_driver \ + connectivity/source/drivers/mysqlc/mysqlc_services \ + connectivity/source/drivers/mysqlc/mysqlc_connection \ + connectivity/source/drivers/mysqlc/mysqlc_resultset \ + connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset \ + connectivity/source/drivers/mysqlc/mysqlc_resultsetmetadata \ + connectivity/source/drivers/mysqlc/mysqlc_statement \ + connectivity/source/drivers/mysqlc/mysqlc_preparedstatement \ + connectivity/source/drivers/mysqlc/mysqlc_databasemetadata \ + connectivity/source/drivers/mysqlc/mysqlc_types \ + connectivity/source/drivers/mysqlc/mysqlc_general \ +)) + +$(eval $(call gb_Library_set_componentfile,mysqlc,connectivity/source/drivers/mysqlc/mysqlc)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_odbc.mk b/connectivity/Library_odbc.mk new file mode 100644 index 000000000..1d1c82cf1 --- /dev/null +++ b/connectivity/Library_odbc.mk @@ -0,0 +1,61 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,odbc)) + +$(eval $(call gb_Library_set_componentfile,odbc,connectivity/source/drivers/odbc/odbc)) + +$(eval $(call gb_Library_use_sdk_api,odbc)) + +$(eval $(call gb_Library_set_include,odbc,\ + $$(INCLUDE) \ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ + -I$(WORKDIR)/YaccTarget/connectivity/source/parse \ +)) + +$(eval $(call gb_Library_add_defs,odbc,\ + -DOOO_DLLIMPLEMENTATION_ODBCBASE \ + $(if $(and $(filter MACOSX,$(OS)), $(if $(SYSTEM_ODBC_HEADERS),,TRUE)), \ + -DSQL_WCHART_CONVERT) \ +)) + +$(eval $(call gb_Library_set_precompiled_header,odbc,connectivity/inc/pch/precompiled_odbc)) + +$(eval $(call gb_Library_use_externals,odbc,\ + boost_headers \ + odbc_headers \ +)) + +$(eval $(call gb_Library_use_libraries,odbc,\ + cppu \ + cppuhelper \ + comphelper \ + dbtools \ + sal \ + salhelper \ +)) + +$(eval $(call gb_Library_add_exception_objects,odbc,\ + connectivity/source/drivers/odbc/oservices \ + connectivity/source/drivers/odbc/ORealDriver \ + connectivity/source/drivers/odbc/OFunctions \ + connectivity/source/drivers/odbc/OPreparedStatement \ + connectivity/source/drivers/odbc/OStatement \ + connectivity/source/drivers/odbc/OResultSetMetaData \ + connectivity/source/drivers/odbc/OResultSet \ + connectivity/source/drivers/odbc/OTools \ + connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet \ + connectivity/source/drivers/odbc/ODatabaseMetaData \ + connectivity/source/drivers/odbc/ODriver \ + connectivity/source/drivers/odbc/OConnection \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_postgresql-sdbc-impl.mk b/connectivity/Library_postgresql-sdbc-impl.mk new file mode 100644 index 000000000..c372f3f0c --- /dev/null +++ b/connectivity/Library_postgresql-sdbc-impl.mk @@ -0,0 +1,106 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,postgresql-sdbc-impl)) + +$(eval $(call gb_Library_add_defs,postgresql-sdbc-impl,\ + -DPQ_SDBC_MAJOR=0 \ + -DPQ_SDBC_MINOR=8 \ + -DPQ_SDBC_MICRO=2 \ +)) + +$(eval $(call gb_Library_set_precompiled_header,postgresql-sdbc-impl,connectivity/inc/pch/precompiled_postgresql-sdbc-impl)) + +$(eval $(call gb_Library_use_sdk_api,postgresql-sdbc-impl)) + +$(eval $(call gb_Library_use_libraries,postgresql-sdbc-impl,\ + comphelper \ + cppu \ + cppuhelper \ + dbtools \ + sal \ + salhelper \ +)) + +ifeq ($(OS),WNT) +$(eval $(call gb_Library_use_system_win32_libs,postgresql-sdbc-impl,\ + shell32 \ + wldap32 \ +)) + +ifeq ($(COM),MSC) +$(eval $(call gb_Library_add_ldflags,postgresql-sdbc-impl,\ + /NODEFAULTLIB:libcmt.lib \ +)) +endif + +endif + +$(eval $(call gb_Library_use_externals,postgresql-sdbc-impl,\ + boost_headers \ + postgresql \ + $(if $(filter-out MSC,$(COM)), \ + openssl \ + $(if $(ENABLE_LDAP),openldap) \ + nss3 \ + plc4 \ + ssl3 \ + ) \ +)) + +ifeq ($(SYSTEM_POSTGRESQL),) +ifneq ($(OS),WNT) + +$(eval $(call gb_Library_add_libs,postgresql-sdbc-impl,\ + $(if $(WITH_GSSAPI),$(GSSAPI_LIBS)) \ + $(if $(WITH_KRB5),$(KRB5_LIBS)) \ + $(if $(filter-out MACOSX,$(OS)),-ldl) \ +)) + +endif +endif + +$(eval $(call gb_Library_set_componentfile,postgresql-sdbc-impl,connectivity/source/drivers/postgresql/postgresql-sdbc-impl)) + +$(eval $(call gb_Library_add_exception_objects,postgresql-sdbc-impl,\ + connectivity/source/drivers/postgresql/pq_array \ + connectivity/source/drivers/postgresql/pq_baseresultset \ + connectivity/source/drivers/postgresql/pq_connection \ + connectivity/source/drivers/postgresql/pq_databasemetadata \ + connectivity/source/drivers/postgresql/pq_fakedupdateableresultset \ + connectivity/source/drivers/postgresql/pq_preparedstatement \ + connectivity/source/drivers/postgresql/pq_resultset \ + connectivity/source/drivers/postgresql/pq_resultsetmetadata \ + connectivity/source/drivers/postgresql/pq_sequenceresultset \ + connectivity/source/drivers/postgresql/pq_sequenceresultsetmetadata \ + connectivity/source/drivers/postgresql/pq_statement \ + connectivity/source/drivers/postgresql/pq_statics \ + connectivity/source/drivers/postgresql/pq_tools \ + connectivity/source/drivers/postgresql/pq_updateableresultset \ + connectivity/source/drivers/postgresql/pq_xbase \ + connectivity/source/drivers/postgresql/pq_xcolumn \ + connectivity/source/drivers/postgresql/pq_xcolumns \ + connectivity/source/drivers/postgresql/pq_xcontainer \ + connectivity/source/drivers/postgresql/pq_xindex \ + connectivity/source/drivers/postgresql/pq_xindexcolumn \ + connectivity/source/drivers/postgresql/pq_xindexcolumns \ + connectivity/source/drivers/postgresql/pq_xindexes \ + connectivity/source/drivers/postgresql/pq_xkey \ + connectivity/source/drivers/postgresql/pq_xkeycolumn \ + connectivity/source/drivers/postgresql/pq_xkeycolumns \ + connectivity/source/drivers/postgresql/pq_xkeys \ + connectivity/source/drivers/postgresql/pq_xtable \ + connectivity/source/drivers/postgresql/pq_xtables \ + connectivity/source/drivers/postgresql/pq_xuser \ + connectivity/source/drivers/postgresql/pq_xusers \ + connectivity/source/drivers/postgresql/pq_xview \ + connectivity/source/drivers/postgresql/pq_xviews \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_postgresql-sdbc.mk b/connectivity/Library_postgresql-sdbc.mk new file mode 100644 index 000000000..48613ab91 --- /dev/null +++ b/connectivity/Library_postgresql-sdbc.mk @@ -0,0 +1,34 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,postgresql-sdbc)) + +$(eval $(call gb_Library_add_defs,postgresql-sdbc,\ + -DPQ_SDBC_MAJOR=0 \ + -DPQ_SDBC_MINOR=8 \ + -DPQ_SDBC_MICRO=2 \ +)) + +$(eval $(call gb_Library_use_sdk_api,postgresql-sdbc)) + +$(eval $(call gb_Library_use_libraries,postgresql-sdbc,\ + comphelper \ + cppu \ + cppuhelper \ + sal \ + salhelper \ +)) + +$(eval $(call gb_Library_set_componentfile,postgresql-sdbc,connectivity/source/drivers/postgresql/postgresql-sdbc)) + +$(eval $(call gb_Library_add_exception_objects,postgresql-sdbc,\ + connectivity/source/drivers/postgresql/pq_driver \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_sdbc2.mk b/connectivity/Library_sdbc2.mk new file mode 100644 index 000000000..494dc4208 --- /dev/null +++ b/connectivity/Library_sdbc2.mk @@ -0,0 +1,39 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,sdbc2)) + +$(eval $(call gb_Library_set_componentfile,sdbc2,connectivity/source/manager/sdbc2)) + +$(eval $(call gb_Library_use_external,sdbc2,boost_headers)) + +$(eval $(call gb_Library_use_sdk_api,sdbc2)) + +$(eval $(call gb_Library_set_include,sdbc2,\ + $$(INCLUDE) \ + -I$(SRCDIR)/connectivity/inc \ +)) + +$(eval $(call gb_Library_use_libraries,sdbc2,\ + cppu \ + cppuhelper \ + comphelper \ + dbtools \ + utl \ + sal \ + tl \ +)) + +$(eval $(call gb_Library_add_exception_objects,sdbc2,\ + connectivity/source/manager/mdrivermanager \ + connectivity/source/manager/mregistration \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Library_writer.mk b/connectivity/Library_writer.mk new file mode 100644 index 000000000..d07f572a3 --- /dev/null +++ b/connectivity/Library_writer.mk @@ -0,0 +1,49 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,writer)) + +$(eval $(call gb_Library_set_componentfile,writer,connectivity/source/drivers/writer/writer)) + +$(eval $(call gb_Library_use_external,writer,boost_headers)) + +$(eval $(call gb_Library_use_sdk_api,writer)) + +$(eval $(call gb_Library_set_include,writer,\ + $$(INCLUDE) \ + -I$(SRCDIR)/connectivity/inc \ + -I$(SRCDIR)/connectivity/source/inc \ + -I$(WORKDIR)/YaccTarget/connectivity/source/parse \ +)) + +$(eval $(call gb_Library_use_libraries,writer,\ + cppu \ + cppuhelper \ + svl \ + tl \ + utl \ + sal \ + salhelper \ + dbtools \ + file \ + comphelper \ +)) + +$(eval $(call gb_Library_add_exception_objects,writer,\ + connectivity/source/drivers/writer/WCatalog \ + connectivity/source/drivers/writer/WConnection \ + connectivity/source/drivers/writer/WDatabaseMetaData \ + connectivity/source/drivers/writer/WDriver \ + connectivity/source/drivers/writer/WTable \ + connectivity/source/drivers/writer/WTables \ + connectivity/source/drivers/writer/Wservices \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Makefile b/connectivity/Makefile new file mode 100644 index 000000000..ccb1c85a0 --- /dev/null +++ b/connectivity/Makefile @@ -0,0 +1,7 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- + +module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST)))) + +include $(module_directory)/../solenv/gbuild/partial_build.mk + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Module_connectivity.mk b/connectivity/Module_connectivity.mk new file mode 100644 index 000000000..6a5dd9263 --- /dev/null +++ b/connectivity/Module_connectivity.mk @@ -0,0 +1,149 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Module_Module,connectivity)) + +$(eval $(call gb_Module_add_targets,connectivity,\ + Library_dbtools \ +)) + +ifneq (,$(filter DBCONNECTIVITY,$(BUILD_TYPE))) + +$(eval $(call gb_Module_add_targets,connectivity,\ + Configuration_calc \ + Configuration_dbase \ + Configuration_flat \ + Configuration_mysql_jdbc \ + Configuration_odbc \ + Configuration_mysql_jdbc \ + Configuration_writer \ + Library_calc \ + Library_dbase \ + Library_dbpool2 \ + Library_file \ + Library_flat \ + $(if $(filter ANDROID iOS,$(OS)),,Library_odbc) \ + Library_mysql_jdbc \ + Library_sdbc2 \ + Library_writer \ +)) + +$(eval $(call gb_Module_add_l10n_targets,connectivity,\ + AllLangMoTarget_cnr \ +)) + +ifneq ($(ENABLE_JAVA),) +$(eval $(call gb_Module_add_targets,connectivity,\ + Configuration_hsqldb \ + Configuration_jdbc \ + Jar_sdbc_hsqldb \ + Library_hsqldb \ + Library_jdbc \ +)) +endif + +ifneq ($(OS),WNT) + +ifeq ($(OS),MACOSX) +$(eval $(call gb_Module_add_targets,connectivity,\ + Configuration_macab \ + Library_macab1 \ + Library_macabdrv1 \ +)) +endif + +endif + +ifeq ($(OS),WNT) +$(eval $(call gb_Module_add_targets,connectivity,\ + Configuration_ado \ + Library_ado \ +)) +endif + +ifeq ($(ENABLE_EVOAB2),TRUE) +$(eval $(call gb_Module_add_targets,connectivity,\ + Configuration_evoab \ + Library_evoab \ +)) +endif + +ifeq ($(ENABLE_FIREBIRD_SDBC),TRUE) +$(eval $(call gb_Module_add_targets,connectivity,\ + Configuration_firebird \ + Library_firebird_sdbc \ +)) +endif + +ifeq ($(ENABLE_MARIADBC),TRUE) +$(eval $(call gb_Module_add_targets,connectivity,\ + Configuration_mysql \ + Library_mysqlc \ +)) +endif + +ifneq ($(BUILD_POSTGRESQL_SDBC),) +$(eval $(call gb_Module_add_targets,connectivity,\ + Configuration_postgresql \ + Library_postgresql-sdbc \ + Library_postgresql-sdbc-impl \ + Package_postgresql-sdbc \ + Rdb_postgresql-sdbc \ +)) +endif + +ifneq (,$(filter DESKTOP,$(BUILD_TYPE))) + +$(eval $(call gb_Module_add_targets,connectivity,\ + Configuration_mork \ + Executable_mork_helper \ + Library_mork \ + Library_mozbootstrap \ +)) + +$(eval $(call gb_Module_add_check_targets,connectivity,\ + CppunitTest_connectivity_mork \ +)) + +endif + +ifeq ($(OS),WNT) +# "ADO is not available on 64bit" said the commit +ifneq ($(CPUNAME),X86_64) +$(eval $(call gb_Module_add_check_targets,connectivity,\ + CppunitTest_connectivity_ado \ +)) +endif +endif + +ifneq ($(filter QADEVOOO,$(BUILD_TYPE)),) +$(eval $(call gb_Module_add_subsequentcheck_targets,connectivity,\ + Jar_ConnectivityTools \ +)) +# FIXME: Does not work. Convert to JUnit. +# JunitTest_complex \ + +endif + +ifneq ($(CONNECTIVITY_TEST_MYSQL_DRIVER),) +$(eval $(call gb_Module_add_check_targets,connectivity,\ + CppunitTest_connectivity_mysql_test \ +)) +endif + +# general tests +$(eval $(call gb_Module_add_check_targets,connectivity,\ + CppunitTest_connectivity_commontools \ + CppunitTest_connectivity_sharedresources \ +)) + +endif + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/Package_postgresql-sdbc.mk b/connectivity/Package_postgresql-sdbc.mk new file mode 100644 index 000000000..171fb6e23 --- /dev/null +++ b/connectivity/Package_postgresql-sdbc.mk @@ -0,0 +1,12 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Package_Package,connectivity_postgresql-sdbc,$(SRCDIR)/connectivity/source/drivers/postgresql)) + +# vim: set noet sw=4 ts=4: diff --git a/connectivity/README b/connectivity/README new file mode 100644 index 000000000..ebae35452 --- /dev/null +++ b/connectivity/README @@ -0,0 +1,24 @@ +Contains database pieces, drivers, etc. + +[[dbaccess]] builds UI on top of this. + +=== mysql_test === + +- The CppunitTest_mysql_test unit test can be used to test the mysqlc + library with any versions of mysql or mariadb server of your choice. + +- This test does not run automatically. It can be triggered with setting + the environment variable "CONNECTIVITY_TEST_MYSQL_DRIVER". + +- The environment variable should contain a URL of the following format: + [user]/[passwd]@sdbc:mysql:mysqlc:[host]:[port]/db_name + +- tl;dr: + + podman pull mariadb/server + podman run --name=mariadb -e MYSQL_ROOT_PASSWORD=foobarbaz -p 127.0.0.1:3306:3306 mariadb/server + podman exec -it mariadb /bin/bash -c "echo -e CREATE DATABASE test | /usr/bin/mysql -u root" + (cd connectivity && make -srj8 CppunitTest_connectivity_mysql_test CONNECTIVITY_TEST_MYSQL_DRIVER="root/foobarbaz@sdbc:mysql:mysqlc:127.0.0.1:3306/test") + podman stop mariadb + podman rm mariadb + diff --git a/connectivity/Rdb_postgresql-sdbc.mk b/connectivity/Rdb_postgresql-sdbc.mk new file mode 100644 index 000000000..6162b309d --- /dev/null +++ b/connectivity/Rdb_postgresql-sdbc.mk @@ -0,0 +1,17 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Rdb_Rdb_install,postgresql-sdbc)) + +$(eval $(call gb_Rdb_add_components,postgresql-sdbc,\ + connectivity/source/drivers/postgresql/postgresql-sdbc \ + connectivity/source/drivers/postgresql/postgresql-sdbc-impl \ +)) + +# vim: set noet sw=4 ts=4: 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 000000000..66b6f5489 --- /dev/null +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java @@ -0,0 +1,62 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package com.sun.star.sdbcx.comp.hsqldb; + +public class NativeInputStreamHelper extends java.io.InputStream{ + private final String key; + private final String file; + private final StorageNativeInputStream in; + /** Creates a new instance of NativeInputStreamHelper */ + public NativeInputStreamHelper(String key,String _file) { + file = _file; + this.key = key; + in = new StorageNativeInputStream(key,file); + } + + @Override + public int read() throws java.io.IOException { + return in.read(key,file); + } + + @Override + public int read(byte[] b, int off, int len) throws java.io.IOException { + return in.read(key,file,b,off,len); + } + + @Override + public void close() throws java.io.IOException { + in.close(key,file); + } + + @Override + public long skip(long n) throws java.io.IOException { + return in.skip(key,file,n); + } + + @Override + public int available() throws java.io.IOException { + return in.available(key,file); + } + + @Override + 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 000000000..e8ea8d44e --- /dev/null +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeLibraries.java @@ -0,0 +1,71 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +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("sal3"); + loadLibrary("dbtoolsmi"); + } + loadLibrary("hsqldb"); + } + + private static void loadLibrary(String libname) { + // At least on macOS 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 macOS Tiger) works + // there: + try { + System.loadLibrary(libname); + } catch (UnsatisfiedLinkError e) { + ClassLoader cl = NativeLibraries.class.getClassLoader(); + if (cl instanceof URLClassLoader) { + String sysname = System.mapLibraryName(libname); + // At least Oracle's 1.7.0_51 now maps to .dylib rather than + // .jnilib: + if (System.getProperty("os.name").startsWith("Mac") + && sysname.endsWith(".dylib")) + { + sysname + = sysname.substring( + 0, sysname.length() - "dylib".length()) + + "jnilib"; + } + URL url = ((URLClassLoader) cl).findResource(sysname); + if (url != null) { + try { + System.load(new File(url.toURI()).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 000000000..6445f2413 --- /dev/null +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeOutputStreamHelper.java @@ -0,0 +1,60 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.sdbcx.comp.hsqldb; + +public class NativeOutputStreamHelper extends java.io.OutputStream{ + + private final String key; + private final String file; + private final StorageNativeOutputStream out; + /** Creates a new instance of NativeOutputStreamHelper */ + public NativeOutputStreamHelper(String key,String _file) { + file = _file; + this.key = key; + out = new StorageNativeOutputStream(file,key); + } + + @Override + public void write(byte[] b, int off, int len) throws java.io.IOException{ + out.write(key,file,b, off, len); + } + + @Override + public void write(byte[] b) throws java.io.IOException{ + out.write(key,file,b); + } + + @Override + public void close() throws java.io.IOException{ + out.close(key,file); + } + + @Override + public void write(int b) throws java.io.IOException{ + out.write(key,file,b); + } + + @Override + 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 000000000..5a9bc8bb6 --- /dev/null +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeStorageAccess.java @@ -0,0 +1,62 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.sdbcx.comp.hsqldb; + +public class NativeStorageAccess { + static { NativeLibraries.load(); } + + public static final int READ = 1; + private static final int SEEKABLE = 2; + private static final int SEEKABLEREAD = 3; + public static final int WRITE = 4; + private 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 ex1){ + java.io.IOException ex2 = new java.io.IOException(); + ex2.initCause(ex1); + throw ex2; + } + } + private 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 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; + + +} 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 000000000..6a53d110e --- /dev/null +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageAccess.java @@ -0,0 +1,126 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package com.sun.star.sdbcx.comp.hsqldb; + +@SuppressWarnings("ucd") +public class StorageAccess implements org.hsqldb.lib.Storage { + String key; + String name; + boolean readonly; + NativeStorageAccess access; + /** 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 ex1){ + java.io.IOException ex2 = new java.io.IOException(); + ex2.initCause(ex1); + throw ex2; + } + } + public void close() throws java.io.IOException{ + access.close(name,key); + } + + public long getFilePointer() throws java.io.IOException{ + return access.getFilePointer(name,key); + } + + public long length() throws java.io.IOException{ + return access.length(name,key); + } + + public int read() throws java.io.IOException{ + return access.read(name,key); + } + + public void read(byte[] b, int off, int len) throws java.io.IOException{ + access.read(name,key,b,off,len); + } + + // based on the same code that reads an int from the .data file in HSQLDB + public int readInt() throws java.io.IOException{ + 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)); + } + + public void seek(long position) throws java.io.IOException{ + access.seek(name,key,position); + } + + public void write(byte[] b, int offset, int length) throws java.io.IOException{ + access.write(name,key,b,offset,length); + } + + public void writeInt(int v) throws java.io.IOException{ + 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; + } + + @SuppressWarnings("cast") + public long readLong() throws java.io.IOException { + return (((long) readInt()) << 32) + (((long) readInt()) & 0xFFFFFFFFL); + } + + public boolean wasNio() { + return false; + } + + public void writeLong(long v) throws java.io.IOException { + 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 000000000..0dd640c4e --- /dev/null +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageFileAccess.java @@ -0,0 +1,90 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.sdbcx.comp.hsqldb; + +import org.hsqldb.lib.FileAccess; +import org.hsqldb.lib.FileSystemRuntimeException; + +@SuppressWarnings("ucd") +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(String filename) { + } + + public boolean isStreamElement(String elementName) { + return isStreamElement(key,elementName); + } + + public java.io.InputStream openInputStreamElement(String streamName) throws java.io.IOException { + return new NativeInputStreamHelper(key,streamName); + } + + public java.io.OutputStream openOutputStreamElement(String streamName) throws java.io.IOException { + return new NativeOutputStreamHelper(key,streamName); + } + + public void removeElement(String filename) throws java.util.NoSuchElementException { + try { + if ( isStreamElement(key,filename) ) + removeElement(key,filename); + } catch (java.io.IOException e) { + throw new FileSystemRuntimeException( e ); + } + } + + public void renameElement(String oldName, 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 ); + } + } + + private static class FileSync implements FileAccess.FileSync + { + private final NativeOutputStreamHelper os; + private FileSync(NativeOutputStreamHelper _os) + { + 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(String key,String elementName); + static native void removeElement(String key,String filename) throws java.util.NoSuchElementException, java.io.IOException; + static native void renameElement(String key,String oldName, 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 000000000..cf147c9b5 --- /dev/null +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java @@ -0,0 +1,34 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.sdbcx.comp.hsqldb; + +public class StorageNativeInputStream { + static { NativeLibraries.load(); } + + /** Creates a new instance of StorageNativeInputStream */ + public StorageNativeInputStream(String key,String _file) { + openStream(key,_file, NativeStorageAccess.READ); + } + private 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 000000000..8cc6cb07d --- /dev/null +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeOutputStream.java @@ -0,0 +1,145 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.sdbcx.comp.hsqldb; + +public class StorageNativeOutputStream { + static { NativeLibraries.load(); } + + /** Creates a new instance of StorageNativeOutputStream */ + public StorageNativeOutputStream(String _name, Object key) { + openStream(_name, (String)key, NativeStorageAccess.WRITE | NativeStorageAccess.TRUNCATE); + } + + private native void openStream(String name,String key, int mode); + /** + * Writes len bytes from the specified byte array + * starting at offset off to this output stream. + * The general contract for write(b, off, len) is that + * some of the bytes in the array b are written to the + * output stream in order; element b[off] is the first + * byte written and b[off+len-1] is the last byte written + * by this operation. + *

+ * The write method of OutputStream 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. + *

+ * If b is null, a + * NullPointerException is thrown. + *

+ * If off is negative, or len is negative, or + * off+len is greater than the length of the array + * b, then an IndexOutOfBoundsException 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 java.io.IOException if an I/O error occurs. In particular, + * an IOException 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 b.length bytes from the specified byte array + * to this output stream. The general contract for write(b) + * is that it should have exactly the same effect as the call + * write(b, 0, b.length). + * + * @param b the data. + * @exception java.io.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 close + * is that it closes the output stream. A closed stream cannot perform + * output operations and cannot be reopened. + *

+ * The close method of OutputStream does nothing. + * @param key The name of the data source. + * @param _file The name of the file to write to. + * + * @exception java.io.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 write is that one byte is written + * to the output stream. The byte to be written is the eight + * low-order bits of the argument b. The 24 + * high-order bits of b are ignored. + *

+ * Subclasses of OutputStream 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 byte. + * @exception java.io.IOException if an I/O error occurs. In particular, + * an IOException 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 flush 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. + *

+ * The flush method of OutputStream does nothing. + * @param key The name of the data source. + * @param _file The name of the file to write to. + * + * @exception java.io.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 java.io.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/inc/ParameterCont.hxx b/connectivity/inc/ParameterCont.hxx new file mode 100644 index 000000000..848cec78e --- /dev/null +++ b/connectivity/inc/ParameterCont.hxx @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include +#include +#include + +namespace dbtools +{ + + //= OParameterContinuation + + class OParameterContinuation final : public comphelper::OInteraction< css::sdb::XInteractionSupplyParameters > + { + css::uno::Sequence< css::beans::PropertyValue > m_aValues; + + public: + OParameterContinuation() { } + + const css::uno::Sequence< css::beans::PropertyValue >& getValues() const { return m_aValues; } + + // XInteractionSupplyParameters + virtual void SAL_CALL setParameters( const css::uno::Sequence< css::beans::PropertyValue >& _rValues ) override; + + private: + virtual ~OParameterContinuation() override { } + OParameterContinuation(const OParameterContinuation&) = delete; + void operator =(const OParameterContinuation&) = delete; + }; +} // dbtools + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/SQLStatementHelper.hxx b/connectivity/inc/SQLStatementHelper.hxx new file mode 100644 index 000000000..0b5ddecf0 --- /dev/null +++ b/connectivity/inc/SQLStatementHelper.hxx @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::uno { template class Reference; } + +namespace dbtools +{ + class OOO_DLLPUBLIC_DBTOOLS ISQLStatementHelper + { + public: + virtual void addComment(const css::uno::Reference< css::beans::XPropertySet >& descriptor,OUStringBuffer& _rOut) = 0; + + protected: + ~ISQLStatementHelper() {} + }; + + +} // namespace dbtools + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/TIndex.hxx b/connectivity/inc/TIndex.hxx new file mode 100644 index 000000000..1ac2f5c4f --- /dev/null +++ b/connectivity/inc/TIndex.hxx @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include "sdbcx/VIndex.hxx" + +namespace connectivity +{ + class OTableHelper; + class OIndexHelper final : public connectivity::sdbcx::OIndex + { + OTableHelper* m_pTable; + public: + virtual void refreshColumns() override; + public: + OIndexHelper( OTableHelper* _pTable); + OIndexHelper( OTableHelper* _pTable, + const OUString& Name, + const OUString& Catalog, + bool _isUnique, + bool _isPrimaryKeyIndex, + bool _isClustered + ); + OTableHelper* getTable() const { return m_pTable; } + }; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/TIndexColumns.hxx b/connectivity/inc/TIndexColumns.hxx new file mode 100644 index 000000000..aa5687afc --- /dev/null +++ b/connectivity/inc/TIndexColumns.hxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +namespace connectivity +{ + class OIndexHelper; + class OIndexColumns final : public sdbcx::OCollection + { + OIndexHelper* m_pIndex; + virtual sdbcx::ObjectType createObject(const OUString& _rName) override; + virtual css::uno::Reference< css::beans::XPropertySet > createDescriptor() override; + virtual void impl_refresh() override; + public: + OIndexColumns( OIndexHelper* _pIndex, + ::osl::Mutex& _rMutex, + const ::std::vector< OUString> &_rVector); + }; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/TKey.hxx b/connectivity/inc/TKey.hxx new file mode 100644 index 000000000..a4d1d92ff --- /dev/null +++ b/connectivity/inc/TKey.hxx @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include "sdbcx/VKey.hxx" + +namespace connectivity +{ + class OTableHelper; + class OTableKeyHelper final : public connectivity::sdbcx::OKey + { + OTableHelper* m_pTable; + public: + virtual void refreshColumns() override; + public: + OTableKeyHelper( OTableHelper* _pTable); + OTableKeyHelper( OTableHelper* _pTable + ,const OUString& Name + ,const std::shared_ptr& _rProps + ); + OTableHelper* getTable() const { return m_pTable; } + }; +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/TKeyColumns.hxx b/connectivity/inc/TKeyColumns.hxx new file mode 100644 index 000000000..c40cd1cd7 --- /dev/null +++ b/connectivity/inc/TKeyColumns.hxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +namespace connectivity +{ + class OTableKeyHelper; + class OKeyColumnsHelper final : public connectivity::sdbcx::OCollection + { + OTableKeyHelper* m_pKey; + virtual sdbcx::ObjectType createObject(const OUString& _rName) override; + virtual css::uno::Reference< css::beans::XPropertySet > createDescriptor() override; + virtual void impl_refresh() override; + public: + OKeyColumnsHelper( OTableKeyHelper* _pKey, + ::osl::Mutex& _rMutex, + const ::std::vector< OUString> &_rVector); + }; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/bitmaps.hlst b/connectivity/inc/bitmaps.hlst new file mode 100644 index 000000000..d51533745 --- /dev/null +++ b/connectivity/inc/bitmaps.hlst @@ -0,0 +1,17 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_CONNECTIVITY_INC_BITMAPS_HRC +#define INCLUDED_CONNECTIVITY_INC_BITMAPS_HRC + +#define LINKED_TEXT_TABLE_IMAGE_RESOURCE "dbaccess/res/linked_text_table.png" + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/connectivity/inc/pch/precompiled_ado.cxx b/connectivity/inc/pch/precompiled_ado.cxx new file mode 100644 index 000000000..6798d4b41 --- /dev/null +++ b/connectivity/inc/pch/precompiled_ado.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "precompiled_ado.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_ado.hxx b/connectivity/inc/pch/precompiled_ado.hxx new file mode 100644 index 000000000..b8d5da458 --- /dev/null +++ b/connectivity/inc/pch/precompiled_ado.hxx @@ -0,0 +1,116 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/* + This file has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2020-04-25 20:54:51 using: + ./bin/update_pch connectivity ado --cutoff=2 --exclude:system --exclude:module --exclude:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./connectivity/inc/pch/precompiled_ado.hxx "make connectivity.build" --find-conflicts +*/ + +#if PCH_LEVEL >= 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 4 + +// Cleanup windows header macro pollution. +#if defined(_WIN32) && defined(WINAPI) +#include +#undef RGB +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_calc.cxx b/connectivity/inc/pch/precompiled_calc.cxx new file mode 100644 index 000000000..425809155 --- /dev/null +++ b/connectivity/inc/pch/precompiled_calc.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "precompiled_calc.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_calc.hxx b/connectivity/inc/pch/precompiled_calc.hxx new file mode 100644 index 000000000..2c36c7a89 --- /dev/null +++ b/connectivity/inc/pch/precompiled_calc.hxx @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/* + This file has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2020-01-22 15:57:33 using: + ./bin/update_pch connectivity calc --cutoff=2 --exclude:system --exclude:module --exclude:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./connectivity/inc/pch/precompiled_calc.hxx "make connectivity.build" --find-conflicts +*/ + +#if PCH_LEVEL >= 1 +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include +#include +#include +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_dbase.cxx b/connectivity/inc/pch/precompiled_dbase.cxx new file mode 100644 index 000000000..244f98557 --- /dev/null +++ b/connectivity/inc/pch/precompiled_dbase.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "precompiled_dbase.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_dbase.hxx b/connectivity/inc/pch/precompiled_dbase.hxx new file mode 100644 index 000000000..e98e54cbd --- /dev/null +++ b/connectivity/inc/pch/precompiled_dbase.hxx @@ -0,0 +1,228 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/* + This file has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2020-04-25 20:54:52 using: + ./bin/update_pch connectivity dbase --cutoff=2 --exclude:system --include:module --include:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./connectivity/inc/pch/precompiled_dbase.hxx "make connectivity.build" --find-conflicts +*/ + +#if PCH_LEVEL >= 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_dbpool2.cxx b/connectivity/inc/pch/precompiled_dbpool2.cxx new file mode 100644 index 000000000..297c81f04 --- /dev/null +++ b/connectivity/inc/pch/precompiled_dbpool2.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "precompiled_dbpool2.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_dbpool2.hxx b/connectivity/inc/pch/precompiled_dbpool2.hxx new file mode 100644 index 000000000..b78f7d5a8 --- /dev/null +++ b/connectivity/inc/pch/precompiled_dbpool2.hxx @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/* + This file has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2020-01-22 15:57:34 using: + ./bin/update_pch connectivity dbpool2 --cutoff=5 --exclude:system --include:module --exclude:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./connectivity/inc/pch/precompiled_dbpool2.hxx "make connectivity.build" --find-conflicts +*/ + +#if PCH_LEVEL >= 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_dbtools.cxx b/connectivity/inc/pch/precompiled_dbtools.cxx new file mode 100644 index 000000000..a4d00e761 --- /dev/null +++ b/connectivity/inc/pch/precompiled_dbtools.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "precompiled_dbtools.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_dbtools.hxx b/connectivity/inc/pch/precompiled_dbtools.hxx new file mode 100644 index 000000000..d39d62a4e --- /dev/null +++ b/connectivity/inc/pch/precompiled_dbtools.hxx @@ -0,0 +1,212 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/* + This file has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2020-04-21 11:13:45 using: + ./bin/update_pch connectivity dbtools --cutoff=2 --exclude:system --exclude:module --include:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./connectivity/inc/pch/precompiled_dbtools.hxx "make connectivity.build" --find-conflicts +*/ + +#if PCH_LEVEL >= 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_file.cxx b/connectivity/inc/pch/precompiled_file.cxx new file mode 100644 index 000000000..4845c91c4 --- /dev/null +++ b/connectivity/inc/pch/precompiled_file.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "precompiled_file.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_file.hxx b/connectivity/inc/pch/precompiled_file.hxx new file mode 100644 index 000000000..656d36132 --- /dev/null +++ b/connectivity/inc/pch/precompiled_file.hxx @@ -0,0 +1,222 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/* + This file has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2020-04-21 11:13:48 using: + ./bin/update_pch connectivity file --cutoff=2 --exclude:system --include:module --exclude:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./connectivity/inc/pch/precompiled_file.hxx "make connectivity.build" --find-conflicts +*/ + +#if PCH_LEVEL >= 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_firebird_sdbc.cxx b/connectivity/inc/pch/precompiled_firebird_sdbc.cxx new file mode 100644 index 000000000..777da8c9c --- /dev/null +++ b/connectivity/inc/pch/precompiled_firebird_sdbc.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "precompiled_firebird_sdbc.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_firebird_sdbc.hxx b/connectivity/inc/pch/precompiled_firebird_sdbc.hxx new file mode 100644 index 000000000..deb68a2c2 --- /dev/null +++ b/connectivity/inc/pch/precompiled_firebird_sdbc.hxx @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/* + This file has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2020-01-22 15:57:35 using: + ./bin/update_pch connectivity firebird_sdbc --cutoff=2 --exclude:system --exclude:module --exclude:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./connectivity/inc/pch/precompiled_firebird_sdbc.hxx "make connectivity.build" --find-conflicts +*/ + +#if PCH_LEVEL >= 1 +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_flat.cxx b/connectivity/inc/pch/precompiled_flat.cxx new file mode 100644 index 000000000..474aa00da --- /dev/null +++ b/connectivity/inc/pch/precompiled_flat.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "precompiled_flat.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_flat.hxx b/connectivity/inc/pch/precompiled_flat.hxx new file mode 100644 index 000000000..d6aea9b6d --- /dev/null +++ b/connectivity/inc/pch/precompiled_flat.hxx @@ -0,0 +1,208 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/* + This file has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2020-04-21 11:13:54 using: + ./bin/update_pch connectivity flat --cutoff=2 --exclude:system --include:module --include:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./connectivity/inc/pch/precompiled_flat.hxx "make connectivity.build" --find-conflicts +*/ + +#if PCH_LEVEL >= 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_mysql_jdbc.cxx b/connectivity/inc/pch/precompiled_mysql_jdbc.cxx new file mode 100644 index 000000000..1f7782e67 --- /dev/null +++ b/connectivity/inc/pch/precompiled_mysql_jdbc.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "precompiled_mysql_jdbc.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_mysql_jdbc.hxx b/connectivity/inc/pch/precompiled_mysql_jdbc.hxx new file mode 100644 index 000000000..fed482c16 --- /dev/null +++ b/connectivity/inc/pch/precompiled_mysql_jdbc.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/* + This file has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2020-01-22 15:57:36 using: + ./bin/update_pch connectivity mysql_jdbc --cutoff=1 --exclude:system --include:module --include:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./connectivity/inc/pch/precompiled_mysql_jdbc.hxx "make connectivity.build" --find-conflicts +*/ + +#if PCH_LEVEL >= 1 +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_odbc.cxx b/connectivity/inc/pch/precompiled_odbc.cxx new file mode 100644 index 000000000..f55f2ec84 --- /dev/null +++ b/connectivity/inc/pch/precompiled_odbc.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "precompiled_odbc.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_odbc.hxx b/connectivity/inc/pch/precompiled_odbc.hxx new file mode 100644 index 000000000..668470fd3 --- /dev/null +++ b/connectivity/inc/pch/precompiled_odbc.hxx @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/* + This file has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2020-02-01 10:57:29 using: + ./bin/update_pch connectivity odbc --cutoff=2 --exclude:system --exclude:module --include:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./connectivity/inc/pch/precompiled_odbc.hxx "make connectivity.build" --find-conflicts +*/ + +#if PCH_LEVEL >= 1 +#include +#include +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_postgresql-sdbc-impl.cxx b/connectivity/inc/pch/precompiled_postgresql-sdbc-impl.cxx new file mode 100644 index 000000000..9dbbeaf36 --- /dev/null +++ b/connectivity/inc/pch/precompiled_postgresql-sdbc-impl.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "precompiled_postgresql-sdbc-impl.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/pch/precompiled_postgresql-sdbc-impl.hxx b/connectivity/inc/pch/precompiled_postgresql-sdbc-impl.hxx new file mode 100644 index 000000000..c8f2a2ac3 --- /dev/null +++ b/connectivity/inc/pch/precompiled_postgresql-sdbc-impl.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/* + This file has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2020-01-22 15:57:37 using: + ./bin/update_pch connectivity postgresql-sdbc-impl --cutoff=3 --exclude:system --exclude:module --exclude:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./connectivity/inc/pch/precompiled_postgresql-sdbc-impl.hxx "make connectivity.build" --find-conflicts +*/ + +#if PCH_LEVEL >= 1 +#include +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/sdbcx/VCatalog.hxx b/connectivity/inc/sdbcx/VCatalog.hxx new file mode 100644 index 000000000..a9b1d18bb --- /dev/null +++ b/connectivity/inc/sdbcx/VCatalog.hxx @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace com::sun::star::sdbc { class XConnection; } +namespace com::sun::star::sdbc { class XDatabaseMetaData; } +namespace com::sun::star::sdbc { class XResultSet; } +namespace com::sun::star::sdbc { class XRow; } + +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::WeakComponentImplHelper< css::sdbcx::XTablesSupplier, + css::sdbcx::XViewsSupplier, + css::sdbcx::XUsersSupplier, + css::sdbcx::XGroupsSupplier, + css::lang::XServiceInfo> OCatalog_BASE; + + + class OOO_DLLPUBLIC_DBTOOLS SAL_NO_VTABLE OCatalog : + public OCatalog_BASE, + public IRefreshableGroups, + public IRefreshableUsers + { + protected: + + ::osl::Mutex m_aMutex; + + // this members are deleted when the dtor is called + // they are hold weak + std::unique_ptr m_pTables; + std::unique_ptr m_pViews; + std::unique_ptr m_pGroups; + std::unique_ptr m_pUsers; + + css::uno::Reference< css::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 OUString buildName( const css::uno::Reference< css::sdbc::XRow >& _xRow); + + /** fills a vector with the necessary 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(css::uno::Reference< css::sdbc::XResultSet >& _xResult,::std::vector< OUString>& _rNames); + + public: + OCatalog(const css::uno::Reference< css::sdbc::XConnection> &_xConnection); + virtual ~OCatalog() override; + + 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() override; + // XTablesSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTables( ) override; + // XViewsSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getViews( ) override; + // XUsersSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getUsers( ) override; + // XGroupsSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getGroups( ) override; + + }; + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/sdbcx/VGroup.hxx b/connectivity/inc/sdbcx/VGroup.hxx new file mode 100644 index 000000000..dcf50d1a9 --- /dev/null +++ b/connectivity/inc/sdbcx/VGroup.hxx @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace connectivity +{ + namespace sdbcx + { + typedef OCollection OUsers; + + typedef ::cppu::WeakComponentImplHelper< css::sdbcx::XUsersSupplier, + css::sdbcx::XAuthorizable, + css::container::XNamed, + css::lang::XServiceInfo> OGroup_BASE; + + class OOO_DLLPUBLIC_DBTOOLS OGroup : + public cppu::BaseMutex, + public OGroup_BASE, + public IRefreshableUsers, + public ::comphelper::OPropertyArrayUsageHelper, + public ODescriptor + { + protected: + // no Reference! see OCollection::acquire + std::unique_ptr m_pUsers; + + using OGroup_BASE::rBHelper; + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + public: + OGroup(bool _bCase); + OGroup( const OUString& Name, bool _bCase); + virtual ~OGroup() override; + DECLARE_SERVICE_INFO(); + + // XInterface + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + + //XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + //XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing() override; + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + // XUsersSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getUsers( ) override; + // XAuthorizable + virtual sal_Int32 SAL_CALL getPrivileges( const OUString& objName, sal_Int32 objType ) override; + virtual sal_Int32 SAL_CALL getGrantablePrivileges( const OUString& objName, sal_Int32 objType ) override; + virtual void SAL_CALL grantPrivileges( const OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) override; + virtual void SAL_CALL revokePrivileges( const OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) override; + + // XNamed + virtual OUString SAL_CALL getName( ) override; + virtual void SAL_CALL setName( const OUString& aName ) override; + }; + } +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/sdbcx/VIndex.hxx b/connectivity/inc/sdbcx/VIndex.hxx new file mode 100644 index 000000000..8bf0a4db2 --- /dev/null +++ b/connectivity/inc/sdbcx/VIndex.hxx @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace connectivity +{ + namespace sdbcx + { + class OCollection; + class OIndex; + typedef ::cppu::ImplHelper1< css::sdbcx::XDataDescriptorFactory > OIndex_BASE; + typedef ::comphelper::OIdPropertyArrayUsageHelper OIndex_PROP; + + class OOO_DLLPUBLIC_DBTOOLS OIndex : + public cppu::BaseMutex, + public ODescriptor_BASE, + public IRefreshableColumns, + public OIndex_PROP, + public ODescriptor, + public OIndex_BASE + { + protected: + OUString m_Catalog; + bool m_IsUnique; + bool m_IsPrimaryKeyIndex; + bool m_IsClustered; + + // no Reference! see OCollection::acquire + std::unique_ptr m_pColumns; + + using ODescriptor_BASE::rBHelper; + virtual void refreshColumns() override; + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + public: + OIndex(bool _bCase); + OIndex( const OUString& Name, + const OUString& Catalog, + bool _isUnique, + bool _isPrimaryKeyIndex, + bool _isClustered, + bool _bCase); + + virtual ~OIndex( ) override; + + DECLARE_SERVICE_INFO(); + + //XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + //XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + // ODescriptor + virtual void construct() override; + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing() override; + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + // XColumnsSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getColumns( ) override; + + // XNamed + virtual OUString SAL_CALL getName( ) override; + virtual void SAL_CALL setName( const OUString& aName ) override; + // XDataDescriptorFactory + virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL createDataDescriptor( ) override; + }; + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/sdbcx/VIndexColumn.hxx b/connectivity/inc/sdbcx/VIndexColumn.hxx new file mode 100644 index 000000000..6677b291e --- /dev/null +++ b/connectivity/inc/sdbcx/VIndexColumn.hxx @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +namespace connectivity +{ + namespace sdbcx + { + class OIndexColumn; + typedef ::comphelper::OIdPropertyArrayUsageHelper OIndexColumn_PROP; + + class OOO_DLLPUBLIC_DBTOOLS OIndexColumn : + public OColumn, public OIndexColumn_PROP + { + bool m_IsAscending; + protected: + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + public: + OIndexColumn( bool _bCase); + OIndexColumn( bool IsAscending, + const OUString& Name, + const OUString& TypeName, + const OUString& DefaultValue, + sal_Int32 IsNullable, + sal_Int32 Precision, + sal_Int32 Scale, + sal_Int32 Type, + bool _bCase, + const OUString& CatalogName, + const OUString& SchemaName, + const OUString& TableName); + + virtual void construct() override; + DECLARE_SERVICE_INFO(); + }; + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/sdbcx/VKey.hxx b/connectivity/inc/sdbcx/VKey.hxx new file mode 100644 index 000000000..01e1d839f --- /dev/null +++ b/connectivity/inc/sdbcx/VKey.hxx @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace connectivity +{ + namespace sdbcx + { + + struct OOO_DLLPUBLIC_DBTOOLS KeyProperties + { + ::std::vector< OUString> m_aKeyColumnNames; + OUString m_ReferencedTable; + sal_Int32 m_Type; + sal_Int32 m_UpdateRule; + sal_Int32 m_DeleteRule; + KeyProperties(const 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 ::cppu::ImplHelper1< css::sdbcx::XDataDescriptorFactory > OKey_BASE; + class OCollection; + + class OOO_DLLPUBLIC_DBTOOLS OKey : + public cppu::BaseMutex, + public ODescriptor_BASE, + public IRefreshableColumns, + public ::comphelper::OIdPropertyArrayUsageHelper, + public ODescriptor, + public OKey_BASE + { + protected: + std::shared_ptr m_aProps; + // no Reference! see OCollection::acquire + std::unique_ptr m_pColumns; + + using ODescriptor_BASE::rBHelper; + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const override; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + public: + OKey(bool _bCase); + OKey(const OUString& Name,const std::shared_ptr& _rProps,bool _bCase); + + virtual ~OKey( ) override; + + DECLARE_SERVICE_INFO(); + //XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + //XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + // ODescriptor + virtual void construct() override; + + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing() override; + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + // XColumnsSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getColumns( ) override; + + // XNamed + virtual OUString SAL_CALL getName( ) override; + virtual void SAL_CALL setName( const OUString& aName ) override; + // XDataDescriptorFactory + virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL createDataDescriptor( ) override; + }; + } +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/sdbcx/VKeyColumn.hxx b/connectivity/inc/sdbcx/VKeyColumn.hxx new file mode 100644 index 000000000..cb6548f31 --- /dev/null +++ b/connectivity/inc/sdbcx/VKeyColumn.hxx @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +namespace connectivity +{ + namespace sdbcx + { + class OKeyColumn; + typedef ::comphelper::OIdPropertyArrayUsageHelper OKeyColumn_PROP; + + class OKeyColumn : + public OColumn, public OKeyColumn_PROP + { + OUString m_ReferencedColumn; + protected: + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + public: + OKeyColumn(bool _bCase); + OKeyColumn( const OUString& ReferencedColumn, + const OUString& Name, + const OUString& TypeName, + const OUString& DefaultValue, + sal_Int32 IsNullable, + sal_Int32 Precision, + sal_Int32 Scale, + sal_Int32 Type, + bool _bCase, + const OUString& CatalogName, + const OUString& SchemaName, + const OUString& TableName); + // just to make it not inline + virtual ~OKeyColumn() override; + + virtual void construct() override; + DECLARE_SERVICE_INFO(); + }; + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/sdbcx/VTypeDef.hxx b/connectivity/inc/sdbcx/VTypeDef.hxx new file mode 100644 index 000000000..205400393 --- /dev/null +++ b/connectivity/inc/sdbcx/VTypeDef.hxx @@ -0,0 +1,37 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include + +namespace connectivity +{ + namespace sdbcx + { + typedef cppu::WeakComponentImplHelper< css::sdbcx::XColumnsSupplier, + css::container::XNamed, + css::lang::XServiceInfo> ODescriptor_BASE; + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/sdbcx/VUser.hxx b/connectivity/inc/sdbcx/VUser.hxx new file mode 100644 index 000000000..c16679466 --- /dev/null +++ b/connectivity/inc/sdbcx/VUser.hxx @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace connectivity +{ + namespace sdbcx + { + typedef OCollection OGroups; + + typedef ::cppu::WeakComponentImplHelper< css::sdbcx::XUser, + css::sdbcx::XGroupsSupplier, + css::container::XNamed, + css::lang::XServiceInfo> OUser_BASE; + + class OOO_DLLPUBLIC_DBTOOLS OUser : + public cppu::BaseMutex, + public OUser_BASE, + public IRefreshableGroups, + public ::comphelper::OPropertyArrayUsageHelper, + public ODescriptor + { + protected: + // no Reference! see OCollection::acquire + std::unique_ptr m_pGroups; + + using OUser_BASE::rBHelper; + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + public: + OUser(bool _bCase); + OUser(const OUString& Name,bool _bCase); + + virtual ~OUser( ) override; + + DECLARE_SERVICE_INFO(); + + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing() override; + //XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + //XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + // XUser + virtual void SAL_CALL changePassword( const OUString& objPassword, const OUString& newPassword ) override; + // XAuthorizable + virtual sal_Int32 SAL_CALL getPrivileges( const OUString& objName, sal_Int32 objType ) override; + virtual sal_Int32 SAL_CALL getGrantablePrivileges( const OUString& objName, sal_Int32 objType ) override; + virtual void SAL_CALL grantPrivileges( const OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) override; + virtual void SAL_CALL revokePrivileges( const OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) override; + // XGroupsSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getGroups( ) override; + + // XNamed + virtual OUString SAL_CALL getName( ) override; + virtual void SAL_CALL setName( const OUString& aName ) override; + }; + } +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/strings.hrc b/connectivity/inc/strings.hrc new file mode 100644 index 000000000..c1b4fa30b --- /dev/null +++ b/connectivity/inc/strings.hrc @@ -0,0 +1,144 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef CONNECTIVITY_STRINGS_HRC +#define CONNECTIVITY_STRINGS_HRC + +#define NC_(Context, String) reinterpret_cast(Context "\004" u8##String) + +// = the mozab driver's resource strings +#define STR_ERR_EXECUTING_QUERY NC_("STR_ERR_EXECUTING_QUERY", "An error occurred while executing the query.") +#define STR_QUERY_AT_LEAST_ONE_TABLES NC_("STR_QUERY_AT_LEAST_ONE_TABLES", "The query can not be executed. It needs at least one table.") +#define STR_NO_COUNT_SUPPORT NC_("STR_NO_COUNT_SUPPORT", "The driver does not support the 'COUNT' function.") +#define STR_STMT_TYPE_NOT_SUPPORTED NC_("STR_STMT_TYPE_NOT_SUPPORTED", "This statement type not supported by this database driver.") +#define STR_UNSPECIFIED_ERROR NC_("STR_UNSPECIFIED_ERROR", "An unknown error occurred.") +#define STR_ERROR_REFRESH_ROW NC_("STR_ERROR_REFRESH_ROW", "An error occurred while refreshing the current row.") +#define STR_ERROR_GET_ROW NC_("STR_ERROR_GET_ROW", "An error occurred while getting the current row.") +#define STR_QUERY_INVALID_IS_NULL_COLUMN NC_("STR_QUERY_INVALID_IS_NULL_COLUMN", "The query can not be executed. The 'IS NULL' can only be used with a column name.") +#define STR_ILLEGAL_MOVEMENT NC_("STR_ILLEGAL_MOVEMENT", "Illegal cursor movement occurred.") +#define STR_COMMIT_ROW NC_("STR_COMMIT_ROW", "Please commit row '$position$' before update rows or insert new rows.") +// = common strings +#define STR_NO_CONNECTION_GIVEN NC_("STR_NO_CONNECTION_GIVEN", "No connection to the database exists.") +#define STR_WRONG_PARAM_INDEX NC_("STR_WRONG_PARAM_INDEX", "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.") +#define STR_NO_INPUTSTREAM NC_("STR_NO_INPUTSTREAM", "The input stream was not set.") +#define STR_NO_ELEMENT_NAME NC_("STR_NO_ELEMENT_NAME", "There is no element named '$name$'.") +#define STR_INVALID_BOOKMARK NC_("STR_INVALID_BOOKMARK", "Invalid bookmark value") +#define STR_PRIVILEGE_NOT_GRANTED NC_("STR_PRIVILEGE_NOT_GRANTED", "Privilege not granted: Only table privileges can be granted.") +#define STR_PRIVILEGE_NOT_REVOKED NC_("STR_PRIVILEGE_NOT_REVOKED", "Privilege not revoked: Only table privileges can be revoked.") +#define STR_ERRORMSG_SEQUENCE NC_("STR_ERRORMSG_SEQUENCE", "Function sequence error.") +#define STR_INVALID_INDEX NC_("STR_INVALID_INDEX", "Invalid descriptor index.") +#define STR_UNSUPPORTED_FUNCTION NC_("STR_UNSUPPORTED_FUNCTION", "The driver does not support the function '$functionname$'.") +#define STR_UNSUPPORTED_FEATURE NC_("STR_UNSUPPORTED_FEATURE", "The driver does not support the functionality for '$featurename$'. It is not implemented.") +#define STR_FORMULA_WRONG NC_("STR_FORMULA_WRONG", "The formula for TypeInfoSettings is wrong!") +#define STR_STRING_LENGTH_EXCEEDED NC_("STR_STRING_LENGTH_EXCEEDED", "The string '$string$' exceeds the maximum length of $maxlen$ characters when converted to the target character set '$charset$'.") +#define STR_CANNOT_CONVERT_STRING NC_("STR_CANNOT_CONVERT_STRING", "The string '$string$' cannot be converted using the encoding '$charset$'.") +#define STR_URI_SYNTAX_ERROR NC_("STR_URI_SYNTAX_ERROR", "The connection URL is invalid.") +#define STR_QUERY_TOO_COMPLEX NC_("STR_QUERY_TOO_COMPLEX", "The query can not be executed. It is too complex.") +#define STR_OPERATOR_TOO_COMPLEX NC_("STR_OPERATOR_TOO_COMPLEX", "The query can not be executed. The operator is too complex.") +#define STR_QUERY_INVALID_LIKE_COLUMN NC_("STR_QUERY_INVALID_LIKE_COLUMN", "The query can not be executed. You cannot use 'LIKE' with columns of this type.") +#define STR_QUERY_INVALID_LIKE_STRING NC_("STR_QUERY_INVALID_LIKE_STRING", "The query can not be executed. 'LIKE' can be used with a string argument only.") +#define STR_QUERY_NOT_LIKE_TOO_COMPLEX NC_("STR_QUERY_NOT_LIKE_TOO_COMPLEX", "The query can not be executed. The 'NOT LIKE' condition is too complex.") +#define STR_QUERY_LIKE_WILDCARD NC_("STR_QUERY_LIKE_WILDCARD", "The query can not be executed. The 'LIKE' condition contains wildcard in the middle.") +#define STR_QUERY_LIKE_WILDCARD_MANY NC_("STR_QUERY_LIKE_WILDCARD_MANY", "The query can not be executed. The 'LIKE' condition contains too many wildcards.") +#define STR_INVALID_COLUMNNAME NC_("STR_INVALID_COLUMNNAME", "The column name '$columnname$' is not valid.") +#define STR_INVALID_COLUMN_SELECTION NC_("STR_INVALID_COLUMN_SELECTION", "The statement contains an invalid selection of columns.") +#define STR_COLUMN_NOT_UPDATEABLE NC_("STR_COLUMN_NOT_UPDATEABLE", "The column at position '$position$' could not be updated.") +#define STR_COULD_NOT_LOAD_FILE NC_("STR_COULD_NOT_LOAD_FILE", "The file $filename$ could not be loaded.") +#define STR_LOAD_FILE_ERROR_MESSAGE NC_("STR_LOAD_FILE_ERROR_MESSAGE", "The attempt to load the file resulted in the following error message ($exception_type$):\n\n$error_message$") +// = the ado driver's resource strings +#define STR_TYPE_NOT_CONVERT NC_("STR_TYPE_NOT_CONVERT", "The type could not be converted.") +#define STR_INVALID_COLUMN_DESCRIPTOR_ERROR NC_("STR_INVALID_COLUMN_DESCRIPTOR_ERROR", "Could not append column: invalid column descriptor.") +#define STR_INVALID_GROUP_DESCRIPTOR_ERROR NC_("STR_INVALID_GROUP_DESCRIPTOR_ERROR", "Could not create group: invalid object descriptor.") +#define STR_INVALID_INDEX_DESCRIPTOR_ERROR NC_("STR_INVALID_INDEX_DESCRIPTOR_ERROR", "Could not create index: invalid object descriptor.") +#define STR_INVALID_KEY_DESCRIPTOR_ERROR NC_("STR_INVALID_KEY_DESCRIPTOR_ERROR", "Could not create key: invalid object descriptor.") +#define STR_INVALID_TABLE_DESCRIPTOR_ERROR NC_("STR_INVALID_TABLE_DESCRIPTOR_ERROR", "Could not create table: invalid object descriptor.") +#define STR_INVALID_USER_DESCRIPTOR_ERROR NC_("STR_INVALID_USER_DESCRIPTOR_ERROR", "Could not create user: invalid object descriptor.") +#define STR_INVALID_VIEW_DESCRIPTOR_ERROR NC_("STR_INVALID_VIEW_DESCRIPTOR_ERROR", "Could not create view: invalid object descriptor.") +#define STR_VIEW_NO_COMMAND_ERROR NC_("STR_VIEW_NO_COMMAND_ERROR", "Could not create view: no command object.") +#define STR_NO_CONNECTION NC_("STR_NO_CONNECTION", "The connection could not be created. May be the necessary data provider is not installed.") +// dbase +#define STR_COULD_NOT_DELETE_INDEX NC_("STR_COULD_NOT_DELETE_INDEX", "The index could not be deleted. An unknown error while accessing the file system occurred.") +#define STR_ONL_ONE_COLUMN_PER_INDEX NC_("STR_ONL_ONE_COLUMN_PER_INDEX", "The index could not be created. Only one column per index is allowed.") +#define STR_COULD_NOT_CREATE_INDEX_NOT_UNIQUE NC_("STR_COULD_NOT_CREATE_INDEX_NOT_UNIQUE", "The index could not be created. The values are not unique.") +#define STR_COULD_NOT_CREATE_INDEX NC_("STR_COULD_NOT_CREATE_INDEX", "The index could not be created. An unknown error appeared.") +#define STR_COULD_NOT_CREATE_INDEX_NAME NC_("STR_COULD_NOT_CREATE_INDEX_NAME", "The index could not be created. The file '$filename$' is used by another index.") +#define STR_COULD_NOT_CREATE_INDEX_KEYSIZE NC_("STR_COULD_NOT_CREATE_INDEX_KEYSIZE", "The index could not be created. The size of the chosen column is too big.") +#define STR_SQL_NAME_ERROR NC_("STR_SQL_NAME_ERROR", "The name '$name$' doesn't match SQL naming constraints.") +#define STR_COULD_NOT_DELETE_FILE NC_("STR_COULD_NOT_DELETE_FILE", "The file $filename$ could not be deleted.") +#define STR_INVALID_COLUMN_TYPE NC_("STR_INVALID_COLUMN_TYPE", "Invalid column type for column '$columnname$'.") +#define STR_INVALID_COLUMN_PRECISION NC_("STR_INVALID_COLUMN_PRECISION", "Invalid precision for column '$columnname$'.") +#define STR_INVALID_PRECISION_SCALE NC_("STR_INVALID_PRECISION_SCALE", "Precision is less than scale for column '$columnname$'.") +#define STR_INVALID_COLUMN_NAME_LENGTH NC_("STR_INVALID_COLUMN_NAME_LENGTH", "Invalid column name length for column '$columnname$'.") +#define STR_DUPLICATE_VALUE_IN_COLUMN NC_("STR_DUPLICATE_VALUE_IN_COLUMN", "Duplicate value found in column '$columnname$'.") +#define STR_INVALID_COLUMN_DECIMAL_VALUE NC_("STR_INVALID_COLUMN_DECIMAL_VALUE", "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.") +#define STR_COLUMN_NOT_ALTERABLE NC_("STR_COLUMN_NOT_ALTERABLE", "The column '$columnname$' could not be altered. May be the file system is write protected.") +#define STR_INVALID_COLUMN_VALUE NC_("STR_INVALID_COLUMN_VALUE", "The column '$columnname$' could not be updated. The value is invalid for that column.") +#define STR_COLUMN_NOT_ADDABLE NC_("STR_COLUMN_NOT_ADDABLE", "The column '$columnname$' could not be added. May be the file system is write protected.") +#define STR_COLUMN_NOT_DROP NC_("STR_COLUMN_NOT_DROP", "The column at position '$position$' could not be dropped. May be the file system is write protected.") +#define STR_TABLE_NOT_DROP NC_("STR_TABLE_NOT_DROP", "The table '$tablename$' could not be dropped. May be the file system is write protected.") +#define STR_COULD_NOT_ALTER_TABLE NC_("STR_COULD_NOT_ALTER_TABLE", "The table could not be altered.") +#define STR_INVALID_DBASE_FILE NC_("STR_INVALID_DBASE_FILE", "The file '$filename$' is an invalid (or unrecognized) dBase file.") +// Evoab2 +#define STR_CANNOT_OPEN_BOOK NC_("STR_CANNOT_OPEN_BOOK", "Cannot open Evolution address book.") +#define STR_SORT_BY_COL_ONLY NC_("STR_SORT_BY_COL_ONLY", "Can only sort by table columns.") +// File +#define STR_QUERY_COMPLEX_COUNT NC_("STR_QUERY_COMPLEX_COUNT", "The query can not be executed. It is too complex. Only \"COUNT(*)\" is supported.") +#define STR_QUERY_INVALID_BETWEEN NC_("STR_QUERY_INVALID_BETWEEN", "The query can not be executed. The 'BETWEEN' arguments are not correct.") +#define STR_QUERY_FUNCTION_NOT_SUPPORTED NC_("STR_QUERY_FUNCTION_NOT_SUPPORTED", "The query can not be executed. The function is not supported.") +#define STR_TABLE_READONLY NC_("STR_TABLE_READONLY", "The table can not be changed. It is read only.") +#define STR_DELETE_ROW NC_("STR_DELETE_ROW", "The row could not be deleted. The option \"Display inactive records\" is set.") +#define STR_ROW_ALREADY_DELETED NC_("STR_ROW_ALREADY_DELETED", "The row could not be deleted. It is already deleted.") +#define STR_QUERY_MORE_TABLES NC_("STR_QUERY_MORE_TABLES", "The query can not be executed. It contains more than one table.") +#define STR_QUERY_NO_TABLE NC_("STR_QUERY_NO_TABLE", "The query can not be executed. It contains no valid table.") +#define STR_QUERY_NO_COLUMN NC_("STR_QUERY_NO_COLUMN", "The query can not be executed. It contains no valid columns.") +#define STR_INVALID_PARA_COUNT NC_("STR_INVALID_PARA_COUNT", "The count of the given parameter values doesn't match the parameters.") +#define STR_NO_VALID_FILE_URL NC_("STR_NO_VALID_FILE_URL", "The URL '$URL$' is not valid. A connection can not be created.") +#define STR_NO_CLASSNAME NC_("STR_NO_CLASSNAME", "The driver class '$classname$' could not be loaded.") +#define STR_NO_JAVA NC_("STR_NO_JAVA", "No Java installation could be found. Please check your installation.") +#define STR_NO_RESULTSET NC_("STR_NO_RESULTSET", "The execution of the query doesn't return a valid result set.") +#define STR_NO_ROWCOUNT NC_("STR_NO_ROWCOUNT", "The execution of the update statement doesn't effect any rows.") +#define STR_NO_CLASSNAME_PATH NC_("STR_NO_CLASSNAME_PATH", "The additional driver class path is '$classpath$'.") +#define STR_UNKNOWN_PARA_TYPE NC_("STR_UNKNOWN_PARA_TYPE", "The type of parameter at position '$position$' is unknown.") +#define STR_UNKNOWN_COLUMN_TYPE NC_("STR_UNKNOWN_COLUMN_TYPE", "The type of column at position '$position$' is unknown.") +// KAB +#define STR_PARA_ONLY_PREPARED NC_("STR_PARA_ONLY_PREPARED", "Parameters can appear only in prepared statements.") +// MACAB +#define STR_NO_TABLE NC_("STR_NO_TABLE", "No such table!") +#define STR_NO_MAC_OS_FOUND NC_("STR_NO_MAC_OS_FOUND", "No suitable Mac OS installation was found.") +// hsqldb +#define STR_NO_STORAGE NC_("STR_NO_STORAGE", "The connection can not be established. No storage or URL was given.") +#define STR_INVALID_FILE_URL NC_("STR_INVALID_FILE_URL", "The given URL contains no valid local file system path. Please check the location of your database file.") +#define STR_NO_TABLE_CONTAINER NC_("STR_NO_TABLE_CONTAINER", "An error occurred while obtaining the connection's table container.") +#define STR_NO_TABLENAME NC_("STR_NO_TABLENAME", "There is no table named '$tablename$'.") +#define STR_NO_DOCUMENTUI NC_("STR_NO_DOCUMENTUI", "The provided DocumentUI is not allowed to be NULL.") +#define STR_ERROR_NEW_VERSION NC_("STR_ERROR_NEW_VERSION", "The connection could not be established. The database was created by a newer version of %PRODUCTNAME.") + +#define STR_ROW_SET_OPERATION_VETOED NC_("STR_ROW_SET_OPERATION_VETOED", "The record operation has been vetoed.") +#define STR_PARSER_CYCLIC_SUB_QUERIES NC_("STR_PARSER_CYCLIC_SUB_QUERIES", "The statement contains a cyclic reference to one or more sub queries.") +#define STR_DB_OBJECT_NAME_WITH_SLASHES NC_("STR_DB_OBJECT_NAME_WITH_SLASHES", "The name must not contain any slashes ('/').") +#define STR_DB_INVALID_SQL_NAME NC_("STR_DB_INVALID_SQL_NAME", "$1$ is no SQL conform identifier.") +#define STR_DB_QUERY_NAME_WITH_QUOTES NC_("STR_DB_QUERY_NAME_WITH_QUOTES", "Query names must not contain quote characters.") +#define STR_DB_OBJECT_NAME_IS_USED NC_("STR_DB_OBJECT_NAME_IS_USED", "The name '$1$' is already in use in the database.") +#define STR_DB_NOT_CONNECTED NC_("STR_DB_NOT_CONNECTED", "No connection to the database exists.") +#define STR_AB_ADDRESSBOOK_NOT_FOUND NC_("STR_AB_ADDRESSBOOK_NOT_FOUND", "No $1$ exists.") +#define STR_DATA_CANNOT_SELECT_UNFILTERED NC_("STR_DATA_CANNOT_SELECT_UNFILTERED", "Unable to display the complete table content. Please apply a filter.") + +#endif // CONNECTIVITY_RESOURCE_MOZAB_HRC + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/inc/strings.hxx b/connectivity/inc/strings.hxx new file mode 100644 index 000000000..c81b2a08b --- /dev/null +++ b/connectivity/inc/strings.hxx @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_CONNECTIVITY_INC_STRINGS_HXX +#define INCLUDED_CONNECTIVITY_INC_STRINGS_HXX + +// = log messages for the JDBC driver + +#define STR_LOG_DRIVER_CONNECTING_URL "jdbcBridge: connecting to URL '$1$'" +#define STR_LOG_DRIVER_SUCCESS "jdbcBridge: success" +#define STR_LOG_CREATE_STATEMENT "c$1$: creating statement" +#define STR_LOG_CREATED_STATEMENT_ID "c$1$: created statement, statement id: s$2$" +#define STR_LOG_PREPARE_STATEMENT "c$1$: preparing statement: $2$" +#define STR_LOG_PREPARED_STATEMENT_ID "c$1$: prepared statement, statement id: s$2$" +#define STR_LOG_PREPARE_CALL "c$1$: preparing call: $2$" +#define STR_LOG_PREPARED_CALL_ID "c$1$: prepared call, statement id: s$2$" +#define STR_LOG_NATIVE_SQL "c$1$: native SQL: $2$ -> $3$" +#define STR_LOG_LOADING_DRIVER "c$1$: attempting to load driver class $2$" +#define STR_LOG_NO_DRIVER_CLASS "c$1$: no Java Driver Class was provided" +#define STR_LOG_CONN_SUCCESS "c$1$: success" +#define STR_LOG_NO_SYSTEM_CONNECTION "c$1$: JDBC driver did not provide a JDBC connection" +#define STR_LOG_GOT_JDBC_CONNECTION "c$1$: obtained a JDBC connection for $2$" +#define STR_LOG_SHUTDOWN_CONNECTION "c$1$: shutting down connection" +#define STR_LOG_GENERATED_VALUES "s$1$: retrieving generated values" +#define STR_LOG_GENERATED_VALUES_FALLBACK "s$1$: getGeneratedValues: falling back to statement: $2$" +#define STR_LOG_EXECUTE_STATEMENT "s$1$: going to execute: $2$" +#define STR_LOG_EXECUTE_QUERY "s$1$: going to execute query: $2$" +#define STR_LOG_CLOSING_STATEMENT "s$1$: closing/disposing statement" +#define STR_LOG_EXECUTE_UPDATE "s$1$: going to execute update: $2$" +#define STR_LOG_UPDATE_COUNT "s$1$: update count: $2$" +#define STR_LOG_RESULT_SET_CONCURRENCY "s$1$: going to set result set concurrency: $2$" +#define STR_LOG_RESULT_SET_TYPE "s$1$: going to set result set type: $2$" +#define STR_LOG_FETCH_DIRECTION "s$1$: fetch direction: $2$" +#define STR_LOG_FETCH_SIZE "s$1$: fetch size: $2$" +#define STR_LOG_SET_ESCAPE_PROCESSING "s$1$: going to set escape processing: $2$" +#define STR_LOG_EXECUTING_PREPARED "s$1$: executing previously prepared statement" +#define STR_LOG_EXECUTING_PREPARED_UPDATE "s$1$: executing previously prepared update statement" +#define STR_LOG_EXECUTING_PREPARED_QUERY "s$1$: executing previously prepared query" +#define STR_LOG_STRING_PARAMETER "s$1$: parameter no. $2$: type: string; value: $3$" +#define STR_LOG_BOOLEAN_PARAMETER "s$1$: parameter no. $2$: type: boolean; value: $3$" +#define STR_LOG_BYTE_PARAMETER "s$1$: parameter no. $2$: type: byte; value: $3$" +#define STR_LOG_DATE_PARAMETER "s$1$: parameter no. $2$: type: date; value: $3$" +#define STR_LOG_TIME_PARAMETER "s$1$: parameter no. $2$: type: time; value: $3$" +#define STR_LOG_TIMESTAMP_PARAMETER "s$1$: parameter no. $2$: type: timestamp; value: $3$" +#define STR_LOG_DOUBLE_PARAMETER "s$1$: parameter no. $2$: type: double; value: $3$" +#define STR_LOG_FLOAT_PARAMETER "s$1$: parameter no. $2$: type: float; value: $3$" +#define STR_LOG_INT_PARAMETER "s$1$: parameter no. $2$: type: int; value: $3$" +#define STR_LOG_LONG_PARAMETER "s$1$: parameter no. $2$: type: long; value: $3$" +#define STR_LOG_NULL_PARAMETER "s$1$: parameter no. $2$: sql-type: $3$; value: null" +#define STR_LOG_OBJECT_NULL_PARAMETER "s$1$: parameter no. $2$: setting to null" +#define STR_LOG_SHORT_PARAMETER "s$1$: parameter no. $2$: type: short; value: $3$" +#define STR_LOG_BYTES_PARAMETER "s$1$: parameter no. $2$: type: byte[]" +#define STR_LOG_CHARSTREAM_PARAMETER "s$1$: parameter no. $2$: type: character stream" +#define STR_LOG_BINARYSTREAM_PARAMETER "s$1$: parameter no. $2$: type: binary stream" +#define STR_LOG_CLEAR_PARAMETERS "s$1$: clearing all parameters" +#define STR_LOG_META_DATA_METHOD "c$1$: entering XDatabaseMetaData::$2$" +#define STR_LOG_META_DATA_METHOD_ARG1 "c$1$: entering XDatabaseMetaData::$2$( '$3$' )" +#define STR_LOG_META_DATA_METHOD_ARG2 "c$1$: entering XDatabaseMetaData::$2$( '$3$', '$4$' )" +#define STR_LOG_META_DATA_METHOD_ARG3 "c$1$: entering XDatabaseMetaData::$2$( '$3$', '$4$', '$5$' )" +#define STR_LOG_META_DATA_METHOD_ARG4 "c$1$: entering XDatabaseMetaData::$2$( '$3$', '$4$', '$5$', '$6$' )" +#define STR_LOG_META_DATA_RESULT "c$1$: leaving XDatabaseMetaData::$2$: success-with-result: $3$" +#define STR_LOG_META_DATA_SUCCESS "c$1$: leaving XDatabaseMetaData::$2$: success" +#define STR_LOG_THROWING_EXCEPTION "SQLException to be thrown: message: '$1$', SQLState: $2$, ErrorCode: $3$" +#define STR_LOG_SETTING_SYSTEM_PROPERTY "setting system property \"$1$\" to value \"$2$\"" + +#define STR_DB_NOT_CONNECTED_STATE "08003" +#define STR_DATA_CANNOT_SELECT_UNFILTERED_STATE "IM001" + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/connectivity/org/hsqldb/lib/FileSystemRuntimeException.java b/connectivity/org/hsqldb/lib/FileSystemRuntimeException.java new file mode 100644 index 000000000..b3598ad30 --- /dev/null +++ b/connectivity/org/hsqldb/lib/FileSystemRuntimeException.java @@ -0,0 +1,38 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +// 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. + * + * @version 1.8.0.8 + * @since 1.8.0.8 + */ +public class FileSystemRuntimeException extends java.lang.RuntimeException { + + public FileSystemRuntimeException(java.lang.Throwable _cause) { + super(_cause); + } + +} diff --git a/connectivity/qa/complex/connectivity/DBaseDriverTest.java b/connectivity/qa/complex/connectivity/DBaseDriverTest.java new file mode 100644 index 000000000..f1c89dc70 --- /dev/null +++ b/connectivity/qa/complex/connectivity/DBaseDriverTest.java @@ -0,0 +1,70 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.connectivity; + +import complex.connectivity.dbase.DBaseDateFunctions; +import complex.connectivity.dbase.DBaseStringFunctions; +import complex.connectivity.dbase.DBaseSqlTests; +import complex.connectivity.dbase.DBaseNumericFunctions; +import complexlib.ComplexTestCase; +import share.LogWriter; + +public class DBaseDriverTest extends ComplexTestCase implements TestCase +{ + @Override + public String[] getTestMethodNames() + { + return new String[] + { + "Functions" + }; + } + + @Override + public String getTestObjectName() + { + return "DBaseDriverTest"; + } + + @Override + public void assure( final String i_message, final boolean i_condition ) + { + super.assure( i_message, i_condition ); + } + + public LogWriter getLog() + { + return log; + } + + public void Functions() throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException + { + DBaseStringFunctions aStringTest = new DBaseStringFunctions(param.getMSF(), this); + aStringTest.testFunctions(); + + DBaseNumericFunctions aNumericTest = new DBaseNumericFunctions(param.getMSF(), this); + aNumericTest.testFunctions(); + + DBaseDateFunctions aDateTest = new DBaseDateFunctions(param.getMSF(), this); + aDateTest.testFunctions(); + + DBaseSqlTests aSqlTest = new DBaseSqlTests(param.getMSF(), this); + aSqlTest.testFunctions(); + } +} diff --git a/connectivity/qa/complex/connectivity/FlatFileAccess.java b/connectivity/qa/complex/connectivity/FlatFileAccess.java new file mode 100644 index 000000000..43d0eabef --- /dev/null +++ b/connectivity/qa/complex/connectivity/FlatFileAccess.java @@ -0,0 +1,245 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.connectivity; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.sdb.CommandType; +import com.sun.star.sdbc.SQLException; +import com.sun.star.util.Date; +import complexlib.ComplexTestCase; +import connectivity.tools.CsvDatabase; +import connectivity.tools.RowSet; +import java.io.File; +import java.io.FileOutputStream; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.List; + +public class FlatFileAccess extends ComplexTestCase +{ + @Override + public String[] getTestMethodNames() + { + return new String[] { + "testBasicAccess", + "testCalendarFunctions", + "testSortingByFunction" + }; + } + + @Override + public String getTestObjectName() + { + return "FlatFileAccess"; + } + + public void before() throws Exception + { + m_database = new CsvDatabase( param.getMSF() ); + + // proper settings + final XPropertySet dataSourceSettings = m_database.getDataSource().geSettings(); + dataSourceSettings.setPropertyValue( "Extension", "csv" ); + dataSourceSettings.setPropertyValue( "HeaderLine", Boolean.TRUE ); + dataSourceSettings.setPropertyValue( "FieldDelimiter", " " ); + m_database.store(); + + // write the table(s) for our test + final String tableLocation = m_database.getTableFileLocation().getAbsolutePath(); + final PrintWriter tableWriter = new PrintWriter( new FileOutputStream( tableLocation + File.separatorChar + "dates.csv", false ) ); + tableWriter.println( "ID date" ); + tableWriter.println( "1 2013-01-01" ); + tableWriter.println( "2 2012-02-02" ); + tableWriter.println( "3 2011-03-03" ); + tableWriter.close(); + } + + public void after() + { + } + + private static class EqualityDate extends Date + { + EqualityDate( short i_day, short i_month, short i_year ) + { + super( i_day, i_month, i_year ); + } + + @Override + public boolean equals( Object i_compare ) + { + if ( !( i_compare instanceof Date ) ) + return false; + return Day == ((Date)i_compare).Day + && Month == ((Date)i_compare).Month + && Year == ((Date)i_compare).Year; + } + } + + /** + * ensures simple SELECTs from our table(s) work, and deliver the expected results + */ + public void testBasicAccess() + { + testRowSetResults( + "SELECT * FROM \"dates\"", + new RowSetIntGetter(1), + new Integer[] { 1, 2, 3 }, + "simple select", "wrong IDs" + ); + + testRowSetResults( + "SELECT * FROM \"dates\"", + new RowSetDateGetter( 2 ), + new EqualityDate[] { new EqualityDate( (short)1, (short)1, (short)2013 ), + new EqualityDate( (short)2, (short)2, (short)2012 ), + new EqualityDate( (short)3, (short)3, (short)2011 ) + }, + "simple select", "wrong dates" + ); + testRowSetResults( + "SELECT \"date\", \"ID\" FROM \"dates\" ORDER BY \"ID\" DESC", + new RowSetIntGetter( 2 ), + new Integer[] { 3, 2, 1 }, + "explicit column selection, sorted by IDs", "wrong IDs" + ); + testRowSetResults( + "SELECT * FROM \"dates\" ORDER BY \"date\"", + new RowSetIntGetter( 1 ), + new Integer[] { 3, 2, 1 }, + "sorted by date", "wrong IDs" + ); + } + + /** + * ensures the basic functionality for selecting calendar functions from a CSV table - this is a prerequisite for + * later tests. + */ + public void testCalendarFunctions() + { + // simple check for proper results of the calendar functions (DATE/MONTH) + // The * at the first position is crucial here - there was code which wrongly calculated + // column positions of function columns when * was present in the statement + testRowSetResults( + "SELECT \"dates\".*, YEAR( \"date\" ) FROM \"dates\"", + new RowSetIntGetter( 3 ), + new Integer[] { 2013, 2012, 2011 }, + "YEAR function", "wrong calculated years" + ); + testRowSetResults( + "SELECT \"dates\".*, MONTH( \"date\" ) FROM \"dates\"", + new RowSetIntGetter( 3 ), + new Integer[] { 1, 2, 3 }, + "MONTH function", "wrong calculated months" + ); + } + + /** + * ensures that sorting by a function column works + */ + public void testSortingByFunction() + { + // most simple case: select a function, and sort by it + testRowSetResults( + "SELECT YEAR( \"date\" ) AS \"year\" FROM \"dates\" ORDER BY \"year\"", + new RowSetIntGetter(1), + new Integer[] { 2011, 2012, 2013 }, + "single YEAR selection, sorted by years", "wrong calculated years" + ); + // somewhat more "difficult" (this used to crash): Select all columns, plus a function, so the calculated + // column has a position greater than column count + testRowSetResults( + "SELECT \"dates\".*, YEAR( \"date\" ) AS \"year\" FROM \"dates\" ORDER BY \"year\" DESC", + new RowSetIntGetter(3), + new Integer[] { 2013, 2012, 2011 }, + "extended YEAR selection, sorted by years", "wrong calculated years" + ); + } + + private interface RowSetValueGetter + { + Object getValue( final RowSet i_rowSet ) throws SQLException; + } + + private static abstract class RowSetColumnValueGetter implements RowSetValueGetter + { + RowSetColumnValueGetter( final int i_columnIndex ) + { + m_columnIndex = i_columnIndex; + } + + protected final int m_columnIndex; + } + + private static class RowSetIntGetter extends RowSetColumnValueGetter + { + RowSetIntGetter( final int i_columnIndex ) + { + super( i_columnIndex ); + } + + public Object getValue( final RowSet i_rowSet ) throws SQLException + { + return i_rowSet.getInt( m_columnIndex ); + } + } + + private static class RowSetDateGetter extends RowSetColumnValueGetter + { + RowSetDateGetter( final int i_columnIndex ) + { + super( i_columnIndex ); + } + + public Object getValue( final RowSet i_rowSet ) throws SQLException + { + return i_rowSet.getDate( m_columnIndex ); + } + } + + @SuppressWarnings("unchecked") + private void testRowSetResults( String i_command, RowSetValueGetter i_getter, + T[] i_expectedValues, String i_context, String i_failureDesc ) + { + RowSet rowSet = null; + try + { + rowSet = m_database.createRowSet( CommandType.COMMAND, i_command ); + rowSet.execute(); + + List< T > values = new ArrayList< T >(); + while ( rowSet.next() ) + { + values.add( (T)i_getter.getValue( rowSet ) ); + } + assureEquals( i_context + ": " + i_failureDesc, i_expectedValues, values.toArray(), ContinueWithTest.YES ); + } + catch( final SQLException e ) + { + failed( i_context + ": caught an exception: " + e.toString(), ContinueWithTest.NO ); + } + finally + { + if ( rowSet != null ) + rowSet.dispose(); + } + } + + private CsvDatabase m_database = null; +} diff --git a/connectivity/qa/complex/connectivity/HsqlDriverTest.java b/connectivity/qa/complex/connectivity/HsqlDriverTest.java new file mode 100644 index 000000000..aba01fad9 --- /dev/null +++ b/connectivity/qa/complex/connectivity/HsqlDriverTest.java @@ -0,0 +1,145 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.connectivity; + +import complex.connectivity.hsqldb.TestCacheSize; +import com.sun.star.frame.XModel; +import com.sun.star.frame.XStorable; + +import com.sun.star.lang.*; +import com.sun.star.document.XDocumentSubStorageSupplier; +import complexlib.ComplexTestCase; + + +import org.hsqldb.lib.StopWatch; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.beans.PropertyState; +import com.sun.star.embed.XStorage; +import com.sun.star.sdbc.XDataSource; +import com.sun.star.sdbc.XDriver; +import connectivity.tools.HsqlDatabase; + +public class HsqlDriverTest extends ComplexTestCase { + + + @Override + public String[] getTestMethodNames() { + return new String[] { "test" }; + } + + @Override + public String getTestObjectName() { + return "DriverTest"; + } + + public void assurePublic(String sMessage,boolean check){ + super.assure(sMessage,check); + } + + public void test(){ + XDataSource ds = null; + System.gc(); + try { + HsqlDatabase database = new HsqlDatabase( param.getMSF() ); + ds = database.getDataSource().getXDataSource(); + } catch(Exception ex) { + throw new RuntimeException("factory: unable to construct data source", ex ); + } + + try{ + XDocumentSubStorageSupplier doc = 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 = UnoRuntime.queryInterface(XStorable.class,ds); + mod.store(); + XComponent xComp = UnoRuntime.queryInterface(XComponent.class,stor); + if ( xComp != null ) + xComp.dispose(); + } catch(Exception e){} + + try{ + XDocumentSubStorageSupplier doc = UnoRuntime.queryInterface(XDocumentSubStorageSupplier.class,ds); + XModel mod = UnoRuntime.queryInterface(XModel.class,ds); + XStorage stor = doc.getDocumentSubStorage("database",4); + com.sun.star.beans.PropertyValue[] 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) + }; + XDriver drv = UnoRuntime.queryInterface(XDriver.class,param.getMSF().createInstance("com.sun.star.sdbcx.comp.hsqldb.Driver")); + + + TestCacheSize test = new TestCacheSize(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 = UnoRuntime.queryInterface(XStorable.class,ds); + mod2.store(); + } catch(Exception e){} + }catch(Exception e){} + } + + public void test2(){ + System.gc(); + + try{ + com.sun.star.beans.PropertyValue[] 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, false,PropertyState.DIRECT_VALUE) + }; + XDriver drv = UnoRuntime.queryInterface(XDriver.class,param.getMSF().createInstance("com.sun.star.comp.sdbc.JDBCDriver")); + TestCacheSize test = new TestCacheSize(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/complex/connectivity/JdbcLongVarCharTest.java b/connectivity/qa/complex/connectivity/JdbcLongVarCharTest.java new file mode 100644 index 000000000..3817add48 --- /dev/null +++ b/connectivity/qa/complex/connectivity/JdbcLongVarCharTest.java @@ -0,0 +1,125 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +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 JdbcLongVarCharTest extends ComplexTestCase +{ + + @Override + public String[] getTestMethodNames() + { + return new String[] + { + "testLongVarChar" + }; + } + + @Override + public String getTestObjectName() + { + return "LongVarCharTest"; + } + + public void testLongVarChar() + { + + try + { + System.out.println("== Start testing =="); + + /* Get URL from environment variable. + * + * Example URL: + * jdbc:mysql://localhost:3306/mysql?user=username&password=password + */ + String url = System.getenv("CONNECTIVITY_TEST_MYSQL_DRIVER_JDBC"); + com.sun.star.beans.PropertyValue prop[] = new PropertyValue[1]; + prop[0] = new PropertyValue("JavaDriverClass", 0, "com.mysql.jdbc.Driver", PropertyState.DIRECT_VALUE); + + // get the remote office component context + XMultiServiceFactory xServiceManager = param.getMSF(); + Object x = xServiceManager.createInstance("com.sun.star.sdbc.DriverManager"); + com.sun.star.sdbc.XDriverAccess xDriverAccess = UnoRuntime.queryInterface(XDriverAccess.class, x); + com.sun.star.sdbc.XDriver xDriver = xDriverAccess.getDriverByURL(url); + com.sun.star.sdbc.XConnection xConnection = xDriver.connect(url, prop); + + Object prepStmnt = xConnection.prepareStatement("SELECT * FROM i90114 WHERE i90114.c1 = ?"); + UnoRuntime.queryInterface(XParameters.class, prepStmnt).clearParameters(); + UnoRuntime.queryInterface(XParameters.class, prepStmnt).setInt(1, 1); + XResultSet xResultSet = ((XPreparedStatement) prepStmnt).executeQuery(); + XRow xRow = UnoRuntime.queryInterface(XRow.class, xResultSet); + + XResultSetMetaDataSupplier xRsMetaSup = 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 = 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 occurred while testing =="); + e.printStackTrace(); + } finally + { + System.out.println("== End testing =="); + System.exit(0); + } + } +} diff --git a/connectivity/qa/complex/connectivity/SubTestCase.java b/connectivity/qa/complex/connectivity/SubTestCase.java new file mode 100644 index 000000000..7abffa844 --- /dev/null +++ b/connectivity/qa/complex/connectivity/SubTestCase.java @@ -0,0 +1,41 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.connectivity; + +import share.LogWriter; + +public class SubTestCase implements TestCase +{ + protected SubTestCase( final TestCase i_parentTestCase ) + { + m_parentTestCase = i_parentTestCase; + } + + public void assure( String i_message, boolean i_condition ) + { + m_parentTestCase.assure( i_message, i_condition ); + } + + public LogWriter getLog() + { + return m_parentTestCase.getLog(); + } + + private final TestCase m_parentTestCase; +} diff --git a/connectivity/qa/complex/connectivity/TestCase.java b/connectivity/qa/complex/connectivity/TestCase.java new file mode 100644 index 000000000..9261499af --- /dev/null +++ b/connectivity/qa/complex/connectivity/TestCase.java @@ -0,0 +1,27 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package complex.connectivity; + +import share.LogWriter; + +public interface TestCase +{ + void assure( final String i_message, final boolean i_condition ); + LogWriter getLog(); +} diff --git a/connectivity/qa/complex/connectivity/dbase/DBaseDateFunctions.java b/connectivity/qa/complex/connectivity/dbase/DBaseDateFunctions.java new file mode 100644 index 000000000..85975b481 --- /dev/null +++ b/connectivity/qa/complex/connectivity/dbase/DBaseDateFunctions.java @@ -0,0 +1,296 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package complex.connectivity.dbase; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.sdbc.*; +import com.sun.star.beans.XPropertySet; + +import com.sun.star.lang.XMultiServiceFactory; +import complex.connectivity.TestCase; +import complex.connectivity.SubTestCase; + +public class DBaseDateFunctions extends SubTestCase +{ + + private static final String where = "FROM \"biblio\" \"biblio\" where \"Identifier\" = 'BOR00'"; + private final XMultiServiceFactory m_xORB; + + public DBaseDateFunctions(final XMultiServiceFactory _xORB, final TestCase i_testCase) + { + super( i_testCase ); + m_xORB = _xORB; + } + + public void testFunctions() throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException + { + final XRowSet xRowRes = UnoRuntime.queryInterface(XRowSet.class, + m_xORB.createInstance("com.sun.star.sdb.RowSet")); + + getLog().println("starting DateTime function test!"); + // set the properties needed to connect to a database + final XPropertySet xProp = 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 = UnoRuntime.queryInterface(XPropertySet.class, xRowRes); + xProp.setPropertyValue("Command", "SELECT " + sql + where); + xRowRes.execute(); + final XResultSet xRes = UnoRuntime.queryInterface(XResultSet.class, xRowRes); + assure("No valid row! ", xRes.next()); + + return 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); + 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); + 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); + getLog().println("NOW() is '" + aTime.Year + "-" + aTime.Month + "-" + aTime.Day + "'"); + getLog().println("'" + aTime.Hours + ":" + aTime.Minutes + ":" + aTime.Seconds + "'"); + } +} diff --git a/connectivity/qa/complex/connectivity/dbase/DBaseNumericFunctions.java b/connectivity/qa/complex/connectivity/dbase/DBaseNumericFunctions.java new file mode 100644 index 000000000..218f02b0a --- /dev/null +++ b/connectivity/qa/complex/connectivity/dbase/DBaseNumericFunctions.java @@ -0,0 +1,388 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package complex.connectivity.dbase; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.sdbc.*; +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import complex.connectivity.SubTestCase; +import complex.connectivity.TestCase; + + +public class DBaseNumericFunctions extends SubTestCase +{ + private static final String where = "FROM \"biblio\" \"biblio\" where \"Identifier\" = 'BOR00'"; + private final XMultiServiceFactory m_xORB; + + public DBaseNumericFunctions(final XMultiServiceFactory _xORB, final TestCase i_testCase) + { + super( i_testCase ); + m_xORB = _xORB; + } + + public void testFunctions() throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException + { + final XRowSet xRowRes = UnoRuntime.queryInterface(XRowSet.class, + m_xORB.createInstance("com.sun.star.sdb.RowSet")); + + getLog().println("starting Numeric function test"); + // set the properties needed to connect to a database + final XPropertySet xProp = 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 = UnoRuntime.queryInterface(XPropertySet.class, xRowRes); + xProp.setPropertyValue("Command", "SELECT " + sql + where); + xRowRes.execute(); + final XResultSet xRes = UnoRuntime.queryInterface(XResultSet.class, xRowRes); + assure("No valid row! ", xRes.next()); + + return 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) Math.exp(2)); + assure("EXP(-2) failed!", (float) row.getDouble(2) == (float) 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) 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) 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) 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) Math.tan(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) == 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) (Math.PI / 2.0)); + } +} diff --git a/connectivity/qa/complex/connectivity/dbase/DBaseSqlTests.java b/connectivity/qa/complex/connectivity/dbase/DBaseSqlTests.java new file mode 100644 index 000000000..09f7cac22 --- /dev/null +++ b/connectivity/qa/complex/connectivity/dbase/DBaseSqlTests.java @@ -0,0 +1,80 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package complex.connectivity.dbase; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.sdbc.*; +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import complex.connectivity.TestCase; +import complex.connectivity.SubTestCase; + +public class DBaseSqlTests extends SubTestCase +{ + private final XMultiServiceFactory m_xORB; + + public DBaseSqlTests(final XMultiServiceFactory _xORB,final TestCase i_testCase) + { + super( i_testCase ); + m_xORB = _xORB; + } + + public void testFunctions() throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException + { + final XRowSet xRowRes = UnoRuntime.queryInterface(XRowSet.class, + m_xORB.createInstance("com.sun.star.sdb.RowSet")); + + getLog().println("starting SQL test"); + // set the properties needed to connect to a database + final XPropertySet xProp = 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 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 = UnoRuntime.queryInterface(XPropertySet.class, xRowRes); + xProp.setPropertyValue("Command", "SELECT " + sql); + xRowRes.execute(); + } + catch(SQLException e) + { + getLog().println(sql + " Error: " + e.getMessage()); + } + } + + +} diff --git a/connectivity/qa/complex/connectivity/dbase/DBaseStringFunctions.java b/connectivity/qa/complex/connectivity/dbase/DBaseStringFunctions.java new file mode 100644 index 000000000..4d5dc2dd6 --- /dev/null +++ b/connectivity/qa/complex/connectivity/dbase/DBaseStringFunctions.java @@ -0,0 +1,310 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package complex.connectivity.dbase; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.sdbc.*; +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import complex.connectivity.SubTestCase; +import complex.connectivity.TestCase; + +public class DBaseStringFunctions extends SubTestCase +{ + private String where = "FROM \"biblio\" \"biblio\" where \"Identifier\" = 'BOR00'"; + private final XMultiServiceFactory m_xORB; + + public DBaseStringFunctions(final XMultiServiceFactory _xORB,final TestCase i_testCase) + { + super( i_testCase ); + m_xORB = _xORB; + } + + public void testFunctions() throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException + { + final XRowSet xRowRes = UnoRuntime.queryInterface(XRowSet.class, + m_xORB.createInstance("com.sun.star.sdb.RowSet")); + + getLog().println("starting String function test"); + // set the properties needed to connect to a database + final XPropertySet xProp = 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 + { + ascii(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 = UnoRuntime.queryInterface(XPropertySet.class, xRowRes); + xProp.setPropertyValue("Command", "SELECT " + sql + where); + xRowRes.execute(); + final XResultSet xRes = UnoRuntime.queryInterface(XResultSet.class, xRowRes); + assure("No valid row! ", xRes.next()); + + return 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 ascii(final XRowSet xRowRes) throws com.sun.star.uno.Exception, com.sun.star.beans.UnknownPropertyException + { + final XRow row = execute(xRowRes, "ASCII('2') "); + assure("ascii('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/complex/connectivity/hsqldb/TestCacheSize.java b/connectivity/qa/complex/connectivity/hsqldb/TestCacheSize.java new file mode 100644 index 000000000..d3c802e15 --- /dev/null +++ b/connectivity/qa/complex/connectivity/hsqldb/TestCacheSize.java @@ -0,0 +1,591 @@ +/* + * This file is part of the LibreOffice project. + * + * 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 complex.connectivity.hsqldb; + + + +import org.hsqldb.lib.StopWatch; + +import java.util.Random; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.sdbc.*; + +/** + * 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 + * + * @version 1.7.2 + * @since 1.7.0 + */ +public class TestCacheSize { + + // program can edit the *.properties file to set cache_size + private boolean filedb = true; + + // shutdown performed mid operation - not for mem: or hsql: URL's + private boolean shutdown = true; + + // fixed + private String url = "sdbc:embedded:hsqldb"; + + // frequent reporting of progress + private boolean reportProgress = false; + + // type of the big table {MEMORY | CACHED | TEXT} + private String tableType = "CACHED"; + private int cacheScale = 17; + + // script format {TEXT, BINARY, COMPRESSED} + private String logType = "TEXT"; + private int writeDelay = 60; + private boolean indexZip = true; + private boolean indexLastName = false; + private boolean addForeignKey = false; + private boolean refIntegrity = true; + + // speeds up inserts when tableType=="CACHED" + private boolean createTempTable = false; + + // introduces fragmentation to the .data file during insert + private boolean deleteWhileInsert = false; + private int deleteWhileInsertInterval = 10000; + + // size of the tables used in test + private int bigrows = 10000; + private int smallrows = 0xfff; + + // if the extra table needs to be created and filled up + private boolean multikeytable = false; + + + private XStatement sStatement; + private XConnection cConnection; + private XDriver drv; + private com.sun.star.beans.PropertyValue[] info; + + public TestCacheSize(com.sun.star.beans.PropertyValue[] _info,XDriver _drv){ + drv = _drv; + info = _info; + } + + public void setURL(String _url){ + url = _url; + } + + public void setUp() { + + try { + sStatement = null; + cConnection = null; + + 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(); + } + } 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"); + } + + 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 = 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 = UnoRuntime.queryInterface(XMultipleResults.class,sStatement); + XResultSet rs = mrs.getResultSet(); + + rs.next(); + + XRow row = 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;"); + } + } + + System.out.println("Total insert: " + i); + System.out.println("Insert time: " + sw.elapsedTime() + " rps: " + + (1000L * i / (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 = 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: " + + (1000L * i / (sw.elapsedTime() + 1))); + } + + public void tearDown() {} + + public 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 = UnoRuntime.queryInterface(XMultipleResults.class,sStatement); + rs = mrs.getResultSet(); + XRow row = 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 = 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: " + + (1000L * i / (sw.elapsedTime() + 1))); + } + } + } catch (SQLException e) { + e.printStackTrace(); + } + + System.out.println("Select random zip " + i + " rows : " + + sw.elapsedTime() + " rps: " + + (1000L * i / (sw.elapsedTime() + 1))); + sw.zero(); + + try { + XPreparedStatement ps = cConnection.prepareStatement( + "SELECT firstname,lastname,zip,filler FROM test WHERE id = ?"); + XParameters para = 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: " + + (1000L * i / (sw.elapsedTime() + 1))); + sw.zero(); + + try { + XPreparedStatement ps = cConnection.prepareStatement( + "SELECT zip FROM zip WHERE zip = ?"); + XParameters para = 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: " + + (1000L * i / (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 = 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: " + + (1000L * count / (sw.elapsedTime() + 1))); + sw.zero(); + + try { + XPreparedStatement ps = cConnection.prepareStatement( + "UPDATE test SET zip = zip + 1 WHERE id = ?"); + XParameters para = 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: " + + (1000L * i / (sw.elapsedTime() + 1))); + } + } + } catch (SQLException e) { + e.printStackTrace(); + } + + System.out.println("Update with random id " + i + " rows : " + + sw.elapsedTime() + " rps: " + + (1000L * i / (sw.elapsedTime() + 1))); + } +} diff --git a/connectivity/qa/connectivity/ado/DriverTest.cxx b/connectivity/qa/connectivity/ado/DriverTest.cxx new file mode 100644 index 000000000..f4dd0ebc2 --- /dev/null +++ b/connectivity/qa/connectivity/ado/DriverTest.cxx @@ -0,0 +1,141 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#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 +#include +#include +#include +#include +#include +#include +#include "strings.hrc" + + +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::uno; + +namespace connectivity::ado { + + +class AdoDriverTest: public test::BootstrapFixture +{ +public: + AdoDriverTest() : test::BootstrapFixture(false, false) {}; + + void test_metadata(); + void test_select_default_all(); + + virtual void setUp(); + virtual void tearDown(); + + CPPUNIT_TEST_SUITE(AdoDriverTest); + + CPPUNIT_TEST(test_metadata); + CPPUNIT_TEST(test_select_default_all); + CPPUNIT_TEST_SUITE_END(); + +private: + Reference m_xAdoComponent; + Reference m_xConnection; +}; + +void AdoDriverTest::setUp() +{ + test::BootstrapFixture::setUp(); + m_xAdoComponent = getMultiServiceFactory()->createInstance("com.sun.star.comp.sdbc.ado.ODriver"); + CPPUNIT_ASSERT_MESSAGE("no ado component!", m_xAdoComponent.is()); + + OUString url = "sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" + + m_directories.getPathFromWorkdir("/CppunitTest/TS001018407.mdb"); + + Sequence< PropertyValue > info; + Reference< XDriver> xDriver(m_xAdoComponent, UNO_QUERY); + if (!xDriver.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot connect to ado driver!", xDriver.is()); + } + + m_xConnection = xDriver->connect(url, info); + if (!m_xConnection.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot connect to students data source!", m_xConnection.is()); + } +} + +void AdoDriverTest::tearDown() +{ + m_xAdoComponent = 0; + test::BootstrapFixture::tearDown(); +} + +void AdoDriverTest::test_metadata() +{ + Reference< XDatabaseMetaData > xDatabaseMetaData = m_xConnection->getMetaData(); + if (!xDatabaseMetaData.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot retrieve meta data!", xDatabaseMetaData.is()); + } + + const Any catalog; + const OUString schemaPattern = "%"; + const OUString tableNamePattern = "%"; + const Sequence< OUString > types; + + Reference< XResultSet > xResultSet = + xDatabaseMetaData->getTables(catalog, schemaPattern, tableNamePattern, types); + if (!xResultSet.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot retrieve tables!", xResultSet.is()); + } +} + +void AdoDriverTest::test_select_default_all() +{ + const OUString sql = "select \"FirstName\" from \"Students\" ORDER BY \"FirstName\""; + Reference< XPreparedStatement > xStatement = m_xConnection->prepareStatement(sql); + if (!xStatement.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot create prepared statement!", xStatement.is()); + } + + Reference< XResultSet > xResultSet = xStatement->executeQuery(); + if (!xResultSet.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot execute sql statement!", xResultSet.is()); + } + + Reference< XRow > xDelegatorRow(xResultSet, UNO_QUERY); + if (!xDelegatorRow.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot extract row from result set!", xDelegatorRow.is()); + } + + sal_Bool result = xResultSet->first(); + CPPUNIT_ASSERT_MESSAGE("fetch first row failed!", result); +/* + OUString mail = xDelegatorRow->getString(1); + CPPUNIT_ASSERT_MESSAGE("first row is not john@doe.org!", mail.equalsAscii("john@doe.org")); +*/ +} + +CPPUNIT_TEST_SUITE_REGISTRATION(AdoDriverTest); + +} + +CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/connectivity/qa/connectivity/ado/TS001018407.mdb b/connectivity/qa/connectivity/ado/TS001018407.mdb new file mode 100644 index 000000000..abe9f5ee3 Binary files /dev/null and b/connectivity/qa/connectivity/ado/TS001018407.mdb differ diff --git a/connectivity/qa/connectivity/commontools/FValue_test.cxx b/connectivity/qa/connectivity/commontools/FValue_test.cxx new file mode 100644 index 000000000..b6f0e3658 --- /dev/null +++ b/connectivity/qa/connectivity/commontools/FValue_test.cxx @@ -0,0 +1,366 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +#include +#include +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::uno; + +namespace connectivity::commontools { + +class FValueTest: public test::BootstrapFixture +{ +public: + FValueTest() : test::BootstrapFixture(false, false) {}; + + void test_Bool(); + + void test_Int8(); + + void test_Int16(); + void test_uInt16(); + + void test_Int32(); + void test_uInt32(); + + void test_Int64(); + void test_uInt64(); + + void test_float(); + void test_double(); + + void test_bool_getString(); + void test_bit_getString(); + + void test_bool_creation(); + + CPPUNIT_TEST_SUITE(FValueTest); + + CPPUNIT_TEST(test_Bool); + + CPPUNIT_TEST(test_Int8); + + CPPUNIT_TEST(test_Int16); + CPPUNIT_TEST(test_uInt16); + + CPPUNIT_TEST(test_Int32); + CPPUNIT_TEST(test_uInt32); + + CPPUNIT_TEST(test_Int64); + CPPUNIT_TEST(test_uInt64); + + CPPUNIT_TEST(test_float); + CPPUNIT_TEST(test_double); + + CPPUNIT_TEST(test_bool_getString); + CPPUNIT_TEST(test_bit_getString); + CPPUNIT_TEST(test_bool_creation); + CPPUNIT_TEST_SUITE_END(); +}; + +void FValueTest::test_Bool() +{ + bool src_Bool = true; + ORowSetValue v(src_Bool); + bool trg_Bool = v.getBool(); + + std::cerr << "src_Bool: " << src_Bool << std::endl; + std::cerr << "trg_Bool: " << trg_Bool << std::endl; + + CPPUNIT_ASSERT_EQUAL_MESSAGE("bool conversion to ORowSetValue didn't work", trg_Bool, src_Bool); + + Any any_Bool = v.makeAny(); + ORowSetValue t; + t.fill(any_Bool); + trg_Bool = t.getBool(); + + std::cerr << "trg_Bool: " << trg_Bool << std::endl; + + CPPUNIT_ASSERT_EQUAL_MESSAGE("bool conversion from Any didn't work", trg_Bool, src_Bool); +} + +void FValueTest::test_Int8() +{ + sal_Int8 src_salInt8 = 127; + ORowSetValue v(src_salInt8); + sal_Int8 trg_salInt8 = v.getInt8(); + + std::cerr << "src_salInt8: " << static_cast(src_salInt8) << std::endl; + std::cerr << "trg_salInt8: " << static_cast(trg_salInt8) << std::endl; + + CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8 conversion to ORowSetValue didn't work", trg_salInt8, src_salInt8); + + Any any_Int8 = v.makeAny(); + ORowSetValue t; + t.fill(any_Int8); + trg_salInt8 = t.getInt8(); + + std::cerr << "trg_salInt8: " << static_cast(trg_salInt8) << std::endl; + + CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int8 conversion from Any didn't work", trg_salInt8, src_salInt8); +} + +void FValueTest::test_Int16() +{ + sal_Int16 src_salInt16 = -10001; + ORowSetValue v(src_salInt16); + sal_Int16 trg_salInt16 = v.getInt16(); + + std::cerr << "src_salInt16: " << src_salInt16 << std::endl; + std::cerr << "trg_salInt16: " << trg_salInt16 << std::endl; + + CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16 conversion to ORowSetValue didn't work", trg_salInt16, src_salInt16); + + Any any_Int16 = v.makeAny(); + ORowSetValue t; + t.fill(any_Int16); + trg_salInt16 = t.getInt16(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int16 conversion from Any didn't work", trg_salInt16, src_salInt16); +} + +void FValueTest::test_uInt16() +{ + sal_uInt16 src_saluInt16 = 10001; + ORowSetValue v(src_saluInt16); + sal_uInt16 trg_saluInt16 = v.getUInt16(); + + std::cerr << "src_saluInt16: " << src_saluInt16 << std::endl; + std::cerr << "trg_saluInt16: " << trg_saluInt16 << std::endl; + + CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16 conversion to ORowSetValue didn't work", trg_saluInt16, src_saluInt16); + + Any any_uInt16 = v.makeAny(); + ORowSetValue t; + t.fill(any_uInt16); + trg_saluInt16 = t.getUInt16(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt16 conversion from Any didn't work", trg_saluInt16, src_saluInt16); +} + +void FValueTest::test_Int32() +{ + sal_Int32 src_salInt32 = -10000001; + ORowSetValue v(src_salInt32); + sal_Int32 trg_salInt32 = v.getInt32(); + + std::cerr << "src_salInt32: " << src_salInt32 << std::endl; + std::cerr << "trg_salInt32: " << trg_salInt32 << std::endl; + + CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32 conversion to ORowSetValue didn't work", trg_salInt32, src_salInt32); + + Any any_Int32 = v.makeAny(); + ORowSetValue t; + t.fill(any_Int32); + trg_salInt32 = t.getInt32(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int32 conversion from Any didn't work", trg_salInt32, src_salInt32); +} + +void FValueTest::test_uInt32() +{ + sal_uInt32 src_saluInt32 = 100000001; + ORowSetValue v(src_saluInt32); + sal_uInt32 trg_saluInt32 = v.getUInt32(); + + std::cerr << "src_saluInt32: " << src_saluInt32 << std::endl; + std::cerr << "trg_saluInt32: " << trg_saluInt32 << std::endl; + + CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32 conversion to ORowSetValue didn't work", trg_saluInt32, src_saluInt32); + + Any any_uInt32 = v.makeAny(); + ORowSetValue t; + t.fill(any_uInt32); + trg_saluInt32 = t.getUInt32(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt32 conversion from Any didn't work", trg_saluInt32, src_saluInt32); +} + +void FValueTest::test_Int64() +{ + sal_Int64 src_salInt64 = -1000000000000000001LL; + ORowSetValue v(src_salInt64); + sal_Int64 trg_salInt64 = v.getLong(); + + std::cerr << "src_salInt64: " << src_salInt64 << std::endl; + std::cerr << "trg_salInt64: " << trg_salInt64 << std::endl; + + CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64 conversion to ORowSetValue didn't work", trg_salInt64, src_salInt64); + + Any any_Int64 = v.makeAny(); + ORowSetValue t; + t.fill(any_Int64); + trg_salInt64 = t.getLong(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_Int64 conversion from Any didn't work", trg_salInt64, src_salInt64); +} + +void FValueTest::test_uInt64() +{ + sal_uInt64 src_saluInt64 = 10000000000000000001ULL; + ORowSetValue v(src_saluInt64); + sal_uInt64 trg_saluInt64 = v.getULong(); + + std::cerr << "src_saluInt64: " << src_saluInt64 << std::endl; + std::cerr << "trg_saluInt64: " << trg_saluInt64 << std::endl; + + CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64 conversion to ORowSetValue didn't work", trg_saluInt64, src_saluInt64); + + Any any_uInt64 = v.makeAny(); + ORowSetValue t; + t.fill(any_uInt64); + trg_saluInt64 = t.getULong(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("sal_uInt64 conversion from Any didn't work", trg_saluInt64, src_saluInt64); +} + +void FValueTest::test_float() +{ + float src_float = 1.234f; + ORowSetValue v(src_float); + float trg_float = v.getFloat(); + + std::cerr << "src_float: " << src_float << std::endl; + std::cerr << "trg_float: " << trg_float << std::endl; + + CPPUNIT_ASSERT_EQUAL_MESSAGE("float conversion to ORowSetValue didn't work", trg_float, src_float); + + Any any_float = v.makeAny(); + ORowSetValue t; + t.fill(any_float); + trg_float = t.getFloat(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("float conversion from Any didn't work", trg_float, src_float); +} + +void FValueTest::test_double() +{ + double src_double = 1.23456789; + ORowSetValue v(src_double); + double trg_double = v.getDouble(); + + std::cerr << "src_double: " << src_double << std::endl; + std::cerr << "trg_double: " << trg_double << std::endl; + + CPPUNIT_ASSERT_EQUAL_MESSAGE("double conversion to ORowSetValue didn't work", trg_double, src_double); + + Any any_double = v.makeAny(); + ORowSetValue t; + t.fill(any_double); + trg_double = t.getDouble(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("double conversion from Any didn't work", trg_double, src_double); +} + +void FValueTest::test_bool_getString() +{ + bool src_bool_1 = true; + ORowSetValue v_1(src_bool_1); + OUString trg_bool_1 = v_1.getString(); + + std::cerr << "src_bool_1: " << src_bool_1 << std::endl; + std::cerr << "trg_bool_1: " << trg_bool_1 << std::endl; + + CPPUNIT_ASSERT_MESSAGE("ORowSetValue bool to string conversion didn't work", bool(trg_bool_1 == "true")); + + bool src_bool_0 = false; + ORowSetValue v_0(src_bool_0); + OUString trg_bool_0 = v_0.getString(); + + std::cerr << "src_bool_0: " << src_bool_0 << std::endl; + std::cerr << "trg_bool_0: " << trg_bool_0 << std::endl; + + CPPUNIT_ASSERT_MESSAGE("ORowSetValue bool to string conversion didn't work", bool(trg_bool_0 == "false")); +} + +void FValueTest::test_bit_getString() +{ + bool src_bool_1 = true; + ORowSetValue v_1(src_bool_1); + v_1.setTypeKind(DataType::BIT); + OUString trg_bool_1 = v_1.getString(); + + std::cerr << "src_bit_1: " << src_bool_1 << std::endl; + std::cerr << "trg_bit_1: " << trg_bool_1 << std::endl; + + CPPUNIT_ASSERT_MESSAGE("ORowSetValue bit to string conversion didn't work", bool(trg_bool_1 == "1")); + + bool src_bool_0 = false; + ORowSetValue v_0(src_bool_0); + v_0.setTypeKind(DataType::BIT); + OUString trg_bool_0 = v_0.getString(); + + std::cerr << "src_bit_0: " << src_bool_0 << std::endl; + std::cerr << "trg_bit_0: " << trg_bool_0 << std::endl; + + CPPUNIT_ASSERT_MESSAGE("ORowSetValue bit to string conversion didn't work", bool(trg_bool_0 == "0")); +} + +void FValueTest::test_bool_creation() +{ + ORowSetValue vTrue(true); + ORowSetValue vFalse(false); + + { + ORowSetValue v(OUString("1")); + v.setTypeKind(DataType::BOOLEAN); + CPPUNIT_ASSERT_MESSAGE("ORowSetValue bool creation from string didn't work", bool(v == vTrue)); + } + + { + ORowSetValue v(OUString("0")); + v.setTypeKind(DataType::BOOLEAN); + CPPUNIT_ASSERT_MESSAGE("ORowSetValue bool creation from string didn't work", bool(v == vFalse)); + } + + { + ORowSetValue v(OUString("true")); + v.setTypeKind(DataType::BOOLEAN); + CPPUNIT_ASSERT_MESSAGE("ORowSetValue bool creation from string didn't work", bool(v == vTrue)); + } + + { + ORowSetValue v(OUString("tRuE")); + v.setTypeKind(DataType::BOOLEAN); + CPPUNIT_ASSERT_MESSAGE("ORowSetValue bool creation from string didn't work", bool(v == vTrue)); + } + + { + ORowSetValue v(OUString("false")); + v.setTypeKind(DataType::BOOLEAN); + CPPUNIT_ASSERT_MESSAGE("ORowSetValue bool creation from string didn't work", bool(v == vFalse)); + } + + { + ORowSetValue v(OUString("0")); + v.setTypeKind(DataType::BOOLEAN); + CPPUNIT_ASSERT_MESSAGE("ORowSetValue bool creation from string didn't work", bool(v == vFalse)); + } + +} + +CPPUNIT_TEST_SUITE_REGISTRATION(FValueTest); + +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/qa/connectivity/mork/DriverTest.cxx b/connectivity/qa/connectivity/mork/DriverTest.cxx new file mode 100644 index 000000000..e2f2849ff --- /dev/null +++ b/connectivity/qa/connectivity/mork/DriverTest.cxx @@ -0,0 +1,199 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include +#include + +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::uno; + +namespace connectivity::mork { + + +class MorkDriverTest: public test::BootstrapFixture +{ +public: + MorkDriverTest() : test::BootstrapFixture(false, false) {}; + + void checkAcceptsURL(Reference< XDriver> const & xDriver, const char* url, bool expected); + void test_metadata(); + void test_select_default_all(); + void test_select_list_table_joe_doe_5(); + + virtual void setUp() override; + virtual void tearDown() override; + + CPPUNIT_TEST_SUITE(MorkDriverTest); + + CPPUNIT_TEST(test_metadata); + CPPUNIT_TEST(test_select_default_all); + CPPUNIT_TEST(test_select_list_table_joe_doe_5); + CPPUNIT_TEST_SUITE_END(); + +private: + Reference m_xMorkComponent; + Reference m_xConnection; +}; + +void MorkDriverTest::checkAcceptsURL(Reference< XDriver> const & xDriver, const char* url, bool expected) +{ + bool res = xDriver->acceptsURL(OUString::createFromAscii(url)); + if (res != expected) + { + CPPUNIT_ASSERT_MESSAGE("wrong URL outcome!", true); + } +} + +void MorkDriverTest::setUp() +{ + test::BootstrapFixture::setUp(); + m_xMorkComponent = getMultiServiceFactory()->createInstance("com.sun.star.comp.sdbc.MorkDriver"); + CPPUNIT_ASSERT_MESSAGE("no mork component!", m_xMorkComponent.is()); + + // is this the best way to pass test file through URL? + // may be take a custom Sequence< PropertyValue > route? + OUString url = "sdbc:address:thunderbird:unittest:" + + m_directories.getPathFromSrc("/connectivity/qa/connectivity/mork/abook_10_john_does.mab"); + + Sequence< PropertyValue > info; + Reference< XDriver> xDriver(m_xMorkComponent, UNO_QUERY); + if (!xDriver.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot connect to mork driver!", xDriver.is()); + } + + // bad + checkAcceptsURL(xDriver, "sdbc:address:macab", false); + checkAcceptsURL(xDriver, "sdbc:mozab:ldap:", false); + checkAcceptsURL(xDriver, "sdbc:mozab:outlook:", false); + checkAcceptsURL(xDriver, "sdbc:mozab:outlookexp:", false); + + // good + checkAcceptsURL(xDriver, "sdbc:mozab:mozilla:", true); + checkAcceptsURL(xDriver, "sdbc:mozab:thunderbird:", true); + checkAcceptsURL(xDriver, "sdbc:address:mozilla:", true); + checkAcceptsURL(xDriver, "sdbc:address:thunderbird:", true); + + m_xConnection = xDriver->connect(url, info); + if (!m_xConnection.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot connect to address book data source!", m_xConnection.is()); + } +} + +void MorkDriverTest::tearDown() +{ +// how to make dispose() work? +// Reference< css::lang::XComponent >( m_xMorkComponent, UNO_QUERY_THROW )->dispose(); + m_xConnection->close(); + test::BootstrapFixture::tearDown(); +} + +void MorkDriverTest::test_metadata() +{ + Reference< XDatabaseMetaData > xDatabaseMetaData = m_xConnection->getMetaData(); + if (!xDatabaseMetaData.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot retrieve meta data!", xDatabaseMetaData.is()); + } + + const Any catalog; + const OUString schemaPattern = "%"; + const OUString tableNamePattern = "%"; + const Sequence< OUString > types; + + Reference< XResultSet > xResultSet = + xDatabaseMetaData->getTables(catalog, schemaPattern, tableNamePattern, types); + if (!xResultSet.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot retrieve tables!", xResultSet.is()); + } + + // TODO: how to access that result set and check the tables? + // it should be 3 tables inside: AddressBook, does_5 and does_10 +} + +void MorkDriverTest::test_select_default_all() +{ + const OUString sql = "select \"E-mail\" from \"AddressBook\" ORDER BY \"E-mail\""; + Reference< XPreparedStatement > xStatement = m_xConnection->prepareStatement(sql); + if (!xStatement.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot create prepared statement!", xStatement.is()); + } + + Reference< XResultSet > xResultSet = xStatement->executeQuery(); + if (!xResultSet.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot execute sql statement!", xResultSet.is()); + } + + Reference< XRow > xDelegatorRow(xResultSet, UNO_QUERY); + if (!xDelegatorRow.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot extract row from result set!", xDelegatorRow.is()); + } + + bool result = xResultSet->first(); + CPPUNIT_ASSERT_MESSAGE("fetch first row failed!", result); + OUString mail = xDelegatorRow->getString(1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("first row is not john@doe.org!", OUString("john@doe.org"), mail); + + result = xResultSet->next(); + CPPUNIT_ASSERT_MESSAGE("fetch second row failed!", result); + mail = xDelegatorRow->getString(1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("second row is not john@doe10.org!", OUString("john@doe10.org"), mail); + + result = xResultSet->last(); + CPPUNIT_ASSERT_MESSAGE("fetch last row failed!", result); + mail = xDelegatorRow->getString(1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("last row is not john@doe9.org!", OUString("john@doe9.org"), mail); + + css::uno::Reference( + xStatement, css::uno::UNO_QUERY_THROW)->close(); +} + +void MorkDriverTest::test_select_list_table_joe_doe_5() +{ + const OUString sql = "select \"E-mail\" from \"does_5\" where \"E-mail\" LIKE '%doe5.org' "; + Reference< XPreparedStatement > xStatement = m_xConnection->prepareStatement(sql); + if (!xStatement.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot create prepared statement!", xStatement.is()); + } + + Reference< XResultSet > xResultSet = xStatement->executeQuery(); + if (!xResultSet.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot execute sql statement!", xResultSet.is()); + } + + Reference< XRow > xDelegatorRow(xResultSet, UNO_QUERY); + if (!xDelegatorRow.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot extract row from result set!", xDelegatorRow.is()); + } + + bool result = xResultSet->first(); + CPPUNIT_ASSERT_MESSAGE("fetch first row failed!", result); + OUString mail = xDelegatorRow->getString(1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("last row is not john@doe5.org!", OUString("john@doe5.org"), mail); + + css::uno::Reference( + xStatement, css::uno::UNO_QUERY_THROW)->close(); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(MorkDriverTest); + +} + +CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/connectivity/qa/connectivity/mork/abook_10_john_does.mab b/connectivity/qa/connectivity/mork/abook_10_john_does.mab new file mode 100644 index 000000000..41aac4c3e --- /dev/null +++ b/connectivity/qa/connectivity/mork/abook_10_john_does.mab @@ -0,0 +1,159 @@ +// +< <(a=c)> // (f=iso-8859-1) + (B8=LastModifiedDate)(B9=RecordKey)(BA=AddrCharSet)(BB=LastRecordKey) + (BC=ns:addrbk:db:table:kind:pab)(BD=ListName)(BE=ListNickName) + (BF=ListDescription)(C0=ListTotalAddresses)(C1=LowercaseListName) + (C2=ns:addrbk:db:table:kind:deleted)(C3=_Yahoo)(C4=_MSN) + (C5=_GoogleTalk)(C6=_Skype)(C7=_JabberId)(C8=PreferDisplayName) + (C9=PhotoURI)(CA=PhotoType)(CB=PhotoName)(CC=DbRowID)(CD=_QQ)(CE=_ICQ) + (80=ns:addrbk:db:row:scope:card:all) + (81=ns:addrbk:db:row:scope:list:all) + (82=ns:addrbk:db:row:scope:data:all)(83=FirstName)(84=LastName) + (85=PhoneticFirstName)(86=PhoneticLastName)(87=DisplayName) + (88=NickName)(89=PrimaryEmail)(8A=LowercasePrimaryEmail) + (8B=SecondEmail)(8C=PreferMailFormat)(8D=PopularityIndex) + (8E=AllowRemoteContent)(8F=WorkPhone)(90=HomePhone)(91=FaxNumber) + (92=PagerNumber)(93=CellularNumber)(94=WorkPhoneType)(95=HomePhoneType) + (96=FaxNumberType)(97=PagerNumberType)(98=CellularNumberType) + (99=HomeAddress)(9A=HomeAddress2)(9B=HomeCity)(9C=HomeState) + (9D=HomeZipCode)(9E=HomeCountry)(9F=WorkAddress)(A0=WorkAddress2) + (A1=WorkCity)(A2=WorkState)(A3=WorkZipCode)(A4=WorkCountry) + (A5=JobTitle)(A6=Department)(A7=Company)(A8=_AimScreenName) + (A9=AnniversaryYear)(AA=AnniversaryMonth)(AB=AnniversaryDay) + (AC=SpouseName)(AD=FamilyName)(AE=WebPage1)(AF=WebPage2)(B0=BirthYear) + (B1=BirthMonth)(B2=BirthDay)(B3=Custom1)(B4=Custom2)(B5=Custom3) + (B6=Custom4)(B7=Notes)> + +<(AF=b)(81=John Doe)(82=)(80=0)(83=John)(84=1)(85=Doe)(86=john@doe.org) + (87=generic)(88=John Doe2)(89=Doe2)(8A=john@doe2.org)(8B=2)(8C=John Doe3) + (8D=Doe3)(8E=john@doe3.org)(8F=3)(90=John Doe4)(91=Doe4)(92 + =john@doe4.org)(93=4)(94=John Doe5)(95=Doe5)(96=john@doe5.org)(97=5) + (98=John Doe6)(99=Doe6)(9A=john@doe6.org)(9B=6)(9C=John Doe7)(9D=Doe7) + (9E=john@doe7.org)(9F=7)(A0=John Doe8)(A1=Doe8)(A2=john@doe8.org) + (A3=8)(A4=John Doe9)(A5=Doe9)(A6=john@doe9.org)(A7=9)(A8=John Doe10) + (A9=Doe10)(AA=john@doe10.org)(AB=10)(AC=a)(AD=Does_5)(AE=does_5)> +{1:^80 {(k^BC:c)(s=9)} + [1:^82(^BB=b)] + [1(^87^81)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) + (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) + (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^85)(^92=)(^C9=) + (^B6=)(^9D=)(^89^86)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) + (^90=)(^CC=1)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) + (^CE=)(^B5=)(^8A^86)(^B9=1)] + [2(^87^88)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) + (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) + (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^89)(^92=)(^C9=) + (^B6=)(^9D=)(^89^8A)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) + (^90=)(^CC=2)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) + (^CE=)(^B5=)(^8A^8A)(^B9=2)] + [3(^87^8C)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) + (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) + (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^8D)(^92=)(^C9=) + (^B6=)(^9D=)(^89^8E)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) + (^90=)(^CC=3)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) + (^CE=)(^B5=)(^8A^8E)(^B9=3)] + [4(^87^90)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) + (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) + (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^91)(^92=)(^C9=) + (^B6=)(^9D=)(^89^92)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) + (^90=)(^CC=4)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) + (^CE=)(^B5=)(^8A^92)(^B9=4)] + [5(^87^94)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) + (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) + (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^95)(^92=)(^C9=) + (^B6=)(^9D=)(^89^96)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) + (^90=)(^CC=5)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) + (^CE=)(^B5=)(^8A^96)(^B9=5)] + [6(^87^98)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) + (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) + (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^99)(^92=)(^C9=) + (^B6=)(^9D=)(^89^9A)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) + (^90=)(^CC=6)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) + (^CE=)(^B5=)(^8A^9A)(^B9=6)] + [7(^87^9C)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) + (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) + (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^9D)(^92=)(^C9=) + (^B6=)(^9D=)(^89^9E)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) + (^90=)(^CC=7)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) + (^CE=)(^B5=)(^8A^9E)(^B9=7)] + [8(^87^A0)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) + (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) + (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^A1)(^92=)(^C9=) + (^B6=)(^9D=)(^89^A2)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) + (^90=)(^CC=8)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) + (^CE=)(^B5=)(^8A^A2)(^B9=8)] + [9(^87^A4)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) + (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) + (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^A5)(^92=)(^C9=) + (^B6=)(^9D=)(^89^A6)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) + (^90=)(^CC=9)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) + (^CE=)(^B5=)(^8A^A6)(^B9=9)] + [A(^87^A8)(^86=)(^C3=)(^A1=)(^AE=)(^C4=)(^C5=)(^B2=)(^A7=)(^9A=)(^B3=) + (^C6=)(^A6=)(^A4=)(^A5=)(^A3=)(^9E=)(^85=)(^B0=)(^8D=0)(^C7=)(^A0=) + (^A2=)(^B7=)(^8C=0)(^B8=0)(^83^83)(^A8=)(^C8=1)(^84^A9)(^92=)(^C9=) + (^B6=)(^9D=)(^89^AA)(^8E=0)(^AF=)(^CA^87)(^8F=)(^CB=)(^8B=)(^93=) + (^90=)(^CC=10)(^B1=)(^CD=)(^9B=)(^9C=)(^91=)(^B4=)(^9F=)(^99=)(^88=) + (^CE=)(^B5=)(^8A^AA)(^B9=a)] + [1:^81(^BD^AD)(^C1^AE)(^BE=)(^BF=)(^C0=0)(^B9=b)]} + +@$${9{@ + +<(B2=c)(B0=Does_10)(B1=does_10)> +{1:^80 {(k^BC:c)(s=9)} + [-2:^81(^BD^B0)(^C1^B1)(^BE=)(^BF=)(^C0=0)(^B9=c)]} +[1:^82(^BB=c)] +@$$}9}@ + +@$${A{@ +< <(a=c)> // (f=iso-8859-1) + (CF=Address1)> +[-1:^81(^BD^AD)(^C1^AE)(^BE=)(^BF=)(^C0=1)(^B9=b)(^CF=1)] +@$$}A}@ + +@$${B{@ +< <(a=c)> // (f=iso-8859-1) + (D0=Address2)> +[-1:^81(^BD^AD)(^C1^AE)(^BE=)(^BF=)(^C0=2)(^B9=b)(^CF=1)(^D0=2)] +@$$}B}@ + +@$${C{@ +< <(a=c)> // (f=iso-8859-1) + (D1=Address3)> +[-1:^81(^BD^AD)(^C1^AE)(^BE=)(^BF=)(^C0=3)(^B9=b)(^CF=1)(^D0=2)(^D1=3)] +@$$}C}@ + +@$${D{@ +< <(a=c)> // (f=iso-8859-1) + (D2=Address4)> +[-1:^81(^BD^AD)(^C1^AE)(^BE=)(^BF=)(^C0=4)(^B9=b)(^CF=1)(^D0=2)(^D1=3) + (^D2=4)] +@$$}D}@ + +@$${E{@ +< <(a=c)> // (f=iso-8859-1) + (D3=Address5)> +[-1:^81(^BD^AD)(^C1^AE)(^BE=)(^BF=)(^C0=5)(^B9=b)(^CF=1)(^D0=2)(^D1=3) + (^D2=4)(^D3=5)] +@$$}E}@ + +@$${F{@ +[-2:^81(^BD^B0)(^C1^B1)(^BE=)(^BF=)(^C0=1)(^B9=c)(^CF=a)] +@$$}F}@ + +@$${10{@ +[-2:^81(^BD^B0)(^C1^B1)(^BE=)(^BF=)(^C0=2)(^B9=c)(^CF=a)(^D0=6)] +@$$}10}@ + +@$${11{@ +[-2:^81(^BD^B0)(^C1^B1)(^BE=)(^BF=)(^C0=3)(^B9=c)(^CF=a)(^D0=6)(^D1=7)] +@$$}11}@ + +@$${12{@ +[-2:^81(^BD^B0)(^C1^B1)(^BE=)(^BF=)(^C0=4)(^B9=c)(^CF=a)(^D0=6)(^D1=7) + (^D2=8)] +@$$}12}@ + +@$${13{@ +[-2:^81(^BD^B0)(^C1^B1)(^BE=)(^BF=)(^C0=5)(^B9=c)(^CF=a)(^D0=6)(^D1=7) + (^D2=8)(^D3=9)] +@$$}13}@ diff --git a/connectivity/qa/connectivity/mysql/mysql.cxx b/connectivity/qa/connectivity/mysql/mysql.cxx new file mode 100644 index 000000000..7291c9f44 --- /dev/null +++ b/connectivity/qa/connectivity/mysql/mysql.cxx @@ -0,0 +1,501 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +using namespace ::com::sun::star; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; + +class MysqlTestDriver : public test::BootstrapFixture +{ +private: + OUString m_sUrl; + Reference m_xMysqlcComponent; + Reference m_xDriver; + Sequence m_infos; + +public: + MysqlTestDriver() + : test::BootstrapFixture(false, false) + { + } + virtual void setUp() override; + virtual void tearDown() override; + void testDBConnection(); + void testCreateAndDropTable(); + void testIntegerInsertAndQuery(); + void testDBPositionChange(); + void testMultipleResultsets(); + void testDBMetaData(); + void testTimestampField(); + void testNumericConversionPrepared(); + void testPreparedStmtIsAfterLast(); + void testGetStringFromBloColumnb(); + + CPPUNIT_TEST_SUITE(MysqlTestDriver); + CPPUNIT_TEST(testDBConnection); + CPPUNIT_TEST(testCreateAndDropTable); + CPPUNIT_TEST(testIntegerInsertAndQuery); + CPPUNIT_TEST(testMultipleResultsets); + CPPUNIT_TEST(testDBMetaData); + CPPUNIT_TEST(testTimestampField); + CPPUNIT_TEST(testNumericConversionPrepared); + CPPUNIT_TEST(testPreparedStmtIsAfterLast); + CPPUNIT_TEST(testGetStringFromBloColumnb); + CPPUNIT_TEST_SUITE_END(); +}; + +void MysqlTestDriver::tearDown() +{ + Reference xConnection = m_xDriver->connect(m_sUrl, m_infos); + if (!xConnection.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot connect to data source!", xConnection.is()); + } + uno::Reference xStatement = xConnection->createStatement(); + CPPUNIT_ASSERT(xStatement.is()); + xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); + xStatement->executeUpdate("DROP TABLE IF EXISTS otherTable"); + test::BootstrapFixture::tearDown(); +} + +void MysqlTestDriver::setUp() +{ + test::BootstrapFixture::setUp(); + + /* Get URL from environment variable. This test suite should run only when + * there is a URL given. This is because it can be used for testing connection to + * external databases as well. + * + * Example URL: + * username/password@sdbc:mysql:mysqlc:localhost:3306/testdatabase + */ + osl_getEnvironment(OUString("CONNECTIVITY_TEST_MYSQL_DRIVER").pData, &m_sUrl.pData); + m_xMysqlcComponent + = getMultiServiceFactory()->createInstance("com.sun.star.comp.sdbc.mysqlc.MysqlCDriver"); + CPPUNIT_ASSERT_MESSAGE("no mysqlc component!", m_xMysqlcComponent.is()); + + // set user name and password + m_infos = Sequence{ 2 }; + m_infos[0].Name = OUString{ "user" }; + sal_Int32 nPer = m_sUrl.indexOf("/"); + m_infos[0].Value = makeAny(m_sUrl.copy(0, nPer)); + m_sUrl = m_sUrl.copy(nPer + 1); + m_infos[1].Name = OUString{ "password" }; + sal_Int32 nAt = m_sUrl.indexOf("@"); + m_infos[1].Value = makeAny(m_sUrl.copy(0, nAt)); + m_sUrl = m_sUrl.copy(nAt + 1); + + m_xDriver.set(m_xMysqlcComponent, UNO_QUERY); + if (!m_xDriver.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot connect to mysqlc driver!", m_xDriver.is()); + } +} + +/** + * Test database connection. It is assumed that the given URL is correct and + * there is a server running at the location. + */ +void MysqlTestDriver::testDBConnection() +{ + Reference xConnection = m_xDriver->connect(m_sUrl, m_infos); + if (!xConnection.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot connect to data source!", xConnection.is()); + } + + uno::Reference xStatement = xConnection->createStatement(); + CPPUNIT_ASSERT(xStatement.is()); + + Reference xResultSet = xStatement->executeQuery("SELECT 1"); + CPPUNIT_ASSERT(xResultSet.is()); + Reference xRow(xResultSet, UNO_QUERY); + CPPUNIT_ASSERT_MESSAGE("cannot extract row from result set!", xRow.is()); + + sal_Bool result = xResultSet->first(); + CPPUNIT_ASSERT_MESSAGE("fetch first row failed!", result); +} + +/** + * Test creation and removal of a table + */ +void MysqlTestDriver::testCreateAndDropTable() +{ + Reference xConnection = m_xDriver->connect(m_sUrl, m_infos); + if (!xConnection.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot connect to data source!", xConnection.is()); + } + + uno::Reference xStatement = xConnection->createStatement(); + CPPUNIT_ASSERT(xStatement.is()); + xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); + + auto nUpdateCount + = xStatement->executeUpdate("CREATE TABLE myTestTable (id INTEGER PRIMARY KEY)"); + CPPUNIT_ASSERT_EQUAL(0, nUpdateCount); // it's a DDL statement + + // we can use the same xStatement instance here + nUpdateCount = xStatement->executeUpdate("DROP TABLE myTestTable"); + CPPUNIT_ASSERT_EQUAL(0, nUpdateCount); // it's a DDL statement +} + +void MysqlTestDriver::testIntegerInsertAndQuery() +{ + Reference xConnection = m_xDriver->connect(m_sUrl, m_infos); + if (!xConnection.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot connect to data source!", xConnection.is()); + } + + Reference xStatement = xConnection->createStatement(); + CPPUNIT_ASSERT(xStatement.is()); + xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); + + auto nUpdateCount + = xStatement->executeUpdate("CREATE TABLE myTestTable (id INTEGER PRIMARY KEY)"); + CPPUNIT_ASSERT_EQUAL(0, nUpdateCount); // it's a DDL statement + + Reference xPrepared + = xConnection->prepareStatement(OUString{ "INSERT INTO myTestTable VALUES (?)" }); + Reference xParams(xPrepared, UNO_QUERY); + constexpr int ROW_COUNT = 3; + for (int i = 0; i < ROW_COUNT; ++i) + { + xParams->setLong(1, i); // first and only column + nUpdateCount = xPrepared->executeUpdate(); + CPPUNIT_ASSERT_EQUAL(1, nUpdateCount); // one row is inserted at a time + } + + // now let's query the existing data + Reference xResultSet = xStatement->executeQuery("SELECT id from myTestTable"); + CPPUNIT_ASSERT_MESSAGE("result set cannot be instantiated after query", xResultSet.is()); + Reference xRow(xResultSet, UNO_QUERY); + Reference xColumnLocate(xResultSet, UNO_QUERY); + CPPUNIT_ASSERT_MESSAGE("cannot extract row from result set!", xRow.is()); + + for (long i = 0; i < ROW_COUNT; ++i) + { + bool hasRow = xResultSet->next(); + CPPUNIT_ASSERT_MESSAGE("not enough result after query", hasRow); + CPPUNIT_ASSERT_EQUAL(i, xRow->getLong(1)); // first and only column + CPPUNIT_ASSERT_EQUAL(i, xRow->getLong(xColumnLocate->findColumn("id"))); // test findColumn + } + CPPUNIT_ASSERT_MESSAGE("Cursor is not on last position.", + xResultSet->isLast()); // cursor is on last position + CPPUNIT_ASSERT_EQUAL(ROW_COUNT, xResultSet->getRow()); // which is the last position + + bool hasRow = xResultSet->next(); // go to afterlast + // no more rows, next should return false + CPPUNIT_ASSERT_MESSAGE("next returns true after last row", !hasRow); + // cursor should be in afterlast position + CPPUNIT_ASSERT_EQUAL(ROW_COUNT + 1, xResultSet->getRow()); + CPPUNIT_ASSERT_MESSAGE("Cursor is not on after-last position.", xResultSet->isAfterLast()); + + nUpdateCount = xStatement->executeUpdate("DROP TABLE myTestTable"); + CPPUNIT_ASSERT_EQUAL(0, nUpdateCount); // it's a DDL statement +} + +void MysqlTestDriver::testDBPositionChange() +{ + Reference xConnection = m_xDriver->connect(m_sUrl, m_infos); + if (!xConnection.is()) + { + CPPUNIT_ASSERT_MESSAGE("cannot connect to data source!", xConnection.is()); + } + + Reference xStatement = xConnection->createStatement(); + CPPUNIT_ASSERT(xStatement.is()); + xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); + + auto nUpdateCount + = xStatement->executeUpdate("CREATE TABLE myTestTable (id INTEGER PRIMARY KEY)"); + CPPUNIT_ASSERT_EQUAL(0, nUpdateCount); // it's a DDL statement + Reference xPrepared + = xConnection->prepareStatement(OUString{ "INSERT INTO myTestTable VALUES (?)" }); + Reference xParams(xPrepared, UNO_QUERY); + constexpr int ROW_COUNT = 3; + for (int i = 1; i <= ROW_COUNT; ++i) + { + xParams->setLong(1, i); // first and only column + nUpdateCount = xPrepared->executeUpdate(); + CPPUNIT_ASSERT_EQUAL(1, nUpdateCount); // one row is inserted at a time + } + Reference xResultSet = xStatement->executeQuery("SELECT id from myTestTable"); + CPPUNIT_ASSERT_MESSAGE("result set cannot be instantiated after query", xResultSet.is()); + Reference xRow(xResultSet, UNO_QUERY); + CPPUNIT_ASSERT_MESSAGE("cannot extract row from result set!", xRow.is()); + + xResultSet->afterLast(); + CPPUNIT_ASSERT_EQUAL(ROW_COUNT + 1, xResultSet->getRow()); + xResultSet->last(); + CPPUNIT_ASSERT_EQUAL(ROW_COUNT, nUpdateCount); + CPPUNIT_ASSERT_EQUAL(ROW_COUNT, xResultSet->getRow()); + bool successPrevious = xResultSet->previous(); + CPPUNIT_ASSERT(successPrevious); + CPPUNIT_ASSERT_EQUAL(ROW_COUNT - 1, nUpdateCount); + xResultSet->beforeFirst(); + xResultSet->next(); + CPPUNIT_ASSERT_EQUAL(1, xResultSet->getRow()); + xResultSet->first(); + CPPUNIT_ASSERT_EQUAL(1, xResultSet->getRow()); + + // Now previous should put the cursor to before-first position, but it + // should return with false. + successPrevious = xResultSet->previous(); + CPPUNIT_ASSERT(!successPrevious); + CPPUNIT_ASSERT_EQUAL(0, xResultSet->getRow()); + + nUpdateCount = xStatement->executeUpdate("DROP TABLE myTestTable"); + CPPUNIT_ASSERT_EQUAL(0, nUpdateCount); // it's a DDL statement +} + +void MysqlTestDriver::testMultipleResultsets() +{ + Reference xConnection = m_xDriver->connect(m_sUrl, m_infos); + CPPUNIT_ASSERT(xConnection.is()); + Reference xStatement = xConnection->createStatement(); + CPPUNIT_ASSERT(xStatement.is()); + // create two tables + xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); + xStatement->executeUpdate("DROP TABLE IF EXISTS otherTable"); + xStatement->executeUpdate("CREATE TABLE myTestTable (id INTEGER PRIMARY KEY)"); + xStatement->executeUpdate("INSERT INTO myTestTable VALUES (1)"); + xStatement->executeUpdate("CREATE TABLE otherTable (id INTEGER PRIMARY KEY)"); + xStatement->executeUpdate("INSERT INTO otherTable VALUES (2)"); + + // create first result set + Reference xResultSet = xStatement->executeQuery("SELECT id from myTestTable"); + CPPUNIT_ASSERT_MESSAGE("result set cannot be instantiated after query", xResultSet.is()); + // use it + xResultSet->next(); + Reference xRowFirst(xResultSet, UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(1l, xRowFirst->getLong(1)); + // create second result set + Reference xResultSet2 = xStatement->executeQuery("SELECT id from otherTable"); + // use second result set + xResultSet2->next(); + Reference xRowSecond(xResultSet2, UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(2l, xRowSecond->getLong(1)); + // now use the first result set again +#if 0 + // FIXME this was broken by 86c86719782243275b65f1f7f2cfdcc0e56c8cd4 adding closeResultSet() in execute() + CPPUNIT_ASSERT_EQUAL(1l, xRowFirst->getLong(1)); +#endif + + xStatement->executeUpdate("DROP TABLE myTestTable"); + xStatement->executeUpdate("DROP TABLE otherTable"); +} + +void MysqlTestDriver::testDBMetaData() +{ + Reference xConnection = m_xDriver->connect(m_sUrl, m_infos); + if (!xConnection.is()) + CPPUNIT_ASSERT_MESSAGE("cannot connect to data source!", xConnection.is()); + uno::Reference xStatement = xConnection->createStatement(); + CPPUNIT_ASSERT(xStatement.is()); + xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); + + xStatement->executeUpdate( + "CREATE TABLE myTestTable (id INTEGER PRIMARY KEY, name VARCHAR(20))"); + Reference xPrepared + = xConnection->prepareStatement(OUString{ "INSERT INTO myTestTable VALUES (?, ?)" }); + Reference xParams(xPrepared, UNO_QUERY); + constexpr int ROW_COUNT = 3; + for (int i = 0; i < ROW_COUNT; ++i) + { + xParams->setLong(1, i); + xParams->setString(2, "lorem"); + xPrepared->executeUpdate(); + } + + Reference xResultSet = xStatement->executeQuery("SELECT * from myTestTable"); + Reference xMetaDataSupplier(xResultSet, UNO_QUERY); + Reference xMetaData = xMetaDataSupplier->getMetaData(); + CPPUNIT_ASSERT_EQUAL(OUString{ "id" }, xMetaData->getColumnName(1)); + CPPUNIT_ASSERT_EQUAL(OUString{ "name" }, xMetaData->getColumnName(2)); + CPPUNIT_ASSERT(!xMetaData->isAutoIncrement(1)); + CPPUNIT_ASSERT(!xMetaData->isCaseSensitive(2)); // default collation should be case insensitive + xResultSet->next(); // use it + // test that meta data is usable even after fetching result set + CPPUNIT_ASSERT_EQUAL(OUString{ "name" }, xMetaData->getColumnName(2)); + CPPUNIT_ASSERT_THROW_MESSAGE("exception expected when indexing out of range", + xMetaData->getColumnName(3), sdbc::SQLException); + xStatement->executeUpdate("DROP TABLE myTestTable"); +} + +void MysqlTestDriver::testTimestampField() +{ + Reference xConnection = m_xDriver->connect(m_sUrl, m_infos); + if (!xConnection.is()) + CPPUNIT_ASSERT_MESSAGE("cannot connect to data source!", xConnection.is()); + uno::Reference xStatement = xConnection->createStatement(); + CPPUNIT_ASSERT(xStatement.is()); + xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); + + xStatement->executeUpdate( + "CREATE TABLE myTestTable (id INTEGER PRIMARY KEY, mytimestamp timestamp)"); + xStatement->executeUpdate("INSERT INTO myTestTable VALUES (1, '2008-02-16 20:15:03')"); + + // now let's query + Reference xResultSet + = xStatement->executeQuery("SELECT mytimestamp from myTestTable"); + + xResultSet->next(); // use it + Reference xRow(xResultSet, UNO_QUERY); + CPPUNIT_ASSERT_MESSAGE("cannot extract row from result set!", xRow.is()); + util::DateTime dt = xRow->getTimestamp(1); + CPPUNIT_ASSERT_EQUAL(static_cast(2008), dt.Year); + CPPUNIT_ASSERT_EQUAL(static_cast(2), dt.Month); + CPPUNIT_ASSERT_EQUAL(static_cast(16), dt.Day); + + CPPUNIT_ASSERT_EQUAL(static_cast(20), dt.Hours); + CPPUNIT_ASSERT_EQUAL(static_cast(15), dt.Minutes); + CPPUNIT_ASSERT_EQUAL(static_cast(3), dt.Seconds); + + xStatement->executeUpdate("DROP TABLE myTestTable"); +} + +/** + * Test getting value from a decimal type column from a result set of a + * prepared statement, getting as a tinyint, string, short, int, long. + */ +void MysqlTestDriver::testNumericConversionPrepared() +{ + Reference xConnection = m_xDriver->connect(m_sUrl, m_infos); + if (!xConnection.is()) + CPPUNIT_ASSERT_MESSAGE("cannot connect to data source!", xConnection.is()); + uno::Reference xStatement = xConnection->createStatement(); + CPPUNIT_ASSERT(xStatement.is()); + xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); + + xStatement->executeUpdate("CREATE TABLE myTestTable (myDecimal DECIMAL(4,2))"); + xStatement->executeUpdate("INSERT INTO myTestTable VALUES (11.22)"); + Reference xPrepared + = xConnection->prepareStatement("SELECT * from myTestTable"); + Reference xResultSet = xPrepared->executeQuery(); + xResultSet->next(); // use it + Reference xRow(xResultSet, UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("11.22"), xRow->getString(1)); + // converting to integer types results in rounding down the number + CPPUNIT_ASSERT_EQUAL(static_cast(11), xRow->getByte(1)); + CPPUNIT_ASSERT_EQUAL(static_cast(11), xRow->getShort(1)); + CPPUNIT_ASSERT_EQUAL(static_cast(11), xRow->getInt(1)); + CPPUNIT_ASSERT_EQUAL(static_cast(11), xRow->getLong(1)); + + xStatement->executeUpdate("DROP TABLE myTestTable"); +} + +/** + * Test cursor positioning method isAfterLast in case of using prepared + * statement. + */ +void MysqlTestDriver::testPreparedStmtIsAfterLast() +{ + Reference xConnection = m_xDriver->connect(m_sUrl, m_infos); + if (!xConnection.is()) + CPPUNIT_ASSERT_MESSAGE("cannot connect to data source!", xConnection.is()); + uno::Reference xStatement = xConnection->createStatement(); + CPPUNIT_ASSERT(xStatement.is()); + xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); + + // create test table + xStatement->executeUpdate("CREATE TABLE myTestTable (id INTEGER PRIMARY KEY)"); + Reference xPrepared + = xConnection->prepareStatement(OUString{ "INSERT INTO myTestTable VALUES (?)" }); + Reference xParams(xPrepared, UNO_QUERY); + constexpr int ROW_COUNT = 6; + for (int i = 0; i < ROW_COUNT; ++i) + { + xParams->setShort(1, i); + xPrepared->executeUpdate(); + } + + // query test table + xPrepared = xConnection->prepareStatement("SELECT id from myTestTable where id = 3"); + Reference xResultSet = xPrepared->executeQuery(); + + // There should be exactly one row, therefore IsAfterLast is false at first. + xResultSet->next(); + CPPUNIT_ASSERT(!xResultSet->isAfterLast()); + + // attempt to fetch more data + bool hasData = xResultSet->next(); + CPPUNIT_ASSERT(!hasData); // now we are on "AfterLast" + CPPUNIT_ASSERT(xResultSet->isAfterLast()); + xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); +} + +void MysqlTestDriver::testGetStringFromBloColumnb() +{ + Reference xConnection = m_xDriver->connect(m_sUrl, m_infos); + if (!xConnection.is()) + CPPUNIT_ASSERT_MESSAGE("cannot connect to data source!", xConnection.is()); + uno::Reference xStatement = xConnection->createStatement(); + CPPUNIT_ASSERT(xStatement.is()); + xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); + + // create test table + xStatement->executeUpdate("CREATE TABLE myTestTable (id INTEGER PRIMARY KEY, tinytexty " + "TINYTEXT, texty TEXT, mediumTexty MEDIUMTEXT, longtexty LONGTEXT)"); + Reference xPrepared = xConnection->prepareStatement( + OUString{ "INSERT INTO myTestTable VALUES (?, ?, ?, ?, ?)" }); + Reference xParams(xPrepared, UNO_QUERY); + constexpr int ROW_COUNT = 6; + for (int i = 0; i < ROW_COUNT; ++i) + { + xParams->setShort(1, i); + xParams->setString(2, OUString::number(i)); + xParams->setString(3, OUString::number(i)); + xParams->setString(4, OUString::number(i)); + xParams->setString(5, OUString::number(i)); + xPrepared->executeUpdate(); + } + + // query test table + xPrepared = xConnection->prepareStatement( + "SELECT tinytexty, texty, mediumtexty, longtexty from myTestTable where texty LIKE '3'"); + Reference xResultSet = xPrepared->executeQuery(); + xResultSet->next(); + Reference xRow(xResultSet, UNO_QUERY); + + // all the textual blob types should be able to be queried via getString(). + CPPUNIT_ASSERT_EQUAL(OUString("3"), xRow->getString(1)); + CPPUNIT_ASSERT_EQUAL(OUString("3"), xRow->getString(2)); + CPPUNIT_ASSERT_EQUAL(OUString("3"), xRow->getString(3)); + CPPUNIT_ASSERT_EQUAL(OUString("3"), xRow->getString(4)); + + xStatement->executeUpdate("DROP TABLE IF EXISTS myTestTable"); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(MysqlTestDriver); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/qa/connectivity/resource/sharedresources_test.cxx b/connectivity/qa/connectivity/resource/sharedresources_test.cxx new file mode 100644 index 000000000..a6bf22fba --- /dev/null +++ b/connectivity/qa/connectivity/resource/sharedresources_test.cxx @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include + +#include +#include + +#include +#include + +using namespace css; + +namespace connectivity_test +{ +#define TEST_SOURCE_STRING NC_("TEST_SOURCE_STRING", "UnitTest") +#define TEST_SOURCE_ONE_SUBSTITUTION NC_("TEST_SOURCE_ONE_SUBSTITUTION", "One substitution $sub$") +#define TEST_SOURCE_TWO_SUBSTITUTION \ + NC_("TEST_SOURCE_TWO_SUBSTITUTION", "Two substitution $sub0$ $sub1$") +#define TEST_SOURCE_THREE_SUBSTITUTION \ + NC_("TEST_SOURCE_THREE_SUBSTITUTION", "Three substitution $sub0$ $sub1$ $sub2$") + +class SharedResourcesTest : public test::BootstrapFixture +{ +public: + SharedResourcesTest(); + + void testGetSourceString(); + void testGetSourceStringWithSubstitutionOne(); + void testGetSourceStringWithSubstitutionTwo(); + void testGetSourceStringWithSubstitutionThree(); + void testGetSourceStringWithSubstitutionVector(); + + CPPUNIT_TEST_SUITE(SharedResourcesTest); + + CPPUNIT_TEST(testGetSourceString); + CPPUNIT_TEST(testGetSourceStringWithSubstitutionOne); + CPPUNIT_TEST(testGetSourceStringWithSubstitutionTwo); + CPPUNIT_TEST(testGetSourceStringWithSubstitutionThree); + CPPUNIT_TEST(testGetSourceStringWithSubstitutionVector); + + CPPUNIT_TEST_SUITE_END(); + +private: + ::connectivity::SharedResources m_aResource; +}; + +SharedResourcesTest::SharedResourcesTest() + : test::BootstrapFixture(false, false) +{ +} + +void SharedResourcesTest::testGetSourceString() +{ + CPPUNIT_ASSERT_EQUAL(OUString("UnitTest"), m_aResource.getResourceString(TEST_SOURCE_STRING)); +} + +void SharedResourcesTest::testGetSourceStringWithSubstitutionOne() +{ + CPPUNIT_ASSERT_EQUAL(OUString("One substitution UnitTest"), + m_aResource.getResourceStringWithSubstitution(TEST_SOURCE_ONE_SUBSTITUTION, + "$sub$", "UnitTest")); +} + +void SharedResourcesTest::testGetSourceStringWithSubstitutionTwo() +{ + CPPUNIT_ASSERT_EQUAL(OUString("Two substitution UnitTest1 UnitTest2"), + m_aResource.getResourceStringWithSubstitution(TEST_SOURCE_TWO_SUBSTITUTION, + "$sub0$", "UnitTest1", + "$sub1$", "UnitTest2")); +} + +void SharedResourcesTest::testGetSourceStringWithSubstitutionThree() +{ + CPPUNIT_ASSERT_EQUAL(OUString("Three substitution UnitTest1 UnitTest2 UnitTest3"), + m_aResource.getResourceStringWithSubstitution( + TEST_SOURCE_THREE_SUBSTITUTION, "$sub0$", "UnitTest1", "$sub1$", + "UnitTest2", "$sub2$", "UnitTest3")); +} + +void SharedResourcesTest::testGetSourceStringWithSubstitutionVector() +{ + std::vector> aStringToSubstitutes; + aStringToSubstitutes.push_back(std::pair("$sub0$", "vector0")); + aStringToSubstitutes.push_back(std::pair("$sub1$", "vector1")); + aStringToSubstitutes.push_back(std::pair("$sub2$", "vector2")); + + CPPUNIT_ASSERT_EQUAL(OUString("Three substitution vector0 vector1 vector2"), + m_aResource.getResourceStringWithSubstitution( + TEST_SOURCE_THREE_SUBSTITUTION, aStringToSubstitutes)); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(SharedResourcesTest); + +} // namespace connectivity_test + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/connectivity/qa/connectivity/tools/AbstractDatabase.java b/connectivity/qa/connectivity/tools/AbstractDatabase.java new file mode 100644 index 000000000..601b36e23 --- /dev/null +++ b/connectivity/qa/connectivity/tools/AbstractDatabase.java @@ -0,0 +1,208 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +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; +import static org.junit.Assert.*; + +public abstract class AbstractDatabase implements DatabaseAccess +{ + 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(); + delete(); + } + + protected void delete() {} + + /** 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 private 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_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 + { + // Cannot call close() here, as it accesses UNO objects (that may + // already have been finalized): + assertNull( + "missing call to connectivity.tools.AbstractDatabase.close", + m_connection); + assertNull( + "missing call to connectivity.tools.AbstractDatabase.close", + m_databaseDocument); + + delete(); + super.finalize(); + } + + // 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 + private Connection m_connection; +} diff --git a/connectivity/qa/connectivity/tools/CRMDatabase.java b/connectivity/qa/connectivity/tools/CRMDatabase.java new file mode 100644 index 000000000..3d3392628 --- /dev/null +++ b/connectivity/qa/connectivity/tools/CRMDatabase.java @@ -0,0 +1,277 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +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.application.XDatabaseDocumentUI; +import com.sun.star.sdbc.SQLException; +import com.sun.star.uno.UnoRuntime; +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 Connection m_connection; + + /** constructs the CRM database + */ + public CRMDatabase( XMultiServiceFactory _orb, boolean _withUI ) throws Exception + { + m_orb = _orb; + + m_database = new HsqlDatabase( m_orb ); + + 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 + */ + public CRMDatabase( XMultiServiceFactory _orb, final String _existingDocumentURL ) throws Exception + { + m_orb = _orb; + + m_database = new HsqlDatabase( m_orb, _existingDocumentURL ); + 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 IOException + { + XDatabaseDocumentUI ui = getDocumentUI(); + if ( ui != null ) + ui.closeSubComponents(); + m_database.store(); + m_database.closeAndDelete(); + } + + + private 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','Preferred') " ); + 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/CsvDatabase.java b/connectivity/qa/connectivity/tools/CsvDatabase.java new file mode 100644 index 000000000..abb016c90 --- /dev/null +++ b/connectivity/qa/connectivity/tools/CsvDatabase.java @@ -0,0 +1,31 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package connectivity.tools; + +import com.sun.star.lang.XMultiServiceFactory; + +public class CsvDatabase extends FlatFileDatabase +{ + + public CsvDatabase( final XMultiServiceFactory i_orb ) throws Exception + { + super( i_orb, "flat" ); + } + +} diff --git a/connectivity/qa/connectivity/tools/DataSource.java b/connectivity/qa/connectivity/tools/DataSource.java new file mode 100644 index 000000000..844c4488f --- /dev/null +++ b/connectivity/qa/connectivity/tools/DataSource.java @@ -0,0 +1,150 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +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 XDataSource m_dataSource; + + public DataSource(final XMultiServiceFactory _orb, final String _registeredName) throws Exception + { + 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 XDataSource _dataSource) + { + m_dataSource = _dataSource; + } + + final public XDataSource getXDataSource() + { + return m_dataSource; + } + + /** + * retrieves the data source's settings + */ + public XPropertySet geSettings() + { + return UnoRuntime.queryInterface( XPropertySet.class, impl_getPropertyValue( "Settings" ) ); + } + + /** 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 + */ + private XNameAccess getQueryDefinitions() + { + final XQueryDefinitionsSupplier suppQueries = UnoRuntime.queryInterface( + XQueryDefinitionsSupplier.class, m_dataSource); + return suppQueries.getQueryDefinitions(); + } + + /** + * retrieves a property value from the data source + * @param i_propertyName + * the name of the property whose value is to be returned. + */ + private Object impl_getPropertyValue( final String i_propertyName ) + { + Object propertyValue = null; + try + { + final XPropertySet dataSourceProps = UnoRuntime.queryInterface( XPropertySet.class, m_dataSource ); + propertyValue = dataSourceProps.getPropertyValue( i_propertyName ); + } + catch (Exception ex) + { + Logger.getLogger(DataSource.class.getName()).log(Level.SEVERE, null, ex); + } + return propertyValue; + } + + /** returns the name of the data source + * + * If a data source is registered at the database context, the name is the registration + * name. Otherwise, it's 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() + { + return (String)impl_getPropertyValue( "Name" ); + } +} diff --git a/connectivity/qa/connectivity/tools/DatabaseAccess.java b/connectivity/qa/connectivity/tools/DatabaseAccess.java new file mode 100644 index 000000000..347faa46e --- /dev/null +++ b/connectivity/qa/connectivity/tools/DatabaseAccess.java @@ -0,0 +1,50 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +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; + +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 100644 index 000000000..9a1dc8448 --- /dev/null +++ b/connectivity/qa/connectivity/tools/DbaseDatabase.java @@ -0,0 +1,32 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package connectivity.tools; + +import com.sun.star.lang.XMultiServiceFactory; + +public class DbaseDatabase extends FlatFileDatabase +{ + + public DbaseDatabase( final XMultiServiceFactory i_orb ) throws Exception + { + super( i_orb, "dbase" ); + } + + +} diff --git a/connectivity/qa/connectivity/tools/FlatFileDatabase.java b/connectivity/qa/connectivity/tools/FlatFileDatabase.java new file mode 100644 index 000000000..5351ba953 --- /dev/null +++ b/connectivity/qa/connectivity/tools/FlatFileDatabase.java @@ -0,0 +1,74 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +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.uno.UnoRuntime; + +import helper.URLHelper; +import java.io.File; + +class FlatFileDatabase extends AbstractDatabase +{ + + protected FlatFileDatabase( final XMultiServiceFactory i_orb, final String i_urlSubScheme ) throws Exception + { + super(i_orb); + m_urlSubScheme = i_urlSubScheme; + createDBDocument(); + } + + + /** + * returns a {@link File} which represents the folder where the database's table files reside. + */ + public File getTableFileLocation() + { + return m_tableFileLocation; + } + + /** creates an empty database document in a temporary location + */ + private void createDBDocument() throws Exception + { + final File documentFile = File.createTempFile( m_urlSubScheme, ".odb" ); + if ( documentFile.exists() ) + documentFile.delete(); + m_tableFileLocation = new File(documentFile.getParent() + File.separator + documentFile.getName().replace(".odb", "") + File.separator ); + m_tableFileLocation.mkdir(); + m_databaseDocumentFile = URLHelper.getFileURLFromSystemPath(documentFile); + final String path = URLHelper.getFileURLFromSystemPath( m_tableFileLocation.getPath() ); + + m_databaseDocument = UnoRuntime.queryInterface( XOfficeDatabaseDocument.class, + m_orb.createInstance("com.sun.star.sdb.OfficeDatabaseDocument")); + m_dataSource = new DataSource(m_databaseDocument.getDataSource()); + + final XPropertySet dsProperties = UnoRuntime.queryInterface(XPropertySet.class, m_databaseDocument.getDataSource()); + dsProperties.setPropertyValue("URL", "sdbc:" + m_urlSubScheme + ":" + path); + + final XStorable storable = UnoRuntime.queryInterface( XStorable.class, m_databaseDocument ); + storable.storeAsURL( m_databaseDocumentFile, new PropertyValue[] { } ); + } + + private final String m_urlSubScheme; + private File m_tableFileLocation = null; +} diff --git a/connectivity/qa/connectivity/tools/HsqlColumnDescriptor.java b/connectivity/qa/connectivity/tools/HsqlColumnDescriptor.java new file mode 100644 index 000000000..12330ff70 --- /dev/null +++ b/connectivity/qa/connectivity/tools/HsqlColumnDescriptor.java @@ -0,0 +1,75 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package connectivity.tools; + +/** is a very simply and rudimentary descriptor of table columns, for creating HSQLDB tables + */ +public class HsqlColumnDescriptor +{ + private final String Name; + private final String TypeName; + private final boolean Required; + private final boolean PrimaryKey; + private final String ForeignTable; + private final 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 static final int REQUIRED = 1; + /// determines that a column is part of the primary key of its table + public static final 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 000000000..0d2ab4af9 --- /dev/null +++ b/connectivity/qa/connectivity/tools/HsqlDatabase.java @@ -0,0 +1,202 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +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.io.File; +import java.util.HashMap; +import java.util.Map; +import org.junit.Assert; + +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 + { + Assert.assertNull(m_documentFile); + m_documentFile = File.createTempFile("testdb", ".odb"); + if ( m_documentFile.exists() ) + m_documentFile.delete(); + m_databaseDocumentFile = URLHelper.getFileURLFromSystemPath(m_documentFile); + + m_databaseDocument = UnoRuntime.queryInterface( + XOfficeDatabaseDocument.class, m_orb.createInstance("com.sun.star.sdb.OfficeDatabaseDocument")); + m_dataSource = new DataSource(m_databaseDocument.getDataSource()); + + final XPropertySet dsProperties = UnoRuntime.queryInterface(XPropertySet.class, m_databaseDocument.getDataSource()); + dsProperties.setPropertyValue("URL", "sdbc:embedded:hsqldb"); + + final XStorable storable = UnoRuntime.queryInterface(XStorable.class, m_databaseDocument); + storable.storeAsURL( m_databaseDocumentFile, new PropertyValue[] + { new PropertyValue( "PickListEntry", 0, false, PropertyState.DIRECT_VALUE ) + } ); + } + + @Override protected final void delete() { + if (m_documentFile != null) { + boolean ok = m_documentFile.delete(); + //TODO: fails on Windows: Assert.assertTrue("delete " + m_documentFile.getPath(), ok); + } + } + + /** drops the table with a given name + + @param _name + the name of the table to drop + */ + private void dropTable(final String _name) throws SQLException + { + final StringBuffer dropStatement = new StringBuffer("DROP TABLE \""); + dropStatement.append(_name); + dropStatement.append("\" IF EXISTS"); + executeSQL(dropStatement.toString()); + } + + public void createTable(final HsqlTableDescriptor _tableDesc, final boolean _dropIfExists) throws SQLException + { + if (_dropIfExists) + { + dropTable(_tableDesc.getName()); + } + 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("\"").append(columns[i].getName()); + createStatement.append("\" ").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) ? foreignKeys.get(foreignTable) : ""; + if (foreignKeysForTable.length() > 0) + { + foreignKeysForTable += ", "; + } + foreignKeysForTable += "\"" + columns[i].getName() + "\""; + foreignKeys.put(foreignTable, foreignKeysForTable); + + final StringBuffer foreignKeyRefsForTable = new StringBuffer(foreignKeyRefs.containsKey(foreignTable) ? foreignKeyRefs.get(foreignTable) : ""); + if (foreignKeyRefsForTable.length() > 0) + { + foreignKeyRefsForTable.append(", "); + } + foreignKeyRefsForTable.append("\"").append(columns[i].getForeignColumn()).append("\""); + foreignKeyRefs.put(foreignTable, foreignKeyRefsForTable.toString()); + } + } + + if (primaryKeyList.length() > 0) + { + createStatement.append(", PRIMARY KEY ("); + createStatement.append(primaryKeyList); + createStatement.append(')'); + } + + for (Map.Entry foreignKey : foreignKeys.entrySet()) + { + final String foreignTable = foreignKey.getKey(); + + createStatement.append(", FOREIGN KEY ("); + createStatement.append(foreignKey.getValue()); + createStatement.append(") REFERENCES \""); + createStatement.append(foreignTable); + createStatement.append("\"("); + createStatement.append(foreignKeyRefs.get(foreignTable)); + createStatement.append(')'); + } + + createStatement.append(')'); + + 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); + } + + private File m_documentFile; +} diff --git a/connectivity/qa/connectivity/tools/HsqlTableDescriptor.java b/connectivity/qa/connectivity/tools/HsqlTableDescriptor.java new file mode 100644 index 000000000..626f62eb8 --- /dev/null +++ b/connectivity/qa/connectivity/tools/HsqlTableDescriptor.java @@ -0,0 +1,93 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +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 final String m_name; + private final 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", Integer.valueOf( 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 000000000..fc3cba382 --- /dev/null +++ b/connectivity/qa/connectivity/tools/QueryDefinition.java @@ -0,0 +1,49 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package connectivity.tools; + +import com.sun.star.beans.UnknownPropertyException; +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.WrappedTargetException; + +public class QueryDefinition +{ + private final 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 getPropertyValue( "Command" ) call + */ + public final String getCommand() throws WrappedTargetException + { + String command = null; + try { + command = (String)m_queryDef.getPropertyValue( "Command" ); + } + catch (UnknownPropertyException e) { } + + return command; + } + +} diff --git a/connectivity/qa/connectivity/tools/RowSet.java b/connectivity/qa/connectivity/tools/RowSet.java new file mode 100644 index 000000000..22b52156f --- /dev/null +++ b/connectivity/qa/connectivity/tools/RowSet.java @@ -0,0 +1,288 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +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.XComponent; +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 XRowSet m_rowSet; + private XRow m_row; + + public RowSet( XMultiServiceFactory _orb, String _dataSource, int _commandType, String _command ) + { + try + { + XPropertySet rowSetProps = UnoRuntime.queryInterface( XPropertySet.class, _orb.createInstance( "com.sun.star.sdb.RowSet" ) ); + rowSetProps.setPropertyValue( "DataSourceName", _dataSource ); + rowSetProps.setPropertyValue( "CommandType", Integer.valueOf( _commandType ) ); + rowSetProps.setPropertyValue( "Command", _command ); + + m_rowSet = UnoRuntime.queryInterface( XRowSet.class, rowSetProps ); + m_row = UnoRuntime.queryInterface( XRow.class, rowSetProps ); + } + catch ( Exception e ) + { + throw new java.lang.RuntimeException(e); + } + } + + // misc + public int getColumnCount() + { + XColumnsSupplier suppCols = UnoRuntime.queryInterface( + XColumnsSupplier.class, m_rowSet ); + XIndexAccess columns = 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); + } + + public void dispose() + { + if ( m_rowSet == null ) + return; + XComponent rowSetComp = UnoRuntime.queryInterface( XComponent.class, m_rowSet ); + rowSetComp.dispose(); + } +} diff --git a/connectivity/qa/connectivity/tools/sdb/Connection.java b/connectivity/qa/connectivity/tools/sdb/Connection.java new file mode 100644 index 000000000..d713de379 --- /dev/null +++ b/connectivity/qa/connectivity/tools/sdb/Connection.java @@ -0,0 +1,80 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +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.XPreparedStatement; +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 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 + void close() throws SQLException + { + m_connection.close(); + } +} diff --git a/connectivity/qa/scenarios.sce b/connectivity/qa/scenarios.sce new file mode 100644 index 000000000..4f366945e --- /dev/null +++ b/connectivity/qa/scenarios.sce @@ -0,0 +1,21 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# +-o complex.connectivity.DBaseDriverTest +-o complex.connectivity.HsqlDriverTest +#-o complex.connectivity.JdbcLongVarCharTest +-o complex.connectivity.FlatFileAccess diff --git a/connectivity/registry/README b/connectivity/registry/README new file mode 100644 index 000000000..18842b7b0 --- /dev/null +++ b/connectivity/registry/README @@ -0,0 +1,25 @@ +xcu files are made from several sections, the main ones are: Properties and Features + +Property: actual setting with its underlying type and its default value + +Feature: a boolean that says "let the user change that setting in the Advanced Settings UI" + +This is checked by using officecfg/registry/schema/org/openoffice/Office/DataAccess/Drivers.xcs +and configmgr mechanism +There are two kinds of properties named "Value": +- first one is in "Property" groups and has a static oor:type="any" (can take on boolean, int and other types of values) +- second one is in "Feature" groups and has a static oor:type="boolean" so can take on only boolean values. + +Each node in Feature section must have an equivalent in Property section +Most of the time the node name of both sections should be equal, +however there are 5 known exceptions (more?): +- "UseBracketedOuterJoinSyntax" feature => "EnableOuterJoinEscape" property +- "UseDOSLineEnds" feature => "PreferDosLikeLineEnds" property +- "UseSQL92NamingConstraints" feature => "EnableSQL92Check" property +- "AppendTableAliasInSelect" feature => "AppendTableAliasName" property +- "UseKeywordAsBeforeAlias" feature => "GenerateASBeforeCorrelationName" + +See dbaccess/source/ui/dlg/DbAdminImpl.cxx, ODbDataSourceAdministrationHelper constructor, eg: +m_aIndirectPropTranslator.emplace( , ) +and dbaccess/source/ui/misc/dsmeta.cxx, lcl_getFeatureMappings() function, eg: +{ , } \ No newline at end of file diff --git a/connectivity/registry/ado/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/ado/org/openoffice/Office/DataAccess/Drivers.xcu new file mode 100644 index 000000000..288c23e2e --- /dev/null +++ b/connectivity/registry/ado/org/openoffice/Office/DataAccess/Drivers.xcu @@ -0,0 +1,369 @@ + + + + + + + com.sun.star.comp.sdbc.ado.ODriver + + + ADO + + + + + + + + + + true + + + + + false + + + + + + false + + + + + + false + + + + + false + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + 0 + + + + + true + + + + + true + + + + + + + + false + + + + + + + true + + + + + true + + + + + + true + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + UserPassword + + + + + true + + + + + + + com.sun.star.comp.sdbc.ado.ODriver + + + Microsoft Access + + + + + + + + + + 3 + + + + + false + + + + + Column(2) = 16,Column(3) = 1 + + + + + false + + + + + + false + + + + + true + + + + + false + + + + + true + + + + + true + + + + + + + true + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + false + + + + + true + + + + + true + + + + + true + + + + + application/msaccess + + + + + mdb + + + + + true + + + + + + + sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=* + + + Microsoft Access 2007 + + + + + + + + + + + diff --git a/connectivity/registry/calc/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/calc/org/openoffice/Office/DataAccess/Drivers.xcu new file mode 100644 index 000000000..8fe901b0f --- /dev/null +++ b/connectivity/registry/calc/org/openoffice/Office/DataAccess/Drivers.xcu @@ -0,0 +1,61 @@ + + + + + + + com.sun.star.comp.sdbc.calc.ODriver + + + Spreadsheet + + + + + true + + + + + + + true + + + + + + + true + + + + + true + + + + + application/vnd.oasis.opendocument.spreadsheet + + + + + + diff --git a/connectivity/registry/dbase/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/dbase/org/openoffice/Office/DataAccess/Drivers.xcu new file mode 100644 index 000000000..2de29af9d --- /dev/null +++ b/connectivity/registry/dbase/org/openoffice/Office/DataAccess/Drivers.xcu @@ -0,0 +1,101 @@ + + + + + + + com.sun.star.comp.sdbc.dbase.ODriver + + + dBASE + + + + + + + + + + false + + + + + false + + + + + false + + + + + false + + + + + true + + + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + true + + + + + application/dbase + + + + + + diff --git a/connectivity/registry/evoab2/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/evoab2/org/openoffice/Office/DataAccess/Drivers.xcu new file mode 100644 index 000000000..152d29e8f --- /dev/null +++ b/connectivity/registry/evoab2/org/openoffice/Office/DataAccess/Drivers.xcu @@ -0,0 +1,88 @@ + + + + + + + com.sun.star.comp.sdbc.evoab.OEvoabDriver + + + Evolution Local + + + + + true + + + + + + + true + + + + + + + com.sun.star.comp.sdbc.evoab.OEvoabDriver + + + Evolution LDAP + + + + + true + + + + + + + true + + + + + + + com.sun.star.comp.sdbc.evoab.OEvoabDriver + + + Groupwise + + + + + true + + + + + + + true + + + + + + diff --git a/connectivity/registry/firebird/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/firebird/org/openoffice/Office/DataAccess/Drivers.xcu new file mode 100644 index 000000000..586264183 --- /dev/null +++ b/connectivity/registry/firebird/org/openoffice/Office/DataAccess/Drivers.xcu @@ -0,0 +1,130 @@ + + + + + + + + com.sun.star.comp.sdbc.firebird.Driver + + + Firebird Embedded + + + + + + false + + + + + + false + + + + + false + + + + + true + + + + + 2 + + + + + + + + + + + + com.sun.star.comp.sdbc.firebird.Driver + + + Firebird File + + + + + + false + + + + + + false + + + + + false + + + + + true + + + + + + + + + true + + + + + true + + + + + + diff --git a/connectivity/registry/flat/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/flat/org/openoffice/Office/DataAccess/Drivers.xcu new file mode 100644 index 000000000..af1e37962 --- /dev/null +++ b/connectivity/registry/flat/org/openoffice/Office/DataAccess/Drivers.xcu @@ -0,0 +1,116 @@ + + + + + + + com.sun.star.comp.sdbc.flat.ODriver + + + Text + + + + + + + + + + + + + + + true + + + + + , + + + + + " + + + + + . + + + + + + + + + + false + + + + + 100 + + + + + true + + + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + text/csv + + + + + + diff --git a/connectivity/registry/hsqldb/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/hsqldb/org/openoffice/Office/DataAccess/Drivers.xcu new file mode 100644 index 000000000..c224b51b1 --- /dev/null +++ b/connectivity/registry/hsqldb/org/openoffice/Office/DataAccess/Drivers.xcu @@ -0,0 +1,103 @@ + + + + + + + com.sun.star.sdbcx.comp.hsqldb.Driver + + + HSQLDB Embedded + + + + + false + + + + + true + + + + + true + + + + + true + + + + + + true + + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + true + + + + + + + true + + + + + true + + + + + true + + + + + + diff --git a/connectivity/registry/jdbc/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/jdbc/org/openoffice/Office/DataAccess/Drivers.xcu new file mode 100644 index 000000000..698393b10 --- /dev/null +++ b/connectivity/registry/jdbc/org/openoffice/Office/DataAccess/Drivers.xcu @@ -0,0 +1,297 @@ + + + + + + + com.sun.star.comp.sdbc.JDBCDriver + + + JDBC + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + + true + + + + + true + + + + + false + + + + + + false + + + + + + false + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + false + + + + + 0 + + + + + true + + + + + true + + + + + + + + false + + + + + + + true + + + + + true + + + + + + true + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + UserPassword + + + + + + + jdbc:* + + + Oracle JDBC + + + + + true + + + + + 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 + + + + + oracle.jdbc.driver.OracleDriver + + + + + false + + + + + + + true + + + + + + + UserPassword + + + + + + diff --git a/connectivity/registry/macab/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/macab/org/openoffice/Office/DataAccess/Drivers.xcu new file mode 100644 index 000000000..3d9d3121d --- /dev/null +++ b/connectivity/registry/macab/org/openoffice/Office/DataAccess/Drivers.xcu @@ -0,0 +1,44 @@ + + + + + + + com.sun.star.comp.sdbc.macab.Driver + + + Mac OS X Address Book + + + + + true + + + + + + + true + + + + + + diff --git a/connectivity/registry/mork/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/mork/org/openoffice/Office/DataAccess/Drivers.xcu new file mode 100644 index 000000000..8e559cdf1 --- /dev/null +++ b/connectivity/registry/mork/org/openoffice/Office/DataAccess/Drivers.xcu @@ -0,0 +1,51 @@ + + + + + + + com.sun.star.comp.sdbc.MorkDriver + + + Thunderbird Address Book + + + + + true + + + + + + + true + + + + + + + true + + + + + + diff --git a/connectivity/registry/mysql_jdbc/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/mysql_jdbc/org/openoffice/Office/DataAccess/Drivers.xcu new file mode 100644 index 000000000..a4e95b04f --- /dev/null +++ b/connectivity/registry/mysql_jdbc/org/openoffice/Office/DataAccess/Drivers.xcu @@ -0,0 +1,264 @@ + + + + + + + org.openoffice.comp.drivers.MySQL.Driver + + + MySQL (JDBC) + + + + + + + + + + com.mysql.jdbc.Driver + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + UserPassword + + + + + true + + + + + + + org.openoffice.comp.drivers.MySQL.Driver + + + MySQL (ODBC) + + + + + + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + UserPassword + + + + + + + org.openoffice.comp.drivers.MySQL.Driver + + + MySQL (Native) + + + + + + + + + + + + + + + + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + UserPassword + + + + + true + + + + + + diff --git a/connectivity/registry/mysqlc/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/mysqlc/org/openoffice/Office/DataAccess/Drivers.xcu new file mode 100644 index 000000000..1b83115dc --- /dev/null +++ b/connectivity/registry/mysqlc/org/openoffice/Office/DataAccess/Drivers.xcu @@ -0,0 +1,128 @@ + + + + + + + com.sun.star.comp.sdbc.mysqlc.MysqlCDriver + + + MySQL Connector + + + + + + + + + + + + + + + + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + 0 + + + + + true + + + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + UserPassword + + + + + + diff --git a/connectivity/registry/odbc/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/odbc/org/openoffice/Office/DataAccess/Drivers.xcu new file mode 100644 index 000000000..f2dbd91c8 --- /dev/null +++ b/connectivity/registry/odbc/org/openoffice/Office/DataAccess/Drivers.xcu @@ -0,0 +1,261 @@ + + + + + + + com.sun.star.comp.sdbc.ODBCDriver + + + ODBC + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + false + + + + + true + + + + + true + + + + + + false + + + + + + false + + + + + + false + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + false + + + + + 0 + + + + + true + + + + + true + + + + + + + + + false + + + + + + + true + + + + + true + + + + + + true + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + + + true + + + + + true + + + + + UserPassword + + + + + + diff --git a/connectivity/registry/postgresql/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/postgresql/org/openoffice/Office/DataAccess/Drivers.xcu new file mode 100644 index 000000000..63757e3ec --- /dev/null +++ b/connectivity/registry/postgresql/org/openoffice/Office/DataAccess/Drivers.xcu @@ -0,0 +1,94 @@ + + + + + + + org.openoffice.comp.connectivity.pq.Driver.noext + + + PostgreSQL + + + + + + false + + + + + + false + + + + + 2 + + + + + + + + + + + + + + + + + + + + + UserPassword + + + + + + + + + + diff --git a/connectivity/registry/writer/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/writer/org/openoffice/Office/DataAccess/Drivers.xcu new file mode 100644 index 000000000..a4624a6e8 --- /dev/null +++ b/connectivity/registry/writer/org/openoffice/Office/DataAccess/Drivers.xcu @@ -0,0 +1,51 @@ + + + + + + + com.sun.star.comp.sdbc.writer.ODriver + + + Writer Document + + + + + true + + + + + + + true + + + + + + + true + + + + + true + + + + + application/vnd.oasis.opendocument.text + + + + + + diff --git a/connectivity/source/commontools/AutoRetrievingBase.cxx b/connectivity/source/commontools/AutoRetrievingBase.cxx new file mode 100644 index 000000000..d1170fdd9 --- /dev/null +++ b/connectivity/source/commontools/AutoRetrievingBase.cxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +#include + +namespace connectivity +{ + OUString OAutoRetrievingBase::getTransformedGeneratedStatement(const OUString& _sInsertStatement) const + { + OSL_ENSURE( m_bAutoRetrievingEnabled,"Illegal call here. isAutoRetrievingEnabled is false!"); + OUString sStmt = _sInsertStatement.toAsciiUpperCase(); + if ( sStmt.startsWith("INSERT") ) + { + static const char sTable[] = "$table"; + const sal_Int32 nColumnIndex {m_sGeneratedValueStatement.indexOf("$column")}; + if ( nColumnIndex>=0 ) + { // we need a column + } + const sal_Int32 nTableIndex {m_sGeneratedValueStatement.indexOf(sTable)}; + if ( nTableIndex>=0 ) + { // we need a table name + sal_Int32 nIntoIndex = sStmt.indexOf("INTO ") + 5; + while (nIntoIndex +#include +#include +#include + +using namespace connectivity; +using namespace dbtools; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::uno; + +BlobHelper::BlobHelper(const css::uno::Sequence< sal_Int8 >& _val) : m_aValue(_val) +{ +} + +::sal_Int64 SAL_CALL BlobHelper::length( ) +{ + return m_aValue.getLength(); +} + +css::uno::Sequence< ::sal_Int8 > SAL_CALL BlobHelper::getBytes( ::sal_Int64 pos, ::sal_Int32 _length ) +{ + if ( sal_Int32(pos + _length) > m_aValue.getLength() ) + throw css::sdbc::SQLException(); + return css::uno::Sequence< ::sal_Int8 >(m_aValue.getConstArray() + sal_Int32(pos),_length); +} + +css::uno::Reference< css::io::XInputStream > SAL_CALL BlobHelper::getBinaryStream( ) +{ + return new ::comphelper::SequenceInputStream(m_aValue); +} + + +// The "return" after a call to throwFeatureNotImplementedSQLException() +// (which always throws) will be detected as unreachable when doing +// global inlining. + +SAL_WNOUNREACHABLE_CODE_PUSH + +::sal_Int64 SAL_CALL BlobHelper::position( const css::uno::Sequence< ::sal_Int8 >& /*pattern*/, ::sal_Int64 /*start*/ ) +{ + ::dbtools::throwFeatureNotImplementedSQLException( "XBlob::position", *this ); + return 0; +} + +::sal_Int64 SAL_CALL BlobHelper::positionOfBlob( const css::uno::Reference< css::sdbc::XBlob >& /*pattern*/, ::sal_Int64 /*start*/ ) +{ + ::dbtools::throwFeatureNotImplementedSQLException( "XBlob::positionOfBlob", *this ); + return 0; +} + +SAL_WNOUNREACHABLE_CODE_POP + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/CommonTools.cxx b/connectivity/source/commontools/CommonTools.cxx new file mode 100644 index 000000000..5c84bf6e6 --- /dev/null +++ b/connectivity/source/commontools/CommonTools.cxx @@ -0,0 +1,235 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +#include +#include +#include +#include +#if HAVE_FEATURE_JAVA +#include +#endif +#include +#include +#include +#include + +using namespace ::comphelper; +static 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 ::com::sun::star::java; + using namespace dbtools; + + const sal_Unicode CHAR_PLACE = '_'; + const sal_Unicode CHAR_WILD = '%'; + + 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 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 false; + else + pWild += pos; + else + break; + // WARNING/TODO: in certain circumstances it will run into + // the next 'case'! + [[fallthrough]]; + case CHAR_WILD: + while ( *pWild == CHAR_WILD ) + pWild++; + if ( *pWild == 0 ) + return 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 ); + } + +#if HAVE_FEATURE_JAVA + ::rtl::Reference< jvmaccess::VirtualMachine > getJavaVM(const Reference& _rxContext) + { + ::rtl::Reference< jvmaccess::VirtualMachine > aRet; + OSL_ENSURE(_rxContext.is(),"No XMultiServiceFactory a.v.!"); + if(!_rxContext.is()) + return aRet; + + try + { + Reference< XJavaVM > xVM = JavaVirtualMachine::create(_rxContext); + + Sequence processID(16); + rtl_getGlobalProcessId( reinterpret_cast(processID.getArray()) ); + processID.realloc(17); + processID[16] = 0; + + Any uaJVM = xVM->getJavaVM( processID ); + sal_Int64 nTemp; + if (!(uaJVM >>= nTemp)) { + throw Exception("cannot get result for getJavaVM", nullptr); // -5 + } + aRet = reinterpret_cast( + static_cast(nTemp)); + } + catch (Exception&) + { + TOOLS_WARN_EXCEPTION("connectivity.commontools", "getJavaVM failed:"); + } + + return aRet; + } + + bool existsJavaClassByName( const ::rtl::Reference< jvmaccess::VirtualMachine >& _pJVM,const OUString& _sClassName ) + { + bool bRet = false; + if ( _pJVM.is() ) + { + jvmaccess::VirtualMachine::AttachGuard aGuard(_pJVM); + JNIEnv* pEnv = aGuard.getEnvironment(); + if( pEnv ) + { + OString sClassName = OUStringToOString(_sClassName, RTL_TEXTENCODING_ASCII_US); + sClassName = sClassName.replace('.','/'); + jobject out = pEnv->FindClass(sClassName.getStr()); + bRet = out != nullptr; + pEnv->DeleteLocalRef( out ); + } + } + return bRet; + } +#endif +} + +namespace dbtools +{ + +static bool isCharOk(sal_Unicode c,const OUString& _rSpecials) +{ + + return ( ((c >= 97) && (c <= 122)) || ((c >= 65) && (c <= 90)) || ((c >= 48) && (c <= 57)) || + c == '_' || _rSpecials.indexOf(c) != -1); +} + + +bool isValidSQLName(const OUString& rName,const OUString& _rSpecials) +{ + // Test for correct naming (in SQL sense) + // This is important for table names for example + const sal_Unicode* pStr = rName.getStr(); + if (*pStr > 127 || rtl::isAsciiDigit(*pStr)) + return false; + + for (; *pStr; ++pStr ) + if(!isCharOk(*pStr,_rSpecials)) + return false; + + if ( !rName.isEmpty() + && ( (rName.toChar() == '_') + || ( (rName.toChar() >= '0') + && (rName.toChar() <= '9') + ) + ) + ) + return 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 true; +} + +// Creates a new name if necessary +OUString convertName2SQLName(const OUString& rName,const OUString& _rSpecials) +{ + if(isValidSQLName(rName,_rSpecials)) + return rName; + + const sal_Unicode* pStr = rName.getStr(); + // if not valid + if (*pStr >= 128 || rtl::isAsciiDigit(*pStr)) + return OUString(); + + OUStringBuffer aNewName(rName); + sal_Int32 nLength = rName.getLength(); + for (sal_Int32 i=0; i < nLength; ++i) + if(!isCharOk(aNewName[i],_rSpecials)) + aNewName[i] = '_'; + + return aNewName.makeStringAndClear(); +} + +OUString quoteName(const OUString& _rQuote, const OUString& _rName) +{ + OUString sName = _rName; + if( !_rQuote.isEmpty() && _rQuote.toChar() != ' ') + sName = _rQuote + _rName + _rQuote; + return sName; +} + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/ConnectionWrapper.cxx b/connectivity/source/commontools/ConnectionWrapper.cxx new file mode 100644 index 000000000..d7d999058 --- /dev/null +++ b/connectivity/source/commontools/ConnectionWrapper.cxx @@ -0,0 +1,239 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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_atomic_increment( &_rRefCount ); + if (_rxProxyConnection.is()) + { + // transfer the (one and only) real ref to the aggregate to our member + m_xProxyConnection = _rxProxyConnection; + _rxProxyConnection = nullptr; + ::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 xIf = static_cast< XUnoTunnel* >( this ); + m_xProxyConnection->setDelegator( xIf ); + + } + osl_atomic_decrement( &_rRefCount ); +} + +void OConnectionWrapper::setDelegation(const Reference< XConnection >& _xConnection + ,const Reference< XComponentContext>& _rxContext + ,oslInterlockedCount& _rRefCount) +{ + OSL_ENSURE(_xConnection.is(),"OConnectionWrapper: Connection must be valid!"); + osl_atomic_increment( &_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 = ProxyFactory::create( _rxContext ); + 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 xIf = static_cast< XUnoTunnel* >( this ); + m_xProxyConnection->setDelegator( xIf ); + + } + osl_atomic_decrement( &_rRefCount ); +} + +void OConnectionWrapper::disposing() +{ +m_xConnection.clear(); +} + +OConnectionWrapper::~OConnectionWrapper() +{ + if (m_xProxyConnection.is()) + m_xProxyConnection->setDelegator(nullptr); +} + +// XServiceInfo + +OUString SAL_CALL OConnectionWrapper::getImplementationName( ) +{ + return "com.sun.star.sdbc.drivers.OConnectionWrapper"; +} + + +css::uno::Sequence< OUString > SAL_CALL OConnectionWrapper::getSupportedServiceNames( ) +{ + // first collect the services which are supported by our aggregate + Sequence< OUString > aSupported; + if ( m_xServiceInfo.is() ) + aSupported = m_xServiceInfo->getSupportedServiceNames(); + + // append our own service, if necessary + OUString sConnectionService( "com.sun.star.sdbc.Connection" ); + if ( ::comphelper::findValue( aSupported, sConnectionService ) == -1 ) + { + sal_Int32 nLen = aSupported.getLength(); + aSupported.realloc( nLen + 1 ); + aSupported[ nLen ] = sConnectionService; + } + + // outta here + return aSupported; +} + + +sal_Bool SAL_CALL OConnectionWrapper::supportsService( const OUString& _rServiceName ) +{ + return cppu::supportsService(this, _rServiceName); +} + + +Any SAL_CALL OConnectionWrapper::queryInterface( const Type& _rType ) +{ + Any aReturn = OConnection_BASE::queryInterface(_rType); + return aReturn.hasValue() ? aReturn : (m_xProxyConnection.is() ? m_xProxyConnection->queryAggregation(_rType) : aReturn); +} + +Sequence< Type > SAL_CALL OConnectionWrapper::getTypes( ) +{ + return ::comphelper::concatSequences( + OConnection_BASE::getTypes(), + m_xTypeProvider->getTypes() + ); +} + +// css::lang::XUnoTunnel +sal_Int64 SAL_CALL OConnectionWrapper::getSomething( const Sequence< sal_Int8 >& rId ) +{ + if (isUnoTunnelId(rId)) + return reinterpret_cast< sal_Int64 >( this ); + + if(m_xUnoTunnel.is()) + return m_xUnoTunnel->getSomething(rId); + return 0; +} + + +Sequence< sal_Int8 > OConnectionWrapper::getUnoTunnelId() +{ + static ::cppu::OImplementationId implId; + + return implId.getImplementationId(); +} + +namespace +{ + class TPropertyValueLessFunctor + { + public: + TPropertyValueLessFunctor() + {} + bool operator() (const css::beans::PropertyValue& lhs, const css::beans::PropertyValue& rhs) const + { + return lhs.Name.compareToIgnoreAsciiCase(rhs.Name) < 0; + } + }; + +} + + +// creates a unique id out of the url and sequence of properties +void OConnectionWrapper::createUniqueId( const OUString& _rURL + ,Sequence< PropertyValue >& _rInfo + ,sal_uInt8* _pBuffer + ,const OUString& _rUserName + ,const OUString& _rPassword) +{ + // first we create the digest we want to have + ::comphelper::Hash sha1(::comphelper::HashType::SHA1); + sha1.update(reinterpret_cast(_rURL.getStr()), _rURL.getLength() * sizeof(sal_Unicode)); + if ( !_rUserName.isEmpty() ) + sha1.update(reinterpret_cast(_rUserName.getStr()), _rUserName.getLength() * sizeof(sal_Unicode)); + if ( !_rPassword.isEmpty() ) + sha1.update(reinterpret_cast(_rPassword.getStr()), _rPassword.getLength() * sizeof(sal_Unicode)); + // now we need to sort the properties + std::sort(_rInfo.begin(),_rInfo.end(),TPropertyValueLessFunctor()); + + for (PropertyValue const & prop : std::as_const(_rInfo)) + { + // we only include strings an integer values + OUString sValue; + if ( prop.Value >>= sValue ) + ; + else + { + sal_Int32 nValue = 0; + if ( prop.Value >>= nValue ) + sValue = OUString::number(nValue); + else + { + Sequence< OUString> aSeq; + if ( prop.Value >>= aSeq ) + { + for(OUString const & s : std::as_const(aSeq)) + sha1.update(reinterpret_cast(s.getStr()), s.getLength() * sizeof(sal_Unicode)); + } + } + } + if ( !sValue.isEmpty() ) + { + // we don't have to convert this into UTF8 because we don't store on a file system + sha1.update(reinterpret_cast(sValue.getStr()), sValue.getLength() * sizeof(sal_Unicode)); + } + } + + std::vector result(sha1.finalize()); + std::copy(result.begin(), result.end(), _pBuffer); +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/DateConversion.cxx b/connectivity/source/commontools/DateConversion.cxx new file mode 100644 index 000000000..510736cc6 --- /dev/null +++ b/connectivity/source/commontools/DateConversion.cxx @@ -0,0 +1,526 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +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; + +OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal, + const Reference< XTypeConverter >& _rxTypeConverter) +{ + 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() == css::uno::TypeClass_BOOLEAN) + { + if (::cppu::any2bool(_rVal)) + aRet.append("1"); + else + aRet.append("0"); + } + else + { + OUString sTemp; + _rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= sTemp; + aRet.append(sTemp); + } + break; + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::LONGVARCHAR: + aRet.append("'"); + { + OUString aTemp; + _rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= aTemp; + sal_Int32 nIndex = sal_Int32(-2); + const OUString sQuot("\'"); + do + { + nIndex += 2; + nIndex = aTemp.indexOf(sQuot,nIndex); + if(nIndex != -1) + aTemp = aTemp.replaceAt(nIndex,sQuot.getLength(), "\'\'"); + } while (nIndex != -1); + + aRet.append(aTemp); + } + aRet.append("'"); + break; + case DataType::REAL: + case DataType::DOUBLE: + case DataType::DECIMAL: + case DataType::NUMERIC: + case DataType::BIGINT: + default: + { + OUString sTemp; + _rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= sTemp; + aRet.append(sTemp); + } + break; + case DataType::TIMESTAMP: + { + DateTime aDateTime; + bool bOk = false; + if (_rVal.getValueType().getTypeClass() == css::uno::TypeClass_DOUBLE) + { + double nValue = 0.0; + _rVal >>= nValue; + aDateTime = DBTypeConversion::toDateTime(nValue); + bOk = true; + } + else if (_rVal.getValueType().getTypeClass() == css::uno::TypeClass_STRING) + { + OUString sValue; + _rVal >>= sValue; + aDateTime = DBTypeConversion::toDateTime(sValue); + bOk = true; + } + else + bOk = _rVal >>= aDateTime; + + OSL_ENSURE( bOk, "DBTypeConversion::toSQLString: _rVal is not datetime!"); + // check if this is really a timestamp or only a date + if ( bOk ) + { + aRet.append("{ts '"); + aRet.append(DBTypeConversion::toDateTimeString(aDateTime)); + aRet.append("'}"); + break; + } + break; + } + case DataType::DATE: + { + Date aDate; + bool bOk = false; + if (_rVal.getValueType().getTypeClass() == css::uno::TypeClass_DOUBLE) + { + double nValue = 0.0; + _rVal >>= nValue; + aDate = DBTypeConversion::toDate(nValue); + bOk = true; + } + else if (_rVal.getValueType().getTypeClass() == css::uno::TypeClass_STRING) + { + OUString sValue; + _rVal >>= sValue; + aDate = DBTypeConversion::toDate(sValue); + bOk = true; + } + else + bOk = _rVal >>= aDate; + OSL_ENSURE( bOk, "DBTypeConversion::toSQLString: _rVal is not date!"); + aRet.append("{d '"); + aRet.append(DBTypeConversion::toDateString(aDate)); + aRet.append("'}"); + } break; + case DataType::TIME: + { + css::util::Time aTime; + bool bOk = false; + if (_rVal.getValueType().getTypeClass() == css::uno::TypeClass_DOUBLE) + { + double nValue = 0.0; + _rVal >>= nValue; + aTime = DBTypeConversion::toTime(nValue); + bOk = true; + } + else if (_rVal.getValueType().getTypeClass() == css::uno::TypeClass_STRING) + { + OUString sValue; + _rVal >>= sValue; + aTime = DBTypeConversion::toTime(sValue); + bOk = true; + } + else + bOk = _rVal >>= aTime; + OSL_ENSURE( bOk,"DBTypeConversion::toSQLString: _rVal is not time!"); + aRet.append("{t '"); + aRet.append(DBTypeConversion::toTimeString(aTime)); + aRet.append("'}"); + } break; + } + } + catch ( const Exception& ) + { + OSL_FAIL("TypeConversion Error"); + } + } + else + aRet.append(" 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("NullDate") >>= aDate; + return aDate; + } + catch ( const Exception& ) + { + } + } + + return getStandardDate(); +} + +void DBTypeConversion::setValue(const Reference& xVariant, + const Reference& xFormatter, + const Date& rNullDate, + const OUString& rString, + sal_Int32 nKey, + sal_Int16 nFieldType, + sal_Int16 nKeyType) +{ + if (!rString.isEmpty()) + { + // Does the String need to be formatted? + sal_Int16 nTypeClass = nKeyType & ~NumberFormat::DEFINED; + bool bTextFormat = nTypeClass == NumberFormat::TEXT; + sal_Int32 nKeyToUse = bTextFormat ? 0 : nKey; + sal_Int16 nRealUsedTypeClass = nTypeClass; + // for a Text-Format the formatter needs some more freedom, otherwise + // convertStringToNumber will throw a NotNumericException + try + { + double fValue = xFormatter->convertStringToNumber(nKeyToUse, rString); + Reference< XNumberFormats > xFormats(xFormatter->getNumberFormatsSupplier()->getNumberFormats()); + Reference< XNumberFormatTypes > xFormatTypes(xFormats, UNO_QUERY); + sal_Int32 nStandardKey(0); + if(xFormatTypes.is()) + { + const Reference< XPropertySet > xFormatProps(xFormats->getByKey(nKeyToUse)); + if (xFormatProps.is()) + { + css::lang::Locale loc; + if (xFormatProps->getPropertyValue("Locale") >>= loc) + nStandardKey = xFormatTypes->getStandardIndex(loc); + else + { + assert(false); + } + } + else + { + SAL_WARN("connectivity.commontools", "no format by key " << nKeyToUse); + } + } + else + { + assert(false); + } + // Why use nStandardKey rather than nKeyToUse here? I'm not sure, but "it was always like that". + // Previously had hardcoded 0 instead of nStandardKey, which led to problems with dates + // because of differences M/D/Y vs D/M/Y. This at least fixes those problems, but possibly + // nKeyToUse is an even better choice than nStandardKey. + // OTOH, using nKeyToUse nullifies the special treatment for percent formats, + // leading to "5" (in a percent format) to be understood as "500%" instead of "5%". + sal_Int32 nRealUsedKey = xFormatter->detectNumberFormat(nStandardKey, rString); + if (nRealUsedKey != nKeyToUse) + nRealUsedTypeClass = getNumberFormatType(xFormatter, nRealUsedKey) & ~NumberFormat::DEFINED; + + // and again a special treatment, this time for percent formats + if ((NumberFormat::NUMBER == nRealUsedTypeClass) && (NumberFormat::PERCENT == nTypeClass)) + { // formatting should be "percent", but the String provides just a simple number -> adjust + OUString sExpanded = rString + "%"; + fValue = xFormatter->convertStringToNumber(nKeyToUse, sExpanded); + } + + switch (nRealUsedTypeClass) + { + case NumberFormat::DATE: + case NumberFormat::DATETIME: + case NumberFormat::TIME: + DBTypeConversion::setValue(xVariant,rNullDate,fValue,nRealUsedTypeClass); + 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 css::sdbc::DataType::CHAR: + case css::sdbc::DataType::VARCHAR: + case css::sdbc::DataType::LONGVARCHAR: + xVariant->updateString(rString); + break; + default: + xVariant->updateNull(); + } + } +} + + +void DBTypeConversion::setValue(const Reference& xVariant, + const Date& rNullDate, + const double& rValue, + sal_Int16 nKeyType) +{ + 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 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(rValue); +// break; +// case DataType::SMALLINT: +// nValue = static_cast(rValue); +// break; +// case DataType::INTEGER: +// nValue = static_cast(rValue); +// break; +// case DataType::BIGINT: +// nValue = static_cast(rValue); +// break; +// } +// } + xVariant->updateDouble(nValue); + } + } +} + + +double DBTypeConversion::getValue( const Reference< XColumn >& i_column, const Date& i_relativeToNullDate ) +{ + try + { + const Reference< XPropertySet > xProp( i_column, UNO_QUERY_THROW ); + + const sal_Int32 nColumnType = ::comphelper::getINT32( xProp->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_TYPE ) ) ); + switch ( nColumnType ) + { + case DataType::DATE: + return toDouble( i_column->getDate(), i_relativeToNullDate ); + + case DataType::TIME: + return toDouble( i_column->getTime() ); + + case DataType::TIMESTAMP: + return toDouble( i_column->getTimestamp(), i_relativeToNullDate ); + + default: + { + bool bIsSigned = true; + OSL_VERIFY( xProp->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_ISSIGNED ) ) >>= bIsSigned ); + if ( !bIsSigned ) + { + switch ( nColumnType) + { + case DataType::TINYINT: + return static_cast(static_cast(i_column->getByte())); + case DataType::SMALLINT: + return static_cast(static_cast(i_column->getShort())); + case DataType::INTEGER: + return static_cast(static_cast(i_column->getInt())); + case DataType::BIGINT: + return static_cast(static_cast(i_column->getLong())); + } + } + } + return i_column->getDouble(); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("connectivity.commontools"); + return 0.0; + } +} + +OUString DBTypeConversion::getFormattedValue(const Reference< XPropertySet>& _xColumn, + const Reference& _xFormatter, + const css::lang::Locale& _rLocale, + const Date& _rNullDate) +{ + OSL_ENSURE(_xColumn.is() && _xFormatter.is(), "DBTypeConversion::getFormattedValue: invalid arg !"); + if (!_xColumn.is() || !_xFormatter.is()) + return OUString(); + + sal_Int32 nKey(0); + try + { + _xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FORMATKEY)) >>= nKey; + } + catch (const Exception& ) + { + OSL_FAIL("DBTypeConversion::getValue: caught an exception while asking for the format key!"); + } + + if (!nKey) + { + Reference xFormats( _xFormatter->getNumberFormatsSupplier()->getNumberFormats() ); + + nKey = ::dbtools::getDefaultNumberFormat(_xColumn, + Reference< XNumberFormatTypes > (xFormats, UNO_QUERY), + _rLocale); + + } + + sal_Int16 nKeyType = getNumberFormatType(_xFormatter, nKey) & ~NumberFormat::DEFINED; + + return DBTypeConversion::getFormattedValue(Reference< XColumn > (_xColumn, UNO_QUERY), _xFormatter, _rNullDate, nKey, nKeyType); +} + + +OUString DBTypeConversion::getFormattedValue(const Reference& xVariant, + const Reference& xFormatter, + const Date& rNullDate, + sal_Int32 nKey, + sal_Int16 nKeyType) +{ + 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 ); + if ( !xVariant->wasNull() ) + { + // get the null date of the formatter + Date aFormatterNullDate( rNullDate ); + try + { + Reference< XNumberFormatsSupplier > xSupplier( xFormatter->getNumberFormatsSupplier(), UNO_SET_THROW ); + Reference< XPropertySet > xFormatterSettings( xSupplier->getNumberFormatSettings(), UNO_SET_THROW ); + OSL_VERIFY( xFormatterSettings->getPropertyValue("NullDate") >>= aFormatterNullDate ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("connectivity.commontools"); + } + // 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; +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/DriversConfig.cxx b/connectivity/source/commontools/DriversConfig.cxx new file mode 100644 index 000000000..9d2ab8a47 --- /dev/null +++ b/connectivity/source/commontools/DriversConfig.cxx @@ -0,0 +1,237 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include +#include +#include + +using namespace connectivity; +using namespace utl; +using namespace ::com::sun::star; + +namespace +{ + void lcl_convert(const uno::Sequence< OUString >& _aSource,uno::Any& _rDest) + { + uno::Sequence aRet(_aSource.getLength()); + uno::Any* pAny = aRet.getArray(); + const OUString* pIter = _aSource.getConstArray(); + const OUString* pEnd = pIter + _aSource.getLength(); + for (;pIter != pEnd ; ++pIter,++pAny) + { + *pAny <<= *pIter; + } + _rDest <<= aRet; + } + void lcl_fillValues(const ::utl::OConfigurationNode& _aURLPatternNode,const OUString& _sNode,::comphelper::NamedValueCollection& _rValues) + { + const ::utl::OConfigurationNode aPropertiesNode = _aURLPatternNode.openNode(_sNode); + if ( !aPropertiesNode.isValid() ) + return; + + uno::Sequence< OUString > aStringSeq; + const uno::Sequence< OUString > aProperties = aPropertiesNode.getNodeNames(); + const OUString* pPropertiesIter = aProperties.getConstArray(); + const OUString* pPropertiesEnd = pPropertiesIter + aProperties.getLength(); + for (;pPropertiesIter != pPropertiesEnd ; ++pPropertiesIter) + { + uno::Any aValue = aPropertiesNode.getNodeValue(*pPropertiesIter + "/Value"); + if ( aValue >>= aStringSeq ) + { + lcl_convert(aStringSeq,aValue); + } + _rValues.put(*pPropertiesIter,aValue); + } // for (;pPropertiesIter != pPropertiesEnd ; ++pPropertiesIter,++pNamedIter) + } + void lcl_readURLPatternNode(const ::utl::OConfigurationTreeRoot& _aInstalled,const OUString& _sEntry,TInstalledDriver& _rInstalledDriver) + { + const ::utl::OConfigurationNode aURLPatternNode = _aInstalled.openNode(_sEntry); + if ( !aURLPatternNode.isValid() ) + return; + + OUString sParentURLPattern; + aURLPatternNode.getNodeValue("ParentURLPattern") >>= sParentURLPattern; + if ( !sParentURLPattern.isEmpty() ) + lcl_readURLPatternNode(_aInstalled,sParentURLPattern,_rInstalledDriver); + + OUString sDriverFactory; + aURLPatternNode.getNodeValue("Driver") >>= sDriverFactory; + if ( !sDriverFactory.isEmpty() ) + _rInstalledDriver.sDriverFactory = sDriverFactory; + + OUString sDriverTypeDisplayName; + aURLPatternNode.getNodeValue("DriverTypeDisplayName") >>= sDriverTypeDisplayName; + OSL_ENSURE(!sDriverTypeDisplayName.isEmpty(),"No valid DriverTypeDisplayName property!"); + if ( !sDriverTypeDisplayName.isEmpty() ) + _rInstalledDriver.sDriverTypeDisplayName = sDriverTypeDisplayName; + + lcl_fillValues(aURLPatternNode,"Properties",_rInstalledDriver.aProperties); + lcl_fillValues(aURLPatternNode,"Features",_rInstalledDriver.aFeatures); + lcl_fillValues(aURLPatternNode,"MetaData",_rInstalledDriver.aMetaData); + } +} + +DriversConfigImpl::DriversConfigImpl() +{ +} + +const TInstalledDrivers& DriversConfigImpl::getInstalledDrivers(const uno::Reference< uno::XComponentContext >& _rxORB) const +{ + if ( m_aDrivers.empty() ) + { + if ( !m_aInstalled.isValid() ) + { + m_aInstalled = ::utl::OConfigurationTreeRoot::createWithComponentContext(_rxORB, + "org.openoffice.Office.DataAccess.Drivers/Installed", -1, ::utl::OConfigurationTreeRoot::CM_READONLY); + } + + if ( m_aInstalled.isValid() ) + { + const uno::Sequence< OUString > aURLPatterns = m_aInstalled.getNodeNames(); + const OUString* pPatternIter = aURLPatterns.getConstArray(); + const OUString* pPatternEnd = pPatternIter + aURLPatterns.getLength(); + for (;pPatternIter != pPatternEnd ; ++pPatternIter) + { + TInstalledDriver aInstalledDriver; + lcl_readURLPatternNode(m_aInstalled,*pPatternIter,aInstalledDriver); + if ( !aInstalledDriver.sDriverFactory.isEmpty() ) + m_aDrivers.emplace(*pPatternIter,aInstalledDriver); + } + } // if ( m_aInstalled.isValid() ) + } + return m_aDrivers; +} + +DriversConfig::DriversConfig(const uno::Reference< uno::XComponentContext >& _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; +} + + +OUString DriversConfig::getDriverFactoryName(const OUString& _sURL) const +{ + const TInstalledDrivers& rDrivers = m_aNode->getInstalledDrivers(m_xORB); + OUString sRet; + OUString sOldPattern; + for(const auto& [rPattern, rDriver] : rDrivers) + { + WildCard aWildCard(rPattern); + if ( sOldPattern.getLength() < rPattern.getLength() && aWildCard.Matches(_sURL) ) + { + sRet = rDriver.sDriverFactory; + sOldPattern = rPattern; + } + } + + return sRet; +} + +OUString DriversConfig::getDriverTypeDisplayName(const OUString& _sURL) const +{ + const TInstalledDrivers& rDrivers = m_aNode->getInstalledDrivers(m_xORB); + OUString sRet; + OUString sOldPattern; + for(const auto& [rPattern, rDriver] : rDrivers) + { + WildCard aWildCard(rPattern); + if ( sOldPattern.getLength() < rPattern.getLength() && aWildCard.Matches(_sURL) ) + { + sRet = rDriver.sDriverTypeDisplayName; + sOldPattern = rPattern; + } + } + + return sRet; +} + +const ::comphelper::NamedValueCollection& DriversConfig::getProperties(const OUString& _sURL) const +{ + return impl_get(_sURL,1); +} + +const ::comphelper::NamedValueCollection& DriversConfig::getFeatures(const OUString& _sURL) const +{ + return impl_get(_sURL,0); +} + +const ::comphelper::NamedValueCollection& DriversConfig::getMetaData(const OUString& _sURL) const +{ + return impl_get(_sURL,2); +} + +const ::comphelper::NamedValueCollection& DriversConfig::impl_get(const OUString& _sURL,sal_Int32 _nProps) const +{ + const TInstalledDrivers& rDrivers = m_aNode->getInstalledDrivers(m_xORB); + const ::comphelper::NamedValueCollection* pRet = nullptr; + OUString sOldPattern; + for(const auto& [rPattern, rDriver] : rDrivers) + { + WildCard aWildCard(rPattern); + if ( sOldPattern.getLength() < rPattern.getLength() && aWildCard.Matches(_sURL) ) + { + switch(_nProps) + { + case 0: + pRet = &rDriver.aFeatures; + break; + case 1: + pRet = &rDriver.aProperties; + break; + case 2: + pRet = &rDriver.aMetaData; + break; + } + sOldPattern = rPattern; + } + } // for(;aIter != aEnd;++aIter) + if ( pRet == nullptr ) + { + static const ::comphelper::NamedValueCollection s_sEmpty; + pRet = &s_sEmpty; + } + return *pRet; +} + +uno::Sequence< OUString > DriversConfig::getURLs() const +{ + const TInstalledDrivers& rDrivers = m_aNode->getInstalledDrivers(m_xORB); + return comphelper::mapKeysToSequence(rDrivers); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx new file mode 100644 index 000000000..7d3d34891 --- /dev/null +++ b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx @@ -0,0 +1,894 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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(nullptr) + ,m_nColPos(0) + ,m_bBOF(true) + ,m_bEOF(true) +{ + construct(); +} + + +ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet( MetaDataResultSetType _eType ) + :ODatabaseMetaDataResultSet_BASE(m_aMutex) + ,::comphelper::OPropertyContainer(ODatabaseMetaDataResultSet_BASE::rBHelper) + ,m_aStatement(nullptr) + ,m_nColPos(0) + ,m_bBOF(true) + ,m_bEOF(true) +{ + construct(); + + setType(_eType); +} + + +ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet() +{ +} + +void ODatabaseMetaDataResultSet::construct() +{ + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), PROPERTY_ID_FETCHSIZE, 0,&m_nFetchSize, ::cppu::UnoType::get()); + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), PROPERTY_ID_RESULTSETTYPE, PropertyAttribute::READONLY,&m_nResultSetType, ::cppu::UnoType::get()); + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), PROPERTY_ID_FETCHDIRECTION, 0, &m_nFetchDirection, ::cppu::UnoType::get()); + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), PROPERTY_ID_RESULTSETCONCURRENCY, PropertyAttribute::READONLY,&m_nResultSetConcurrency, ::cppu::UnoType::get()); +} + +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; + case eUDTs: setUDTsMap(); break; + default: + OSL_FAIL("Wrong type!"); + } +} + +void ODatabaseMetaDataResultSet::disposing() +{ + OPropertySetHelper::disposing(); + + ::osl::MutexGuard aGuard(m_aMutex); + m_aStatement = nullptr; + 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 ) +{ + Any aRet = OPropertySetHelper::queryInterface(rType); + return aRet.hasValue() ? aRet : ODatabaseMetaDataResultSet_BASE::queryInterface(rType); +} + +Sequence< Type > SAL_CALL ODatabaseMetaDataResultSet::getTypes( ) +{ + ::cppu::OTypeCollection aTypes( cppu::UnoType::get(), + cppu::UnoType::get(), + cppu::UnoType::get()); + + return ::comphelper::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes()); +} + +void ODatabaseMetaDataResultSet::setRows(const ORows& _rRows) +{ + m_aRows = _rRows; + m_bBOF = true; + m_bEOF = m_aRows.empty(); +} + +sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const OUString& columnName ) +{ + ::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)) + ) + return i; + } + + ::dbtools::throwInvalidColumnException( columnName, *this ); +#if !(defined(_MSC_VER) && defined(ENABLE_LTO)) + assert(false); + return 0; // Never reached +#endif +} + +void ODatabaseMetaDataResultSet::checkIndex(sal_Int32 columnIndex ) +{ + if(columnIndex >= static_cast((*m_aRowsIter).size()) || columnIndex < 1) + ::dbtools::throwInvalidIndexException(*this); +} + +Reference< css::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) +{ + return nullptr; +} + +Reference< css::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) +{ + return nullptr; +} + + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ) +{ + return bool(getValue(columnIndex)); +} + + +sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) +{ + return getValue(columnIndex); +} + + +Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex ) +{ + return getValue(columnIndex); +} + + +css::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex ) +{ + return getValue(columnIndex); +} + + +double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex ) +{ + return getValue(columnIndex); +} + + +float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex ) +{ + return getValue(columnIndex); +} + + +sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex ) +{ + return getValue(columnIndex); +} + + +sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow( ) +{ + return 0; +} + + +sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 columnIndex ) +{ + return getValue(columnIndex); +} + + +Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData( ) +{ + ::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*/ ) +{ + return nullptr; +} + + +Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 /*columnIndex*/ ) +{ + return nullptr; +} + +Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 /*columnIndex*/ ) +{ + return nullptr; +} + + +Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 /*columnIndex*/ ) +{ + return nullptr; +} + + +Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex, const Reference< css::container::XNameAccess >& /*typeMap*/ ) +{ + return getValue(columnIndex).makeAny(); +} + + +sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) +{ + return getValue(columnIndex); +} + + +OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex ) +{ + return getValue(columnIndex); +} + + +css::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex ) +{ + return getValue(columnIndex); +} + + +css::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex ) +{ + return getValue(columnIndex); +} + + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast( ) +{ + return m_bEOF; +} + + +SAL_WNOUNREACHABLE_CODE_PUSH + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst( ) +{ + ::dbtools::throwFunctionSequenceException(*this); + return false; +} + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast( ) +{ + ::dbtools::throwFunctionSequenceException(*this); + return false; +} + +SAL_WNOUNREACHABLE_CODE_POP + + +void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst( ) +{ + ::dbtools::throwFunctionSequenceException(*this); +} + +void SAL_CALL ODatabaseMetaDataResultSet::afterLast( ) +{ + ::dbtools::throwFunctionSequenceException(*this); +} + + +void SAL_CALL ODatabaseMetaDataResultSet::close( ) +{ + { + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); + + } + dispose(); +} + + +SAL_WNOUNREACHABLE_CODE_PUSH + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first( ) +{ + ::dbtools::throwFunctionSequenceException(*this); + return false; +} + + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last( ) +{ + ::dbtools::throwFunctionSequenceException(*this); + return false; +} + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 /*row*/ ) +{ + ::dbtools::throwFunctionSequenceException(*this); + return false; +} + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 /*row*/ ) +{ + ::dbtools::throwFunctionSequenceException(*this); + return false; +} + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous( ) +{ + ::dbtools::throwFunctionSequenceException(*this); + return false; +} + +SAL_WNOUNREACHABLE_CODE_POP + + +Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement( ) +{ + return m_aStatement.get(); +} + + +SAL_WNOUNREACHABLE_CODE_PUSH + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted( ) +{ + ::dbtools::throwFunctionSequenceException(*this); + return false; +} + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted( ) +{ + ::dbtools::throwFunctionSequenceException(*this); + return false; +} + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated( ) +{ + ::dbtools::throwFunctionSequenceException(*this); + return false; +} + +SAL_WNOUNREACHABLE_CODE_POP + + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst( ) +{ + return m_bBOF; +} + + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next( ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); + + if ( m_bBOF ) + { + m_aRowsIter = m_aRows.begin(); + m_bBOF = 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 = true; + m_bBOF = m_aRows.empty(); + } + return bSuccess; +} + + +sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull( ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); + + + if(m_aRowsIter == m_aRows.end() || !(*m_aRowsIter)[m_nColPos].is()) + return true; + + return (*m_aRowsIter)[m_nColPos]->getValue().isNull(); +} + +void SAL_CALL ODatabaseMetaDataResultSet::refreshRow( ) +{ +} + + +void SAL_CALL ODatabaseMetaDataResultSet::cancel( ) +{ +} + +void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings( ) +{ +} + +Any SAL_CALL ODatabaseMetaDataResultSet::getWarnings( ) +{ + return Any(); +} + +::cppu::IPropertyArrayHelper* ODatabaseMetaDataResultSet::createArrayHelper( ) const +{ + Sequence< Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} + +::cppu::IPropertyArrayHelper & ODatabaseMetaDataResultSet::getInfoHelper() +{ + return *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::setUDTsMap() +{ + ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(); + pMetaData->setUDTsMap(); + 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< css::beans::XPropertySetInfo > SAL_CALL ODatabaseMetaDataResultSet::getPropertySetInfo( ) +{ + 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].is()) + return *(*m_aRowsIter)[columnIndex]; + return m_aEmptyValue; +} + +/// return an empty ORowSetValueDecorator +ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getEmptyValue() +{ + static ORowSetValueDecoratorRef aEmptyValueRef = new ORowSetValueDecorator(); + return aEmptyValueRef; +} + +/// return an ORowSetValueDecorator with 0 as value +ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::get0Value() +{ + static ORowSetValueDecoratorRef a0ValueRef = new ORowSetValueDecorator(sal_Int32(0)); + return a0ValueRef; +} + +/// return an ORowSetValueDecorator with 1 as value +ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::get1Value() +{ + static ORowSetValueDecoratorRef a1ValueRef = new ORowSetValueDecorator(sal_Int32(1)); + return a1ValueRef; +} + +/// return an ORowSetValueDecorator with ColumnSearch::BASIC as value +ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getBasicValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(ColumnSearch::BASIC); + return aValueRef; +} + +ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getSelectValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("SELECT")); + return aValueRef; +} + +ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getInsertValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("INSERT")); + return aValueRef; +} + +ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getDeleteValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("DELETE")); + return aValueRef; +} + +ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getUpdateValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("UPDATE")); + return aValueRef; +} + +ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getCreateValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("CREATE")); + return aValueRef; +} + +ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getReadValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("READ")); + return aValueRef; +} + +ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getAlterValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("ALTER")); + return aValueRef; +} + +ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getDropValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("DROP")); + return aValueRef; +} + +ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getQuoteValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(OUString("'")); + return aValueRef; +} + +void SAL_CALL ODatabaseMetaDataResultSet::initialize( const Sequence< Any >& _aArguments ) +{ + if ( _aArguments.getLength() != 2 ) + return; + + sal_Int32 nResultSetType = 0; + if ( !(_aArguments[0] >>= nResultSetType)) + return; + + setType(static_cast(nResultSetType)); + Sequence< Sequence > aRows; + if ( !(_aArguments[1] >>= aRows) ) + return; + + ORows aRowsToSet; + const Sequence* pRowsIter = aRows.getConstArray(); + const Sequence* 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: + { + bool bValue = 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: + { + 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 + + + OUString ODatabaseMetaDataResultSet::getImplementationName_Static( ) + { + return "org.openoffice.comp.helper.DatabaseMetaDataResultSet"; + } + + Sequence< OUString > ODatabaseMetaDataResultSet::getSupportedServiceNames_Static( ) + { + Sequence aSNS { "com.sun.star.sdbc.ResultSet" }; + return aSNS; + } + + OUString SAL_CALL ODatabaseMetaDataResultSet::getImplementationName( ) + { + return getImplementationName_Static(); + } + + sal_Bool SAL_CALL ODatabaseMetaDataResultSet::supportsService( const OUString& _rServiceName ) + { + return cppu::supportsService(this, _rServiceName); + } + + Sequence< OUString > SAL_CALL ODatabaseMetaDataResultSet::getSupportedServiceNames( ) + { + return getSupportedServiceNames_Static(); + } + + namespace connectivity + { + /// @throws Exception + static Reference< XInterface > ODatabaseMetaDataResultSet_CreateInstance(const Reference< XComponentContext >& ) + { + return *(new ODatabaseMetaDataResultSet()); + } + } + + +namespace +{ + cppu::ImplementationEntry const entries[] = { + { &ODatabaseMetaDataResultSet_CreateInstance, &ODatabaseMetaDataResultSet::getImplementationName_Static, &ODatabaseMetaDataResultSet::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, nullptr, 0 }, + { &ParameterSubstitution::create, &ParameterSubstitution::getImplementationName_Static, &ParameterSubstitution::getSupportedServiceNames_Static, + &cppu::createSingleComponentFactory, nullptr, 0 }, + { nullptr, nullptr, nullptr, nullptr, nullptr, 0 } + }; +} + +extern "C" +{ + + +SAL_DLLPUBLIC_EXPORT void* dbtools_component_getFactory(const char* implName, void* serviceManager, void* registryKey) +{ + return cppu::component_getFactoryHelper(implName, serviceManager, registryKey, entries); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/FDatabaseMetaDataResultSetMetaData.cxx b/connectivity/source/commontools/FDatabaseMetaDataResultSetMetaData.cxx new file mode 100644 index 000000000..561953a07 --- /dev/null +++ b/connectivity/source/commontools/FDatabaseMetaDataResultSetMetaData.cxx @@ -0,0 +1,357 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include + +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::lang; + +ODatabaseMetaDataResultSetMetaData::~ODatabaseMetaDataResultSetMetaData() +{ +} + +sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) +{ + if((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 ) +{ + if((m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getColumnType(); + return 1; +} + +sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnCount( ) +{ + return m_mColumns.size(); +} + +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isCaseSensitive( sal_Int32 column ) +{ + if((m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isCaseSensitive(); + return true; +} + +OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getSchemaName( sal_Int32 /*column*/ ) +{ + return OUString(); +} + +OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnName( sal_Int32 column ) +{ + if((m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getColumnName(); + return OUString(); +} + +OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getTableName( sal_Int32 column ) +{ + if((m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getTableName(); + return OUString(); +} + +OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getCatalogName( sal_Int32 /*column*/ ) +{ + return OUString(); +} + +OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnTypeName( sal_Int32 /*column*/ ) +{ + return OUString(); +} + +OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnLabel( sal_Int32 column ) +{ + if((m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.getColumnLabel(); + return getColumnName(column); +} + +OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnServiceName( sal_Int32 /*column*/ ) +{ + return OUString(); +} + +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isCurrency( sal_Int32 column ) +{ + if((m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isCurrency(); + return false; +} + +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isAutoIncrement( sal_Int32 column ) +{ + if((m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isAutoIncrement(); + return false; +} + +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isSigned( sal_Int32 column ) +{ + if((m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isSigned(); + return false; +} + +sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getPrecision( sal_Int32 column ) +{ + if((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 ) +{ + if((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 ) +{ + if((m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isNullable(); + + return sal_Int32(false); +} + +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isSearchable( sal_Int32 column ) +{ + if((m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end()) + return (*m_mColumnsIter).second.isSearchable(); + return true; +} + +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isReadOnly( sal_Int32 /*column*/ ) +{ + return true; +} + +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isDefinitelyWritable( sal_Int32 /*column*/ ) +{ + return false; +} + +sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isWritable( sal_Int32 column ) +{ + return isDefinitelyWritable(column); +} + +void ODatabaseMetaDataResultSetMetaData::setColumnPrivilegesMap() +{ + setColumnMap(); + m_mColumns[5] = OColumn(OUString(),"GRANTOR", ColumnValue::NULLABLE, 3,3,0, DataType::VARCHAR); + m_mColumns[6] = OColumn(OUString(),"GRANTEE", ColumnValue::NULLABLE, 3,3,0, DataType::VARCHAR); + m_mColumns[7] = OColumn(OUString(),"PRIVILEGE", ColumnValue::NULLABLE, 3,3,0, DataType::VARCHAR); + m_mColumns[8] = OColumn(OUString(),"IS_GRANTABLE", ColumnValue::NULLABLE, 3,3,0, DataType::VARCHAR); +} + +void ODatabaseMetaDataResultSetMetaData::setTableNameMap() +{ + m_mColumns[1] = OColumn(OUString(),"TABLE_CAT", ColumnValue::NULLABLE, 3,3,0, DataType::VARCHAR); + m_mColumns[2] = OColumn(OUString(),"TABLE_SCHEM", ColumnValue::NULLABLE, 3,3,0, DataType::VARCHAR); + m_mColumns[3] = OColumn(OUString(),"TABLE_NAME", ColumnValue::NO_NULLS, 3,3,0, DataType::VARCHAR); +} + +void ODatabaseMetaDataResultSetMetaData::setColumnMap() +{ + setTableNameMap(); + m_mColumns[4] = OColumn(OUString(),"COLUMN_NAME", ColumnValue::NO_NULLS, 3,3,0, DataType::VARCHAR); +} + +void ODatabaseMetaDataResultSetMetaData::setColumnsMap() +{ + setColumnMap(); + + m_mColumns[5] = OColumn(OUString(),"DATA_TYPE", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[6] = OColumn(OUString(),"TYPE_NAME", ColumnValue::NO_NULLS, 0,0,0, DataType::VARCHAR); + m_mColumns[7] = OColumn(OUString(),"COLUMN_SIZE", ColumnValue::NO_NULLS, 3,3,0, DataType::INTEGER); + m_mColumns[8] = OColumn(OUString(),"BUFFER_LENGTH", ColumnValue::NULLABLE, 3,3,0, DataType::INTEGER); + m_mColumns[9] = OColumn(OUString(),"DECIMAL_DIGITS", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[10] = OColumn(OUString(),"NUM_PREC_RADIX", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[11] = OColumn(OUString(),"NULLABLE", ColumnValue::NO_NULLS, 1,1,0, DataType::INTEGER); + m_mColumns[12] = OColumn(OUString(),"REMARKS", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[13] = OColumn(OUString(),"COLUMN_DEF", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[14] = OColumn(OUString(),"SQL_DATA_TYPE", ColumnValue::NO_NULLS, 1,1,0, DataType::INTEGER); + m_mColumns[15] = OColumn(OUString(),"SQL_DATETIME_SUB", ColumnValue::NO_NULLS, 1,1,0, DataType::INTEGER); + m_mColumns[16] = OColumn(OUString(),"CHAR_OCTET_LENGTH", ColumnValue::NO_NULLS, 1,1,0, DataType::INTEGER); + m_mColumns[17] = OColumn(OUString(),"ORDINAL_POSITION", ColumnValue::NO_NULLS, 1,1,0, DataType::INTEGER); + m_mColumns[18] = OColumn(OUString(),"IS_NULLABLE", ColumnValue::NO_NULLS, 1,1,0, DataType::VARCHAR); +} + +void ODatabaseMetaDataResultSetMetaData::setTablesMap() +{ + setTableNameMap(); + m_mColumns[4] = OColumn(OUString(),"TABLE_TYPE", ColumnValue::NO_NULLS, 0,0,0, DataType::VARCHAR); + m_mColumns[5] = OColumn(OUString(),"REMARKS", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); +} + +void ODatabaseMetaDataResultSetMetaData::setProcedureNameMap() +{ + m_mColumns[1] = OColumn(OUString(),"PROCEDURE_CAT", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[2] = OColumn(OUString(),"PROCEDURE_SCHEM", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[3] = OColumn(OUString(),"PROCEDURE_NAME", ColumnValue::NO_NULLS, 0,0,0, DataType::VARCHAR); +} + +void ODatabaseMetaDataResultSetMetaData::setProcedureColumnsMap() +{ + setProcedureNameMap(); + m_mColumns[4] = OColumn(OUString(),"COLUMN_NAME", ColumnValue::NO_NULLS, 0,0,0, DataType::VARCHAR); + m_mColumns[5] = OColumn(OUString(),"COLUMN_TYPE", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[6] = OColumn(OUString(),"DATA_TYPE", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[7] = OColumn(OUString(),"TYPE_NAME", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[8] = OColumn(OUString(),"PRECISION", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[9] = OColumn(OUString(),"LENGTH", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[10] = OColumn(OUString(),"SCALE", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[11] = OColumn(OUString(),"RADIX", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[12] = OColumn(OUString(),"NULLABLE", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[13] = OColumn(OUString(),"REMARKS", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); +} + +void ODatabaseMetaDataResultSetMetaData::setPrimaryKeysMap() +{ + setColumnMap(); + m_mColumns[5] = OColumn(OUString(),"KEY_SEQ", ColumnValue::NO_NULLS, 1,1,0, DataType::INTEGER); + m_mColumns[6] = OColumn(OUString(),"PK_NAME", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); +} + +void ODatabaseMetaDataResultSetMetaData::setIndexInfoMap() +{ + setTableNameMap(); + m_mColumns[4] = OColumn(OUString(),"NON_UNIQUE", ColumnValue::NO_NULLS, 1,1,0, DataType::BIT); + m_mColumns[5] = OColumn(OUString(),"INDEX_QUALIFIER", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[6] = OColumn(OUString(),"INDEX_NAME", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[7] = OColumn(OUString(),"TYPE", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[8] = OColumn(OUString(),"ORDINAL_POSITION", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[9] = OColumn(OUString(),"COLUMN_NAME", ColumnValue::NO_NULLS, 0,0,0, DataType::VARCHAR); + m_mColumns[10] = OColumn(OUString(),"ASC_OR_DESC", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[11] = OColumn(OUString(),"CARDINALITY", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[12] = OColumn(OUString(),"PAGES", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[13] = OColumn(OUString(),"FILTER_CONDITION", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); +} + +void ODatabaseMetaDataResultSetMetaData::setTablePrivilegesMap() +{ + setTableNameMap(); + m_mColumns[4] = OColumn(OUString(),"GRANTOR", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[5] = OColumn(OUString(),"GRANTEE", ColumnValue::NO_NULLS, 0,0,0, DataType::VARCHAR); + m_mColumns[6] = OColumn(OUString(),"PRIVILEGE", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[7] = OColumn(OUString(),"IS_GRANTABLE", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); +} + +void ODatabaseMetaDataResultSetMetaData::setCrossReferenceMap() +{ + m_mColumns[1] = OColumn(OUString(),"PKTABLE_CAT", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[2] = OColumn(OUString(),"PKTABLE_SCHEM", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[3] = OColumn(OUString(),"PKTABLE_NAME", ColumnValue::NO_NULLS, 0,0,0, DataType::VARCHAR); + m_mColumns[4] = OColumn(OUString(),"PKCOLUMN_NAME", ColumnValue::NO_NULLS, 0,0,0, DataType::VARCHAR); + m_mColumns[5] = OColumn(OUString(),"FKTABLE_CAT", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[6] = OColumn(OUString(),"FKTABLE_SCHEM", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[7] = OColumn(OUString(),"FKTABLE_NAME", ColumnValue::NO_NULLS, 0,0,0, DataType::VARCHAR); + m_mColumns[8] = OColumn(OUString(),"FKCOLUMN_NAME", ColumnValue::NO_NULLS, 0,0,0, DataType::VARCHAR); + + m_mColumns[9] = OColumn(OUString(),"KEY_SEQ", ColumnValue::NO_NULLS, 1,1,0, DataType::INTEGER); + m_mColumns[10] = OColumn(OUString(),"UPDATE_RULE", ColumnValue::NO_NULLS, 1,1,0, DataType::INTEGER); + m_mColumns[11] = OColumn(OUString(),"DELETE_RULE", ColumnValue::NO_NULLS, 1,1,0, DataType::INTEGER); + m_mColumns[12] = OColumn(OUString(),"FK_NAME", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[13] = OColumn(OUString(),"PK_NAME", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[14] = OColumn(OUString(),"DEFERRABILITY", ColumnValue::NO_NULLS, 1,1,0, DataType::INTEGER); +} + +void ODatabaseMetaDataResultSetMetaData::setTypeInfoMap() +{ + m_mColumns[1] = OColumn(OUString(),"TYPE_NAME", ColumnValue::NO_NULLS, 0,0,0, DataType::VARCHAR); + m_mColumns[2] = OColumn(OUString(),"DATA_TYPE", ColumnValue::NO_NULLS, 1,1,0, DataType::INTEGER); + m_mColumns[3] = OColumn(OUString(),"PRECISION", ColumnValue::NO_NULLS, 1,1,0, DataType::INTEGER); + m_mColumns[4] = OColumn(OUString(),"LITERAL_PREFIX", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[5] = OColumn(OUString(),"LITERAL_SUFFIX", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[6] = OColumn(OUString(),"CREATE_PARAMS", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[7] = OColumn(OUString(),"NULLABLE", ColumnValue::NO_NULLS, 1,1,0, DataType::INTEGER); + m_mColumns[8] = OColumn(OUString(),"CASE_SENSITIVE", ColumnValue::NO_NULLS, 1,1,0, DataType::BIT); + m_mColumns[9] = OColumn(OUString(),"SEARCHABLE", ColumnValue::NO_NULLS, 1,1,0, DataType::INTEGER); + m_mColumns[10] = OColumn(OUString(),"UNSIGNED_ATTRIBUTE", ColumnValue::NO_NULLS, 1,1,0, DataType::BIT); + m_mColumns[11] = OColumn(OUString(),"FIXED_PREC_SCALE", ColumnValue::NO_NULLS, 1,1,0, DataType::BIT); + m_mColumns[12] = OColumn(OUString(),"AUTO_INCREMENT", ColumnValue::NO_NULLS, 1,1,0, DataType::BIT); + m_mColumns[13] = OColumn(OUString(),"LOCAL_TYPE_NAME", ColumnValue::NO_NULLS, 0,0,0, DataType::VARCHAR); + m_mColumns[14] = OColumn(OUString(),"MINIMUM_SCALE", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[15] = OColumn(OUString(),"MAXIMUM_SCALE", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[16] = OColumn(OUString(),"SQL_DATA_TYPE", ColumnValue::NO_NULLS, 1,1,0, DataType::INTEGER); + m_mColumns[17] = OColumn(OUString(),"SQL_DATETIME_SUB", ColumnValue::NO_NULLS, 1,1,0, DataType::INTEGER); + m_mColumns[18] = OColumn(OUString(),"NUM_PREC_RADIX", ColumnValue::NO_NULLS, 1,1,0, DataType::INTEGER); +} + +void ODatabaseMetaDataResultSetMetaData::setProceduresMap() +{ + setProcedureNameMap(); + m_mColumns[4] = OColumn(OUString(),"RESERVED1", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[5] = OColumn(OUString(),"RESERVED2", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[6] = OColumn(OUString(),"RESERVED3", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[7] = OColumn(OUString(),"REMARKS", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[8] = OColumn(OUString(),"PROCEDURE_TYPE", ColumnValue::NO_NULLS, 1,1,0, DataType::INTEGER); +} + +void ODatabaseMetaDataResultSetMetaData::setTableTypes() +{ + m_mColumns[1] = OColumn(OUString(),"TABLE_TYPE", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); +} + +void ODatabaseMetaDataResultSetMetaData::setCatalogsMap() +{ + m_mColumns[1] = OColumn(OUString(),"TABLE_CAT", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); +} + +void ODatabaseMetaDataResultSetMetaData::setSchemasMap() +{ + m_mColumns[1] = OColumn(OUString(),"TABLE_SCHEM", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); +} + +void ODatabaseMetaDataResultSetMetaData::setVersionColumnsMap() +{ + m_mColumns[1] = OColumn(OUString(),"SCOPE", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[2] = OColumn(OUString(),"COLUMN_NAME", ColumnValue::NO_NULLS, 0,0,0, DataType::VARCHAR); + m_mColumns[3] = OColumn(OUString(),"DATA_TYPE", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[4] = OColumn(OUString(),"TYPE_NAME", ColumnValue::NO_NULLS, 0,0,0, DataType::VARCHAR); + m_mColumns[5] = OColumn(OUString(),"COLUMN_SIZE", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[6] = OColumn(OUString(),"BUFFER_LENGTH", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); + m_mColumns[7] = OColumn(OUString(),"DECIMAL_DIGITS", ColumnValue::NULLABLE, 0,0,0, DataType::INTEGER); + m_mColumns[8] = OColumn(OUString(),"PSEUDO_COLUMN", ColumnValue::NO_NULLS, 0,0,0, DataType::INTEGER); +} + +void ODatabaseMetaDataResultSetMetaData::setUDTsMap() +{ + m_mColumns[1] = OColumn(OUString(),"TYPE_CAT", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[2] = OColumn(OUString(),"TYPE_SCHEM", ColumnValue::NULLABLE, 0,0,0, DataType::VARCHAR); + m_mColumns[3] = OColumn(OUString(),"TYPE_NAME", ColumnValue::NO_NULLS, 0,0,0, DataType::VARCHAR); + m_mColumns[4] = OColumn(OUString(),"CLASS_NAME", ColumnValue::NO_NULLS, 0,0,0, DataType::VARCHAR); + m_mColumns[5] = OColumn(OUString(),"DATA_TYPE", ColumnValue::NO_NULLS, 0,0,0, DataType::VARCHAR); + m_mColumns[6] = OColumn(OUString(),"REMARKS", ColumnValue::NO_NULLS, 0,0,0, DataType::VARCHAR); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx new file mode 100644 index 000000000..2f1cabbd4 --- /dev/null +++ b/connectivity/source/commontools/FValue.cxx @@ -0,0 +1,2473 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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 { + bool isStorageCompatible(sal_Int32 _eType1, sal_Int32 _eType2) + { + bool bIsCompatible = true; + + if (_eType1 != _eType2) + { + SAL_INFO( "connectivity.commontools", "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 = false; + } + } + return bIsCompatible; + } + + bool isStorageComparable(sal_Int32 _eType1, sal_Int32 _eType2) + { + bool bIsComparable = true; + + if (_eType1 != _eType2) + { + SAL_INFO( "connectivity.commontools", "ORowSetValue::isStorageCompatible _eType1 != _eType2" ); + switch (_eType1) + { + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::LONGVARCHAR: + bIsComparable = (DataType::CHAR == _eType2) + || (DataType::VARCHAR == _eType2) + || (DataType::LONGVARCHAR == _eType2); + break; + + case DataType::DECIMAL: + case DataType::NUMERIC: + bIsComparable = (DataType::DECIMAL == _eType2) + || (DataType::NUMERIC == _eType2); + break; + + case DataType::DOUBLE: + case DataType::REAL: + bIsComparable = (DataType::DOUBLE == _eType2) + || (DataType::REAL == _eType2); + break; + + case DataType::BINARY: + case DataType::VARBINARY: + case DataType::LONGVARBINARY: + bIsComparable = (DataType::BINARY == _eType2) + || (DataType::VARBINARY == _eType2) + || (DataType::LONGVARBINARY == _eType2); + break; + + case DataType::INTEGER: + bIsComparable = (DataType::SMALLINT == _eType2) + || (DataType::TINYINT == _eType2) + || (DataType::BIT == _eType2) + || (DataType::BOOLEAN == _eType2); + break; + case DataType::SMALLINT: + bIsComparable = (DataType::TINYINT == _eType2) + || (DataType::BIT == _eType2) + || (DataType::BOOLEAN == _eType2); + break; + case DataType::TINYINT: + bIsComparable = (DataType::BIT == _eType2) + || (DataType::BOOLEAN == _eType2); + break; + + case DataType::BLOB: + case DataType::CLOB: + case DataType::OBJECT: + bIsComparable = (DataType::BLOB == _eType2) + || (DataType::CLOB == _eType2) + || (DataType::OBJECT == _eType2); + break; + + default: + bIsComparable = false; + } + } + return bIsComparable; + } +} + +void ORowSetValue::setTypeKind(sal_Int32 _eType) +{ + 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: + { + sal_Int64 nVal(getLong()); + sal_uInt64 nuVal(getULong()); + if (nVal == 0 && nuVal != 0) + (*this) = nuVal; + else + (*this) = nVal; + 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: + { + sal_Int32 nVal(getInt32()); + sal_uInt32 nuVal(getUInt32()); + if (nVal == 0 && nuVal != 0) + (*this) = nuVal; + else + (*this) = nVal; + 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) = makeAny(); + break; + default: + (*this) = makeAny(); + SAL_WARN( "connectivity.commontools","ORowSetValue::setTypeKind(): UNSUPPORTED TYPE!"); + } + } + + m_eTypeKind = _eType; +} + + +void ORowSetValue::free() noexcept +{ + if(m_bNull) + return; + + 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 = nullptr; + break; + case DataType::DATE: + delete static_cast(m_aValue.m_pValue); + m_aValue.m_pValue = nullptr; + break; + case DataType::TIME: + delete static_cast(m_aValue.m_pValue); + m_aValue.m_pValue = nullptr; + break; + case DataType::TIMESTAMP: + delete static_cast(m_aValue.m_pValue); + m_aValue.m_pValue = nullptr; + break; + case DataType::BINARY: + case DataType::VARBINARY: + case DataType::LONGVARBINARY: + delete static_cast*>(m_aValue.m_pValue); + m_aValue.m_pValue = nullptr; + break; + case DataType::BLOB: + case DataType::CLOB: + case DataType::OBJECT: + delete static_cast(m_aValue.m_pValue); + m_aValue.m_pValue = nullptr; + break; + case DataType::BIT: + case DataType::TINYINT: + case DataType::SMALLINT: + case DataType::INTEGER: + case DataType::BIGINT: + case DataType::BOOLEAN: + case DataType::FLOAT: + case DataType::DOUBLE: + case DataType::REAL: + break; + default: + if ( m_aValue.m_pValue ) + { + delete static_cast(m_aValue.m_pValue); + m_aValue.m_pValue = nullptr; + } + break; + + } + m_bNull = 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::DATE: + m_aValue.m_pValue = new Date(*static_cast(_rRH.m_aValue.m_pValue)); + break; + case DataType::TIME: + m_aValue.m_pValue = new Time(*static_cast(_rRH.m_aValue.m_pValue)); + break; + case DataType::TIMESTAMP: + m_aValue.m_pValue = new DateTime(*static_cast(_rRH.m_aValue.m_pValue)); + break; + case DataType::BINARY: + case DataType::VARBINARY: + case DataType::LONGVARBINARY: + m_aValue.m_pValue = new Sequence(*static_cast*>(_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_uInt8 = _rRH.m_aValue.m_uInt8; + break; + case DataType::SMALLINT: + if ( _rRH.m_bSigned ) + m_aValue.m_nInt16 = _rRH.m_aValue.m_nInt16; + else + m_aValue.m_uInt16 = _rRH.m_aValue.m_uInt16; + break; + case DataType::INTEGER: + if ( _rRH.m_bSigned ) + m_aValue.m_nInt32 = _rRH.m_aValue.m_nInt32; + else + m_aValue.m_uInt32 = _rRH.m_aValue.m_uInt32; + break; + case DataType::BIGINT: + if ( _rRH.m_bSigned ) + m_aValue.m_nInt64 = _rRH.m_aValue.m_nInt64; + else + m_aValue.m_uInt64 = _rRH.m_aValue.m_uInt64; + break; + case DataType::FLOAT: + m_aValue.m_nFloat = _rRH.m_aValue.m_nFloat; + break; + case DataType::DOUBLE: + case DataType::REAL: + m_aValue.m_nDouble = _rRH.m_aValue.m_nDouble; + break; + default: + m_aValue.m_pValue = new Any(*static_cast(_rRH.m_aValue.m_pValue)); + } + } + 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) = OUString(_rRH.m_aValue.m_pString); + break; + case DataType::DATE: + (*this) = *static_cast(_rRH.m_aValue.m_pValue); + break; + case DataType::TIME: + (*this) = *static_cast(_rRH.m_aValue.m_pValue); + break; + case DataType::TIMESTAMP: + (*this) = *static_cast(_rRH.m_aValue.m_pValue); + break; + case DataType::BINARY: + case DataType::VARBINARY: + case DataType::LONGVARBINARY: + (*this) = *static_cast*>(_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_uInt8 = _rRH.m_aValue.m_uInt8; + break; + case DataType::SMALLINT: + if ( _rRH.m_bSigned ) + m_aValue.m_nInt16 = _rRH.m_aValue.m_nInt16; + else + m_aValue.m_uInt16 = _rRH.m_aValue.m_uInt16; + break; + case DataType::INTEGER: + if ( _rRH.m_bSigned ) + m_aValue.m_nInt32 = _rRH.m_aValue.m_nInt32; + else + m_aValue.m_uInt32 = _rRH.m_aValue.m_uInt32; + break; + case DataType::BIGINT: + if ( _rRH.m_bSigned ) + m_aValue.m_nInt64 = _rRH.m_aValue.m_nInt64; + else + m_aValue.m_uInt64 = _rRH.m_aValue.m_uInt64; + break; + case DataType::FLOAT: + m_aValue.m_nFloat = _rRH.m_aValue.m_nFloat; + break; + case DataType::DOUBLE: + case DataType::REAL: + m_aValue.m_nDouble = _rRH.m_aValue.m_nDouble; + break; + default: + *static_cast(m_aValue.m_pValue) = *static_cast(_rRH.m_aValue.m_pValue); + } + } + + m_bNull = _rRH.m_bNull; + // OJ: BUGID: 96277 + m_eTypeKind = _rRH.m_eTypeKind; + + return *this; +} + +ORowSetValue& ORowSetValue::operator=(ORowSetValue&& _rRH) noexcept +{ + if ( m_eTypeKind != _rRH.m_eTypeKind || !m_bNull) + free(); + if(!_rRH.m_bNull) + { + m_aValue = _rRH.m_aValue; + memset(&_rRH.m_aValue, 0, sizeof(_rRH.m_aValue)); + } + m_bBound = _rRH.m_bBound; + m_eTypeKind = _rRH.m_eTypeKind; + m_bSigned = _rRH.m_bSigned; + m_bNull = _rRH.m_bNull; + _rRH.m_bNull = true; + return *this; +} + + +ORowSetValue& ORowSetValue::operator=(const Date& _rRH) +{ + if(m_eTypeKind != DataType::DATE) + free(); + + if(m_bNull) + { + m_aValue.m_pValue = new Date(_rRH); + m_eTypeKind = DataType::DATE; + m_bNull = false; + } + else + *static_cast(m_aValue.m_pValue) = _rRH; + + return *this; +} + +ORowSetValue& ORowSetValue::operator=(const css::util::Time& _rRH) +{ + if(m_eTypeKind != DataType::TIME) + free(); + + if(m_bNull) + { + m_aValue.m_pValue = new Time(_rRH); + m_eTypeKind = DataType::TIME; + m_bNull = false; + } + else + *static_cast(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); + m_eTypeKind = DataType::TIMESTAMP; + m_bNull = false; + } + else + *static_cast(m_aValue.m_pValue) = _rRH; + + return *this; +} + + +ORowSetValue& ORowSetValue::operator=(const OUString& _rRH) +{ + if(m_eTypeKind != DataType::VARCHAR || m_aValue.m_pString != _rRH.pData) + { + free(); + m_bNull = false; + + m_aValue.m_pString = _rRH.pData; + rtl_uString_acquire(m_aValue.m_pString); + m_eTypeKind = DataType::VARCHAR; + } + + return *this; +} + + +ORowSetValue& ORowSetValue::operator=(double _rRH) +{ + if(m_eTypeKind != DataType::DOUBLE) + free(); + + m_aValue.m_nDouble = _rRH; + m_eTypeKind = DataType::DOUBLE; + m_bNull = false; + + return *this; +} + +ORowSetValue& ORowSetValue::operator=(float _rRH) +{ + if(m_eTypeKind != DataType::FLOAT) + free(); + + m_aValue.m_nFloat = _rRH; + m_eTypeKind = DataType::FLOAT; + m_bNull = false; + + return *this; +} + + +ORowSetValue& ORowSetValue::operator=(sal_Int8 _rRH) +{ + if(m_eTypeKind != DataType::TINYINT ) + free(); + + m_aValue.m_nInt8 = _rRH; + m_eTypeKind = DataType::TINYINT; + m_bNull = false; + m_bSigned = true; + return *this; +} + +ORowSetValue& ORowSetValue::operator=(sal_Int16 _rRH) +{ + if(m_eTypeKind != DataType::SMALLINT ) + free(); + + m_aValue.m_nInt16 = _rRH; + m_eTypeKind = DataType::SMALLINT; + m_bNull = false; + m_bSigned = true; + + return *this; +} + + +ORowSetValue& ORowSetValue::operator=(sal_uInt16 _rRH) +{ + if(m_eTypeKind != DataType::SMALLINT ) + free(); + + m_aValue.m_uInt16 = _rRH; + m_eTypeKind = DataType::SMALLINT; + m_bNull = false; + m_bSigned = false; + + return *this; +} + + +ORowSetValue& ORowSetValue::operator=(sal_Int32 _rRH) +{ + if(m_eTypeKind != DataType::INTEGER ) + free(); + + m_aValue.m_nInt32 = _rRH; + + m_eTypeKind = DataType::INTEGER; + m_bNull = false; + m_bSigned = true; + + return *this; +} + + +ORowSetValue& ORowSetValue::operator=(sal_uInt32 _rRH) +{ + if(m_eTypeKind != DataType::INTEGER ) + free(); + + m_aValue.m_uInt32 = _rRH; + + m_eTypeKind = DataType::INTEGER; + m_bNull = false; + m_bSigned = false; + + return *this; +} + + +ORowSetValue& ORowSetValue::operator=(const bool _rRH) +{ + if(m_eTypeKind != DataType::BIT && DataType::BOOLEAN != m_eTypeKind ) + free(); + + m_aValue.m_bBool = _rRH; + m_eTypeKind = DataType::BOOLEAN; + m_bNull = false; + + return *this; +} + +ORowSetValue& ORowSetValue::operator=(sal_Int64 _rRH) +{ + if ( DataType::BIGINT != m_eTypeKind) + free(); + + m_aValue.m_nInt64 = _rRH; + m_eTypeKind = DataType::BIGINT; + m_bNull = false; + m_bSigned = true; + + return *this; +} + +ORowSetValue& ORowSetValue::operator=(sal_uInt64 _rRH) +{ + if ( DataType::BIGINT != m_eTypeKind) + free(); + + m_aValue.m_uInt64 = _rRH; + m_eTypeKind = DataType::BIGINT; + m_bNull = false; + m_bSigned = false; + + return *this; +} + +ORowSetValue& ORowSetValue::operator=(const Sequence& _rRH) +{ + if (!isStorageCompatible(DataType::LONGVARBINARY,m_eTypeKind)) + free(); + + if (m_bNull) + { + m_aValue.m_pValue = new Sequence(_rRH); + } + else + *static_cast< Sequence< sal_Int8 >* >(m_aValue.m_pValue) = _rRH; + + m_eTypeKind = DataType::LONGVARBINARY; + m_bNull = 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); + } + else + *static_cast(m_aValue.m_pValue) = _rAny; + + m_eTypeKind = DataType::OBJECT; + m_bNull = false; + + return *this; +} + + +bool ORowSetValue::operator==(const ORowSetValue& _rRH) const +{ + if ( m_bNull != _rRH.isNull() ) + return false; + + if(m_bNull && _rRH.isNull()) + return true; + + if ( !isStorageComparable(m_eTypeKind, _rRH.m_eTypeKind )) + { + switch(m_eTypeKind) + { + case DataType::FLOAT: + case DataType::DOUBLE: + case DataType::REAL: + return getDouble() == _rRH.getDouble(); + default: + switch(_rRH.m_eTypeKind) + { + case DataType::FLOAT: + case DataType::DOUBLE: + case DataType::REAL: + return getDouble() == _rRH.getDouble(); + default: + break; + } + break; + } + return false; + } + + bool bRet = false; + OSL_ENSURE(!m_bNull,"Should not be null!"); + switch(m_eTypeKind) + { + case DataType::VARCHAR: + case DataType::CHAR: + case DataType::LONGVARCHAR: + { + OUString aVal1(m_aValue.m_pString); + OUString aVal2(_rRH.m_aValue.m_pString); + return aVal1 == aVal2; + } + default: + if ( m_bSigned != _rRH.m_bSigned ) + return false; + break; + } + + switch(m_eTypeKind) + { + case DataType::DECIMAL: + case DataType::NUMERIC: + { + OUString aVal1(m_aValue.m_pString); + OUString aVal2(_rRH.m_aValue.m_pString); + bRet = aVal1 == aVal2; + } + break; + case DataType::FLOAT: + bRet = m_aValue.m_nFloat == _rRH.m_aValue.m_nFloat; + break; + case DataType::DOUBLE: + case DataType::REAL: + bRet = m_aValue.m_nDouble == _rRH.m_aValue.m_nDouble; + break; + case DataType::TINYINT: + bRet = m_bSigned ? ( m_aValue.m_nInt8 == _rRH.m_aValue.m_nInt8 ) : (m_aValue.m_uInt8 == _rRH.m_aValue.m_uInt8); + break; + case DataType::SMALLINT: + bRet = m_bSigned ? ( m_aValue.m_nInt16 == _rRH.m_aValue.m_nInt16 ) : (m_aValue.m_uInt16 == _rRH.m_aValue.m_uInt16); + break; + case DataType::INTEGER: + bRet = m_bSigned ? ( m_aValue.m_nInt32 == _rRH.m_aValue.m_nInt32 ) : (m_aValue.m_uInt32 == _rRH.m_aValue.m_uInt32); + break; + case DataType::BIGINT: + bRet = m_bSigned ? ( m_aValue.m_nInt64 == _rRH.m_aValue.m_nInt64 ) : (m_aValue.m_uInt64 == _rRH.m_aValue.m_uInt64); + break; + case DataType::BIT: + case DataType::BOOLEAN: + bRet = m_aValue.m_bBool == _rRH.m_aValue.m_bBool; + break; + case DataType::DATE: + bRet = *static_cast(m_aValue.m_pValue) == *static_cast(_rRH.m_aValue.m_pValue); + break; + case DataType::TIME: + bRet = *static_cast(m_aValue.m_pValue) == *static_cast(_rRH.m_aValue.m_pValue); + break; + case DataType::TIMESTAMP: + bRet = *static_cast(m_aValue.m_pValue) == *static_cast(_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; + SAL_WARN( "connectivity.commontools","ORowSetValue::operator==(): UNSUPPORTED TYPE!"); + break; + } + return bRet; +} + +Any ORowSetValue::makeAny() const +{ + Any rValue; + if(isBound() && !isNull()) + { + switch(getTypeKind()) + { + case DataType::SQLNULL: + assert(rValue == Any()); + break; + 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 <<= OUString(m_aValue.m_pString); + break; + case DataType::FLOAT: + rValue <<= m_aValue.m_nFloat; + break; + case DataType::DOUBLE: + case DataType::REAL: + rValue <<= m_aValue.m_nDouble; + break; + case DataType::DATE: + OSL_ENSURE(m_aValue.m_pValue,"Value is null!"); + rValue <<= *static_cast(m_aValue.m_pValue); + break; + case DataType::TIME: + OSL_ENSURE(m_aValue.m_pValue,"Value is null!"); + rValue <<= *static_cast(m_aValue.m_pValue); + break; + case DataType::TIMESTAMP: + OSL_ENSURE(m_aValue.m_pValue,"Value is null!"); + rValue <<= *static_cast(m_aValue.m_pValue); + break; + case DataType::BINARY: + case DataType::VARBINARY: + case DataType::LONGVARBINARY: + OSL_ENSURE(m_aValue.m_pValue,"Value is null!"); + rValue <<= *static_cast*>(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 <<= m_aValue.m_bBool; + break; + case DataType::TINYINT: + if ( m_bSigned ) + // TypeClass_BYTE + rValue <<= m_aValue.m_nInt8; + else + // There is no TypeClass_UNSIGNED_BYTE, + // so silently promote it to a 16-bit integer, + // that is TypeClass_UNSIGNED_SHORT + rValue <<= static_cast(m_aValue.m_uInt8); + break; + case DataType::SMALLINT: + if ( m_bSigned ) + // TypeClass_SHORT + rValue <<= m_aValue.m_nInt16; + else + // TypeClass_UNSIGNED_SHORT + rValue <<= m_aValue.m_uInt16; + break; + case DataType::INTEGER: + if ( m_bSigned ) + // TypeClass_LONG + rValue <<= m_aValue.m_nInt32; + else + // TypeClass_UNSIGNED_LONG + rValue <<= m_aValue.m_uInt32; + break; + case DataType::BIGINT: + if ( m_bSigned ) + // TypeClass_HYPER + rValue <<= m_aValue.m_nInt64; + else + // TypeClass_UNSIGNED_HYPER + rValue <<= m_aValue.m_uInt64; + break; + default: + SAL_WARN( "connectivity.commontools","ORowSetValue::makeAny(): UNSUPPORTED TYPE!"); + rValue = getAny(); + break; + } + } + return rValue; +} + +OUString ORowSetValue::getString( ) const +{ + 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::FLOAT: + aRet = OUString::number(static_cast(*this)); + break; + case DataType::DOUBLE: + case DataType::REAL: + aRet = OUString::number(static_cast(*this)); + break; + case DataType::DATE: + aRet = DBTypeConversion::toDateString(*this); + break; + case DataType::TIME: + aRet = DBTypeConversion::toTimeString(*this); + break; + case DataType::TIMESTAMP: + aRet = DBTypeConversion::toDateTimeString(*this); + break; + case DataType::BINARY: + case DataType::VARBINARY: + case DataType::LONGVARBINARY: + { + OUStringBuffer sVal("0x"); + Sequence aSeq(getSequence()); + const sal_Int8* pBegin = aSeq.getConstArray(); + const sal_Int8* pEnd = pBegin + aSeq.getLength(); + for(;pBegin != pEnd;++pBegin) + sVal.append(static_cast(*pBegin),16); + aRet = sVal.makeStringAndClear(); + } + break; + case DataType::BIT: + aRet = OUString::number(int(static_cast(*this))); + break; + case DataType::BOOLEAN: + aRet = OUString::boolean(static_cast(*this)); + break; + case DataType::TINYINT: + case DataType::SMALLINT: + case DataType::INTEGER: + if ( m_bSigned ) + aRet = OUString::number(static_cast(*this)); + else + aRet = OUString::number(static_cast(*this)); + break; + case DataType::BIGINT: + if ( m_bSigned ) + aRet = OUString::number(static_cast(*this)); + else + aRet = OUString::number(static_cast(*this)); + break; + case DataType::CLOB: + { + Any aValue( getAny() ); + Reference< XClob > xClob; + if ( (aValue >>= xClob) && xClob.is() ) + { + aRet = xClob->getSubString(1,static_cast(xClob->length()) ); + } + } + break; + default: + { + Any aValue = makeAny(); + aValue >>= aRet; + break; + } + } + } + return aRet; +} + +bool ORowSetValue::getBool() const +{ + bool bRet = false; + if(!m_bNull) + { + switch(getTypeKind()) + { + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::LONGVARCHAR: + { + const OUString sValue(m_aValue.m_pString); + if ( sValue.equalsIgnoreAsciiCase("true") || (sValue == "1") ) + { + bRet = true; + break; + } + else if ( sValue.equalsIgnoreAsciiCase("false") || (sValue == "0") ) + { + bRet = false; + break; + } + } + [[fallthrough]]; + case DataType::DECIMAL: + case DataType::NUMERIC: + + bRet = OUString(m_aValue.m_pString).toInt32() != 0; + break; + case DataType::FLOAT: + bRet = m_aValue.m_nFloat != 0.0; + break; + case DataType::DOUBLE: + case DataType::REAL: + bRet = m_aValue.m_nDouble != 0.0; + break; + case DataType::DATE: + case DataType::TIME: + case DataType::TIMESTAMP: + case DataType::BINARY: + case DataType::VARBINARY: + case DataType::LONGVARBINARY: + OSL_FAIL("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_uInt8 != 0); + break; + case DataType::SMALLINT: + bRet = m_bSigned ? (m_aValue.m_nInt16 != 0) : (m_aValue.m_uInt16 != 0); + break; + case DataType::INTEGER: + bRet = m_bSigned ? (m_aValue.m_nInt32 != 0) : (m_aValue.m_uInt32 != 0); + break; + case DataType::BIGINT: + bRet = m_bSigned ? (m_aValue.m_nInt64 != 0) : (m_aValue.m_uInt64 != 0); + break; + default: + { + Any aValue = makeAny(); + aValue >>= bRet; + break; + } + } + } + return bRet; +} + + +sal_Int8 ORowSetValue::getInt8() const +{ + 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(OUString(m_aValue.m_pString).toInt32()); + break; + case DataType::FLOAT: + nRet = sal_Int8(m_aValue.m_nFloat); + break; + case DataType::DOUBLE: + case DataType::REAL: + nRet = sal_Int8(m_aValue.m_nDouble); + 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_FAIL("getInt8() for this type is not allowed!"); + break; + case DataType::BIT: + case DataType::BOOLEAN: + nRet = sal_Int8(m_aValue.m_bBool); + break; + case DataType::TINYINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt8; + else + nRet = static_cast(m_aValue.m_uInt8); + break; + case DataType::SMALLINT: + if ( m_bSigned ) + nRet = static_cast(m_aValue.m_nInt16); + else + nRet = static_cast(m_aValue.m_uInt16); + break; + case DataType::INTEGER: + if ( m_bSigned ) + nRet = static_cast(m_aValue.m_nInt32); + else + nRet = static_cast(m_aValue.m_uInt32); + break; + case DataType::BIGINT: + if ( m_bSigned ) + nRet = static_cast(m_aValue.m_nInt64); + else + nRet = static_cast(m_aValue.m_uInt64); + break; + default: + { + Any aValue = makeAny(); + aValue >>= nRet; + break; + } + } + } + return nRet; +} + + +sal_uInt8 ORowSetValue::getUInt8() const +{ + sal_uInt8 nRet = 0; + if(!m_bNull) + { + switch(getTypeKind()) + { + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::DECIMAL: + case DataType::NUMERIC: + case DataType::LONGVARCHAR: + nRet = sal_uInt8(OUString(m_aValue.m_pString).toInt32()); + break; + case DataType::FLOAT: + nRet = sal_uInt8(m_aValue.m_nFloat); + break; + case DataType::DOUBLE: + case DataType::REAL: + nRet = sal_uInt8(m_aValue.m_nDouble); + 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_FAIL("getuInt8() for this type is not allowed!"); + break; + case DataType::BIT: + case DataType::BOOLEAN: + nRet = int(m_aValue.m_bBool); + break; + case DataType::TINYINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt8; + else + nRet = m_aValue.m_uInt8; + break; + case DataType::SMALLINT: + if ( m_bSigned ) + nRet = static_cast(m_aValue.m_nInt16); + else + nRet = static_cast(m_aValue.m_uInt16); + break; + case DataType::INTEGER: + if ( m_bSigned ) + nRet = static_cast(m_aValue.m_nInt32); + else + nRet = static_cast(m_aValue.m_uInt32); + break; + case DataType::BIGINT: + if ( m_bSigned ) + nRet = static_cast(m_aValue.m_nInt64); + else + nRet = static_cast(m_aValue.m_uInt64); + break; + default: + { + Any aValue = makeAny(); + // Cf. "There is no TypeClass_UNSIGNED_BYTE" in makeAny: + sal_uInt16 n; + if (aValue >>= n) { + nRet = static_cast(n); + } + break; + } + } + } + return nRet; +} + + +sal_Int16 ORowSetValue::getInt16() const +{ + 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(OUString(m_aValue.m_pString).toInt32()); + break; + case DataType::FLOAT: + nRet = sal_Int16(m_aValue.m_nFloat); + break; + case DataType::DOUBLE: + case DataType::REAL: + nRet = sal_Int16(m_aValue.m_nDouble); + 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_FAIL("getInt16() for this type is not allowed!"); + break; + case DataType::BIT: + case DataType::BOOLEAN: + nRet = sal_Int16(m_aValue.m_bBool); + break; + case DataType::TINYINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt8; + else + nRet = m_aValue.m_uInt8; + break; + case DataType::SMALLINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt16; + else + nRet = static_cast(m_aValue.m_uInt16); + break; + case DataType::INTEGER: + if ( m_bSigned ) + nRet = static_cast(m_aValue.m_nInt32); + else + nRet = static_cast(m_aValue.m_uInt32); + break; + case DataType::BIGINT: + if ( m_bSigned ) + nRet = static_cast(m_aValue.m_nInt64); + else + nRet = static_cast(m_aValue.m_uInt64); + break; + default: + { + Any aValue = makeAny(); + aValue >>= nRet; + break; + } + } + } + return nRet; +} + + +sal_uInt16 ORowSetValue::getUInt16() const +{ + sal_uInt16 nRet = 0; + if(!m_bNull) + { + switch(getTypeKind()) + { + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::DECIMAL: + case DataType::NUMERIC: + case DataType::LONGVARCHAR: + nRet = sal_uInt16(OUString(m_aValue.m_pString).toInt32()); + break; + case DataType::FLOAT: + nRet = sal_uInt16(m_aValue.m_nFloat); + break; + case DataType::DOUBLE: + case DataType::REAL: + nRet = sal_uInt16(m_aValue.m_nDouble); + 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_FAIL("getuInt16() for this type is not allowed!"); + break; + case DataType::BIT: + case DataType::BOOLEAN: + nRet = sal_uInt16(m_aValue.m_bBool); + break; + case DataType::TINYINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt8; + else + nRet = m_aValue.m_uInt8; + break; + case DataType::SMALLINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt16; + else + nRet = m_aValue.m_uInt16; + break; + case DataType::INTEGER: + if ( m_bSigned ) + nRet = static_cast(m_aValue.m_nInt32); + else + nRet = static_cast(m_aValue.m_uInt32); + break; + case DataType::BIGINT: + if ( m_bSigned ) + nRet = static_cast(m_aValue.m_nInt64); + else + nRet = static_cast(m_aValue.m_uInt64); + break; + default: + { + Any aValue = makeAny(); + aValue >>= nRet; + break; + } + } + } + return nRet; +} + + +sal_Int32 ORowSetValue::getInt32() const +{ + 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 = OUString(m_aValue.m_pString).toInt32(); + break; + case DataType::FLOAT: + nRet = sal_Int32(m_aValue.m_nFloat); + break; + case DataType::DOUBLE: + case DataType::REAL: + nRet = sal_Int32(m_aValue.m_nDouble); + break; + case DataType::DATE: + nRet = dbtools::DBTypeConversion::toDays(*static_cast(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_FAIL("getInt32() for this type is not allowed!"); + break; + case DataType::BIT: + case DataType::BOOLEAN: + nRet = sal_Int32(m_aValue.m_bBool); + break; + case DataType::TINYINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt8; + else + nRet = m_aValue.m_uInt8; + break; + case DataType::SMALLINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt16; + else + nRet = m_aValue.m_uInt16; + break; + case DataType::INTEGER: + if ( m_bSigned ) + nRet = m_aValue.m_nInt32; + else + nRet = static_cast(m_aValue.m_uInt32); + break; + case DataType::BIGINT: + if ( m_bSigned ) + nRet = static_cast(m_aValue.m_nInt64); + else + nRet = static_cast(m_aValue.m_uInt64); + break; + default: + { + Any aValue = makeAny(); + aValue >>= nRet; + break; + } + } + } + return nRet; +} + + +sal_uInt32 ORowSetValue::getUInt32() const +{ + sal_uInt32 nRet = 0; + if(!m_bNull) + { + switch(getTypeKind()) + { + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::DECIMAL: + case DataType::NUMERIC: + case DataType::LONGVARCHAR: + nRet = OUString(m_aValue.m_pString).toUInt32(); + break; + case DataType::FLOAT: + nRet = sal_uInt32(m_aValue.m_nFloat); + break; + case DataType::DOUBLE: + case DataType::REAL: + nRet = sal_uInt32(m_aValue.m_nDouble); + break; + case DataType::DATE: + nRet = dbtools::DBTypeConversion::toDays(*static_cast(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_FAIL("getuInt32() for this type is not allowed!"); + break; + case DataType::BIT: + case DataType::BOOLEAN: + nRet = sal_uInt32(m_aValue.m_bBool); + break; + case DataType::TINYINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt8; + else + nRet = m_aValue.m_uInt8; + break; + case DataType::SMALLINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt16; + else + nRet = m_aValue.m_uInt16; + break; + case DataType::INTEGER: + if ( m_bSigned ) + nRet = m_aValue.m_nInt32; + else + nRet = m_aValue.m_uInt32; + break; + case DataType::BIGINT: + if ( m_bSigned ) + nRet = static_cast(m_aValue.m_nInt64); + else + nRet = static_cast(m_aValue.m_uInt64); + break; + default: + { + Any aValue = makeAny(); + aValue >>= nRet; + break; + } + } + } + return nRet; +} + + +sal_Int64 ORowSetValue::getLong() const +{ + 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 = OUString(m_aValue.m_pString).toInt64(); + break; + case DataType::FLOAT: + nRet = sal_Int64(m_aValue.m_nFloat); + break; + case DataType::DOUBLE: + case DataType::REAL: + nRet = sal_Int64(m_aValue.m_nDouble); + break; + case DataType::DATE: + nRet = dbtools::DBTypeConversion::toDays(*static_cast(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_FAIL("getLong() for this type is not allowed!"); + break; + case DataType::BIT: + case DataType::BOOLEAN: + nRet = sal_Int64(m_aValue.m_bBool); + break; + case DataType::TINYINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt8; + else + nRet = m_aValue.m_uInt8; + break; + case DataType::SMALLINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt16; + else + nRet = m_aValue.m_uInt16; + break; + case DataType::INTEGER: + if ( m_bSigned ) + nRet = m_aValue.m_nInt32; + else + nRet = m_aValue.m_uInt32; + break; + case DataType::BIGINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt64; + else + nRet = static_cast(m_aValue.m_uInt64); + break; + default: + { + Any aValue = makeAny(); + aValue >>= nRet; + break; + } + } + } + return nRet; +} + + +sal_uInt64 ORowSetValue::getULong() const +{ + sal_uInt64 nRet = 0; + if(!m_bNull) + { + switch(getTypeKind()) + { + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::DECIMAL: + case DataType::NUMERIC: + case DataType::LONGVARCHAR: + nRet = OUString(m_aValue.m_pString).toUInt64(); + break; + case DataType::FLOAT: + nRet = sal_uInt64(m_aValue.m_nFloat); + break; + case DataType::DOUBLE: + case DataType::REAL: + nRet = sal_uInt64(m_aValue.m_nDouble); + break; + case DataType::DATE: + nRet = dbtools::DBTypeConversion::toDays(*static_cast(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_FAIL("getULong() for this type is not allowed!"); + break; + case DataType::BIT: + case DataType::BOOLEAN: + nRet = sal_uInt64(m_aValue.m_bBool); + break; + case DataType::TINYINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt8; + else + nRet = m_aValue.m_uInt8; + break; + case DataType::SMALLINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt16; + else + nRet = m_aValue.m_uInt16; + break; + case DataType::INTEGER: + if ( m_bSigned ) + nRet = m_aValue.m_nInt32; + else + nRet = m_aValue.m_uInt32; + break; + case DataType::BIGINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt64; + else + nRet = m_aValue.m_uInt64; + break; + default: + { + Any aValue = makeAny(); + aValue >>= nRet; + break; + } + } + } + return nRet; +} + + +float ORowSetValue::getFloat() const +{ + float nRet = 0; + if(!m_bNull) + { + switch(getTypeKind()) + { + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::DECIMAL: + case DataType::NUMERIC: + case DataType::LONGVARCHAR: + nRet = OUString(m_aValue.m_pString).toFloat(); + break; + case DataType::FLOAT: + nRet = m_aValue.m_nFloat; + break; + case DataType::DOUBLE: + case DataType::REAL: + nRet = static_cast(m_aValue.m_nDouble); + break; + case DataType::DATE: + nRet = static_cast(dbtools::DBTypeConversion::toDouble(*static_cast(m_aValue.m_pValue))); + break; + case DataType::TIME: + nRet = static_cast(dbtools::DBTypeConversion::toDouble(*static_cast(m_aValue.m_pValue))); + break; + case DataType::TIMESTAMP: + nRet = static_cast(dbtools::DBTypeConversion::toDouble(*static_cast(m_aValue.m_pValue))); + break; + case DataType::BINARY: + case DataType::VARBINARY: + case DataType::LONGVARBINARY: + case DataType::BLOB: + case DataType::CLOB: + OSL_FAIL("getDouble() for this type is not allowed!"); + break; + case DataType::BIT: + case DataType::BOOLEAN: + nRet = float(m_aValue.m_bBool); + break; + case DataType::TINYINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt8; + else + nRet = m_aValue.m_uInt8; + break; + case DataType::SMALLINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt16; + else + nRet = static_cast(m_aValue.m_uInt16); + break; + case DataType::INTEGER: + if ( m_bSigned ) + nRet = static_cast(m_aValue.m_nInt32); + else + nRet = static_cast(m_aValue.m_uInt32); + break; + case DataType::BIGINT: + if ( m_bSigned ) + nRet = static_cast(m_aValue.m_nInt64); + else + nRet = static_cast(m_aValue.m_uInt64); + break; + default: + { + Any aValue = makeAny(); + aValue >>= nRet; + break; + } + } + } + return nRet; +} + +double ORowSetValue::getDouble() const +{ + double nRet = 0; + if(!m_bNull) + { + switch(getTypeKind()) + { + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::DECIMAL: + case DataType::NUMERIC: + case DataType::LONGVARCHAR: + nRet = OUString(m_aValue.m_pString).toDouble(); + break; + case DataType::FLOAT: + nRet = m_aValue.m_nFloat; + break; + case DataType::DOUBLE: + case DataType::REAL: + nRet = m_aValue.m_nDouble; + break; + case DataType::DATE: + nRet = dbtools::DBTypeConversion::toDouble(*static_cast(m_aValue.m_pValue)); + break; + case DataType::TIME: + nRet = dbtools::DBTypeConversion::toDouble(*static_cast(m_aValue.m_pValue)); + break; + case DataType::TIMESTAMP: + nRet = dbtools::DBTypeConversion::toDouble(*static_cast(m_aValue.m_pValue)); + break; + case DataType::BINARY: + case DataType::VARBINARY: + case DataType::LONGVARBINARY: + case DataType::BLOB: + case DataType::CLOB: + OSL_FAIL("getDouble() for this type is not allowed!"); + break; + case DataType::BIT: + case DataType::BOOLEAN: + nRet = double(m_aValue.m_bBool); + break; + case DataType::TINYINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt8; + else + nRet = m_aValue.m_uInt8; + break; + case DataType::SMALLINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt16; + else + nRet = m_aValue.m_uInt16; + break; + case DataType::INTEGER: + if ( m_bSigned ) + nRet = m_aValue.m_nInt32; + else + nRet = m_aValue.m_uInt32; + break; + case DataType::BIGINT: + if ( m_bSigned ) + nRet = m_aValue.m_nInt64; + else + nRet = m_aValue.m_uInt64; + break; + default: + { + Any aValue = makeAny(); + aValue >>= nRet; + break; + } + } + } + return nRet; +} + +Sequence ORowSetValue::getSequence() const +{ + Sequence aSeq; + if (!m_bNull) + { + switch(m_eTypeKind) + { + case DataType::OBJECT: + case DataType::CLOB: + case DataType::BLOB: + { + Reference xStream; + const Any aValue = makeAny(); + if(aValue.hasValue()) + { + Reference xBlob(aValue,UNO_QUERY); + if ( xBlob.is() ) + xStream = xBlob->getBinaryStream(); + else + { + Reference xClob(aValue,UNO_QUERY); + if ( xClob.is() ) + xStream = xClob->getCharacterStream(); + } + if(xStream.is()) + { + const sal_uInt32 nBytesToRead = 65535; + sal_uInt32 nRead; + + do + { + css::uno::Sequence< sal_Int8 > aReadSeq; + + nRead = xStream->readSomeBytes( aReadSeq, nBytesToRead ); + + if( nRead ) + { + const sal_uInt32 nOldLength = aSeq.getLength(); + aSeq.realloc( nOldLength + nRead ); + memcpy( aSeq.getArray() + nOldLength, aReadSeq.getConstArray(), aReadSeq.getLength() ); + } + } + while( nBytesToRead == nRead ); + xStream->closeInput(); + } + } + } + break; + case DataType::VARCHAR: + case DataType::LONGVARCHAR: + { + aSeq = Sequence(reinterpret_cast(m_aValue.m_pString->buffer), + sizeof(sal_Unicode) * m_aValue.m_pString->length); + } + break; + case DataType::BINARY: + case DataType::VARBINARY: + case DataType::LONGVARBINARY: + aSeq = *static_cast< Sequence*>(m_aValue.m_pValue); + break; + default: + { + Any aValue = makeAny(); + aValue >>= aSeq; + break; + } + } + } + return aSeq; + +} + +css::util::Date ORowSetValue::getDate() const +{ + css::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: + case DataType::FLOAT: + case DataType::DOUBLE: + case DataType::REAL: + aValue = DBTypeConversion::toDate(static_cast(*this)); + break; + + case DataType::DATE: + aValue = *static_cast< css::util::Date*>(m_aValue.m_pValue); + break; + case DataType::TIMESTAMP: + { + css::util::DateTime* pDateTime = static_cast< css::util::DateTime*>(m_aValue.m_pValue); + aValue.Day = pDateTime->Day; + aValue.Month = pDateTime->Month; + aValue.Year = pDateTime->Year; + } + break; + case DataType::BIT: + case DataType::BOOLEAN: + case DataType::TINYINT: + case DataType::SMALLINT: + case DataType::INTEGER: + case DataType::BIGINT: + aValue = DBTypeConversion::toDate( double( sal_Int64( *this ) ) ); + break; + + case DataType::BLOB: + case DataType::CLOB: + case DataType::OBJECT: + default: + OSL_ENSURE( false, "ORowSetValue::getDate: cannot retrieve the data!" ); + [[fallthrough]]; + + case DataType::BINARY: + case DataType::VARBINARY: + case DataType::LONGVARBINARY: + case DataType::TIME: + aValue = DBTypeConversion::toDate( double(0) ); + break; + } + } + return aValue; +} + +css::util::Time ORowSetValue::getTime() const +{ + css::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(static_cast(*this)); + break; + case DataType::FLOAT: + case DataType::DOUBLE: + case DataType::REAL: + aValue = DBTypeConversion::toTime(static_cast(*this)); + break; + case DataType::TIMESTAMP: + { + css::util::DateTime* pDateTime = static_cast< css::util::DateTime*>(m_aValue.m_pValue); + aValue.NanoSeconds = pDateTime->NanoSeconds; + aValue.Seconds = pDateTime->Seconds; + aValue.Minutes = pDateTime->Minutes; + aValue.Hours = pDateTime->Hours; + } + break; + case DataType::TIME: + aValue = *static_cast< css::util::Time*>(m_aValue.m_pValue); + break; + default: + { + Any aAnyValue = makeAny(); + aAnyValue >>= aValue; + break; + } + } + } + return aValue; +} + +css::util::DateTime ORowSetValue::getDateTime() const +{ + css::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(static_cast(*this)); + break; + case DataType::FLOAT: + case DataType::DOUBLE: + case DataType::REAL: + aValue = DBTypeConversion::toDateTime(static_cast(*this)); + break; + case DataType::DATE: + { + css::util::Date* pDate = static_cast< css::util::Date*>(m_aValue.m_pValue); + aValue.Day = pDate->Day; + aValue.Month = pDate->Month; + aValue.Year = pDate->Year; + } + break; + case DataType::TIME: + { + css::util::Time* pTime = static_cast< css::util::Time*>(m_aValue.m_pValue); + aValue.NanoSeconds = pTime->NanoSeconds; + aValue.Seconds = pTime->Seconds; + aValue.Minutes = pTime->Minutes; + aValue.Hours = pTime->Hours; + } + break; + case DataType::TIMESTAMP: + aValue = *static_cast< css::util::DateTime*>(m_aValue.m_pValue); + break; + default: + { + Any aAnyValue = makeAny(); + aAnyValue >>= aValue; + break; + } + } + } + return aValue; +} + +void ORowSetValue::setSigned(bool _bMod) +{ + if ( m_bSigned == _bMod ) + return; + + m_bSigned = _bMod; + if ( m_bNull ) + return; + + sal_Int32 nType = m_eTypeKind; + switch(m_eTypeKind) + { + 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; + case DataType::BIGINT: + { + if ( m_bSigned ) + { + auto nTmp = static_cast(m_aValue.m_uInt64); + m_aValue.m_nInt64 = nTmp; + } + else + { + auto nTmp = static_cast(m_aValue.m_nInt64); + m_aValue.m_uInt64 = nTmp; + } + break; + } + } + m_eTypeKind = nType; +} + + +namespace detail +{ + class SAL_NO_VTABLE IValueSource + { + public: + virtual OUString getString() const = 0; + virtual 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 css::util::Time getTime() const = 0; + virtual DateTime getTimestamp() const = 0; + virtual Sequence< sal_Int8 > getBytes() const = 0; + virtual Reference< XBlob > getBlob() const = 0; + virtual Reference< XClob > getClob() const = 0; + virtual Any getObject() const = 0; + virtual bool wasNull() const = 0; + + virtual ~IValueSource() { } + }; + + namespace { + + class RowValue : public IValueSource + { + public: + RowValue( const Reference< XRow >& _xRow, const sal_Int32 _nPos ) + :m_xRow( _xRow ) + ,m_nPos( _nPos ) + { + } + + // IValueSource + virtual OUString getString() const override { return m_xRow->getString( m_nPos ); }; + virtual bool getBoolean() const override { return m_xRow->getBoolean( m_nPos ); }; + virtual sal_Int8 getByte() const override { return m_xRow->getByte( m_nPos ); }; + virtual sal_Int16 getShort() const override { return m_xRow->getShort( m_nPos ); } + virtual sal_Int32 getInt() const override { return m_xRow->getInt( m_nPos ); } + virtual sal_Int64 getLong() const override { return m_xRow->getLong( m_nPos ); } + virtual float getFloat() const override { return m_xRow->getFloat( m_nPos ); }; + virtual double getDouble() const override { return m_xRow->getDouble( m_nPos ); }; + virtual Date getDate() const override { return m_xRow->getDate( m_nPos ); }; + virtual css::util::Time getTime() const override { return m_xRow->getTime( m_nPos ); }; + virtual DateTime getTimestamp() const override { return m_xRow->getTimestamp( m_nPos ); }; + virtual Sequence< sal_Int8 > getBytes() const override { return m_xRow->getBytes( m_nPos ); }; + virtual Reference< XBlob > getBlob() const override { return m_xRow->getBlob( m_nPos ); }; + virtual Reference< XClob > getClob() const override { return m_xRow->getClob( m_nPos ); }; + virtual Any getObject() const override { return m_xRow->getObject( m_nPos ,nullptr); }; + virtual bool wasNull() const override { return m_xRow->wasNull( ); }; + + private: + const Reference< XRow > m_xRow; + const sal_Int32 m_nPos; + }; + + class ColumnValue : public IValueSource + { + public: + explicit ColumnValue( const Reference< XColumn >& _rxColumn ) + :m_xColumn( _rxColumn ) + { + } + + // IValueSource + virtual OUString getString() const override { return m_xColumn->getString(); }; + virtual bool getBoolean() const override { return m_xColumn->getBoolean(); }; + virtual sal_Int8 getByte() const override { return m_xColumn->getByte(); }; + virtual sal_Int16 getShort() const override { return m_xColumn->getShort(); } + virtual sal_Int32 getInt() const override { return m_xColumn->getInt(); } + virtual sal_Int64 getLong() const override { return m_xColumn->getLong(); } + virtual float getFloat() const override { return m_xColumn->getFloat(); }; + virtual double getDouble() const override { return m_xColumn->getDouble(); }; + virtual Date getDate() const override { return m_xColumn->getDate(); }; + virtual css::util::Time getTime() const override { return m_xColumn->getTime(); }; + virtual DateTime getTimestamp() const override { return m_xColumn->getTimestamp(); }; + virtual Sequence< sal_Int8 > getBytes() const override { return m_xColumn->getBytes(); }; + virtual Reference< XBlob > getBlob() const override { return m_xColumn->getBlob(); }; + virtual Reference< XClob > getClob() const override { return m_xColumn->getClob(); }; + virtual Any getObject() const override { return m_xColumn->getObject( nullptr ); }; + virtual bool wasNull() const override { 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, true, aColumnValue ); +} + + +void ORowSetValue::fill( sal_Int32 _nPos, sal_Int32 _nType, 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 css::uno::Reference< css::sdbc::XRow>& _xRow) +{ + fill(_nPos,_nType,true,_xRow); +} + + +void ORowSetValue::impl_fill( const sal_Int32 _nType, bool _bNullable, const detail::IValueSource& _rValueSource ) +{ + 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 + // TODO: this is rather horrible performance-wise + // but fixing it needs extending the css::sdbc::XRow API + // to have a getULong(), and needs updating all drivers :-| + // When doing that, add getUByte, getUShort, getUInt for symmetry/completeness + (*this) = _rValueSource.getString().toUInt64(); + 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) = css::uno::makeAny(_rValueSource.getClob()); + setTypeKind(DataType::CLOB); + break; + case DataType::BLOB: + (*this) = css::uno::makeAny(_rValueSource.getBlob()); + setTypeKind(DataType::BLOB); + break; + case DataType::OTHER: + (*this) = _rValueSource.getObject(); + setTypeKind(DataType::OTHER); + break; + default: + SAL_WARN( "connectivity.commontools", "ORowSetValue::fill: unsupported type!" ); + (*this) = _rValueSource.getObject(); + break; + } + if ( _bNullable && _rValueSource.wasNull() ) + setNull(); + setTypeKind(_nType); +} + +void ORowSetValue::fill(const Any& _rValue) +{ + switch (_rValue.getValueType().getTypeClass()) + { + case TypeClass_VOID: + setNull(); break; + case TypeClass_BOOLEAN: + { + bool bValue( false ); + _rValue >>= bValue; + (*this) = bValue; + break; + } + case TypeClass_CHAR: + { + sal_Unicode aDummy(0); + _rValue >>= aDummy; + (*this) = OUString(aDummy); + break; + } + case TypeClass_STRING: + { + 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_UNSIGNED_SHORT: + { + sal_uInt16 nValue(0); + _rValue >>= nValue; + (*this) = nValue; + break; + } + case TypeClass_LONG: + { + sal_Int32 aDummy(0); + _rValue >>= aDummy; + (*this) = aDummy; + break; + } + case TypeClass_UNSIGNED_LONG: + { + sal_uInt32 nValue(0); + _rValue >>= nValue; + (*this) = static_cast(nValue); + setSigned(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) = nValue; + setSigned(false); + break; + } + case TypeClass_ENUM: + { + sal_Int32 enumValue( 0 ); + ::cppu::enum2int( enumValue, _rValue ); + (*this) = enumValue; + } + break; + + case TypeClass_SEQUENCE: + { + Sequence aDummy; + if ( _rValue >>= aDummy ) + (*this) = aDummy; + else + SAL_WARN( "connectivity.commontools", "ORowSetValue::fill: unsupported sequence type!" ); + break; + } + + case TypeClass_STRUCT: + { + css::util::Date aDate; + css::util::Time aTime; + css::util::DateTime aDateTime; + if ( _rValue >>= aDate ) + { + (*this) = aDate; + } + else if ( _rValue >>= aTime ) + { + (*this) = aTime; + } + else if ( _rValue >>= aDateTime ) + { + (*this) = aDateTime; + } + else + SAL_WARN( "connectivity.commontools", "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: + SAL_WARN( "connectivity.commontools","Unknown type"); + break; + } +} + +} // namespace connectivity + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/ParameterSubstitution.cxx b/connectivity/source/commontools/ParameterSubstitution.cxx new file mode 100644 index 000000000..9adf63a93 --- /dev/null +++ b/connectivity/source/commontools/ParameterSubstitution.cxx @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include +#include +#include +#include + +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 css::uno::Reference< css::uno::XComponentContext >& _rxContext ) : m_xContext(_rxContext) + { + } + void SAL_CALL ParameterSubstitution::initialize( const uno::Sequence< uno::Any >& _aArguments ) + { + ::osl::MutexGuard aGuard(m_aMutex); + comphelper::SequenceAsHashMap aArgs(_aArguments); + uno::Reference< sdbc::XConnection > xConnection; + xConnection = aArgs.getUnpackedValueOrDefault("ActiveConnection",xConnection); + m_xConnection = xConnection; + } + + OUString ParameterSubstitution::getImplementationName_Static( ) + { + return "org.openoffice.comp.helper.ParameterSubstitution"; + } + + OUString SAL_CALL ParameterSubstitution::getImplementationName( ) + { + return getImplementationName_Static(); + } + + sal_Bool SAL_CALL ParameterSubstitution::supportsService( const OUString& _rServiceName ) + { + return cppu::supportsService(this, _rServiceName); + } + + Sequence< OUString > SAL_CALL ParameterSubstitution::getSupportedServiceNames( ) + { + return getSupportedServiceNames_Static(); + } + + Sequence< OUString > ParameterSubstitution::getSupportedServiceNames_Static( ) + { + return { "com.sun.star.sdb.ParameterSubstitution" }; + } + + + Reference< XInterface > ParameterSubstitution::create(const Reference< XComponentContext >& _xContext) + { + return *(new ParameterSubstitution(_xContext)); + } + + OUString SAL_CALL ParameterSubstitution::substituteVariables( const OUString& _sText, sal_Bool /*bSubstRequired*/ ) + { + OUString sRet = _sText; + uno::Reference< sdbc::XConnection > xConnection = m_xConnection; + if ( xConnection.is() ) + { + try + { + OSQLParser aParser( m_xContext ); + OUString sErrorMessage; + OUString sNewSql; + std::unique_ptr pNode = aParser.parseTree(sErrorMessage,_sText); + if(pNode) + { // special handling for parameters + OSQLParseNode::substituteParameterNames(pNode.get()); + pNode->parseNodeToStr( sNewSql, xConnection ); + sRet = sNewSql; + } + } + catch(const Exception&) + { + } + } + return sRet; + } + + OUString SAL_CALL ParameterSubstitution::reSubstituteVariables( const OUString& _sText ) + { + return _sText; + } + + OUString SAL_CALL ParameterSubstitution::getSubstituteVariableValue( const OUString& /*variable*/ ) + { + throw container::NoSuchElementException(); + } + + +} // connectivity + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/RowFunctionParser.cxx b/connectivity/source/commontools/RowFunctionParser.cxx new file mode 100644 index 000000000..21f5e638a --- /dev/null +++ b/connectivity/source/commontools/RowFunctionParser.cxx @@ -0,0 +1,441 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +// 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 OSL_DEBUG_LEVEL >= 2 && defined(DBG_UTIL) +#include +#define BOOST_SPIRIT_DEBUG +#endif +#include +#include +#include + + +#if (OSL_DEBUG_LEVEL > 0) +#include +#endif +#include +#include + +namespace connectivity +{ +using namespace com::sun::star; + +namespace +{ + + +// EXPRESSION NODES + + +class ConstantValueExpression : public ExpressionNode +{ + ORowSetValueDecoratorRef maValue; + +public: + + explicit ConstantValueExpression( ORowSetValueDecoratorRef const & rValue ) : + maValue( rValue ) + { + } + virtual ORowSetValueDecoratorRef evaluate(const ODatabaseMetaDataResultSet::ORow& /*_aRow*/ ) const override + { + return maValue; + } + virtual void fill(const ODatabaseMetaDataResultSet::ORow& /*_aRow*/ ) const override + { + } +}; + + +/** ExpressionNode implementation for unary + function over two ExpressionNodes + */ +class BinaryFunctionExpression : public ExpressionNode +{ + const ExpressionFunct meFunct; + std::shared_ptr mpFirstArg; + std::shared_ptr mpSecondArg; + +public: + + BinaryFunctionExpression( const ExpressionFunct eFunct, const std::shared_ptr& rFirstArg, const std::shared_ptr& rSecondArg ) : + meFunct( eFunct ), + mpFirstArg( rFirstArg ), + mpSecondArg( rSecondArg ) + { + } + virtual ORowSetValueDecoratorRef evaluate(const ODatabaseMetaDataResultSet::ORow& _aRow ) const override + { + ORowSetValueDecoratorRef aRet; + switch(meFunct) + { + case ExpressionFunct::Equation: + aRet = new ORowSetValueDecorator( mpFirstArg->evaluate(_aRow )->getValue() == mpSecondArg->evaluate(_aRow )->getValue() ); + break; + case ExpressionFunct::And: + aRet = new ORowSetValueDecorator( mpFirstArg->evaluate(_aRow )->getValue().getBool() && mpSecondArg->evaluate(_aRow )->getValue().getBool() ); + break; + case ExpressionFunct::Or: + aRet = new ORowSetValueDecorator( mpFirstArg->evaluate(_aRow )->getValue().getBool() || mpSecondArg->evaluate(_aRow )->getValue().getBool() ); + break; + default: + break; + } + return aRet; + } + virtual void fill(const ODatabaseMetaDataResultSet::ORow& _aRow ) const override + { + switch(meFunct) + { + case ExpressionFunct::Equation: + (*mpFirstArg->evaluate(_aRow )) = mpSecondArg->evaluate(_aRow )->getValue(); + break; + default: + break; + } + } +}; + + +// FUNCTION PARSER + + +typedef const char* StringIteratorT; + +struct ParserContext +{ + typedef std::stack< std::shared_ptr > 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 std::shared_ptr< ParserContext > ParserContextSharedPtr; + +/** Generate apriori constant value + */ + +class ConstantFunctor +{ + ParserContextSharedPtr mpContext; + +public: + + explicit ConstantFunctor( const ParserContextSharedPtr& rContext ) : + mpContext( rContext ) + { + } + void operator()( StringIteratorT rFirst,StringIteratorT rSecond) const + { + OUString sVal( rFirst, rSecond - rFirst, RTL_TEXTENCODING_UTF8 ); + mpContext->maOperandStack.push( std::make_shared( new ORowSetValueDecorator( sVal ) ) ); + } +}; + +/** Generate parse-dependent-but-then-constant value + */ +class IntConstantFunctor +{ + ParserContextSharedPtr mpContext; + +public: + explicit IntConstantFunctor( const ParserContextSharedPtr& rContext ) : + mpContext( rContext ) + { + } + void operator()( sal_Int32 n ) const + { + mpContext->maOperandStack.push( std::make_shared( new ORowSetValueDecorator( n ) ) ); + } +}; + +/** 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 + std::shared_ptr pSecondArg( std::move(rNodeStack.top()) ); + rNodeStack.pop(); + std::shared_ptr pFirstArg( std::move(rNodeStack.top()) ); + rNodeStack.pop(); + + // create combined ExpressionNode + auto pNode = std::make_shared( meFunct, pFirstArg, pSecondArg ); + // check for constness + rNodeStack.push( pNode ); + } +}; +/** ExpressionNode implementation for unary + function over one ExpressionNode + */ +class UnaryFunctionExpression : public ExpressionNode +{ + std::shared_ptr mpArg; + +public: + explicit UnaryFunctionExpression( const std::shared_ptr& rArg ) : + mpArg( rArg ) + { + } + virtual ORowSetValueDecoratorRef evaluate(const ODatabaseMetaDataResultSet::ORow& _aRow ) const override + { + return _aRow[mpArg->evaluate(_aRow )->getValue().getUInt32()]; + } + virtual void fill(const ODatabaseMetaDataResultSet::ORow& /*_aRow*/ ) const override + { + } +}; + +class UnaryFunctionFunctor +{ + ParserContextSharedPtr mpContext; + +public: + + explicit UnaryFunctionFunctor(const ParserContextSharedPtr& rContext) + : mpContext(rContext) + { + } + void operator()( StringIteratorT, StringIteratorT ) const + { + + ParserContext::OperandStack& rNodeStack( mpContext->maOperandStack ); + + if( rNodeStack.empty() ) + throw ParseError( "Not enough arguments for unary operator" ); + + // retrieve arguments + std::shared_ptr pArg( std::move(rNodeStack.top()) ); + rNodeStack.pop(); + + rNodeStack.push( std::make_shared( 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::classic::grammar< ExpressionGrammar > +{ +public: + /** Create an arithmetic expression grammar + + @param rParserContext + Contains context info for the parser + */ + explicit ExpressionGrammar( const ParserContextSharedPtr& rParserContext ) : + mpParserContext( rParserContext ) + { + } + + template< typename ScannerT > class definition + { + public: + // grammar definition + explicit definition( const ExpressionGrammar& self ) + { + using ::boost::spirit::classic::space_p; + using ::boost::spirit::classic::range_p; + using ::boost::spirit::classic::lexeme_d; + using ::boost::spirit::classic::ch_p; + using ::boost::spirit::classic::int_p; + using ::boost::spirit::classic::as_lower_d; + using ::boost::spirit::classic::strlit; + using ::boost::spirit::classic::inhibit_case; + + + typedef inhibit_case > 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( self.getContext()) ] + ; + + assignment = + unaryFunction >> ch_p('=') >> argument + [ BinaryFunctionFunctor( ExpressionFunct::Equation, self.getContext()) ] + ; + + andExpression = + assignment + | ( '(' >> orExpression >> ')' ) + | ( assignment >> AND_ >> assignment ) [ BinaryFunctionFunctor( ExpressionFunct::And, self.getContext()) ] + ; + + orExpression = + andExpression + | ( orExpression >> OR_ >> andExpression ) [ BinaryFunctionFunctor( ExpressionFunct::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::classic::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::classic::rule< ScannerT > basicExpression; + ::boost::spirit::classic::rule< ScannerT > unaryFunction; + ::boost::spirit::classic::rule< ScannerT > assignment; + ::boost::spirit::classic::rule< ScannerT > integer,argument; + ::boost::spirit::classic::rule< ScannerT > orExpression,andExpression; + }; + + const ParserContextSharedPtr& getContext() const + { + return mpParserContext; + } + +private: + ParserContextSharedPtr mpParserContext; // might get modified during parsing +}; + +const ParserContextSharedPtr& getParserContext() +{ + static ParserContextSharedPtr lcl_parserContext = std::make_shared(); + + // 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; +} + +} + +std::shared_ptr const & FunctionParser::parseFunction( const 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 OString& rAsciiFunction( + OUStringToOString( _sFunction, RTL_TEXTENCODING_ASCII_US ) ); + + StringIteratorT aStart( rAsciiFunction.getStr() ); + StringIteratorT aEnd( rAsciiFunction.getStr()+rAsciiFunction.getLength() ); + + // static parser context, because the actual + // Spirit parser is also a static object + ParserContextSharedPtr pContext = getParserContext(); + + ExpressionGrammar aExpressionGrammer( pContext ); + + const ::boost::spirit::classic::parse_info aParseInfo( + ::boost::spirit::classic::parse( aStart, + aEnd, + aExpressionGrammer, + ::boost::spirit::classic::space_p ) ); + +#if (OSL_DEBUG_LEVEL > 0) + std::cout.flush(); // needed to keep stdout and cout in sync +#endif + + // 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(); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/TColumnsHelper.cxx b/connectivity/source/commontools/TColumnsHelper.cxx new file mode 100644 index 000000000..a97faeeb8 --- /dev/null +++ b/connectivity/source/commontools/TColumnsHelper.cxx @@ -0,0 +1,208 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +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; + +namespace connectivity +{ + class OColumnsHelperImpl + { + public: + explicit OColumnsHelperImpl(bool _bCase) + : m_aColumnInfo(_bCase) + { + } + ColumnInformationMap m_aColumnInfo; + }; +} + +OColumnsHelper::OColumnsHelper( ::cppu::OWeakObject& _rParent + ,bool _bCase + ,::osl::Mutex& _rMutex + ,const ::std::vector< OUString> &_rVector + ,bool _bUseHardRef + ) : OCollection(_rParent,_bCase,_rMutex,_rVector,false,_bUseHardRef) + ,m_pTable(nullptr) +{ +} + +OColumnsHelper::~OColumnsHelper() +{ +} + + +sdbcx::ObjectType OColumnsHelper::createObject(const OUString& _rName) +{ + OSL_ENSURE(m_pTable,"NO Table set. Error!"); + Reference xConnection = m_pTable->getConnection(); + + if ( !m_pImpl ) + m_pImpl.reset(new OColumnsHelperImpl(isCaseSensitive())); + + bool bQueryInfo = true; + bool bAutoIncrement = false; + bool bIsCurrency = false; + sal_Int32 nDataType = DataType::OTHER; + + ColumnInformationMap::const_iterator aFind = m_pImpl->m_aColumnInfo.find(_rName); + if ( aFind == m_pImpl->m_aColumnInfo.end() ) // we have to fill it + { + OUString sComposedName = ::dbtools::composeTableNameForSelect( xConnection, m_pTable ); + collectColumnInformation(xConnection,sComposedName,"*" ,m_pImpl->m_aColumnInfo); + aFind = m_pImpl->m_aColumnInfo.find(_rName); + } + if ( aFind != m_pImpl->m_aColumnInfo.end() ) + { + bQueryInfo = 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 xPr = m_pTable; + const Reference 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() ) + ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap(); + OUString aCatalog, aSchema, aTable; + m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)) >>= aCatalog; + m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema; + m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable; + connectivity::sdbcx::OColumn* pRet = new connectivity::sdbcx::OColumn(_rName, + pColDesc->aField6, + pColDesc->sField13, + pColDesc->sField12, + nField11, + pColDesc->nField7, + pColDesc->nField9, + pColDesc->nField5, + bAutoIncrement, + false, + bIsCurrency, + isCaseSensitive(), + aCatalog, + aSchema, + aTable); + + xRet = pRet; + } + else + { + + xRet = ::dbtools::createSDBCXColumn( m_pTable, + xConnection, + _rName, + isCaseSensitive(), + bQueryInfo, + bAutoIncrement, + bIsCurrency, + nDataType); + } + return xRet; +} + + +void OColumnsHelper::impl_refresh() +{ + if ( m_pTable ) + { + m_pImpl->m_aColumnInfo.clear(); + m_pTable->refreshColumns(); + } +} + +Reference< XPropertySet > OColumnsHelper::createDescriptor() +{ + return new OColumn(true); +} + +// XAppend +sdbcx::ObjectType OColumnsHelper::appendObject( const 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 xMetaData = m_pTable->getConnection()->getMetaData(); + OUString aSql = "ALTER TABLE " + + ::dbtools::composeTableName( xMetaData, m_pTable, ::dbtools::EComposeRule::InTableDefinitions, true ) + + " ADD " + + ::dbtools::createStandardColumnPart(descriptor,m_pTable->getConnection(),nullptr,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 OUString& _sElementName) +{ + OSL_ENSURE(m_pTable,"OColumnsHelper::dropByName: Table is null!"); + if ( !(m_pTable && !m_pTable->isNew()) ) + return; + + Reference xMetaData = m_pTable->getConnection()->getMetaData(); + OUString aQuote = xMetaData->getIdentifierQuoteString( ); + OUString aSql = "ALTER TABLE " + + ::dbtools::composeTableName( xMetaData, m_pTable, ::dbtools::EComposeRule::InTableDefinitions, true ) + + " DROP " + + ::dbtools::quoteName( aQuote,_sElementName); + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + if ( xStmt.is() ) + { + xStmt->execute(aSql); + ::comphelper::disposeComponent(xStmt); + } +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/TConnection.cxx b/connectivity/source/commontools/TConnection.cxx new file mode 100644 index 000000000..134aa5960 --- /dev/null +++ b/connectivity/source/commontools/TConnection.cxx @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include + +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 (auto const& statement : m_aStatements) + { + try + { + Reference< XInterface > xStatement( statement.get() ); + ::comphelper::disposeComponent( xStatement ); + } + catch (const DisposedException&) + { + } + } + m_aStatements.clear(); +} +//XUnoTunnel +sal_Int64 SAL_CALL OMetaConnection::getSomething( const css::uno::Sequence< sal_Int8 >& rId ) +{ + return (isUnoTunnelId(rId)) + ? reinterpret_cast< sal_Int64 >( this ) + : sal_Int64(0); +} + +Sequence< sal_Int8 > OMetaConnection::getUnoTunnelId() +{ + static ::cppu::OImplementationId implId; + + return implId.getImplementationId(); +} + +::dbtools::OPropertyMap& OMetaConnection::getPropMap() +{ + static ::dbtools::OPropertyMap s_aPropertyNameMap; + return s_aPropertyNameMap; +} + +void OMetaConnection::throwGenericSQLException(const char* pErrorResourceId, const Reference< XInterface>& _xContext ) +{ + OUString sErrorMessage; + if (pErrorResourceId) + sErrorMessage = m_aResources.getResourceString(pErrorResourceId); + Reference< XInterface> xContext = _xContext; + if ( !xContext.is() ) + xContext = *this; + ::dbtools::throwGenericSQLException( sErrorMessage, xContext); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/TDatabaseMetaDataBase.cxx b/connectivity/source/commontools/TDatabaseMetaDataBase.cxx new file mode 100644 index 000000000..e58232780 --- /dev/null +++ b/connectivity/source/commontools/TDatabaseMetaDataBase.cxx @@ -0,0 +1,326 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +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 comphelper; +using namespace connectivity; + + +ODatabaseMetaDataBase::ODatabaseMetaDataBase(const Reference< XConnection >& _rxConnection,const Sequence< PropertyValue >& _rInfo) + : m_aConnectionInfo(_rInfo) + ,m_isCatalogAtStart(false,false) + ,m_sCatalogSeparator(false,OUString()) + ,m_sIdentifierQuoteString(false,OUString()) + ,m_supportsCatalogsInTableDefinitions(false,false) + ,m_supportsSchemasInTableDefinitions(false,false) + ,m_supportsCatalogsInDataManipulation(false,false) + ,m_supportsSchemasInDataManipulation(false,false) + ,m_supportsMixedCaseQuotedIdentifiers(false,false) + ,m_supportsAlterTableWithAddColumn(false,false) + ,m_supportsAlterTableWithDropColumn(false,false) + ,m_MaxStatements(false,0) + ,m_MaxTablesInSelect(false,0) + ,m_storesMixedCaseQuotedIdentifiers(false,false) + , m_xConnection(_rxConnection) +{ + osl_atomic_increment( &m_refCount ); + { + m_xListenerHelper = new OEventListenerHelper(this); + Reference xCom(m_xConnection,UNO_QUERY); + if(xCom.is()) + xCom->addEventListener(m_xListenerHelper); + } + osl_atomic_decrement( &m_refCount ); +} + +ODatabaseMetaDataBase::~ODatabaseMetaDataBase() +{ +} + + +Sequence< PropertyValue > SAL_CALL ODatabaseMetaDataBase::getConnectionInfo( ) +{ + return m_aConnectionInfo; +} + + +void SAL_CALL ODatabaseMetaDataBase::disposing( const EventObject& /*Source*/ ) +{ + // cut off all references to the connection +m_xConnection.clear(); +m_xListenerHelper.clear(); +} + +Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getTypeInfo( ) +{ + ::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("TypeInfoSettings",aTypeInfoSettings); + + if ( xRow.is() ) + { + static const 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> 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 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()); + const sal_Int32* pType = pTypes; + for (sal_Int32 i = 1; i <= sal_Int32(SAL_N_ELEMENTS(pTypes)); ++i,++pType) + { + ORowSetValue aValue; + aValue.fill(i,*pType,xRow); + aRow.push_back(new ORowSetValueDecorator(aValue)); + } + + std::vector>::iterator aIter = aConditions.begin(); + std::vector>::const_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 OUString& /*schema*/, const OUString& /*table*/ ) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eExportedKeys ); +} + +Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getImportedKeys( + const Any& /*catalog*/, const OUString& /*schema*/, const OUString& /*table*/ ) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eImportedKeys ); +} + +Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getPrimaryKeys( + const Any& /*catalog*/, const OUString& /*schema*/, const OUString& /*table*/ ) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::ePrimaryKeys ); +} + +Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getIndexInfo( + const Any& /*catalog*/, const OUString& /*schema*/, const OUString& /*table*/, + sal_Bool /*unique*/, sal_Bool /*approximate*/ ) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eIndexInfo ); +} + +Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getBestRowIdentifier( + const Any& /*catalog*/, const OUString& /*schema*/, const OUString& /*table*/, sal_Int32 /*scope*/, + sal_Bool /*nullable*/ ) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eBestRowIdentifier ); +} + +Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getCrossReference( + const Any& /*primaryCatalog*/, const OUString& /*primarySchema*/, + const OUString& /*primaryTable*/, const Any& /*foreignCatalog*/, + const OUString& /*foreignSchema*/, const OUString& /*foreignTable*/ ) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCrossReference ); +} + +Reference< XConnection > SAL_CALL ODatabaseMetaDataBase::getConnection( ) +{ + return m_xConnection; +} + +Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getProcedureColumns( + const Any& /*catalog*/, const OUString& /*schemaPattern*/, + const OUString& /*procedureNamePattern*/, const OUString& /*columnNamePattern*/ ) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedureColumns ); +} + +Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getProcedures( + const Any& /*catalog*/, const OUString& /*schemaPattern*/, + const OUString& /*procedureNamePattern*/ ) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedures ); +} + +Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getVersionColumns( + const Any& /*catalog*/, const OUString& /*schema*/, const OUString& /*table*/ ) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eVersionColumns ); +} + +Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getSchemas( ) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eSchemas ); +} + +Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getColumnPrivileges( + const Any& /*catalog*/, const OUString& /*schema*/, const OUString& /*table*/, + const OUString& /*columnNamePattern*/ ) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumnPrivileges ); +} + +Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getTablePrivileges( + const Any& /*catalog*/, const OUString& /*schema*/, const OUString& /*table*/) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges ); +} + +Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getCatalogs( ) +{ + return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCatalogs ); +} + +OUString SAL_CALL ODatabaseMetaDataBase::getIdentifierQuoteString( ) +{ + return callImplMethod(m_sIdentifierQuoteString,std::function(&ODatabaseMetaDataBase::impl_getIdentifierQuoteString_throw)); +} + +sal_Bool SAL_CALL ODatabaseMetaDataBase::isCatalogAtStart( ) +{ + return callImplMethod(m_isCatalogAtStart,std::function(&ODatabaseMetaDataBase::impl_isCatalogAtStart_throw)); +} + +OUString SAL_CALL ODatabaseMetaDataBase::getCatalogSeparator( ) +{ + return callImplMethod(m_sCatalogSeparator,std::function(&ODatabaseMetaDataBase::impl_getCatalogSeparator_throw)); +} + +sal_Bool SAL_CALL ODatabaseMetaDataBase::supportsCatalogsInTableDefinitions( ) +{ + return callImplMethod(m_supportsCatalogsInTableDefinitions,std::function(&ODatabaseMetaDataBase::impl_supportsCatalogsInTableDefinitions_throw)); +} + +sal_Bool SAL_CALL ODatabaseMetaDataBase::supportsSchemasInTableDefinitions( ) +{ + return callImplMethod(m_supportsSchemasInTableDefinitions,std::function(&ODatabaseMetaDataBase::impl_supportsSchemasInTableDefinitions_throw)); +} + +sal_Bool SAL_CALL ODatabaseMetaDataBase::supportsCatalogsInDataManipulation( ) +{ + return callImplMethod(m_supportsCatalogsInDataManipulation,std::function(&ODatabaseMetaDataBase::impl_supportsCatalogsInDataManipulation_throw)); +} + +sal_Bool SAL_CALL ODatabaseMetaDataBase::supportsSchemasInDataManipulation( ) +{ + return callImplMethod(m_supportsSchemasInDataManipulation,std::function(&ODatabaseMetaDataBase::impl_supportsSchemasInDataManipulation_throw)); +} + +sal_Bool SAL_CALL ODatabaseMetaDataBase::supportsMixedCaseQuotedIdentifiers( ) +{ + return callImplMethod(m_supportsMixedCaseQuotedIdentifiers,std::function(&ODatabaseMetaDataBase::impl_supportsMixedCaseQuotedIdentifiers_throw)); +} + +sal_Bool SAL_CALL ODatabaseMetaDataBase::supportsAlterTableWithAddColumn( ) +{ + return callImplMethod(m_supportsAlterTableWithAddColumn,std::function(&ODatabaseMetaDataBase::impl_supportsAlterTableWithAddColumn_throw)); +} + +sal_Bool SAL_CALL ODatabaseMetaDataBase::supportsAlterTableWithDropColumn( ) +{ + return callImplMethod(m_supportsAlterTableWithDropColumn,std::function(&ODatabaseMetaDataBase::impl_supportsAlterTableWithDropColumn_throw)); +} + +sal_Int32 SAL_CALL ODatabaseMetaDataBase::getMaxStatements( ) +{ + return callImplMethod(m_MaxStatements,std::function(&ODatabaseMetaDataBase::impl_getMaxStatements_throw)); +} + +sal_Int32 SAL_CALL ODatabaseMetaDataBase::getMaxTablesInSelect( ) +{ + return callImplMethod(m_MaxTablesInSelect,std::function(&ODatabaseMetaDataBase::impl_getMaxTablesInSelect_throw)); +} + +sal_Bool SAL_CALL ODatabaseMetaDataBase::storesMixedCaseQuotedIdentifiers( ) +{ + return callImplMethod(m_storesMixedCaseQuotedIdentifiers,std::function(&ODatabaseMetaDataBase::impl_storesMixedCaseQuotedIdentifiers_throw)); +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/TIndex.cxx b/connectivity/source/commontools/TIndex.cxx new file mode 100644 index 000000000..f7f891308 --- /dev/null +++ b/connectivity/source/commontools/TIndex.cxx @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include + +using namespace connectivity; +using namespace connectivity::sdbcx; +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; + +OIndexHelper::OIndexHelper( OTableHelper* _pTable) : connectivity::sdbcx::OIndex(true) + , m_pTable(_pTable) +{ + construct(); + std::vector< OUString> aVector; + m_pColumns.reset(new OIndexColumns(this,m_aMutex,aVector)); +} + +OIndexHelper::OIndexHelper( OTableHelper* _pTable, + const OUString& Name, + const OUString& Catalog, + bool _isUnique, + bool _isPrimaryKeyIndex, + bool _isClustered + ) : connectivity::sdbcx::OIndex(Name, + Catalog, + _isUnique, + _isPrimaryKeyIndex, + _isClustered,true) + ,m_pTable(_pTable) +{ + construct(); + refreshColumns(); +} + + +void OIndexHelper::refreshColumns() +{ + if ( !m_pTable ) + return; + + std::vector< OUString> aVector; + if ( !isNew() ) + { + ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap(); + 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,false,false); + + if ( xResult.is() ) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + 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.reset(new OIndexColumns(this,m_aMutex,aVector)); +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/TIndexColumns.cxx b/connectivity/source/commontools/TIndexColumns.cxx new file mode 100644 index 000000000..bbb5ca706 --- /dev/null +++ b/connectivity/source/commontools/TIndexColumns.cxx @@ -0,0 +1,115 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include +#include + +using namespace connectivity; +using namespace connectivity::sdbcx; +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; + +OIndexColumns::OIndexColumns( OIndexHelper* _pIndex, + ::osl::Mutex& _rMutex, + const std::vector< OUString> &_rVector) + : connectivity::sdbcx::OCollection(*_pIndex,true,_rMutex,_rVector) + ,m_pIndex(_pIndex) +{ +} + +sdbcx::ObjectType OIndexColumns::createObject(const OUString& _rName) +{ + ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap(); + OUString aCatalog, aSchema, aTable; + css::uno::Any Catalog(m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME))); + Catalog >>= aCatalog; + 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( + Catalog, aSchema, aTable, false, false); + + bool bAsc = true; + if ( xResult.is() ) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while( xResult->next() ) + { + if(xRow->getString(9) == _rName) + bAsc = xRow->getString(10) != "D"; + } + } + + xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getColumns( + Catalog, 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); + OUString aTypeName(xRow->getString(6)); + sal_Int32 nSize = xRow->getInt(7); + sal_Int32 nDec = xRow->getInt(9); + sal_Int32 nNull = xRow->getInt(11); + OUString aColumnDef(xRow->getString(13)); + + OIndexColumn* pRet = new OIndexColumn(bAsc, + _rName, + aTypeName, + aColumnDef, + nNull, + nSize, + nDec, + nDataType, + true, + aCatalog, aSchema, aTable); + xRet = pRet; + break; + } + } + } + + return xRet; +} + +Reference< XPropertySet > OIndexColumns::createDescriptor() +{ + return new OIndexColumn(true); +} + +void OIndexColumns::impl_refresh() +{ + m_pIndex->refreshColumns(); +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/TIndexes.cxx b/connectivity/source/commontools/TIndexes.cxx new file mode 100644 index 000000000..f5cff00ec --- /dev/null +++ b/connectivity/source/commontools/TIndexes.cxx @@ -0,0 +1,248 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +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; + + +OIndexesHelper::OIndexesHelper(OTableHelper* _pTable, + ::osl::Mutex& _rMutex, + const std::vector< OUString> &_rVector + ) + : OCollection(*_pTable,true,_rMutex,_rVector) + ,m_pTable(_pTable) +{ +} + + +sdbcx::ObjectType OIndexesHelper::createObject(const OUString& _rName) +{ + Reference< XConnection> xConnection = m_pTable->getConnection(); + if ( !xConnection.is() ) + return nullptr; + + sdbcx::ObjectType xRet; + 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(); + 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,false,false); + + if ( xResult.is() ) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while( xResult->next() ) + { + bool bUnique = !xRow->getBoolean(4); + if((aQualifier.isEmpty() || xRow->getString(5) == aQualifier ) && xRow->getString(6) == aName) + { + sal_Int32 nClustered = xRow->getShort(7); + bool bPrimarKeyIndex = 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(const Exception&) + { + } + OIndexHelper* pRet = new OIndexHelper(m_pTable,aName,aQualifier,bUnique, + bPrimarKeyIndex, + nClustered == IndexType::CLUSTERED); + xRet = pRet; + break; + } + } + } + + return xRet; +} + +void OIndexesHelper::impl_refresh() +{ + m_pTable->refreshIndexes(); +} + +Reference< XPropertySet > OIndexesHelper::createDescriptor() +{ + return new OIndexHelper(m_pTable); +} + +// XAppend +sdbcx::ObjectType OIndexesHelper::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor ) +{ + Reference< XConnection> xConnection = m_pTable->getConnection(); + if ( !xConnection.is() ) + return nullptr; + 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(); + OUStringBuffer aSql( "CREATE " ); + OUString aQuote = m_pTable->getMetaData()->getIdentifierQuoteString( ); + + if(comphelper::getBOOL(descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISUNIQUE)))) + aSql.append("UNIQUE "); + aSql.append("INDEX "); + + + OUString aCatalog,aSchema,aTable; + dbtools::qualifiedNameComponents(m_pTable->getMetaData(),m_pTable->getName(),aCatalog,aSchema,aTable,::dbtools::EComposeRule::InDataManipulation); + + OUString aComposedName = dbtools::composeTableName(m_pTable->getMetaData(),aCatalog,aSchema,aTable, true, ::dbtools::EComposeRule::InIndexDefinitions); + if (!_rForName.isEmpty() ) + { + aSql.append( ::dbtools::quoteName( aQuote, _rForName ) ); + aSql.append(" ON "); + aSql.append(aComposedName); + aSql.append(" ( "); + + Reference xColumnSup(descriptor,UNO_QUERY); + Reference xColumns(xColumnSup->getColumns(),UNO_QUERY); + Reference< XPropertySet > xColProp; + 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.append(","); + } + aSql[aSql.getLength() - 1] = ')'; + } + else + { + aSql.append(aComposedName); + + Reference xColumnSup(descriptor,UNO_QUERY); + Reference xColumns(xColumnSup->getColumns(),UNO_QUERY); + Reference< XPropertySet > xColProp; + if(xColumns->getCount() != 1) + throw SQLException(); + + xColumns->getByIndex(0) >>= xColProp; + + aSql.append("."); + aSql.append(::dbtools::quoteName( aQuote,comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))))); + } + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + if ( xStmt.is() ) + { + OUString sSql = aSql.makeStringAndClear(); + xStmt->execute(sSql); + ::comphelper::disposeComponent(xStmt); + } + } + + return createObject( _rForName ); +} + +// XDrop +void OIndexesHelper::dropObject(sal_Int32 /*_nPos*/,const OUString& _sElementName) +{ + Reference< XConnection> xConnection = m_pTable->getConnection(); + if( !(xConnection.is() && !m_pTable->isNew())) + return; + + if ( m_pTable->getIndexService().is() ) + { + m_pTable->getIndexService()->dropIndex(m_pTable,_sElementName); + } + else + { + OUString aName,aSchema; + sal_Int32 nLen = _sElementName.indexOf('.'); + if(nLen != -1) + aSchema = _sElementName.copy(0,nLen); + aName = _sElementName.copy(nLen+1); + + OUString aSql( "DROP INDEX " ); + + OUString aComposedName = dbtools::composeTableName( m_pTable->getMetaData(), m_pTable, ::dbtools::EComposeRule::InIndexDefinitions, true ); + OUString sIndexName = dbtools::composeTableName( m_pTable->getMetaData(), OUString(), aSchema, aName, true, ::dbtools::EComposeRule::InIndexDefinitions ); + + aSql += sIndexName + " ON " + aComposedName; + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + if ( xStmt.is() ) + { + xStmt->execute(aSql); + ::comphelper::disposeComponent(xStmt); + } + } +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/TKey.cxx b/connectivity/source/commontools/TKey.cxx new file mode 100644 index 000000000..1341291ab --- /dev/null +++ b/connectivity/source/commontools/TKey.cxx @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include + +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; + +OTableKeyHelper::OTableKeyHelper(OTableHelper* _pTable) : connectivity::sdbcx::OKey(true) + ,m_pTable(_pTable) +{ + construct(); +} + +OTableKeyHelper::OTableKeyHelper( OTableHelper* _pTable + ,const OUString& Name + ,const std::shared_ptr& _rProps + ) : connectivity::sdbcx::OKey(Name,_rProps,true) + ,m_pTable(_pTable) +{ + construct(); + refreshColumns(); +} + +void OTableKeyHelper::refreshColumns() +{ + if ( !m_pTable ) + return; + + std::vector< OUString> aVector; + if ( !isNew() ) + { + aVector = m_aProps->m_aKeyColumnNames; + if ( aVector.empty() ) + { + ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap(); + OUString aSchema,aTable; + m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema; + m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable; + + if ( !m_Name.isEmpty() ) // 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() ) + { + 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.reset(new OKeyColumnsHelper(this,m_aMutex,aVector)); +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/TKeyColumns.cxx b/connectivity/source/commontools/TKeyColumns.cxx new file mode 100644 index 000000000..acbfc54bf --- /dev/null +++ b/connectivity/source/commontools/TKeyColumns.cxx @@ -0,0 +1,133 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace connectivity; +using namespace connectivity::sdbcx; +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; + + +OKeyColumnsHelper::OKeyColumnsHelper( OTableKeyHelper* _pKey, + ::osl::Mutex& _rMutex, + const std::vector< OUString> &_rVector) + : connectivity::sdbcx::OCollection(*_pKey,true,_rMutex,_rVector) + ,m_pKey(_pKey) +{ +} + +sdbcx::ObjectType OKeyColumnsHelper::createObject(const OUString& _rName) +{ + ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap(); + OUString aCatalog, aSchema, aTable; + css::uno::Any Catalog(m_pKey->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME))); + Catalog >>= aCatalog; + m_pKey->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema; + m_pKey->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable; + + // first get the related column to _rName + Reference< XResultSet > xResult = m_pKey->getTable()->getMetaData()->getImportedKeys( + Catalog, aSchema, aTable); + + OUString aRefColumnName; + if ( xResult.is() ) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + 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(Catalog, 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); + OUString aTypeName(xRow->getString(6)); + sal_Int32 nSize = xRow->getInt(7); + sal_Int32 nDec = xRow->getInt(9); + sal_Int32 nNull = xRow->getInt(11); + OUString sColumnDef; + try + { + sColumnDef = xRow->getString(13); + } + catch(const SQLException&) + { + // sometimes we get an error when asking for this param + } + + OKeyColumn* pRet = new OKeyColumn(aRefColumnName, + _rName, + aTypeName, + sColumnDef, + nNull, + nSize, + nDec, + nDataType, + isCaseSensitive(), + aCatalog, + aSchema, + aTable); + xRet = pRet; + } + } + } + + return xRet; +} + +Reference< XPropertySet > OKeyColumnsHelper::createDescriptor() +{ + return new OKeyColumn(isCaseSensitive()); +} + +void OKeyColumnsHelper::impl_refresh() +{ + m_pKey->refreshColumns(); +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/TKeys.cxx b/connectivity/source/commontools/TKeys.cxx new file mode 100644 index 000000000..742a18320 --- /dev/null +++ b/connectivity/source/commontools/TKeys.cxx @@ -0,0 +1,311 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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 ::std::vector< OUString>& _rVector + ) : OKeys_BASE(*_pTable,true,_rMutex,_rVector,true) + ,m_pTable(_pTable) +{ +} + +sdbcx::ObjectType OKeysHelper::createObject(const OUString& _rName) +{ + sdbcx::ObjectType xRet; + + if(!_rName.isEmpty()) + { + 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() +{ + m_pTable->refreshKeys(); +} + +Reference< XPropertySet > OKeysHelper::createDescriptor() +{ + return new OTableKeyHelper(m_pTable); +} + +/** returns the keyrule string for the primary key +*/ +static OUString getKeyRuleString(bool _bUpdate,sal_Int32 _nKeyRule) +{ + const char* pKeyRule = nullptr; + 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: + ; + } + OUString sRet; + if ( pKeyRule ) + sRet = 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 OUString& _rForName, const Reference< XPropertySet >& descriptor ) +{ + Reference< XConnection> xConnection = m_pTable->getConnection(); + if ( !xConnection.is() ) + return nullptr; + 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; + 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. + OUStringBuffer aSql; + aSql.append("ALTER TABLE "); + OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( ); + + aSql.append(composeTableName( m_pTable->getConnection()->getMetaData(), m_pTable, ::dbtools::EComposeRule::InTableDefinitions, true )); + aSql.append(" ADD "); + + if ( nKeyType == KeyType::PRIMARY ) + { + aSql.append(" PRIMARY KEY ("); + } + else if ( nKeyType == KeyType::FOREIGN ) + { + aSql.append(" FOREIGN KEY ("); + } + else + throw SQLException(); + + Reference xColumnSup(descriptor,UNO_QUERY); + Reference xColumns(xColumnSup->getColumns(),UNO_QUERY); + Reference< XPropertySet > xColProp; + for(sal_Int32 i = 0 ; i < xColumns->getCount() ; ++i) + { + if ( i > 0 ) + aSql.append(","); + xColProp.set(xColumns->getByIndex(i), css::uno::UNO_QUERY); + aSql.append( ::dbtools::quoteName( aQuote,getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))) ); + + } + aSql.append(")"); + + if ( nKeyType == KeyType::FOREIGN ) + { + aSql.append(" REFERENCES "); + aSql.append(::dbtools::quoteTableName(m_pTable->getConnection()->getMetaData(),sReferencedName,::dbtools::EComposeRule::InTableDefinitions)); + aSql.append(" ("); + + for(sal_Int32 i=0;igetCount();++i) + { + if ( i > 0 ) + aSql.append(","); + xColumns->getByIndex(i) >>= xColProp; + aSql.append(::dbtools::quoteName( aQuote,getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_RELATEDCOLUMN))))); + + } + aSql.append(")"); + aSql.append(getKeyRuleString(true ,nUpdateRule)); + aSql.append(getKeyRuleString(false ,nDeleteRule)); + } + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + xStmt->execute(aSql.makeStringAndClear()); + } + // find the name which the database gave the new key + OUString sNewName( _rForName ); + try + { + 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() ) + { + OUString sName = xRow->getString(nColumn); + if ( !m_pElements->exists(sName) ) // this name wasn't inserted yet so it must be the new one + { + descriptor->setPropertyValue( rPropMap.getNameByIndex( PROPERTY_ID_NAME ), makeAny( sName ) ); + sNewName = sName; + break; + } + } + ::comphelper::disposeComponent(xResult); + } + } + catch(const SQLException&) + { + } + + m_pTable->addKey(sNewName,std::make_shared(sReferencedName,nKeyType,nUpdateRule,nDeleteRule)); + + return createObject( sNewName ); +} + +OUString OKeysHelper::getDropForeignKey() const +{ + return " DROP CONSTRAINT "; +} + +// XDrop +void OKeysHelper::dropObject(sal_Int32 _nPos, const OUString& _sElementName) +{ + Reference< XConnection> xConnection = m_pTable->getConnection(); + if ( !(xConnection.is() && !m_pTable->isNew()) ) + return; + + Reference xKey(getObject(_nPos),UNO_QUERY); + if ( m_pTable->getKeyService().is() ) + { + m_pTable->getKeyService()->dropKey(m_pTable,xKey); + } + else + { + OUStringBuffer aSql; + aSql.append("ALTER TABLE "); + + aSql.append( composeTableName( m_pTable->getConnection()->getMetaData(), m_pTable,::dbtools::EComposeRule::InTableDefinitions, 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.append(" DROP PRIMARY KEY"); + } + else + { + aSql.append(getDropForeignKey()); + const 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 + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/TPrivilegesResultSet.cxx b/connectivity/source/commontools/TPrivilegesResultSet.cxx new file mode 100644 index 000000000..de255d3cb --- /dev/null +++ b/connectivity/source/commontools/TPrivilegesResultSet.cxx @@ -0,0 +1,143 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +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 OUString& schemaPattern + , const OUString& tableNamePattern) + : ODatabaseMetaDataResultSet(eTablePrivileges) + , m_bResetValues(true) +{ + osl_atomic_increment( &m_refCount ); + { + OUString sUserWorkingFor; + Sequence< OUString > sTableTypes(3); + // we want all catalogues, all schemas, all tables + sTableTypes[0] = "VIEW"; + sTableTypes[1] = "TABLE"; + sTableTypes[2] = "%"; // just to be sure to include anything else... + try + { + m_xTables = _rxMeta->getTables(catalog,schemaPattern,tableNamePattern,sTableTypes); + m_xRow.set(m_xTables,UNO_QUERY); + + sUserWorkingFor = _rxMeta->getUserName(); + } + catch(Exception&) + { + } + + ODatabaseMetaDataResultSet::ORows aRows; + ODatabaseMetaDataResultSet::ORow aRow(8); + aRow[5] = new ORowSetValueDecorator(sUserWorkingFor); + aRow[6] = ODatabaseMetaDataResultSet::getSelectValue(); + aRow[7] = new ORowSetValueDecorator(OUString("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(OUString("REFERENCE")); + aRows.push_back(aRow); + + setRows(aRows); + } + osl_atomic_decrement( &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 = false; + } + } + return ODatabaseMetaDataResultSet::getValue(columnIndex); +} + +void SAL_CALL OResultSetPrivileges::disposing() +{ + ODatabaseMetaDataResultSet::disposing(); + m_xTables.clear(); + m_xRow.clear(); +} + +sal_Bool SAL_CALL OResultSetPrivileges::next( ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); + + bool bReturn = false; + if ( m_xTables.is() ) + { + if ( m_bBOF ) + { + m_bResetValues = true; + if ( !m_xTables->next() ) + return false; + } + + bReturn = ODatabaseMetaDataResultSet::next(); + if ( !bReturn ) + { + m_bBOF = false; + m_bResetValues = bReturn = m_xTables->next(); + } + } + return bReturn; +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/TSkipDeletedSet.cxx b/connectivity/source/commontools/TSkipDeletedSet.cxx new file mode 100644 index 000000000..d3ae392f7 --- /dev/null +++ b/connectivity/source/commontools/TSkipDeletedSet.cxx @@ -0,0 +1,255 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include + +using namespace connectivity; + +OSkipDeletedSet::OSkipDeletedSet(IResultSetHelper* _pHelper) + : m_pHelper(_pHelper) + ,m_bDeletedVisible(false) +{ + m_aBookmarksPositions.reserve(256); +} + +OSkipDeletedSet::~OSkipDeletedSet() +{ + m_aBookmarksPositions.clear(); + //m_aBookmarks.clear(); +} + +bool OSkipDeletedSet::skipDeleted(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, bool _bRetrieveData) +{ + 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::ABSOLUTE1: + 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; // last row is invalid so position before + nDelOffset = 1; + break; + case IResultSetHelper::RELATIVE1: + eDelPosition = (_nOffset >= 0) ? IResultSetHelper::NEXT : IResultSetHelper::PRIOR; + break; + default: + break; + } + + bool bDone = true; + bool bDataFound = false; + + if (_eCursorPosition == IResultSetHelper::LAST) + { + SAL_INFO( "connectivity.commontools", "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.emplace( 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 then move forward until we are after the last row + while(bDataFound) + { + bDataFound = m_pHelper->move(IResultSetHelper::NEXT, 1, 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.emplace( 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::RELATIVE1) + { + 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.emplace( m_pHelper->getDriverPos(),m_aBookmarksPositions.size()+1)).first); + } + else + bDone = false; + } + + while (bDataFound && !bDone) // Iterate until we are at the valid set + { + bDataFound = m_pHelper->move(eDelPosition, 1, _bRetrieveData); + if (_eCursorPosition != IResultSetHelper::RELATIVE1) + 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.emplace( m_pHelper->getDriverPos(),m_aBookmarksPositions.size()+1)).first); + } + else + bDone = false; + } + + if(bDataFound && bDone) + { + const sal_Int32 nDriverPos = m_pHelper->getDriverPos(); + if ( m_bDeletedVisible ) + { + if ( nDriverPos > static_cast(m_aBookmarksPositions.size()) ) + m_aBookmarksPositions.push_back(nDriverPos); + } + else 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.emplace( nDriverPos,m_aBookmarksPositions.size()+1)).first);*/ + } + + return bDataFound; +} + +bool OSkipDeletedSet::moveAbsolute(sal_Int32 _nPos,bool _bRetrieveData) +{ + bool bDataFound = false; + sal_Int32 nNewPos = _nPos; + if(nNewPos > 0) + { + if(static_cast(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.emplace( 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.emplace( 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() +{ + std::vector().swap(m_aBookmarksPositions); +} + +sal_Int32 OSkipDeletedSet::getMappedPosition(sal_Int32 _nPos) const +{ + std::vector::const_iterator aFind = std::find(m_aBookmarksPositions.begin(),m_aBookmarksPositions.end(),_nPos); + if ( aFind != m_aBookmarksPositions.end() ) + return (aFind - m_aBookmarksPositions.begin()) + 1; + OSL_FAIL("Why!"); + return -1; +} + +void OSkipDeletedSet::insertNewPosition(sal_Int32 _nPos) +{ + m_aBookmarksPositions.push_back(_nPos); +} + +void OSkipDeletedSet::deletePosition(sal_Int32 _nBookmark) +{ + std::vector::iterator aFind = std::find(m_aBookmarksPositions.begin(),m_aBookmarksPositions.end(),_nBookmark); + if ( aFind != m_aBookmarksPositions.end() ) + { + m_aBookmarksPositions.erase(aFind); + } +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/TSortIndex.cxx b/connectivity/source/commontools/TSortIndex.cxx new file mode 100644 index 000000000..6b94216a3 --- /dev/null +++ b/connectivity/source/commontools/TSortIndex.cxx @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include + +using namespace connectivity; + +namespace { + +/// Functor object for class OSortIndex::TIntValuePairVector::value_type returntype is bool +struct TKeyValueFunc +{ + OSortIndex* pIndex; + + explicit TKeyValueFunc(OSortIndex* _pIndex) : pIndex(_pIndex) + { + } + // return false if compared values are equal otherwise true + bool operator()(const OSortIndex::TIntValuePairVector::value_type& lhs,const OSortIndex::TIntValuePairVector::value_type& rhs) const + { + const std::vector& aKeyType = pIndex->getKeyType(); + size_t i = 0; + for (auto const& elem : aKeyType) + { + const bool bGreater = pIndex->getAscending(i) != TAscendingOrder::ASC; + const bool bLess = !bGreater; + + // compare depending for type + switch (elem) + { + case OKeyType::String: + { + sal_Int32 nRes = lhs.second->getKeyString(i).compareTo(rhs.second->getKeyString(i)); + if (nRes < 0) + return bLess; + else if (nRes > 0) + return bGreater; + } + break; + case OKeyType::Double: + { + double d1 = lhs.second->getKeyDouble(i); + double d2 = rhs.second->getKeyDouble(i); + + if (d1 < d2) + return bLess; + else if (d1 > d2) + return bGreater; + } + break; + case OKeyType::NONE: + break; + } + ++i; + } + + // know we know that the values are equal + return false; + } +}; + +} + +::rtl::Reference OSortIndex::CreateKeySet() +{ + Freeze(); + + ::rtl::Reference pKeySet = new OKeySet(); + pKeySet->reserve(m_aKeyValues.size()); + std::transform(m_aKeyValues.begin() + ,m_aKeyValues.end() + ,std::back_inserter(*pKeySet) + ,::o3tl::select1st()); + pKeySet->setFrozen(); + return pKeySet; +} + +OSortIndex::OSortIndex( const std::vector& _aKeyType, + const std::vector& _aAscending) + :m_aKeyType(_aKeyType) + ,m_aAscending(_aAscending) + ,m_bFrozen(false) +{ +} + +OSortIndex::~OSortIndex() +{ +} + +void OSortIndex::AddKeyValue(std::unique_ptr pKeyValue) +{ + assert(pKeyValue && "Can not be null here!"); + if(m_bFrozen) + { + m_aKeyValues.push_back({pKeyValue->getValue(),nullptr}); + } + else + m_aKeyValues.push_back({pKeyValue->getValue(),std::move(pKeyValue)}); +} + +void OSortIndex::Freeze() +{ + OSL_ENSURE(! m_bFrozen,"OSortIndex::Freeze: already frozen!"); + // sorting: + if (m_aKeyType[0] != OKeyType::NONE) + // we will sort ourself when the first keyType say so + std::sort(m_aKeyValues.begin(),m_aKeyValues.end(),TKeyValueFunc(this)); + + for (auto & keyValue : m_aKeyValues) + { + keyValue.second.reset(); + } + + m_bFrozen = true; +} + + +OKeyValue::OKeyValue(sal_Int32 nVal) +: m_nValue(nVal) +{ +} + +OKeyValue::~OKeyValue() +{ +} + +std::unique_ptr OKeyValue::createKeyValue(sal_Int32 _nVal) +{ + return std::unique_ptr(new OKeyValue(_nVal)); +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/TTableHelper.cxx b/connectivity/source/commontools/TTableHelper.cxx new file mode 100644 index 000000000..03724d669 --- /dev/null +++ b/connectivity/source/commontools/TTableHelper.cxx @@ -0,0 +1,605 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +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 +class OTableContainerListener: + public ::cppu::WeakImplHelper< XContainerListener > +{ + OTableHelper* m_pComponent; + std::map< OUString,bool> m_aRefNames; + +protected: + virtual ~OTableContainerListener() override {} +public: + explicit OTableContainerListener(OTableHelper* _pComponent) : m_pComponent(_pComponent){} + // noncopyable + OTableContainerListener(const OTableContainerListener&) = delete; + const OTableContainerListener& operator=(const OTableContainerListener&) = delete; + virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& /*Event*/ ) override + { + } + virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override + { + // tdf#137745, perhaps connectivity::OTableHelper::disposing() has been called + // which called OTableContainerListener::clear(), so m_pComponent may be null + if (m_pComponent == nullptr) + return; + + OUString sName; + Event.Accessor >>= sName; + if ( m_aRefNames.find(sName) != m_aRefNames.end() ) + m_pComponent->refreshKeys(); + } + virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override + { + 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*/ ) override + { + } + void clear() { m_pComponent = nullptr; } + void add(const OUString& _sRefName) { m_aRefNames.emplace(_sRefName,true); } +}; +} +namespace connectivity +{ + static OUString lcl_getServiceNameForSetting(const Reference< css::sdbc::XConnection >& _xConnection,const OUString& i_sSetting) + { + 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< css::sdb::tools::XTableRename> m_xRename; + Reference< css::sdb::tools::XTableAlteration> m_xAlter; + Reference< css::sdb::tools::XKeyAlteration> m_xKeyAlter; + Reference< css::sdb::tools::XIndexAlteration> m_xIndexAlter; + + Reference< css::sdbc::XDatabaseMetaData > m_xMetaData; + Reference< css::sdbc::XConnection > m_xConnection; + rtl::Reference m_xTablePropertyListener; + std::vector< ColumnDesc > m_aColumnDesc; + explicit OTableHelperImpl(const Reference< css::sdbc::XConnection >& _xConnection) + : m_xConnection(_xConnection) + { + try + { + m_xMetaData = m_xConnection->getMetaData(); + Reference xFac(_xConnection,UNO_QUERY); + if ( xFac.is() ) + { + m_xRename.set(xFac->createInstance(lcl_getServiceNameForSetting(m_xConnection,"TableRenameServiceName")),UNO_QUERY); + m_xAlter.set(xFac->createInstance(lcl_getServiceNameForSetting(m_xConnection,"TableAlterationServiceName")),UNO_QUERY); + m_xKeyAlter.set(xFac->createInstance(lcl_getServiceNameForSetting(m_xConnection,"KeyAlterationServiceName")),UNO_QUERY); + m_xIndexAlter.set(xFac->createInstance(lcl_getServiceNameForSetting(m_xConnection,"IndexAlterationServiceName")),UNO_QUERY); + } + } + catch(const Exception&) + { + } + } + }; +} + +OTableHelper::OTableHelper( sdbcx::OCollection* _pTables, + const Reference< XConnection >& _xConnection, + bool _bCase) + :OTable_TYPEDEF(_pTables,_bCase) + ,m_pImpl(new OTableHelperImpl(_xConnection)) +{ +} + +OTableHelper::OTableHelper( sdbcx::OCollection* _pTables, + const Reference< XConnection >& _xConnection, + bool _bCase, + const OUString& Name, + const OUString& Type, + const OUString& Description , + const OUString& SchemaName, + const 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.get()); + m_pImpl->m_xTablePropertyListener->clear(); + m_pImpl->m_xTablePropertyListener.clear(); + } + OTable_TYPEDEF::disposing(); + + m_pImpl->m_xConnection = nullptr; + m_pImpl->m_xMetaData = nullptr; + +} + + +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 ); + OUString sName; + OrdinalPosition nOrdinalPosition( 0 ); + while ( _rxResult->next() ) + { + sName = xRow->getString( 4 ); // COLUMN_NAME + sal_Int32 nField5 = xRow->getInt(5); + OUString aField6 = xRow->getString(6); + sal_Int32 nField7 = xRow->getInt(7) + , nField9 = xRow->getInt(9) + , nField11= xRow->getInt(11); + 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 ( const auto& collect : _rColumns ) + 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_FAIL( "lcl_sanitizeColumnDescs: database did provide invalid ORDINAL_POSITION values!" ); + + OrdinalPosition nNormalizedPosition = 1; + for ( auto& normalize : _rColumns ) + normalize.nOrdinalPosition = nNormalizedPosition++; + return; + } + + // what's left is that the range might not be from 1 to , but for instance + // 0 to -1. + size_t nOffset = *aUsedOrdinals.begin() - 1; + for ( auto& offset : _rColumns ) + offset.nOrdinalPosition -= nOffset; + } +} + + +void OTableHelper::refreshColumns() +{ + ::std::vector< OUString> aVector; + if(!isNew()) + { + Any aCatalog; + if ( !m_CatalogName.isEmpty() ) + aCatalog <<= m_CatalogName; + + ::utl::SharedUNOComponent< XResultSet > xResult( getMetaData()->getColumns( + aCatalog, + m_SchemaName, + m_Name, + "%" + ) ); + + // 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, OUString > aSortedColumns; + for (const auto& copy : m_pImpl->m_aColumnDesc) + 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< ::std::vector< OUString> >( aVector, aVector.begin() ), + ::o3tl::select2nd< std::map< OrdinalPosition, OUString >::value_type >() + ); + } + + if(m_xColumns) + m_xColumns->reFill(aVector); + else + m_xColumns = createColumns(aVector); +} + +const ColumnDesc* OTableHelper::getColumnDescription(const OUString& _sName) const +{ + const ColumnDesc* pRet = nullptr; + auto aIter = std::find_if(m_pImpl->m_aColumnDesc.begin(), m_pImpl->m_aColumnDesc.end(), + [&_sName](const ColumnDesc& rColumnDesc) { return rColumnDesc.sName == _sName; }); + if (aIter != m_pImpl->m_aColumnDesc.end()) + pRet = &*aIter; + return pRet; +} + +void OTableHelper::refreshPrimaryKeys(::std::vector< OUString>& _rNames) +{ + Any aCatalog; + if ( !m_CatalogName.isEmpty() ) + aCatalog <<= m_CatalogName; + Reference< XResultSet > xResult = getMetaData()->getPrimaryKeys(aCatalog,m_SchemaName,m_Name); + + if ( xResult.is() ) + { + auto pKeyProps = std::make_shared(OUString(),KeyType::PRIMARY,0,0); + 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); + SAL_WARN_IF(xRow->wasNull(),"connectivity.commontools", "NULL Primary Key name"); + SAL_WARN_IF(aPkName.isEmpty(),"connectivity.commontools", "empty Primary Key name"); + bAlreadyFetched = true; + } + } + + if(bAlreadyFetched) + { + SAL_WARN_IF(aPkName.isEmpty(),"connectivity.commontools", "empty Primary Key name"); + SAL_WARN_IF(pKeyProps->m_aKeyColumnNames.empty(),"connectivity.commontools", "Primary Key has no columns"); + m_pImpl->m_aKeys.emplace(aPkName,pKeyProps); + _rNames.push_back(aPkName); + } + } // if ( xResult.is() && xResult->next() ) + ::comphelper::disposeComponent(xResult); +} + +void OTableHelper::refreshForeignKeys(::std::vector< OUString>& _rNames) +{ + Any aCatalog; + if ( !m_CatalogName.isEmpty() ) + aCatalog <<= m_CatalogName; + Reference< XResultSet > xResult = getMetaData()->getImportedKeys(aCatalog,m_SchemaName,m_Name); + Reference< XRow > xRow(xResult,UNO_QUERY); + + if ( !xRow.is() ) + return; + + std::shared_ptr pKeyProps; + OUString aName,sCatalog,aSchema,sOldFKName; + while( xResult->next() ) + { + // this must be outside the "if" because we have to call in a right order + sCatalog = xRow->getString(1); + if ( xRow->wasNull() ) + sCatalog.clear(); + aSchema = xRow->getString(2); + aName = xRow->getString(3); + + const OUString sForeignKeyColumn = xRow->getString(8); + const sal_Int32 nUpdateRule = xRow->getInt(10); + const sal_Int32 nDeleteRule = xRow->getInt(11); + const OUString sFkName = xRow->getString(12); + + if ( !sFkName.isEmpty() && !xRow->wasNull() ) + { + if ( sOldFKName != sFkName ) + { + if ( pKeyProps ) + m_pImpl->m_aKeys.emplace(sOldFKName,pKeyProps); + + const OUString sReferencedName = ::dbtools::composeTableName(getMetaData(),sCatalog,aSchema,aName,false,::dbtools::EComposeRule::InDataManipulation); + pKeyProps = std::make_shared(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 = new OTableContainerListener(this); + m_pTables->addContainerListener(m_pImpl->m_xTablePropertyListener.get()); + m_pImpl->m_xTablePropertyListener->add(sReferencedName); + } // if ( m_pTables->hasByName(sReferencedName) ) + sOldFKName = sFkName; + } // if ( sOldFKName != sFkName ) + else if ( pKeyProps ) + { + pKeyProps->m_aKeyColumnNames.push_back(sForeignKeyColumn); + } + } + } // while( xResult->next() ) + if ( pKeyProps ) + m_pImpl->m_aKeys.emplace(sOldFKName,pKeyProps); + ::comphelper::disposeComponent(xResult); +} + +void OTableHelper::refreshKeys() +{ + m_pImpl->m_aKeys.clear(); + + ::std::vector< OUString> aNames; + + if(!isNew()) + { + refreshPrimaryKeys(aNames); + refreshForeignKeys(aNames); + m_xKeys = createKeys(aNames); + } // if(!isNew()) + else if (!m_xKeys ) + m_xKeys = createKeys(aNames); + /*if(m_pKeys) + m_pKeys->reFill(aVector); + else*/ + +} + +void OTableHelper::refreshIndexes() +{ + ::std::vector< OUString> aVector; + if(!isNew()) + { + // fill indexes + Any aCatalog; + if ( !m_CatalogName.isEmpty() ) + aCatalog <<= m_CatalogName; + Reference< XResultSet > xResult = getMetaData()->getIndexInfo(aCatalog,m_SchemaName,m_Name,false,false); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + OUString sCatalogSep = getMetaData()->getCatalogSeparator(); + OUString sPreviousRoundName; + while( xResult->next() ) + { + OUString aName = xRow->getString(5); + if(!aName.isEmpty()) + aName += sCatalogSep; + aName += xRow->getString(6); + if ( !aName.isEmpty() ) + { + // 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_xIndexes) + m_xIndexes->reFill(aVector); + else + m_xIndexes = createIndexes(aVector); +} + +OUString OTableHelper::getRenameStart() const +{ + OUString sSql("RENAME "); + if ( m_Type == "VIEW" ) + sSql += " VIEW "; + else + sSql += " TABLE "; + + return sSql; +} + +// XRename +void SAL_CALL OTableHelper::rename( const OUString& newName ) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed( +#ifdef __GNUC__ + ::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 + { + OUString sSql = getRenameStart(); + + OUString sCatalog,sSchema,sTable; + ::dbtools::qualifiedNameComponents(getMetaData(),newName,sCatalog,sSchema,sTable,::dbtools::EComposeRule::InDataManipulation); + + OUString sComposedName; + sComposedName = ::dbtools::composeTableName(getMetaData(),m_CatalogName,m_SchemaName,m_Name,true,::dbtools::EComposeRule::InDataManipulation); + sSql += sComposedName + + " TO "; + sComposedName = ::dbtools::composeTableName(getMetaData(),sCatalog,sSchema,sTable,true,::dbtools::EComposeRule::InDataManipulation); + 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::EComposeRule::InTableDefinitions); +} + +Reference< XDatabaseMetaData> OTableHelper::getMetaData() const +{ + return m_pImpl->m_xMetaData; +} + +void SAL_CALL OTableHelper::alterColumnByIndex( sal_Int32 index, const Reference< XPropertySet >& descriptor ) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed( +#ifdef __GNUC__ + ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed +#else + rBHelper.bDisposed +#endif + ); + + Reference< XPropertySet > xOld( + m_xColumns->getByIndex(index), css::uno::UNO_QUERY); + if(xOld.is()) + alterColumnByName(getString(xOld->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))),descriptor); +} + + +OUString SAL_CALL OTableHelper::getName() +{ + OUString sComposedName = ::dbtools::composeTableName(getMetaData(),m_CatalogName,m_SchemaName,m_Name,false,::dbtools::EComposeRule::InDataManipulation); + return sComposedName; +} + +std::shared_ptr OTableHelper::getKeyProperties(const OUString& _sName) const +{ + std::shared_ptr 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_FAIL("No key with the given name found"); + pKeyProps = std::make_shared(); + } + + return pKeyProps; +} + +void OTableHelper::addKey(const OUString& _sName,const std::shared_ptr& _aKeyProperties) +{ + m_pImpl->m_aKeys.emplace(_sName,_aKeyProperties); +} + +OUString OTableHelper::getTypeCreatePattern() const +{ + return OUString(); +} + +Reference< XConnection> const & OTableHelper::getConnection() const +{ + return m_pImpl->m_xConnection; +} + +Reference< css::sdb::tools::XTableRename> const & OTableHelper::getRenameService() const +{ + return m_pImpl->m_xRename; +} + +Reference< css::sdb::tools::XTableAlteration> const & OTableHelper::getAlterService() const +{ + return m_pImpl->m_xAlter; +} + +Reference< css::sdb::tools::XKeyAlteration> const & OTableHelper::getKeyService() const +{ + return m_pImpl->m_xKeyAlter; +} + +Reference< css::sdb::tools::XIndexAlteration> const & OTableHelper::getIndexService() const +{ + return m_pImpl->m_xIndexAlter; +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/conncleanup.cxx b/connectivity/source/commontools/conncleanup.cxx new file mode 100644 index 000000000..d0198df5f --- /dev/null +++ b/connectivity/source/commontools/conncleanup.cxx @@ -0,0 +1,230 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include +#include + + +namespace dbtools +{ + + + using namespace css::uno; + using namespace css::beans; + using namespace css::sdbc; + using namespace css::lang; + + static const char ACTIVE_CONNECTION_PROPERTY_NAME[] = "ActiveConnection"; + + OAutoConnectionDisposer::OAutoConnectionDisposer(const Reference< XRowSet >& _rxRowSet, const Reference< XConnection >& _rxConnection) + :m_xRowSet( _rxRowSet ) + ,m_bRSListening( false ) + ,m_bPropertyListening( false ) + { + Reference< XPropertySet > xProps(_rxRowSet, UNO_QUERY); + OSL_ENSURE(xProps.is(), "OAutoConnectionDisposer::OAutoConnectionDisposer: invalid rowset (no XPropertySet)!"); + + if (!xProps.is()) + return; + + try + { + xProps->setPropertyValue( ACTIVE_CONNECTION_PROPERTY_NAME, makeAny( _rxConnection ) ); + m_xOriginalConnection = _rxConnection; + startPropertyListening( xProps ); + } + catch( const Exception& ) + { + TOOLS_WARN_EXCEPTION( "connectivity.commontools", "OAutoConnectionDisposer::OAutoConnectionDisposer" ); + } + } + + + void OAutoConnectionDisposer::startPropertyListening( const Reference< XPropertySet >& _rxRowSet ) + { + try + { + _rxRowSet->addPropertyChangeListener( ACTIVE_CONNECTION_PROPERTY_NAME, this ); + m_bPropertyListening = true; + } + catch( const Exception& ) + { + TOOLS_WARN_EXCEPTION( "connectivity.commontools", "OAutoConnectionDisposer::startPropertyListening" ); + } + } + + + 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( ACTIVE_CONNECTION_PROPERTY_NAME, this ); + m_bPropertyListening = false; + } + } + catch( const Exception& ) + { + TOOLS_WARN_EXCEPTION( "connectivity.commontools", "OAutoConnectionDisposer::stopPropertyListening" ); + } + } + + + void OAutoConnectionDisposer::startRowSetListening() + { + OSL_ENSURE( !m_bRSListening, "OAutoConnectionDisposer::startRowSetListening: already listening!" ); + try + { + if ( !m_bRSListening ) + m_xRowSet->addRowSetListener( this ); + } + catch( const Exception& ) + { + TOOLS_WARN_EXCEPTION( "connectivity.commontools", "OAutoConnectionDisposer::startRowSetListening" ); + } + m_bRSListening = true; + } + + + void OAutoConnectionDisposer::stopRowSetListening() + { + OSL_ENSURE( m_bRSListening, "OAutoConnectionDisposer::stopRowSetListening: not listening!" ); + try + { + m_xRowSet->removeRowSetListener( this ); + } + catch( const Exception& ) + { + TOOLS_WARN_EXCEPTION( "connectivity.commontools", "OAutoConnectionDisposer::stopRowSetListening" ); + } + m_bRSListening = false; + } + + + void SAL_CALL OAutoConnectionDisposer::propertyChange( const PropertyChangeEvent& _rEvent ) + { + if ( _rEvent.PropertyName != ACTIVE_CONNECTION_PROPERTY_NAME ) + return; + +// 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 an 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 :( + 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 ) + { + // the rowset is being disposed, and nobody has set a new ActiveConnection in the meantime + if ( isRowSetListening() ) + stopRowSetListening(); + + clearConnection(); + + if ( m_bPropertyListening ) + 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&) + { + TOOLS_WARN_EXCEPTION("connectivity.commontools", "OAutoConnectionDisposer::clearConnection"); + } + } + + void SAL_CALL OAutoConnectionDisposer::cursorMoved( const css::lang::EventObject& /*event*/ ) + { + } + + void SAL_CALL OAutoConnectionDisposer::rowChanged( const css::lang::EventObject& /*event*/ ) + { + } + + void SAL_CALL OAutoConnectionDisposer::rowSetChanged( const css::lang::EventObject& /*event*/ ) + { + stopRowSetListening(); + clearConnection(); + + } + + +} // namespace dbtools + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/dbcharset.cxx b/connectivity/source/commontools/dbcharset.cxx new file mode 100644 index 000000000..ebe45c028 --- /dev/null +++ b/connectivity/source/commontools/dbcharset.cxx @@ -0,0 +1,190 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include + + +namespace dbtools +{ + + 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!" ); + } + + + bool OCharsetMap::approveEncoding( const rtl_TextEncoding _eEncoding, const rtl_TextEncodingInfo& _rInfo ) const + { + bool bIsMimeEncoding = 0 != ( _rInfo.Flags & RTL_TEXTENCODING_INFO_MIME ); + OSL_ENSURE( !bIsMimeEncoding || rtl_getMimeCharsetFromTextEncoding( _eEncoding ), + "OCharsetMap::OCharsetMap: inconsistence in rtl!" ); + 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::findIanaName(const OUString& _rIanaName) const + { + ensureConstructed( ); + + rtl_TextEncoding eEncoding = RTL_TEXTENCODING_DONTKNOW; + if ( !_rIanaName.isEmpty() ) + { + // byte string conversion + 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( const CharsetIteratorDerefHelper& _rSource ) + :m_eEncoding( _rSource.m_eEncoding ) + ,m_aIanaName( _rSource.m_aIanaName ) + { + } + + + CharsetIteratorDerefHelper:: CharsetIteratorDerefHelper(const rtl_TextEncoding _eEncoding, const OUString& _rIanaName ) + :m_eEncoding( _eEncoding ) + ,m_aIanaName( _rIanaName ) + { + } + + OCharsetMap::CharsetIterator::CharsetIterator(const OCharsetMap* _pContainer, OCharsetMap::TextEncBag::const_iterator const & _aPos ) + :m_pContainer( _pContainer ) + ,m_aPos( _aPos ) + { + OSL_ENSURE( m_pContainer, "OCharsetMap::CharsetIterator::CharsetIterator : invalid container!" ); + } + + CharsetIteratorDerefHelper OCharsetMap::CharsetIterator::operator*() const + { + OSL_ENSURE( m_aPos != m_pContainer->m_aEncodings.end(), "OCharsetMap::CharsetIterator::operator*: invalid position!"); + + rtl_TextEncoding eEncoding = *m_aPos; + 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 = 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 + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/dbconversion.cxx b/connectivity/source/commontools/dbconversion.cxx new file mode 100644 index 000000000..3dd42e9ca --- /dev/null +++ b/connectivity/source/commontools/dbconversion.cxx @@ -0,0 +1,461 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ + const sal_Int64 nanoSecInSec = 1000000000; + const sal_Int16 secInMin = 60; + const sal_Int16 minInHour = 60; + + const sal_Int64 secMask = 1000000000; + const sal_Int64 minMask = 100000000000LL; + const sal_Int64 hourMask = 10000000000000LL; + + const double fNanoSecondsPerDay = nanoSecInSec * secInMin * minInHour * 24.0; + + // 32767-12-31 in "(days since 0001-01-01) + 1" format + const sal_Int32 maxDays = 11967896; + // -32768-01-01 in "(days since 0001-01-01) + 1" format + // Yes, I know it is currently unused. Will have to be used + // when we implement negative years. Writing down the correct + // value for future reference. + // *** Please don't remove just because it is unused *** + // Lionel Élie Mamane 2017-08-02 + // const sal_Int32 minDays = -11968270; +} + + +namespace dbtools +{ + + + 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; + + + css::util::Date const & DBTypeConversion::getStandardDate() + { + static css::util::Date STANDARD_DB_DATE(1,1,1900); + return STANDARD_DB_DATE; + } + + OUString DBTypeConversion::toDateString(const css::util::Date& rDate) + { + std::ostringstream ostr; + using std::setw; + ostr.fill('0'); + ostr << setw(4) << rDate.Year << "-" + << setw(2) << rDate.Month << "-" + << setw(2) << rDate.Day; + return OUString::createFromAscii(ostr.str().c_str()); + } + + OUString DBTypeConversion::toTimeStringS(const css::util::Time& rTime) + { + std::ostringstream ostr; + using std::setw; + ostr.fill('0'); + ostr << setw(2) << rTime.Hours << ":" + << setw(2) << rTime.Minutes << ":" + << setw(2) << rTime.Seconds; + return OUString::createFromAscii(ostr.str().c_str()); + } + + OUString DBTypeConversion::toTimeString(const css::util::Time& rTime) + { + std::ostringstream ostr; + using std::setw; + ostr.fill('0'); + ostr << setw(2) << rTime.Hours << ":" + << setw(2) << rTime.Minutes << ":" + << setw(2) << rTime.Seconds << "." + << setw(9) << rTime.NanoSeconds; + return OUString::createFromAscii(ostr.str().c_str()); + } + + OUString DBTypeConversion::toDateTimeString(const css::util::DateTime& _rDateTime) + { + css::util::Date aDate(_rDateTime.Day,_rDateTime.Month,_rDateTime.Year); + OUStringBuffer aTemp(toDateString(aDate)); + aTemp.append(" "); + css::util::Time const aTime(_rDateTime.NanoSeconds, _rDateTime.Seconds, + _rDateTime.Minutes, _rDateTime.Hours, _rDateTime.IsUTC); + aTemp.append( toTimeString(aTime) ); + return aTemp.makeStringAndClear(); + } + + css::util::Date DBTypeConversion::toDate(const sal_Int32 _nVal) + { + css::util::Date aReturn; + aReturn.Day = static_cast(_nVal % 100); + aReturn.Month = static_cast((_nVal / 100) % 100); + aReturn.Year = static_cast(_nVal / 10000); + return aReturn; + } + + + css::util::Time DBTypeConversion::toTime(const sal_Int64 _nVal) + { + css::util::Time aReturn; + sal_uInt64 unVal = static_cast(_nVal >= 0 ? _nVal : -_nVal); + aReturn.Hours = unVal / hourMask; + aReturn.Minutes = (unVal / minMask) % 100; + aReturn.Seconds = (unVal / secMask) % 100; + aReturn.NanoSeconds = unVal % secMask; + return aReturn; + } + + sal_Int64 DBTypeConversion::getNsFromTime(const css::util::Time& rVal) + { + sal_Int32 nHour = rVal.Hours; + sal_Int32 nMin = rVal.Minutes; + sal_Int32 nSec = rVal.Seconds; + sal_Int32 nNanoSec = rVal.NanoSeconds; + + return nNanoSec + + nSec * nanoSecInSec + + nMin * (secInMin * nanoSecInSec) + + nHour * (minInHour * secInMin * nanoSecInSec); + } + + + static const sal_Int32 aDaysInMonth[12] = { 31, 28, 31, 30, 31, 30, + 31, 31, 30, 31, 30, 31 }; + + + static 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 css::util::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( const sal_Int32 nDays, sal_uInt16& rDay, sal_uInt16& rMonth, sal_Int16& rYear) + { + sal_Int32 nTempDays; + sal_Int32 i = 0; + bool bCalc; + + do + { + nTempDays = nDays; + rYear = static_cast((nTempDays / 365) - i); + nTempDays -= (rYear-1) * 365; + nTempDays -= ((rYear-1) / 4) - ((rYear-1) / 100) + ((rYear-1) / 400); + bCalc = false; + if ( nTempDays < 1 ) + { + i++; + bCalc = true; + } + else + { + if ( nTempDays > 365 ) + { + if ( (nTempDays != 366) || !implIsLeapYear( rYear ) ) + { + i--; + bCalc = true; + } + } + } + } + while ( bCalc ); + + rMonth = 1; + while ( nTempDays > implDaysInMonth( rMonth, rYear ) ) + { + nTempDays -= implDaysInMonth( rMonth, rYear ); + rMonth++; + } + rDay = static_cast(nTempDays); + } + + sal_Int32 DBTypeConversion::toDays(const css::util::Date& _rVal, const css::util::Date& _rNullDate) + { + return implRelativeToAbsoluteNull(_rVal) - implRelativeToAbsoluteNull(_rNullDate); + } + + + double DBTypeConversion::toDouble(const css::util::Date& rVal, const css::util::Date& _rNullDate) + { + return static_cast(toDays(rVal, _rNullDate)); + } + + + double DBTypeConversion::toDouble(const css::util::Time& rVal) + { + return static_cast(getNsFromTime(rVal)) / fNanoSecondsPerDay; + } + + + double DBTypeConversion::toDouble(const css::util::DateTime& _rVal, const css::util::Date& _rNullDate) + { + sal_Int64 nTime = toDays(css::util::Date(_rVal.Day, _rVal.Month, _rVal.Year), _rNullDate); + css::util::Time aTimePart; + + aTimePart.Hours = _rVal.Hours; + aTimePart.Minutes = _rVal.Minutes; + aTimePart.Seconds = _rVal.Seconds; + aTimePart.NanoSeconds = _rVal.NanoSeconds; + + return static_cast(nTime) + toDouble(aTimePart); + } + + static void addDays(const sal_Int32 nDays, css::util::Date& _rDate) + { + sal_Int32 nTempDays = implRelativeToAbsoluteNull( _rDate ); + + nTempDays += nDays; + if ( nTempDays > maxDays ) + { + _rDate.Day = 31; + _rDate.Month = 12; + _rDate.Year = 9999; + } + // TODO: can we replace that check by minDays? Would allow dates BCE + // implBuildFromRelative probably needs to be updated for the "no year 0" question + else if ( nTempDays <= 0 ) + { + _rDate.Day = 1; + _rDate.Month = 1; + _rDate.Year = 1; + } + else + implBuildFromRelative( nTempDays, _rDate.Day, _rDate.Month, _rDate.Year ); + } + + static void subDays(const sal_Int32 nDays, css::util::Date& _rDate ) + { + sal_Int32 nTempDays = implRelativeToAbsoluteNull( _rDate ); + + nTempDays -= nDays; + if ( nTempDays > maxDays ) + { + _rDate.Day = 31; + _rDate.Month = 12; + _rDate.Year = 9999; + } + // TODO: can we replace that check by minDays? Would allow dates BCE + // implBuildFromRelative probably needs to be updated for the "no year 0" question + else if ( nTempDays <= 0 ) + { + _rDate.Day = 1; + _rDate.Month = 1; + _rDate.Year = 1; + } + else + implBuildFromRelative( nTempDays, _rDate.Day, _rDate.Month, _rDate.Year ); + } + + css::util::Date DBTypeConversion::toDate(const double dVal, const css::util::Date& _rNullDate) + { + css::util::Date aRet = _rNullDate; + + if (dVal >= 0) + addDays(static_cast(dVal),aRet); + else + subDays(static_cast(-dVal),aRet); + // x -= (sal_uInt32)(-nDays); + + return aRet; + } + + css::util::Time DBTypeConversion::toTime(const double dVal, short nDigits) + { + const sal_Int32 nDays = static_cast(dVal); + sal_Int64 nNS; + { + double fSeconds((dVal - static_cast(nDays)) * (fNanoSecondsPerDay / nanoSecInSec)); + fSeconds = ::rtl::math::round( fSeconds, nDigits ); + nNS = fSeconds * nanoSecInSec; + } + + sal_Int16 nSign; + if ( nNS < 0 ) + { + nNS *= -1; + nSign = -1; + } + else + nSign = 1; + + css::util::Time aRet; + // normalize time + // we have to sal_Int32 here because otherwise we get an overflow + sal_Int64 nNanoSeconds = nNS; + sal_Int32 nSeconds = nNanoSeconds / nanoSecInSec; + sal_Int32 nMinutes = nSeconds / secInMin; + + aRet.NanoSeconds = nNanoSeconds % nanoSecInSec; + aRet.Seconds = nSeconds % secInMin; + aRet.Hours = nMinutes / minInHour; + aRet.Minutes = nMinutes % minInHour; + + // assemble time + sal_Int64 nTime = nSign * + (aRet.NanoSeconds + + aRet.Seconds * secMask + + aRet.Minutes * minMask + + aRet.Hours * hourMask); + + if(nTime < 0) + { + aRet.NanoSeconds = nanoSecInSec-1; + aRet.Seconds = secInMin-1; + aRet.Minutes = minInHour-1; + aRet.Hours = 23; + } + return aRet; + } + + css::util::DateTime DBTypeConversion::toDateTime(const double dVal, const css::util::Date& _rNullDate) + { + css::util::Date aDate = toDate(dVal, _rNullDate); + // there is not enough precision in a double to have both a date + // and a time up to nanoseconds -> limit to microseconds to have + // correct rounding, that is e.g. 13:00:00.000000000 instead of + // 12:59:59.999999790 + css::util::Time aTime = toTime(dVal, 6); + + css::util::DateTime aRet; + + aRet.Day = aDate.Day; + aRet.Month = aDate.Month; + aRet.Year = aDate.Year; + + aRet.NanoSeconds = aTime.NanoSeconds; + aRet.Minutes = aTime.Minutes; + aRet.Seconds = aTime.Seconds; + aRet.Hours = aTime.Hours; + + + return aRet; + } + + css::util::Date DBTypeConversion::toDate(const OUString& _sSQLString) + { + // get the token out of a string + static const sal_Unicode sDateSep = '-'; + + sal_Int32 nIndex = 0; + sal_uInt16 nYear = 0, + nMonth = 0, + nDay = 0; + nYear = static_cast(_sSQLString.getToken(0,sDateSep,nIndex).toInt32()); + if(nIndex != -1) + { + nMonth = static_cast(_sSQLString.getToken(0,sDateSep,nIndex).toInt32()); + if(nIndex != -1) + nDay = static_cast(_sSQLString.getToken(0,sDateSep,nIndex).toInt32()); + } + + return css::util::Date(nDay,nMonth,nYear); + } + + + css::util::DateTime DBTypeConversion::toDateTime(const 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 + css::util::Date aDate = toDate(_sSQLString); + css::util::Time aTime; + sal_Int32 nSeparation = _sSQLString.indexOf( ' ' ); + if ( -1 != nSeparation ) + { + const sal_Unicode *p = _sSQLString.getStr() + nSeparation; + const sal_Unicode *const begin = p; + while (rtl::isAsciiWhiteSpace(*p)) { ++p; } + nSeparation += p - begin; + aTime = toTime( _sSQLString.copy( nSeparation ) ); + } + + return css::util::DateTime(aTime.NanoSeconds, aTime.Seconds, aTime.Minutes, aTime.Hours, + aDate.Day, aDate.Month, aDate.Year, false); + } + + + css::util::Time DBTypeConversion::toTime(const OUString& _sSQLString) + { + css::util::Time aTime; + ::utl::ISO8601parseTime(_sSQLString, aTime); + return aTime; + } + + +} // namespace dbtools + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/dbexception.cxx b/connectivity/source/commontools/dbexception.cxx new file mode 100644 index 000000000..f15237d82 --- /dev/null +++ b/connectivity/source/commontools/dbexception.cxx @@ -0,0 +1,481 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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::SQLExceptionInfo() + :m_eType(TYPE::Undefined) +{ +} + + +SQLExceptionInfo::SQLExceptionInfo(const css::sdbc::SQLException& _rError) +{ + m_aContent <<= _rError; + implDetermineType(); +} + + +SQLExceptionInfo::SQLExceptionInfo(const css::sdbc::SQLWarning& _rError) +{ + m_aContent <<= _rError; + implDetermineType(); +} + + +SQLExceptionInfo::SQLExceptionInfo(const css::sdb::SQLContext& _rError) +{ + m_aContent <<= _rError; + implDetermineType(); +} + + +SQLExceptionInfo::SQLExceptionInfo( const OUString& _rSimpleErrorMessage ) +{ + SQLException aError; + aError.Message = _rSimpleErrorMessage; + m_aContent <<= aError; + implDetermineType(); +} + +SQLExceptionInfo& SQLExceptionInfo::operator=(const css::sdbc::SQLException& _rError) +{ + m_aContent <<= _rError; + implDetermineType(); + return *this; +} + + +SQLExceptionInfo& SQLExceptionInfo::operator=(const css::sdbc::SQLWarning& _rError) +{ + m_aContent <<= _rError; + implDetermineType(); + return *this; +} + + +SQLExceptionInfo& SQLExceptionInfo::operator=(const css::sdb::SQLContext& _rError) +{ + m_aContent <<= _rError; + implDetermineType(); + return *this; +} + + +SQLExceptionInfo& SQLExceptionInfo::operator=(const css::sdb::SQLErrorEvent& _rErrorEvent) +{ + m_aContent = _rErrorEvent.Reason; + implDetermineType(); + return *this; +} + + +SQLExceptionInfo& SQLExceptionInfo::operator=(const css::uno::Any& _rCaughtSQLException) +{ + m_aContent = _rCaughtSQLException; + implDetermineType(); + return *this; +} + + +SQLExceptionInfo::SQLExceptionInfo(const css::uno::Any& _rError) +{ + const css::uno::Type& aSQLExceptionType = cppu::UnoType::get(); + 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() +{ + const Type& aSQLExceptionType = ::cppu::UnoType::get(); + const Type& aSQLWarningType = ::cppu::UnoType::get(); + const Type& aSQLContextType = ::cppu::UnoType::get(); + + if ( isAssignableFrom( aSQLContextType, m_aContent.getValueType() ) ) + m_eType = TYPE::SQLContext; + else if ( isAssignableFrom( aSQLWarningType, m_aContent.getValueType() ) ) + m_eType = TYPE::SQLWarning; + else if ( isAssignableFrom( aSQLExceptionType, m_aContent.getValueType() ) ) + m_eType = TYPE::SQLException; + else + { + m_eType = TYPE::Undefined; + m_aContent.clear(); + } +} + + +bool SQLExceptionInfo::isKindOf(TYPE _eType) const +{ + switch (_eType) + { + case TYPE::SQLContext: + return (m_eType == TYPE::SQLContext); + case TYPE::SQLWarning: + return (m_eType == TYPE::SQLContext) || (m_eType == TYPE::SQLWarning); + case TYPE::SQLException: + return (m_eType == TYPE::SQLContext) || (m_eType == TYPE::SQLWarning) || (m_eType == TYPE::SQLException); + case TYPE::Undefined: + return (m_eType == TYPE::Undefined); + } + return false; +} + + +SQLExceptionInfo::operator const css::sdbc::SQLException*() const +{ + OSL_ENSURE(isKindOf(TYPE::SQLException), "SQLExceptionInfo::operator SQLException* : invalid call !"); + return o3tl::doAccess(m_aContent); +} + + +SQLExceptionInfo::operator const css::sdb::SQLContext*() const +{ + OSL_ENSURE(isKindOf(TYPE::SQLContext), "SQLExceptionInfo::operator SQLException* : invalid call !"); + return o3tl::doAccess(m_aContent); +} + + +void SQLExceptionInfo::prepend( const OUString& _rErrorMessage ) +{ + SQLException aException; + aException.Message = _rErrorMessage; + aException.ErrorCode = 0; + aException.SQLState = "S1000"; + aException.NextException = m_aContent; + m_aContent <<= aException; + + m_eType = TYPE::SQLException; +} + + +void SQLExceptionInfo::append( TYPE _eType, const OUString& _rErrorMessage, const OUString& _rSQLState, const sal_Int32 _nErrorCode ) +{ + // create the to-be-appended exception + Any aAppend; + switch ( _eType ) + { + case TYPE::SQLException: aAppend <<= SQLException(); break; + case TYPE::SQLWarning: aAppend <<= SQLWarning(); break; + case TYPE::SQLContext: aAppend <<= SQLContext(); break; + default: + OSL_FAIL( "SQLExceptionInfo::append: invalid exception type: this will crash!" ); + break; + } + + SQLException& pAppendException = const_cast(*o3tl::forceAccess(aAppend)); + pAppendException.Message = _rErrorMessage; + pAppendException.SQLState = _rSQLState; + pAppendException.ErrorCode = _nErrorCode; + + // find the end of the current chain + Any* pChainIterator = &m_aContent; + SQLException* pLastException = nullptr; + const Type& aSQLExceptionType( cppu::UnoType::get() ); + while ( pChainIterator ) + { + if ( !pChainIterator->hasValue() ) + break; + + if ( !isAssignableFrom( aSQLExceptionType, pChainIterator->getValueType() ) ) + break; + + pLastException = const_cast< SQLException* >( o3tl::doAccess( *pChainIterator ) ); + 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( const SQLExceptionInfo& _rChainStart ) + :m_pCurrent( nullptr ) + ,m_eCurrentType( SQLExceptionInfo::TYPE::Undefined ) +{ + if ( _rChainStart.isValid() ) + { + m_pCurrent = _rChainStart; + m_eCurrentType = _rChainStart.getType(); + } +} + + +SQLExceptionIteratorHelper::SQLExceptionIteratorHelper( const css::sdbc::SQLException& _rChainStart ) + :m_pCurrent( &_rChainStart ) + ,m_eCurrentType( SQLExceptionInfo::TYPE::SQLException ) +{ +} + + +void SQLExceptionIteratorHelper::current( SQLExceptionInfo& _out_rInfo ) const +{ + switch ( m_eCurrentType ) + { + case SQLExceptionInfo::TYPE::SQLException: + _out_rInfo = *m_pCurrent; + break; + + case SQLExceptionInfo::TYPE::SQLWarning: + _out_rInfo = *static_cast< const SQLWarning* >( m_pCurrent ); + break; + + case SQLExceptionInfo::TYPE::SQLContext: + _out_rInfo = *static_cast< const SQLContext* >( m_pCurrent ); + break; + + default: + _out_rInfo = Any(); + break; + } +} + + +const css::sdbc::SQLException* SQLExceptionIteratorHelper::next() +{ + OSL_ENSURE( hasMoreElements(), "SQLExceptionIteratorHelper::next : invalid call (please use hasMoreElements)!" ); + + const css::sdbc::SQLException* pReturn = m_pCurrent; + 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 = nullptr; + m_eCurrentType = SQLExceptionInfo::TYPE::Undefined; + return pReturn; + } + + m_pCurrent = o3tl::doAccess< SQLException >( m_pCurrent->NextException ); + + // no finally determine the proper type of the exception + const Type aTypeContext( ::cppu::UnoType< SQLContext >::get() ); + if ( isAssignableFrom( aTypeContext, aNextElementType ) ) + { + m_eCurrentType = SQLExceptionInfo::TYPE::SQLContext; + return pReturn; + } + + const Type aTypeWarning( ::cppu::UnoType< SQLWarning >::get() ); + if ( isAssignableFrom( aTypeWarning, aNextElementType ) ) + { + m_eCurrentType = SQLExceptionInfo::TYPE::SQLWarning; + return pReturn; + } + + // a simple SQLException + m_eCurrentType = SQLExceptionInfo::TYPE::SQLException; + return pReturn; +} + + +void SQLExceptionIteratorHelper::next( SQLExceptionInfo& _out_rInfo ) +{ + current( _out_rInfo ); + next(); +} + + +void throwFunctionSequenceException(const Reference< XInterface >& Context, const Any& Next) +{ + ::connectivity::SharedResources aResources; + throw SQLException( + aResources.getResourceString(STR_ERRORMSG_SEQUENCE), + Context, + getStandardSQLState( StandardSQLState::FUNCTION_SEQUENCE_ERROR ), + 0, + Next + ); +} + +void throwInvalidIndexException(const css::uno::Reference< css::uno::XInterface >& Context, + const css::uno::Any& Next) +{ + ::connectivity::SharedResources aResources; + throw SQLException( + aResources.getResourceString(STR_INVALID_INDEX), + Context, + getStandardSQLState( StandardSQLState::INVALID_DESCRIPTOR_INDEX ), + 0, + Next + ); +} + +void throwFunctionNotSupportedSQLException(const OUString& _rFunctionName, + const css::uno::Reference& _rxContext) +{ + ::connectivity::SharedResources aResources; + const OUString sError( aResources.getResourceStringWithSubstitution( + STR_UNSUPPORTED_FUNCTION, + "$functionname$", _rFunctionName + ) ); + throw SQLException( + sError, + _rxContext, + getStandardSQLState( StandardSQLState::FUNCTION_NOT_SUPPORTED ), + 0, + css::uno::Any() + ); +} + +void throwFunctionNotSupportedRuntimeException(const OUString& _rFunctionName, + const css::uno::Reference& _rxContext) +{ + ::connectivity::SharedResources aResources; + const OUString sError( aResources.getResourceStringWithSubstitution( + STR_UNSUPPORTED_FUNCTION, + "$functionname$", _rFunctionName + ) ); + throw RuntimeException( + sError, + _rxContext + ); +} + +void throwGenericSQLException(const OUString& _rMsg, const css::uno::Reference< css::uno::XInterface >& _rxSource) +{ + throwGenericSQLException(_rMsg, _rxSource, Any()); +} + + +void throwGenericSQLException(const OUString& _rMsg, const Reference< XInterface >& _rxSource, const Any& _rNextException) +{ + throw SQLException( _rMsg, _rxSource, getStandardSQLState( StandardSQLState::GENERAL_ERROR ), 0, _rNextException); +} + +void throwFeatureNotImplementedSQLException( const OUString& _rFeatureName, const Reference< XInterface >& _rxContext, const Any& _rNextException ) +{ + ::connectivity::SharedResources aResources; + const OUString sError( aResources.getResourceStringWithSubstitution( + STR_UNSUPPORTED_FEATURE, + "$featurename$", _rFeatureName + ) ); + + throw SQLException( + sError, + _rxContext, + getStandardSQLState( StandardSQLState::FEATURE_NOT_IMPLEMENTED ), + 0, + _rNextException + ); +} + +void throwFeatureNotImplementedRuntimeException(const OUString& _rFeatureName, const Reference< XInterface >& _rxContext) +{ + ::connectivity::SharedResources aResources; + const OUString sError( aResources.getResourceStringWithSubstitution( + STR_UNSUPPORTED_FEATURE, + "$featurename$", _rFeatureName + ) ); + + throw RuntimeException(sError, _rxContext); +} + +void throwInvalidColumnException( const OUString& _rColumnName, const Reference< XInterface >& _rxContext) +{ + ::connectivity::SharedResources aResources; + OUString sErrorMessage( aResources.getResourceStringWithSubstitution( + STR_INVALID_COLUMNNAME, + "$columnname$",_rColumnName) ); + throwSQLException( sErrorMessage, StandardSQLState::COLUMN_NOT_FOUND, _rxContext ); +} + +void throwSQLException( const OUString& _rMessage, const OUString& _rSQLState, + const Reference< XInterface >& _rxContext, const sal_Int32 _nErrorCode ) +{ + throw SQLException( + _rMessage, + _rxContext, + _rSQLState, + _nErrorCode, + Any() + ); +} + + +void throwSQLException( const OUString& _rMessage, StandardSQLState _eSQLState, + const Reference< XInterface >& _rxContext, const sal_Int32 _nErrorCode ) +{ + throwSQLException( _rMessage, getStandardSQLState( _eSQLState ), _rxContext, _nErrorCode ); +} + + +OUString getStandardSQLState( StandardSQLState _eState ) +{ + switch ( _eState ) + { + case StandardSQLState::INVALID_DESCRIPTOR_INDEX: return "07009"; + case StandardSQLState::INVALID_CURSOR_STATE: return "24000"; + case StandardSQLState::COLUMN_NOT_FOUND: return "42S22"; + case StandardSQLState::GENERAL_ERROR: return "HY000"; + case StandardSQLState::INVALID_SQL_DATA_TYPE: return "HY004"; + case StandardSQLState::FUNCTION_SEQUENCE_ERROR: return "HY010"; + case StandardSQLState::INVALID_CURSOR_POSITION: return "HY109"; + case StandardSQLState::FEATURE_NOT_IMPLEMENTED: return "HYC00"; + case StandardSQLState::FUNCTION_NOT_SUPPORTED: return "IM001"; + case StandardSQLState::CONNECTION_DOES_NOT_EXIST: return "08003"; + default: return "HY001"; // General Error + } +} + + +} // namespace dbtools + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/dbmetadata.cxx b/connectivity/source/commontools/dbmetadata.cxx new file mode 100644 index 000000000..f8afdcda6 --- /dev/null +++ b/connectivity/source/commontools/dbmetadata.cxx @@ -0,0 +1,448 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + + +namespace dbtools +{ + + + using ::com::sun::star::uno::Reference; + 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::uno::XComponentContext; + 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::UNO_QUERY; + using ::com::sun::star::sdbcx::XUsersSupplier; + using ::com::sun::star::sdbcx::XDataDefinitionSupplier; + using ::com::sun::star::sdbc::DriverManager; + using ::com::sun::star::sdbc::XDriverManager2; + using ::com::sun::star::uno::UNO_SET_THROW; + + namespace BooleanComparisonMode = ::com::sun::star::sdb::BooleanComparisonMode; + + struct DatabaseMetaData_Impl + { + Reference< XConnection > xConnection; + Reference< XDatabaseMetaData > xConnectionMetaData; + ::connectivity::DriversConfig aDriverConfig; + + ::std::optional< OUString > sCachedIdentifierQuoteString; + ::std::optional< OUString > sCachedCatalogSeparator; + + DatabaseMetaData_Impl() + :xConnection() + ,xConnectionMetaData() + ,aDriverConfig( ::comphelper::getProcessComponentContext() ) + ,sCachedIdentifierQuoteString() + ,sCachedCatalogSeparator() + { + } + }; + + + namespace + { + + 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(); + } + + + void lcl_checkConnected( const DatabaseMetaData_Impl& _metaDataImpl ) + { + if ( !_metaDataImpl.xConnection.is() || !_metaDataImpl.xConnectionMetaData.is() ) + { + ::connectivity::SharedResources aResources; + const OUString sError( aResources.getResourceString(STR_NO_CONNECTION_GIVEN)); + throwSQLException( sError, StandardSQLState::CONNECTION_DOES_NOT_EXIST, nullptr ); + } + } + + + bool lcl_getDriverSetting( const 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; + } + + + bool lcl_getConnectionSetting( const 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("Settings"), + UNO_QUERY_THROW ); + + _out_setting = xDataSourceSettings->getPropertyValue( 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("connectivity.commontools"); + } + return false; + } + + + const OUString& lcl_getConnectionStringSetting( + const DatabaseMetaData_Impl& _metaData, ::std::optional< OUString >& _cachedSetting, + OUString (SAL_CALL XDatabaseMetaData::*_getter)() ) + { + if ( !_cachedSetting ) + { + lcl_checkConnected( _metaData ); + try + { + _cachedSetting = (_metaData.xConnectionMetaData.get()->*_getter)(); + } + catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION("connectivity.commontools"); } + } + return *_cachedSetting; + } + } + + 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(DatabaseMetaData&& _copyFrom) noexcept + :m_pImpl(std::move(_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::operator=(DatabaseMetaData&& _copyFrom) noexcept + { + m_pImpl = std::move(_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 bSupportsSubQueries = false; + try + { + sal_Int32 maxTablesInselect = m_pImpl->xConnectionMetaData->getMaxTablesInSelect(); + bSupportsSubQueries = ( 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("connectivity.commontools"); + } + return bSupportsSubQueries; + } + + + bool DatabaseMetaData::supportsPrimaryKeys() const + { + lcl_checkConnected( *m_pImpl ); + + bool bDoesSupportPrimaryKeys = false; + try + { + Any setting; + if ( !( lcl_getConnectionSetting( "PrimaryKeySupport", *m_pImpl, setting ) ) + || !( setting >>= bDoesSupportPrimaryKeys ) + ) + bDoesSupportPrimaryKeys = m_pImpl->xConnectionMetaData->supportsCoreSQLGrammar() + || m_pImpl->xConnectionMetaData->supportsANSI92EntryLevelSQL(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("connectivity.commontools"); + } + return bDoesSupportPrimaryKeys; + } + + + const OUString& DatabaseMetaData::getIdentifierQuoteString() const + { + return lcl_getConnectionStringSetting( *m_pImpl, m_pImpl->sCachedIdentifierQuoteString, &XDatabaseMetaData::getIdentifierQuoteString ); + } + + + const 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 ) ) + if( ! (setting >>= restrict) ) + SAL_WARN("connectivity.commontools", "restrictIdentifiersToSQL92: unable to assign EnableSQL92Check"); + return restrict; + } + + + bool DatabaseMetaData::generateASBeforeCorrelationName() const + { + bool doGenerate( false ); + Any setting; + if ( lcl_getConnectionSetting( "GenerateASBeforeCorrelationName", *m_pImpl, setting ) ) + if( ! (setting >>= doGenerate) ) + SAL_WARN("connectivity.commontools", "generateASBeforeCorrelationName: unable to assign GenerateASBeforeCorrelationName"); + return doGenerate; + } + + bool DatabaseMetaData::shouldEscapeDateTime() const + { + bool doGenerate( true ); + Any setting; + if ( lcl_getConnectionSetting( "EscapeDateTime", *m_pImpl, setting ) ) + if( ! (setting >>= doGenerate) ) + SAL_WARN("connectivity.commontools", "shouldEscapeDateTime: unable to assign EscapeDateTime"); + return doGenerate; + } + + bool DatabaseMetaData::shouldSubstituteParameterNames() const + { + bool doSubstitute( true ); + Any setting; + if ( lcl_getConnectionSetting( "ParameterNameSubstitution", *m_pImpl, setting ) ) + if( ! (setting >>= doSubstitute) ) + SAL_WARN("connectivity.commontools", "shouldSubstituteParameterNames: unable to assign ParameterNameSubstitution"); + return doSubstitute; + } + + bool DatabaseMetaData::isAutoIncrementPrimaryKey() const + { + bool is( true ); + Any setting; + if ( lcl_getDriverSetting( "AutoIncrementIsPrimaryKey", *m_pImpl, setting ) ) + if( ! (setting >>= is) ) + SAL_WARN("connectivity.commontools", "isAutoIncrementPrimaryKey: unable to assign AutoIncrementIsPrimaryKey"); + return is; + } + + sal_Int32 DatabaseMetaData::getBooleanComparisonMode() const + { + sal_Int32 mode( BooleanComparisonMode::EQUAL_INTEGER ); + Any setting; + if ( lcl_getConnectionSetting( "BooleanComparisonMode", *m_pImpl, setting ) ) + if( ! (setting >>= mode) ) + SAL_WARN("connectivity.commontools", "getBooleanComparisonMode: unable to assign BooleanComparisonMode"); + 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("connectivity.commontools"); + } + try + { + if ( !bSupport ) + { + const OUString url = m_pImpl->xConnectionMetaData->getURL(); + bSupport = url.startsWith("sdbc:mysql"); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("connectivity.commontools"); + } + return bSupport; + } + + + bool DatabaseMetaData::supportsColumnAliasInOrderBy() const + { + bool doGenerate( true ); + Any setting; + if ( lcl_getConnectionSetting( "ColumnAliasInOrderBy", *m_pImpl, setting ) ) + if( ! (setting >>= doGenerate) ) + SAL_WARN("connectivity.commontools", "supportsColumnAliasInOrderBy: unable to assign ColumnAliasInOrderBy"); + return doGenerate; + } + + + bool DatabaseMetaData::supportsUserAdministration( const Reference& _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< XDriverManager2 > xDriverManager = DriverManager::create( _rContext ); + 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("connectivity.commontools"); + } + return isSupported; + } + + + bool DatabaseMetaData::displayEmptyTableFolders() const + { + bool doDisplay( true ); +#ifdef IMPLEMENTED_LATER + Any setting; + if ( lcl_getConnectionSetting( "DisplayEmptyTableFolders", *m_pImpl, setting ) ) + if( ! (setting >>= doDisplay) ) + SAL_WARN("connectivity.commontools", "displayEmptyTableFolders: unable to assign DisplayEmptyTableFolders"); +#else + try + { + Reference< XDatabaseMetaData > xMeta( m_pImpl->xConnectionMetaData, UNO_SET_THROW ); + OUString sConnectionURL( xMeta->getURL() ); + doDisplay = sConnectionURL.startsWith( "sdbc:mysql:mysqlc" ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("connectivity.commontools"); + } +#endif + return doDisplay; + } + + bool DatabaseMetaData::supportsThreads() const + { + bool bSupported( true ); + try + { + Reference< XDatabaseMetaData > xMeta( m_pImpl->xConnectionMetaData, UNO_SET_THROW ); + OUString sConnectionURL( xMeta->getURL() ); + bSupported = !sConnectionURL.startsWith( "sdbc:mysql:mysqlc" ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("connectivity.commontools"); + } + return bSupported; + } + + +} // namespace dbtools + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx new file mode 100644 index 000000000..419cd26e7 --- /dev/null +++ b/connectivity/source/commontools/dbtools.cxx @@ -0,0 +1,2086 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +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::task; +using namespace ::com::sun::star::form; +using namespace connectivity; + +namespace dbtools +{ + +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("Type") >>= nDataType; + + if (DataType::NUMERIC == nDataType || DataType::DECIMAL == nDataType) + _xColumn->getPropertyValue("Scale") >>= nScale; + } + catch (Exception&) + { + return NumberFormat::UNDEFINED; + } + return getDefaultNumberFormat(nDataType, + nScale, + ::cppu::any2bool(_xColumn->getPropertyValue("IsCurrency")), + _xTypes, + _rLocale); +} + +sal_Int32 getDefaultNumberFormat(sal_Int32 _nDataType, + sal_Int32 _nScale, + 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(static_cast(nNumberType), _rLocale); + if(_nScale > 0) + { + // generate a new format if necessary + Reference< XNumberFormats > xFormats(_xTypes, UNO_QUERY); + OUString sNewFormat = xFormats->generateFormat( 0, _rLocale, false, false, static_cast(_nScale), 1); + + // and add it to the formatter if necessary + nFormat = xFormats->queryKey(sNewFormat, _rLocale, false); + if (nFormat == sal_Int32(-1)) + nFormat = xFormats->addNew(sNewFormat, _rLocale); + } + } + catch (Exception&) + { + nFormat = _xTypes->getStandardFormat(static_cast(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); + } + return nFormat; +} + +static 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; +} + +static Reference< XDataSource> getDataSource_allowException( + const OUString& _rsTitleOrPath, + const Reference< XComponentContext >& _rxContext ) +{ + ENSURE_OR_RETURN( !_rsTitleOrPath.isEmpty(), "getDataSource_allowException: invalid arg !", nullptr ); + + Reference< XDatabaseContext> xDatabaseContext = DatabaseContext::create(_rxContext); + + return Reference< XDataSource >( xDatabaseContext->getByName( _rsTitleOrPath ), UNO_QUERY ); +} + +Reference< XDataSource > getDataSource( + const OUString& _rsTitleOrPath, + const Reference< XComponentContext >& _rxContext ) +{ + Reference< XDataSource > xDS; + try + { + xDS = getDataSource_allowException( _rsTitleOrPath, _rxContext ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("connectivity.commontools"); + } + + return xDS; +} + +static Reference< XConnection > getConnection_allowException( + const OUString& _rsTitleOrPath, + const OUString& _rsUser, + const OUString& _rsPwd, + const Reference< XComponentContext>& _rxContext, + const Reference< XWindow >& _rxParent) +{ + Reference< XDataSource> xDataSource( getDataSource_allowException(_rsTitleOrPath, _rxContext) ); + Reference xConnection; + if (xDataSource.is()) + { + + //set ParentWindow for dialog, but just for the duration of this + //call, undo at end of scope + Reference xIni(xDataSource, UNO_QUERY); + if (xIni.is()) + { + Sequence< Any > aArgs(1); + NamedValue aParam( "ParentWindow", makeAny(_rxParent) ); + aArgs[0] <<= aParam; + xIni->initialize(aArgs); + } + + // do it with interaction handler + if(_rsUser.isEmpty() || _rsPwd.isEmpty()) + { + Reference xProp(xDataSource,UNO_QUERY); + OUString sPwd, sUser; + bool bPwdReq = false; + try + { + xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)) >>= sPwd; + bPwdReq = ::cppu::any2bool(xProp->getPropertyValue("IsPasswordRequired")); + xProp->getPropertyValue("User") >>= sUser; + } + catch(Exception&) + { + OSL_FAIL("dbtools::getConnection: error while retrieving data source properties!"); + } + if(bPwdReq && sPwd.isEmpty()) + { // password required, but empty -> connect using an interaction handler + Reference xConnectionCompletion(xProp, UNO_QUERY); + if (xConnectionCompletion.is()) + { // instantiate the default SDB interaction handler + Reference< XInteractionHandler > xHandler = + InteractionHandler::createWithParent(_rxContext, _rxParent); + 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); + + if (xIni.is()) + { + Sequence< Any > aArgs(1); + NamedValue aParam( "ParentWindow", makeAny(Reference()) ); + aArgs[0] <<= aParam; + xIni->initialize(aArgs); + } + + } + return xConnection; +} + +Reference< XConnection> getConnection_withFeedback(const OUString& _rDataSourceName, + const OUString& _rUser, const OUString& _rPwd, const Reference< XComponentContext>& _rxContext, + const Reference< XWindow >& _rxParent) +{ + Reference< XConnection > xReturn; + try + { + xReturn = getConnection_allowException(_rDataSourceName, _rUser, _rPwd, _rxContext, _rxParent); + } + catch(SQLException&) + { + // allowed to pass + throw; + } + catch(Exception&) + { + OSL_FAIL("::dbtools::getConnection_withFeedback: unexpected (non-SQL) exception caught!"); + } + return xReturn; +} + +Reference< XConnection> getConnection(const Reference< XRowSet>& _rxRowSet) +{ + Reference< XConnection> xReturn; + Reference< XPropertySet> xRowSetProps(_rxRowSet, UNO_QUERY); + if (xRowSetProps.is()) + xRowSetProps->getPropertyValue("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) +static SharedConnection lcl_connectRowSet(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext >& _rxContext, + bool _bAttachAutoDisposer, const Reference< XWindow >& _rxParent) +{ + SharedConnection xConnection; + + do + { + Reference< XPropertySet> xRowSetProps(_rxRowSet, UNO_QUERY); + if ( !xRowSetProps.is() ) + break; + + // 1. already connected? + Reference< XConnection > xExistingConn( + xRowSetProps->getPropertyValue("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() + ) + { + xRowSetProps->setPropertyValue("ActiveConnection", makeAny( xExistingConn ) ); + // no auto disposer needed, since we did not create the connection + + xConnection.reset( xExistingConn, SharedConnection::NoTakeOwnership ); + break; + } + + // build a connection with its current settings (4. data source name, or 5. URL) + + const OUString sUserProp( "User" ); + OUString sDataSourceName; + xRowSetProps->getPropertyValue("DataSourceName") >>= sDataSourceName; + OUString sURL; + xRowSetProps->getPropertyValue("URL") >>= sURL; + + Reference< XConnection > xPureConnection; + if (!sDataSourceName.isEmpty()) + { // the row set's data source property is set + // -> try to connect, get user and pwd setting for that + 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, _rxContext, _rxParent ); + } + else if (!sURL.isEmpty()) + { // the row set has no data source, but a connection url set + // -> try to connection with that url + Reference< XConnectionPool > xDriverManager; + try { + xDriverManager = ConnectionPool::create( _rxContext ); + } catch( const Exception& ) { } + if (xDriverManager.is()) + { + 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.isEmpty()) + { // use user and pwd together with the url + auto aInfo(::comphelper::InitPropertySequence({ + { "user", makeAny(sUser) }, + { "password", makeAny(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() ) + { + try + { + if ( _bAttachAutoDisposer ) + { + new OAutoConnectionDisposer( _rxRowSet, xConnection ); + } + else + xRowSetProps->setPropertyValue( + "ActiveConnection", + makeAny( xConnection.getTyped() ) + ); + } + catch(Exception&) + { + OSL_FAIL("EXception when we set the new active connection!"); + } + } + } + while ( false ); + + return xConnection; +} + +Reference< XConnection> connectRowset(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext >& _rxContext, const Reference< XWindow >& _rxParent) +{ + SharedConnection xConnection = lcl_connectRowSet( _rxRowSet, _rxContext, true, _rxParent ); + return xConnection.getTyped(); +} + +SharedConnection ensureRowSetConnection(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext>& _rxContext, const Reference< XWindow >& _rxParent) +{ + return lcl_connectRowSet( _rxRowSet, _rxContext, false/*bUseAutoConnectionDisposer*/, _rxParent ); +} + +Reference< XNameAccess> getTableFields(const Reference< XConnection>& _rxConn,const 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 xKeyColumns; + const Reference xKeySup(i_xTable,UNO_QUERY); + if ( xKeySup.is() ) + { + const Reference xKeys = xKeySup->getKeys(); + if ( xKeys.is() ) + { + ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap(); + const OUString& sPropName = rPropMap.getNameByIndex(PROPERTY_ID_TYPE); + Reference xProp; + const sal_Int32 nCount = xKeys->getCount(); + for(sal_Int32 i = 0;i< nCount;++i) + { + xProp.set(xKeys->getByIndex(i),UNO_QUERY_THROW); + sal_Int32 nKeyType = 0; + xProp->getPropertyValue(sPropName) >>= nKeyType; + if(KeyType::PRIMARY == nKeyType) + { + const Reference 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 OUString& _rCommand, + Reference< XComponent >& _rxKeepFieldsAlive, SQLExceptionInfo* _pErrorInfo ) +{ + 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.isEmpty(), "::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() && 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: + { + 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("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( "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.set(xStatement, css::uno::UNO_QUERY); + + // 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( "MaxRows", makeAny( sal_Int32( 0 ) ) ); + } + catch( const Exception& ) + { + OSL_FAIL( "::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.set(xStatement->executeQuery(), css::uno::UNO_QUERY); + // 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_FAIL( "::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_FAIL( "::dbtools::getFieldsByCommandDescriptor: caught an exception while retrieving the fields!" ); + } + + return xFields; +} + +Sequence< OUString > getFieldNamesByCommandDescriptor( const Reference< XConnection >& _rxConnection, + const sal_Int32 _nCommandType, const OUString& _rCommand, + SQLExceptionInfo* _pErrorInfo ) +{ + // 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< OUString > aNames; + if ( xFieldContainer.is() ) + aNames = xFieldContainer->getElementNames(); + + // clean up any temporary objects which have been created + disposeComponent( xKeepFieldsAlive ); + + // outta here + return aNames; +} + +SQLException prependErrorInfo( const SQLException& _rChainedException, const Reference< XInterface >& _rxContext, + const OUString& _rAdditionalError, const StandardSQLState _eSQLState ) +{ + return SQLException( _rAdditionalError, _rxContext, + _eSQLState == StandardSQLState::ERROR_UNSPECIFIED ? OUString() : getStandardSQLState( _eSQLState ), + 0, makeAny( _rChainedException ) ); +} + +namespace +{ + struct NameComponentSupport + { + const bool bCatalogs; + const bool bSchemas; + + 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 EComposeRule::InTableDefinitions: + pCatalogCall = &XDatabaseMetaData::supportsCatalogsInTableDefinitions; + pSchemaCall = &XDatabaseMetaData::supportsSchemasInTableDefinitions; + break; + case EComposeRule::InIndexDefinitions: + pCatalogCall = &XDatabaseMetaData::supportsCatalogsInIndexDefinitions; + pSchemaCall = &XDatabaseMetaData::supportsSchemasInIndexDefinitions; + break; + case EComposeRule::InProcedureCalls: + pCatalogCall = &XDatabaseMetaData::supportsCatalogsInProcedureCalls; + pSchemaCall = &XDatabaseMetaData::supportsSchemasInProcedureCalls; + break; + case EComposeRule::InPrivilegeDefinitions: + pCatalogCall = &XDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions; + pSchemaCall = &XDatabaseMetaData::supportsSchemasInPrivilegeDefinitions; + break; + case EComposeRule::Complete: + bIgnoreMetaData = true; + break; + case EComposeRule::InDataManipulation: + // already properly set above + break; + } + return NameComponentSupport( + bIgnoreMetaData || (_rxMetaData.get()->*pCatalogCall)(), + bIgnoreMetaData || (_rxMetaData.get()->*pSchemaCall)() + ); + } +} + +static OUString impl_doComposeTableName( const Reference< XDatabaseMetaData >& _rxMetaData, + const OUString& _rCatalog, const OUString& _rSchema, const OUString& _rName, + bool _bQuote, EComposeRule _eComposeRule ) +{ + OSL_ENSURE(_rxMetaData.is(), "impl_doComposeTableName : invalid meta data !"); + if ( !_rxMetaData.is() ) + return OUString(); + OSL_ENSURE(!_rName.isEmpty(), "impl_doComposeTableName : at least the name should be non-empty !"); + + const OUString sQuoteString = _rxMetaData->getIdentifierQuoteString(); + const NameComponentSupport aNameComps( lcl_getNameComponentSupport( _rxMetaData, _eComposeRule ) ); + + OUStringBuffer aComposedName; + + OUString sCatalogSep; + bool bCatlogAtStart = true; + if ( !_rCatalog.isEmpty() && aNameComps.bCatalogs ) + { + sCatalogSep = _rxMetaData->getCatalogSeparator(); + bCatlogAtStart = _rxMetaData->isCatalogAtStart(); + + if ( bCatlogAtStart && !sCatalogSep.isEmpty()) + { + aComposedName.append( _bQuote ? quoteName( sQuoteString, _rCatalog ) : _rCatalog ); + aComposedName.append( sCatalogSep ); + } + } + + if ( !_rSchema.isEmpty() && aNameComps.bSchemas ) + { + aComposedName.append( _bQuote ? quoteName( sQuoteString, _rSchema ) : _rSchema ); + aComposedName.append( "." ); + } + + aComposedName.append( _bQuote ? quoteName( sQuoteString, _rName ) : _rName ); + + if ( !_rCatalog.isEmpty() + && !bCatlogAtStart + && !sCatalogSep.isEmpty() + && aNameComps.bCatalogs + ) + { + aComposedName.append( sCatalogSep ); + aComposedName.append( _bQuote ? quoteName( sQuoteString, _rCatalog ) : _rCatalog ); + } + + return aComposedName.makeStringAndClear(); +} + +OUString quoteTableName(const Reference< XDatabaseMetaData>& _rxMeta + , const OUString& _rName + , EComposeRule _eComposeRule) +{ + OUString sCatalog, sSchema, sTable; + qualifiedNameComponents(_rxMeta,_rName,sCatalog,sSchema,sTable,_eComposeRule); + return impl_doComposeTableName( _rxMeta, sCatalog, sSchema, sTable, true, _eComposeRule ); +} + +void qualifiedNameComponents(const Reference< XDatabaseMetaData >& _rxConnMetaData, const OUString& _rQualifiedName, OUString& _rCatalog, OUString& _rSchema, OUString& _rName,EComposeRule _eComposeRule) +{ + OSL_ENSURE(_rxConnMetaData.is(), "QualifiedNameComponents : invalid meta data!"); + + NameComponentSupport aNameComps( lcl_getNameComponentSupport( _rxConnMetaData, _eComposeRule ) ); + + OUString sSeparator = _rxConnMetaData->getCatalogSeparator(); + + 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 + { + // Catalog name at the end + 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('.'); + // 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, + bool _bAlloweDefault, + const Reference< XComponentContext>& _rxContext) +{ + // ask the parent of the connection (should be a DatabaseAccess) + Reference< XNumberFormatsSupplier> xReturn; + Reference< XChild> xConnAsChild(_rxConn, UNO_QUERY); + OUString sPropFormatsSupplier( "NumberFormatsSupplier" ); + if (xConnAsChild.is()) + { + Reference< XPropertySet> xConnParentProps(xConnAsChild->getParent(), UNO_QUERY); + if (xConnParentProps.is() && hasProperty(sPropFormatsSupplier, xConnParentProps)) + xConnParentProps->getPropertyValue(sPropFormatsSupplier) >>= xReturn; + } + else if(_bAlloweDefault && _rxContext.is()) + { + xReturn = NumberFormatsSupplier::createWithDefaultLocale( _rxContext ); + } + 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; + + // First we copy all the Props, that are available in source and target and have the same description + Reference< XPropertySetInfo> xOldInfo( xOldProps->getPropertySetInfo()); + Reference< XPropertySetInfo> xNewInfo( xNewProps->getPropertySetInfo()); + + const Sequence< Property> aOldProperties = xOldInfo->getProperties(); + Sequence< Property> aNewProperties = xNewInfo->getProperties(); + int nNewLen = aNewProperties.getLength(); + + Property* pNewProps = aNewProperties.getArray(); + + OUString sPropFormatsSupplier("FormatsSupplier"); + OUString sPropCurrencySymbol("CurrencySymbol"); + OUString sPropDecimals("Decimals"); + OUString sPropEffectiveMin("EffectiveMin"); + OUString sPropEffectiveMax("EffectiveMax"); + OUString sPropEffectiveDefault("EffectiveDefault"); + OUString sPropDefaultText("DefaultText"); + OUString sPropDefaultDate("DefaultDate"); + OUString sPropDefaultTime("DefaultTime"); + OUString sPropValueMin("ValueMin"); + OUString sPropValueMax("ValueMax"); + OUString sPropDecimalAccuracy("DecimalAccuracy"); + OUString sPropClassId("ClassId"); + OUString sFormattedServiceName( "com.sun.star.form.component.FormattedField" ); + + for (const Property& rOldProp : aOldProperties) + { + if ( rOldProp.Name != "DefaultControl" && rOldProp.Name != "LabelControl" ) + { + // binary search + Property* pResult = std::lower_bound( + pNewProps, pNewProps + nNewLen, rOldProp, ::comphelper::PropertyCompareByName()); + + if ( ( pResult != aNewProperties.end() ) + && ( pResult->Name == rOldProp.Name ) + && ( (pResult->Attributes & PropertyAttribute::READONLY) == 0 ) + && ( pResult->Type.equals(rOldProp.Type)) ) + { // Attributes match and the property is not read-only + try + { + xNewProps->setPropertyValue(pResult->Name, xOldProps->getPropertyValue(pResult->Name)); + } + catch(IllegalArgumentException const &) + { + TOOLS_WARN_EXCEPTION( "connectivity.commontools", "TransferFormComponentProperties : could not transfer the value for property \"" + << pResult->Name << "\""); + } + } + } + } + + // for formatted fields (either old or new) we have some special treatments + Reference< XServiceInfo > xSI( xOldProps, UNO_QUERY ); + bool bOldIsFormatted = xSI.is() && xSI->supportsService( sFormattedServiceName ); + xSI.set( xNewProps, UNO_QUERY ); + bool bNewIsFormatted = xSI.is() && xSI->supportsService( sFormattedServiceName ); + + if (!bOldIsFormatted && !bNewIsFormatted) + return; // nothing to do + + if (bOldIsFormatted && bNewIsFormatted) + // if both fields are formatted we do no conversions + return; + + if (bOldIsFormatted) + { + // get some properties from the selected format and put them in the new Set + 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)) + // If the source value hasn't been set then don't copy it + // so we don't overwrite the default value + xNewProps->setPropertyValue(sPropCurrencySymbol, aVal); + } + if (hasProperty(sPropDecimals, xFormat) && hasProperty(sPropDecimals, xNewProps)) + xNewProps->setPropertyValue(sPropDecimals, xFormat->getPropertyValue(sPropDecimals)); + } + } + + // a potential Min-Max-Conversion + Any aEffectiveMin( xOldProps->getPropertyValue(sPropEffectiveMin) ); + if (aEffectiveMin.hasValue()) + { // Unlike the ValueMin the EffectiveMin can be void + 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); + } + } + + // then we can still convert and copy the default values + Any aEffectiveDefault( xOldProps->getPropertyValue(sPropEffectiveDefault) ); + if (aEffectiveDefault.hasValue()) + { + bool bIsString = aEffectiveDefault.getValueType().getTypeClass() == TypeClass_STRING; + OSL_ENSURE(bIsString || aEffectiveDefault.getValueType().getTypeClass() == TypeClass_DOUBLE, + "TransferFormComponentProperties : invalid property type !"); + // The Effective-Properties should always be void or string or double... + + if (hasProperty(sPropDefaultDate, xNewProps) && !bIsString) + { // (to convert an OUString into a date will not always succeed, because it might be bound to a text-column, + // but we can work with a double) + Date aDate = DBTypeConversion::toDate(getDouble(aEffectiveDefault)); + xNewProps->setPropertyValue(sPropDefaultDate, makeAny(aDate)); + } + + if (hasProperty(sPropDefaultTime, xNewProps) && !bIsString) + { // Completely analogous to time + css::util::Time aTime = DBTypeConversion::toTime(getDouble(aEffectiveDefault)); + xNewProps->setPropertyValue(sPropDefaultTime, makeAny(aTime)); + } + + if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE), xNewProps) && !bIsString) + { // Here we can simply pass the double + xNewProps->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE), aEffectiveDefault); + } + + if (hasProperty(sPropDefaultText, xNewProps) && bIsString) + { // and here the OUString + xNewProps->setPropertyValue(sPropDefaultText, aEffectiveDefault); + } + + // nyi: The translation between doubles and OUString would offer more alternatives + } + } + + // The other direction: the new Control shall be formatted + if (bNewIsFormatted) + { + // first the formatting + // we can't set a Supplier, so the new Set must bring one in + Reference< XNumberFormatsSupplier> xSupplier; + xNewProps->getPropertyValue(sPropFormatsSupplier) >>= xSupplier; + if (xSupplier.is()) + { + Reference< XNumberFormats> xFormats(xSupplier->getNumberFormats()); + + // Set number of decimals + sal_Int16 nDecimals = 2; + if (hasProperty(sPropDecimalAccuracy, xOldProps)) + xOldProps->getPropertyValue(sPropDecimalAccuracy) >>= nDecimals; + + // base format (depending on the ClassId of the old Set) + 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; + } + } + } + + // With this we can generate a new format ... + OUString sNewFormat = xFormats->generateFormat(nBaseKey, _rLocale, false, false, nDecimals, 0); + // No thousands separator, negative numbers are not in red, no leading zeros + + // ... and add at FormatsSupplier (if needed) + sal_Int32 nKey = xFormats->queryKey(sNewFormat, _rLocale, false); + if (nKey == sal_Int32(-1)) + { // not added yet in my formatter ... + nKey = xFormats->addNew(sNewFormat, _rLocale); + } + + xNewProps->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FORMATKEY), makeAny(nKey)); + } + + // min-/max-Value + 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-Value + Any aNewDefault; + if (hasProperty(sPropDefaultDate, xOldProps)) + { + Any aDate( xOldProps->getPropertyValue(sPropDefaultDate) ); + if (aDate.hasValue()) + aNewDefault <<= DBTypeConversion::toDouble(*o3tl::doAccess(aDate)); + } + + if (hasProperty(sPropDefaultTime, xOldProps)) + { + Any aTime( xOldProps->getPropertyValue(sPropDefaultTime) ); + if (aTime.hasValue()) + aNewDefault <<= DBTypeConversion::toDouble(*o3tl::doAccess