fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / slideshow / source / engine / animationnodes / generateevent.cxx
blob65a3421793b7684704da96868921906f229e4b41
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 // must be first
22 #include <canvas/debug.hxx>
23 #include <tools/diagnose_ex.h>
24 #include <canvas/verbosetrace.hxx>
26 #include <com/sun/star/drawing/XShape.hpp>
27 #include <com/sun/star/animations/XAnimationNode.hpp>
28 #include <com/sun/star/animations/Timing.hpp>
29 #include <com/sun/star/animations/EventTrigger.hpp>
30 #include <com/sun/star/animations/Event.hpp>
32 #include "generateevent.hxx"
33 #include "shape.hxx"
34 #include "subsettableshapemanager.hxx"
35 #include "usereventqueue.hxx"
36 #include "slideshowcontext.hxx"
37 #include "delayevent.hxx"
39 namespace slideshow {
40 namespace internal {
42 using namespace com::sun::star;
44 EventSharedPtr generateEvent(
45 uno::Any const& rEventDescription,
46 Delay::FunctorT const& rFunctor,
47 SlideShowContext const& rContext,
48 double nAdditionalDelay )
50 EventSharedPtr pEvent;
52 if (! rEventDescription.hasValue())
53 return pEvent;
55 animations::Timing eTiming;
56 animations::Event aEvent;
57 uno::Sequence<uno::Any> aSequence;
58 double nDelay1 = 0;
60 if (rEventDescription >>= eTiming) {
61 switch (eTiming) {
62 case animations::Timing_INDEFINITE:
63 break; // don't schedule no event
64 case animations::Timing_MEDIA:
65 OSL_FAIL( "MEDIA timing not yet implemented!" );
66 break;
67 default:
68 ENSURE_OR_THROW( false, "unexpected case!" );
71 else if (rEventDescription >>= aEvent) {
73 // try to extract additional event delay
74 double nDelay2 = 0.0;
75 if (aEvent.Offset.hasValue() && !(aEvent.Offset >>= nDelay2)) {
76 OSL_FAIL( "offset values apart from DOUBLE not "
77 "recognized in animations::Event!" );
80 // common vars used inside switch
81 uno::Reference<animations::XAnimationNode> xNode;
82 uno::Reference<drawing::XShape> xShape;
83 ShapeSharedPtr pShape;
85 // TODO(F1): Respect aEvent.Repeat value
87 switch (aEvent.Trigger) {
88 default:
89 ENSURE_OR_THROW( false, "unexpected event trigger!" );
90 case animations::EventTrigger::NONE:
91 // no event at all
92 break;
93 case animations::EventTrigger::ON_BEGIN:
94 OSL_FAIL( "event trigger ON_BEGIN not yet implemented!" );
95 break;
96 case animations::EventTrigger::ON_END:
97 OSL_FAIL( "event trigger ON_END not yet implemented!" );
98 break;
99 case animations::EventTrigger::BEGIN_EVENT:
100 // try to extract XAnimationNode event source
101 if (aEvent.Source >>= xNode) {
102 pEvent = makeDelay( rFunctor,
103 nDelay2 + nAdditionalDelay,
104 "generateEvent, BEGIN_EVENT");
105 rContext.mrUserEventQueue.registerAnimationStartEvent(
106 pEvent, xNode );
108 else {
109 OSL_FAIL("could not extract source XAnimationNode "
110 "for BEGIN_EVENT!" );
112 break;
113 case animations::EventTrigger::END_EVENT:
114 // try to extract XAnimationNode event source
115 if (aEvent.Source >>= xNode) {
116 pEvent = makeDelay( rFunctor,
117 nDelay2 + nAdditionalDelay,
118 "generateEvent, END_EVENT");
119 rContext.mrUserEventQueue.registerAnimationEndEvent(
120 pEvent, xNode );
122 else {
123 OSL_FAIL( "could not extract source XAnimationNode "
124 "for END_EVENT!" );
126 break;
127 case animations::EventTrigger::ON_CLICK:
128 // try to extract XShape event source
129 if ((aEvent.Source >>= xShape) &&
130 (pShape = rContext.mpSubsettableShapeManager->lookupShape(xShape)).get())
132 pEvent = makeDelay( rFunctor,
133 nDelay2 + nAdditionalDelay,
134 "generateEvent, ON_CLICK");
135 rContext.mrUserEventQueue.registerShapeClickEvent(
136 pEvent, pShape );
138 else {
139 OSL_FAIL( "could not extract source XAnimationNode "
140 "for ON_CLICK!" );
142 break;
143 case animations::EventTrigger::ON_DBL_CLICK:
144 // try to extract XShape event source
145 if ((aEvent.Source >>= xShape) &&
146 (pShape = rContext.mpSubsettableShapeManager->lookupShape(xShape)).get())
148 pEvent = makeDelay( rFunctor,
149 nDelay2 + nAdditionalDelay,
150 "generateEvent, ON_DBL_CLICK");
151 rContext.mrUserEventQueue.registerShapeDoubleClickEvent(
152 pEvent, pShape );
154 else {
155 OSL_FAIL( "could not extract source XAnimationNode "
156 "for ON_DBL_CLICK!" );
158 break;
159 case animations::EventTrigger::ON_MOUSE_ENTER:
160 // try to extract XShape event source
161 if ((aEvent.Source >>= xShape) &&
162 (pShape = rContext.mpSubsettableShapeManager->lookupShape(xShape)).get())
164 pEvent = makeDelay( rFunctor,
165 nDelay2 + nAdditionalDelay,
166 "generateEvent, ON_MOUSE_ENTER");
167 rContext.mrUserEventQueue.registerMouseEnterEvent(
168 pEvent, pShape );
170 else {
171 OSL_FAIL( "could not extract source XAnimationNode "
172 "for ON_MOUSE_ENTER!" );
174 break;
175 case animations::EventTrigger::ON_MOUSE_LEAVE:
176 // try to extract XShape event source
177 if ((aEvent.Source >>= xShape) &&
178 (pShape = rContext.mpSubsettableShapeManager->lookupShape(xShape)).get())
180 pEvent = makeDelay( rFunctor,
181 nDelay2 + nAdditionalDelay,
182 "generateEvent, ON_MOUSE_LEAVE");
183 rContext.mrUserEventQueue.registerMouseLeaveEvent(
184 pEvent, pShape );
186 else {
187 OSL_FAIL( "could not extract source XAnimationNode "
188 "for ON_MOUSE_LEAVE!" );
190 break;
191 case animations::EventTrigger::ON_PREV:
192 OSL_FAIL( "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,
197 nDelay2 + nAdditionalDelay,
198 "generateEvent, ON_NEXT");
199 rContext.mrUserEventQueue.registerNextEffectEvent( pEvent );
200 break;
201 case animations::EventTrigger::ON_STOP_AUDIO:
202 // try to extract XAnimationNode event source
203 if (aEvent.Source >>= xNode) {
204 pEvent = makeDelay( rFunctor,
205 nDelay2 + nAdditionalDelay,
206 "generateEvent, ON_STOP_AUDIO");
207 rContext.mrUserEventQueue.registerAudioStoppedEvent(
208 pEvent, xNode );
210 else {
211 OSL_FAIL( "could not extract source XAnimationNode "
212 "for ON_STOP_AUDIO!" );
214 break;
215 case animations::EventTrigger::REPEAT:
216 OSL_FAIL( "event trigger REPEAT not yet implemented!" );
217 break;
220 else if (rEventDescription >>= aSequence) {
221 OSL_FAIL( "sequence of timing primitives "
222 "not yet implemented!" );
224 else if (rEventDescription >>= nDelay1) {
225 pEvent = makeDelay( rFunctor,
226 nDelay1 + nAdditionalDelay,
227 "generateEvent with delay");
228 // schedule delay event
229 rContext.mrEventQueue.addEvent( pEvent );
232 return pEvent;
235 } // namespace internal
236 } // namespace slideshow
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */