LCOV - code coverage report
Current view: top level - vcl/source/helper - xconnection.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 29 67 43.3 %
Date: 2015-06-13 12:38:46 Functions: 7 12 58.3 %
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 "vcl/svapp.hxx"
      21             : 
      22             : #include "xconnection.hxx"
      23             : #include "svdata.hxx"
      24             : #include "salinst.hxx"
      25             : 
      26             : using namespace osl;
      27             : using namespace vcl;
      28             : using namespace com::sun::star::uno;
      29             : using namespace com::sun::star::awt;
      30             : 
      31         111 : DisplayConnection::DisplayConnection()
      32             : {
      33             :     SalInstance::ConnectionIdentifierType eType;
      34             :     int nBytes;
      35         111 :     void* pBytes = ImplGetSVData()->mpDefInst->GetConnectionIdentifier( eType, nBytes );
      36         111 :     switch( eType )
      37             :     {
      38             :         case SalInstance::AsciiCString:
      39         111 :             m_aAny <<= OUString::createFromAscii( static_cast<sal_Char*>(pBytes) );
      40         111 :             break;
      41             :         case SalInstance::Blob:
      42           0 :             m_aAny <<= Sequence< sal_Int8 >( static_cast<sal_Int8*>(pBytes), nBytes );
      43           0 :             break;
      44             :     }
      45         111 : }
      46             : 
      47         218 : DisplayConnection::~DisplayConnection()
      48         218 : {}
      49             : 
      50         111 : void DisplayConnection::start()
      51             : {
      52             :     DBG_TESTSOLARMUTEX();
      53         111 :     ImplSVData* pSVData = ImplGetSVData();
      54         111 :     pSVData->mpDefInst->SetEventCallback( this );
      55         111 : }
      56             : 
      57          44 : void DisplayConnection::terminate()
      58             : {
      59             :     DBG_TESTSOLARMUTEX();
      60          44 :     ImplSVData* pSVData = ImplGetSVData();
      61             : 
      62          44 :     if( pSVData )
      63             :     {
      64          44 :         pSVData->mpDefInst->SetEventCallback( NULL );
      65             :     }
      66             : 
      67          44 :     SolarMutexReleaser aRel;
      68             : 
      69          88 :     MutexGuard aGuard( m_aMutex );
      70          88 :     Any aEvent;
      71          88 :     std::list< css::uno::Reference< XEventHandler > > aLocalList( m_aHandlers );
      72          44 :     for( ::std::list< css::uno::Reference< XEventHandler > >::const_iterator it = aLocalList.begin(); it != aLocalList.end(); ++it )
      73          44 :         (*it)->handleEvent( aEvent );
      74          44 : }
      75             : 
      76           2 : void SAL_CALL DisplayConnection::addEventHandler( const Any& /*window*/, const css::uno::Reference< XEventHandler >& handler, sal_Int32 /*eventMask*/ ) throw(std::exception)
      77             : {
      78           2 :     MutexGuard aGuard( m_aMutex );
      79             : 
      80           2 :     m_aHandlers.push_back( handler );
      81           2 : }
      82             : 
      83           0 : void SAL_CALL DisplayConnection::removeEventHandler( const Any& /*window*/, const css::uno::Reference< XEventHandler >& handler ) throw(std::exception)
      84             : {
      85           0 :     MutexGuard aGuard( m_aMutex );
      86             : 
      87           0 :     m_aHandlers.remove( handler );
      88           0 : }
      89             : 
      90           0 : void SAL_CALL DisplayConnection::addErrorHandler( const css::uno::Reference< XEventHandler >& handler ) throw(std::exception)
      91             : {
      92           0 :     MutexGuard aGuard( m_aMutex );
      93             : 
      94           0 :     m_aErrorHandlers.push_back( handler );
      95           0 : }
      96             : 
      97           0 : void SAL_CALL DisplayConnection::removeErrorHandler( const css::uno::Reference< XEventHandler >& handler ) throw(std::exception)
      98             : {
      99           0 :     MutexGuard aGuard( m_aMutex );
     100             : 
     101           0 :     m_aErrorHandlers.remove( handler );
     102           0 : }
     103             : 
     104           2 : Any SAL_CALL DisplayConnection::getIdentifier() throw(std::exception)
     105             : {
     106           2 :     return m_aAny;
     107             : }
     108             : 
     109           0 : bool DisplayConnection::dispatchEvent( void* pData, int nBytes )
     110             : {
     111           0 :     SolarMutexReleaser aRel;
     112             : 
     113           0 :     Sequence< sal_Int8 > aSeq( static_cast<sal_Int8*>(pData), nBytes );
     114           0 :     Any aEvent;
     115           0 :     aEvent <<= aSeq;
     116           0 :     ::std::list< css::uno::Reference< XEventHandler > > handlers;
     117             :     {
     118           0 :         MutexGuard aGuard( m_aMutex );
     119           0 :         handlers = m_aHandlers;
     120             :     }
     121           0 :     for( ::std::list< css::uno::Reference< XEventHandler > >::const_iterator it = handlers.begin(); it != handlers.end(); ++it )
     122           0 :         if( (*it)->handleEvent( aEvent ) )
     123           0 :             return true;
     124           0 :     return false;
     125             : }
     126             : 
     127           0 : bool DisplayConnection::dispatchErrorEvent( void* pData, int nBytes )
     128             : {
     129           0 :     SolarMutexReleaser aRel;
     130             : 
     131           0 :     Sequence< sal_Int8 > aSeq( static_cast<sal_Int8*>(pData), nBytes );
     132           0 :     Any aEvent;
     133           0 :     aEvent <<= aSeq;
     134           0 :     ::std::list< css::uno::Reference< XEventHandler > > handlers;
     135             :     {
     136           0 :         MutexGuard aGuard( m_aMutex );
     137           0 :         handlers = m_aErrorHandlers;
     138             :     }
     139           0 :     for( ::std::list< css::uno::Reference< XEventHandler > >::const_iterator it = handlers.begin(); it != handlers.end(); ++it )
     140           0 :         if( (*it)->handleEvent( aEvent ) )
     141           0 :             return true;
     142             : 
     143           0 :     return false;
     144             : }
     145             : 
     146             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11