LCOV - code coverage report
Current view: top level - connectivity/source/sdbcx - VDescriptor.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 47 0.0 %
Date: 2014-04-14 Functions: 0 11 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             :  * 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 <connectivity/sdbcx/VDescriptor.hxx>
      21             : #include <cppuhelper/queryinterface.hxx>
      22             : 
      23             : #include <functional>
      24             : #include <algorithm>
      25             : #include <string.h>
      26             : 
      27             : namespace connectivity
      28             : {
      29             :     namespace sdbcx
      30             :     {
      31             :         using namespace ::com::sun::star::uno;
      32             :         using namespace ::com::sun::star::lang;
      33             :         using namespace ::com::sun::star::beans;
      34             : 
      35             : 
      36             :         // = ODescriptor
      37             : 
      38             : 
      39           0 :         ODescriptor::ODescriptor(::cppu::OBroadcastHelper& _rBHelper, bool _bCase, bool _bNew)
      40             :             :ODescriptor_PBASE(_rBHelper)
      41             :             ,m_aCase(_bCase)
      42           0 :             ,m_bNew(_bNew)
      43             :         {
      44           0 :         }
      45             : 
      46             : 
      47             :         // com::sun::star::lang::XUnoTunnel
      48           0 :         sal_Int64 SAL_CALL ODescriptor::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException, std::exception)
      49             :         {
      50           0 :             return (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(),  rId.getConstArray(), 16 ) )
      51             :                 ? reinterpret_cast< sal_Int64 >( this )
      52           0 :                 : 0;
      53             :         }
      54             : 
      55             : 
      56           0 :         ODescriptor* ODescriptor::getImplementation( const Reference< XInterface >& _rxSomeComp )
      57             :         {
      58           0 :             Reference< XUnoTunnel > xTunnel( _rxSomeComp, UNO_QUERY );
      59           0 :             if ( xTunnel.is() )
      60           0 :                 return reinterpret_cast< ODescriptor* >( xTunnel->getSomething( getUnoTunnelImplementationId() ) );
      61           0 :             return NULL;
      62             :         }
      63             : 
      64             : 
      65             :         namespace
      66             :         {
      67             :             struct ResetROAttribute : public ::std::unary_function< Property, void >
      68             :             {
      69           0 :                 void operator ()( Property& _rProperty ) const
      70             :                 {
      71           0 :                     _rProperty.Attributes &= ~PropertyAttribute::READONLY;
      72           0 :                 }
      73             :             };
      74             :             struct SetROAttribute : public ::std::unary_function< Property, void >
      75             :             {
      76           0 :                 void operator ()( Property& _rProperty ) const
      77             :                 {
      78           0 :                     _rProperty.Attributes |= PropertyAttribute::READONLY;
      79           0 :                 }
      80             :             };
      81             :         }
      82             : 
      83             : 
      84           0 :         ::cppu::IPropertyArrayHelper* ODescriptor::doCreateArrayHelper() const
      85             :         {
      86           0 :             Sequence< Property > aProperties;
      87           0 :             describeProperties( aProperties );
      88             : 
      89           0 :             if ( isNew() )
      90           0 :                 ::std::for_each( aProperties.getArray(), aProperties.getArray() + aProperties.getLength(), ResetROAttribute() );
      91             :             else
      92           0 :                 ::std::for_each( aProperties.getArray(), aProperties.getArray() + aProperties.getLength(), SetROAttribute() );
      93             : 
      94           0 :             return new ::cppu::OPropertyArrayHelper( aProperties );
      95             :         }
      96             : 
      97             : 
      98           0 :         bool ODescriptor::isNew( const Reference< XInterface >& _rxDescriptor )
      99             :         {
     100           0 :             ODescriptor* pImplementation = getImplementation( _rxDescriptor );
     101           0 :             return pImplementation && pImplementation->isNew();
     102             :         }
     103             : 
     104             : 
     105           0 :         Sequence< sal_Int8 > ODescriptor::getUnoTunnelImplementationId()
     106             :         {
     107             :             static ::cppu::OImplementationId * pId = 0;
     108           0 :             if (! pId)
     109             :             {
     110           0 :                 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     111           0 :                 if (! pId)
     112             :                 {
     113           0 :                     static ::cppu::OImplementationId aId;
     114           0 :                     pId = &aId;
     115           0 :                 }
     116             :             }
     117           0 :             return pId->getImplementationId();
     118             :         }
     119             : 
     120             : 
     121           0 :         Any SAL_CALL ODescriptor::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
     122             :         {
     123           0 :             Any aRet = ::cppu::queryInterface(rType,static_cast< XUnoTunnel*> (this));
     124           0 :             return aRet.hasValue() ? aRet : ODescriptor_PBASE::queryInterface(rType);
     125             :         }
     126             : 
     127             : 
     128           0 :         void ODescriptor::setNew(bool _bNew)
     129             :         {
     130           0 :             m_bNew = _bNew;
     131           0 :         }
     132             : 
     133             : 
     134           0 :         Sequence< Type > SAL_CALL ODescriptor::getTypes(  ) throw(RuntimeException, std::exception)
     135             :         {
     136           0 :             ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
     137           0 :                                             ::getCppuType( (const Reference< XFastPropertySet > *)0 ),
     138           0 :                                             ::getCppuType( (const Reference< XPropertySet > *)0 ),
     139           0 :                                             ::getCppuType( (const Reference< XUnoTunnel > *)0 ));
     140           0 :             return aTypes.getTypes();
     141             :         }
     142             : 
     143             :     }
     144             : }
     145             : 
     146             : 
     147             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10