LCOV - code coverage report
Current view: top level - sd/source/ui/slideshow - SlideShowRestarter.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 48 2.1 %
Date: 2015-06-13 12:38:46 Functions: 2 9 22.2 %
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             : #include "DrawController.hxx"
      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 <sfx2/app.hxx>
      28             : #include <svx/svxids.hrc>
      29             : #include <vcl/svapp.hxx>
      30             : #include <boost/bind.hpp>
      31             : 
      32             : using namespace ::com::sun::star::uno;
      33             : using namespace ::com::sun::star::lang;
      34             : using ::sd::framework::FrameworkHelper;
      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()
      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 :             bool bIsExitAfterPresenting = mpSlideShow->IsExitAfterPresenting();
      87           0 :             mpSlideShow->SetExitAfterPresenting(false);
      88           0 :             mpSlideShow->end();
      89           0 :             mpSlideShow->SetExitAfterPresenting(bIsExitAfterPresenting);
      90             : 
      91             :             // The following piece of code should not be here because the
      92             :             // slide show should be aware of the existence of the presenter
      93             :             // console (which is displayed in the FullScreenPane).  But the
      94             :             // timing has to be right and I did not find a better place for
      95             :             // it.
      96             : 
      97             :             // Wait for the full screen pane, which displays the presenter
      98             :             // console, to disappear.  Only when it is gone, call
      99             :             // InitiatePresenterStart(), in order to begin the asynchronous
     100             :             // restart of the slide show.
     101           0 :             if (mpViewShellBase != NULL)
     102             :             {
     103             :                 ::boost::shared_ptr<FrameworkHelper> pHelper(
     104           0 :                     FrameworkHelper::Instance(*mpViewShellBase));
     105           0 :                 if (pHelper->GetConfigurationController()->getResource(
     106           0 :                     FrameworkHelper::CreateResourceId(FrameworkHelper::msFullScreenPaneURL)).is())
     107             :                 {
     108             :                     ::sd::framework::ConfigurationController::Lock aLock (
     109           0 :                         pHelper->GetConfigurationController());
     110             : 
     111             :                     pHelper->RunOnConfigurationEvent(
     112             :                         FrameworkHelper::msConfigurationUpdateEndEvent,
     113           0 :                         ::boost::bind(&SlideShowRestarter::StartPresentation, shared_from_this()));
     114           0 :                     pHelper->UpdateConfiguration();
     115             :                 }
     116             :                 else
     117             :                 {
     118           0 :                     StartPresentation();
     119           0 :                 }
     120             :             }
     121             :         }
     122             :     }
     123           0 :     return 0;
     124             : }
     125             : 
     126           0 : void SlideShowRestarter::StartPresentation()
     127             : {
     128             :     //rhbz#1091117 crash because we're exiting the application, and this is
     129             :     //being called during the configuration update event on exit. At this point
     130             :     //newly created objects won't get disposed called on them, because the
     131             :     //disposer is doing its last execution of that now.
     132           0 :     if (mpViewShellBase && mpViewShellBase->GetDrawController().IsDisposing())
     133           0 :         return;
     134             : 
     135           0 :     if (mpDispatcher == NULL && mpViewShellBase!=NULL)
     136           0 :         mpDispatcher = mpViewShellBase->GetViewFrame()->GetDispatcher();
     137             : 
     138             :     // Start the slide show on the saved current slide.
     139           0 :     if (mpDispatcher != NULL)
     140             :     {
     141           0 :         mpDispatcher->Execute(SID_PRESENTATION, SfxCallMode::ASYNCHRON);
     142           0 :         if (mpSlideShow.is())
     143             :         {
     144           0 :             Sequence<css::beans::PropertyValue> aProperties (1);
     145           0 :             aProperties[0].Name = "FirstPage";
     146           0 :             aProperties[0].Value <<= "page" + OUString::number(mnCurrentSlideNumber+1);
     147           0 :             mpSlideShow->startWithArguments(aProperties);
     148             :         }
     149           0 :         mpSelf.reset();
     150             :     }
     151             : }
     152             : 
     153          66 : } // end of namespace sd
     154             : 
     155             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11