LCOV - code coverage report
Current view: top level - sd/source/ui/tools - IdleDetection.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 35 0.0 %
Date: 2014-04-14 Functions: 0 4 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             : 
      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           0 : sal_Int32 IdleDetection::GetIdleState (const ::Window* pWindow)
      39             : {
      40           0 :     sal_Int32 nResult (CheckInputPending() | CheckSlideShowRunning());
      41           0 :     if (pWindow != NULL)
      42           0 :         nResult |= CheckWindowPainting(*pWindow);
      43           0 :     return nResult;
      44             : }
      45             : 
      46             : 
      47             : 
      48             : 
      49           0 : sal_Int32 IdleDetection::CheckInputPending (void)
      50             : {
      51           0 :     if (GetpApp()->AnyInput(VCL_INPUT_MOUSE | VCL_INPUT_KEYBOARD | VCL_INPUT_PAINT))
      52           0 :         return IDET_SYSTEM_EVENT_PENDING;
      53             :     else
      54           0 :         return IDET_IDLE;
      55             : }
      56             : 
      57             : 
      58             : 
      59             : 
      60           0 : sal_Int32 IdleDetection::CheckSlideShowRunning (void)
      61             : {
      62           0 :     sal_Int32 eResult (IDET_IDLE);
      63             : 
      64           0 :     bool bIsSlideShowShowing = false;
      65             : 
      66             :     // Iterate over all view frames.
      67           0 :     for (SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst();
      68           0 :          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           0 :         bool bIgnoreFrame (true);
      74           0 :         uno::Reference<frame::XFrame> xFrame (pViewFrame->GetFrame().GetFrameInterface());
      75             :         try
      76             :         {
      77           0 :             if (xFrame.is() && xFrame->isActive())
      78           0 :                 bIgnoreFrame = false;
      79             :         }
      80           0 :         catch (const uno::RuntimeException&)
      81             :         {
      82             :         }
      83           0 :         if (bIgnoreFrame)
      84           0 :             continue;
      85             : 
      86             :         // Get sd::ViewShell from active frame.
      87           0 :         ViewShellBase* pBase = ViewShellBase::GetViewShellBase(pViewFrame);
      88           0 :         if (pBase != NULL)
      89             :         {
      90           0 :             rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( *pBase ) );
      91           0 :             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           0 :             }
      98             :         }
      99           0 :     }
     100             : 
     101           0 :     return eResult;
     102             : }
     103             : 
     104             : 
     105             : 
     106             : 
     107           0 : sal_Int32 IdleDetection::CheckWindowPainting (const ::Window& rWindow)
     108             : {
     109           0 :     if (rWindow.IsInPaint())
     110           0 :         return IDET_WINDOW_PAINTING;
     111             :     else
     112           0 :         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