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
;
33 AnimationActivitySharedPtr
AnimationSetNode::createActivity() const
35 ActivitiesFactory::CommonParameters
aParms( fillCommonParameters() );
36 uno::Reference
<animations::XAnimate
> const xAnimateNode
= getXAnimateNode();
37 OUString
const attrName( xAnimateNode
->getAttributeName() );
38 AttributableShapeSharedPtr
const pShape( getShape() );
40 // make deactivation a two-step procedure. Normally, we
41 // could solely rely on
42 // BaseNode::scheduleDeactivationEvent() to deactivate()
43 // us. Unfortunately, that method on the one hand ignores
44 // indefinite timing, on the other hand generates
45 // zero-timeout delays, which might get fired _before_ our
46 // set activity has taken place. Therefore, we enforce
47 // sequentiality by letting only the set activity schedule
48 // the deactivation event (and AnimationBaseNode
49 // takes care for the fact when mpActivity should be zero).
51 // AnimationBaseNode::fillCommonParameters() has set up
52 // immediate deactivation as default when activity ends, but
53 if (! isIndefiniteTiming( xAnimateNode
->getDuration() )) {
54 std::shared_ptr
<AnimationSetNode
> const pSelf(
55 std::dynamic_pointer_cast
<AnimationSetNode
>(getSelf()) );
57 pSelf
, "cannot cast getSelf() to my type!" );
58 aParms
.mpEndEvent
= makeEvent(
59 [pSelf
] () { pSelf
->scheduleDeactivationEvent(); },
60 "AnimationSetNode::scheduleDeactivationEvent");
63 switch (AnimationFactory::classifyAttributeName( attrName
)) {
65 case AnimationFactory::CLASS_UNKNOWN_PROPERTY
:
67 false, "AnimationSetNode::createSetActivity(): "
68 "Unexpected attribute class" );
71 case AnimationFactory::CLASS_NUMBER_PROPERTY
:
73 NumberAnimation::ValueType aValue
;
77 xAnimateNode
->getTo(),
80 "AnimationSetNode::createSetActivity(): "
81 "Could not import numeric to value" );
83 return makeSetActivity(
85 AnimationFactory::createNumberPropertyAnimation(
88 getContext().mpSubsettableShapeManager
,
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 AnimationFactory::FLAG_NO_SPRITE
),
117 case AnimationFactory::CLASS_COLOR_PROPERTY
:
119 ColorAnimation::ValueType aValue
;
122 extractValue( aValue
,
123 xAnimateNode
->getTo(),
126 "AnimationSetNode::createSetActivity(): "
127 "Could not import color to value" );
129 return makeSetActivity(
131 AnimationFactory::createColorPropertyAnimation(
134 getContext().mpSubsettableShapeManager
,
136 AnimationFactory::FLAG_NO_SPRITE
),
140 case AnimationFactory::CLASS_STRING_PROPERTY
:
142 StringAnimation::ValueType aValue
;
145 extractValue( aValue
,
146 xAnimateNode
->getTo(),
149 "AnimationSetNode::createSetActivity(): "
150 "Could not import string to value" );
152 return makeSetActivity(
154 AnimationFactory::createStringPropertyAnimation(
157 getContext().mpSubsettableShapeManager
,
159 AnimationFactory::FLAG_NO_SPRITE
),
163 case AnimationFactory::CLASS_BOOL_PROPERTY
:
165 BoolAnimation::ValueType aValue
;
168 extractValue( aValue
,
169 xAnimateNode
->getTo(),
172 "AnimationSetNode::createSetActivity(): "
173 "Could not import bool to value" );
175 return makeSetActivity(
177 AnimationFactory::createBoolPropertyAnimation(
180 getContext().mpSubsettableShapeManager
,
182 AnimationFactory::FLAG_NO_SPRITE
),
187 return AnimationActivitySharedPtr();
190 } // namespace internal
191 } // namespace slideshow
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */