LCOV - code coverage report
Current view: top level - connectivity/source/drivers/file - FDriver.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 27 82 32.9 %
Date: 2014-04-11 Functions: 4 15 26.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 "file/FDriver.hxx"
      21             : #include "file/FConnection.hxx"
      22             : #include "file/fcode.hxx"
      23             : #include <com/sun/star/lang/DisposedException.hpp>
      24             : #include <comphelper/types.hxx>
      25             : #include <cppuhelper/supportsservice.hxx>
      26             : #include "connectivity/dbexception.hxx"
      27             : #include "resource/common_res.hrc"
      28             : #include "resource/sharedresources.hxx"
      29             : 
      30             : 
      31             : using namespace connectivity::file;
      32             : using namespace com::sun::star::uno;
      33             : using namespace com::sun::star::lang;
      34             : using namespace com::sun::star::beans;
      35             : using namespace com::sun::star::sdbc;
      36             : using namespace com::sun::star::sdbcx;
      37             : using namespace com::sun::star::container;
      38             : 
      39           5 : OFileDriver::OFileDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext)
      40             :     : ODriver_BASE(m_aMutex)
      41           5 :     ,m_xContext(_rxContext)
      42             : {
      43             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileDriver::OFileDriver" );
      44           5 : }
      45             : 
      46           0 : void OFileDriver::disposing()
      47             : {
      48             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileDriver::disposing" );
      49           0 :     ::osl::MutexGuard aGuard(m_aMutex);
      50             : 
      51             : 
      52           0 :     for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i)
      53             :     {
      54           0 :         Reference< XComponent > xComp(i->get(), UNO_QUERY);
      55           0 :         if (xComp.is())
      56           0 :             xComp->dispose();
      57           0 :     }
      58           0 :     m_xConnections.clear();
      59             : 
      60           0 :     ODriver_BASE::disposing();
      61           0 : }
      62             : 
      63             : // static ServiceInfo
      64             : 
      65           0 : OUString OFileDriver::getImplementationName_Static(  ) throw(RuntimeException)
      66             : {
      67           0 :     return OUString("com.sun.star.sdbc.driver.file.Driver");
      68             : }
      69             : 
      70           5 : Sequence< OUString > OFileDriver::getSupportedServiceNames_Static(  ) throw (RuntimeException)
      71             : {
      72           5 :     Sequence< OUString > aSNS( 2 );
      73           5 :     aSNS[0] = "com.sun.star.sdbc.Driver";
      74           5 :     aSNS[1] = "com.sun.star.sdbcx.Driver";
      75           5 :     return aSNS;
      76             : }
      77             : 
      78             : 
      79           0 : OUString SAL_CALL OFileDriver::getImplementationName(  ) throw(RuntimeException, std::exception)
      80             : {
      81           0 :     return getImplementationName_Static();
      82             : }
      83             : 
      84           0 : sal_Bool SAL_CALL OFileDriver::supportsService( const OUString& _rServiceName ) throw(RuntimeException, std::exception)
      85             : {
      86           0 :     return cppu::supportsService(this, _rServiceName);
      87             : }
      88             : 
      89             : 
      90           0 : Sequence< OUString > SAL_CALL OFileDriver::getSupportedServiceNames(  ) throw(RuntimeException, std::exception)
      91             : {
      92           0 :     return getSupportedServiceNames_Static();
      93             : }
      94             : 
      95             : 
      96           0 : Reference< XConnection > SAL_CALL OFileDriver::connect( const OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException, std::exception)
      97             : {
      98             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileDriver::connect" );
      99           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     100           0 :     checkDisposed(ODriver_BASE::rBHelper.bDisposed);
     101             : 
     102           0 :     OConnection* pCon = new OConnection(this);
     103           0 :     Reference< XConnection > xCon = pCon;
     104           0 :     pCon->construct(url,info);
     105           0 :     m_xConnections.push_back(WeakReferenceHelper(*pCon));
     106             : 
     107           0 :     return xCon;
     108             : }
     109             : 
     110           0 : sal_Bool SAL_CALL OFileDriver::acceptsURL( const OUString& url )
     111             :                 throw(SQLException, RuntimeException, std::exception)
     112             : {
     113             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileDriver::acceptsURL" );
     114           0 :     return url.startsWith("sdbc:file:");
     115             : }
     116             : 
     117           0 : Sequence< DriverPropertyInfo > SAL_CALL OFileDriver::getPropertyInfo( const OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException, std::exception)
     118             : {
     119             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileDriver::getPropertyInfo" );
     120           0 :     if ( acceptsURL(url) )
     121             :     {
     122           0 :         ::std::vector< DriverPropertyInfo > aDriverInfo;
     123             : 
     124           0 :         Sequence< OUString > aBoolean(2);
     125           0 :         aBoolean[0] = "0";
     126           0 :         aBoolean[1] = "1";
     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("Extension")
     137             :                 ,OUString("Extension of the file format.")
     138             :                 ,sal_False
     139             :                 ,OUString(".*")
     140             :                 ,Sequence< OUString >())
     141           0 :                 );
     142             :         aDriverInfo.push_back(DriverPropertyInfo(
     143             :                 OUString("ShowDeleted")
     144             :                 ,OUString("Display inactive records.")
     145             :                 ,sal_False
     146             :                 ,OUString("0")
     147             :                 ,aBoolean)
     148           0 :                 );
     149             :         aDriverInfo.push_back(DriverPropertyInfo(
     150             :                 OUString("EnableSQL92Check")
     151             :                 ,OUString("Use SQL92 naming constraints.")
     152             :                 ,sal_False
     153             :                 ,OUString("0")
     154             :                 ,aBoolean)
     155           0 :                 );
     156             :         aDriverInfo.push_back(DriverPropertyInfo(
     157             :                 OUString("UseRelativePath")
     158             :                 ,OUString("Handle the connection url as relative path.")
     159             :                 ,sal_False
     160             :                 ,OUString("0")
     161             :                 ,aBoolean)
     162           0 :                 );
     163             :         aDriverInfo.push_back(DriverPropertyInfo(
     164             :                 OUString("URL")
     165             :                 ,OUString("The URL of the database document which is used to create an absolute path.")
     166             :                 ,sal_False
     167             :                 ,OUString()
     168             :                 ,Sequence< OUString >())
     169           0 :                 );
     170           0 :         return Sequence< DriverPropertyInfo >(&(aDriverInfo[0]),aDriverInfo.size());
     171             :     } // if ( acceptsURL(url) )
     172             :     {
     173           0 :         ::connectivity::SharedResources aResources;
     174           0 :         const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
     175           0 :         ::dbtools::throwGenericSQLException(sMessage ,*this);
     176             :     } // if ( ! acceptsURL(url) )
     177           0 :     return Sequence< DriverPropertyInfo >();
     178             : }
     179             : 
     180           0 : sal_Int32 SAL_CALL OFileDriver::getMajorVersion(  ) throw(RuntimeException, std::exception)
     181             : {
     182             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileDriver::getMajorVersion" );
     183           0 :     return 1;
     184             : }
     185             : 
     186           0 : sal_Int32 SAL_CALL OFileDriver::getMinorVersion(  ) throw(RuntimeException, std::exception)
     187             : {
     188             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileDriver::getMinorVersion" );
     189           0 :     return 0;
     190             : }
     191             : 
     192             : 
     193             : // XDataDefinitionSupplier
     194          29 : Reference< XTablesSupplier > SAL_CALL OFileDriver::getDataDefinitionByConnection( const Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, RuntimeException, std::exception)
     195             : {
     196             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileDriver::getDataDefinitionByConnection" );
     197          29 :     ::osl::MutexGuard aGuard( m_aMutex );
     198          29 :     checkDisposed(ODriver_BASE::rBHelper.bDisposed);
     199             : 
     200          29 :     Reference< XTablesSupplier > xTab = NULL;
     201          58 :     Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(connection,UNO_QUERY);
     202          29 :     if(xTunnel.is())
     203             :     {
     204          29 :         OConnection* pSearchConnection = reinterpret_cast< OConnection* >( xTunnel->getSomething(OConnection::getUnoTunnelImplementationId()) );
     205          29 :         OConnection* pConnection = NULL;
     206         156 :         for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i)
     207             :         {
     208         156 :             if ((OConnection*) Reference< XConnection >::query(i->get().get()).get() == pSearchConnection)
     209             :             {
     210          29 :                 pConnection = pSearchConnection;
     211          29 :                 break;
     212             :             }
     213             :         }
     214             : 
     215          29 :         if(pConnection)
     216          29 :             xTab = pConnection->createCatalog();
     217             :     }
     218          58 :     return xTab;
     219             : }
     220             : 
     221             : 
     222           0 : Reference< XTablesSupplier > SAL_CALL OFileDriver::getDataDefinitionByURL( const OUString& url, const Sequence< PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, RuntimeException, std::exception)
     223             : {
     224             :     SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OFileDriver::getDataDefinitionByURL" );
     225           0 :     if ( ! acceptsURL(url) )
     226             :     {
     227           0 :         ::connectivity::SharedResources aResources;
     228           0 :         const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
     229           0 :         ::dbtools::throwGenericSQLException(sMessage ,*this);
     230             :     }
     231           0 :     return getDataDefinitionByConnection(connect(url,info));
     232             : }
     233             : 
     234             : 
     235           6 : OOperandAttr::OOperandAttr(sal_uInt16 _nPos,const Reference< XPropertySet>& _xColumn)
     236           6 :     : OOperandRow(_nPos,::comphelper::getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))))
     237           6 :     , m_xColumn(_xColumn)
     238             : {
     239           6 : }
     240             : 
     241             : 
     242             : 
     243             : 
     244             : 
     245             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10