1*70f497fbSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*70f497fbSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*70f497fbSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*70f497fbSAndrew Rist * distributed with this work for additional information 6*70f497fbSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*70f497fbSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*70f497fbSAndrew Rist * "License"); you may not use this file except in compliance 9*70f497fbSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*70f497fbSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*70f497fbSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*70f497fbSAndrew Rist * software distributed under the License is distributed on an 15*70f497fbSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*70f497fbSAndrew Rist * KIND, either express or implied. See the License for the 17*70f497fbSAndrew Rist * specific language governing permissions and limitations 18*70f497fbSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*70f497fbSAndrew Rist *************************************************************/ 21*70f497fbSAndrew Rist 22*70f497fbSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_slideshow.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir // must be first 28cdf0e10cSrcweir #include <canvas/debug.hxx> 29cdf0e10cSrcweir #include <canvas/verbosetrace.hxx> 30cdf0e10cSrcweir #include <com/sun/star/presentation/EffectCommands.hpp> 31cdf0e10cSrcweir #include <com/sun/star/animations/XAnimate.hpp> 32cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include "animationcommandnode.hxx" 35cdf0e10cSrcweir #include "delayevent.hxx" 36cdf0e10cSrcweir #include "tools.hxx" 37cdf0e10cSrcweir #include "nodetools.hxx" 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include <boost/bind.hpp> 40cdf0e10cSrcweir 41cdf0e10cSrcweir using namespace com::sun::star; 42cdf0e10cSrcweir 43cdf0e10cSrcweir namespace slideshow { 44cdf0e10cSrcweir namespace internal { 45cdf0e10cSrcweir 46cdf0e10cSrcweir namespace EffectCommands = com::sun::star::presentation::EffectCommands; 47cdf0e10cSrcweir 48cdf0e10cSrcweir AnimationCommandNode::AnimationCommandNode( uno::Reference<animations::XAnimationNode> const& xNode, 49cdf0e10cSrcweir ::boost::shared_ptr<BaseContainerNode> const& pParent, 50cdf0e10cSrcweir NodeContext const& rContext ) : 51cdf0e10cSrcweir BaseNode( xNode, pParent, rContext ), 52cdf0e10cSrcweir mpShape(), 53cdf0e10cSrcweir mxCommandNode( xNode, ::com::sun::star::uno::UNO_QUERY_THROW ) 54cdf0e10cSrcweir { 55cdf0e10cSrcweir uno::Reference< drawing::XShape > xShape( mxCommandNode->getTarget(), 56cdf0e10cSrcweir uno::UNO_QUERY ); 57cdf0e10cSrcweir ShapeSharedPtr pShape( getContext().mpSubsettableShapeManager->lookupShape( xShape ) ); 58cdf0e10cSrcweir mpShape = ::boost::dynamic_pointer_cast< ExternalMediaShape >( pShape ); 59cdf0e10cSrcweir } 60cdf0e10cSrcweir 61cdf0e10cSrcweir void AnimationCommandNode::dispose() 62cdf0e10cSrcweir { 63cdf0e10cSrcweir mxCommandNode.clear(); 64cdf0e10cSrcweir mpShape.reset(); 65cdf0e10cSrcweir BaseNode::dispose(); 66cdf0e10cSrcweir } 67cdf0e10cSrcweir 68cdf0e10cSrcweir void AnimationCommandNode::activate_st() 69cdf0e10cSrcweir { 70cdf0e10cSrcweir switch( mxCommandNode->getCommand() ) { 71cdf0e10cSrcweir // the command is user defined 72cdf0e10cSrcweir case EffectCommands::CUSTOM: break; 73cdf0e10cSrcweir // the command is an ole verb. 74cdf0e10cSrcweir case EffectCommands::VERB: break; 75cdf0e10cSrcweir // the command starts playing on a media object 76cdf0e10cSrcweir case EffectCommands::PLAY: 77cdf0e10cSrcweir { 78cdf0e10cSrcweir double fMediaTime=0.0; 79cdf0e10cSrcweir beans::PropertyValue aMediaTime; 80cdf0e10cSrcweir if( (mxCommandNode->getParameter() >>= aMediaTime) && 81cdf0e10cSrcweir aMediaTime.Name.equalsAsciiL( 82cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("MediaTime") )) 83cdf0e10cSrcweir { 84cdf0e10cSrcweir aMediaTime.Value >>= fMediaTime; 85cdf0e10cSrcweir } 86cdf0e10cSrcweir if( mpShape ) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir mpShape->setMediaTime(fMediaTime/1000.0); 89cdf0e10cSrcweir mpShape->play(); 90cdf0e10cSrcweir } 91cdf0e10cSrcweir break; 92cdf0e10cSrcweir } 93cdf0e10cSrcweir // the command toggles the pause status on a media object 94cdf0e10cSrcweir case EffectCommands::TOGGLEPAUSE: 95cdf0e10cSrcweir { 96cdf0e10cSrcweir if( mpShape ) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir if( mpShape->isPlaying() ) 99cdf0e10cSrcweir mpShape->pause(); 100cdf0e10cSrcweir else 101cdf0e10cSrcweir mpShape->play(); 102cdf0e10cSrcweir } 103cdf0e10cSrcweir break; 104cdf0e10cSrcweir } 105cdf0e10cSrcweir // the command stops the animation on a media object 106cdf0e10cSrcweir case EffectCommands::STOP: 107cdf0e10cSrcweir { 108cdf0e10cSrcweir if( mpShape ) 109cdf0e10cSrcweir mpShape->stop(); 110cdf0e10cSrcweir break; 111cdf0e10cSrcweir } 112cdf0e10cSrcweir // the command stops all currently running sound effects 113cdf0e10cSrcweir case EffectCommands::STOPAUDIO: 114cdf0e10cSrcweir getContext().mrEventMultiplexer.notifyCommandStopAudio( getSelf() ); 115cdf0e10cSrcweir break; 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir // deactivate ASAP: 119cdf0e10cSrcweir scheduleDeactivationEvent( 120cdf0e10cSrcweir makeEvent( boost::bind( &AnimationNode::deactivate, getSelf() ), 121cdf0e10cSrcweir "AnimationCommandNode::deactivate" ) ); 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir bool AnimationCommandNode::hasPendingAnimation() const 125cdf0e10cSrcweir { 126cdf0e10cSrcweir return mxCommandNode->getCommand() == EffectCommands::STOPAUDIO || mpShape; 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir } // namespace internal 130cdf0e10cSrcweir } // namespace slideshow 131