LCOV - code coverage report
Current view: top level - dbaccess/source/core/dataaccess - connection.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 3 4 75.0 %
Date: 2015-06-13 12:38:46 Functions: 1 1 100.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             : #ifndef INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_CONNECTION_HXX
      20             : #define INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_CONNECTION_HXX
      21             : 
      22             : #include <sal/config.h>
      23             : 
      24             : #include <map>
      25             : 
      26             : #include "apitools.hxx"
      27             : #include "querycontainer.hxx"
      28             : #include "tablecontainer.hxx"
      29             : #include "viewcontainer.hxx"
      30             : #include "RefreshListener.hxx"
      31             : 
      32             : #include <com/sun/star/container/XChild.hpp>
      33             : #include <com/sun/star/lang/DisposedException.hpp>
      34             : #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
      35             : #include <com/sun/star/sdb/XCommandPreparation.hpp>
      36             : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
      37             : #include <com/sun/star/sdbcx/XViewsSupplier.hpp>
      38             : #include <com/sun/star/sdbcx/XUsersSupplier.hpp>
      39             : #include <com/sun/star/sdbcx/XGroupsSupplier.hpp>
      40             : #include <com/sun/star/sdb/XQueriesSupplier.hpp>
      41             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      42             : #include <com/sun/star/sdb/tools/XConnectionTools.hpp>
      43             : #include <com/sun/star/sdb/application/XTableUIProvider.hpp>
      44             : 
      45             : #include <cppuhelper/implbase13.hxx>
      46             : #include <comphelper/stl_types.hxx>
      47             : #include <connectivity/ConnectionWrapper.hxx>
      48             : #include <connectivity/CommonTools.hxx>
      49             : #include <connectivity/warningscontainer.hxx>
      50             : 
      51             : namespace dbaccess
      52             : {
      53             : 
      54             : typedef cppu::ImplHelper13  <   ::com::sun::star::container::XChild
      55             :                                     ,   ::com::sun::star::sdbcx::XTablesSupplier
      56             :                                     ,   ::com::sun::star::sdbcx::XViewsSupplier
      57             :                                     ,   ::com::sun::star::sdbc::XConnection
      58             :                                     ,   ::com::sun::star::sdbc::XWarningsSupplier
      59             :                                     ,   ::com::sun::star::sdb::XQueriesSupplier
      60             :                                     ,   ::com::sun::star::sdb::XSQLQueryComposerFactory
      61             :                                     ,   ::com::sun::star::sdb::XCommandPreparation
      62             :                                     ,   ::com::sun::star::lang::XMultiServiceFactory
      63             :                                     ,   ::com::sun::star::sdbcx::XUsersSupplier
      64             :                                     ,   ::com::sun::star::sdbcx::XGroupsSupplier
      65             :                                     ,   ::com::sun::star::sdb::tools::XConnectionTools
      66             :                                     ,   ::com::sun::star::sdb::application::XTableUIProvider
      67             :                                     >   OConnection_Base;
      68             : 
      69             : class ODatabaseSource;
      70             : // OConnection
      71             : class OConnection           :public ::comphelper::OBaseMutex
      72             :                             ,public OSubComponent
      73             :                             ,public ::connectivity::OConnectionWrapper
      74             :                             ,public OConnection_Base
      75             :                             ,public IRefreshListener
      76             : {
      77             : protected:
      78             :     ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier >
      79             :                             m_xMasterTables; // just to avoid the recreation of the catalog
      80             :     connectivity::OWeakRefArray           m_aStatements;
      81             :     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
      82             :                             m_xQueries;
      83             :     connectivity::OWeakRefArray           m_aComposers;
      84             : 
      85             :     // the filter as set on the parent data link at construction of the connection
      86             :     ::com::sun::star::uno::Sequence< OUString >  m_aTableFilter;
      87             :     ::com::sun::star::uno::Sequence< OUString >  m_aTableTypeFilter;
      88             :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >                m_aContext;
      89             :     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >                     m_xMasterConnection;
      90             :     ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XConnectionTools >          m_xConnectionTools;
      91             :     ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XTableUIProvider >    m_xTableUIProvider;
      92             : 
      93             :     // defines the helper services for example to query the command of a view
      94             :     // @ see com.sun.star.sdb.tools.XViewAccess
      95             :     typedef std::map< OUString, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> > TSupportServices;
      96             :     TSupportServices                m_aSupportServices;
      97             : 
      98             :     OTableContainer*                m_pTables;
      99             :     OViewContainer*                 m_pViews;
     100             :     ::dbtools::WarningsContainer    m_aWarnings;
     101             :     oslInterlockedCount             m_nInAppend;
     102             :     bool                        m_bSupportsViews;       // true when the getTableTypes return "VIEW" as type
     103             :     bool                        m_bSupportsUsers;
     104             :     bool                        m_bSupportsGroups;
     105             : 
     106             : protected:
     107             :     virtual ~OConnection();
     108             : public:
     109             :     OConnection(ODatabaseSource& _rDB
     110             :                 ,::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxMaster
     111             :                 ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB);
     112             : 
     113             : // com::sun::star::lang::XTypeProvider
     114             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     115             :     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     116             : 
     117             : // com::sun::star::uno::XInterface
     118             :     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     119             :         virtual void SAL_CALL acquire() throw( ) SAL_OVERRIDE;
     120             :     virtual void SAL_CALL release() throw( ) SAL_OVERRIDE;
     121             : 
     122             : // OComponentHelper
     123             :     virtual void SAL_CALL disposing() SAL_OVERRIDE;
     124             : 
     125             : // ::com::sun::star::container::XChild
     126             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     127             :     virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw(::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     128             : 
     129             : // ::com::sun::star::sdbcx::XTablesSupplier
     130             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     131             : // ::com::sun::star::sdbcx::XViewsSupplier
     132             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getViews(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     133             : 
     134             : // ::com::sun::star::sdb::XQueriesSupplier
     135             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getQueries(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     136             : 
     137             : // ::com::sun::star::sdb::XSQLQueryComposerFactory
     138             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLQueryComposer > SAL_CALL createQueryComposer(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     139             : 
     140             : // ::com::sun::star::sdb::XCommandPreparation
     141             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCommand( const OUString& command, sal_Int32 commandType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     142             : 
     143             : // ::com::sun::star::sdbc::XWarningsSupplier
     144             :     virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     145             :     virtual void SAL_CALL clearWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     146             : 
     147             : // ::com::sun::star::lang::XServiceInfo
     148             :     virtual OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     149             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     150             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     151             : 
     152             : // XConnection
     153             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     154             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     155             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     156             :     virtual OUString SAL_CALL nativeSQL( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     157             :     virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     158             :     virtual sal_Bool SAL_CALL getAutoCommit(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     159             :     virtual void SAL_CALL commit(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     160             :     virtual void SAL_CALL rollback(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     161             :     virtual sal_Bool SAL_CALL isClosed(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     162             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     163             :     virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     164             :     virtual sal_Bool SAL_CALL isReadOnly(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     165             :     virtual void SAL_CALL setCatalog( const OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     166             :     virtual OUString SAL_CALL getCatalog(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     167             :     virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     168             :     virtual sal_Int32 SAL_CALL getTransactionIsolation(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     169             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     170             :     virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     171             : 
     172             : // ::com::sun::star::sdbc::XCloseable
     173             :     virtual void SAL_CALL close(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     174             : 
     175             :     // XMultiServiceFactory
     176             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     177             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     178             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     179             : 
     180             :     // XUsersSupplier
     181             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getUsers(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     182             :     // XGroupsSupplier
     183             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getGroups(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     184             : 
     185             :     // XConnectionTools
     186             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XTableName > SAL_CALL createTableName(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     187             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XObjectNames > SAL_CALL getObjectNames(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     188             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::tools::XDataSourceMetaData > SAL_CALL getDataSourceMetaData(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     189             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getFieldsByCommandDescriptor( ::sal_Int32 commandType, const OUString& command, ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& keepFieldsAlive ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     190             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > SAL_CALL getComposer( ::sal_Int32 commandType, const OUString& command ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     191             : 
     192             :     // XTableUIProvider
     193             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > SAL_CALL getTableIcon( const OUString& TableName, ::sal_Int32 ColorMode ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     194             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getTableEditor( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& DocumentUI, const OUString& TableName ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     195             : 
     196             :     // IRefreshListener
     197             :     virtual void refresh(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rToBeRefreshed) SAL_OVERRIDE;
     198             : 
     199             : protected:
     200        7684 :     inline  void checkDisposed() throw (::com::sun::star::lang::DisposedException)
     201             :     {
     202        7684 :         if ( rBHelper.bDisposed || !m_xConnection.is() )
     203           0 :             throw ::com::sun::star::lang::DisposedException();
     204        7684 :     }
     205             : 
     206             :     ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > getMasterTables();
     207             : 
     208             : private:
     209             :     /** checks whether or not there are naming conflicts between tables and queries
     210             :     */
     211             :     void    impl_checkTableQueryNames_nothrow();
     212             : 
     213             :     /** loads the XConnectionTools implementation which we forward the respective functionality to
     214             : 
     215             :         @throws ::com::sun::star::uno::RuntimeException
     216             :             if the implementation cannot be loaded
     217             : 
     218             :         @postcond
     219             :             m_xConnectionTools is nol <NULL/>
     220             :     */
     221             :     void    impl_loadConnectionTools_throw();
     222             : 
     223             :     /** reads the table filter and table type filter from the datasourfce
     224             :     */
     225             :     void    impl_fillTableFilter();
     226             : };
     227             : 
     228             : }   // namespace dbaccess
     229             : 
     230             : #endif // INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_CONNECTION_HXX
     231             : 
     232             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11