LCOV - code coverage report
Current view: top level - connectivity/source/drivers/odbc - ORealDriver.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 4 124 3.2 %
Date: 2015-06-13 12:38:46 Functions: 4 6 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "ORealDriver.hxx"
      21             : #include "odbc/ODriver.hxx"
      22             : #include "odbc/OTools.hxx"
      23             : #include "odbc/OFunctions.hxx"
      24             : #include "diagnose_ex.h"
      25             : 
      26             : namespace connectivity
      27             : {
      28             :     // extern declaration of the function pointer
      29             :     extern T3SQLAllocHandle pODBC3SQLAllocHandle;
      30             :     extern T3SQLConnect pODBC3SQLConnect;
      31             :     extern T3SQLDriverConnect pODBC3SQLDriverConnect;
      32             :     extern T3SQLBrowseConnect pODBC3SQLBrowseConnect;
      33             :     extern T3SQLDataSources pODBC3SQLDataSources;
      34             :     extern T3SQLDrivers pODBC3SQLDrivers;
      35             :     extern T3SQLGetInfo pODBC3SQLGetInfo;
      36             :     extern T3SQLGetFunctions pODBC3SQLGetFunctions;
      37             :     extern T3SQLGetTypeInfo pODBC3SQLGetTypeInfo;
      38             :     extern T3SQLSetConnectAttr pODBC3SQLSetConnectAttr;
      39             :     extern T3SQLGetConnectAttr pODBC3SQLGetConnectAttr;
      40             :     extern T3SQLSetEnvAttr pODBC3SQLSetEnvAttr;
      41             :     extern T3SQLGetEnvAttr pODBC3SQLGetEnvAttr;
      42             :     extern T3SQLSetStmtAttr pODBC3SQLSetStmtAttr;
      43             :     extern T3SQLGetStmtAttr pODBC3SQLGetStmtAttr;
      44             :     //extern T3SQLSetDescField pODBC3SQLSetDescField;
      45             :     //extern T3SQLGetDescField pODBC3SQLGetDescField;
      46             :     //extern T3SQLGetDescRec pODBC3SQLGetDescRec;
      47             :     //extern T3SQLSetDescRec pODBC3SQLSetDescRec;
      48             :     extern T3SQLPrepare pODBC3SQLPrepare;
      49             :     extern T3SQLBindParameter pODBC3SQLBindParameter;
      50             :     //extern T3SQLGetCursorName pODBC3SQLGetCursorName;
      51             :     extern T3SQLSetCursorName pODBC3SQLSetCursorName;
      52             :     extern T3SQLExecute pODBC3SQLExecute;
      53             :     extern T3SQLExecDirect pODBC3SQLExecDirect;
      54             :     //extern T3SQLNativeSql pODBC3SQLNativeSql;
      55             :     extern T3SQLDescribeParam pODBC3SQLDescribeParam;
      56             :     extern T3SQLNumParams pODBC3SQLNumParams;
      57             :     extern T3SQLParamData pODBC3SQLParamData;
      58             :     extern T3SQLPutData pODBC3SQLPutData;
      59             :     extern T3SQLRowCount pODBC3SQLRowCount;
      60             :     extern T3SQLNumResultCols pODBC3SQLNumResultCols;
      61             :     extern T3SQLDescribeCol pODBC3SQLDescribeCol;
      62             :     extern T3SQLColAttribute pODBC3SQLColAttribute;
      63             :     extern T3SQLBindCol pODBC3SQLBindCol;
      64             :     extern T3SQLFetch pODBC3SQLFetch;
      65             :     extern T3SQLFetchScroll pODBC3SQLFetchScroll;
      66             :     extern T3SQLGetData pODBC3SQLGetData;
      67             :     extern T3SQLSetPos pODBC3SQLSetPos;
      68             :     extern T3SQLBulkOperations pODBC3SQLBulkOperations;
      69             :     extern T3SQLMoreResults pODBC3SQLMoreResults;
      70             :     //extern T3SQLGetDiagField pODBC3SQLGetDiagField;
      71             :     extern T3SQLGetDiagRec pODBC3SQLGetDiagRec;
      72             :     extern T3SQLColumnPrivileges pODBC3SQLColumnPrivileges;
      73             :     extern T3SQLColumns pODBC3SQLColumns;
      74             :     extern T3SQLForeignKeys pODBC3SQLForeignKeys;
      75             :     extern T3SQLPrimaryKeys pODBC3SQLPrimaryKeys;
      76             :     extern T3SQLProcedureColumns pODBC3SQLProcedureColumns;
      77             :     extern T3SQLProcedures pODBC3SQLProcedures;
      78             :     extern T3SQLSpecialColumns pODBC3SQLSpecialColumns;
      79             :     extern T3SQLStatistics pODBC3SQLStatistics;
      80             :     extern T3SQLTablePrivileges pODBC3SQLTablePrivileges;
      81             :     extern T3SQLTables pODBC3SQLTables;
      82             :     extern T3SQLFreeStmt pODBC3SQLFreeStmt;
      83             :     extern T3SQLCloseCursor pODBC3SQLCloseCursor;
      84             :     extern T3SQLCancel pODBC3SQLCancel;
      85             :     extern T3SQLEndTran pODBC3SQLEndTran;
      86             :     extern T3SQLDisconnect pODBC3SQLDisconnect;
      87             :     extern T3SQLFreeHandle pODBC3SQLFreeHandle;
      88             :     extern T3SQLGetCursorName pODBC3SQLGetCursorName;
      89             :     extern T3SQLNativeSql pODBC3SQLNativeSql;
      90             : 
      91             : 
      92             :     namespace odbc
      93             :     {
      94           2 :         class ORealObdcDriver : public ODBCDriver
      95             :         {
      96             :         protected:
      97             :             virtual oslGenericFunction  getOdbcFunction(ODBC3SQLFunctionId _nIndex)  const SAL_OVERRIDE;
      98             :             virtual SQLHANDLE   EnvironmentHandle(OUString &_rPath) SAL_OVERRIDE;
      99             :         public:
     100           1 :             ORealObdcDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) : ODBCDriver(_rxFactory) {}
     101             :         };
     102             : 
     103             : 
     104           0 : oslGenericFunction ORealObdcDriver::getOdbcFunction(ODBC3SQLFunctionId _nIndex) const
     105             : {
     106           0 :     oslGenericFunction pFunction = NULL;
     107           0 :     switch(_nIndex)
     108             :     {
     109             :         case ODBC3SQLFunctionId::AllocHandle:
     110           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLAllocHandle);
     111           0 :             break;
     112             :         case ODBC3SQLFunctionId::Connect:
     113           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLConnect);
     114           0 :             break;
     115             :         case ODBC3SQLFunctionId::DriverConnect:
     116           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLDriverConnect);
     117           0 :             break;
     118             :         case ODBC3SQLFunctionId::BrowseConnect:
     119           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLBrowseConnect);
     120           0 :             break;
     121             :         case ODBC3SQLFunctionId::DataSources:
     122           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLDataSources);
     123           0 :             break;
     124             :         case ODBC3SQLFunctionId::Drivers:
     125           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLDrivers);
     126           0 :             break;
     127             :         case ODBC3SQLFunctionId::GetInfo:
     128             : 
     129           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetInfo);
     130           0 :             break;
     131             :         case ODBC3SQLFunctionId::GetFunctions:
     132             : 
     133           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetFunctions);
     134           0 :             break;
     135             :         case ODBC3SQLFunctionId::GetTypeInfo:
     136             : 
     137           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetTypeInfo);
     138           0 :             break;
     139             :         case ODBC3SQLFunctionId::SetConnectAttr:
     140             : 
     141           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLSetConnectAttr);
     142           0 :             break;
     143             :         case ODBC3SQLFunctionId::GetConnectAttr:
     144             : 
     145           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetConnectAttr);
     146           0 :             break;
     147             :         case ODBC3SQLFunctionId::SetEnvAttr:
     148             : 
     149           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLSetEnvAttr);
     150           0 :             break;
     151             :         case ODBC3SQLFunctionId::GetEnvAttr:
     152             : 
     153           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetEnvAttr);
     154           0 :             break;
     155             :         case ODBC3SQLFunctionId::SetStmtAttr:
     156             : 
     157           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLSetStmtAttr);
     158           0 :             break;
     159             :         case ODBC3SQLFunctionId::GetStmtAttr:
     160             : 
     161           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetStmtAttr);
     162           0 :             break;
     163             :         case ODBC3SQLFunctionId::Prepare:
     164             : 
     165           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLPrepare);
     166           0 :             break;
     167             :         case ODBC3SQLFunctionId::BindParameter:
     168             : 
     169           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLBindParameter);
     170           0 :             break;
     171             :         case ODBC3SQLFunctionId::SetCursorName:
     172             : 
     173           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLSetCursorName);
     174           0 :             break;
     175             :         case ODBC3SQLFunctionId::Execute:
     176             : 
     177           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLExecute);
     178           0 :             break;
     179             :         case ODBC3SQLFunctionId::ExecDirect:
     180             : 
     181           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLExecDirect);
     182           0 :             break;
     183             :         case ODBC3SQLFunctionId::DescribeParam:
     184             : 
     185           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLDescribeParam);
     186           0 :             break;
     187             :         case ODBC3SQLFunctionId::NumParams:
     188             : 
     189           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLNumParams);
     190           0 :             break;
     191             :         case ODBC3SQLFunctionId::ParamData:
     192             : 
     193           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLParamData);
     194           0 :             break;
     195             :         case ODBC3SQLFunctionId::PutData:
     196             : 
     197           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLPutData);
     198           0 :             break;
     199             :         case ODBC3SQLFunctionId::RowCount:
     200             : 
     201           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLRowCount);
     202           0 :             break;
     203             :         case ODBC3SQLFunctionId::NumResultCols:
     204             : 
     205           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLNumResultCols);
     206           0 :             break;
     207             :         case ODBC3SQLFunctionId::DescribeCol:
     208             : 
     209           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLDescribeCol);
     210           0 :             break;
     211             :         case ODBC3SQLFunctionId::ColAttribute:
     212             : 
     213           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLColAttribute);
     214           0 :             break;
     215             :         case ODBC3SQLFunctionId::BindCol:
     216             : 
     217           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLBindCol);
     218           0 :             break;
     219             :         case ODBC3SQLFunctionId::Fetch:
     220             : 
     221           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLFetch);
     222           0 :             break;
     223             :         case ODBC3SQLFunctionId::FetchScroll:
     224             : 
     225           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLFetchScroll);
     226           0 :             break;
     227             :         case ODBC3SQLFunctionId::GetData:
     228             : 
     229           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetData);
     230           0 :             break;
     231             :         case ODBC3SQLFunctionId::SetPos:
     232             : 
     233           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLSetPos);
     234           0 :             break;
     235             :         case ODBC3SQLFunctionId::BulkOperations:
     236             : 
     237           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLBulkOperations);
     238           0 :             break;
     239             :         case ODBC3SQLFunctionId::MoreResults:
     240             : 
     241           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLMoreResults);
     242           0 :             break;
     243             :         case ODBC3SQLFunctionId::GetDiagRec:
     244             : 
     245           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetDiagRec);
     246           0 :             break;
     247             :         case ODBC3SQLFunctionId::ColumnPrivileges:
     248             : 
     249           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLColumnPrivileges);
     250           0 :             break;
     251             :         case ODBC3SQLFunctionId::Columns:
     252             : 
     253           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLColumns);
     254           0 :             break;
     255             :         case ODBC3SQLFunctionId::ForeignKeys:
     256             : 
     257           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLForeignKeys);
     258           0 :             break;
     259             :         case ODBC3SQLFunctionId::PrimaryKeys:
     260             : 
     261           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLPrimaryKeys);
     262           0 :             break;
     263             :         case ODBC3SQLFunctionId::ProcedureColumns:
     264             : 
     265           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLProcedureColumns);
     266           0 :             break;
     267             :         case ODBC3SQLFunctionId::Procedures:
     268             : 
     269           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLProcedures);
     270           0 :             break;
     271             :         case ODBC3SQLFunctionId::SpecialColumns:
     272             : 
     273           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLSpecialColumns);
     274           0 :             break;
     275             :         case ODBC3SQLFunctionId::Statistics:
     276             : 
     277           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLStatistics);
     278           0 :             break;
     279             :         case ODBC3SQLFunctionId::TablePrivileges:
     280             : 
     281           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLTablePrivileges);
     282           0 :             break;
     283             :         case ODBC3SQLFunctionId::Tables:
     284             : 
     285           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLTables);
     286           0 :             break;
     287             :         case ODBC3SQLFunctionId::FreeStmt:
     288             : 
     289           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLFreeStmt);
     290           0 :             break;
     291             :         case ODBC3SQLFunctionId::CloseCursor:
     292             : 
     293           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLCloseCursor);
     294           0 :             break;
     295             :         case ODBC3SQLFunctionId::Cancel:
     296             : 
     297           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLCancel);
     298           0 :             break;
     299             :         case ODBC3SQLFunctionId::EndTran:
     300             : 
     301           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLEndTran);
     302           0 :             break;
     303             :         case ODBC3SQLFunctionId::Disconnect:
     304             : 
     305           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLDisconnect);
     306           0 :             break;
     307             :         case ODBC3SQLFunctionId::FreeHandle:
     308             : 
     309           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLFreeHandle);
     310           0 :             break;
     311             :         case ODBC3SQLFunctionId::GetCursorName:
     312             : 
     313           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetCursorName);
     314           0 :             break;
     315             :         case ODBC3SQLFunctionId::NativeSql:
     316             : 
     317           0 :             pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLNativeSql);
     318           0 :             break;
     319             :         default:
     320             :             OSL_FAIL("Function unknown!");
     321             :     }
     322           0 :     return pFunction;
     323             : }
     324             : 
     325             : 
     326           1 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  SAL_CALL ODBCDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
     327             : {
     328           1 :     return *(new ORealObdcDriver(_rxFactory));
     329             : }
     330             : 
     331             : // ODBC Environment (common for all Connections):
     332           0 : SQLHANDLE ORealObdcDriver::EnvironmentHandle(OUString &_rPath)
     333             : {
     334             :     // Is (for this instance) already a Environment made?
     335           0 :     if (!m_pDriverHandle)
     336             :     {
     337           0 :         SQLHANDLE h = SQL_NULL_HANDLE;
     338             :         // allocate Environment
     339             : 
     340             :         // load ODBC-DLL now:
     341           0 :         if (!LoadLibrary_ODBC3(_rPath) || N3SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&h) != SQL_SUCCESS)
     342           0 :             return SQL_NULL_HANDLE;
     343             : 
     344             :         // Save in global Structure
     345           0 :         m_pDriverHandle = h;
     346           0 :         SQLRETURN nError = N3SQLSetEnvAttr(h, SQL_ATTR_ODBC_VERSION, reinterpret_cast<SQLPOINTER>(SQL_OV_ODBC3), SQL_IS_UINTEGER);
     347             :         OSL_UNUSED( nError );
     348             :         //N3SQLSetEnvAttr(h, SQL_ATTR_CONNECTION_POOLING,(SQLPOINTER) SQL_CP_ONE_PER_HENV, SQL_IS_INTEGER);
     349             :     }
     350             : 
     351           0 :     return m_pDriverHandle;
     352             : }
     353             : 
     354             : 
     355             :     }
     356             : }
     357             : 
     358             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11