LCOV - code coverage report
Current view: top level - UnoControls/source/controls - OConnectionPointContainerHelper.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 34 0.0 %
Date: 2014-04-11 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 "OConnectionPointContainerHelper.hxx"
      21             : 
      22             : #include "OConnectionPointHelper.hxx"
      23             : 
      24             : //  namespaces
      25             : 
      26             : using namespace ::rtl;
      27             : using namespace ::osl;
      28             : using namespace ::cppu;
      29             : using namespace ::com::sun::star::uno;
      30             : using namespace ::com::sun::star::lang;
      31             : 
      32             : namespace unocontrols{
      33             : 
      34             : //  construct/destruct
      35             : 
      36           0 : OConnectionPointContainerHelper::OConnectionPointContainerHelper( Mutex& aMutex )
      37             :     : m_aSharedMutex        ( aMutex    )
      38           0 :     , m_aMultiTypeContainer ( aMutex    )
      39             : {
      40           0 : }
      41             : 
      42           0 : OConnectionPointContainerHelper::~OConnectionPointContainerHelper()
      43             : {
      44           0 : }
      45             : 
      46             : //  XInterface
      47             : 
      48           0 : Any SAL_CALL OConnectionPointContainerHelper::queryInterface( const Type& aType ) throw( RuntimeException, std::exception )
      49             : {
      50             :     // Attention:
      51             :     //  Don't use mutex or guard in this method!!! Is a method of XInterface.
      52             : 
      53             :     // Ask for my own supported interfaces ...
      54             :     Any aReturn ( ::cppu::queryInterface(   aType                                               ,
      55             :                                                static_cast< XConnectionPointContainer*  > ( this )
      56             :                                         )
      57           0 :                 );
      58             : 
      59             :     // If searched interface not supported by this class ...
      60           0 :     if ( !aReturn.hasValue() )
      61             :     {
      62             :         // ... ask baseclasses.
      63           0 :         aReturn = OWeakObject::queryInterface( aType );
      64             :     }
      65             : 
      66           0 :     return aReturn;
      67             : }
      68             : 
      69             : //  XInterface
      70             : 
      71           0 : void SAL_CALL OConnectionPointContainerHelper::acquire() throw()
      72             : {
      73             :     // Attention:
      74             :     //  Don't use mutex or guard in this method!!! Is a method of XInterface.
      75             : 
      76             :     // Forward to baseclass
      77           0 :     OWeakObject::acquire();
      78           0 : }
      79             : 
      80             : //  XInterface
      81             : 
      82           0 : void SAL_CALL OConnectionPointContainerHelper::release() throw()
      83             : {
      84             :     // Attention:
      85             :     //  Don't use mutex or guard in this method!!! Is a method of XInterface.
      86             : 
      87             :     // Forward to baseclass
      88           0 :     OWeakObject::release();
      89           0 : }
      90             : 
      91             : //  XConnectionPointContainer
      92             : 
      93           0 : Sequence< Type > SAL_CALL OConnectionPointContainerHelper::getConnectionPointTypes() throw( RuntimeException, std::exception )
      94             : {
      95             :     // Container is threadsafe himself !
      96           0 :     return m_aMultiTypeContainer.getContainedTypes();
      97             : }
      98             : 
      99             : //  XConnectionPointContainer
     100             : 
     101           0 : Reference< XConnectionPoint > SAL_CALL OConnectionPointContainerHelper::queryConnectionPoint( const Type& aType ) throw( RuntimeException, std::exception )
     102             : {
     103             :     // Set default return value, if method failed.
     104           0 :     Reference< XConnectionPoint > xConnectionPoint;
     105             : 
     106             :     // Get all elements of the container, which have the searched type.
     107           0 :     OInterfaceContainerHelper* pSpecialContainer = m_aMultiTypeContainer.getContainer( aType );
     108           0 :     if ( pSpecialContainer && pSpecialContainer->getLength() > 0 )
     109             :     {
     110             :         // Ready for multithreading
     111           0 :         MutexGuard aGuard( m_aSharedMutex );
     112             :         // If this container contains elements, build a connectionpoint-instance.
     113           0 :         OConnectionPointHelper* pNewConnectionPoint = new OConnectionPointHelper( m_aSharedMutex, this, aType );
     114           0 :         xConnectionPoint = Reference< XConnectionPoint >( (OWeakObject*)pNewConnectionPoint, UNO_QUERY );
     115             :     }
     116             : 
     117           0 :     return xConnectionPoint;
     118             : }
     119             : 
     120             : //  XConnectionPointContainer
     121             : 
     122           0 : void SAL_CALL OConnectionPointContainerHelper::advise(  const   Type&                       aType       ,
     123             :                                                         const   Reference< XInterface >&    xListener   ) throw( RuntimeException, std::exception )
     124             : {
     125             :     // Container is threadsafe himself !
     126           0 :     m_aMultiTypeContainer.addInterface( aType, xListener );
     127           0 : }
     128             : 
     129             : //  XConnectionPointContainer
     130             : 
     131           0 : void SAL_CALL OConnectionPointContainerHelper::unadvise(    const   Type&                       aType       ,
     132             :                                                             const   Reference< XInterface >&    xListener   ) throw( RuntimeException, std::exception )
     133             : {
     134             :     // Container is threadsafe himself !
     135           0 :     m_aMultiTypeContainer.removeInterface( aType, xListener );
     136           0 : }
     137             : 
     138             : //  public but impl method!
     139             : //  Is necessary to get container member at OConnectionPoint-instance.
     140             : 
     141           0 : OMultiTypeInterfaceContainerHelper& OConnectionPointContainerHelper::impl_getMultiTypeContainer()
     142             : {
     143             :     // Impl methods are not threadsafe!
     144             :     // "Parent" function must do this.
     145           0 :     return m_aMultiTypeContainer;
     146             : }
     147             : 
     148             : }   // namespace unocontrols
     149             : 
     150             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10