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

Generated by: LCOV version 1.10