LCOV - code coverage report
Current view: top level - dbaccess/source/core/dataaccess - ComponentDefinition.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 10 11 90.9 %
Date: 2015-06-13 12:38:46 Functions: 8 9 88.9 %
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_COMPONENTDEFINITION_HXX
      21             : #define INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_COMPONENTDEFINITION_HXX
      22             : 
      23             : #include "commandbase.hxx"
      24             : #include <comphelper/propertycontainer.hxx>
      25             : #include <com/sun/star/sdbcx/XRename.hpp>
      26             : #include <cppuhelper/implbase1.hxx>
      27             : #include <comphelper/proparrhlp.hxx>
      28             : #include "datasettings.hxx"
      29             : #include <com/sun/star/container/XNameAccess.hpp>
      30             : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
      31             : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
      32             : #include <com/sun/star/uno/XComponentContext.hpp>
      33             : #include "ContentHelper.hxx"
      34             : #include "apitools.hxx"
      35             : #include <column.hxx>
      36             : 
      37             : #include <memory>
      38             : namespace dbaccess
      39             : {
      40             : 
      41             :     typedef ::cppu::ImplHelper1< ::com::sun::star::sdbcx::XColumnsSupplier > OComponentDefinition_BASE;
      42             : 
      43             :     class OComponentDefinition_Impl : public OContentHelper_Impl
      44             :                                      ,public ODataSettings_Base
      45             :     {
      46             :     public:
      47             :         typedef ::std::map  <   OUString
      48             :                             ,   ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
      49             :                             >   Columns;
      50             :     typedef Columns::iterator           iterator;
      51             :     typedef Columns::const_iterator     const_iterator;
      52             : 
      53             :     private:
      54             :         Columns             m_aColumns;
      55             : 
      56             :     public:
      57             :         OUString     m_sSchemaName;
      58             :         OUString     m_sCatalogName;
      59             : 
      60             :     public:
      61             :         OComponentDefinition_Impl();
      62             :         virtual ~OComponentDefinition_Impl();
      63             : 
      64          53 :         inline size_t size() const { return m_aColumns.size(); }
      65             : 
      66          53 :         inline const_iterator begin() const   { return m_aColumns.begin(); }
      67         518 :         inline const_iterator end() const     { return m_aColumns.end(); }
      68             : 
      69         465 :         inline const_iterator find( const OUString& _rName ) const { return m_aColumns.find( _rName ); }
      70             : 
      71           0 :         inline void erase( const OUString& _rName ) { m_aColumns.erase( _rName ); }
      72             : 
      73         213 :         inline void insert( const OUString& _rName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn )
      74             :         {
      75             :             OSL_PRECOND( m_aColumns.find( _rName ) == m_aColumns.end(), "OComponentDefinition_Impl::insert: there's already an element with this name!" );
      76         213 :             m_aColumns.insert( Columns::value_type( _rName, _rxColumn ) );
      77         213 :         }
      78             :     };
      79             : 
      80             : class OColumnPropertyListener;
      81             : // OComponentDefinition - a database "document" which describes a query
      82             : class OComponentDefinition  :public OContentHelper
      83             :                             ,public ODataSettings
      84             :                             ,public IColumnFactory
      85             :                             ,public OComponentDefinition_BASE
      86             :                             ,public ::comphelper::OPropertyArrayUsageHelper< OComponentDefinition >
      87             : {
      88             :     OComponentDefinition();
      89             : 
      90             : protected:
      91             :     ::std::unique_ptr< OColumns >     m_pColumns;
      92             :     rtl::Reference<OColumnPropertyListener> m_xColumnPropertyListener;
      93             :     bool                        m_bTable;
      94             : 
      95             :     virtual ~OComponentDefinition();
      96             :     virtual void SAL_CALL disposing() SAL_OVERRIDE;
      97             : 
      98             : protected:
      99             :     OComponentDefinition(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&
     100             :         ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >&   _xParentContainer
     101             :         ,const TContentPtr& _pImpl
     102             :         ,bool _bTable = true);
     103             : 
     104         465 :     const   OComponentDefinition_Impl& getDefinition() const { return dynamic_cast< const OComponentDefinition_Impl& >( *m_pImpl.get() ); }
     105         365 :             OComponentDefinition_Impl& getDefinition()       { return dynamic_cast<       OComponentDefinition_Impl& >( *m_pImpl.get() ); }
     106             : public:
     107             : 
     108             :     OComponentDefinition(
     109             :              const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContainer
     110             :             ,const OUString& _rElementName
     111             :             ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&
     112             :             ,const TContentPtr& _pImpl
     113             :             ,bool _bTable = true
     114             :         );
     115             : 
     116             :     virtual css::uno::Sequence<css::uno::Type> SAL_CALL getTypes()
     117             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     118             :     virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId()
     119             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     120             : 
     121             : // ::com::sun::star::uno::XInterface
     122             :     DECLARE_XINTERFACE( )
     123             : 
     124             :     // ::com::sun::star::lang::XServiceInfo
     125             :     virtual OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     126             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     127             : 
     128             :     static ::com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_static() throw( ::com::sun::star::uno::RuntimeException );
     129             :     static OUString getImplementationName_static() throw( ::com::sun::star::uno::RuntimeException );
     130             :     static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
     131             :         Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
     132             : 
     133             :     // XInitialization
     134             :     virtual void SAL_CALL initialize( com::sun::star::uno::Sequence< com::sun::star::uno::Any > const & rArguments) throw (com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
     135             : 
     136             :     // ::com::sun::star::beans::XPropertySet
     137             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     138             : 
     139             :     // XColumnsSupplier
     140             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns(  ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     141             : 
     142             :     // OPropertySetHelper
     143             :     virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
     144             : 
     145             :     // IColumnFactory
     146             :     virtual OColumn*    createColumn(const OUString& _rName) const SAL_OVERRIDE;
     147             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createColumnDescriptor() SAL_OVERRIDE;
     148             :     virtual void columnAppended( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSourceDescriptor ) SAL_OVERRIDE;
     149             :     virtual void columnDropped(const OUString& _sName) SAL_OVERRIDE;
     150         546 :     virtual void notifyDataSourceModified() SAL_OVERRIDE { OContentHelper::notifyDataSourceModified(); }
     151             : 
     152             : protected:
     153             : // OPropertyArrayUsageHelper
     154             :     virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
     155             : 
     156             :     virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
     157             :                                     sal_Int32 nHandle,
     158             :                                     const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
     159             : 
     160             :     // OContentHelper overridables
     161             :     virtual OUString determineContentType() const SAL_OVERRIDE;
     162             : 
     163             : private:
     164             :     void registerProperties();
     165             : };
     166             : 
     167             : }   // namespace dbaccess
     168             : 
     169             : #endif // INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_COMPONENTDEFINITION_HXX
     170             : 
     171             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11