LCOV - code coverage report
Current view: top level - cui/source/options - sdbcdriverenum.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 27 0.0 %
Date: 2012-08-25 Functions: 0 7 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 44 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "sdbcdriverenum.hxx"
      30                 :            : #include <comphelper/stl_types.hxx>
      31                 :            : #include <comphelper/processfactory.hxx>
      32                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      33                 :            : #include <com/sun/star/container/XEnumerationAccess.hpp>
      34                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      35                 :            : 
      36                 :            : //........................................................................
      37                 :            : namespace offapp
      38                 :            : {
      39                 :            : //........................................................................
      40                 :            : 
      41                 :            :     using namespace ::com::sun::star::uno;
      42                 :            :     using namespace ::com::sun::star::lang;
      43                 :            :     using namespace ::com::sun::star::container;
      44                 :            : 
      45                 :            :     //====================================================================
      46                 :            :     //= ODriverEnumerationImpl
      47                 :            :     //====================================================================
      48                 :          0 :     class ODriverEnumerationImpl
      49                 :            :     {
      50                 :            :     protected:
      51                 :            :         ::std::vector< ::rtl::OUString >    m_aImplNames;
      52                 :            : 
      53                 :            :     public:
      54                 :            :         ODriverEnumerationImpl();
      55                 :            : 
      56                 :          0 :         const ::std::vector< ::rtl::OUString >& getDriverImplNames() const { return m_aImplNames; }
      57                 :            :     };
      58                 :            : 
      59                 :            :     //--------------------------------------------------------------------
      60                 :          0 :     ODriverEnumerationImpl::ODriverEnumerationImpl()
      61                 :            :     {
      62                 :            :         try
      63                 :            :         {
      64         [ #  # ]:          0 :             Reference< XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory();
      65 [ #  # ][ #  # ]:          0 :             Reference< XInterface > xDM = xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.DriverManager") ) );
                 [ #  # ]
      66                 :            :             OSL_ENSURE(xDM.is(), "ODriverEnumerationImpl::ODriverEnumerationImpl: no access to the SDBC driver manager!");
      67                 :            : 
      68         [ #  # ]:          0 :             Reference< XEnumerationAccess > xEnumAccess(xDM, UNO_QUERY);
      69                 :            :             OSL_ENSURE(xEnumAccess.is() || !xDM.is(), "ODriverEnumerationImpl::ODriverEnumerationImpl: can't enumerate SDBC drivers (missing the interface)!");
      70         [ #  # ]:          0 :             if (xEnumAccess.is())
      71                 :            :             {
      72 [ #  # ][ #  # ]:          0 :                 Reference< XEnumeration > xEnumDrivers = xEnumAccess->createEnumeration();
      73                 :            :                 OSL_ENSURE(xEnumDrivers.is(), "ODriverEnumerationImpl::ODriverEnumerationImpl: invalid enumeration object!");
      74                 :            : 
      75                 :          0 :                 Reference< XServiceInfo > xDriverSI;
      76 [ #  # ][ #  # ]:          0 :                 while (xEnumDrivers->hasMoreElements())
                 [ #  # ]
      77                 :            :                 {
      78 [ #  # ][ #  # ]:          0 :                     xEnumDrivers->nextElement() >>= xDriverSI;
                 [ #  # ]
      79                 :            :                     OSL_ENSURE(xDriverSI.is(), "ODriverEnumerationImpl::ODriverEnumerationImpl: driver without service info!");
      80         [ #  # ]:          0 :                     if (xDriverSI.is())
      81 [ #  # ][ #  # ]:          0 :                         m_aImplNames.push_back(xDriverSI->getImplementationName());
                 [ #  # ]
      82                 :          0 :                 }
      83         [ #  # ]:          0 :             }
      84                 :            :         }
      85         [ #  # ]:          0 :         catch(const Exception&)
      86                 :            :         {
      87                 :            :             OSL_FAIL("ODriverEnumerationImpl::ODriverEnumerationImpl: caught an exception while enumerating the drivers!");
      88                 :            :         }
      89                 :          0 :     }
      90                 :            : 
      91                 :            :     //====================================================================
      92                 :            :     //= ODriverEnumeration
      93                 :            :     //====================================================================
      94                 :            :     //--------------------------------------------------------------------
      95                 :          0 :     ODriverEnumeration::ODriverEnumeration() throw()
      96         [ #  # ]:          0 :         :m_pImpl(new ODriverEnumerationImpl)
      97                 :            :     {
      98                 :          0 :     }
      99                 :            : 
     100                 :            :     //--------------------------------------------------------------------
     101                 :          0 :     ODriverEnumeration::~ODriverEnumeration() throw()
     102                 :            :     {
     103         [ #  # ]:          0 :         delete m_pImpl;
     104                 :          0 :     }
     105                 :            : 
     106                 :            :     //--------------------------------------------------------------------
     107                 :          0 :     ODriverEnumeration::const_iterator ODriverEnumeration::begin() const throw()
     108                 :            :     {
     109                 :          0 :         return m_pImpl->getDriverImplNames().begin();
     110                 :            :     }
     111                 :            : 
     112                 :            :     //--------------------------------------------------------------------
     113                 :          0 :     ODriverEnumeration::const_iterator ODriverEnumeration::end() const throw()
     114                 :            :     {
     115                 :          0 :         return m_pImpl->getDriverImplNames().end();
     116                 :            :     }
     117                 :            : //........................................................................
     118                 :            : }   // namespace offapp
     119                 :            : //........................................................................
     120                 :            : 
     121                 :            : 
     122                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10