LCOV - code coverage report
Current view: top level - vcl/generic/app - gendisp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 67 0.0 %
Date: 2012-08-25 Functions: 0 10 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 76 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <salframe.hxx>
      31                 :            : #include <generic/gendisp.hxx>
      32                 :            : #include <generic/geninst.h>
      33                 :            : 
      34                 :            : using ::rtl::OUString;
      35                 :            : 
      36         [ #  # ]:          0 : SalGenericDisplay::SalGenericDisplay()
      37                 :            : {
      38                 :          0 :     m_pCapture = NULL;
      39         [ #  # ]:          0 :     m_aEventGuard = osl_createMutex();
      40                 :          0 : }
      41                 :            : 
      42                 :          0 : SalGenericDisplay::~SalGenericDisplay()
      43                 :            : {
      44         [ #  # ]:          0 :     if (m_aEventGuard)
      45         [ #  # ]:          0 :         osl_destroyMutex( m_aEventGuard );
      46                 :          0 :     m_aEventGuard = NULL;
      47         [ #  # ]:          0 : }
      48                 :            : 
      49                 :          0 : void SalGenericDisplay::registerFrame( SalFrame* pFrame )
      50                 :            : {
      51                 :          0 :     m_aFrames.push_front( pFrame );
      52                 :          0 : }
      53                 :            : 
      54                 :          0 : void SalGenericDisplay::deregisterFrame( SalFrame* pFrame )
      55                 :            : {
      56         [ #  # ]:          0 :     if( osl_acquireMutex( m_aEventGuard ) )
      57                 :            :     {
      58                 :          0 :         std::list< SalUserEvent >::iterator it = m_aUserEvents.begin();
      59 [ #  # ][ #  # ]:          0 :         while ( it != m_aUserEvents.end() )
      60                 :            :         {
      61 [ #  # ][ #  # ]:          0 :             if( it->m_pFrame == pFrame )
      62         [ #  # ]:          0 :                 it = m_aUserEvents.erase( it );
      63                 :            :             else
      64         [ #  # ]:          0 :                 ++it;
      65                 :            :         }
      66         [ #  # ]:          0 :         osl_releaseMutex( m_aEventGuard );
      67                 :            :     }
      68                 :            :     else
      69                 :            :         OSL_FAIL( "SalGenericDisplay::deregisterFrame !acquireMutex\n" );
      70                 :            : 
      71                 :          0 :     m_aFrames.remove( pFrame );
      72                 :          0 : }
      73                 :            : 
      74                 :          0 : void SalGenericDisplay::emitDisplayChanged()
      75                 :            : {
      76         [ #  # ]:          0 :     if( !m_aFrames.empty() )
      77                 :          0 :         m_aFrames.front()->CallCallback( SALEVENT_DISPLAYCHANGED, 0 );
      78                 :          0 : }
      79                 :            : 
      80                 :          0 : bool SalGenericDisplay::DispatchInternalEvent()
      81                 :            : {
      82                 :          0 :     void* pData = NULL;
      83                 :          0 :     SalFrame* pFrame = NULL;
      84                 :          0 :     sal_uInt16 nEvent = 0;
      85                 :            : 
      86         [ #  # ]:          0 :     if( osl_acquireMutex( m_aEventGuard ) )
      87                 :            :     {
      88 [ #  # ][ #  # ]:          0 :         if( m_aUserEvents.begin() != m_aUserEvents.end() )
      89                 :            :         {
      90                 :          0 :             pFrame      = m_aUserEvents.front().m_pFrame;
      91                 :          0 :             pData       = m_aUserEvents.front().m_pData;
      92                 :          0 :             nEvent      = m_aUserEvents.front().m_nEvent;
      93                 :            : 
      94                 :          0 :             m_aUserEvents.pop_front();
      95                 :            :         }
      96                 :          0 :         osl_releaseMutex( m_aEventGuard );
      97                 :            :     }
      98                 :            :     else
      99                 :            :         OSL_FAIL( "SalGenericDisplay::Yield !acquireMutex\n" );
     100                 :            : 
     101         [ #  # ]:          0 :     if( pFrame )
     102                 :          0 :         pFrame->CallCallback( nEvent, pData );
     103                 :            : 
     104                 :          0 :     return pFrame != NULL;
     105                 :            : }
     106                 :            : 
     107                 :          0 : void SalGenericDisplay::SendInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent )
     108                 :            : {
     109         [ #  # ]:          0 :     if( osl_acquireMutex( m_aEventGuard ) )
     110                 :            :     {
     111         [ #  # ]:          0 :         m_aUserEvents.push_back( SalUserEvent( pFrame, pData, nEvent ) );
     112                 :            : 
     113                 :          0 :         PostUserEvent(); // wakeup the concrete mainloop
     114                 :            : 
     115                 :          0 :         osl_releaseMutex( m_aEventGuard );
     116                 :            :     }
     117                 :            :     else
     118                 :            :         OSL_FAIL( "SalGenericDisplay::SendInternalEvent !acquireMutex\n" );
     119                 :          0 : }
     120                 :            : 
     121                 :          0 : void SalGenericDisplay::CancelInternalEvent( SalFrame* pFrame, void* pData, sal_uInt16 nEvent )
     122                 :            : {
     123         [ #  # ]:          0 :     if( osl_acquireMutex( m_aEventGuard ) )
     124                 :            :     {
     125         [ #  # ]:          0 :         if( ! m_aUserEvents.empty() )
     126                 :            :         {
     127 [ #  # ][ #  # ]:          0 :             std::list< SalUserEvent >::iterator it, next;
     128                 :          0 :             next = m_aUserEvents.begin();
     129 [ #  # ][ #  # ]:          0 :             do
     130                 :            :             {
     131         [ #  # ]:          0 :                 it = next++;
     132 [ #  # ][ #  # ]:          0 :                 if( it->m_pFrame    == pFrame   &&
         [ #  # ][ #  # ]
                 [ #  # ]
     133         [ #  # ]:          0 :                     it->m_pData     == pData    &&
     134         [ #  # ]:          0 :                     it->m_nEvent    == nEvent )
     135                 :            :                 {
     136         [ #  # ]:          0 :                     m_aUserEvents.erase( it );
     137                 :            :                 }
     138                 :          0 :             } while( next != m_aUserEvents.end() );
     139                 :            :         }
     140                 :            : 
     141                 :          0 :         osl_releaseMutex( m_aEventGuard );
     142                 :            :     }
     143                 :            :     else
     144                 :            :         OSL_FAIL( "SalGenericDisplay::CancelInternalEvent !acquireMutex\n" );
     145                 :          0 : }
     146                 :            : 
     147                 :          0 : bool SalGenericDisplay::HasUserEvents() const
     148                 :            : {
     149                 :          0 :     bool bRet = false;
     150         [ #  # ]:          0 :     if( osl_acquireMutex( m_aEventGuard ) )
     151                 :            :     {
     152 [ #  # ][ #  # ]:          0 :         if( m_aUserEvents.begin() != m_aUserEvents.end() )
     153                 :          0 :             bRet = true;
     154                 :          0 :         osl_releaseMutex( m_aEventGuard );
     155                 :            :     }
     156                 :          0 :     return bRet;
     157                 :            : }
     158                 :            : 
     159                 :            : 
     160                 :            : 
     161                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10