LCOV - code coverage report
Current view: top level - dbaccess/source/core/dataaccess - datasource.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 1 100.0 %
Date: 2014-11-03 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             : 
      20             : #ifndef INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DATASOURCE_HXX
      21             : #define INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_DATASOURCE_HXX
      22             : 
      23             : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
      24             : #include <com/sun/star/lang/XServiceInfo.hpp>
      25             : #include <com/sun/star/sdbc/XDataSource.hpp>
      26             : #include <com/sun/star/container/XContainerListener.hpp>
      27             : #include <com/sun/star/sdb/XBookmarksSupplier.hpp>
      28             : #include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
      29             : #include <com/sun/star/sdbc/XIsolatedConnection.hpp>
      30             : #include <com/sun/star/util/XNumberFormatter.hpp>
      31             : #include <com/sun/star/document/XEventListener.hpp>
      32             : #include <com/sun/star/util/XFlushable.hpp>
      33             : #include <cppuhelper/propshlp.hxx>
      34             : #include <comphelper/proparrhlp.hxx>
      35             : #include <cppuhelper/weakref.hxx>
      36             : #include <cppuhelper/compbase11.hxx>
      37             : #include <com/sun/star/embed/XTransactionListener.hpp>
      38             : #include "apitools.hxx"
      39             : #include "bookmarkcontainer.hxx"
      40             : #include <rtl/ref.hxx>
      41             : #include <connectivity/CommonTools.hxx>
      42             : #include <comphelper/broadcasthelper.hxx>
      43             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      44             : #include <com/sun/star/beans/PropertyValue.hpp>
      45             : #include <com/sun/star/sdb/XCompletedConnection.hpp>
      46             : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
      47             : #include <com/sun/star/embed/XStorage.hpp>
      48             : #include "ContentHelper.hxx"
      49             : #include <com/sun/star/document/XStorageBasedDocument.hpp>
      50             : #include <com/sun/star/embed/ElementModes.hpp>
      51             : #include <com/sun/star/util/XRefreshable.hpp>
      52             : #include <com/sun/star/sdb/XDocumentDataSource.hpp>
      53             : #include "ModelImpl.hxx"
      54             : 
      55             : namespace dbaccess
      56             : {
      57             : 
      58             : class OSharedConnectionManager;
      59             : 
      60             : // ODatabaseSource
      61             : typedef ::cppu::WeakComponentImplHelper11   <   ::com::sun::star::lang::XServiceInfo
      62             :                                             ,   ::com::sun::star::sdbc::XDataSource
      63             :                                             ,   ::com::sun::star::sdb::XBookmarksSupplier
      64             :                                             ,   ::com::sun::star::sdb::XQueryDefinitionsSupplier
      65             :                                             ,   ::com::sun::star::sdb::XCompletedConnection
      66             :                                             ,   ::com::sun::star::container::XContainerListener
      67             :                                             ,   ::com::sun::star::sdbc::XIsolatedConnection
      68             :                                             ,   ::com::sun::star::sdbcx::XTablesSupplier
      69             :                                             ,   ::com::sun::star::util::XFlushable
      70             :                                             ,   ::com::sun::star::util::XFlushListener
      71             :                                             ,   ::com::sun::star::sdb::XDocumentDataSource
      72             :                                             >   ODatabaseSource_Base;
      73             : 
      74             : class ODatabaseSource   :public ModelDependentComponent // must be first
      75             :                         ,public ODatabaseSource_Base
      76             :                         ,public ::cppu::OPropertySetHelper
      77             :                         ,public ::comphelper::OPropertyArrayUsageHelper < ODatabaseSource >
      78             : {
      79             :     friend class ODatabaseContext;
      80             :     friend class OConnection;
      81             :     friend class OSharedConnectionManager;
      82             : 
      83             : private:
      84             :     using ODatabaseSource_Base::rBHelper;
      85             :     OBookmarkContainer                      m_aBookmarks;
      86             :     ::cppu::OInterfaceContainerHelper       m_aFlushListeners;
      87             : 
      88             : private:
      89             :     virtual ~ODatabaseSource();
      90             : 
      91             : public:
      92             :     ODatabaseSource( const ::rtl::Reference< ODatabaseModelImpl >& _pImpl );
      93             : 
      94         178 :     struct DBContextAccess { friend class ODatabaseContext; private: DBContextAccess() { } };
      95             : 
      96             :     /** sets a new name for the data source
      97             : 
      98             :         The name of a data source (our m_sName member) is the registration name, *if* the
      99             :         data source actually *is* registered at the database context.
     100             : 
     101             :         Normally, this name is passed at time of creation of the ODatabaseModelImpl instance,
     102             :         but if a newly creaed data source is registered, then it must be possible to propagate
     103             :         the new trgistration name.
     104             :     */
     105             :     static void setName(
     106             :             const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XDocumentDataSource >& _rxDocument,
     107             :             const OUString& _rNewName,
     108             :             DBContextAccess
     109             :         );
     110             : 
     111             :     // XContainerListener
     112             :     virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     113             :     virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     114             :     virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     115             :     // ::com::sun::star::sdbcx::XTablesSupplier
     116             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     117             : 
     118             : // com::sun::star::lang::XTypeProvider
     119             :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     120             :     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     121             : 
     122             : // com::sun::star::uno::XInterface
     123             :     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;
     124             :     virtual void SAL_CALL acquire() throw( ) SAL_OVERRIDE;
     125             :     virtual void SAL_CALL release() throw( ) SAL_OVERRIDE;
     126             : 
     127             : // ::com::sun::star::lang::XServiceInfo
     128             :     virtual OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     129             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     130             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     131             : 
     132             : // ::com::sun::star::lang::XServiceInfo - static methods
     133             :     static ::com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_static(void) throw( ::com::sun::star::uno::RuntimeException );
     134             :     static OUString getImplementationName_static(void) throw( ::com::sun::star::uno::RuntimeException );
     135             :     static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
     136             :         SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
     137             : 
     138             : // OComponentHelper
     139             :     virtual void SAL_CALL disposing(void) SAL_OVERRIDE;
     140             : 
     141             : // com::sun::star::beans::XPropertySet
     142             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     143             :     // XEventListener
     144             :     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     145             : 
     146             : // comphelper::OPropertyArrayUsageHelper
     147             :     virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
     148             : 
     149             : // cppu::OPropertySetHelper
     150             :     virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
     151             : 
     152             :     virtual sal_Bool SAL_CALL convertFastPropertyValue(
     153             :                             ::com::sun::star::uno::Any & rConvertedValue,
     154             :                             ::com::sun::star::uno::Any & rOldValue,
     155             :                             sal_Int32 nHandle,
     156             :                             const ::com::sun::star::uno::Any& rValue )
     157             :                                 throw (::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
     158             :     virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
     159             :                                 sal_Int32 nHandle,
     160             :                                 const ::com::sun::star::uno::Any& rValue
     161             :                                                  )
     162             :                                                  throw (::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
     163             :     virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const SAL_OVERRIDE;
     164             : 
     165             : // ::com::sun::star::sdb::XCompletedConnection
     166             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connectWithCompletion( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& handler ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     167             : 
     168             : // ::com::sun::star::sdbc::XDataSource
     169             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( const OUString& user, const OUString& password ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     170             :     virtual void SAL_CALL setLoginTimeout( sal_Int32 seconds ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     171             :     virtual sal_Int32 SAL_CALL getLoginTimeout(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     172             : 
     173             : // :: com::sun::star::sdb::XBookmarksSupplier
     174             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getBookmarks(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     175             : 
     176             : // :: com::sun::star::sdb::XQueryDefinitionsSupplier
     177             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getQueryDefinitions(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     178             : 
     179             : // ::com::sun::star::sdbc::XIsolatedConnection
     180             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getIsolatedConnection( const OUString& user, const OUString& password ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     181             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getIsolatedConnectionWithCompletion( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& handler ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     182             : 
     183             : // XFlushable
     184             :     virtual void SAL_CALL flush(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     185             :     virtual void SAL_CALL addFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     186             :     virtual void SAL_CALL removeFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     187             : 
     188             :     // XFlushListener
     189             :     virtual void SAL_CALL flushed( const ::com::sun::star::lang::EventObject& rEvent ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     190             : 
     191             :     // XDocumentDataSource
     192             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XOfficeDatabaseDocument > SAL_CALL getDatabaseDocument() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     193             : 
     194             : protected:
     195             :     // ModelDependentComponent overridables
     196             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getThis() const SAL_OVERRIDE;
     197             : 
     198             : private:
     199             : // helper
     200             :     /** open a connection for the current settings. this is the simple connection we get from the driver
     201             :         manager, so it can be used as a master for a "high level" sdb connection.
     202             :     */
     203             :     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > buildLowLevelConnection(
     204             :         const OUString& _rUid, const OUString& _rPwd
     205             :         );
     206             : 
     207             :     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > buildIsolatedConnection(
     208             :         const OUString& user, const OUString& password
     209             :         );
     210             : 
     211             :     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( const OUString& user, const OUString& password , bool _bIsolated) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     212             :     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connectWithCompletion( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& handler , bool _bIsolated) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     213             : 
     214             :     void clearConnections();
     215             : 
     216             : protected:
     217             :     using ::cppu::OPropertySetHelper::getFastPropertyValue;
     218             : };
     219             : 
     220             : }   // namespace dbaccess
     221             : 
     222             : #endif // _DBA_COREDATAACCESS_DATALINK_HXX_
     223             : 
     224             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10