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 .
21 #include <animationfactory.hxx>
22 #include "setactivity.hxx"
23 #include "animationsetnode.hxx"
24 #include "nodetools.hxx"
26 #include <delayevent.hxx>
28 using namespace com::sun::star
;
30 namespace slideshow::internal
{
32 AnimationActivitySharedPtr
AnimationSetNode::createActivity() const
34 ActivitiesFactory::CommonParameters
aParms( fillCommonParameters() );
35 uno::Reference
<animations::XAnimate
> const xAnimateNode
= getXAnimateNode();
36 OUString
const attrName( xAnimateNode
->getAttributeName() );
37 AttributableShapeSharedPtr
const pShape( getShape() );
39 // make deactivation a two-step procedure. Normally, we
40 // could solely rely on
41 // BaseNode::scheduleDeactivationEvent() to deactivate()
42 // us. Unfortunately, that method on the one hand ignores
43 // indefinite timing, on the other hand generates
44 // zero-timeout delays, which might get fired _before_ our
45 // set activity has taken place. Therefore, we enforce
46 // sequentiality by letting only the set activity schedule
47 // the deactivation event (and AnimationBaseNode
48 // takes care for the fact when mpActivity should be zero).
50 // AnimationBaseNode::fillCommonParameters() has set up
51 // immediate deactivation as default when activity ends, but
52 if (! isIndefiniteTiming( xAnimateNode
->getDuration() )) {
53 std::shared_ptr
<AnimationSetNode
> const pSelf(
54 std::dynamic_pointer_cast
<AnimationSetNode
>(getSelf()) );
56 pSelf
, "cannot cast getSelf() to my type!" );
57 aParms
.mpEndEvent
= makeEvent(
58 [pSelf
] () { pSelf
->scheduleDeactivationEvent(); },
59 u
"AnimationSetNode::scheduleDeactivationEvent"_ustr
);
62 switch (AnimationFactory::classifyAttributeName( attrName
)) {
64 case AnimationFactory::CLASS_UNKNOWN_PROPERTY
:
66 false, "AnimationSetNode::createSetActivity(): "
67 "Unexpected attribute class" );
70 case AnimationFactory::CLASS_NUMBER_PROPERTY
:
72 NumberAnimation::ValueType aValue
;
76 xAnimateNode
->getTo(),
79 "AnimationSetNode::createSetActivity(): "
80 "Could not import numeric to value" );
82 return makeSetActivity(
84 AnimationFactory::createNumberPropertyAnimation(
87 getContext().mpSubsettableShapeManager
,
89 getContext().mpBox2DWorld
,
90 AnimationFactory::FLAG_NO_SPRITE
),
94 case AnimationFactory::CLASS_ENUM_PROPERTY
:
96 EnumAnimation::ValueType aValue
;
100 xAnimateNode
->getTo(),
103 "AnimationSetNode::createSetActivity(): "
104 "Could not import enum to value" );
106 return makeSetActivity(
108 AnimationFactory::createEnumPropertyAnimation(
111 getContext().mpSubsettableShapeManager
,
113 getContext().mpBox2DWorld
,
114 AnimationFactory::FLAG_NO_SPRITE
),
118 case AnimationFactory::CLASS_COLOR_PROPERTY
:
120 ColorAnimation::ValueType aValue
;
123 extractValue( aValue
,
124 xAnimateNode
->getTo(),
127 "AnimationSetNode::createSetActivity(): "
128 "Could not import color to value" );
130 return makeSetActivity(
132 AnimationFactory::createColorPropertyAnimation(
135 getContext().mpSubsettableShapeManager
,
137 getContext().mpBox2DWorld
,
138 AnimationFactory::FLAG_NO_SPRITE
),
142 case AnimationFactory::CLASS_STRING_PROPERTY
:
144 StringAnimation::ValueType aValue
;
147 extractValue( aValue
,
148 xAnimateNode
->getTo(),
151 "AnimationSetNode::createSetActivity(): "
152 "Could not import string to value" );
154 return makeSetActivity(
156 AnimationFactory::createStringPropertyAnimation(
159 getContext().mpSubsettableShapeManager
,
161 getContext().mpBox2DWorld
,
162 AnimationFactory::FLAG_NO_SPRITE
),
166 case AnimationFactory::CLASS_BOOL_PROPERTY
:
168 BoolAnimation::ValueType aValue
;
171 extractValue( aValue
,
172 xAnimateNode
->getTo(),
175 "AnimationSetNode::createSetActivity(): "
176 "Could not import bool to value" );
178 return makeSetActivity(
180 AnimationFactory::createBoolPropertyAnimation(
183 getContext().mpSubsettableShapeManager
,
185 getContext().mpBox2DWorld
,
186 AnimationFactory::FLAG_NO_SPRITE
),
191 return AnimationActivitySharedPtr();
194 } // namespace slideshow::internal
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */