xref: /AOO41X/main/oox/source/ppt/timenode.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include "oox/ppt/timenode.hxx"
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <boost/bind.hpp>
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/container/XEnumerationAccess.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/animations/XAnimateColor.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/animations/XAnimateMotion.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/animations/XAnimateTransform.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/animations/XCommand.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/animations/XIterateContainer.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/animations/XTimeContainer.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/animations/AnimationNodeType.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/animations/Event.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/animations/EventTrigger.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/presentation/EffectNodeType.hpp>
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir #include "oox/helper/helper.hxx"
50*cdf0e10cSrcweir #include "oox/core/xmlfilterbase.hxx"
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir using ::rtl::OUString;
53*cdf0e10cSrcweir using namespace ::oox::core;
54*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
55*cdf0e10cSrcweir using namespace ::com::sun::star::container;
56*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
57*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
58*cdf0e10cSrcweir using namespace ::com::sun::star::animations;
59*cdf0e10cSrcweir using namespace ::com::sun::star::frame;
60*cdf0e10cSrcweir using namespace ::com::sun::star::presentation;
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir namespace oox { namespace ppt {
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir 		OUString TimeNode::getServiceName( sal_Int16 nNodeType )
65*cdf0e10cSrcweir 		{
66*cdf0e10cSrcweir 			OUString sServiceName;
67*cdf0e10cSrcweir 			switch( nNodeType )
68*cdf0e10cSrcweir 			{
69*cdf0e10cSrcweir 			case AnimationNodeType::PAR:
70*cdf0e10cSrcweir //				sServiceName = CREATE_OUSTRING("com.sun.star.animations.IterateContainer");
71*cdf0e10cSrcweir 				sServiceName = CREATE_OUSTRING("com.sun.star.animations.ParallelTimeContainer");
72*cdf0e10cSrcweir 				break;
73*cdf0e10cSrcweir 			case AnimationNodeType::SEQ:
74*cdf0e10cSrcweir 				sServiceName = CREATE_OUSTRING("com.sun.star.animations.SequenceTimeContainer");
75*cdf0e10cSrcweir 				break;
76*cdf0e10cSrcweir 			case AnimationNodeType::ANIMATE:
77*cdf0e10cSrcweir 				sServiceName = CREATE_OUSTRING("com.sun.star.animations.Animate");
78*cdf0e10cSrcweir 				break;
79*cdf0e10cSrcweir 			case AnimationNodeType::ANIMATECOLOR:
80*cdf0e10cSrcweir 				sServiceName = CREATE_OUSTRING("com.sun.star.animations.AnimateColor");
81*cdf0e10cSrcweir 				break;
82*cdf0e10cSrcweir 			case AnimationNodeType::TRANSITIONFILTER:
83*cdf0e10cSrcweir 				sServiceName = CREATE_OUSTRING("com.sun.star.animations.TransitionFilter");
84*cdf0e10cSrcweir 				break;
85*cdf0e10cSrcweir 			case AnimationNodeType::ANIMATEMOTION:
86*cdf0e10cSrcweir 				sServiceName = CREATE_OUSTRING("com.sun.star.animations.AnimateMotion");
87*cdf0e10cSrcweir 				break;
88*cdf0e10cSrcweir 			case AnimationNodeType::ANIMATETRANSFORM:
89*cdf0e10cSrcweir 				sServiceName = CREATE_OUSTRING("com.sun.star.animations.AnimateTransform");
90*cdf0e10cSrcweir 				break;
91*cdf0e10cSrcweir 			case AnimationNodeType::COMMAND:
92*cdf0e10cSrcweir 				sServiceName = CREATE_OUSTRING("com.sun.star.animations.Command");
93*cdf0e10cSrcweir 				break;
94*cdf0e10cSrcweir 			case AnimationNodeType::SET:
95*cdf0e10cSrcweir 				sServiceName = CREATE_OUSTRING("com.sun.star.animations.AnimateSet");
96*cdf0e10cSrcweir 				break;
97*cdf0e10cSrcweir 			case AnimationNodeType::AUDIO:
98*cdf0e10cSrcweir 				sServiceName = CREATE_OUSTRING("com.sun.star.animations.Audio");
99*cdf0e10cSrcweir 				break;
100*cdf0e10cSrcweir 			default:
101*cdf0e10cSrcweir 				OSL_TRACE( "OOX: uhandled type %x", nNodeType );
102*cdf0e10cSrcweir 				break;
103*cdf0e10cSrcweir 			}
104*cdf0e10cSrcweir 			return sServiceName;
105*cdf0e10cSrcweir 		}
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 	TimeNode::TimeNode( sal_Int16 nNodeType )
110*cdf0e10cSrcweir 		: mnNodeType( nNodeType )
111*cdf0e10cSrcweir 		, mbHasEndSyncValue( false )
112*cdf0e10cSrcweir 	{
113*cdf0e10cSrcweir 	}
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir 	TimeNode::~TimeNode()
117*cdf0e10cSrcweir 	{
118*cdf0e10cSrcweir 	}
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir // BEGIN CUT&PASTE from sd/source/filter/ppt/pptinanimations.hxx
121*cdf0e10cSrcweir // --------------------------------------------------------------------
122*cdf0e10cSrcweir 	static void fixMainSequenceTiming( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode )
123*cdf0e10cSrcweir 	{
124*cdf0e10cSrcweir 		try
125*cdf0e10cSrcweir 		{
126*cdf0e10cSrcweir 			bool bFirst = true;
127*cdf0e10cSrcweir 			Reference< XEnumerationAccess > xEA( xNode, UNO_QUERY_THROW );
128*cdf0e10cSrcweir 			Reference< XEnumeration > xE( xEA->createEnumeration(), UNO_QUERY_THROW );
129*cdf0e10cSrcweir 			while( xE->hasMoreElements() )
130*cdf0e10cSrcweir 			{
131*cdf0e10cSrcweir 				// click node
132*cdf0e10cSrcweir 				Reference< XAnimationNode > xClickNode( xE->nextElement(), UNO_QUERY );
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 				Event aEvent;
135*cdf0e10cSrcweir 				aEvent.Trigger = EventTrigger::ON_NEXT;
136*cdf0e10cSrcweir 				aEvent.Repeat = 0;
137*cdf0e10cSrcweir 				xClickNode->setBegin( makeAny( aEvent ) );
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 				if( bFirst )
140*cdf0e10cSrcweir 				{
141*cdf0e10cSrcweir 					bFirst = false;
142*cdf0e10cSrcweir 					Reference< XEnumerationAccess > xEA2( xClickNode, UNO_QUERY_THROW );
143*cdf0e10cSrcweir 					Reference< XEnumeration > xE2( xEA2->createEnumeration(), UNO_QUERY_THROW );
144*cdf0e10cSrcweir 					if( xE2->hasMoreElements() )
145*cdf0e10cSrcweir 					{
146*cdf0e10cSrcweir 						// with node
147*cdf0e10cSrcweir 						xE2->nextElement() >>= xEA2;
148*cdf0e10cSrcweir 						if( xEA2.is() )
149*cdf0e10cSrcweir 							xE2.query( xEA2->createEnumeration() );
150*cdf0e10cSrcweir 						else
151*cdf0e10cSrcweir 							xE2.clear();
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 						if( xE2.is() && xE2->hasMoreElements() )
154*cdf0e10cSrcweir 						{
155*cdf0e10cSrcweir 							Reference< XAnimationNode > xEffectNode( xE2->nextElement(), UNO_QUERY_THROW );
156*cdf0e10cSrcweir 							const Sequence< NamedValue > aUserData( xEffectNode->getUserData() );
157*cdf0e10cSrcweir 							const NamedValue* p = aUserData.getConstArray();
158*cdf0e10cSrcweir 							sal_Int32 nLength = aUserData.getLength();
159*cdf0e10cSrcweir 							while( nLength-- )
160*cdf0e10cSrcweir 							{
161*cdf0e10cSrcweir 								if( p->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "node-type" ) ) )
162*cdf0e10cSrcweir 								{
163*cdf0e10cSrcweir 									sal_Int16 nNodeType = 0;
164*cdf0e10cSrcweir 									p->Value >>= nNodeType;
165*cdf0e10cSrcweir 									if( nNodeType != ::com::sun::star::presentation::EffectNodeType::ON_CLICK )
166*cdf0e10cSrcweir 									{
167*cdf0e10cSrcweir 										// first effect does not start on click, so correct
168*cdf0e10cSrcweir 										// first click nodes begin to 0s
169*cdf0e10cSrcweir 										xClickNode->setBegin( makeAny( (double)0.0 ) );
170*cdf0e10cSrcweir 										break;
171*cdf0e10cSrcweir 									}
172*cdf0e10cSrcweir 								}
173*cdf0e10cSrcweir 								p++;
174*cdf0e10cSrcweir 							}
175*cdf0e10cSrcweir 						}
176*cdf0e10cSrcweir 					}
177*cdf0e10cSrcweir 				}
178*cdf0e10cSrcweir 			}
179*cdf0e10cSrcweir 		}
180*cdf0e10cSrcweir 		catch( Exception& e )
181*cdf0e10cSrcweir 		{
182*cdf0e10cSrcweir 			(void)e;
183*cdf0e10cSrcweir 			OSL_TRACE("fixMainSequenceTiming(), exception caught!" );
184*cdf0e10cSrcweir 		}
185*cdf0e10cSrcweir 	}
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir // --------------------------------------------------------------------
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir 	static void fixInteractiveSequenceTiming( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode )
190*cdf0e10cSrcweir 	{
191*cdf0e10cSrcweir 		try
192*cdf0e10cSrcweir 		{
193*cdf0e10cSrcweir 			Any aBegin( xNode->getBegin() );
194*cdf0e10cSrcweir 			Any aEmpty;
195*cdf0e10cSrcweir 			xNode->setBegin( aEmpty );
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir 			Reference< XEnumerationAccess > xEA( xNode, UNO_QUERY_THROW );
198*cdf0e10cSrcweir 			Reference< XEnumeration > xE( xEA->createEnumeration(), UNO_QUERY_THROW );
199*cdf0e10cSrcweir 			while( xE->hasMoreElements() )
200*cdf0e10cSrcweir 			{
201*cdf0e10cSrcweir 				// click node
202*cdf0e10cSrcweir 				Reference< XAnimationNode > xClickNode( xE->nextElement(), UNO_QUERY );
203*cdf0e10cSrcweir 				xClickNode->setBegin( aBegin );
204*cdf0e10cSrcweir 			}
205*cdf0e10cSrcweir 		}
206*cdf0e10cSrcweir 		catch( Exception& e )
207*cdf0e10cSrcweir 		{
208*cdf0e10cSrcweir 			(void)e;
209*cdf0e10cSrcweir 			OSL_TRACE("fixInteractiveSequenceTiming(), exception caught!" );
210*cdf0e10cSrcweir 		}
211*cdf0e10cSrcweir 	}
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir // END CUT&PASTE
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir     void TimeNode::addNode( const XmlFilterBase& rFilter, const Reference< XAnimationNode >& rxNode, const SlidePersistPtr & pSlide )
216*cdf0e10cSrcweir 	{
217*cdf0e10cSrcweir 		try {
218*cdf0e10cSrcweir 			OUString sServiceName = getServiceName( mnNodeType );
219*cdf0e10cSrcweir             Reference< XAnimationNode > xNode = createAndInsert( rFilter, sServiceName, rxNode );
220*cdf0e10cSrcweir             setNode( rFilter, xNode, pSlide );
221*cdf0e10cSrcweir 		}
222*cdf0e10cSrcweir 		catch( const Exception& e )
223*cdf0e10cSrcweir 		{
224*cdf0e10cSrcweir 			OSL_TRACE( "OOX: exception raised in TimeNode::addNode() - %s",
225*cdf0e10cSrcweir 								 OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
226*cdf0e10cSrcweir 		}
227*cdf0e10cSrcweir 	}
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir     void TimeNode::setNode( const XmlFilterBase& rFilter, const Reference< XAnimationNode >& xNode, const SlidePersistPtr & pSlide )
230*cdf0e10cSrcweir 	{
231*cdf0e10cSrcweir 		OSL_ENSURE( xNode.is(), "null node passed" );
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir 		try {
234*cdf0e10cSrcweir 			if( msId.getLength() )
235*cdf0e10cSrcweir 			{
236*cdf0e10cSrcweir 				pSlide->getAnimNodesMap()[ msId ] = xNode;
237*cdf0e10cSrcweir 			}
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir 			if( mpTarget )
240*cdf0e10cSrcweir 			{
241*cdf0e10cSrcweir 				sal_Int16 nSubType;
242*cdf0e10cSrcweir 				maNodeProperties[ NP_TARGET ] = mpTarget->convert( pSlide, nSubType );
243*cdf0e10cSrcweir 				if( mpTarget->mnType == XML_spTgt )
244*cdf0e10cSrcweir 				{
245*cdf0e10cSrcweir 					maNodeProperties[ NP_SUBITEM ] <<= nSubType;
246*cdf0e10cSrcweir 				}
247*cdf0e10cSrcweir 			}
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 			if( !maStCondList.empty() )
250*cdf0e10cSrcweir 			{
251*cdf0e10cSrcweir 				Any aAny = AnimationCondition::convertList( pSlide, maStCondList );
252*cdf0e10cSrcweir  				if( aAny.hasValue() )
253*cdf0e10cSrcweir 				{
254*cdf0e10cSrcweir 					xNode->setBegin( aAny );
255*cdf0e10cSrcweir 				}
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir 			}
258*cdf0e10cSrcweir 			if( !maEndCondList.empty() )
259*cdf0e10cSrcweir 			{
260*cdf0e10cSrcweir 				Any aAny = AnimationCondition::convertList( pSlide, maEndCondList );
261*cdf0e10cSrcweir 				if( aAny.hasValue() )
262*cdf0e10cSrcweir 				{
263*cdf0e10cSrcweir 					xNode->setEnd( aAny );
264*cdf0e10cSrcweir 				}
265*cdf0e10cSrcweir 			}
266*cdf0e10cSrcweir #if 0  // FIXME even the binary filter has this disabled.
267*cdf0e10cSrcweir 			if( !maNextCondList.empty() )
268*cdf0e10cSrcweir 			{
269*cdf0e10cSrcweir 				Any aAny = AnimationCondition::convertList( pSlide, maNextCondList );
270*cdf0e10cSrcweir 				if( aAny.hasValue() )
271*cdf0e10cSrcweir 				{
272*cdf0e10cSrcweir 					xNode->setNext( aAny );
273*cdf0e10cSrcweir 				}
274*cdf0e10cSrcweir 			}
275*cdf0e10cSrcweir 			if( !maPrevCondList.empty() )
276*cdf0e10cSrcweir 			{
277*cdf0e10cSrcweir 				Any aAny = AnimationCondition::convertList( pSlide, maPrevCondList );
278*cdf0e10cSrcweir 				if( aAny.hasValue() )
279*cdf0e10cSrcweir 				{
280*cdf0e10cSrcweir 					xNode->setPrev( aAny );
281*cdf0e10cSrcweir 				}
282*cdf0e10cSrcweir 			}
283*cdf0e10cSrcweir #endif
284*cdf0e10cSrcweir 			if( mbHasEndSyncValue )
285*cdf0e10cSrcweir 			{
286*cdf0e10cSrcweir 				Any aValue = maEndSyncValue.convert( pSlide );
287*cdf0e10cSrcweir 				xNode->setEndSync(aValue);
288*cdf0e10cSrcweir 			}
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir             if( !maUserData.empty() )
291*cdf0e10cSrcweir             {
292*cdf0e10cSrcweir                 Sequence< NamedValue > aUserDataSeq( static_cast< sal_Int32 >( maUserData.size() ) );
293*cdf0e10cSrcweir                 NamedValue* pValues = aUserDataSeq.getArray();
294*cdf0e10cSrcweir                 for( UserDataMap::const_iterator aIt = maUserData.begin(), aEnd = maUserData.end(); aIt != aEnd; ++aIt, ++pValues )
295*cdf0e10cSrcweir                 {
296*cdf0e10cSrcweir                     pValues->Name = aIt->first;
297*cdf0e10cSrcweir                     pValues->Value = aIt->second;
298*cdf0e10cSrcweir                 }
299*cdf0e10cSrcweir                 maNodeProperties[ NP_USERDATA ] <<= aUserDataSeq;
300*cdf0e10cSrcweir 			}
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir 			Reference< XAnimate > xAnimate( xNode, UNO_QUERY );
303*cdf0e10cSrcweir 			Reference< XAnimateColor > xAnimateColor( xNode, UNO_QUERY );
304*cdf0e10cSrcweir 			Reference< XAnimateMotion > xAnimateMotion( xNode, UNO_QUERY );
305*cdf0e10cSrcweir 			Reference< XAnimateTransform > xAnimateTransform( xNode, UNO_QUERY );
306*cdf0e10cSrcweir 			Reference< XCommand > xCommand( xNode, UNO_QUERY );
307*cdf0e10cSrcweir 			Reference< XIterateContainer > xIterateContainer( xNode, UNO_QUERY );
308*cdf0e10cSrcweir 			sal_Int16 nInt16 = 0;
309*cdf0e10cSrcweir 			sal_Bool bBool = sal_False;
310*cdf0e10cSrcweir 			double fDouble = 0;
311*cdf0e10cSrcweir 			OUString sString;
312*cdf0e10cSrcweir 			Sequence< NamedValue > aSeq;
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir 			for( int i = 0; i < _NP_SIZE; i++)
315*cdf0e10cSrcweir 			{
316*cdf0e10cSrcweir 				Any & aValue( maNodeProperties[ i ] );
317*cdf0e10cSrcweir 				if( aValue.hasValue() )
318*cdf0e10cSrcweir 				{
319*cdf0e10cSrcweir 					switch( i )
320*cdf0e10cSrcweir 					{
321*cdf0e10cSrcweir 					case NP_TO:
322*cdf0e10cSrcweir 						if( xAnimate.is() )
323*cdf0e10cSrcweir 							xAnimate->setTo( aValue );
324*cdf0e10cSrcweir 						break;
325*cdf0e10cSrcweir 					case NP_FROM:
326*cdf0e10cSrcweir 						if( xAnimate.is() )
327*cdf0e10cSrcweir 							xAnimate->setFrom( aValue );
328*cdf0e10cSrcweir 						break;
329*cdf0e10cSrcweir 					case NP_BY:
330*cdf0e10cSrcweir 						if( xAnimate.is() )
331*cdf0e10cSrcweir 							xAnimate->setBy( aValue );
332*cdf0e10cSrcweir 						break;
333*cdf0e10cSrcweir 					case NP_TARGET:
334*cdf0e10cSrcweir 						if( xAnimate.is() )
335*cdf0e10cSrcweir 							xAnimate->setTarget( aValue );
336*cdf0e10cSrcweir 						break;
337*cdf0e10cSrcweir 					case NP_SUBITEM:
338*cdf0e10cSrcweir 						if( xAnimate.is() )
339*cdf0e10cSrcweir 						{
340*cdf0e10cSrcweir 							if( aValue >>= nInt16 )
341*cdf0e10cSrcweir 								xAnimate->setSubItem( nInt16 );
342*cdf0e10cSrcweir 							else
343*cdf0e10cSrcweir 							{
344*cdf0e10cSrcweir 								OSL_TRACE( "any >>= failed %d", __LINE__ );
345*cdf0e10cSrcweir 							}
346*cdf0e10cSrcweir 						}
347*cdf0e10cSrcweir 						break;
348*cdf0e10cSrcweir 					case NP_ATTRIBUTENAME:
349*cdf0e10cSrcweir 						if( xAnimate.is() )
350*cdf0e10cSrcweir 						{
351*cdf0e10cSrcweir 							if(	aValue >>= sString )
352*cdf0e10cSrcweir 								xAnimate->setAttributeName( sString );
353*cdf0e10cSrcweir 							else
354*cdf0e10cSrcweir 							{
355*cdf0e10cSrcweir 								OSL_TRACE( "any >>= failed %d", __LINE__ );
356*cdf0e10cSrcweir 							}
357*cdf0e10cSrcweir 						}
358*cdf0e10cSrcweir 						break;
359*cdf0e10cSrcweir 					case NP_CALCMODE:
360*cdf0e10cSrcweir 						if( xAnimate.is() )
361*cdf0e10cSrcweir 						{
362*cdf0e10cSrcweir 							if( aValue >>= nInt16 )
363*cdf0e10cSrcweir 								xAnimate->setCalcMode( nInt16 );
364*cdf0e10cSrcweir 							else
365*cdf0e10cSrcweir 							{
366*cdf0e10cSrcweir 								OSL_TRACE( "any >>= failed %d", __LINE__ );
367*cdf0e10cSrcweir 							}
368*cdf0e10cSrcweir 						}
369*cdf0e10cSrcweir 						break;
370*cdf0e10cSrcweir 					case NP_KEYTIMES:
371*cdf0e10cSrcweir 						if( xAnimate.is() )
372*cdf0e10cSrcweir 						{
373*cdf0e10cSrcweir 							Sequence<double> aKeyTimes;
374*cdf0e10cSrcweir 							if( aValue >>= aKeyTimes )
375*cdf0e10cSrcweir 								xAnimate->setKeyTimes(aKeyTimes);
376*cdf0e10cSrcweir 							else
377*cdf0e10cSrcweir 							{
378*cdf0e10cSrcweir 								OSL_TRACE( "any >>= failed %d", __LINE__ );
379*cdf0e10cSrcweir 							}
380*cdf0e10cSrcweir 						}
381*cdf0e10cSrcweir 						break;
382*cdf0e10cSrcweir 					case NP_VALUES:
383*cdf0e10cSrcweir 						if( xAnimate.is() )
384*cdf0e10cSrcweir 						{
385*cdf0e10cSrcweir 							Sequence<Any> aValues;
386*cdf0e10cSrcweir 							if( aValue >>= aValues )
387*cdf0e10cSrcweir 								xAnimate->setValues(aValues);
388*cdf0e10cSrcweir 							else
389*cdf0e10cSrcweir 							{
390*cdf0e10cSrcweir 								OSL_TRACE( "any >>= failed %d", __LINE__ );
391*cdf0e10cSrcweir 							}
392*cdf0e10cSrcweir 						}
393*cdf0e10cSrcweir 						break;
394*cdf0e10cSrcweir 					case NP_FORMULA:
395*cdf0e10cSrcweir 						if( xAnimate.is() )
396*cdf0e10cSrcweir 						{
397*cdf0e10cSrcweir 							if( aValue >>= sString )
398*cdf0e10cSrcweir 								xAnimate->setFormula(sString);
399*cdf0e10cSrcweir 							else
400*cdf0e10cSrcweir 							{
401*cdf0e10cSrcweir 								OSL_TRACE( "any >>= failed %d", __LINE__ );
402*cdf0e10cSrcweir 							}
403*cdf0e10cSrcweir 						}
404*cdf0e10cSrcweir 						break;
405*cdf0e10cSrcweir 					case NP_COLORINTERPOLATION:
406*cdf0e10cSrcweir 						if( xAnimateColor.is() )
407*cdf0e10cSrcweir 						{
408*cdf0e10cSrcweir 							if( aValue >>= nInt16 )
409*cdf0e10cSrcweir 								xAnimateColor->setColorInterpolation( nInt16 );
410*cdf0e10cSrcweir 							else
411*cdf0e10cSrcweir 							{
412*cdf0e10cSrcweir 								OSL_TRACE( "any >>= failed %d", __LINE__ );
413*cdf0e10cSrcweir 							}
414*cdf0e10cSrcweir 						}
415*cdf0e10cSrcweir 						break;
416*cdf0e10cSrcweir 					case NP_DIRECTION:
417*cdf0e10cSrcweir 						if( xAnimateColor.is() )
418*cdf0e10cSrcweir 						{
419*cdf0e10cSrcweir 							if( aValue >>= bBool )
420*cdf0e10cSrcweir 								xAnimateColor->setDirection( bBool );
421*cdf0e10cSrcweir 							else
422*cdf0e10cSrcweir 							{
423*cdf0e10cSrcweir 								OSL_TRACE( "any >>= failed %d", __LINE__ );
424*cdf0e10cSrcweir 							}
425*cdf0e10cSrcweir 						}
426*cdf0e10cSrcweir 						break;
427*cdf0e10cSrcweir 					case NP_PATH:
428*cdf0e10cSrcweir 						if( xAnimateMotion.is() )
429*cdf0e10cSrcweir 							xAnimateMotion->setPath( aValue );
430*cdf0e10cSrcweir 						break;
431*cdf0e10cSrcweir 					case NP_TRANSFORMTYPE:
432*cdf0e10cSrcweir 						if( xAnimateTransform.is() )
433*cdf0e10cSrcweir 						{
434*cdf0e10cSrcweir 							if( aValue >>= nInt16 )
435*cdf0e10cSrcweir 								xAnimateTransform->setTransformType( nInt16 );
436*cdf0e10cSrcweir 							else
437*cdf0e10cSrcweir 							{
438*cdf0e10cSrcweir 								OSL_TRACE( "any >>= failed %d", __LINE__ );
439*cdf0e10cSrcweir 							}
440*cdf0e10cSrcweir 						}
441*cdf0e10cSrcweir 						break;
442*cdf0e10cSrcweir 					case NP_USERDATA:
443*cdf0e10cSrcweir 						if( aValue >>= aSeq )
444*cdf0e10cSrcweir 							xNode->setUserData( aSeq );
445*cdf0e10cSrcweir 						else
446*cdf0e10cSrcweir 						{
447*cdf0e10cSrcweir 							OSL_TRACE( "any >>= failed %d", __LINE__ );
448*cdf0e10cSrcweir 						}
449*cdf0e10cSrcweir 						break;
450*cdf0e10cSrcweir 					case NP_ACCELERATION:
451*cdf0e10cSrcweir 						if( aValue >>= fDouble )
452*cdf0e10cSrcweir 							xNode->setAcceleration( fDouble );
453*cdf0e10cSrcweir 						else
454*cdf0e10cSrcweir 						{
455*cdf0e10cSrcweir 							OSL_TRACE( "any >>= failed %d", __LINE__ );
456*cdf0e10cSrcweir 						}
457*cdf0e10cSrcweir 						break;
458*cdf0e10cSrcweir 					case NP_DECELERATE:
459*cdf0e10cSrcweir 						if( aValue >>= fDouble )
460*cdf0e10cSrcweir 							xNode->setDecelerate( fDouble );
461*cdf0e10cSrcweir 						else
462*cdf0e10cSrcweir 						{
463*cdf0e10cSrcweir 							OSL_TRACE( "any >>= failed %d", __LINE__ );
464*cdf0e10cSrcweir 						}
465*cdf0e10cSrcweir 						break;
466*cdf0e10cSrcweir 					case NP_AUTOREVERSE:
467*cdf0e10cSrcweir 						if( aValue >>= bBool )
468*cdf0e10cSrcweir 							xNode->setAutoReverse( bBool );
469*cdf0e10cSrcweir 						else
470*cdf0e10cSrcweir 						{
471*cdf0e10cSrcweir 							OSL_TRACE( "any >>= failed %d", __LINE__ );
472*cdf0e10cSrcweir 						}
473*cdf0e10cSrcweir 						break;
474*cdf0e10cSrcweir 					case NP_DURATION:
475*cdf0e10cSrcweir 						xNode->setDuration( aValue );
476*cdf0e10cSrcweir 						break;
477*cdf0e10cSrcweir 					case NP_FILL:
478*cdf0e10cSrcweir 						if( aValue >>= nInt16 )
479*cdf0e10cSrcweir 							xNode->setFill( nInt16 );
480*cdf0e10cSrcweir 						else
481*cdf0e10cSrcweir 						{
482*cdf0e10cSrcweir 							OSL_TRACE( "any >>= failed %d", __LINE__ );
483*cdf0e10cSrcweir 						}
484*cdf0e10cSrcweir 						break;
485*cdf0e10cSrcweir 					case NP_REPEATCOUNT:
486*cdf0e10cSrcweir 						xNode->setRepeatCount( aValue );
487*cdf0e10cSrcweir 						break;
488*cdf0e10cSrcweir 					case NP_REPEATDURATION:
489*cdf0e10cSrcweir 						xNode->setRepeatDuration( aValue );
490*cdf0e10cSrcweir 						break;
491*cdf0e10cSrcweir 					case NP_RESTART:
492*cdf0e10cSrcweir 						if( aValue >>= nInt16 )
493*cdf0e10cSrcweir 							xNode->setRestart( nInt16 );
494*cdf0e10cSrcweir 						else
495*cdf0e10cSrcweir 						{
496*cdf0e10cSrcweir 							OSL_TRACE( "any >>= failed %d", __LINE__ );
497*cdf0e10cSrcweir 						}
498*cdf0e10cSrcweir 						break;
499*cdf0e10cSrcweir 					case NP_COMMAND:
500*cdf0e10cSrcweir 						if( xCommand.is() )
501*cdf0e10cSrcweir 						{
502*cdf0e10cSrcweir 							if( aValue >>= nInt16 )
503*cdf0e10cSrcweir 								xCommand->setCommand( nInt16 );
504*cdf0e10cSrcweir 							else
505*cdf0e10cSrcweir 							{
506*cdf0e10cSrcweir 								OSL_TRACE( "any >>= failed %d", __LINE__ );
507*cdf0e10cSrcweir 							}
508*cdf0e10cSrcweir 						}
509*cdf0e10cSrcweir 						break;
510*cdf0e10cSrcweir 					case NP_PARAMETER:
511*cdf0e10cSrcweir 						if( xCommand.is() )
512*cdf0e10cSrcweir 							xCommand->setParameter( aValue );
513*cdf0e10cSrcweir 						break;
514*cdf0e10cSrcweir 					case NP_ITERATETYPE:
515*cdf0e10cSrcweir 						if( xIterateContainer.is() )
516*cdf0e10cSrcweir 						{
517*cdf0e10cSrcweir 							if( aValue >>= nInt16 )
518*cdf0e10cSrcweir 								xIterateContainer->setIterateType( nInt16 );
519*cdf0e10cSrcweir 							else
520*cdf0e10cSrcweir 							{
521*cdf0e10cSrcweir 								OSL_TRACE( "any >>= failed %d", __LINE__ );
522*cdf0e10cSrcweir 							}
523*cdf0e10cSrcweir 						}
524*cdf0e10cSrcweir 						break;
525*cdf0e10cSrcweir 					case NP_ITERATEINTERVAL:
526*cdf0e10cSrcweir 						if( xIterateContainer.is() )
527*cdf0e10cSrcweir 						{
528*cdf0e10cSrcweir 							if( aValue >>= fDouble )
529*cdf0e10cSrcweir 								xIterateContainer->setIterateInterval( fDouble );
530*cdf0e10cSrcweir 							else
531*cdf0e10cSrcweir 							{
532*cdf0e10cSrcweir 								OSL_TRACE( "any >>= failed %d", __LINE__ );
533*cdf0e10cSrcweir 							}
534*cdf0e10cSrcweir 						}
535*cdf0e10cSrcweir 						break;
536*cdf0e10cSrcweir 					default:
537*cdf0e10cSrcweir 						OSL_TRACE( "ERR-OOX: unknown prop index %d", i );
538*cdf0e10cSrcweir 						break;
539*cdf0e10cSrcweir 					}
540*cdf0e10cSrcweir 				}
541*cdf0e10cSrcweir 			}
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir 			if( mnNodeType == AnimationNodeType::TRANSITIONFILTER )
544*cdf0e10cSrcweir 			{
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir 				Reference< XTransitionFilter > xFilter( xNode, UNO_QUERY );
547*cdf0e10cSrcweir 				maTransitionFilter.setTransitionFilterProperties( xFilter );
548*cdf0e10cSrcweir 			}
549*cdf0e10cSrcweir 
550*cdf0e10cSrcweir             std::for_each( maChildren.begin(), maChildren.end(),
551*cdf0e10cSrcweir                            boost::bind(&TimeNode::addNode, _1, boost::cref(rFilter), boost::ref(xNode),
552*cdf0e10cSrcweir 									   boost::ref(pSlide) ) );
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir 			switch( mnNodeType )
555*cdf0e10cSrcweir 			{
556*cdf0e10cSrcweir 			case AnimationNodeType::SEQ:
557*cdf0e10cSrcweir 			{
558*cdf0e10cSrcweir 				sal_Int16 nEnum = 0;
559*cdf0e10cSrcweir 				if( maUserData[ CREATE_OUSTRING( "node-type" ) ] >>= nEnum )
560*cdf0e10cSrcweir 				{
561*cdf0e10cSrcweir 					if( nEnum == EffectNodeType::MAIN_SEQUENCE )
562*cdf0e10cSrcweir 					{
563*cdf0e10cSrcweir 						fixMainSequenceTiming( xNode );
564*cdf0e10cSrcweir 					}
565*cdf0e10cSrcweir 					else if( nEnum ==  EffectNodeType::INTERACTIVE_SEQUENCE )
566*cdf0e10cSrcweir 					{
567*cdf0e10cSrcweir 						fixInteractiveSequenceTiming( xNode );
568*cdf0e10cSrcweir 					}
569*cdf0e10cSrcweir 				}
570*cdf0e10cSrcweir 				break;
571*cdf0e10cSrcweir 			}
572*cdf0e10cSrcweir 			case AnimationNodeType::PAR:
573*cdf0e10cSrcweir 				// some other cut&paste... from AnimationImporter::importAnimationContainer()
574*cdf0e10cSrcweir 				break;
575*cdf0e10cSrcweir 			}
576*cdf0e10cSrcweir 		}
577*cdf0e10cSrcweir 		catch( const Exception& e )
578*cdf0e10cSrcweir 		{
579*cdf0e10cSrcweir 			OSL_TRACE( "OOX: exception raised in TimeNode::setNode() - %s",
580*cdf0e10cSrcweir 								 OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
581*cdf0e10cSrcweir 		}
582*cdf0e10cSrcweir 	}
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir     Reference< XAnimationNode > TimeNode::createAndInsert(
586*cdf0e10cSrcweir             const XmlFilterBase& rFilter,
587*cdf0e10cSrcweir             const OUString& rServiceName,
588*cdf0e10cSrcweir             const Reference< XAnimationNode >& rxNode )
589*cdf0e10cSrcweir 	{
590*cdf0e10cSrcweir 		try {
591*cdf0e10cSrcweir             Reference< XAnimationNode > xNode ( rFilter.getServiceFactory()->createInstance( rServiceName ), UNO_QUERY_THROW );
592*cdf0e10cSrcweir 			Reference< XTimeContainer > xParentContainer( rxNode, UNO_QUERY_THROW );
593*cdf0e10cSrcweir 
594*cdf0e10cSrcweir 			xParentContainer->appendChild( xNode );
595*cdf0e10cSrcweir 			return xNode;
596*cdf0e10cSrcweir 		}
597*cdf0e10cSrcweir 		catch( const Exception& e )
598*cdf0e10cSrcweir 		{
599*cdf0e10cSrcweir 			OSL_TRACE( "OOX: exception raised in TimeNode::createAndInsert() trying to create a service %s = %s",
600*cdf0e10cSrcweir 								 OUStringToOString( rServiceName, RTL_TEXTENCODING_ASCII_US ).getStr(),
601*cdf0e10cSrcweir 								 OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
602*cdf0e10cSrcweir 		}
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir 		return Reference< XAnimationNode >();
605*cdf0e10cSrcweir 	}
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir 
608*cdf0e10cSrcweir 	void 	TimeNode::setId( sal_Int32 nId )
609*cdf0e10cSrcweir 	{
610*cdf0e10cSrcweir 		msId = OUString::valueOf(nId);
611*cdf0e10cSrcweir 	}
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir 	void TimeNode::setTo( const Any & aTo )
614*cdf0e10cSrcweir 	{
615*cdf0e10cSrcweir 		maNodeProperties[ NP_TO ] = aTo;
616*cdf0e10cSrcweir 	}
617*cdf0e10cSrcweir 
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir 	void TimeNode::setFrom( const Any & aFrom )
620*cdf0e10cSrcweir 	{
621*cdf0e10cSrcweir 		maNodeProperties[ NP_FROM ] = aFrom;
622*cdf0e10cSrcweir 	}
623*cdf0e10cSrcweir 
624*cdf0e10cSrcweir 	void TimeNode::setBy( const Any & aBy )
625*cdf0e10cSrcweir 	{
626*cdf0e10cSrcweir 		maNodeProperties[ NP_BY ] = aBy;
627*cdf0e10cSrcweir 	}
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir 
630*cdf0e10cSrcweir } }
631