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