LCOV - code coverage report
Current view: top level - connectivity/source/drivers/dbase - DDriver.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 26 33 78.8 %
Date: 2012-08-25 Functions: 5 6 83.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 33 82 40.2 %

           Branch data     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 "dbase/DDriver.hxx"
      21                 :            : #include "dbase/DConnection.hxx"
      22                 :            : #include <com/sun/star/lang/DisposedException.hpp>
      23                 :            : #include "connectivity/dbexception.hxx"
      24                 :            : #include "resource/dbase_res.hrc"
      25                 :            : 
      26                 :            : using namespace connectivity::dbase;
      27                 :            : using namespace connectivity::file;
      28                 :            : using namespace ::com::sun::star::uno;
      29                 :            : using namespace ::com::sun::star::beans;
      30                 :            : using namespace ::com::sun::star::sdbcx;
      31                 :            : using namespace ::com::sun::star::sdbc;
      32                 :            : using namespace ::com::sun::star::lang;
      33                 :            : 
      34                 :            : 
      35                 :            : // static ServiceInfo
      36                 :            : //------------------------------------------------------------------------------
      37                 :          9 : rtl::OUString ODriver::getImplementationName_Static(  ) throw(RuntimeException)
      38                 :            : {
      39                 :          9 :     return rtl::OUString("com.sun.star.comp.sdbc.dbase.ODriver");
      40                 :            : }
      41                 :            : 
      42                 :            : //------------------------------------------------------------------
      43                 :          0 : ::rtl::OUString SAL_CALL ODriver::getImplementationName(  ) throw(RuntimeException)
      44                 :            : {
      45                 :          0 :     return getImplementationName_Static();
      46                 :            : }
      47                 :            : 
      48                 :            : //------------------------------------------------------------------
      49                 :          9 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  SAL_CALL connectivity::dbase::ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
      50                 :            : {
      51         [ +  - ]:          9 :     return *(new ODriver(_rxFactory));
      52                 :            : }
      53                 :            : // --------------------------------------------------------------------------------
      54                 :         56 : Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
      55                 :            : {
      56         [ +  - ]:         56 :     ::osl::MutexGuard aGuard( m_aMutex );
      57         [ -  + ]:         56 :     if (ODriver_BASE::rBHelper.bDisposed)
      58         [ #  # ]:          0 :         throw DisposedException();
      59                 :            : 
      60 [ +  - ][ -  + ]:         56 :     if ( ! acceptsURL(url) )
      61         [ #  # ]:          0 :         return NULL;
      62                 :            : 
      63         [ +  - ]:         56 :     ODbaseConnection* pCon = new ODbaseConnection(this);
      64         [ +  - ]:         56 :     pCon->construct(url,info);
      65 [ +  - ][ +  - ]:         56 :     Reference< XConnection > xCon = pCon;
      66 [ +  - ][ +  - ]:         56 :     m_xConnections.push_back(WeakReferenceHelper(*pCon));
         [ +  - ][ +  - ]
      67                 :            : 
      68         [ +  - ]:         56 :     return xCon;
      69                 :            : }
      70                 :            : // --------------------------------------------------------------------------------
      71                 :        336 : sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url ) throw(SQLException, RuntimeException)
      72                 :            : {
      73                 :        336 :     return !url.compareTo(::rtl::OUString("sdbc:dbase:"),11);
      74                 :            : }
      75                 :            : // -----------------------------------------------------------------------------
      76                 :         56 : Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
      77                 :            : {
      78 [ +  - ][ +  - ]:         56 :     if ( acceptsURL(url) )
      79                 :            :     {
      80         [ +  - ]:         56 :         ::std::vector< DriverPropertyInfo > aDriverInfo;
      81                 :            : 
      82         [ +  - ]:         56 :         Sequence< ::rtl::OUString > aBoolean(2);
      83         [ +  - ]:         56 :         aBoolean[0] = ::rtl::OUString("0");
      84         [ +  - ]:         56 :         aBoolean[1] = ::rtl::OUString("1");
      85                 :            : 
      86                 :            :         aDriverInfo.push_back(DriverPropertyInfo(
      87                 :            :                 ::rtl::OUString("CharSet")
      88                 :            :                 ,::rtl::OUString("CharSet of the database.")
      89                 :            :                 ,sal_False
      90                 :            :                 ,::rtl::OUString()
      91                 :            :                 ,Sequence< ::rtl::OUString >())
      92 [ +  - ][ +  - ]:         56 :                 );
         [ +  - ][ +  - ]
                 [ +  - ]
      93                 :            :         aDriverInfo.push_back(DriverPropertyInfo(
      94                 :            :                 ::rtl::OUString("ShowDeleted")
      95                 :            :                 ,::rtl::OUString("Display inactive records.")
      96                 :            :                 ,sal_False
      97                 :            :                 ,::rtl::OUString("0")
      98                 :            :                 ,aBoolean)
      99 [ +  - ][ +  - ]:         56 :                 );
                 [ +  - ]
     100                 :            :         aDriverInfo.push_back(DriverPropertyInfo(
     101                 :            :                 ::rtl::OUString("EnableSQL92Check")
     102                 :            :                 ,::rtl::OUString("Use SQL92 naming constraints.")
     103                 :            :                 ,sal_False
     104                 :            :                 ,::rtl::OUString("0")
     105                 :            :                 ,aBoolean)
     106 [ +  - ][ +  - ]:         56 :                 );
                 [ +  - ]
     107 [ +  - ][ +  - ]:         56 :         return Sequence< DriverPropertyInfo >(&(aDriverInfo[0]),aDriverInfo.size());
     108                 :            :     }
     109                 :            : 
     110         [ #  # ]:          0 :     SharedResources aResources;
     111         [ #  # ]:          0 :     const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
     112 [ #  # ][ #  # ]:          0 :     ::dbtools::throwGenericSQLException(sMessage ,*this);
     113 [ #  # ][ #  # ]:         56 :     return Sequence< DriverPropertyInfo >();
     114                 :            : }
     115                 :            : // -----------------------------------------------------------------------------
     116                 :            : 
     117                 :            : 
     118                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10