build fix
[LibreOffice.git] / slideshow / source / engine / animationnodes / animationcommandnode.cxx
blob9ad60892d15f40ee18e8d66c4d78959e2a84af05
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/animations/XAnimate.hpp>
23 #include <com/sun/star/beans/PropertyValue.hpp>
25 #include "animationcommandnode.hxx"
26 #include "delayevent.hxx"
27 #include "tools.hxx"
28 #include "nodetools.hxx"
31 using namespace com::sun::star;
33 namespace slideshow {
34 namespace internal {
36 namespace EffectCommands = css::presentation::EffectCommands;
38 AnimationCommandNode::AnimationCommandNode( uno::Reference<animations::XAnimationNode> const& xNode,
39 ::std::shared_ptr<BaseContainerNode> const& pParent,
40 NodeContext const& rContext ) :
41 BaseNode( xNode, pParent, rContext ),
42 mpShape(),
43 mxCommandNode( xNode, css::uno::UNO_QUERY_THROW )
45 uno::Reference< drawing::XShape > xShape( mxCommandNode->getTarget(),
46 uno::UNO_QUERY );
47 ShapeSharedPtr pShape( getContext().mpSubsettableShapeManager->lookupShape( xShape ) );
48 mpShape = ::std::dynamic_pointer_cast< IExternalMediaShapeBase >( pShape );
51 void AnimationCommandNode::dispose()
53 mxCommandNode.clear();
54 mpShape.reset();
55 BaseNode::dispose();
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;
74 if( mpShape )
76 mpShape->setMediaTime(fMediaTime/1000.0);
77 mpShape->play();
79 break;
81 // the command toggles the pause status on a media object
82 case EffectCommands::TOGGLEPAUSE:
84 if( mpShape )
86 if( mpShape->isPlaying() )
87 mpShape->pause();
88 else
89 mpShape->play();
91 break;
93 // the command stops the animation on a media object
94 case EffectCommands::STOP:
96 if( mpShape )
97 mpShape->stop();
98 break;
100 // the command stops all currently running sound effects
101 case EffectCommands::STOPAUDIO:
102 getContext().mrEventMultiplexer.notifyCommandStopAudio( getSelf() );
103 break;
106 // deactivate ASAP:
107 auto self(getSelf());
108 scheduleDeactivationEvent(
109 makeEvent( [self] () { self->deactivate(); },
110 "AnimationCommandNode::deactivate" ) );
113 bool AnimationCommandNode::hasPendingAnimation() const
115 return mxCommandNode->getCommand() == EffectCommands::STOPAUDIO || mpShape;
118 } // namespace internal
119 } // namespace slideshow
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */