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/XFramesSupplier.hpp>
15 : #include <com/sun/star/uno/RuntimeException.hpp>
16 :
17 :
18 : #include <comphelper/processfactory.hxx>
19 : #include <osl/file.hxx>
20 : #include <rtl/ustrbuf.hxx>
21 : #include <rtl/strbuf.hxx>
22 :
23 : using namespace sd;
24 : using namespace ::com::sun::star;
25 : using rtl::OUString;
26 : using rtl::OString;
27 : using namespace ::osl;
28 : using namespace std;
29 :
30 0 : Receiver::Receiver( Transmitter *aTransmitter )
31 : {
32 0 : pTransmitter = aTransmitter;
33 0 : }
34 :
35 0 : Receiver::~Receiver()
36 : {
37 0 : }
38 :
39 0 : void Receiver::parseCommand( std::vector<OString> aCommand )
40 : {
41 0 : uno::Reference<presentation::XSlideShowController> xSlideShowController;
42 0 : uno::Reference<presentation::XPresentation2> xPresentation;
43 : try {
44 : uno::Reference< lang::XMultiServiceFactory > xServiceManager(
45 0 : ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
46 0 : uno::Reference< frame::XFramesSupplier > xFramesSupplier( xServiceManager->createInstance(
47 0 : "com.sun.star.frame.Desktop" ) , uno::UNO_QUERY_THROW );
48 0 : uno::Reference< frame::XFrame > xFrame ( xFramesSupplier->getActiveFrame(), uno::UNO_QUERY_THROW );
49 0 : uno::Reference<presentation::XPresentationSupplier> xPS ( xFrame->getController()->getModel(), uno::UNO_QUERY_THROW);
50 : xPresentation = uno::Reference<presentation::XPresentation2>(
51 0 : xPS->getPresentation(), uno::UNO_QUERY_THROW);
52 : // Throws an exception if now slideshow running
53 : xSlideShowController = uno::Reference<presentation::XSlideShowController>(
54 0 : xPresentation->getController(), uno::UNO_QUERY_THROW );
55 : }
56 0 : catch (uno::RuntimeException &)
57 : {
58 : }
59 :
60 0 : if ( aCommand[0].equals( "transition_next" ) )
61 : {
62 0 : if ( xSlideShowController.is() )
63 0 : xSlideShowController->gotoNextEffect();
64 : }
65 0 : else if ( aCommand[0].equals( "transition_previous" ) )
66 : {
67 0 : if ( xSlideShowController.is() )
68 0 : xSlideShowController->gotoPreviousEffect();
69 : }
70 0 : else if ( aCommand[0].equals( "goto_slide" ) )
71 : {
72 : // FIXME: if 0 returned, then not a valid number
73 0 : sal_Int32 aSlide = aCommand[1].toInt32();
74 0 : if ( xSlideShowController.is() &&
75 0 : xSlideShowController->getCurrentSlideIndex() != aSlide )
76 : {
77 0 : xSlideShowController->gotoSlideIndex( aSlide );
78 : }
79 : }
80 0 : else if ( aCommand[0].equals( "presentation_start" ) )
81 : {
82 0 : if ( xPresentation.is() )
83 0 : xPresentation->start();
84 : }
85 0 : else if ( aCommand[0].equals( "presentation_stop" ) )
86 : {
87 0 : if ( xPresentation.is() )
88 0 : xPresentation->end();
89 : }
90 0 : else if ( aCommand[0].equals( "presentation_blank_screen" ) )
91 : {
92 0 : sal_Int32 aColour = 0; // Default is black
93 0 : if ( aCommand.size() > 1 )
94 : {
95 : // aColour = FIXME: get the colour in some format from this string
96 : // Determine the formatting first.
97 : }
98 0 : if ( xSlideShowController.is() )
99 : {
100 0 : xSlideShowController->blankScreen( aColour );
101 : }
102 : }
103 0 : else if ( aCommand[0].equals( "presentation_resume" ) )
104 : {
105 0 : if ( xSlideShowController.is() )
106 : {
107 0 : xSlideShowController->resume();
108 : }
109 0 : }
110 0 : }
111 :
112 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|