1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "PresenterCurrentSlideObserver.hxx"
22 using namespace ::com::sun::star
;
23 using namespace ::com::sun::star::uno
;
25 namespace sdext
{ namespace presenter
{
27 //===== PresenterCurrentSlideObserver =========================================
29 PresenterCurrentSlideObserver::PresenterCurrentSlideObserver (
30 const ::rtl::Reference
<PresenterController
>& rxPresenterController
,
31 const Reference
<presentation::XSlideShowController
>& rxSlideShowController
)
32 : PresenterCurrentSlideObserverInterfaceBase(m_aMutex
),
33 mpPresenterController(rxPresenterController
),
34 mxSlideShowController(rxSlideShowController
)
36 if( mpPresenterController
.is() )
38 mpPresenterController
->addEventListener(this);
41 if( mxSlideShowController
.is() )
43 // Listen for events from the slide show controller.
44 mxSlideShowController
->addSlideShowListener(static_cast<XSlideShowListener
*>(this));
48 PresenterCurrentSlideObserver::~PresenterCurrentSlideObserver()
52 void SAL_CALL
PresenterCurrentSlideObserver::disposing()
54 // Disconnect form the slide show controller.
55 if(mxSlideShowController
.is())
57 mxSlideShowController
->removeSlideShowListener(static_cast<XSlideShowListener
*>(this));
58 mxSlideShowController
= nullptr;
62 //----- XSlideShowListener ----------------------------------------------------
64 void SAL_CALL
PresenterCurrentSlideObserver::beginEvent (
65 const Reference
<animations::XAnimationNode
>&)
68 void SAL_CALL
PresenterCurrentSlideObserver::endEvent (
69 const Reference
<animations::XAnimationNode
>&)
72 void SAL_CALL
PresenterCurrentSlideObserver::repeat (
73 const css::uno::Reference
<css::animations::XAnimationNode
>&,
77 void SAL_CALL
PresenterCurrentSlideObserver::paused()
81 void SAL_CALL
PresenterCurrentSlideObserver::resumed()
85 void SAL_CALL
PresenterCurrentSlideObserver::slideEnded (sal_Bool bReverse
)
87 // Determine whether the new current slide (the one after the one that
88 // just ended) is the slide past the last slide in the presentation,
89 // i.e. the one that says something like "click to end presentation...".
90 if (mxSlideShowController
.is() && !bReverse
)
91 if (mxSlideShowController
->getNextSlideIndex() < 0)
92 if( mpPresenterController
.is() )
93 mpPresenterController
->UpdateCurrentSlide(+1);
96 void SAL_CALL
PresenterCurrentSlideObserver::hyperLinkClicked (const OUString
&)
100 void SAL_CALL
PresenterCurrentSlideObserver::slideTransitionStarted()
102 if( mpPresenterController
.is() )
103 mpPresenterController
->UpdateCurrentSlide(0);
106 void SAL_CALL
PresenterCurrentSlideObserver::slideTransitionEnded()
110 void SAL_CALL
PresenterCurrentSlideObserver::slideAnimationsEnded()
114 //----- XEventListener --------------------------------------------------------
116 void SAL_CALL
PresenterCurrentSlideObserver::disposing (
117 const lang::EventObject
& rEvent
)
119 if (rEvent
.Source
== Reference
<XInterface
>(static_cast<XWeak
*>(mpPresenterController
.get())))
121 else if (rEvent
.Source
== mxSlideShowController
)
122 mxSlideShowController
= nullptr;
125 } } // end of namespace ::sdext::presenter
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */