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

Generated by: LCOV version 1.10