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 <com/sun/star/presentation/EffectCommands.hpp>
22 #include <com/sun/star/beans/PropertyValue.hpp>
24 #include "animationcommandnode.hxx"
25 #include <delayevent.hxx>
27 #include "nodetools.hxx"
30 using namespace com::sun::star
;
35 namespace EffectCommands
= css::presentation::EffectCommands
;
37 AnimationCommandNode::AnimationCommandNode( uno::Reference
<animations::XAnimationNode
> const& xNode
,
38 ::std::shared_ptr
<BaseContainerNode
> const& pParent
,
39 NodeContext
const& rContext
) :
40 BaseNode( xNode
, pParent
, rContext
),
43 mxCommandNode( xNode
, css::uno::UNO_QUERY_THROW
)
45 uno::Reference
< drawing::XShape
> xShape( mxCommandNode
->getTarget(),
47 ShapeSharedPtr
pShape( getContext().mpSubsettableShapeManager
->lookupShape( xShape
) );
48 mpShape
= ::std::dynamic_pointer_cast
< IExternalMediaShapeBase
>( pShape
);
51 void AnimationCommandNode::dispose()
53 mxCommandNode
.clear();
58 void AnimationCommandNode::activate_st()
60 switch( mxCommandNode
->getCommand() ) {
61 // the command is user defined
62 case EffectCommands::CUSTOM
: break;
63 // the command is an ole verb.
64 case EffectCommands::VERB
: break;
65 // the command starts playing on a media object
66 case EffectCommands::PLAY
:
68 double fMediaTime
=0.0;
69 beans::PropertyValue aMediaTime
;
70 if( (mxCommandNode
->getParameter() >>= aMediaTime
) && aMediaTime
.Name
== "MediaTime" )
72 aMediaTime
.Value
>>= fMediaTime
;
76 mpShape
->setMediaTime(fMediaTime
/1000.0);
81 // the command toggles the pause status on a media object
82 case EffectCommands::TOGGLEPAUSE
:
86 if( mpShape
->isPlaying() )
94 // the command stops the animation on a media object
95 case EffectCommands::STOP
:
101 // the command stops all currently running sound effects
102 case EffectCommands::STOPAUDIO
:
103 getContext().mrEventMultiplexer
.notifyCommandStopAudio( getSelf() );
108 auto self(getSelf());
109 scheduleDeactivationEvent(
110 makeEvent( [self
] () { self
->deactivate(); },
111 "AnimationCommandNode::deactivate" ) );
114 void AnimationCommandNode::deactivate_st( NodeState
/*eDestState*/ )
116 switch( mxCommandNode
->getCommand() ) {
117 // the command toggles the pause status on a media object
118 case EffectCommands::TOGGLEPAUSE
:
120 if (mpShape
&& mbToggled
)
122 if( mpShape
->isPlaying() )
134 bool AnimationCommandNode::hasPendingAnimation() const
136 return mxCommandNode
->getCommand() == EffectCommands::STOPAUDIO
|| mpShape
;
139 } // namespace internal
140 } // namespace slideshow
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */