LCOV - code coverage report
Current view: top level - sd/source/ui/tools - IdleDetection.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 30 36 83.3 %
Date: 2012-08-25 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 29 52 55.8 %

           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 "tools/IdleDetection.hxx"
      31                 :            : 
      32                 :            : #include "ViewShell.hxx"
      33                 :            : #include "slideshow.hxx"
      34                 :            : #include "ViewShellBase.hxx"
      35                 :            : 
      36                 :            : #include <vcl/window.hxx>
      37                 :            : #include <sfx2/viewfrm.hxx>
      38                 :            : 
      39                 :            : #include <com/sun/star/frame/XFrame.hpp>
      40                 :            : #include <vcl/svapp.hxx>
      41                 :            : 
      42                 :            : using namespace ::com::sun::star;
      43                 :            : 
      44                 :            : namespace sd { namespace tools {
      45                 :            : 
      46                 :            : 
      47                 :        270 : sal_Int32 IdleDetection::GetIdleState (const ::Window* pWindow)
      48                 :            : {
      49                 :        270 :     sal_Int32 nResult (CheckInputPending() | CheckSlideShowRunning());
      50         [ +  - ]:        270 :     if (pWindow != NULL)
      51                 :        270 :         nResult |= CheckWindowPainting(*pWindow);
      52                 :        270 :     return nResult;
      53                 :            : }
      54                 :            : 
      55                 :            : 
      56                 :            : 
      57                 :            : 
      58                 :        270 : sal_Int32 IdleDetection::CheckInputPending (void)
      59                 :            : {
      60         [ -  + ]:        270 :     if (GetpApp()->AnyInput(VCL_INPUT_MOUSE | VCL_INPUT_KEYBOARD | VCL_INPUT_PAINT))
      61                 :          0 :         return IDET_SYSTEM_EVENT_PENDING;
      62                 :            :     else
      63                 :        270 :         return IDET_IDLE;
      64                 :            : }
      65                 :            : 
      66                 :            : 
      67                 :            : 
      68                 :            : 
      69                 :        270 : sal_Int32 IdleDetection::CheckSlideShowRunning (void)
      70                 :            : {
      71                 :        270 :     sal_Int32 eResult (IDET_IDLE);
      72                 :            : 
      73                 :        270 :     bool bIsSlideShowShowing = false;
      74                 :            : 
      75                 :            :     // Iterate over all view frames.
      76                 :        270 :     SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst();
      77 [ +  + ][ +  - ]:        552 :     for (pViewFrame = SfxViewFrame::GetFirst();
                 [ +  + ]
      78                 :        282 :          pViewFrame!=NULL && !bIsSlideShowShowing;
      79                 :            :          pViewFrame = SfxViewFrame::GetNext(*pViewFrame))
      80                 :            :     {
      81                 :            :         // Ignore the current frame when it does not exist, is not valid, or
      82                 :            :         // is not active.
      83                 :        282 :         bool bIgnoreFrame (true);
      84 [ +  - ][ +  - ]:        282 :         uno::Reference<frame::XFrame> xFrame (pViewFrame->GetFrame().GetFrameInterface());
      85                 :            :         try
      86                 :            :         {
      87 [ +  - ][ +  - ]:        282 :             if (xFrame.is() && xFrame->isActive())
         [ +  - ][ +  + ]
                 [ +  + ]
      88                 :        167 :                 bIgnoreFrame = false;
      89                 :            :         }
      90         [ #  # ]:          0 :         catch (const uno::RuntimeException&)
      91                 :            :         {
      92                 :            :         }
      93         [ +  + ]:        282 :         if (bIgnoreFrame)
      94                 :        115 :             continue;
      95                 :            : 
      96                 :            :         // Get sd::ViewShell from active frame.
      97         [ +  - ]:        167 :         ViewShellBase* pBase = ViewShellBase::GetViewShellBase(pViewFrame);
      98         [ +  + ]:        167 :         if (pBase != NULL)
      99                 :            :         {
     100         [ +  - ]:        165 :             rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( *pBase ) );
     101 [ +  - ][ +  - ]:        165 :             if( xSlideShow.is() && xSlideShow->isRunning() )
         [ -  + ][ -  + ]
     102                 :            :             {
     103 [ #  # ][ #  # ]:          0 :                 if (xSlideShow->isFullScreen())
     104                 :          0 :                     eResult |= IDET_FULL_SCREEN_SHOW_ACTIVE;
     105                 :            :                 else
     106                 :          0 :                     eResult |= IDET_WINDOW_SHOW_ACTIVE;
     107                 :        167 :             }
     108                 :            :         }
     109         [ +  + ]:        282 :     }
     110                 :            : 
     111         [ #  # ]:        270 :     return eResult;
     112                 :            : }
     113                 :            : 
     114                 :            : 
     115                 :            : 
     116                 :            : 
     117                 :        270 : sal_Int32 IdleDetection::CheckWindowPainting (const ::Window& rWindow)
     118                 :            : {
     119         [ -  + ]:        270 :     if (rWindow.IsInPaint())
     120                 :          0 :         return IDET_WINDOW_PAINTING;
     121                 :            :     else
     122                 :        270 :         return IDET_IDLE;
     123                 :            : }
     124                 :            : 
     125                 :            : } } // end of namespace ::sd::tools
     126                 :            : 
     127                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10