LibreOffice Module slideshow (master) 1
animationsetnode.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
21#include <animationfactory.hxx>
22#include "setactivity.hxx"
23#include "animationsetnode.hxx"
24#include "nodetools.hxx"
25#include <tools.hxx>
26#include <delayevent.hxx>
27
28using namespace com::sun::star;
29
30namespace slideshow::internal {
31
33{
36 OUString const attrName( xAnimateNode->getAttributeName() );
37 AttributableShapeSharedPtr const pShape( getShape() );
38
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).
49
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 "AnimationSetNode::scheduleDeactivationEvent");
60 }
61
63 default:
66 false, "AnimationSetNode::createSetActivity(): "
67 "Unexpected attribute class" );
68 break;
69
71 {
73
75 extractValue( aValue,
76 xAnimateNode->getTo(),
77 pShape,
78 getSlideSize() ),
79 "AnimationSetNode::createSetActivity(): "
80 "Could not import numeric to value" );
81
82 return makeSetActivity(
83 aParms,
86 pShape,
91 aValue );
92 }
93
95 {
97
99 extractValue( aValue,
100 xAnimateNode->getTo(),
101 pShape,
102 getSlideSize() ),
103 "AnimationSetNode::createSetActivity(): "
104 "Could not import enum to value" );
105
106 return makeSetActivity(
107 aParms,
109 attrName,
110 pShape,
112 getSlideSize(),
115 aValue );
116 }
117
119 {
121
123 extractValue( aValue,
124 xAnimateNode->getTo(),
125 pShape,
126 getSlideSize() ),
127 "AnimationSetNode::createSetActivity(): "
128 "Could not import color to value" );
129
130 return makeSetActivity(
131 aParms,
133 attrName,
134 pShape,
136 getSlideSize(),
139 aValue );
140 }
141
143 {
145
147 extractValue( aValue,
148 xAnimateNode->getTo(),
149 pShape,
150 getSlideSize() ),
151 "AnimationSetNode::createSetActivity(): "
152 "Could not import string to value" );
153
154 return makeSetActivity(
155 aParms,
157 attrName,
158 pShape,
160 getSlideSize(),
163 aValue );
164 }
165
167 {
169
171 extractValue( aValue,
172 xAnimateNode->getTo(),
173 pShape,
174 getSlideSize() ),
175 "AnimationSetNode::createSetActivity(): "
176 "Could not import bool to value" );
177
178 return makeSetActivity(
179 aParms,
181 attrName,
182 pShape,
184 getSlideSize(),
187 aValue );
188 }
189 }
190
192}
193
194} // namespace slideshow::internal
195
196/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
box2d::utils::Box2DWorldSharedPtr mpBox2DWorld
AttributableShapeSharedPtr const & getShape() const
::basegfx::B2DVector const & getSlideSize() const
css::uno::Reference< css::animations::XAnimate > const & getXAnimateNode() const
ActivitiesFactory::CommonParameters fillCommonParameters() const
Create parameter struct for ActivitiesFactory.
virtual AnimationActivitySharedPtr createActivity() const override
SlideShowContext const & getContext() const
Definition: basenode.hxx:135
::std::shared_ptr< BaseNode > const & getSelf() const
Definition: basenode.hxx:136
RGB color space class.
Definition: rgbcolor.hxx:35
#define makeEvent(f, d)
Definition: delayevent.hxx:131
#define ENSURE_OR_THROW(c, m)
const char * attrName
@ FLAG_NO_SPRITE
Don't call enter/leaveAnimation for the Shape.
NumberAnimationSharedPtr createNumberPropertyAnimation(const OUString &rAttrName, const AnimatableShapeSharedPtr &rShape, const ShapeManagerSharedPtr &rShapeManager, const ::basegfx::B2DVector &rSlideSize, const box2d::utils::Box2DWorldSharedPtr &pBox2DWorld, int nFlags=0)
AttributeClass classifyAttributeName(const OUString &rAttrName)
ColorAnimationSharedPtr createColorPropertyAnimation(const OUString &rAttrName, const AnimatableShapeSharedPtr &rShape, const ShapeManagerSharedPtr &rShapeManager, const ::basegfx::B2DVector &rSlideSize, const box2d::utils::Box2DWorldSharedPtr &pBox2DWorld, int nFlags=0)
@ CLASS_STRING_PROPERTY
Use createStringPropertyAnimation.
@ CLASS_UNKNOWN_PROPERTY
Unknown, prolly invalid name.
@ CLASS_COLOR_PROPERTY
Use createColorPropertyAnimation.
@ CLASS_BOOL_PROPERTY
Use createBoolPropertyAnimation.
@ CLASS_NUMBER_PROPERTY
Use createNumberPropertyAnimation.
@ CLASS_ENUM_PROPERTY
Use createEnumPropertyAnimation.
BoolAnimationSharedPtr createBoolPropertyAnimation(const OUString &rAttrName, const AnimatableShapeSharedPtr &rShape, const ShapeManagerSharedPtr &rShapeManager, const ::basegfx::B2DVector &rSlideSize, const box2d::utils::Box2DWorldSharedPtr &pBox2DWorld, int nFlags)
EnumAnimationSharedPtr createEnumPropertyAnimation(const OUString &rAttrName, const AnimatableShapeSharedPtr &rShape, const ShapeManagerSharedPtr &rShapeManager, const ::basegfx::B2DVector &rSlideSize, const box2d::utils::Box2DWorldSharedPtr &pBox2DWorld, int nFlags)
StringAnimationSharedPtr createStringPropertyAnimation(const OUString &rAttrName, const AnimatableShapeSharedPtr &rShape, const ShapeManagerSharedPtr &rShapeManager, const ::basegfx::B2DVector &rSlideSize, const box2d::utils::Box2DWorldSharedPtr &pBox2DWorld, int nFlags)
bool isIndefiniteTiming(const uno::Any &rAny)
Definition: nodetools.cxx:72
::std::shared_ptr< AnimationActivity > AnimationActivitySharedPtr
AnimationActivitySharedPtr makeSetActivity(const ActivitiesFactory::CommonParameters &rParms, const ::std::shared_ptr< AnimationT > &rAnimation, const typename AnimationT::ValueType &rToValue)
::std::shared_ptr< AttributableShape > AttributableShapeSharedPtr
bool extractValue(double &o_rValue, const uno::Any &rSourceAny, const ShapeSharedPtr &rShape, const ::basegfx::B2DVector &rSlideBounds)
extract unary double value from Any
Definition: tools.cxx:137
std::shared_ptr< SubsettableShapeManager > mpSubsettableShapeManager
Definition: slideimpl.cxx:199
EventSharedPtr mpEndEvent
End event to fire when animation is over.