LCOV - code coverage report
Current view: top level - connectivity/source/drivers/odbc - ODriver.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 19 63 30.2 %
Date: 2015-06-13 12:38:46 Functions: 6 12 50.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 "odbc/ODriver.hxx"
      21             : #include "odbc/OConnection.hxx"
      22             : #include "odbc/OFunctions.hxx"
      23             : #include "odbc/OTools.hxx"
      24             : #include <connectivity/dbexception.hxx>
      25             : #include <cppuhelper/supportsservice.hxx>
      26             : #include "resource/common_res.hrc"
      27             : #include "resource/sharedresources.hxx"
      28             : 
      29             : using namespace connectivity::odbc;
      30             : using namespace com::sun::star::uno;
      31             : using namespace com::sun::star::lang;
      32             : using namespace com::sun::star::beans;
      33             : using namespace com::sun::star::sdbc;
      34             : 
      35           1 : ODBCDriver::ODBCDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
      36             :     :ODriver_BASE(m_aMutex)
      37             :     ,m_xORB(_rxFactory)
      38           1 :     ,m_pDriverHandle(SQL_NULL_HANDLE)
      39             : {
      40           1 : }
      41             : 
      42           1 : void ODBCDriver::disposing()
      43             : {
      44           1 :     ::osl::MutexGuard aGuard(m_aMutex);
      45             : 
      46             : 
      47           1 :     for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i)
      48             :     {
      49           0 :         Reference< XComponent > xComp(i->get(), UNO_QUERY);
      50           0 :         if (xComp.is())
      51           0 :             xComp->dispose();
      52           0 :     }
      53           1 :     m_xConnections.clear();
      54             : 
      55           1 :     ODriver_BASE::disposing();
      56           1 : }
      57             : 
      58             : // static ServiceInfo
      59             : 
      60           2 : OUString ODBCDriver::getImplementationName_Static(  ) throw(RuntimeException)
      61             : {
      62           2 :     return OUString("com.sun.star.comp.sdbc.ODBCDriver");
      63             :         // this name is referenced in the configuration and in the odbc.xml
      64             :         // Please take care when changing it.
      65             : }
      66             : 
      67             : 
      68           2 : Sequence< OUString > ODBCDriver::getSupportedServiceNames_Static(  ) throw (RuntimeException)
      69             : {
      70           2 :     Sequence< OUString > aSNS( 1 );
      71           2 :     aSNS[0] = "com.sun.star.sdbc.Driver";
      72           2 :     return aSNS;
      73             : }
      74             : 
      75             : 
      76           1 : OUString SAL_CALL ODBCDriver::getImplementationName(  ) throw(RuntimeException, std::exception)
      77             : {
      78           1 :     return getImplementationName_Static();
      79             : }
      80             : 
      81           0 : sal_Bool SAL_CALL ODBCDriver::supportsService( const OUString& _rServiceName ) throw(RuntimeException, std::exception)
      82             : {
      83           0 :     return cppu::supportsService(this, _rServiceName);
      84             : }
      85             : 
      86             : 
      87           1 : Sequence< OUString > SAL_CALL ODBCDriver::getSupportedServiceNames(  ) throw(RuntimeException, std::exception)
      88             : {
      89           1 :     return getSupportedServiceNames_Static();
      90             : }
      91             : 
      92             : 
      93           0 : Reference< XConnection > SAL_CALL ODBCDriver::connect( const OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException, std::exception)
      94             : {
      95           0 :     if ( ! acceptsURL(url) )
      96           0 :         return NULL;
      97             : 
      98           0 :     if(!m_pDriverHandle)
      99             :     {
     100           0 :         OUString aPath;
     101           0 :         if(!EnvironmentHandle(aPath))
     102           0 :             throw SQLException(aPath,*this,OUString(),1000,Any());
     103             :     }
     104           0 :     OConnection* pCon = new OConnection(m_pDriverHandle,this);
     105           0 :     Reference< XConnection > xCon = pCon;
     106           0 :     pCon->Construct(url,info);
     107           0 :     m_xConnections.push_back(WeakReferenceHelper(*pCon));
     108             : 
     109           0 :     return xCon;
     110             : }
     111             : 
     112           0 : sal_Bool SAL_CALL ODBCDriver::acceptsURL( const OUString& url )
     113             :         throw(SQLException, RuntimeException, std::exception)
     114             : {
     115           0 :     return url.startsWith("sdbc:odbc:");
     116             : }
     117             : 
     118           0 : Sequence< DriverPropertyInfo > SAL_CALL ODBCDriver::getPropertyInfo( const OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException, std::exception)
     119             : {
     120           0 :     if ( acceptsURL(url) )
     121             :     {
     122           0 :         ::std::vector< DriverPropertyInfo > aDriverInfo;
     123             : 
     124           0 :         Sequence< OUString > aBooleanValues(2);
     125           0 :         aBooleanValues[0] = "false";
     126           0 :         aBooleanValues[1] = "true";
     127             : 
     128             :         aDriverInfo.push_back(DriverPropertyInfo(
     129             :                 OUString("CharSet")
     130             :                 ,OUString("CharSet of the database.")
     131             :                 ,sal_False
     132             :                 ,OUString()
     133             :                 ,Sequence< OUString >())
     134           0 :                 );
     135             :         aDriverInfo.push_back(DriverPropertyInfo(
     136             :                 OUString("UseCatalog")
     137             :                 ,OUString("Use catalog for file-based databases.")
     138             :                 ,sal_False
     139             :                 ,OUString(  "false"  )
     140             :                 ,aBooleanValues)
     141           0 :                 );
     142             :         aDriverInfo.push_back(DriverPropertyInfo(
     143             :                 OUString("SystemDriverSettings")
     144             :                 ,OUString("Driver settings.")
     145             :                 ,sal_False
     146             :                 ,OUString()
     147             :                 ,Sequence< OUString >())
     148           0 :                 );
     149             :         aDriverInfo.push_back(DriverPropertyInfo(
     150             :                 OUString("ParameterNameSubstitution")
     151             :                 ,OUString("Change named parameters with '?'.")
     152             :                 ,sal_False
     153             :                 ,OUString(  "false"  )
     154             :                 ,aBooleanValues)
     155           0 :                 );
     156             :         aDriverInfo.push_back(DriverPropertyInfo(
     157             :                 OUString("IgnoreDriverPrivileges")
     158             :                 ,OUString("Ignore the privileges from the database driver.")
     159             :                 ,sal_False
     160             :                 ,OUString(  "false"  )
     161             :                 ,aBooleanValues)
     162           0 :                 );
     163             :         aDriverInfo.push_back(DriverPropertyInfo(
     164             :                 OUString("IsAutoRetrievingEnabled")
     165             :                 ,OUString("Retrieve generated values.")
     166             :                 ,sal_False
     167             :                 ,OUString(  "false"  )
     168             :                 ,aBooleanValues)
     169           0 :                 );
     170             :         aDriverInfo.push_back(DriverPropertyInfo(
     171             :                 OUString("AutoRetrievingStatement")
     172             :                 ,OUString("Auto-increment statement.")
     173             :                 ,sal_False
     174             :                 ,OUString()
     175             :                 ,Sequence< OUString >())
     176           0 :                 );
     177             :         aDriverInfo.push_back(DriverPropertyInfo(
     178             :                 OUString("GenerateASBeforeCorrelationName")
     179             :                 ,OUString("Generate AS before table correlation names.")
     180             :                 ,sal_False
     181             :                 ,OUString(  "false"  )
     182             :                 ,aBooleanValues)
     183           0 :                 );
     184             :         aDriverInfo.push_back(DriverPropertyInfo(
     185             :                 OUString("EscapeDateTime")
     186             :                 ,OUString("Escape date time format.")
     187             :                 ,sal_False
     188             :                 ,OUString(  "true"  )
     189             :                 ,aBooleanValues)
     190           0 :                 );
     191             : 
     192           0 :         return Sequence< DriverPropertyInfo >(&aDriverInfo[0],aDriverInfo.size());
     193             :     }
     194           0 :     ::connectivity::SharedResources aResources;
     195           0 :     const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
     196           0 :     ::dbtools::throwGenericSQLException(sMessage ,*this);
     197           0 :     return Sequence< DriverPropertyInfo >();
     198             : }
     199             : 
     200           0 : sal_Int32 SAL_CALL ODBCDriver::getMajorVersion(  ) throw(RuntimeException, std::exception)
     201             : {
     202           0 :     return 1;
     203             : }
     204             : 
     205           0 : sal_Int32 SAL_CALL ODBCDriver::getMinorVersion(  ) throw(RuntimeException, std::exception)
     206             : {
     207           0 :     return 0;
     208             : }
     209             : 
     210             : 
     211             : 
     212             : 
     213             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11