LCOV - code coverage report
Current view: top level - dbaccess/source/core/inc - column.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 5 9 55.6 %
Date: 2012-08-25 Functions: 5 8 62.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     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_COREAPI_COLUMN_HXX_
      21                 :            : #define _DBA_COREAPI_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 <comphelper/stl_types.hxx>
      46                 :            : #include <connectivity/CommonTools.hxx>
      47                 :            : #include <connectivity/FValue.hxx>
      48                 :            : #include <connectivity/TColumnsHelper.hxx>
      49                 :            : #include <connectivity/sdbcx/IRefreshable.hxx>
      50                 :            : #include <cppuhelper/compbase2.hxx>
      51                 :            : #include <cppuhelper/compbase4.hxx>
      52                 :            : #include <cppuhelper/implbase1.hxx>
      53                 :            : #include <cppuhelper/propshlp.hxx>
      54                 :            : #include <osl/diagnose.h>
      55                 :            : 
      56                 :            : #include <boost/unordered_map.hpp>
      57                 :            : 
      58                 :            : namespace dbaccess
      59                 :            : {
      60                 :            : 
      61                 :            :     //************************************************************
      62                 :            :     //  OColumn
      63                 :            :     //************************************************************
      64                 :            :     typedef ::cppu::WeakComponentImplHelper2<   ::com::sun::star::lang::XServiceInfo,
      65                 :            :                                                 ::com::sun::star::container::XNamed
      66                 :            :                                             >   OColumnBase;
      67                 :            : 
      68                 :            :     class OColumn   :public comphelper::OBaseMutex
      69                 :            :                     ,public OColumnBase
      70                 :            :                     ,public ::comphelper::OPropertyContainer
      71                 :            :                     ,public IPropertyContainer  // convenience for the derived class which also derive from OColumnSettings
      72                 :            :     {
      73                 :            :         friend class OColumns;
      74                 :            : 
      75                 :            :     protected:
      76                 :            :         // <properties>
      77                 :            :         ::rtl::OUString m_sName;
      78                 :            :         // </properties>
      79                 :            : 
      80                 :            :     protected:
      81                 :            :         OColumn( const bool _bNameIsReadOnly );
      82                 :            : 
      83                 :            :     public:
      84                 :            :         virtual ~OColumn();
      85                 :            : 
      86                 :            :     // com::sun::star::lang::XTypeProvider
      87                 :            :         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
      88                 :            :         virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) = 0;
      89                 :            : 
      90                 :            :     // com::sun::star::uno::XInterface
      91                 :            :         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException);
      92                 :            :         virtual void SAL_CALL acquire() throw();
      93                 :            :         virtual void SAL_CALL release() throw();
      94                 :            : 
      95                 :            :     // com::sun::star::beans::XPropertySet
      96                 :            :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
      97                 :            : 
      98                 :            :     // cppu::OComponentHelper
      99                 :            :         virtual void SAL_CALL disposing(void);
     100                 :            : 
     101                 :            :     // ::com::sun::star::lang::XServiceInfo
     102                 :            :         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
     103                 :            :         virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
     104                 :            :         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
     105                 :            : 
     106                 :            :         // XNamed
     107                 :            :         virtual ::rtl::OUString SAL_CALL getName(  ) throw(::com::sun::star::uno::RuntimeException);
     108                 :            :         virtual void SAL_CALL setName( const ::rtl::OUString& _rName ) throw(::com::sun::star::uno::RuntimeException);
     109                 :            : 
     110                 :            :         virtual void fireValueChange( const ::connectivity::ORowSetValue& _rOldValue );
     111                 :            : 
     112                 :            :     protected:
     113                 :            :         // IPropertyContainer
     114                 :            :         virtual void registerProperty( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void* _pPointerToMember, const ::com::sun::star::uno::Type& _rMemberType );
     115                 :            :         virtual void registerMayBeVoidProperty( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, ::com::sun::star::uno::Any* _pPointerToMember, const ::com::sun::star::uno::Type& _rExpectedType );
     116                 :            :         virtual void registerPropertyNoMember( const ::rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, const ::com::sun::star::uno::Type& _rType, const void* _pInitialValue );
     117                 :            :     };
     118                 :            : 
     119                 :            :     //============================================================
     120                 :            :     //= IColumnFactory - used by OColumns for creating new columns
     121                 :            :     //============================================================
     122                 :         82 :     class SAL_NO_VTABLE IColumnFactory
     123                 :            :     {
     124                 :            :     public:
     125                 :            :         /** creates a OColumn object which should represent the column with a given name
     126                 :            :         */
     127                 :            :         virtual OColumn*
     128                 :            :             createColumn( const ::rtl::OUString& _rName ) const = 0;
     129                 :            : 
     130                 :            :         /** creates a column descriptor object.
     131                 :            : 
     132                 :            :             A column descriptor object is used to append new columns to the collection. If such an append
     133                 :            :             actually happened, columnAppended is called afterwards.
     134                 :            :         */
     135                 :            :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor() = 0;
     136                 :            : 
     137                 :            :         /** notifies that a column, created from a column descriptor, has been appended
     138                 :            :         */
     139                 :            :         virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor ) = 0;
     140                 :            : 
     141                 :            :         /** notifies that a column with a given name has been dropped
     142                 :            :         */
     143                 :            :         virtual void columnDropped( const ::rtl::OUString& _sName ) = 0;
     144                 :            : 
     145                 :            :     protected:
     146                 :         82 :         ~IColumnFactory() {}
     147                 :            :     };
     148                 :            : 
     149                 :            :     //============================================================
     150                 :            :     //= OColumns
     151                 :            :     //= general columns map, could be used for readonly access
     152                 :            :     //= no appending and dropping is supported
     153                 :            :     //============================================================
     154                 :            :     typedef ::boost::unordered_map<rtl::OUString, OColumn*, ::comphelper::UStringMixHash, ::comphelper::UStringMixEqual> OColumnMap;
     155                 :            :     typedef ::std::vector<OColumn*> OColumnArray;
     156                 :            : 
     157                 :            :     class OContainerMediator;
     158                 :            :     typedef ::cppu::ImplHelper1< ::com::sun::star::container::XChild > TXChild;
     159                 :            :     typedef connectivity::OColumnsHelper OColumns_BASE;
     160                 :            : 
     161                 :            :     class OColumns : public OColumns_BASE
     162                 :            :                     ,public TXChild
     163                 :            :     {
     164                 :            :         OContainerMediator*     m_pMediator;
     165                 :            : 
     166                 :            :     protected:
     167                 :            :         // comes from the driver can be null
     168                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >    m_xDrvColumns;
     169                 :            :         ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface >       m_xParent;
     170                 :            :         IColumnFactory*                             m_pColFactoryImpl;
     171                 :            :         ::connectivity::sdbcx::IRefreshableColumns* m_pRefreshColumns;
     172                 :            : 
     173                 :            :         sal_Bool                                    m_bInitialized  : 1;
     174                 :            :         sal_Bool                                    m_bAddColumn    : 1;
     175                 :            :         sal_Bool                                    m_bDropColumn   : 1;
     176                 :            : 
     177                 :            :         virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
     178                 :            :         virtual connectivity::sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
     179                 :            :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createDescriptor();
     180                 :            :         virtual connectivity::sdbcx::ObjectType appendObject( const ::rtl::OUString& _rForName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
     181                 :            :         virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
     182                 :            : 
     183                 :            :     public:
     184                 :          0 :         connectivity::sdbcx::ObjectType createBaseObject(const ::rtl::OUString& _rName)
     185                 :            :         {
     186                 :          0 :             return OColumns_BASE::createObject(_rName);
     187                 :            :         }
     188                 :            :         /** flag which determines whether the container is filled or not
     189                 :            :         */
     190                 :          0 :         inline sal_Bool isInitialized() const { return m_bInitialized; }
     191                 :          0 :         inline void     setInitialized() {m_bInitialized = sal_True;}
     192                 :         28 :         inline void     setMediator(OContainerMediator* _pMediator) { m_pMediator = _pMediator; }
     193                 :            : 
     194                 :            :     public:
     195                 :            :         /** constructs an empty container without configuration location.
     196                 :            :             @param      rParent             the parent object. This instance will be used for refcounting, so the parent
     197                 :            :                                             cannot die before the container does.
     198                 :            :             @param      _rMutex             the mutex of the parent.
     199                 :            :             @param      _bCaseSensitive     the initial case sensitivity flag
     200                 :            :             @see        setCaseSensitive
     201                 :            :         */
     202                 :            :         OColumns(
     203                 :            :                 ::cppu::OWeakObject& _rParent,
     204                 :            :                 ::osl::Mutex& _rMutex,
     205                 :            :                 sal_Bool _bCaseSensitive,
     206                 :            :                 const ::std::vector< ::rtl::OUString>& _rVector,
     207                 :            :                 IColumnFactory* _pColFactory,
     208                 :            :                 ::connectivity::sdbcx::IRefreshableColumns* _pRefresh,
     209                 :            :                 sal_Bool _bAddColumn = sal_False,
     210                 :            :                 sal_Bool _bDropColumn = sal_False,
     211                 :            :                 sal_Bool _bUseHardRef = sal_True);
     212                 :            : 
     213                 :            :         OColumns(
     214                 :            :             ::cppu::OWeakObject& _rParent,
     215                 :            :             ::osl::Mutex& _rMutex,
     216                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxDrvColumns,
     217                 :            :             sal_Bool _bCaseSensitive,
     218                 :            :             const ::std::vector< ::rtl::OUString> &_rVector,
     219                 :            :             IColumnFactory* _pColFactory,
     220                 :            :             ::connectivity::sdbcx::IRefreshableColumns* _pRefresh,
     221                 :            :             sal_Bool _bAddColumn = sal_False,
     222                 :            :             sal_Bool _bDropColumn = sal_False,
     223                 :            :             sal_Bool _bUseHardRef = sal_True);
     224                 :            :         virtual ~OColumns();
     225                 :            : 
     226                 :            :         //XInterface
     227                 :            :         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
     228                 :      12870 :         virtual void SAL_CALL acquire() throw() { OColumns_BASE::acquire(); }
     229                 :      12742 :         virtual void SAL_CALL release() throw() { OColumns_BASE::release(); }
     230                 :            :         //XTypeProvider
     231                 :            :         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
     232                 :            : 
     233                 :            :     // ::com::sun::star::lang::XServiceInfo
     234                 :            :         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
     235                 :            :         virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
     236                 :            :         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
     237                 :            : 
     238                 :            :         // ::com::sun::star::container::XChild
     239                 :            :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent(  ) throw (::com::sun::star::uno::RuntimeException);
     240                 :            :         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);
     241                 :            : 
     242                 :            :         void append(const ::rtl::OUString& rName, OColumn*);
     243                 :            :         void clearColumns();
     244                 :            :         // only the name is identical to ::cppu::OComponentHelper
     245                 :            :         virtual void SAL_CALL disposing(void);
     246                 :            : 
     247                 :            :     private:
     248                 :            :         using OColumns_BASE::setParent;
     249                 :            :     };
     250                 :            : }
     251                 :            : #endif // _DBA_COREAPI_COLUMN_HXX_
     252                 :            : 
     253                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10