LCOV - code coverage report
Current view: top level - sd/source/ui/tools - IdleDetection.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 29 35 82.9 %
Date: 2014-04-11 Functions: 4 4 100.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             : 
      21             : #include "tools/IdleDetection.hxx"
      22             : 
      23             : #include "ViewShell.hxx"
      24             : #include "slideshow.hxx"
      25             : #include "ViewShellBase.hxx"
      26             : 
      27             : #include <vcl/window.hxx>
      28             : #include <sfx2/viewfrm.hxx>
      29             : 
      30             : #include <com/sun/star/frame/XFrame.hpp>
      31             : #include <vcl/svapp.hxx>
      32             : 
      33             : using namespace ::com::sun::star;
      34             : 
      35             : namespace sd { namespace tools {
      36             : 
      37             : 
      38         134 : sal_Int32 IdleDetection::GetIdleState (const ::Window* pWindow)
      39             : {
      40         134 :     sal_Int32 nResult (CheckInputPending() | CheckSlideShowRunning());
      41         134 :     if (pWindow != NULL)
      42         134 :         nResult |= CheckWindowPainting(*pWindow);
      43         134 :     return nResult;
      44             : }
      45             : 
      46             : 
      47             : 
      48             : 
      49         134 : sal_Int32 IdleDetection::CheckInputPending (void)
      50             : {
      51         134 :     if (GetpApp()->AnyInput(VCL_INPUT_MOUSE | VCL_INPUT_KEYBOARD | VCL_INPUT_PAINT))
      52           0 :         return IDET_SYSTEM_EVENT_PENDING;
      53             :     else
      54         134 :         return IDET_IDLE;
      55             : }
      56             : 
      57             : 
      58             : 
      59             : 
      60         134 : sal_Int32 IdleDetection::CheckSlideShowRunning (void)
      61             : {
      62         134 :     sal_Int32 eResult (IDET_IDLE);
      63             : 
      64         134 :     bool bIsSlideShowShowing = false;
      65             : 
      66             :     // Iterate over all view frames.
      67         272 :     for (SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst();
      68         138 :          pViewFrame!=NULL && !bIsSlideShowShowing;
      69             :          pViewFrame = SfxViewFrame::GetNext(*pViewFrame))
      70             :     {
      71             :         // Ignore the current frame when it does not exist, is not valid, or
      72             :         // is not active.
      73         138 :         bool bIgnoreFrame (true);
      74         138 :         uno::Reference<frame::XFrame> xFrame (pViewFrame->GetFrame().GetFrameInterface());
      75             :         try
      76             :         {
      77         138 :             if (xFrame.is() && xFrame->isActive())
      78          81 :                 bIgnoreFrame = false;
      79             :         }
      80           0 :         catch (const uno::RuntimeException&)
      81             :         {
      82             :         }
      83         138 :         if (bIgnoreFrame)
      84          57 :             continue;
      85             : 
      86             :         // Get sd::ViewShell from active frame.
      87          81 :         ViewShellBase* pBase = ViewShellBase::GetViewShellBase(pViewFrame);
      88          81 :         if (pBase != NULL)
      89             :         {
      90          81 :             rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( *pBase ) );
      91          81 :             if( xSlideShow.is() && xSlideShow->isRunning() )
      92             :             {
      93           0 :                 if (xSlideShow->isFullScreen())
      94           0 :                     eResult |= IDET_FULL_SCREEN_SHOW_ACTIVE;
      95             :                 else
      96           0 :                     eResult |= IDET_WINDOW_SHOW_ACTIVE;
      97          81 :             }
      98             :         }
      99          81 :     }
     100             : 
     101         134 :     return eResult;
     102             : }
     103             : 
     104             : 
     105             : 
     106             : 
     107         134 : sal_Int32 IdleDetection::CheckWindowPainting (const ::Window& rWindow)
     108             : {
     109         134 :     if (rWindow.IsInPaint())
     110           0 :         return IDET_WINDOW_PAINTING;
     111             :     else
     112         134 :         return IDET_IDLE;
     113             : }
     114             : 
     115             : } } // end of namespace ::sd::tools
     116             : 
     117             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10