1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_slideshow.hxx" 30 31 // must be first 32 #include <canvas/debug.hxx> 33 #include <canvas/verbosetrace.hxx> 34 #include <com/sun/star/presentation/EffectCommands.hpp> 35 #include <com/sun/star/animations/XAnimate.hpp> 36 #include <com/sun/star/beans/PropertyValue.hpp> 37 38 #include "animationcommandnode.hxx" 39 #include "delayevent.hxx" 40 #include "tools.hxx" 41 #include "nodetools.hxx" 42 43 #include <boost/bind.hpp> 44 45 using namespace com::sun::star; 46 47 namespace slideshow { 48 namespace internal { 49 50 namespace EffectCommands = com::sun::star::presentation::EffectCommands; 51 52 AnimationCommandNode::AnimationCommandNode( uno::Reference<animations::XAnimationNode> const& xNode, 53 ::boost::shared_ptr<BaseContainerNode> const& pParent, 54 NodeContext const& rContext ) : 55 BaseNode( xNode, pParent, rContext ), 56 mpShape(), 57 mxCommandNode( xNode, ::com::sun::star::uno::UNO_QUERY_THROW ) 58 { 59 uno::Reference< drawing::XShape > xShape( mxCommandNode->getTarget(), 60 uno::UNO_QUERY ); 61 ShapeSharedPtr pShape( getContext().mpSubsettableShapeManager->lookupShape( xShape ) ); 62 mpShape = ::boost::dynamic_pointer_cast< ExternalMediaShape >( pShape ); 63 } 64 65 void AnimationCommandNode::dispose() 66 { 67 mxCommandNode.clear(); 68 mpShape.reset(); 69 BaseNode::dispose(); 70 } 71 72 void AnimationCommandNode::activate_st() 73 { 74 switch( mxCommandNode->getCommand() ) { 75 // the command is user defined 76 case EffectCommands::CUSTOM: break; 77 // the command is an ole verb. 78 case EffectCommands::VERB: break; 79 // the command starts playing on a media object 80 case EffectCommands::PLAY: 81 { 82 double fMediaTime=0.0; 83 beans::PropertyValue aMediaTime; 84 if( (mxCommandNode->getParameter() >>= aMediaTime) && 85 aMediaTime.Name.equalsAsciiL( 86 RTL_CONSTASCII_STRINGPARAM("MediaTime") )) 87 { 88 aMediaTime.Value >>= fMediaTime; 89 } 90 if( mpShape ) 91 { 92 mpShape->setMediaTime(fMediaTime/1000.0); 93 mpShape->play(); 94 } 95 break; 96 } 97 // the command toggles the pause status on a media object 98 case EffectCommands::TOGGLEPAUSE: 99 { 100 if( mpShape ) 101 { 102 if( mpShape->isPlaying() ) 103 mpShape->pause(); 104 else 105 mpShape->play(); 106 } 107 break; 108 } 109 // the command stops the animation on a media object 110 case EffectCommands::STOP: 111 { 112 if( mpShape ) 113 mpShape->stop(); 114 break; 115 } 116 // the command stops all currently running sound effects 117 case EffectCommands::STOPAUDIO: 118 getContext().mrEventMultiplexer.notifyCommandStopAudio( getSelf() ); 119 break; 120 } 121 122 // deactivate ASAP: 123 scheduleDeactivationEvent( 124 makeEvent( boost::bind( &AnimationNode::deactivate, getSelf() ), 125 "AnimationCommandNode::deactivate" ) ); 126 } 127 128 bool AnimationCommandNode::hasPendingAnimation() const 129 { 130 return mxCommandNode->getCommand() == EffectCommands::STOPAUDIO || mpShape; 131 } 132 133 } // namespace internal 134 } // namespace slideshow 135