LCOV - code coverage report
Current view: top level - sd/source/ui/slideshow - SlideShowRestarter.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 44 0.0 %
Date: 2014-04-14 Functions: 0 9 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 "SlideShowRestarter.hxx"
      22             : #include "framework/ConfigurationController.hxx"
      23             : #include "framework/FrameworkHelper.hxx"
      24             : #include <comphelper/processfactory.hxx>
      25             : #include <sfx2/dispatch.hxx>
      26             : #include <sfx2/viewfrm.hxx>
      27             : #include <svx/svxids.hrc>
      28             : #include <vcl/svapp.hxx>
      29             : #include <boost/bind.hpp>
      30             : 
      31             : using namespace ::com::sun::star::uno;
      32             : using namespace ::com::sun::star::lang;
      33             : using ::sd::framework::FrameworkHelper;
      34             : 
      35             : 
      36             : namespace sd {
      37             : 
      38           0 : SlideShowRestarter::SlideShowRestarter (
      39             :     const ::rtl::Reference<SlideShow>& rpSlideShow,
      40             :     ViewShellBase* pViewShellBase)
      41             :     : mnEventId(0),
      42             :       mpSlideShow(rpSlideShow),
      43             :       mpViewShellBase(pViewShellBase),
      44           0 :       mnDisplayCount(Application::GetScreenCount()),
      45           0 :       mpDispatcher(pViewShellBase->GetViewFrame()->GetDispatcher()),
      46           0 :       mnCurrentSlideNumber(0)
      47             : {
      48           0 : }
      49             : 
      50           0 : SlideShowRestarter::~SlideShowRestarter (void)
      51             : {
      52           0 : }
      53             : 
      54           0 : void SlideShowRestarter::Restart (bool bForce)
      55             : {
      56             :     // Prevent multiple and concurrently restarts.
      57           0 :     if (mnEventId != 0)
      58           0 :         return;
      59             : 
      60           0 :     if (bForce)
      61           0 :         mnDisplayCount = 0;
      62             : 
      63             :     // Remember the current slide in order to restore it after the slide
      64             :     // show has been restarted.
      65           0 :     if (mpSlideShow.is())
      66           0 :         mnCurrentSlideNumber = mpSlideShow->getCurrentPageNumber();
      67             : 
      68             :     // Remember a shared pointer to this object to prevent its destruction
      69             :     // before the whole restarting process has finished.
      70           0 :     mpSelf = shared_from_this();
      71             : 
      72             :     // We do not know in what situation this method was called.  So, in
      73             :     // order to be able to cleanly stop the presentation, we do that
      74             :     // asynchronously.
      75             :     mnEventId = Application::PostUserEvent(
      76           0 :         LINK(this, SlideShowRestarter, EndPresentation));
      77             : }
      78             : 
      79           0 : IMPL_LINK_NOARG(SlideShowRestarter, EndPresentation)
      80             : {
      81           0 :     mnEventId = 0;
      82           0 :     if (mpSlideShow.is())
      83             :     {
      84           0 :         if (mnDisplayCount != (sal_Int32)Application::GetScreenCount())
      85             :         {
      86           0 :             mpSlideShow->end();
      87             : 
      88             :             // The following piece of code should not be here because the
      89             :             // slide show should be aware of the existence of the presenter
      90             :             // console (which is displayed in the FullScreenPane).  But the
      91             :             // timing has to be right and I did not find a better place for
      92             :             // it.
      93             : 
      94             :             // Wait for the full screen pane, which displays the presenter
      95             :             // console, to disappear.  Only when it is gone, call
      96             :             // InitiatePresenterStart(), in order to begin the asynchronous
      97             :             // restart of the slide show.
      98           0 :             if (mpViewShellBase != NULL)
      99             :             {
     100             :                 ::boost::shared_ptr<FrameworkHelper> pHelper(
     101           0 :                     FrameworkHelper::Instance(*mpViewShellBase));
     102           0 :                 if (pHelper->GetConfigurationController()->getResource(
     103           0 :                     pHelper->CreateResourceId(FrameworkHelper::msFullScreenPaneURL)).is())
     104             :                 {
     105             :                     ::sd::framework::ConfigurationController::Lock aLock (
     106           0 :                         pHelper->GetConfigurationController());
     107             : 
     108             :                     pHelper->RunOnConfigurationEvent(
     109             :                         FrameworkHelper::msConfigurationUpdateEndEvent,
     110           0 :                         ::boost::bind(&SlideShowRestarter::StartPresentation, shared_from_this()));
     111           0 :                     pHelper->UpdateConfiguration();
     112             :                 }
     113             :                 else
     114             :                 {
     115           0 :                     StartPresentation();
     116           0 :                 }
     117             :             }
     118             :         }
     119             :     }
     120           0 :     return 0;
     121             : }
     122             : 
     123           0 : void SlideShowRestarter::StartPresentation (void)
     124             : {
     125           0 :     if (mpDispatcher == NULL && mpViewShellBase!=NULL)
     126           0 :         mpDispatcher = mpViewShellBase->GetViewFrame()->GetDispatcher();
     127             : 
     128             :     // Start the slide show on the saved current slide.
     129           0 :     if (mpDispatcher != NULL)
     130             :     {
     131           0 :         mpDispatcher->Execute(SID_PRESENTATION, SFX_CALLMODE_ASYNCHRON);
     132           0 :         if (mpSlideShow.is())
     133             :         {
     134           0 :             Sequence<css::beans::PropertyValue> aProperties (1);
     135           0 :             aProperties[0].Name = "FirstPage";
     136           0 :             aProperties[0].Value <<= "page" + OUString::number(mnCurrentSlideNumber+1);
     137           0 :             mpSlideShow->startWithArguments(aProperties);
     138             :         }
     139           0 :         mpSelf.reset();
     140             :     }
     141           0 : }
     142             : 
     143           0 : } // end of namespace sd
     144             : 
     145             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10