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

Generated by: LCOV version 1.10