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

Generated by: LCOV version 1.10