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