LCOV - code coverage report
Current view: top level - connectivity/source/drivers/odbc - ORealDriver.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 124 0.0 %
Date: 2014-04-14 Functions: 0 6 0.0 %
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             :     sal_Bool LoadLibrary_ODBC3(OUString &_rPath);
      29             :     // extern declaration of the function pointer
      30             :     extern T3SQLAllocHandle pODBC3SQLAllocHandle;
      31             :     extern T3SQLConnect pODBC3SQLConnect;
      32             :     extern T3SQLDriverConnect pODBC3SQLDriverConnect;
      33             :     extern T3SQLBrowseConnect pODBC3SQLBrowseConnect;
      34             :     extern T3SQLDataSources pODBC3SQLDataSources;
      35             :     extern T3SQLDrivers pODBC3SQLDrivers;
      36             :     extern T3SQLGetInfo pODBC3SQLGetInfo;
      37             :     extern T3SQLGetFunctions pODBC3SQLGetFunctions;
      38             :     extern T3SQLGetTypeInfo pODBC3SQLGetTypeInfo;
      39             :     extern T3SQLSetConnectAttr pODBC3SQLSetConnectAttr;
      40             :     extern T3SQLGetConnectAttr pODBC3SQLGetConnectAttr;
      41             :     extern T3SQLSetEnvAttr pODBC3SQLSetEnvAttr;
      42             :     extern T3SQLGetEnvAttr pODBC3SQLGetEnvAttr;
      43             :     extern T3SQLSetStmtAttr pODBC3SQLSetStmtAttr;
      44             :     extern T3SQLGetStmtAttr pODBC3SQLGetStmtAttr;
      45             :     //extern T3SQLSetDescField pODBC3SQLSetDescField;
      46             :     //extern T3SQLGetDescField pODBC3SQLGetDescField;
      47             :     //extern T3SQLGetDescRec pODBC3SQLGetDescRec;
      48             :     //extern T3SQLSetDescRec pODBC3SQLSetDescRec;
      49             :     extern T3SQLPrepare pODBC3SQLPrepare;
      50             :     extern T3SQLBindParameter pODBC3SQLBindParameter;
      51             :     //extern T3SQLGetCursorName pODBC3SQLGetCursorName;
      52             :     extern T3SQLSetCursorName pODBC3SQLSetCursorName;
      53             :     extern T3SQLExecute pODBC3SQLExecute;
      54             :     extern T3SQLExecDirect pODBC3SQLExecDirect;
      55             :     //extern T3SQLNativeSql pODBC3SQLNativeSql;
      56             :     extern T3SQLDescribeParam pODBC3SQLDescribeParam;
      57             :     extern T3SQLNumParams pODBC3SQLNumParams;
      58             :     extern T3SQLParamData pODBC3SQLParamData;
      59             :     extern T3SQLPutData pODBC3SQLPutData;
      60             :     extern T3SQLRowCount pODBC3SQLRowCount;
      61             :     extern T3SQLNumResultCols pODBC3SQLNumResultCols;
      62             :     extern T3SQLDescribeCol pODBC3SQLDescribeCol;
      63             :     extern T3SQLColAttribute pODBC3SQLColAttribute;
      64             :     extern T3SQLBindCol pODBC3SQLBindCol;
      65             :     extern T3SQLFetch pODBC3SQLFetch;
      66             :     extern T3SQLFetchScroll pODBC3SQLFetchScroll;
      67             :     extern T3SQLGetData pODBC3SQLGetData;
      68             :     extern T3SQLSetPos pODBC3SQLSetPos;
      69             :     extern T3SQLBulkOperations pODBC3SQLBulkOperations;
      70             :     extern T3SQLMoreResults pODBC3SQLMoreResults;
      71             :     //extern T3SQLGetDiagField pODBC3SQLGetDiagField;
      72             :     extern T3SQLGetDiagRec pODBC3SQLGetDiagRec;
      73             :     extern T3SQLColumnPrivileges pODBC3SQLColumnPrivileges;
      74             :     extern T3SQLColumns pODBC3SQLColumns;
      75             :     extern T3SQLForeignKeys pODBC3SQLForeignKeys;
      76             :     extern T3SQLPrimaryKeys pODBC3SQLPrimaryKeys;
      77             :     extern T3SQLProcedureColumns pODBC3SQLProcedureColumns;
      78             :     extern T3SQLProcedures pODBC3SQLProcedures;
      79             :     extern T3SQLSpecialColumns pODBC3SQLSpecialColumns;
      80             :     extern T3SQLStatistics pODBC3SQLStatistics;
      81             :     extern T3SQLTablePrivileges pODBC3SQLTablePrivileges;
      82             :     extern T3SQLTables pODBC3SQLTables;
      83             :     extern T3SQLFreeStmt pODBC3SQLFreeStmt;
      84             :     extern T3SQLCloseCursor pODBC3SQLCloseCursor;
      85             :     extern T3SQLCancel pODBC3SQLCancel;
      86             :     extern T3SQLEndTran pODBC3SQLEndTran;
      87             :     extern T3SQLDisconnect pODBC3SQLDisconnect;
      88             :     extern T3SQLFreeHandle pODBC3SQLFreeHandle;
      89             :     extern T3SQLGetCursorName pODBC3SQLGetCursorName;
      90             :     extern T3SQLNativeSql pODBC3SQLNativeSql;
      91             : 
      92             : 
      93             :     namespace odbc
      94             :     {
      95           0 :         class ORealObdcDriver : public ODBCDriver
      96             :         {
      97             :         protected:
      98             :             virtual oslGenericFunction  getOdbcFunction(sal_Int32 _nIndex)  const SAL_OVERRIDE;
      99             :             virtual SQLHANDLE   EnvironmentHandle(OUString &_rPath) SAL_OVERRIDE;
     100             :         public:
     101           0 :             ORealObdcDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) : ODBCDriver(_rxFactory) {}
     102             :         };
     103             : 
     104             : 
     105           0 : oslGenericFunction ORealObdcDriver::getOdbcFunction(sal_Int32 _nIndex) const
     106             : {
     107           0 :     oslGenericFunction pFunction = NULL;
     108           0 :     switch(_nIndex)
     109             :     {
     110             :         case ODBC3SQLAllocHandle:
     111           0 :             pFunction = (oslGenericFunction)pODBC3SQLAllocHandle;
     112           0 :             break;
     113             :         case ODBC3SQLConnect:
     114           0 :             pFunction = (oslGenericFunction)pODBC3SQLConnect;
     115           0 :             break;
     116             :         case ODBC3SQLDriverConnect:
     117           0 :             pFunction = (oslGenericFunction)pODBC3SQLDriverConnect;
     118           0 :             break;
     119             :         case ODBC3SQLBrowseConnect:
     120           0 :             pFunction = (oslGenericFunction)pODBC3SQLBrowseConnect;
     121           0 :             break;
     122             :         case ODBC3SQLDataSources:
     123           0 :             pFunction = (oslGenericFunction)pODBC3SQLDataSources;
     124           0 :             break;
     125             :         case ODBC3SQLDrivers:
     126           0 :             pFunction = (oslGenericFunction)pODBC3SQLDrivers;
     127           0 :             break;
     128             :         case ODBC3SQLGetInfo:
     129             : 
     130           0 :             pFunction = (oslGenericFunction)pODBC3SQLGetInfo;
     131           0 :             break;
     132             :         case ODBC3SQLGetFunctions:
     133             : 
     134           0 :             pFunction = (oslGenericFunction)pODBC3SQLGetFunctions;
     135           0 :             break;
     136             :         case ODBC3SQLGetTypeInfo:
     137             : 
     138           0 :             pFunction = (oslGenericFunction)pODBC3SQLGetTypeInfo;
     139           0 :             break;
     140             :         case ODBC3SQLSetConnectAttr:
     141             : 
     142           0 :             pFunction = (oslGenericFunction)pODBC3SQLSetConnectAttr;
     143           0 :             break;
     144             :         case ODBC3SQLGetConnectAttr:
     145             : 
     146           0 :             pFunction = (oslGenericFunction)pODBC3SQLGetConnectAttr;
     147           0 :             break;
     148             :         case ODBC3SQLSetEnvAttr:
     149             : 
     150           0 :             pFunction = (oslGenericFunction)pODBC3SQLSetEnvAttr;
     151           0 :             break;
     152             :         case ODBC3SQLGetEnvAttr:
     153             : 
     154           0 :             pFunction = (oslGenericFunction)pODBC3SQLGetEnvAttr;
     155           0 :             break;
     156             :         case ODBC3SQLSetStmtAttr:
     157             : 
     158           0 :             pFunction = (oslGenericFunction)pODBC3SQLSetStmtAttr;
     159           0 :             break;
     160             :         case ODBC3SQLGetStmtAttr:
     161             : 
     162           0 :             pFunction = (oslGenericFunction)pODBC3SQLGetStmtAttr;
     163           0 :             break;
     164             :         case ODBC3SQLPrepare:
     165             : 
     166           0 :             pFunction = (oslGenericFunction)pODBC3SQLPrepare;
     167           0 :             break;
     168             :         case ODBC3SQLBindParameter:
     169             : 
     170           0 :             pFunction = (oslGenericFunction)pODBC3SQLBindParameter;
     171           0 :             break;
     172             :         case ODBC3SQLSetCursorName:
     173             : 
     174           0 :             pFunction = (oslGenericFunction)pODBC3SQLSetCursorName;
     175           0 :             break;
     176             :         case ODBC3SQLExecute:
     177             : 
     178           0 :             pFunction = (oslGenericFunction)pODBC3SQLExecute;
     179           0 :             break;
     180             :         case ODBC3SQLExecDirect:
     181             : 
     182           0 :             pFunction = (oslGenericFunction)pODBC3SQLExecDirect;
     183           0 :             break;
     184             :         case ODBC3SQLDescribeParam:
     185             : 
     186           0 :             pFunction = (oslGenericFunction)pODBC3SQLDescribeParam;
     187           0 :             break;
     188             :         case ODBC3SQLNumParams:
     189             : 
     190           0 :             pFunction = (oslGenericFunction)pODBC3SQLNumParams;
     191           0 :             break;
     192             :         case ODBC3SQLParamData:
     193             : 
     194           0 :             pFunction = (oslGenericFunction)pODBC3SQLParamData;
     195           0 :             break;
     196             :         case ODBC3SQLPutData:
     197             : 
     198           0 :             pFunction = (oslGenericFunction)pODBC3SQLPutData;
     199           0 :             break;
     200             :         case ODBC3SQLRowCount:
     201             : 
     202           0 :             pFunction = (oslGenericFunction)pODBC3SQLRowCount;
     203           0 :             break;
     204             :         case ODBC3SQLNumResultCols:
     205             : 
     206           0 :             pFunction = (oslGenericFunction)pODBC3SQLNumResultCols;
     207           0 :             break;
     208             :         case ODBC3SQLDescribeCol:
     209             : 
     210           0 :             pFunction = (oslGenericFunction)pODBC3SQLDescribeCol;
     211           0 :             break;
     212             :         case ODBC3SQLColAttribute:
     213             : 
     214           0 :             pFunction = (oslGenericFunction)pODBC3SQLColAttribute;
     215           0 :             break;
     216             :         case ODBC3SQLBindCol:
     217             : 
     218           0 :             pFunction = (oslGenericFunction)pODBC3SQLBindCol;
     219           0 :             break;
     220             :         case ODBC3SQLFetch:
     221             : 
     222           0 :             pFunction = (oslGenericFunction)pODBC3SQLFetch;
     223           0 :             break;
     224             :         case ODBC3SQLFetchScroll:
     225             : 
     226           0 :             pFunction = (oslGenericFunction)pODBC3SQLFetchScroll;
     227           0 :             break;
     228             :         case ODBC3SQLGetData:
     229             : 
     230           0 :             pFunction = (oslGenericFunction)pODBC3SQLGetData;
     231           0 :             break;
     232             :         case ODBC3SQLSetPos:
     233             : 
     234           0 :             pFunction = (oslGenericFunction)pODBC3SQLSetPos;
     235           0 :             break;
     236             :         case ODBC3SQLBulkOperations:
     237             : 
     238           0 :             pFunction = (oslGenericFunction)pODBC3SQLBulkOperations;
     239           0 :             break;
     240             :         case ODBC3SQLMoreResults:
     241             : 
     242           0 :             pFunction = (oslGenericFunction)pODBC3SQLMoreResults;
     243           0 :             break;
     244             :         case ODBC3SQLGetDiagRec:
     245             : 
     246           0 :             pFunction = (oslGenericFunction)pODBC3SQLGetDiagRec;
     247           0 :             break;
     248             :         case ODBC3SQLColumnPrivileges:
     249             : 
     250           0 :             pFunction = (oslGenericFunction)pODBC3SQLColumnPrivileges;
     251           0 :             break;
     252             :         case ODBC3SQLColumns:
     253             : 
     254           0 :             pFunction = (oslGenericFunction)pODBC3SQLColumns;
     255           0 :             break;
     256             :         case ODBC3SQLForeignKeys:
     257             : 
     258           0 :             pFunction = (oslGenericFunction)pODBC3SQLForeignKeys;
     259           0 :             break;
     260             :         case ODBC3SQLPrimaryKeys:
     261             : 
     262           0 :             pFunction = (oslGenericFunction)pODBC3SQLPrimaryKeys;
     263           0 :             break;
     264             :         case ODBC3SQLProcedureColumns:
     265             : 
     266           0 :             pFunction = (oslGenericFunction)pODBC3SQLProcedureColumns;
     267           0 :             break;
     268             :         case ODBC3SQLProcedures:
     269             : 
     270           0 :             pFunction = (oslGenericFunction)pODBC3SQLProcedures;
     271           0 :             break;
     272             :         case ODBC3SQLSpecialColumns:
     273             : 
     274           0 :             pFunction = (oslGenericFunction)pODBC3SQLSpecialColumns;
     275           0 :             break;
     276             :         case ODBC3SQLStatistics:
     277             : 
     278           0 :             pFunction = (oslGenericFunction)pODBC3SQLStatistics;
     279           0 :             break;
     280             :         case ODBC3SQLTablePrivileges:
     281             : 
     282           0 :             pFunction = (oslGenericFunction)pODBC3SQLTablePrivileges;
     283           0 :             break;
     284             :         case ODBC3SQLTables:
     285             : 
     286           0 :             pFunction = (oslGenericFunction)pODBC3SQLTables;
     287           0 :             break;
     288             :         case ODBC3SQLFreeStmt:
     289             : 
     290           0 :             pFunction = (oslGenericFunction)pODBC3SQLFreeStmt;
     291           0 :             break;
     292             :         case ODBC3SQLCloseCursor:
     293             : 
     294           0 :             pFunction = (oslGenericFunction)pODBC3SQLCloseCursor;
     295           0 :             break;
     296             :         case ODBC3SQLCancel:
     297             : 
     298           0 :             pFunction = (oslGenericFunction)pODBC3SQLCancel;
     299           0 :             break;
     300             :         case ODBC3SQLEndTran:
     301             : 
     302           0 :             pFunction = (oslGenericFunction)pODBC3SQLEndTran;
     303           0 :             break;
     304             :         case ODBC3SQLDisconnect:
     305             : 
     306           0 :             pFunction = (oslGenericFunction)pODBC3SQLDisconnect;
     307           0 :             break;
     308             :         case ODBC3SQLFreeHandle:
     309             : 
     310           0 :             pFunction = (oslGenericFunction)pODBC3SQLFreeHandle;
     311           0 :             break;
     312             :         case ODBC3SQLGetCursorName:
     313             : 
     314           0 :             pFunction = (oslGenericFunction)pODBC3SQLGetCursorName;
     315           0 :             break;
     316             :         case ODBC3SQLNativeSql:
     317             : 
     318           0 :             pFunction = (oslGenericFunction)pODBC3SQLNativeSql;
     319           0 :             break;
     320             :         default:
     321             :             OSL_FAIL("Function unknown!");
     322             :     }
     323           0 :     return pFunction;
     324             : }
     325             : 
     326             : 
     327           0 : ::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 )
     328             : {
     329           0 :     return *(new ORealObdcDriver(_rxFactory));
     330             : }
     331             : 
     332             : // ODBC Environment (common for all Connections):
     333           0 : SQLHANDLE ORealObdcDriver::EnvironmentHandle(OUString &_rPath)
     334             : {
     335             :     // Is (for this instance) already a Enviroment made?
     336           0 :     if (!m_pDriverHandle)
     337             :     {
     338           0 :         SQLHANDLE h = SQL_NULL_HANDLE;
     339             :         // allocate Environment
     340             : 
     341             :         // load ODBC-DLL now:
     342           0 :         if (!LoadLibrary_ODBC3(_rPath) || N3SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&h) != SQL_SUCCESS)
     343           0 :             return SQL_NULL_HANDLE;
     344             : 
     345             :         // Save in global Structure
     346           0 :         m_pDriverHandle = h;
     347           0 :         SQLRETURN nError = N3SQLSetEnvAttr(h, SQL_ATTR_ODBC_VERSION,(SQLPOINTER) SQL_OV_ODBC3, SQL_IS_UINTEGER);
     348             :         OSL_UNUSED( nError );
     349             :         //N3SQLSetEnvAttr(h, SQL_ATTR_CONNECTION_POOLING,(SQLPOINTER) SQL_CP_ONE_PER_HENV, SQL_IS_INTEGER);
     350             :     }
     351             : 
     352           0 :     return m_pDriverHandle;
     353             : }
     354             : 
     355             : 
     356             :     }
     357             : }
     358             : 
     359             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10