LCOV - code coverage report
Current view: top level - sd/source/ui/remotecontrol - Receiver.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 92 0.0 %
Date: 2014-04-14 Functions: 0 6 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             : #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             : #include <comphelper/processfactory.hxx>
      19             : #include <comphelper/anytostring.hxx>
      20             : #include "cppuhelper/exc_hlp.hxx"
      21             : #include <osl/file.hxx>
      22             : #include <rtl/ustrbuf.hxx>
      23             : #include <rtl/strbuf.hxx>
      24             : #include <com/sun/star/beans/PropertyValue.hpp>
      25             : #include <com/sun/star/presentation/SlideShow.hpp>
      26             : 
      27             : using namespace sd;
      28             : using namespace ::com::sun::star;
      29             : using namespace ::osl;
      30             : using namespace std;
      31             : using namespace ::com::sun::star;
      32             : using namespace ::com::sun::star::lang;
      33             : using namespace ::com::sun::star::uno;
      34             : using namespace ::com::sun::star::presentation;
      35             : using namespace ::com::sun::star::beans;
      36             : 
      37           0 : Receiver::Receiver( Transmitter *aTransmitter )
      38             : {
      39           0 :     pTransmitter = aTransmitter;
      40           0 :     SetTimeout( 0 );
      41           0 : }
      42             : 
      43           0 : Receiver::~Receiver()
      44             : {
      45           0 : }
      46             : 
      47             : // Bounce the commands to the main thread to avoid threading woes
      48           0 : void Receiver::pushCommand( const std::vector<OString> &rCommand )
      49             : {
      50           0 :     SolarMutexGuard aGuard;
      51           0 :     maExecQueue.push_back( rCommand );
      52           0 :     Start();
      53           0 : }
      54             : 
      55           0 : void Receiver::Timeout()
      56             : {
      57           0 :     if( maExecQueue.size() )
      58             :     {
      59           0 :         std::vector< OString > aCommands( maExecQueue.front() );
      60           0 :         maExecQueue.pop_front();
      61           0 :         if( !aCommands.empty() )
      62           0 :             executeCommand( aCommands );
      63           0 :         Start();
      64             :     }
      65             :     else
      66           0 :         Stop();
      67           0 : }
      68             : 
      69           0 : void Receiver::executeCommand( const std::vector<OString> &aCommand )
      70             : {
      71           0 :     uno::Reference<presentation::XSlideShowController> xSlideShowController;
      72           0 :     uno::Reference<presentation::XPresentation2> xPresentation;
      73           0 :     uno::Reference<presentation::XSlideShow> xSlideShow;
      74             :     try {
      75           0 :         uno::Reference< frame::XDesktop2 > xFramesSupplier = frame::Desktop::create( ::comphelper::getProcessComponentContext() );
      76           0 :         uno::Reference< frame::XFrame > xFrame ( xFramesSupplier->getActiveFrame(), uno::UNO_QUERY_THROW );
      77           0 :         uno::Reference<presentation::XPresentationSupplier> xPS ( xFrame->getController()->getModel(), uno::UNO_QUERY_THROW);
      78           0 :         xPresentation = uno::Reference<presentation::XPresentation2>(
      79           0 :             xPS->getPresentation(), uno::UNO_QUERY_THROW);
      80             :         // Throws an exception if now slideshow running
      81           0 :         xSlideShowController =  uno::Reference<presentation::XSlideShowController>(
      82           0 :            xPresentation->getController(), uno::UNO_QUERY_THROW );
      83           0 :         xSlideShow = uno::Reference<presentation::XSlideShow>(
      84           0 :             xSlideShowController->getSlideShow(), uno::UNO_QUERY_THROW );
      85             :     }
      86           0 :     catch (uno::RuntimeException &)
      87             :     {
      88             :     }
      89             : 
      90           0 :     if ( aCommand[0].equals( "transition_next" ) )
      91             :     {
      92           0 :         if ( xSlideShowController.is() )
      93           0 :             xSlideShowController->gotoNextEffect();
      94             :     }
      95           0 :     else if ( aCommand[0].equals( "transition_previous" ) )
      96             :     {
      97           0 :         if ( xSlideShowController.is() )
      98           0 :             xSlideShowController->gotoPreviousEffect();
      99             :     }
     100           0 :     else if ( aCommand[0].equals( "goto_slide" ) )
     101             :     {
     102             :         // FIXME: if 0 returned, then not a valid number
     103           0 :         sal_Int32 aSlide = aCommand[1].toInt32();
     104           0 :         if ( xSlideShowController.is() &&
     105           0 :             xSlideShowController->getCurrentSlideIndex() != aSlide )
     106             :         {
     107           0 :             xSlideShowController->gotoSlideIndex( aSlide );
     108             :         }
     109             :     }
     110           0 :     else if ( aCommand[0].equals( "presentation_start" ) )
     111             :     {
     112           0 :         if ( xPresentation.is() )
     113           0 :             xPresentation->start();
     114             :     }
     115           0 :     else if ( aCommand[0].equals( "presentation_stop" ) )
     116             :     {
     117           0 :         if ( xPresentation.is() )
     118           0 :             xPresentation->end();
     119             :     }
     120           0 :     else if ( aCommand[0].equals( "presentation_blank_screen" ) )
     121             :     {
     122           0 :         sal_Int32 aColour = 0; // Default is black
     123           0 :         if ( aCommand.size() > 1 )
     124             :         {
     125             : //             aColour = FIXME: get the colour in some format from this string
     126             : //              Determine the formatting first.
     127             :         }
     128           0 :         if ( xSlideShowController.is() )
     129             :         {
     130           0 :             xSlideShowController->blankScreen( aColour );
     131             :         }
     132             :     }
     133           0 :     else if (aCommand[0].equals( "pointer_started" ))
     134             :     {
     135             :         // std::cerr << "pointer_started" << std::endl;
     136           0 :         float x = aCommand[1].toFloat();
     137           0 :         float y = aCommand[2].toFloat();
     138           0 :         SolarMutexGuard aSolarGuard;
     139             : 
     140           0 :         const ::com::sun::star::geometry::RealPoint2D pos(x,y);
     141             :         // std::cerr << "Pointer at ("<<pos.X<<","<<pos.Y<<")" << std::endl;
     142             : 
     143           0 :         if (xSlideShow.is()) try
     144             :         {
     145             :             // std::cerr << "pointer_coordination in the is" << std::endl;
     146           0 :             xSlideShow->setProperty(
     147             :                         beans::PropertyValue( "PointerPosition" ,
     148             :                             -1,
     149             :                             makeAny( pos ),
     150           0 :                             beans::PropertyState_DIRECT_VALUE ) );
     151             :         }
     152           0 :         catch ( Exception& )
     153             :         {
     154             :             SAL_WARN( "sd.slideshow", "sd::SlideShowImpl::setPointerPosition(), "
     155             :                 "exception caught: " << comphelper::anyToString( cppu::getCaughtException() ));
     156             :         }
     157             : 
     158           0 :         if (xSlideShow.is()) try
     159             :         {
     160           0 :             xSlideShow->setProperty(
     161             :                         beans::PropertyValue( "PointerVisible" ,
     162             :                             -1,
     163             :                             makeAny( true ),
     164           0 :                             beans::PropertyState_DIRECT_VALUE ) );
     165             :         }
     166           0 :         catch ( Exception& )
     167             :         {
     168             :             SAL_WARN( "sd.slideshow", "sd::SlideShowImpl::setPointerMode(), "
     169             :                 "exception caught: " << comphelper::anyToString( cppu::getCaughtException() ));
     170             :         }
     171             : 
     172           0 :         SAL_INFO( "sdremote", "Pointer started, we display the pointer on screen" );
     173             :     }
     174           0 :     else if (aCommand[0].equals( "pointer_dismissed" ))
     175             :     {
     176           0 :         SolarMutexGuard aSolarGuard;
     177           0 :         if (xSlideShow.is()) try
     178             :         {
     179           0 :             xSlideShow->setProperty(
     180             :                         beans::PropertyValue( "PointerVisible" ,
     181             :                             -1,
     182             :                             makeAny( false ),
     183           0 :                             beans::PropertyState_DIRECT_VALUE ) );
     184             :         }
     185           0 :         catch ( Exception& )
     186             :         {
     187             :             SAL_WARN( "sd.slideshow", "sd::SlideShowImpl::setPointerMode(), "
     188             :                 "exception caught: " << comphelper::anyToString( cppu::getCaughtException() ));
     189             :         }
     190             : 
     191           0 :         SAL_INFO( "sdremote", "Pointer dismissed, we hide the pointer on screen" );
     192             :     }
     193           0 :     else if (aCommand[0].equals( "pointer_coordination" ))
     194             :     {
     195           0 :         float x = aCommand[1].toFloat();
     196           0 :         float y = aCommand[2].toFloat();
     197             : 
     198             :         SAL_INFO( "sdremote", "Pointer at ("<<x<<","<<y<<")" );
     199           0 :         const ::com::sun::star::geometry::RealPoint2D pos(x,y);
     200             : 
     201           0 :         SolarMutexGuard aSolarGuard;
     202           0 :         if (xSlideShow.is()) try
     203             :         {
     204           0 :             xSlideShow->setProperty(
     205             :                         beans::PropertyValue( "PointerPosition" ,
     206             :                             -1,
     207             :                             makeAny( pos ),
     208           0 :                             beans::PropertyState_DIRECT_VALUE ) );
     209             :         }
     210           0 :         catch ( Exception& )
     211             :         {
     212             :             SAL_WARN( "sd.slideshow", "sd::SlideShowImpl::setPointerPosition(), "
     213             :                 "exception caught: " << comphelper::anyToString( cppu::getCaughtException() ));
     214           0 :         }
     215             :     }
     216           0 :     else if ( aCommand[0].equals( "presentation_resume" ) )
     217             :     {
     218           0 :         if ( xSlideShowController.is() )
     219             :         {
     220           0 :             xSlideShowController->resume();
     221             :         }
     222           0 :     }
     223           0 : }
     224             : 
     225             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10