LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/core/dataaccess - dataaccessdescriptor.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 11 73 15.1 %
Date: 2012-12-27 Functions: 4 26 15.4 %
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             : 
      21             : #include "dbastrings.hrc"
      22             : #include "module_dba.hxx"
      23             : 
      24             : #include <com/sun/star/lang/XServiceInfo.hpp>
      25             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      26             : #include <com/sun/star/sdb/CommandType.hpp>
      27             : #include <com/sun/star/sdbc/XConnection.hpp>
      28             : #include <com/sun/star/sdbc/XResultSet.hpp>
      29             : #include <com/sun/star/sdb/XDataAccessDescriptorFactory.hpp>
      30             : 
      31             : #include <comphelper/broadcasthelper.hxx>
      32             : #include <comphelper/componentcontext.hxx>
      33             : #include <comphelper/proparrhlp.hxx>
      34             : #include <comphelper/propertycontainer.hxx>
      35             : #include <comphelper/uno3.hxx>
      36             : #include <cppuhelper/implbase1.hxx>
      37             : #include <cppuhelper/implbase2.hxx>
      38             : 
      39             : //........................................................................
      40             : namespace dbaccess
      41             : {
      42             : //........................................................................
      43             : 
      44             :     /** === begin UNO using === **/
      45             :     using ::com::sun::star::uno::Reference;
      46             :     using ::com::sun::star::uno::XInterface;
      47             :     using ::com::sun::star::uno::UNO_QUERY;
      48             :     using ::com::sun::star::uno::UNO_QUERY_THROW;
      49             :     using ::com::sun::star::uno::UNO_SET_THROW;
      50             :     using ::com::sun::star::uno::Exception;
      51             :     using ::com::sun::star::uno::RuntimeException;
      52             :     using ::com::sun::star::uno::Any;
      53             :     using ::com::sun::star::uno::makeAny;
      54             :     using ::com::sun::star::uno::Sequence;
      55             :     using ::com::sun::star::lang::XServiceInfo;
      56             :     using ::com::sun::star::lang::XMultiServiceFactory;
      57             :     using ::com::sun::star::beans::XPropertySetInfo;
      58             :     using ::com::sun::star::beans::Property;
      59             :     using ::com::sun::star::sdbc::XConnection;
      60             :     using ::com::sun::star::sdbc::XResultSet;
      61             :     using ::com::sun::star::sdb::XDataAccessDescriptorFactory;
      62             :     using ::com::sun::star::beans::XPropertySet;
      63             :     using ::com::sun::star::uno::XComponentContext;
      64             :     using ::com::sun::star::beans::PropertyValue;
      65             :     /** === end UNO using === **/
      66             : 
      67             :     namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
      68             :     namespace CommandType = ::com::sun::star::sdb::CommandType;
      69             : 
      70             :     //====================================================================
      71             :     //= DataAccessDescriptor
      72             :     //====================================================================
      73             :     typedef ::comphelper::OMutexAndBroadcastHelper  DataAccessDescriptor_MutexBase;
      74             : 
      75             :     typedef ::cppu::WeakImplHelper1             <   XServiceInfo
      76             :                                                 >   DataAccessDescriptor_TypeBase;
      77             : 
      78             :     typedef ::comphelper::OPropertyContainer        DataAccessDescriptor_PropertyBase;
      79             : 
      80             :     class DataAccessDescriptor  :public DataAccessDescriptor_MutexBase
      81             :                                 ,public DataAccessDescriptor_TypeBase
      82             :                                 ,public DataAccessDescriptor_PropertyBase
      83             :                                 ,public ::comphelper::OPropertyArrayUsageHelper< DataAccessDescriptor >
      84             :     {
      85             :     public:
      86             :         DataAccessDescriptor( const ::comphelper::ComponentContext& _rContext );
      87             : 
      88             :         // UNO
      89             :         DECLARE_XINTERFACE()
      90             :         DECLARE_XTYPEPROVIDER()
      91             : 
      92             :         // XServiceInfo
      93             :         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (RuntimeException);
      94             :         virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException);
      95             :         virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (RuntimeException);
      96             : 
      97             :     protected:
      98             :         ~DataAccessDescriptor();
      99             : 
     100             :     protected:
     101             :         // XPropertySet
     102             :         virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(RuntimeException);
     103             :         virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
     104             : 
     105             :         // OPropertyArrayUsageHelper
     106             :         virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
     107             : 
     108             :     private:
     109             :         ::comphelper::ComponentContext  m_aContext;
     110             : 
     111             :         // </properties>
     112             :         ::rtl::OUString             m_sDataSourceName;
     113             :         ::rtl::OUString             m_sDatabaseLocation;
     114             :         ::rtl::OUString             m_sConnectionResource;
     115             :         Sequence< PropertyValue >   m_aConnectionInfo;
     116             :         Reference< XConnection >    m_xActiveConnection;
     117             :         ::rtl::OUString             m_sCommand;
     118             :         sal_Int32                   m_nCommandType;
     119             :         ::rtl::OUString             m_sFilter;
     120             :         ::rtl::OUString             m_sOrder;
     121             :         ::rtl::OUString             m_sHavingClause;
     122             :         ::rtl::OUString             m_sGroupBy;
     123             :         sal_Bool                    m_bEscapeProcessing;
     124             :         Reference< XResultSet >     m_xResultSet;
     125             :         Sequence< Any >             m_aSelection;
     126             :         sal_Bool                    m_bBookmarkSelection;
     127             :         ::rtl::OUString             m_sColumnName;
     128             :         Reference< XPropertySet >   m_xColumn;
     129             :         // </properties>
     130             :     };
     131             : 
     132             : #define REGISTER_PROPERTY( propname, member ) \
     133             :     registerProperty( PROPERTY_##propname, PROPERTY_ID_##propname, PropertyAttribute::BOUND, &member, ::getCppuType( &member ) )
     134             : 
     135           0 :     DataAccessDescriptor::DataAccessDescriptor( const ::comphelper::ComponentContext& _rContext )
     136             :         :DataAccessDescriptor_MutexBase()
     137             :         ,DataAccessDescriptor_TypeBase()
     138             :         ,DataAccessDescriptor_PropertyBase( m_aBHelper )
     139             :         ,m_aContext( _rContext )
     140             :         ,m_sDataSourceName()
     141             :         ,m_sDatabaseLocation()
     142             :         ,m_sConnectionResource()
     143             :         ,m_aConnectionInfo()
     144             :         ,m_xActiveConnection()
     145             :         ,m_sCommand()
     146             :         ,m_nCommandType( CommandType::COMMAND )
     147             :         ,m_sFilter()
     148             :         ,m_sOrder()
     149             :         ,m_sHavingClause()
     150             :         ,m_sGroupBy()
     151             :         ,m_bEscapeProcessing( sal_True )
     152             :         ,m_xResultSet()
     153             :         ,m_aSelection()
     154             :         ,m_bBookmarkSelection( sal_True )
     155             :         ,m_sColumnName()
     156           0 :         ,m_xColumn()
     157             :     {
     158           0 :         REGISTER_PROPERTY( DATASOURCENAME,      m_sDataSourceName );
     159           0 :         REGISTER_PROPERTY( DATABASE_LOCATION,   m_sDatabaseLocation );
     160           0 :         REGISTER_PROPERTY( CONNECTION_RESOURCE, m_sConnectionResource );
     161           0 :         REGISTER_PROPERTY( CONNECTION_INFO,     m_aConnectionInfo );
     162           0 :         REGISTER_PROPERTY( ACTIVE_CONNECTION,   m_xActiveConnection );
     163           0 :         REGISTER_PROPERTY( COMMAND,             m_sCommand );
     164           0 :         REGISTER_PROPERTY( COMMAND_TYPE,        m_nCommandType );
     165           0 :         REGISTER_PROPERTY( FILTER,              m_sFilter );
     166           0 :         REGISTER_PROPERTY( ORDER,               m_sOrder );
     167           0 :         REGISTER_PROPERTY( HAVING_CLAUSE,       m_sHavingClause );
     168           0 :         REGISTER_PROPERTY( GROUP_BY,            m_sGroupBy );
     169           0 :         REGISTER_PROPERTY( ESCAPE_PROCESSING,   m_bEscapeProcessing );
     170           0 :         REGISTER_PROPERTY( RESULT_SET,          m_xResultSet );
     171           0 :         REGISTER_PROPERTY( SELECTION,           m_aSelection );
     172           0 :         REGISTER_PROPERTY( BOOKMARK_SELECTION,  m_bBookmarkSelection );
     173           0 :         REGISTER_PROPERTY( COLUMN_NAME,         m_sColumnName );
     174           0 :         REGISTER_PROPERTY( COLUMN,              m_xColumn );
     175           0 :     }
     176             : 
     177           0 :     DataAccessDescriptor::~DataAccessDescriptor()
     178             :     {
     179           0 :     }
     180             : 
     181           0 :     IMPLEMENT_FORWARD_XINTERFACE2( DataAccessDescriptor, DataAccessDescriptor_TypeBase, DataAccessDescriptor_PropertyBase );
     182             : 
     183           0 :     IMPLEMENT_FORWARD_XTYPEPROVIDER2( DataAccessDescriptor, DataAccessDescriptor_TypeBase, DataAccessDescriptor_PropertyBase );
     184             : 
     185           0 :     ::rtl::OUString SAL_CALL DataAccessDescriptor::getImplementationName() throw (RuntimeException)
     186             :     {
     187           0 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.dba.DataAccessDescriptor" ) );
     188             :     }
     189             : 
     190           0 :     ::sal_Bool SAL_CALL DataAccessDescriptor::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
     191             :     {
     192           0 :         Sequence< ::rtl::OUString > aServices( getSupportedServiceNames() );
     193           0 :         const ::rtl::OUString* pStart = aServices.getConstArray();
     194           0 :         const ::rtl::OUString* pEnd = aServices.getConstArray() + aServices.getLength();
     195           0 :         return ::std::find( pStart, pEnd, rServiceName ) != pEnd;
     196             :     }
     197             : 
     198           0 :     Sequence< ::rtl::OUString > SAL_CALL DataAccessDescriptor::getSupportedServiceNames(  ) throw (RuntimeException)
     199             :     {
     200           0 :         Sequence< ::rtl::OUString > aServices(1);
     201           0 :         aServices[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.DataAccessDescriptor" ) );
     202           0 :         return aServices;
     203             :     }
     204             : 
     205           0 :     Reference< XPropertySetInfo > SAL_CALL DataAccessDescriptor::getPropertySetInfo() throw(RuntimeException)
     206             :     {
     207           0 :         Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
     208           0 :         return xInfo;
     209             :     }
     210             : 
     211           0 :     ::cppu::IPropertyArrayHelper& DataAccessDescriptor::getInfoHelper()
     212             :     {
     213           0 :         return *getArrayHelper();
     214             :     }
     215             : 
     216           0 :     ::cppu::IPropertyArrayHelper* DataAccessDescriptor::createArrayHelper( ) const
     217             :     {
     218           0 :         Sequence< Property > aProps;
     219           0 :         describeProperties( aProps );
     220           0 :         return new ::cppu::OPropertyArrayHelper( aProps );
     221             :     }
     222             : 
     223             :     //====================================================================
     224             :     //= DataAccessDescriptorFactory
     225             :     //====================================================================
     226             :     typedef ::cppu::WeakImplHelper2 <   XServiceInfo
     227             :                                     ,   XDataAccessDescriptorFactory
     228             :                                     >   DataAccessDescriptorFactory_Base;
     229             :     class DataAccessDescriptorFactory : public DataAccessDescriptorFactory_Base
     230             :     {
     231             :     public:
     232             :         // XServiceInfo
     233             :         virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (RuntimeException);
     234             :         virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException);
     235             :         virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (RuntimeException);
     236             : 
     237             :         // XServiceInfo - static versions
     238             :         static Sequence< ::rtl::OUString >  getSupportedServiceNames_static(void) throw( RuntimeException );
     239             :         static ::rtl::OUString              getImplementationName_static(void) throw( RuntimeException );
     240             :         static Reference< XInterface >      Create(const Reference< XComponentContext >& _rxContext);
     241             :         static ::rtl::OUString              getSingletonName_static();
     242             : 
     243             :         // XDataAccessDescriptorFactory
     244             :         virtual Reference< XPropertySet > SAL_CALL createDataAccessDescriptor(  ) throw (RuntimeException);
     245             : 
     246             :     protected:
     247             :         DataAccessDescriptorFactory( const Reference< XComponentContext >& _rxContext );
     248             :         ~DataAccessDescriptorFactory();
     249             : 
     250             :     private:
     251             :         ::comphelper::ComponentContext  m_aContext;
     252             :     };
     253             : 
     254           0 :     DataAccessDescriptorFactory::DataAccessDescriptorFactory( const Reference< XComponentContext >& _rxContext )
     255           0 :         :m_aContext( _rxContext )
     256             :     {
     257           0 :     }
     258             : 
     259           0 :     DataAccessDescriptorFactory::~DataAccessDescriptorFactory()
     260             :     {
     261           0 :     }
     262             : 
     263           6 :     ::rtl::OUString DataAccessDescriptorFactory::getSingletonName_static()
     264             :     {
     265           6 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.DataAccessDescriptorFactory" ) );
     266             :     }
     267             : 
     268           3 :     Sequence< ::rtl::OUString > DataAccessDescriptorFactory::getSupportedServiceNames_static() throw( RuntimeException )
     269             :     {
     270           3 :         Sequence< ::rtl::OUString > aServices(1);
     271           3 :         aServices[0] = getSingletonName_static();
     272           3 :         return aServices;
     273             :     }
     274             : 
     275           3 :     ::rtl::OUString DataAccessDescriptorFactory::getImplementationName_static() throw( RuntimeException )
     276             :     {
     277           3 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.dba.DataAccessDescriptorFactory" ) );
     278             :     }
     279             : 
     280           0 :     Reference< XInterface > DataAccessDescriptorFactory::Create( const Reference< XComponentContext >& _rxContext )
     281             :     {
     282           0 :         return *( new DataAccessDescriptorFactory( _rxContext ) );
     283             :     }
     284             : 
     285           0 :     ::rtl::OUString SAL_CALL DataAccessDescriptorFactory::getImplementationName() throw (RuntimeException)
     286             :     {
     287           0 :         return getImplementationName_static();
     288             :     }
     289             : 
     290           0 :     ::sal_Bool SAL_CALL DataAccessDescriptorFactory::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
     291             :     {
     292           0 :         Sequence< ::rtl::OUString > aServices( getSupportedServiceNames_static() );
     293           0 :         const ::rtl::OUString* pStart = aServices.getConstArray();
     294           0 :         const ::rtl::OUString* pEnd = aServices.getConstArray() + aServices.getLength();
     295           0 :         return ::std::find( pStart, pEnd, rServiceName ) != pEnd;
     296             :     }
     297             : 
     298           0 :     Sequence< ::rtl::OUString > SAL_CALL DataAccessDescriptorFactory::getSupportedServiceNames(  ) throw (RuntimeException)
     299             :     {
     300           0 :         return getSupportedServiceNames_static();
     301             :     }
     302             : 
     303           0 :     Reference< XPropertySet > SAL_CALL DataAccessDescriptorFactory::createDataAccessDescriptor(  ) throw (RuntimeException)
     304             :     {
     305           0 :         return new DataAccessDescriptor( m_aContext );
     306             :     }
     307             : 
     308             : } // namespace dbaccess
     309             : 
     310           3 : extern "C" void SAL_CALL createRegistryInfo_DataAccessDescriptorFactory()
     311             : {
     312           3 :     static ::dba::OSingletonRegistration< ::dbaccess::DataAccessDescriptorFactory > aAutoRegistration;
     313           3 : }
     314             : 
     315             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10