LCOV - code coverage report
Current view: top level - dbaccess/source/core/misc - apitools.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 37 0.0 %
Date: 2014-04-14 Functions: 0 7 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 "apitools.hxx"
      21             : #include "dbastrings.hrc"
      22             : #include <cppuhelper/typeprovider.hxx>
      23             : #include <com/sun/star/lang/XServiceInfo.hpp>
      24             : #include <osl/diagnose.h>
      25             : #include <tools/debug.hxx>
      26             : 
      27             : using namespace ::com::sun::star::uno;
      28             : using namespace ::com::sun::star::lang;
      29             : using namespace cppu;
      30             : using namespace osl;
      31             : 
      32             : // various helper functions
      33             : // OSubComponent
      34           0 : OSubComponent::OSubComponent(Mutex& _rMutex, const Reference< XInterface > & xParent)
      35             :               :OComponentHelper(_rMutex)
      36           0 :               ,m_xParent(xParent)
      37             : {
      38             : 
      39           0 : }
      40             : 
      41           0 : OSubComponent::~OSubComponent()
      42             : {
      43           0 :     m_xParent = NULL;
      44             : 
      45           0 : }
      46             : 
      47             : // com::sun::star::lang::XTypeProvider
      48           0 : Sequence< Type > OSubComponent::getTypes() throw (RuntimeException, std::exception)
      49             : {
      50           0 :     OTypeCollection aTypes(::getCppuType( (const Reference< XComponent > *)0 ),
      51           0 :                            ::getCppuType( (const Reference< XTypeProvider > *)0 ),
      52           0 :                            ::getCppuType( (const Reference< XWeak > *)0 ));
      53             : 
      54           0 :     return aTypes.getTypes();
      55             : }
      56             : 
      57             : // XInterface
      58           0 : void OSubComponent::acquire() throw ( )
      59             : {
      60           0 :     OComponentHelper::acquire();
      61           0 : }
      62             : 
      63           0 : void OSubComponent::release() throw ( )
      64             : {
      65           0 :     Reference< XInterface > x( xDelegator );
      66           0 :     if (! x.is())
      67             :     {
      68           0 :         if (osl_atomic_decrement( &m_refCount ) == 0 )
      69             :         {
      70           0 :             if (! rBHelper.bDisposed)
      71             :             {
      72             :                 // *before* again incrementing our ref count, ensure that our weak connection point
      73             :                 // will not create references to us anymore (via XAdapter::queryAdapted)
      74           0 :                 disposeWeakConnectionPoint();
      75             : 
      76           0 :                 Reference< XInterface > xHoldAlive( *this );
      77             :                 // remember the parent
      78           0 :                 Reference< XInterface > xParent;
      79             :                 {
      80           0 :                     MutexGuard aGuard( rBHelper.rMutex );
      81           0 :                     xParent = m_xParent;
      82           0 :                     m_xParent = NULL;
      83             :                 }
      84             : 
      85             :                 OSL_ENSURE( m_refCount == 1, "OSubComponent::release: invalid ref count (before dispose)!" );
      86             : 
      87             :                 // First dispose
      88           0 :                 dispose();
      89             : 
      90             :                 // only the alive ref holds the object
      91             :                 OSL_ENSURE( m_refCount == 1, "OSubComponent::release: invalid ref count (after dispose)!" );
      92             : 
      93             :                 // release the parent in the ~
      94           0 :                 if (xParent.is())
      95             :                 {
      96           0 :                     MutexGuard aGuard( rBHelper.rMutex );
      97           0 :                     m_xParent = xParent;
      98             :                 }
      99             : 
     100             :                 // destroy the object if xHoldAlive decrement the refcount to 0
     101           0 :                 return;
     102             :             }
     103             :         }
     104             :         // restore the reference count
     105           0 :         osl_atomic_increment( &m_refCount );
     106             :     }
     107             : 
     108             :     // as we cover the job of the componenthelper we use the ...
     109           0 :     OWeakAggObject::release();
     110             : }
     111             : 
     112           0 : Any OSubComponent::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
     113             : {
     114           0 :     Any aReturn;
     115           0 :     if (!rType.equals(::getCppuType(static_cast< Reference< XAggregation >* >(NULL))))
     116           0 :         aReturn = OComponentHelper::queryInterface(rType);
     117             : 
     118           0 :     return aReturn;
     119             : }
     120             : 
     121             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10