LCOV - code coverage report
Current view: top level - dbaccess/source/core/inc - column.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 6 9 66.7 %
Date: 2015-06-13 12:38:46 Functions: 6 8 75.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_INC_COLUMN_HXX
      21             : #define INCLUDED_DBACCESS_SOURCE_CORE_INC_COLUMN_HXX
      22             : 
      23             : #include "columnsettings.hxx"
      24             : 
      25             : #include <com/sun/star/container/XChild.hpp>
      26             : #include <com/sun/star/container/XEnumerationAccess.hpp>
      27             : #include <com/sun/star/container/XIndexAccess.hpp>
      28             : #include <com/sun/star/container/XNameAccess.hpp>
      29             : #include <com/sun/star/container/XNamed.hpp>
      30             : #include <com/sun/star/io/IOException.hpp>
      31             : #include <com/sun/star/io/XObjectInputStream.hpp>
      32             : #include <com/sun/star/io/XObjectOutputStream.hpp>
      33             : #include <com/sun/star/lang/WrappedTargetException.hpp>
      34             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      35             : #include <com/sun/star/lang/XServiceInfo.hpp>
      36             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      37             : #include <com/sun/star/sdbc/XResultSet.hpp>
      38             : #include <com/sun/star/sdbcx/XAppend.hpp>
      39             : #include <com/sun/star/sdbcx/XDrop.hpp>
      40             : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
      41             : 
      42             : #include <comphelper/broadcasthelper.hxx>
      43             : #include <comphelper/proparrhlp.hxx>
      44             : #include <comphelper/propertycontainer.hxx>
      45             : #include <connectivity/CommonTools.hxx>
      46             : #include <connectivity/FValue.hxx>
      47             : #include <connectivity/TColumnsHelper.hxx>
      48             : #include <connectivity/sdbcx/IRefreshable.hxx>
      49             : #include <cppuhelper/compbase2.hxx>
      50             : #include <cppuhelper/compbase4.hxx>
      51             : #include <cppuhelper/implbase1.hxx>
      52             : #include <cppuhelper/propshlp.hxx>
      53             : #include <osl/diagnose.h>
      54             : 
      55             : namespace dbaccess
      56             : {
      57             : 
      58             : 
      59             :     //  OColumn
      60             : 
      61             :     typedef ::cppu::WeakComponentImplHelper2<   ::com::sun::star::lang::XServiceInfo,
      62             :                                                 ::com::sun::star::container::XNamed
      63             :                                             >   OColumnBase;
      64             : 
      65             :     class OColumn   :public comphelper::OBaseMutex
      66             :                     ,public OColumnBase
      67             :                     ,public ::comphelper::OPropertyContainer
      68             :                     ,public IPropertyContainer  // convenience for the derived class which also derive from OColumnSettings
      69             :     {
      70             :         friend class OColumns;
      71             : 
      72             :     protected:
      73             :         // <properties>
      74             :         OUString m_sName;
      75             :         // </properties>
      76             : 
      77             :     protected:
      78             :         OColumn( const bool _bNameIsReadOnly );
      79             : 
      80             :     public:
      81             :         virtual ~OColumn();
      82             : 
      83             :     // com::sun::star::lang::XTypeProvider
      84             :         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      85             :         virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE = 0;
      86             : 
      87             :     // com::sun::star::uno::XInterface
      88             :         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;
      89             :         virtual void SAL_CALL acquire() throw() SAL_OVERRIDE;
      90             :         virtual void SAL_CALL release() throw() SAL_OVERRIDE;
      91             : 
      92             :     // com::sun::star::beans::XPropertySet
      93             :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      94             : 
      95             :     // cppu::OComponentHelper
      96             :         virtual void SAL_CALL disposing() SAL_OVERRIDE;
      97             : 
      98             :     // ::com::sun::star::lang::XServiceInfo
      99             :         virtual OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     100             :         virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     101             :         virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     102             : 
     103             :         // XNamed
     104             :         virtual OUString SAL_CALL getName(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     105             :         virtual void SAL_CALL setName( const OUString& _rName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     106             : 
     107             :         virtual void fireValueChange( const ::connectivity::ORowSetValue& _rOldValue );
     108             : 
     109             :     protected:
     110             :         // IPropertyContainer
     111             :         virtual void registerProperty( const OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void* _pPointerToMember, const ::com::sun::star::uno::Type& _rMemberType ) SAL_OVERRIDE;
     112             :         virtual void registerMayBeVoidProperty( const OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, ::com::sun::star::uno::Any* _pPointerToMember, const ::com::sun::star::uno::Type& _rExpectedType ) SAL_OVERRIDE;
     113             :         virtual void registerPropertyNoMember( const OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, const ::com::sun::star::uno::Type& _rType, const void* _pInitialValue ) SAL_OVERRIDE;
     114             :     };
     115             : 
     116             :     // IColumnFactory - used by OColumns for creating new columns
     117         132 :     class SAL_NO_VTABLE IColumnFactory
     118             :     {
     119             :     public:
     120             :         /** creates a OColumn object which should represent the column with a given name
     121             :         */
     122             :         virtual OColumn*
     123             :             createColumn( const OUString& _rName ) const = 0;
     124             : 
     125             :         /** creates a column descriptor object.
     126             : 
     127             :             A column descriptor object is used to append new columns to the collection. If such an append
     128             :             actually happened, columnAppended is called afterwards.
     129             :         */
     130             :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor() = 0;
     131             : 
     132             :         /** notifies that a column, created from a column descriptor, has been appended
     133             :         */
     134             :         virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor ) = 0;
     135             : 
     136             :         /** notifies that a column with a given name has been dropped
     137             :         */
     138             :         virtual void columnDropped( const OUString& _sName ) = 0;
     139             : 
     140             :     protected:
     141         132 :         ~IColumnFactory() {}
     142             :     };
     143             : 
     144             :     class OContainerMediator;
     145             :     typedef ::cppu::ImplHelper1< ::com::sun::star::container::XChild > TXChild;
     146             :     typedef connectivity::OColumnsHelper OColumns_BASE;
     147             : 
     148             :     class OColumns : public OColumns_BASE
     149             :                     ,public TXChild
     150             :     {
     151             :         OContainerMediator*     m_pMediator;
     152             : 
     153             :     protected:
     154             :         // comes from the driver can be null
     155             :         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >    m_xDrvColumns;
     156             :         ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface >       m_xParent;
     157             :         IColumnFactory*                             m_pColFactoryImpl;
     158             :         ::connectivity::sdbcx::IRefreshableColumns* m_pRefreshColumns;
     159             : 
     160             :         bool                                    m_bInitialized  : 1;
     161             :         bool                                    m_bAddColumn    : 1;
     162             :         bool                                    m_bDropColumn   : 1;
     163             : 
     164             :         virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
     165             :         virtual connectivity::sdbcx::ObjectType createObject(const OUString& _rName) SAL_OVERRIDE;
     166             :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor() SAL_OVERRIDE;
     167             :         virtual connectivity::sdbcx::ObjectType appendObject( const OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) SAL_OVERRIDE;
     168             :         virtual void dropObject(sal_Int32 _nPos, const OUString& _sElementName) SAL_OVERRIDE;
     169             : 
     170             :     public:
     171           0 :         connectivity::sdbcx::ObjectType createBaseObject(const OUString& _rName)
     172             :         {
     173           0 :             return OColumns_BASE::createObject(_rName);
     174             :         }
     175             :         /** flag which determines whether the container is filled or not
     176             :         */
     177           0 :         inline bool isInitialized() const { return m_bInitialized; }
     178           1 :         inline void     setInitialized() {m_bInitialized = true;}
     179          32 :         inline void     setMediator(OContainerMediator* _pMediator) { m_pMediator = _pMediator; }
     180             : 
     181             :     public:
     182             :         /** constructs an empty container without configuration location.
     183             :             @param      rParent             the parent object. This instance will be used for refcounting, so the parent
     184             :                                             cannot die before the container does.
     185             :             @param      _rMutex             the mutex of the parent.
     186             :             @param      _bCaseSensitive     the initial case sensitivity flag
     187             :             @see        setCaseSensitive
     188             :         */
     189             :         OColumns(
     190             :                 ::cppu::OWeakObject& _rParent,
     191             :                 ::osl::Mutex& _rMutex,
     192             :                 bool _bCaseSensitive,
     193             :                 const ::std::vector< OUString>& _rVector,
     194             :                 IColumnFactory* _pColFactory,
     195             :                 ::connectivity::sdbcx::IRefreshableColumns* _pRefresh,
     196             :                 bool _bAddColumn = false,
     197             :                 bool _bDropColumn = false,
     198             :                 bool _bUseHardRef = true);
     199             : 
     200             :         OColumns(
     201             :             ::cppu::OWeakObject& _rParent,
     202             :             ::osl::Mutex& _rMutex,
     203             :             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxDrvColumns,
     204             :             bool _bCaseSensitive,
     205             :             const ::std::vector< OUString> &_rVector,
     206             :             IColumnFactory* _pColFactory,
     207             :             ::connectivity::sdbcx::IRefreshableColumns* _pRefresh,
     208             :             bool _bAddColumn = false,
     209             :             bool _bDropColumn = false,
     210             :             bool _bUseHardRef = true);
     211             :         virtual ~OColumns();
     212             : 
     213             :         //XInterface
     214             :         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;
     215      130707 :         virtual void SAL_CALL acquire() throw() SAL_OVERRIDE { OColumns_BASE::acquire(); }
     216      117074 :         virtual void SAL_CALL release() throw() SAL_OVERRIDE { OColumns_BASE::release(); }
     217             :         //XTypeProvider
     218             :         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     219             : 
     220             :     // ::com::sun::star::lang::XServiceInfo
     221             :         virtual OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     222             :         virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     223             :         virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     224             : 
     225             :         // ::com::sun::star::container::XChild
     226             :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     227             :         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;
     228             : 
     229             :         void append(const OUString& rName, OColumn*);
     230             :         void clearColumns();
     231             :         // only the name is identical to ::cppu::OComponentHelper
     232             :         virtual void SAL_CALL disposing() SAL_OVERRIDE;
     233             : 
     234             :     private:
     235             :         using OColumns_BASE::setParent;
     236             :     };
     237             : }
     238             : #endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_COLUMN_HXX
     239             : 
     240             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11