From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- sd/source/ui/remotecontrol/Receiver.cxx | 207 ++++++++++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 sd/source/ui/remotecontrol/Receiver.cxx (limited to 'sd/source/ui/remotecontrol/Receiver.cxx') diff --git a/sd/source/ui/remotecontrol/Receiver.cxx b/sd/source/ui/remotecontrol/Receiver.cxx new file mode 100644 index 000000000..dd92e8e99 --- /dev/null +++ b/sd/source/ui/remotecontrol/Receiver.cxx @@ -0,0 +1,207 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#include "Receiver.hxx" +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +using namespace sd; +using namespace ::osl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::presentation; +using namespace ::com::sun::star::beans; + +Receiver::Receiver( Transmitter *aTransmitter ) : Timer("sd Receiver") +{ + pTransmitter = aTransmitter; + SetTimeout( 0 ); +} + +Receiver::~Receiver() +{ +} + +// Bounce the commands to the main thread to avoid threading woes +void Receiver::pushCommand( const std::vector &rCommand ) +{ + SolarMutexGuard aGuard; + maExecQueue.push_back( rCommand ); + Start(); +} + +void Receiver::Invoke() +{ + if( !maExecQueue.empty() ) + { + std::vector< OString > aCommands( maExecQueue.front() ); + maExecQueue.pop_front(); + if( !aCommands.empty() ) + executeCommand( aCommands ); + Start(); + } + else + Stop(); +} + +void Receiver::executeCommand( const std::vector &aCommand ) +{ + uno::Reference xSlideShowController; + uno::Reference xPresentation; + uno::Reference xSlideShow; + try { + uno::Reference< frame::XDesktop2 > xFramesSupplier = frame::Desktop::create( ::comphelper::getProcessComponentContext() ); + uno::Reference< frame::XFrame > xFrame ( xFramesSupplier->getActiveFrame(), uno::UNO_SET_THROW ); + uno::Reference xPS ( xFrame->getController()->getModel(), uno::UNO_QUERY_THROW); + xPresentation.set( xPS->getPresentation(), uno::UNO_QUERY_THROW); + // Throws an exception if no slideshow running + xSlideShowController.set( xPresentation->getController(), uno::UNO_SET_THROW ); + xSlideShow.set( xSlideShowController->getSlideShow(), uno::UNO_SET_THROW ); + } + catch (uno::RuntimeException &) + { + } + + if ( aCommand[0] == "transition_next" ) + { + if ( xSlideShowController.is() ) + xSlideShowController->gotoNextEffect(); + } + else if ( aCommand[0] == "transition_previous" ) + { + if ( xSlideShowController.is() ) + xSlideShowController->gotoPreviousEffect(); + } + else if ( aCommand[0] == "goto_slide" ) + { + // FIXME: if 0 returned, then not a valid number + sal_Int32 aSlide = aCommand[1].toInt32(); + if ( xSlideShowController.is() && + xSlideShowController->getCurrentSlideIndex() != aSlide ) + { + xSlideShowController->gotoSlideIndex( aSlide ); + } + } + else if ( aCommand[0] == "presentation_start" ) + { + if ( xPresentation.is() ) + xPresentation->start(); + } + else if ( aCommand[0] == "presentation_stop" ) + { + if ( xPresentation.is() ) + xPresentation->end(); + } + else if ( aCommand[0] == "presentation_blank_screen" ) + { + if ( aCommand.size() > 1 ) + { +// aColour = FIXME: get the colour in some format from this string +// Determine the formatting first. + } + if ( xSlideShowController.is() ) + { + xSlideShowController->blankScreen( 0 ); // Default is black + } + } + else if (aCommand[0] == "pointer_started" ) + { + // std::cerr << "pointer_started" << std::endl; + float x = aCommand[1].toFloat(); + float y = aCommand[2].toFloat(); + SolarMutexGuard aSolarGuard; + + const css::geometry::RealPoint2D pos(x,y); + // std::cerr << "Pointer at ("<setProperty(beans::PropertyValue("PointerPosition", -1, Any(pos), + beans::PropertyState_DIRECT_VALUE)); + } + catch (Exception&) + { + TOOLS_WARN_EXCEPTION("sdremote", "sd::SlideShowImpl::setPointerPosition()"); + } + + try + { + xSlideShow->setProperty(beans::PropertyValue("PointerVisible", -1, Any(true), + beans::PropertyState_DIRECT_VALUE)); + } + catch (Exception&) + { + TOOLS_WARN_EXCEPTION("sdremote", "sd::SlideShowImpl::setPointerMode()"); + } + } + + SAL_INFO( "sdremote", "Pointer started, we display the pointer on screen" ); + } + else if (aCommand[0] == "pointer_dismissed" ) + { + SolarMutexGuard aSolarGuard; + if (xSlideShow.is()) try + { + xSlideShow->setProperty( + beans::PropertyValue( "PointerVisible" , + -1, + Any( false ), + beans::PropertyState_DIRECT_VALUE ) ); + } + catch ( Exception& ) + { + TOOLS_WARN_EXCEPTION( "sdremote", "sd::SlideShowImpl::setPointerMode()" ); + } + + SAL_INFO( "sdremote", "Pointer dismissed, we hide the pointer on screen" ); + } + else if (aCommand[0] == "pointer_coordination" ) + { + float x = aCommand[1].toFloat(); + float y = aCommand[2].toFloat(); + + SAL_INFO( "sdremote", "Pointer at ("<setProperty( + beans::PropertyValue( "PointerPosition" , + -1, + Any( pos ), + beans::PropertyState_DIRECT_VALUE ) ); + } + catch ( Exception& ) + { + TOOLS_WARN_EXCEPTION( "sdremote", "sd::SlideShowImpl::setPointerPosition()" ); + } + } + else if ( aCommand[0] == "presentation_resume" ) + { + if ( xSlideShowController.is() ) + { + xSlideShowController->resume(); + } + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3