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 .
22 #include <canvas/debug.hxx>
23 #include <canvas/verbosetrace.hxx>
24 #include <com/sun/star/presentation/EffectCommands.hpp>
25 #include <com/sun/star/animations/XAnimate.hpp>
26 #include <com/sun/star/beans/PropertyValue.hpp>
28 #include "animationcommandnode.hxx"
29 #include "delayevent.hxx"
31 #include "nodetools.hxx"
33 #include <boost/bind.hpp>
35 using namespace com::sun::star
;
40 namespace EffectCommands
= com::sun::star::presentation::EffectCommands
;
42 AnimationCommandNode::AnimationCommandNode( uno::Reference
<animations::XAnimationNode
> const& xNode
,
43 ::boost::shared_ptr
<BaseContainerNode
> const& pParent
,
44 NodeContext
const& rContext
) :
45 BaseNode( xNode
, pParent
, rContext
),
47 mxCommandNode( xNode
, ::com::sun::star::uno::UNO_QUERY_THROW
)
49 uno::Reference
< drawing::XShape
> xShape( mxCommandNode
->getTarget(),
51 ShapeSharedPtr
pShape( getContext().mpSubsettableShapeManager
->lookupShape( xShape
) );
52 mpShape
= ::boost::dynamic_pointer_cast
< IExternalMediaShapeBase
>( pShape
);
55 void AnimationCommandNode::dispose()
57 mxCommandNode
.clear();
62 void AnimationCommandNode::activate_st()
64 switch( mxCommandNode
->getCommand() ) {
65 // the command is user defined
66 case EffectCommands::CUSTOM
: break;
67 // the command is an ole verb.
68 case EffectCommands::VERB
: break;
69 // the command starts playing on a media object
70 case EffectCommands::PLAY
:
72 double fMediaTime
=0.0;
73 beans::PropertyValue aMediaTime
;
74 if( (mxCommandNode
->getParameter() >>= aMediaTime
) && aMediaTime
.Name
== "MediaTime" )
76 aMediaTime
.Value
>>= fMediaTime
;
80 mpShape
->setMediaTime(fMediaTime
/1000.0);
85 // the command toggles the pause status on a media object
86 case EffectCommands::TOGGLEPAUSE
:
90 if( mpShape
->isPlaying() )
97 // the command stops the animation on a media object
98 case EffectCommands::STOP
:
104 // the command stops all currently running sound effects
105 case EffectCommands::STOPAUDIO
:
106 getContext().mrEventMultiplexer
.notifyCommandStopAudio( getSelf() );
111 scheduleDeactivationEvent(
112 makeEvent( boost::bind( &AnimationNode::deactivate
, getSelf() ),
113 "AnimationCommandNode::deactivate" ) );
116 bool AnimationCommandNode::hasPendingAnimation() const
118 return mxCommandNode
->getCommand() == EffectCommands::STOPAUDIO
|| mpShape
;
121 } // namespace internal
122 } // namespace slideshow
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */