LCOV - code coverage report
Current view: top level - sd/source/ui/slideshow - SlideShowRestarter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 54 1.9 %
Date: 2012-08-25 Functions: 2 10 20.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 108 1.9 %

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

Generated by: LCOV version 1.10