xref: /AOO41X/main/sd/source/ui/unoidl/randomnode.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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 
29 // MARKER(update_precomp.py): autogen include statement, do not remove
30 #include "precompiled_sd.hxx"
31 #include <com/sun/star/animations/XTimeContainer.hpp>
32 #include <com/sun/star/presentation/ParagraphTarget.hpp>
33 #include <com/sun/star/animations/AnimationFill.hpp>
34 #include <com/sun/star/animations/XAnimate.hpp>
35 #include <com/sun/star/animations/AnimationRestart.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/lang/XInitialization.hpp>
38 #include <com/sun/star/container/XEnumerationAccess.hpp>
39 #include <com/sun/star/util/XCloneable.hpp>
40 #include <comphelper/processfactory.hxx>
41 
42 #include <cppuhelper/implbase5.hxx>
43 #include <osl/mutex.hxx>
44 #include "CustomAnimationPreset.hxx"
45 
46 using ::osl::Mutex;
47 using ::osl::Guard;
48 using ::rtl::OUString;
49 
50 using ::com::sun::star::uno::Reference;
51 using ::com::sun::star::uno::RuntimeException;
52 using ::com::sun::star::uno::Exception;
53 using ::com::sun::star::uno::Sequence;
54 using ::com::sun::star::uno::Any;
55 using ::com::sun::star::uno::UNO_QUERY;
56 using ::com::sun::star::uno::XInterface;
57 using ::com::sun::star::lang::NoSupportException;
58 using ::com::sun::star::beans::NamedValue;
59 using ::com::sun::star::lang::IllegalArgumentException;
60 using ::com::sun::star::container::NoSuchElementException;
61 using ::com::sun::star::container::ElementExistException;
62 using ::com::sun::star::lang::WrappedTargetException;
63 using ::com::sun::star::container::XEnumeration;
64 using ::com::sun::star::container::XEnumerationAccess;
65 using ::com::sun::star::util::XCloneable;
66 using ::com::sun::star::lang::XServiceInfo;
67 using ::com::sun::star::lang::XInitialization;
68 using ::com::sun::star::uno::Type;
69 using ::com::sun::star::uno::XWeak;
70 using ::com::sun::star::lang::XMultiServiceFactory;
71 using ::com::sun::star::presentation::ParagraphTarget;
72 using ::com::sun::star::drawing::XShape;
73 
74 using namespace ::com::sun::star::animations;
75 namespace sd
76 {
77 
78 typedef ::cppu::WeakImplHelper5< XTimeContainer, XEnumerationAccess, XCloneable, XServiceInfo, XInitialization > RandomAnimationNodeBase;
79 class RandomAnimationNode : public RandomAnimationNodeBase
80 {
81 public:
82 	RandomAnimationNode( const RandomAnimationNode& rNode );
83 	RandomAnimationNode( sal_Int16 nPresetClass );
84 	RandomAnimationNode();
85 
86 	void init( sal_Int16 nPresetClass );
87 
88 	// XInitialization
89     void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException);
90 
91     // XChild
92     Reference< XInterface > SAL_CALL getParent(  ) throw (RuntimeException);
93     void SAL_CALL setParent( const Reference< XInterface >& Parent ) throw (NoSupportException, RuntimeException);
94 
95     // XCloneable
96     virtual Reference< XCloneable > SAL_CALL createClone() throw (RuntimeException);
97 
98 	// XServiceInfo
99     OUString SAL_CALL getImplementationName() throw();
100     Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw();
101     sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw();
102 
103     // XAnimationNode
104     ::sal_Int16 SAL_CALL getType() throw (RuntimeException);
105     Any SAL_CALL getBegin() throw (RuntimeException);
106     void SAL_CALL setBegin( const Any& _begin ) throw (RuntimeException);
107     Any SAL_CALL getDuration() throw (RuntimeException);
108     void SAL_CALL setDuration( const Any& _duration ) throw (RuntimeException);
109     Any SAL_CALL getEnd() throw (RuntimeException);
110     void SAL_CALL setEnd( const Any& _end ) throw (RuntimeException);
111     Any SAL_CALL getEndSync() throw (RuntimeException);
112     void SAL_CALL setEndSync( const Any& _endsync ) throw (RuntimeException);
113     Any SAL_CALL getRepeatCount() throw (RuntimeException);
114     void SAL_CALL setRepeatCount( const Any& _repeatcount ) throw (RuntimeException);
115     Any SAL_CALL getRepeatDuration() throw (RuntimeException);
116     void SAL_CALL setRepeatDuration( const Any& _repeatduration ) throw (RuntimeException);
117     ::sal_Int16 SAL_CALL getFill() throw (RuntimeException);
118     void SAL_CALL setFill( ::sal_Int16 _fill ) throw (RuntimeException);
119     ::sal_Int16 SAL_CALL getFillDefault() throw (RuntimeException);
120     void SAL_CALL setFillDefault( ::sal_Int16 _filldefault ) throw (RuntimeException);
121     ::sal_Int16 SAL_CALL getRestart() throw (RuntimeException);
122     void SAL_CALL setRestart( ::sal_Int16 _restart ) throw (RuntimeException);
123     ::sal_Int16 SAL_CALL getRestartDefault() throw (RuntimeException);
124 	void SAL_CALL setRestartDefault( ::sal_Int16 _restartdefault ) throw (RuntimeException);
125     double SAL_CALL getAcceleration() throw (RuntimeException);
126     void SAL_CALL setAcceleration( double _acceleration ) throw (RuntimeException);
127     double SAL_CALL getDecelerate() throw (RuntimeException);
128     void SAL_CALL setDecelerate( double _decelerate ) throw (RuntimeException);
129     ::sal_Bool SAL_CALL getAutoReverse() throw (RuntimeException);
130     void SAL_CALL setAutoReverse( ::sal_Bool _autoreverse ) throw (RuntimeException);
131     Sequence< NamedValue > SAL_CALL getUserData() throw (RuntimeException);
132     void SAL_CALL setUserData( const Sequence< NamedValue >& _userdata ) throw (RuntimeException);
133 
134 	// XElementAccess
135 	virtual Type SAL_CALL getElementType() throw (RuntimeException);
136 	virtual sal_Bool SAL_CALL hasElements() throw (RuntimeException);
137 
138 	// XEnumerationAccess
139     virtual Reference< XEnumeration > SAL_CALL createEnumeration() throw (RuntimeException);
140 
141     // XTimeContainer
142     Reference< XAnimationNode > SAL_CALL insertBefore( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >& refChild ) throw (IllegalArgumentException, NoSuchElementException, ElementExistException, WrappedTargetException, RuntimeException);
143     Reference< XAnimationNode > SAL_CALL insertAfter( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >& refChild ) throw (IllegalArgumentException, NoSuchElementException, ElementExistException, WrappedTargetException, RuntimeException);
144     Reference< XAnimationNode > SAL_CALL replaceChild( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >& oldChild ) throw (IllegalArgumentException, NoSuchElementException, ElementExistException, WrappedTargetException, RuntimeException);
145     Reference< XAnimationNode > SAL_CALL removeChild( const Reference< XAnimationNode >& oldChild ) throw (IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException);
146     Reference< XAnimationNode > SAL_CALL appendChild( const Reference< XAnimationNode >& newChild ) throw (IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException);
147 
148 private:
149 	// our first, last and only protection from mutli-threads!
150 	Mutex maMutex;
151 
152 	sal_Int16 mnPresetClass;
153 	Reference< XInterface > mxParent;
154 
155 	Any maBegin, maDuration, maEnd, maEndSync, maRepeatCount, maRepeatDuration, maTarget;
156 	sal_Int16 mnFill, mnFillDefault, mnRestart, mnRestartDefault;
157 	double mfAcceleration, mfDecelerate;
158 	sal_Bool mbAutoReverse;
159 	Sequence< NamedValue > maUserData;
160 
161 	Reference< XAnimate > mxFirstNode;
162 };
163 
164 // --------------------------------------------------------------------
165 
166 static const sal_Char* pSN1 = "com.sun.star.animations.ParallelTimeContainer";
167 static const sal_Char* pSN2 = "com.sun.star.comp.sd.RandomAnimationNode";
168 
169 // --------------------------------------------------------------------
170 
171 SD_DLLPUBLIC Reference< XInterface > RandomAnimationNode_createInstance( sal_Int16 nPresetClass )
172 {
173 	Reference< XInterface > xInt( static_cast<XWeak*>( new RandomAnimationNode( nPresetClass ) ) );
174 	return xInt;
175 }
176 
177 // --------------------------------------------------------------------
178 
179 Reference< XInterface > SAL_CALL RandomNode_createInstance( const Reference< XMultiServiceFactory > &  )
180 {
181 	Reference< XInterface > xInt( static_cast<XWeak*>( new RandomAnimationNode() ) );
182 	return xInt;
183 }
184 
185 // --------------------------------------------------------------------
186 
187 OUString RandomNode__getImplementationName() throw( RuntimeException )
188 {
189 	return OUString( RTL_CONSTASCII_USTRINGPARAM( "sd::RandomAnimationNode" ) );
190 }
191 
192 // --------------------------------------------------------------------
193 
194 Sequence< OUString > SAL_CALL RandomNode_getSupportedServiceNames() throw( RuntimeException )
195 {
196 //	static const OUString aSN1( OUString::createFromAscii( pSN1 ) );
197 	static const OUString aSN2( OUString::createFromAscii( pSN2 ) );
198 	Sequence< OUString > aSeq( &aSN2, 1 );
199 //	aSeq[0] = aSN1;
200 ///	aSeq[1] = aSN2;
201 	return aSeq;
202 }
203 
204 // --------------------------------------------------------------------
205 
206 RandomAnimationNode::RandomAnimationNode( const RandomAnimationNode& rNode )
207 :	RandomAnimationNodeBase(),
208 	mnPresetClass( rNode.mnPresetClass ),
209 	maBegin( rNode.maBegin ),
210 	maDuration( rNode.maDuration ),
211 	maEnd( rNode.maEnd ),
212 	maEndSync( rNode.maEndSync ),
213 	maRepeatCount( rNode.maRepeatCount ),
214 	maRepeatDuration( rNode.maRepeatDuration ),
215 	maTarget( rNode.maTarget ),
216 	mnFill( rNode.mnFill ),
217 	mnFillDefault( rNode.mnFillDefault ),
218 	mnRestart( rNode.mnRestart ),
219 	mnRestartDefault( rNode.mnRestartDefault ),
220 	mfAcceleration( rNode.mfAcceleration ),
221 	mfDecelerate( rNode.mfDecelerate ),
222 	mbAutoReverse( rNode.mbAutoReverse ),
223 	maUserData( rNode.maUserData )
224 {
225 }
226 
227 // --------------------------------------------------------------------
228 
229 RandomAnimationNode::RandomAnimationNode( sal_Int16 nPresetClass )
230 {
231 	init( nPresetClass );
232 }
233 
234 RandomAnimationNode::RandomAnimationNode()
235 {
236 	init( 1 );
237 }
238 
239 void RandomAnimationNode::init( sal_Int16 nPresetClass )
240 {
241 	mnPresetClass = nPresetClass;
242 	mnFill = AnimationFill::DEFAULT;
243 	mnFillDefault = AnimationFill::INHERIT;
244 	mnRestart = AnimationRestart::DEFAULT;
245 	mnRestartDefault = AnimationRestart::INHERIT;
246 	mfAcceleration = 0.0;
247 	mfDecelerate = 0.0;
248 	mbAutoReverse = sal_False;
249 }
250 
251 // --------------------------------------------------------------------
252 
253 // XInitialization
254 void SAL_CALL RandomAnimationNode::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException)
255 {
256 	if( aArguments.getLength() != 1 )
257 		throw IllegalArgumentException();
258 
259 	if( aArguments[0].getValueType() == ::getCppuType((const sal_Int16*)0) )
260 	{
261 		aArguments[0] >>= mnPresetClass;
262 	}
263 	else if( aArguments[0].getValueType() != ::getCppuType((const ParagraphTarget*)0) )
264 	{
265 		Reference< XShape > xShape;
266 		aArguments[0] >>= xShape;
267 		if( !xShape.is() )
268 			throw IllegalArgumentException();
269 	}
270 	maTarget = aArguments[0];
271 }
272 
273 // --------------------------------------------------------------------
274 
275 // XAnimationNode
276 sal_Int16 SAL_CALL RandomAnimationNode::getType() throw (RuntimeException)
277 {
278 	Guard< Mutex > aGuard( maMutex );
279 	return ::com::sun::star::animations::AnimationNodeType::PAR;
280 }
281 
282 // --------------------------------------------------------------------
283 
284 // XAnimationNode
285 Any SAL_CALL RandomAnimationNode::getBegin() throw (RuntimeException)
286 {
287 	Guard< Mutex > aGuard( maMutex );
288 	return maBegin;
289 }
290 
291 // --------------------------------------------------------------------
292 
293 // XAnimationNode
294 void SAL_CALL RandomAnimationNode::setBegin( const Any& _begin ) throw (RuntimeException)
295 {
296 	Guard< Mutex > aGuard( maMutex );
297 	maBegin = _begin;
298 }
299 
300 // --------------------------------------------------------------------
301 
302 // XAnimationNode
303 Any SAL_CALL RandomAnimationNode::getDuration() throw (RuntimeException)
304 {
305 	Guard< Mutex > aGuard( maMutex );
306 	return maDuration;
307 }
308 
309 // --------------------------------------------------------------------
310 
311 // XAnimationNode
312 void SAL_CALL RandomAnimationNode::setDuration( const Any& _duration ) throw (RuntimeException)
313 {
314 	Guard< Mutex > aGuard( maMutex );
315 	maDuration = _duration;
316 }
317 
318 // --------------------------------------------------------------------
319 
320 // XAnimationNode
321 Any SAL_CALL RandomAnimationNode::getEnd() throw (RuntimeException)
322 {
323 	Guard< Mutex > aGuard( maMutex );
324 	return maEnd;
325 }
326 
327 // --------------------------------------------------------------------
328 
329 // XAnimationNode
330 void SAL_CALL RandomAnimationNode::setEnd( const Any& _end ) throw (RuntimeException)
331 {
332 	Guard< Mutex > aGuard( maMutex );
333 	maEnd = _end;
334 }
335 
336 // --------------------------------------------------------------------
337 
338 // XAnimationNode
339 Any SAL_CALL RandomAnimationNode::getEndSync() throw (RuntimeException)
340 {
341 	Guard< Mutex > aGuard( maMutex );
342 	return maEndSync;
343 }
344 
345 // --------------------------------------------------------------------
346 
347 // XAnimationNode
348 void SAL_CALL RandomAnimationNode::setEndSync( const Any& _endsync ) throw (RuntimeException)
349 {
350 	Guard< Mutex > aGuard( maMutex );
351 	maEndSync = _endsync;
352 }
353 
354 // --------------------------------------------------------------------
355 
356 // XAnimationNode
357 Any SAL_CALL RandomAnimationNode::getRepeatCount() throw (RuntimeException)
358 {
359 	Guard< Mutex > aGuard( maMutex );
360 	return maRepeatCount;
361 }
362 
363 // --------------------------------------------------------------------
364 
365 // XAnimationNode
366 void SAL_CALL RandomAnimationNode::setRepeatCount( const Any& _repeatcount ) throw (RuntimeException)
367 {
368 	Guard< Mutex > aGuard( maMutex );
369 	maRepeatCount = _repeatcount;
370 }
371 
372 // --------------------------------------------------------------------
373 
374 // XAnimationNode
375 Any SAL_CALL RandomAnimationNode::getRepeatDuration() throw (RuntimeException)
376 {
377 	Guard< Mutex > aGuard( maMutex );
378 	return maRepeatDuration;
379 }
380 
381 // --------------------------------------------------------------------
382 
383 // XAnimationNode
384 void SAL_CALL RandomAnimationNode::setRepeatDuration( const Any& _repeatduration ) throw (RuntimeException)
385 {
386 	Guard< Mutex > aGuard( maMutex );
387 	maRepeatDuration = _repeatduration;
388 }
389 
390 // --------------------------------------------------------------------
391 
392 // XAnimationNode
393 sal_Int16 SAL_CALL RandomAnimationNode::getFill() throw (RuntimeException)
394 {
395 	Guard< Mutex > aGuard( maMutex );
396 	return mnFill;
397 }
398 
399 // --------------------------------------------------------------------
400 
401 // XAnimationNode
402 void SAL_CALL RandomAnimationNode::setFill( sal_Int16 _fill ) throw (RuntimeException)
403 {
404 	Guard< Mutex > aGuard( maMutex );
405 	mnFill = _fill;
406 }
407 
408 // --------------------------------------------------------------------
409 
410 // XAnimationNode
411 sal_Int16 SAL_CALL RandomAnimationNode::getFillDefault() throw (RuntimeException)
412 {
413 	Guard< Mutex > aGuard( maMutex );
414 	return mnFillDefault;
415 }
416 
417 // --------------------------------------------------------------------
418 
419 // XAnimationNode
420 void SAL_CALL RandomAnimationNode::setFillDefault( sal_Int16 _filldefault ) throw (RuntimeException)
421 {
422 	Guard< Mutex > aGuard( maMutex );
423 	mnFillDefault = _filldefault;
424 }
425 
426 // --------------------------------------------------------------------
427 
428 // XAnimationNode
429 sal_Int16 SAL_CALL RandomAnimationNode::getRestart() throw (RuntimeException)
430 {
431 	Guard< Mutex > aGuard( maMutex );
432 	return mnRestart;
433 }
434 
435 // --------------------------------------------------------------------
436 
437 // XAnimationNode
438 void SAL_CALL RandomAnimationNode::setRestart( sal_Int16 _restart ) throw (RuntimeException)
439 {
440 	Guard< Mutex > aGuard( maMutex );
441 	mnRestart = _restart;
442 }
443 
444 // --------------------------------------------------------------------
445 
446 // XAnimationNode
447 sal_Int16 SAL_CALL RandomAnimationNode::getRestartDefault() throw (RuntimeException)
448 {
449 	Guard< Mutex > aGuard( maMutex );
450 	return mnRestartDefault;
451 }
452 
453 // --------------------------------------------------------------------
454 
455 // XAnimationNode
456 void SAL_CALL RandomAnimationNode::setRestartDefault( sal_Int16 _restartdefault ) throw (RuntimeException)
457 {
458 	Guard< Mutex > aGuard( maMutex );
459 	mnRestartDefault = _restartdefault;
460 }
461 
462 // --------------------------------------------------------------------
463 
464 // XAnimationNode
465 double SAL_CALL RandomAnimationNode::getAcceleration() throw (RuntimeException)
466 {
467 	Guard< Mutex > aGuard( maMutex );
468 	return mfAcceleration;
469 }
470 
471 // --------------------------------------------------------------------
472 
473 // XAnimationNode
474 void SAL_CALL RandomAnimationNode::setAcceleration( double _acceleration ) throw (RuntimeException)
475 {
476 	Guard< Mutex > aGuard( maMutex );
477 	mfAcceleration = _acceleration;
478 }
479 
480 // --------------------------------------------------------------------
481 
482 // XAnimationNode
483 double SAL_CALL RandomAnimationNode::getDecelerate() throw (RuntimeException)
484 {
485 	Guard< Mutex > aGuard( maMutex );
486 	return mfDecelerate;
487 }
488 
489 // --------------------------------------------------------------------
490 
491 // XAnimationNode
492 void SAL_CALL RandomAnimationNode::setDecelerate( double _decelerate ) throw (RuntimeException)
493 {
494 	Guard< Mutex > aGuard( maMutex );
495 	mfDecelerate = _decelerate;
496 }
497 
498 // --------------------------------------------------------------------
499 
500 // XAnimationNode
501 sal_Bool SAL_CALL RandomAnimationNode::getAutoReverse() throw (RuntimeException)
502 {
503 	Guard< Mutex > aGuard( maMutex );
504 	return mbAutoReverse;
505 }
506 
507 // --------------------------------------------------------------------
508 
509 // XAnimationNode
510 void SAL_CALL RandomAnimationNode::setAutoReverse( sal_Bool _autoreverse ) throw (RuntimeException)
511 {
512 	Guard< Mutex > aGuard( maMutex );
513 	mbAutoReverse = _autoreverse;
514 }
515 
516 // --------------------------------------------------------------------
517 
518 Sequence< NamedValue > SAL_CALL RandomAnimationNode::getUserData() throw (RuntimeException)
519 {
520 	Guard< Mutex > aGuard( maMutex );
521 	return maUserData;
522 }
523 
524 // --------------------------------------------------------------------
525 
526 void SAL_CALL RandomAnimationNode::setUserData( const Sequence< NamedValue >& _userdata ) throw (RuntimeException)
527 {
528 	Guard< Mutex > aGuard( maMutex );
529 	maUserData = _userdata;
530 }
531 
532 // --------------------------------------------------------------------
533 
534 // XChild
535 Reference< XInterface > SAL_CALL RandomAnimationNode::getParent() throw (RuntimeException)
536 {
537 	Guard< Mutex > aGuard( maMutex );
538 	return mxParent;
539 }
540 
541 // --------------------------------------------------------------------
542 
543 // XChild
544 void SAL_CALL RandomAnimationNode::setParent( const Reference< XInterface >& Parent ) throw (NoSupportException, RuntimeException)
545 {
546 	Guard< Mutex > aGuard( maMutex );
547 	mxParent = Parent;
548 }
549 
550 // --------------------------------------------------------------------
551 
552 // XCloneable
553 Reference< XCloneable > SAL_CALL RandomAnimationNode::createClone() throw (RuntimeException)
554 {
555 	Reference< XCloneable > xNewNode( new RandomAnimationNode( *this ) );
556 	return xNewNode;
557 }
558 
559 // --------------------------------------------------------------------
560 
561 // XElementAccess
562 Type SAL_CALL RandomAnimationNode::getElementType() throw (RuntimeException)
563 {
564 	return ::getCppuType((const Reference< XAnimationNode >*)0);
565 }
566 
567 // --------------------------------------------------------------------
568 
569 // XElementAccess
570 sal_Bool SAL_CALL RandomAnimationNode::hasElements() throw (RuntimeException)
571 {
572 	return sal_True;
573 }
574 
575 // --------------------------------------------------------------------
576 
577 // XEnumerationAccess
578 Reference< XEnumeration > SAL_CALL RandomAnimationNode::createEnumeration()
579 	throw (RuntimeException)
580 {
581 	Guard< Mutex > aGuard( maMutex );
582 
583 	if( !maTarget.hasValue() && mxFirstNode.is() )
584 	{
585 		Any aTarget( mxFirstNode->getTarget() );
586 		if( aTarget.hasValue() )
587 		{
588 			maTarget = aTarget;
589 			mxFirstNode.clear();
590 		}
591 	}
592 
593 	Reference< XEnumeration > xEnum;
594 
595 	Reference< XEnumerationAccess > aEnumAccess( CustomAnimationPresets::getCustomAnimationPresets().getRandomPreset( mnPresetClass ), UNO_QUERY );
596 
597 	if( aEnumAccess.is() )
598 	{
599 		Reference< XEnumeration > xEnumeration( aEnumAccess->createEnumeration(), UNO_QUERY );
600 		if( xEnumeration.is() )
601 		{
602 			while( xEnumeration->hasMoreElements() )
603 			{
604 				Reference< XAnimate > xAnimate( xEnumeration->nextElement(), UNO_QUERY );
605 				if( xAnimate.is() )
606 					xAnimate->setTarget( maTarget );
607 			}
608 		}
609 		xEnum = aEnumAccess->createEnumeration();
610 	}
611 	else
612 	{
613 		// no presets? give empty node!
614 		Reference< XMultiServiceFactory > xServiceFactory( comphelper::getProcessServiceFactory() );
615 		Reference< XEnumerationAccess > aEmptyEnumAccess(
616 			xServiceFactory->createInstance(
617 				OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.animations.ParallelTimeContainer" ))),
618 			UNO_QUERY );
619 
620 		if( aEmptyEnumAccess.is() )
621 			xEnum = aEmptyEnumAccess->createEnumeration();
622 	}
623 
624 	return xEnum;
625 }
626 
627 // --------------------------------------------------------------------
628 
629 
630 // XTimeContainer
631 Reference< XAnimationNode > SAL_CALL RandomAnimationNode::insertBefore( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >&  )
632 	throw (IllegalArgumentException, NoSuchElementException, ElementExistException, WrappedTargetException, RuntimeException)
633 {
634 	return appendChild( newChild );
635 }
636 
637 // --------------------------------------------------------------------
638 
639 // XTimeContainer
640 Reference< XAnimationNode > SAL_CALL RandomAnimationNode::insertAfter( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >&  )
641 	throw (IllegalArgumentException, NoSuchElementException, ElementExistException, WrappedTargetException, RuntimeException)
642 {
643 	return appendChild( newChild );
644 }
645 
646 // --------------------------------------------------------------------
647 
648 // XTimeContainer
649 Reference< XAnimationNode > SAL_CALL RandomAnimationNode::replaceChild( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >&  )
650 	throw( IllegalArgumentException, NoSuchElementException, ElementExistException, WrappedTargetException, RuntimeException)
651 {
652 	return appendChild( newChild );
653 }
654 
655 // --------------------------------------------------------------------
656 
657 // XTimeContainer
658 Reference< XAnimationNode > SAL_CALL RandomAnimationNode::removeChild( const Reference< XAnimationNode >& oldChild )
659 	throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
660 {
661 	return oldChild;
662 }
663 
664 // --------------------------------------------------------------------
665 
666 // XTimeContainer
667 Reference< XAnimationNode > SAL_CALL RandomAnimationNode::appendChild( const Reference< XAnimationNode >& newChild )
668 	throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
669 {
670 	Reference< XAnimate > xAnimate( newChild, UNO_QUERY );
671 	if( xAnimate.is() )
672 	{
673 		Any aTarget( xAnimate->getTarget() );
674 		if( aTarget.hasValue() )
675 			maTarget = aTarget;
676 	}
677 
678 	if( !maTarget.hasValue() && !mxFirstNode.is() )
679 		mxFirstNode = xAnimate;
680 
681 	return newChild;
682 }
683 
684 // XServiceInfo
685 OUString RandomAnimationNode::getImplementationName() throw()
686 {
687 	return RandomNode__getImplementationName();
688 }
689 
690 // XServiceInfo
691 sal_Bool RandomAnimationNode::supportsService(const OUString& ServiceName) throw()
692 {
693 	return ServiceName.equalsAscii( pSN1 ) || ServiceName.equalsAscii( pSN2 );
694 }
695 
696 // XServiceInfo
697 Sequence< OUString > RandomAnimationNode::getSupportedServiceNames(void) throw()
698 {
699 	return RandomNode_getSupportedServiceNames();
700 }
701 
702 }
703 
704