LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/dbaccess/source/sdbtools/connection - connectiontools.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 56 0.0 %
Date: 2013-07-09 Functions: 0 16 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 "connectiontools.hxx"
      21             : #include "tablename.hxx"
      22             : #include "objectnames.hxx"
      23             : #include "datasourcemetadata.hxx"
      24             : 
      25             : #include <comphelper/namedvaluecollection.hxx>
      26             : #include <connectivity/dbtools.hxx>
      27             : #include <connectivity/statementcomposer.hxx>
      28             : 
      29             : #include <algorithm>
      30             : 
      31           0 : extern "C" void SAL_CALL createRegistryInfo_ConnectionTools()
      32             : {
      33           0 :     ::sdbtools::OAutoRegistration< ::sdbtools::ConnectionTools > aRegistration;
      34           0 : }
      35             : 
      36             : //........................................................................
      37             : namespace sdbtools
      38             : {
      39             : //........................................................................
      40             : 
      41             :     using namespace ::com::sun::star;
      42             :     using namespace ::com::sun::star::uno;
      43             :     using ::com::sun::star::uno::Reference;
      44             :     using ::com::sun::star::uno::RuntimeException;
      45             :     using ::com::sun::star::sdb::tools::XTableName;
      46             :     using ::com::sun::star::sdb::tools::XObjectNames;
      47             :     using ::com::sun::star::sdb::tools::XDataSourceMetaData;
      48             :     using ::com::sun::star::uno::Sequence;
      49             :     using ::com::sun::star::uno::XInterface;
      50             :     using ::com::sun::star::uno::Any;
      51             :     using ::com::sun::star::uno::Exception;
      52             :     using ::com::sun::star::sdbc::XConnection;
      53             :     using ::com::sun::star::lang::IllegalArgumentException;
      54             :     using ::com::sun::star::uno::XComponentContext;
      55             : 
      56             :     //====================================================================
      57             :     //= ConnectionTools
      58             :     //====================================================================
      59             :     //--------------------------------------------------------------------
      60           0 :     ConnectionTools::ConnectionTools( const Reference<XComponentContext>& _rContext )
      61           0 :         :ConnectionDependentComponent( _rContext )
      62             :     {
      63           0 :     }
      64             : 
      65             :     //--------------------------------------------------------------------
      66           0 :     ConnectionTools::~ConnectionTools()
      67             :     {
      68           0 :     }
      69             : 
      70             :     //--------------------------------------------------------------------
      71           0 :     Reference< XTableName > SAL_CALL ConnectionTools::createTableName() throw (RuntimeException)
      72             :     {
      73           0 :         EntryGuard aGuard( *this );
      74           0 :         return new TableName( getContext(), getConnection() );
      75             :     }
      76             : 
      77             :     //--------------------------------------------------------------------
      78           0 :     Reference< XObjectNames > SAL_CALL ConnectionTools::getObjectNames() throw (RuntimeException)
      79             :     {
      80           0 :         EntryGuard aGuard( *this );
      81           0 :         return new ObjectNames( getContext(), getConnection() );
      82             :     }
      83             : 
      84             :     //--------------------------------------------------------------------
      85           0 :     Reference< XDataSourceMetaData > SAL_CALL ConnectionTools::getDataSourceMetaData() throw (RuntimeException)
      86             :     {
      87           0 :         EntryGuard aGuard( *this );
      88           0 :         return new DataSourceMetaData( getContext(), getConnection() );
      89             :     }
      90             :     //--------------------------------------------------------------------
      91           0 :     Reference< container::XNameAccess > SAL_CALL ConnectionTools::getFieldsByCommandDescriptor( ::sal_Int32 commandType, const OUString& command, Reference< lang::XComponent >& keepFieldsAlive ) throw (sdbc::SQLException, RuntimeException)
      92             :     {
      93           0 :         EntryGuard aGuard( *this );
      94           0 :         ::dbtools::SQLExceptionInfo aErrorInfo;
      95           0 :         Reference< container::XNameAccess > xRet = ::dbtools::getFieldsByCommandDescriptor(getConnection(),commandType,command,keepFieldsAlive,&aErrorInfo);
      96           0 :         if ( aErrorInfo.isValid() )
      97           0 :             aErrorInfo.doThrow();
      98           0 :         return xRet;
      99             :     }
     100             :     //--------------------------------------------------------------------
     101           0 :     Reference< sdb::XSingleSelectQueryComposer > SAL_CALL ConnectionTools::getComposer( ::sal_Int32 commandType, const OUString& command ) throw (::com::sun::star::uno::RuntimeException)
     102             :     {
     103           0 :         EntryGuard aGuard( *this );
     104           0 :         dbtools::StatementComposer aComposer(getConnection(), command, commandType, sal_True );
     105           0 :         aComposer.setDisposeComposer(sal_False);
     106           0 :         return aComposer.getComposer();
     107             :     }
     108             : 
     109             :     //--------------------------------------------------------------------
     110           0 :     OUString SAL_CALL ConnectionTools::getImplementationName() throw (RuntimeException)
     111             :     {
     112           0 :         return getImplementationName_static();
     113             :     }
     114             : 
     115             :     //--------------------------------------------------------------------
     116           0 :     ::sal_Bool SAL_CALL ConnectionTools::supportsService(const OUString & _ServiceName) throw (RuntimeException)
     117             :     {
     118           0 :         Sequence< OUString > aSupported( getSupportedServiceNames() );
     119           0 :         const OUString* begin = aSupported.getConstArray();
     120           0 :         const OUString* end = aSupported.getConstArray() + aSupported.getLength();
     121           0 :         return ::std::find( begin, end, _ServiceName ) != end;
     122             :     }
     123             : 
     124             :     //--------------------------------------------------------------------
     125           0 :     Sequence< OUString > SAL_CALL ConnectionTools::getSupportedServiceNames() throw (RuntimeException)
     126             :     {
     127           0 :         return getSupportedServiceNames_static();
     128             :     }
     129             : 
     130             :     //--------------------------------------------------------------------
     131           0 :     OUString SAL_CALL ConnectionTools::getImplementationName_static()
     132             :     {
     133           0 :         return OUString( "com.sun.star.comp.dbaccess.ConnectionTools" );
     134             :     }
     135             : 
     136             :     //--------------------------------------------------------------------
     137           0 :     Sequence< OUString > SAL_CALL ConnectionTools::getSupportedServiceNames_static()
     138             :     {
     139           0 :         Sequence< OUString > aSupported( 1 );
     140           0 :         aSupported[0] = OUString( "com.sun.star.sdb.tools.ConnectionTools" );
     141           0 :         return aSupported;
     142             :     }
     143             : 
     144             :     //--------------------------------------------------------------------
     145           0 :     Reference< XInterface > SAL_CALL ConnectionTools::Create(const Reference< XComponentContext >& _rxContext )
     146             :     {
     147           0 :         return *( new ConnectionTools( Reference<XComponentContext>( _rxContext ) ) );
     148             :     }
     149             : 
     150             :     //--------------------------------------------------------------------
     151           0 :     void SAL_CALL ConnectionTools::initialize(const Sequence< Any > & _rArguments) throw (RuntimeException, Exception)
     152             :     {
     153           0 :         ::osl::MutexGuard aGuard( getMutex() );
     154             : 
     155           0 :         Reference< XConnection > xConnection;
     156           0 :         if (_rArguments.getLength()==1 && (_rArguments[0] >>= xConnection))
     157             :         {
     158             :         }
     159             :         else
     160             :         {
     161           0 :             ::comphelper::NamedValueCollection aArguments( _rArguments );
     162           0 :             aArguments.get( "Connection" ) >>= xConnection;
     163             :         }
     164           0 :         if ( !xConnection.is() )
     165           0 :             throw IllegalArgumentException();
     166             : 
     167           0 :         setWeakConnection( xConnection );
     168           0 :     }
     169             : 
     170             : 
     171             : //........................................................................
     172             : } // namespace sdbtools
     173             : //........................................................................
     174             : 
     175             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10