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

Generated by: LCOV version 1.10