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 
10 #include <sal/log.hxx>
11 #include <vcl/svapp.hxx>
12 
13 #include "Communicator.hxx"
14 #include "Listener.hxx"
15 #include "ImagePreparer.hxx"
16 #include "Transmitter.hxx"
17 
18 #include <com/sun/star/presentation/XSlideShowController.hpp>
19 
20 using namespace sd;
21 using namespace ::com::sun::star::presentation;
22 
Listener(const::rtl::Reference<Communicator> & rCommunicator,sd::Transmitter * aTransmitter)23 Listener::Listener( const ::rtl::Reference<Communicator>& rCommunicator,
24                     sd::Transmitter *aTransmitter  ):
25       ::cppu::WeakComponentImplHelper< XSlideShowListener >( m_aMutex ),
26       mCommunicator( rCommunicator ),
27       pTransmitter( nullptr )
28 {
29     pTransmitter = aTransmitter;
30 }
31 
~Listener()32 Listener::~Listener()
33 {
34 }
35 
init(const css::uno::Reference<css::presentation::XSlideShowController> & aController)36 void Listener::init( const css::uno::Reference< css::presentation::XSlideShowController >& aController)
37 {
38     if ( aController.is() )
39     {
40         mController.set( aController );
41         aController->addSlideShowListener( this );
42 
43         sal_Int32 aSlides = aController->getSlideCount();
44         sal_Int32 aCurrentSlide = aController->getCurrentSlideIndex();
45         OString aBuffer = "slideshow_started\n" +
46             OString::number( aSlides ) + "\n" +
47             OString::number( aCurrentSlide ) + "\n\n";
48 
49         pTransmitter->addMessage( aBuffer,
50                                   Transmitter::PRIORITY_HIGH );
51 
52         {
53             SolarMutexGuard aGuard;
54             /* ImagePreparer* pPreparer = */ new ImagePreparer( aController, pTransmitter );
55         }
56     }
57     else
58     {
59         SAL_INFO( "sdremote", "Listener::init but no controller - so no preview push queued" );
60     }
61 }
62 
63 //----- XAnimationListener ----------------------------------------------------
64 
beginEvent(const css::uno::Reference<css::animations::XAnimationNode> &)65 void SAL_CALL Listener::beginEvent(const css::uno::Reference<
66     css::animations::XAnimationNode >& )
67 {}
68 
endEvent(const css::uno::Reference<css::animations::XAnimationNode> &)69 void SAL_CALL Listener::endEvent( const css::uno::Reference<
70     css::animations::XAnimationNode >& )
71 {}
72 
repeat(const css::uno::Reference<css::animations::XAnimationNode> &,::sal_Int32)73 void SAL_CALL Listener::repeat( const css::uno::Reference<
74     css::animations::XAnimationNode >&, ::sal_Int32 )
75 {}
76 
77 //----- XSlideShowListener ----------------------------------------------------
78 
paused()79 void SAL_CALL Listener::paused()
80 {
81 }
82 
resumed()83 void SAL_CALL Listener::resumed()
84 {
85 }
86 
slideEnded(sal_Bool)87 void SAL_CALL Listener::slideEnded (sal_Bool)
88 {
89 }
90 
hyperLinkClicked(const OUString &)91 void SAL_CALL Listener::hyperLinkClicked (const OUString &)
92 {
93 }
94 
slideTransitionStarted()95 void SAL_CALL Listener::slideTransitionStarted()
96 {
97     sal_Int32 aSlide = mController->getCurrentSlideIndex();
98 
99     OString aBuilder = "slide_updated\n" +
100         OString::number( aSlide ) +
101         "\n\n";
102 
103     if ( pTransmitter )
104     {
105         pTransmitter->addMessage( aBuilder,
106                                Transmitter::PRIORITY_HIGH );
107     }
108 }
109 
slideTransitionEnded()110 void SAL_CALL Listener::slideTransitionEnded()
111 {
112 }
113 
slideAnimationsEnded()114 void SAL_CALL Listener::slideAnimationsEnded()
115 {
116 }
117 
disposing()118 void SAL_CALL Listener::disposing()
119 {
120     pTransmitter = nullptr;
121     if ( mController.is() )
122     {
123         mController->removeSlideShowListener( this );
124         mController = nullptr;
125     }
126     mCommunicator->informListenerDestroyed();
127 }
128 
disposing(const css::lang::EventObject &)129 void SAL_CALL Listener::disposing (
130     const css::lang::EventObject&)
131 {
132     dispose();
133 }
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
135