LCOV - code coverage report
Current view: top level - connectivity/source/drivers/postgresql - pq_xbase.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 74 0.0 %
Date: 2014-04-14 Functions: 0 16 0.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             :  *
       4             :  *  Effective License of whole file:
       5             :  *
       6             :  *    This library is free software; you can redistribute it and/or
       7             :  *    modify it under the terms of the GNU Lesser General Public
       8             :  *    License version 2.1, as published by the Free Software Foundation.
       9             :  *
      10             :  *    This library is distributed in the hope that it will be useful,
      11             :  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13             :  *    Lesser General Public License for more details.
      14             :  *
      15             :  *    You should have received a copy of the GNU Lesser General Public
      16             :  *    License along with this library; if not, write to the Free Software
      17             :  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      18             :  *    MA  02111-1307  USA
      19             :  *
      20             :  *  Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
      21             :  *
      22             :  *    The Contents of this file are made available subject to the terms of
      23             :  *    the GNU Lesser General Public License Version 2.1
      24             :  *
      25             :  *    Copyright: 2000 by Sun Microsystems, Inc.
      26             :  *
      27             :  *    Contributor(s): Joerg Budischewski
      28             :  *
      29             :  *  All parts contributed on or after August 2011:
      30             :  *
      31             :  *    This Source Code Form is subject to the terms of the Mozilla Public
      32             :  *    License, v. 2.0. If a copy of the MPL was not distributed with this
      33             :  *    file, You can obtain one at http://mozilla.org/MPL/2.0/.
      34             :  *
      35             :  ************************************************************************/
      36             : 
      37             : #include <rtl/ustrbuf.hxx>
      38             : #include <cppuhelper/supportsservice.hxx>
      39             : #include <cppuhelper/typeprovider.hxx>
      40             : 
      41             : #include "pq_tools.hxx"
      42             : #include "pq_xbase.hxx"
      43             : 
      44             : using osl::MutexGuard;
      45             : 
      46             : using com::sun::star::uno::Any;
      47             : using com::sun::star::uno::Sequence;
      48             : using com::sun::star::uno::Reference;
      49             : using com::sun::star::uno::RuntimeException;
      50             : 
      51             : using com::sun::star::beans::Property;
      52             : using com::sun::star::beans::XPropertySetInfo;
      53             : using com::sun::star::beans::XMultiPropertySet;
      54             : using com::sun::star::beans::XFastPropertySet;
      55             : using com::sun::star::beans::XPropertySet;
      56             : 
      57             : namespace pq_sdbc_driver
      58             : {
      59             : 
      60           0 : ReflectionBase::ReflectionBase(
      61             :     const OUString &implName,
      62             :     const ::com::sun::star::uno::Sequence< OUString > &supportedServices,
      63             :     const ::rtl::Reference< RefCountedMutex > refMutex,
      64             :     const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > &conn,
      65             :     ConnectionSettings *pSettings,
      66             :     cppu::IPropertyArrayHelper & props /* must survive this object !*/ )
      67           0 :     : OComponentHelper( refMutex->mutex ),
      68             :       OPropertySetHelper( OComponentHelper::rBHelper ),
      69             :       m_implName( implName ),
      70             :       m_supportedServices( supportedServices ),
      71             :       m_refMutex( refMutex ),
      72             :       m_conn( conn ),
      73             :       m_pSettings( pSettings ),
      74             :       m_propsDesc( props ),
      75           0 :       m_values( props.getProperties().getLength() )
      76           0 : {}
      77             : 
      78           0 : cppu::IPropertyArrayHelper & ReflectionBase::getInfoHelper()
      79             : {
      80           0 :     return m_propsDesc;
      81             : }
      82             : 
      83           0 : sal_Bool ReflectionBase::convertFastPropertyValue(
      84             :     ::com::sun::star::uno::Any & rConvertedValue,
      85             :     ::com::sun::star::uno::Any & rOldValue,
      86             :     sal_Int32 nHandle,
      87             :     const ::com::sun::star::uno::Any& rValue )
      88             :     throw (::com::sun::star::lang::IllegalArgumentException)
      89             : {
      90             : 
      91           0 :     rOldValue = m_values[nHandle];
      92           0 :     rConvertedValue = rValue;     // TODO !!! implement correct conversion !
      93           0 :     m_values[nHandle] = rValue;
      94           0 :     return sal_True;
      95             : }
      96             : 
      97           0 : void ReflectionBase::setPropertyValue_NoBroadcast_public(
      98             :     const OUString & name, const com::sun::star::uno::Any & value )
      99             : {
     100           0 :     sal_Int32 nHandle = m_propsDesc.getHandleByName( name );
     101           0 :     if( -1 == nHandle  )
     102             :     {
     103           0 :         OUStringBuffer buf(128);
     104           0 :         buf.appendAscii( "Unknown property '" );
     105           0 :         buf.append( name );
     106           0 :         buf.appendAscii( "' in " );
     107           0 :         buf.append( m_implName );
     108           0 :         throw com::sun::star::uno::RuntimeException( buf.makeStringAndClear() , *this );
     109             :     }
     110           0 :     setFastPropertyValue_NoBroadcast( nHandle , value );
     111           0 : }
     112             : 
     113           0 : void ReflectionBase::setFastPropertyValue_NoBroadcast(
     114             :     sal_Int32 nHandle,
     115             :     const ::com::sun::star::uno::Any& rValue )
     116             :     throw (::com::sun::star::uno::Exception, std::exception)
     117             : {
     118             : //     OUString s;
     119             : //     rValue >>= s;
     120             : //     printf( "setting value (handle %d):%s\n" ,
     121             : //             nHandle, OUStringToOString(s, RTL_TEXTENCODING_ASCII_US).getStr() );
     122           0 :     m_values[nHandle] = rValue;
     123           0 : }
     124             : 
     125           0 : void ReflectionBase::getFastPropertyValue(
     126             :     ::com::sun::star::uno::Any& rValue,
     127             :     sal_Int32 nHandle ) const
     128             : {
     129           0 :     rValue = m_values[nHandle];
     130             : //     OUString s;
     131             : //     rValue >>= s;
     132             : //     printf( "getting value (handle %d):%s\n" ,
     133             : //             nHandle, OUStringToOString(s, RTL_TEXTENCODING_ASCII_US).getStr() );
     134             : 
     135           0 : }
     136             : 
     137           0 : Reference < ::com::sun::star::beans::XPropertySetInfo >  ReflectionBase::getPropertySetInfo()
     138             :         throw(com::sun::star::uno::RuntimeException, std::exception)
     139             : {
     140           0 :     return OPropertySetHelper::createPropertySetInfo( m_propsDesc );
     141             : }
     142             : 
     143           0 : OUString ReflectionBase::getImplementationName()
     144             :         throw(::com::sun::star::uno::RuntimeException, std::exception)
     145             : {
     146           0 :     return m_implName;
     147             : }
     148             : 
     149           0 : sal_Bool ReflectionBase::supportsService(const OUString& ServiceName)
     150             :         throw(::com::sun::star::uno::RuntimeException, std::exception)
     151             : {
     152           0 :     return cppu::supportsService(this, ServiceName);
     153             : }
     154             : 
     155           0 : Sequence< OUString > ReflectionBase::getSupportedServiceNames(void)
     156             :         throw(::com::sun::star::uno::RuntimeException, std::exception)
     157             : {
     158           0 :     return m_supportedServices;
     159             : }
     160             : 
     161             : 
     162           0 : Sequence< com::sun::star::uno::Type > ReflectionBase::getTypes()
     163             :         throw( com::sun::star::uno::RuntimeException, std::exception )
     164             : {
     165           0 :     osl::MutexGuard guard( m_refMutex->mutex );
     166             :     static cppu::OTypeCollection collection(
     167           0 :         getCppuType( (Reference< XPropertySet >*) 0 ),
     168           0 :         getCppuType( (Reference< XFastPropertySet > *) 0 ),
     169           0 :         getCppuType( (Reference< XMultiPropertySet > *) 0 ),
     170           0 :         getCppuType( (Reference< com::sun::star::lang::XServiceInfo > *) 0 ),
     171           0 :         getCppuType( (Reference< com::sun::star::sdbcx::XDataDescriptorFactory > *) 0 ),
     172           0 :         getCppuType( (Reference< com::sun::star::container::XNamed > *) 0 ),
     173           0 :         OComponentHelper::getTypes());
     174           0 :     return collection.getTypes();
     175             : }
     176             : 
     177             : 
     178           0 : com::sun::star::uno::Any ReflectionBase::queryInterface(
     179             :     const com::sun::star::uno::Type & reqType )
     180             :     throw (com::sun::star::uno::RuntimeException, std::exception)
     181             : {
     182           0 :     Any ret;
     183           0 :     ret = OComponentHelper::queryInterface( reqType );
     184           0 :     if( ! ret.hasValue() )
     185           0 :         ret = ::cppu::queryInterface(
     186             :             reqType,
     187             :             static_cast< com::sun::star::beans::XPropertySet * > ( this ),
     188             :             static_cast< com::sun::star::beans::XMultiPropertySet * > ( this ),
     189             :             static_cast< com::sun::star::lang::XServiceInfo * > ( this ),
     190             :             static_cast< com::sun::star::beans::XFastPropertySet * > ( this ) ,
     191             :             static_cast< com::sun::star::sdbcx::XDataDescriptorFactory * > ( this ),
     192           0 :             static_cast< com::sun::star::container::XNamed * > ( this ) );
     193           0 :     return ret;
     194             : 
     195             : }
     196             : 
     197           0 : Sequence< sal_Int8> ReflectionBase::getImplementationId() throw( RuntimeException, std::exception )
     198             : {
     199           0 :     return css::uno::Sequence<sal_Int8>();
     200             : }
     201             : 
     202           0 : void ReflectionBase::copyValuesFrom( const Reference< XPropertySet > & set )
     203             : {
     204           0 :     Reference< XPropertySetInfo > info = set->getPropertySetInfo();
     205           0 :     if( info.is () )
     206             :     {
     207           0 :         Reference< XPropertySetInfo > myPropInfo = getPropertySetInfo();
     208             : 
     209           0 :         Sequence< Property > props = info->getProperties();
     210           0 :         for( int i = 0 ; i < props.getLength() ; i ++ )
     211             :         {
     212           0 :             if( myPropInfo->hasPropertyByName( props[i].Name ) )
     213             :                 setPropertyValue_NoBroadcast_public(
     214           0 :                     props[i].Name, set->getPropertyValue( props[i].Name ) );
     215           0 :         }
     216           0 :     }
     217           0 : }
     218             : 
     219           0 : OUString ReflectionBase::getName(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     220             : {
     221           0 :     Statics & st = getStatics();
     222           0 :     if( getInfoHelper().hasPropertyByName( st.SCHEMA_NAME ) )
     223             :         return concatQualified(
     224           0 :             extractStringProperty( this, getStatics().SCHEMA_NAME  ),
     225           0 :             extractStringProperty( this, getStatics().NAME  ) );
     226             :     else
     227           0 :         return extractStringProperty( this, getStatics().NAME );
     228             : }
     229             : 
     230             : 
     231           0 : void ReflectionBase::setName( const OUString& /* aName */ )
     232             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     233             : {
     234             :     throw RuntimeException(
     235             :         OUString( "pq_sdbc::ReflectionBase::setName not implemented" ),
     236           0 :         *this );
     237             :     //setPropertyValue( getStatics().NAME , makeAny( aName ) );
     238             : }
     239             : 
     240             : 
     241             : }
     242             : 
     243             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10