1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sdext.hxx"
30 
31 #include "PresenterCurrentSlideObserver.hxx"
32 
33 using namespace ::com::sun::star;
34 using namespace ::com::sun::star::uno;
35 using ::rtl::OUString;
36 
37 namespace sdext { namespace presenter {
38 
39 //===== PresenterCurrentSlideObserver =========================================
40 
41 PresenterCurrentSlideObserver::PresenterCurrentSlideObserver (
42     const ::rtl::Reference<PresenterController>& rxPresenterController,
43     const Reference<presentation::XSlideShowController>& rxSlideShowController)
44     : PresenterCurrentSlideObserverInterfaceBase(m_aMutex),
45       mpPresenterController(rxPresenterController),
46       mxSlideShowController(rxSlideShowController)
47 {
48 	if( mpPresenterController.is() )
49 	{
50 		mpPresenterController->addEventListener(this);
51 	}
52 
53 	if( mxSlideShowController.is() )
54 	{
55 		// Listen for events from the slide show controller.
56 	    mxSlideShowController->addSlideShowListener(static_cast<XSlideShowListener*>(this));
57 	}
58 }
59 
60 PresenterCurrentSlideObserver::~PresenterCurrentSlideObserver (void)
61 {
62 }
63 
64 void SAL_CALL PresenterCurrentSlideObserver::disposing (void)
65 {
66     // Disconnect form the slide show controller.
67     if(mxSlideShowController.is())
68     {
69         mxSlideShowController->removeSlideShowListener(static_cast<XSlideShowListener*>(this));
70         mxSlideShowController = NULL;
71     }
72 }
73 
74 //----- XSlideShowListener ----------------------------------------------------
75 
76 void SAL_CALL PresenterCurrentSlideObserver::beginEvent (
77     const Reference<animations::XAnimationNode>& rNode)
78     throw (css::uno::RuntimeException)
79 {
80     (void)rNode;
81 }
82 
83 void SAL_CALL PresenterCurrentSlideObserver::endEvent (
84     const Reference<animations::XAnimationNode>& rNode)
85     throw(css::uno::RuntimeException)
86 {
87     (void)rNode;
88 }
89 
90 void SAL_CALL PresenterCurrentSlideObserver::repeat (
91     const css::uno::Reference<css::animations::XAnimationNode>& rNode,
92     sal_Int32)
93     throw (com::sun::star::uno::RuntimeException)
94 {
95     (void)rNode;
96 }
97 
98 void SAL_CALL PresenterCurrentSlideObserver::paused (void)
99     throw (com::sun::star::uno::RuntimeException)
100 {
101 }
102 
103 void SAL_CALL PresenterCurrentSlideObserver::resumed (void)
104     throw (css::uno::RuntimeException)
105 {
106 }
107 
108 void SAL_CALL PresenterCurrentSlideObserver::slideEnded (sal_Bool bReverse)
109     throw (css::uno::RuntimeException)
110 {
111     // Determine whether the new current slide (the one after the one that
112     // just ended) is the slide past the last slide in the presentation,
113     // i.e. the one that says something like "click to end presentation...".
114     if (mxSlideShowController.is() && !bReverse)
115         if (mxSlideShowController->getNextSlideIndex() < 0)
116             if( mpPresenterController.is() )
117                 mpPresenterController->UpdateCurrentSlide(+1);
118 }
119 
120 void SAL_CALL PresenterCurrentSlideObserver::hyperLinkClicked (const rtl::OUString &)
121     throw (css::uno::RuntimeException)
122 {
123 }
124 
125 void SAL_CALL PresenterCurrentSlideObserver::slideTransitionStarted (void)
126     throw (css::uno::RuntimeException)
127 {
128 	if( mpPresenterController.is() )
129 		mpPresenterController->UpdateCurrentSlide(0);
130 }
131 
132 void SAL_CALL PresenterCurrentSlideObserver::slideTransitionEnded (void)
133     throw (css::uno::RuntimeException)
134 {
135 }
136 
137 void SAL_CALL PresenterCurrentSlideObserver::slideAnimationsEnded (void)
138     throw (css::uno::RuntimeException)
139 {
140 }
141 
142 //----- XEventListener --------------------------------------------------------
143 
144 void SAL_CALL PresenterCurrentSlideObserver::disposing (
145     const lang::EventObject& rEvent)
146     throw (RuntimeException)
147 {
148     if (rEvent.Source == Reference<XInterface>(static_cast<XWeak*>(mpPresenterController.get())))
149         dispose();
150     else if (rEvent.Source == mxSlideShowController)
151         mxSlideShowController = NULL;
152 }
153 
154 } } // end of namespace ::sdext::presenter
155