LCOV - code coverage report
Current view: top level - cui/source/options - sdbcdriverenum.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 24 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 7 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 "sdbcdriverenum.hxx"
      21             : #include <comphelper/processfactory.hxx>
      22             : #include <osl/diagnose.h>
      23             : #include <com/sun/star/container/XEnumerationAccess.hpp>
      24             : #include <com/sun/star/lang/XServiceInfo.hpp>
      25             : #include <com/sun/star/sdbc/DriverManager.hpp>
      26             : 
      27             : 
      28             : namespace offapp
      29             : {
      30             : 
      31             : 
      32             :     using namespace ::com::sun::star::uno;
      33             :     using namespace ::com::sun::star::lang;
      34             :     using namespace ::com::sun::star::container;
      35             :     using namespace ::com::sun::star::sdbc;
      36             : 
      37           0 :     class ODriverEnumerationImpl
      38             :     {
      39             :     protected:
      40             :         ::std::vector< OUString >    m_aImplNames;
      41             : 
      42             :     public:
      43             :         ODriverEnumerationImpl();
      44             : 
      45           0 :         const ::std::vector< OUString >& getDriverImplNames() const { return m_aImplNames; }
      46             :     };
      47             : 
      48             : 
      49           0 :     ODriverEnumerationImpl::ODriverEnumerationImpl()
      50             :     {
      51             :         try
      52             :         {
      53           0 :             Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
      54           0 :             Reference< XDriverManager2 > xEnumAccess = DriverManager::create( xContext );
      55             : 
      56           0 :             Reference< XEnumeration > xEnumDrivers = xEnumAccess->createEnumeration();
      57             :             OSL_ENSURE(xEnumDrivers.is(), "ODriverEnumerationImpl::ODriverEnumerationImpl: invalid enumeration object!");
      58             : 
      59           0 :             Reference< XServiceInfo > xDriverSI;
      60           0 :             while (xEnumDrivers->hasMoreElements())
      61             :             {
      62           0 :                 xEnumDrivers->nextElement() >>= xDriverSI;
      63             :                 OSL_ENSURE(xDriverSI.is(), "ODriverEnumerationImpl::ODriverEnumerationImpl: driver without service info!");
      64           0 :                 if (xDriverSI.is())
      65           0 :                     m_aImplNames.push_back(xDriverSI->getImplementationName());
      66           0 :             }
      67             :         }
      68           0 :         catch(const Exception&)
      69             :         {
      70             :             OSL_FAIL("ODriverEnumerationImpl::ODriverEnumerationImpl: caught an exception while enumerating the drivers!");
      71             :         }
      72           0 :     }
      73             : 
      74           0 :     ODriverEnumeration::ODriverEnumeration() throw()
      75           0 :         :m_pImpl(new ODriverEnumerationImpl)
      76             :     {
      77           0 :     }
      78             : 
      79             : 
      80           0 :     ODriverEnumeration::~ODriverEnumeration() throw()
      81             :     {
      82           0 :         delete m_pImpl;
      83           0 :     }
      84             : 
      85             : 
      86           0 :     ODriverEnumeration::const_iterator ODriverEnumeration::begin() const throw()
      87             :     {
      88           0 :         return m_pImpl->getDriverImplNames().begin();
      89             :     }
      90             : 
      91             : 
      92           0 :     ODriverEnumeration::const_iterator ODriverEnumeration::end() const throw()
      93             :     {
      94           0 :         return m_pImpl->getDriverImplNames().end();
      95             :     }
      96             : 
      97             : }   // namespace offapp
      98             : 
      99             : 
     100             : 
     101             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11