LCOV - code coverage report
Current view: top level - libreoffice/vcl/generic/app - gendisp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 67 0.0 %
Date: 2012-12-27 Functions: 0 10 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 <salframe.hxx>
      21             : #include <generic/gendisp.hxx>
      22             : #include <generic/geninst.h>
      23             : 
      24             : using ::rtl::OUString;
      25             : 
      26           0 : SalGenericDisplay::SalGenericDisplay()
      27             : {
      28           0 :     m_pCapture = NULL;
      29           0 :     m_aEventGuard = osl_createMutex();
      30           0 : }
      31             : 
      32           0 : SalGenericDisplay::~SalGenericDisplay()
      33             : {
      34           0 :     if (m_aEventGuard)
      35           0 :         osl_destroyMutex( m_aEventGuard );
      36           0 :     m_aEventGuard = NULL;
      37           0 : }
      38             : 
      39           0 : void SalGenericDisplay::registerFrame( SalFrame* pFrame )
      40             : {
      41           0 :     m_aFrames.push_front( pFrame );
      42           0 : }
      43             : 
      44           0 : void SalGenericDisplay::deregisterFrame( SalFrame* pFrame )
      45             : {
      46           0 :     if( osl_acquireMutex( m_aEventGuard ) )
      47             :     {
      48           0 :         std::list< SalUserEvent >::iterator it = m_aUserEvents.begin();
      49           0 :         while ( it != m_aUserEvents.end() )
      50             :         {
      51           0 :             if( it->m_pFrame == pFrame )
      52           0 :                 it = m_aUserEvents.erase( it );
      53             :             else
      54           0 :                 ++it;
      55             :         }
      56           0 :         osl_releaseMutex( m_aEventGuard );
      57             :     }
      58             :     else
      59             :         OSL_FAIL( "SalGenericDisplay::deregisterFrame !acquireMutex\n" );
      60             : 
      61           0 :     m_aFrames.remove( pFrame );
      62           0 : }
      63             : 
      64           0 : void SalGenericDisplay::emitDisplayChanged()
      65             : {
      66           0 :     if( !m_aFrames.empty() )
      67           0 :         m_aFrames.front()->CallCallback( SALEVENT_DISPLAYCHANGED, 0 );
      68           0 : }
      69             : 
      70           0 : bool SalGenericDisplay::DispatchInternalEvent()
      71             : {
      72           0 :     void* pData = NULL;
      73           0 :     SalFrame* pFrame = NULL;
      74           0 :     sal_uInt16 nEvent = 0;
      75             : 
      76           0 :     if( osl_acquireMutex( m_aEventGuard ) )
      77             :     {
      78           0 :         if( m_aUserEvents.begin() != m_aUserEvents.end() )
      79             :         {
      80           0 :             pFrame      = m_aUserEvents.front().m_pFrame;
      81           0 :             pData       = m_aUserEvents.front().m_pData;
      82           0 :             nEvent      = m_aUserEvents.front().m_nEvent;
      83             : 
      84           0 :             m_aUserEvents.pop_front();
      85             :         }
      86           0 :         osl_releaseMutex( m_aEventGuard );
      87             :     }
      88             :     else
      89             :         OSL_FAIL( "SalGenericDisplay::Yield !acquireMutex\n" );
      90             : 
      91           0 :     if( pFrame )
      92           0 :         pFrame->CallCallback( nEvent, pData );
      93             : 
      94           0 :     return pFrame != NULL;
      95             : }
      96             : 
      97           0 : void SalGenericDisplay::SendInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent )
      98             : {
      99           0 :     if( osl_acquireMutex( m_aEventGuard ) )
     100             :     {
     101           0 :         m_aUserEvents.push_back( SalUserEvent( pFrame, pData, nEvent ) );
     102             : 
     103           0 :         PostUserEvent(); // wakeup the concrete mainloop
     104             : 
     105           0 :         osl_releaseMutex( m_aEventGuard );
     106             :     }
     107             :     else
     108             :         OSL_FAIL( "SalGenericDisplay::SendInternalEvent !acquireMutex\n" );
     109           0 : }
     110             : 
     111           0 : void SalGenericDisplay::CancelInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent )
     112             : {
     113           0 :     if( osl_acquireMutex( m_aEventGuard ) )
     114             :     {
     115           0 :         if( ! m_aUserEvents.empty() )
     116             :         {
     117           0 :             std::list< SalUserEvent >::iterator it, next;
     118           0 :             next = m_aUserEvents.begin();
     119           0 :             do
     120             :             {
     121           0 :                 it = next++;
     122           0 :                 if( it->m_pFrame    == pFrame   &&
     123           0 :                     it->m_pData     == pData    &&
     124           0 :                     it->m_nEvent    == nEvent )
     125             :                 {
     126           0 :                     m_aUserEvents.erase( it );
     127             :                 }
     128           0 :             } while( next != m_aUserEvents.end() );
     129             :         }
     130             : 
     131           0 :         osl_releaseMutex( m_aEventGuard );
     132             :     }
     133             :     else
     134             :         OSL_FAIL( "SalGenericDisplay::CancelInternalEvent !acquireMutex\n" );
     135           0 : }
     136             : 
     137           0 : bool SalGenericDisplay::HasUserEvents() const
     138             : {
     139           0 :     bool bRet = false;
     140           0 :     if( osl_acquireMutex( m_aEventGuard ) )
     141             :     {
     142           0 :         if( m_aUserEvents.begin() != m_aUserEvents.end() )
     143           0 :             bRet = true;
     144           0 :         osl_releaseMutex( m_aEventGuard );
     145             :     }
     146           0 :     return bRet;
     147             : }
     148             : 
     149             : 
     150             : 
     151             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10