1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: generateevent.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_slideshow.hxx"
35 #include <canvas/debug.hxx>
36 #include <tools/diagnose_ex.h>
37 #include <canvas/verbosetrace.hxx>
39 #include <com/sun/star/drawing/XShape.hpp>
40 #include <com/sun/star/animations/XAnimationNode.hpp>
41 #include <com/sun/star/animations/Timing.hpp>
42 #include <com/sun/star/animations/EventTrigger.hpp>
43 #include <com/sun/star/animations/Event.hpp>
46 #include "subsettableshapemanager.hxx"
47 #include "usereventqueue.hxx"
48 #include "slideshowcontext.hxx"
49 #include "delayevent.hxx"
54 using namespace com::sun::star
;
56 EventSharedPtr
generateEvent(
57 uno::Any
const& rEventDescription
,
58 Delay::FunctorT
const& rFunctor
,
59 SlideShowContext
const& rContext
,
60 double nAdditionalDelay
)
62 EventSharedPtr pEvent
;
64 if (! rEventDescription
.hasValue())
67 animations::Timing eTiming
;
68 animations::Event aEvent
;
69 uno::Sequence
<uno::Any
> aSequence
;
72 if (rEventDescription
>>= eTiming
) {
74 case animations::Timing_INDEFINITE
:
75 break; // don't schedule no event
76 case animations::Timing_MEDIA
:
77 OSL_ENSURE( false, "MEDIA timing not yet implemented!" );
80 ENSURE_OR_THROW( false, "unexpected case!" );
83 else if (rEventDescription
>>= aEvent
) {
85 // try to extract additional event delay
87 if (aEvent
.Offset
.hasValue() && !(aEvent
.Offset
>>= nDelay2
)) {
88 OSL_ENSURE( false, "offset values apart from DOUBLE not "
89 "recognized in animations::Event!" );
92 // common vars used inside switch
93 uno::Reference
<animations::XAnimationNode
> xNode
;
94 uno::Reference
<drawing::XShape
> xShape
;
95 ShapeSharedPtr pShape
;
97 // TODO(F1): Respect aEvent.Repeat value
99 switch (aEvent
.Trigger
) {
101 ENSURE_OR_THROW( false, "unexpected event trigger!" );
102 case animations::EventTrigger::NONE
:
105 case animations::EventTrigger::ON_BEGIN
:
106 OSL_ENSURE( false, "event trigger ON_BEGIN not yet implemented!" );
108 case animations::EventTrigger::ON_END
:
109 OSL_ENSURE( false, "event trigger ON_END not yet implemented!" );
111 case animations::EventTrigger::BEGIN_EVENT
:
112 // try to extract XAnimationNode event source
113 if (aEvent
.Source
>>= xNode
) {
114 pEvent
= makeDelay( rFunctor
, nDelay2
+ nAdditionalDelay
);
115 rContext
.mrUserEventQueue
.registerAnimationStartEvent(
119 OSL_ENSURE(false, "could not extract source XAnimationNode "
120 "for BEGIN_EVENT!" );
123 case animations::EventTrigger::END_EVENT
:
124 // try to extract XAnimationNode event source
125 if (aEvent
.Source
>>= xNode
) {
126 pEvent
= makeDelay( rFunctor
, nDelay2
+ nAdditionalDelay
);
127 rContext
.mrUserEventQueue
.registerAnimationEndEvent(
131 OSL_ENSURE( false, "could not extract source XAnimationNode "
135 case animations::EventTrigger::ON_CLICK
:
136 // try to extract XShape event source
137 if ((aEvent
.Source
>>= xShape
) &&
138 (pShape
= rContext
.mpSubsettableShapeManager
->lookupShape(xShape
)).get())
140 pEvent
= makeDelay( rFunctor
, nDelay2
+ nAdditionalDelay
);
141 rContext
.mrUserEventQueue
.registerShapeClickEvent(
145 OSL_ENSURE( false, "could not extract source XAnimationNode "
149 case animations::EventTrigger::ON_DBL_CLICK
:
150 // try to extract XShape event source
151 if ((aEvent
.Source
>>= xShape
) &&
152 (pShape
= rContext
.mpSubsettableShapeManager
->lookupShape(xShape
)).get())
154 pEvent
= makeDelay( rFunctor
, nDelay2
+ nAdditionalDelay
);
155 rContext
.mrUserEventQueue
.registerShapeDoubleClickEvent(
159 OSL_ENSURE( false, "could not extract source XAnimationNode "
160 "for ON_DBL_CLICK!" );
163 case animations::EventTrigger::ON_MOUSE_ENTER
:
164 // try to extract XShape event source
165 if ((aEvent
.Source
>>= xShape
) &&
166 (pShape
= rContext
.mpSubsettableShapeManager
->lookupShape(xShape
)).get())
168 pEvent
= makeDelay( rFunctor
, nDelay2
+ nAdditionalDelay
);
169 rContext
.mrUserEventQueue
.registerMouseEnterEvent(
173 OSL_ENSURE( false, "could not extract source XAnimationNode "
174 "for ON_MOUSE_ENTER!" );
177 case animations::EventTrigger::ON_MOUSE_LEAVE
:
178 // try to extract XShape event source
179 if ((aEvent
.Source
>>= xShape
) &&
180 (pShape
= rContext
.mpSubsettableShapeManager
->lookupShape(xShape
)).get())
182 pEvent
= makeDelay( rFunctor
, nDelay2
+ nAdditionalDelay
);
183 rContext
.mrUserEventQueue
.registerMouseLeaveEvent(
187 OSL_ENSURE( false, "could not extract source XAnimationNode "
188 "for ON_MOUSE_LEAVE!" );
191 case animations::EventTrigger::ON_PREV
:
192 OSL_ENSURE( false, "event trigger ON_PREV not yet implemented, "
193 "mapped to ON_NEXT!" );
194 // FALLTHROUGH intended
195 case animations::EventTrigger::ON_NEXT
:
196 pEvent
= makeDelay( rFunctor
, nDelay2
+ nAdditionalDelay
);
197 rContext
.mrUserEventQueue
.registerNextEffectEvent( pEvent
);
199 case animations::EventTrigger::ON_STOP_AUDIO
:
200 // try to extract XAnimationNode event source
201 if (aEvent
.Source
>>= xNode
) {
202 pEvent
= makeDelay( rFunctor
, nDelay2
+ nAdditionalDelay
);
203 rContext
.mrUserEventQueue
.registerAudioStoppedEvent(
207 OSL_ENSURE( false, "could not extract source XAnimationNode "
208 "for ON_STOP_AUDIO!" );
211 case animations::EventTrigger::REPEAT
:
212 OSL_ENSURE( false, "event trigger REPEAT not yet implemented!" );
216 else if (rEventDescription
>>= aSequence
) {
217 OSL_ENSURE( false, "sequence of timing primitives "
218 "not yet implemented!" );
220 else if (rEventDescription
>>= nDelay1
) {
221 pEvent
= makeDelay( rFunctor
, nDelay1
+ nAdditionalDelay
);
222 // schedule delay event
223 rContext
.mrEventQueue
.addEvent( pEvent
);
229 } // namespace internal
230 } // namespace slideshow