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

Generated by: LCOV version 1.10