LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/remotecontrol - Receiver.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 58 1.7 %
Date: 2013-07-09 Functions: 2 8 25.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             : #include "Receiver.hxx"
      10             : #include <string.h>
      11             : #include <com/sun/star/presentation/XSlideShowController.hpp>
      12             : #include <com/sun/star/presentation/XPresentationSupplier.hpp>
      13             : #include <com/sun/star/presentation/XPresentation2.hpp>
      14             : #include <com/sun/star/frame/Desktop.hpp>
      15             : #include <com/sun/star/frame/XFramesSupplier.hpp>
      16             : #include <com/sun/star/uno/RuntimeException.hpp>
      17             : 
      18             : 
      19             : #include <comphelper/processfactory.hxx>
      20             : #include <osl/file.hxx>
      21             : #include <rtl/ustrbuf.hxx>
      22             : #include <rtl/strbuf.hxx>
      23             : 
      24             : using namespace sd;
      25             : using namespace ::com::sun::star;
      26             : using namespace ::osl;
      27             : using namespace std;
      28             : 
      29           0 : Receiver::Receiver( Transmitter *aTransmitter )
      30             : {
      31           0 :     pTransmitter = aTransmitter;
      32           0 :     SetTimeout( 0 );
      33           0 : }
      34             : 
      35           0 : Receiver::~Receiver()
      36             : {
      37           0 : }
      38             : 
      39             : // Bounce the commands to the main thread to avoid threading woes
      40           0 : void Receiver::pushCommand( const std::vector<OString> &rCommand )
      41             : {
      42           0 :     SolarMutexGuard aGuard;
      43           0 :     maExecQueue.push_back( rCommand );
      44           0 :     Start();
      45           0 : }
      46             : 
      47           0 : void Receiver::Timeout()
      48             : {
      49           0 :     if( maExecQueue.size() )
      50             :     {
      51           0 :         std::vector< OString > aCommands( maExecQueue.front() );
      52           0 :         maExecQueue.pop_front();
      53           0 :         if( !aCommands.empty() )
      54           0 :             executeCommand( aCommands );
      55           0 :         Start();
      56             :     }
      57             :     else
      58           0 :         Stop();
      59           0 : }
      60             : 
      61           0 : void Receiver::executeCommand( const std::vector<OString> &aCommand )
      62             : {
      63           0 :     uno::Reference<presentation::XSlideShowController> xSlideShowController;
      64           0 :     uno::Reference<presentation::XPresentation2> xPresentation;
      65             :     try {
      66           0 :         uno::Reference< frame::XDesktop2 > xFramesSupplier = frame::Desktop::create( ::comphelper::getProcessComponentContext() );
      67           0 :         uno::Reference< frame::XFrame > xFrame ( xFramesSupplier->getActiveFrame(), uno::UNO_QUERY_THROW );
      68           0 :         uno::Reference<presentation::XPresentationSupplier> xPS ( xFrame->getController()->getModel(), uno::UNO_QUERY_THROW);
      69           0 :         xPresentation = uno::Reference<presentation::XPresentation2>(
      70           0 :             xPS->getPresentation(), uno::UNO_QUERY_THROW);
      71             :         // Throws an exception if now slideshow running
      72           0 :         xSlideShowController =  uno::Reference<presentation::XSlideShowController>(
      73           0 :            xPresentation->getController(), uno::UNO_QUERY_THROW );
      74             :     }
      75           0 :     catch (uno::RuntimeException &)
      76             :     {
      77             :     }
      78             : 
      79           0 :     if ( aCommand[0].equals( "transition_next" ) )
      80             :     {
      81           0 :         if ( xSlideShowController.is() )
      82           0 :             xSlideShowController->gotoNextEffect();
      83             :     }
      84           0 :     else if ( aCommand[0].equals( "transition_previous" ) )
      85             :     {
      86           0 :         if ( xSlideShowController.is() )
      87           0 :             xSlideShowController->gotoPreviousEffect();
      88             :     }
      89           0 :     else if ( aCommand[0].equals( "goto_slide" ) )
      90             :     {
      91             :         // FIXME: if 0 returned, then not a valid number
      92           0 :         sal_Int32 aSlide = aCommand[1].toInt32();
      93           0 :         if ( xSlideShowController.is() &&
      94           0 :             xSlideShowController->getCurrentSlideIndex() != aSlide )
      95             :         {
      96           0 :             xSlideShowController->gotoSlideIndex( aSlide );
      97             :         }
      98             :     }
      99           0 :     else if ( aCommand[0].equals( "presentation_start" ) )
     100             :     {
     101           0 :         if ( xPresentation.is() )
     102           0 :             xPresentation->start();
     103             :     }
     104           0 :     else if ( aCommand[0].equals( "presentation_stop" ) )
     105             :     {
     106           0 :         if ( xPresentation.is() )
     107           0 :             xPresentation->end();
     108             :     }
     109           0 :     else if ( aCommand[0].equals( "presentation_blank_screen" ) )
     110             :     {
     111           0 :         sal_Int32 aColour = 0; // Default is black
     112           0 :         if ( aCommand.size() > 1 )
     113             :         {
     114             : //             aColour = FIXME: get the colour in some format from this string
     115             : //              Determine the formatting first.
     116             :         }
     117           0 :         if ( xSlideShowController.is() )
     118             :         {
     119           0 :             xSlideShowController->blankScreen( aColour );
     120             :         }
     121             :     }
     122           0 :     else if ( aCommand[0].equals( "presentation_resume" ) )
     123             :     {
     124           0 :         if ( xSlideShowController.is() )
     125             :         {
     126           0 :             xSlideShowController->resume();
     127             :         }
     128           0 :     }
     129          33 : }
     130             : 
     131             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10