Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <com/sun/star/animations/XTimeContainer.hpp>
21 : #include <com/sun/star/presentation/ParagraphTarget.hpp>
22 : #include <com/sun/star/animations/AnimationFill.hpp>
23 : #include <com/sun/star/animations/XAnimate.hpp>
24 : #include <com/sun/star/animations/AnimationRestart.hpp>
25 : #include <com/sun/star/animations/ParallelTimeContainer.hpp>
26 : #include <com/sun/star/lang/XServiceInfo.hpp>
27 : #include <com/sun/star/lang/XInitialization.hpp>
28 : #include <com/sun/star/container/XEnumerationAccess.hpp>
29 : #include <com/sun/star/util/XCloneable.hpp>
30 : #include <comphelper/processfactory.hxx>
31 :
32 : #include <cppuhelper/implbase5.hxx>
33 : #include <cppuhelper/supportsservice.hxx>
34 : #include <osl/mutex.hxx>
35 : #include "CustomAnimationPreset.hxx"
36 : #include "facreg.hxx"
37 : #include "randomnode.hxx"
38 :
39 : using ::osl::Mutex;
40 : using ::osl::Guard;
41 :
42 : using ::com::sun::star::uno::Reference;
43 : using ::com::sun::star::uno::RuntimeException;
44 : using ::com::sun::star::uno::Exception;
45 : using ::com::sun::star::uno::Sequence;
46 : using ::com::sun::star::uno::Any;
47 : using ::com::sun::star::uno::UNO_QUERY;
48 : using ::com::sun::star::uno::XInterface;
49 : using ::com::sun::star::lang::NoSupportException;
50 : using ::com::sun::star::beans::NamedValue;
51 : using ::com::sun::star::lang::IllegalArgumentException;
52 : using ::com::sun::star::container::NoSuchElementException;
53 : using ::com::sun::star::container::ElementExistException;
54 : using ::com::sun::star::lang::WrappedTargetException;
55 : using ::com::sun::star::container::XEnumeration;
56 : using ::com::sun::star::container::XEnumerationAccess;
57 : using ::com::sun::star::util::XCloneable;
58 : using ::com::sun::star::lang::XServiceInfo;
59 : using ::com::sun::star::lang::XInitialization;
60 : using ::com::sun::star::uno::Type;
61 : using ::com::sun::star::uno::XWeak;
62 : using ::com::sun::star::lang::XMultiServiceFactory;
63 : using ::com::sun::star::presentation::ParagraphTarget;
64 : using ::com::sun::star::drawing::XShape;
65 :
66 : using namespace ::com::sun::star::animations;
67 : namespace sd
68 : {
69 :
70 : typedef ::cppu::WeakImplHelper5< XTimeContainer, XEnumerationAccess, XCloneable, XServiceInfo, XInitialization > RandomAnimationNodeBase;
71 0 : class RandomAnimationNode : public RandomAnimationNodeBase
72 : {
73 : public:
74 : RandomAnimationNode( const RandomAnimationNode& rNode );
75 : RandomAnimationNode( sal_Int16 nPresetClass );
76 : RandomAnimationNode();
77 :
78 : void init( sal_Int16 nPresetClass );
79 :
80 : // XInitialization
81 : void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException, std::exception) SAL_OVERRIDE;
82 :
83 : // XChild
84 : Reference< XInterface > SAL_CALL getParent( ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
85 : void SAL_CALL setParent( const Reference< XInterface >& Parent ) throw (NoSupportException, RuntimeException, std::exception) SAL_OVERRIDE;
86 :
87 : // XCloneable
88 : virtual Reference< XCloneable > SAL_CALL createClone() throw (RuntimeException, std::exception) SAL_OVERRIDE;
89 :
90 : // XServiceInfo
91 : OUString SAL_CALL getImplementationName() throw(std::exception) SAL_OVERRIDE;
92 : Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw(std::exception) SAL_OVERRIDE;
93 : sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw(std::exception) SAL_OVERRIDE;
94 :
95 : // XAnimationNode
96 : ::sal_Int16 SAL_CALL getType() throw (RuntimeException, std::exception) SAL_OVERRIDE;
97 : Any SAL_CALL getBegin() throw (RuntimeException, std::exception) SAL_OVERRIDE;
98 : void SAL_CALL setBegin( const Any& _begin ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
99 : Any SAL_CALL getDuration() throw (RuntimeException, std::exception) SAL_OVERRIDE;
100 : void SAL_CALL setDuration( const Any& _duration ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
101 : Any SAL_CALL getEnd() throw (RuntimeException, std::exception) SAL_OVERRIDE;
102 : void SAL_CALL setEnd( const Any& _end ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
103 : Any SAL_CALL getEndSync() throw (RuntimeException, std::exception) SAL_OVERRIDE;
104 : void SAL_CALL setEndSync( const Any& _endsync ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
105 : Any SAL_CALL getRepeatCount() throw (RuntimeException, std::exception) SAL_OVERRIDE;
106 : void SAL_CALL setRepeatCount( const Any& _repeatcount ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
107 : Any SAL_CALL getRepeatDuration() throw (RuntimeException, std::exception) SAL_OVERRIDE;
108 : void SAL_CALL setRepeatDuration( const Any& _repeatduration ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
109 : ::sal_Int16 SAL_CALL getFill() throw (RuntimeException, std::exception) SAL_OVERRIDE;
110 : void SAL_CALL setFill( ::sal_Int16 _fill ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
111 : ::sal_Int16 SAL_CALL getFillDefault() throw (RuntimeException, std::exception) SAL_OVERRIDE;
112 : void SAL_CALL setFillDefault( ::sal_Int16 _filldefault ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
113 : ::sal_Int16 SAL_CALL getRestart() throw (RuntimeException, std::exception) SAL_OVERRIDE;
114 : void SAL_CALL setRestart( ::sal_Int16 _restart ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
115 : ::sal_Int16 SAL_CALL getRestartDefault() throw (RuntimeException, std::exception) SAL_OVERRIDE;
116 : void SAL_CALL setRestartDefault( ::sal_Int16 _restartdefault ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
117 : double SAL_CALL getAcceleration() throw (RuntimeException, std::exception) SAL_OVERRIDE;
118 : void SAL_CALL setAcceleration( double _acceleration ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
119 : double SAL_CALL getDecelerate() throw (RuntimeException, std::exception) SAL_OVERRIDE;
120 : void SAL_CALL setDecelerate( double _decelerate ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
121 : sal_Bool SAL_CALL getAutoReverse() throw (RuntimeException, std::exception) SAL_OVERRIDE;
122 : void SAL_CALL setAutoReverse( sal_Bool _autoreverse ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
123 : Sequence< NamedValue > SAL_CALL getUserData() throw (RuntimeException, std::exception) SAL_OVERRIDE;
124 : void SAL_CALL setUserData( const Sequence< NamedValue >& _userdata ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
125 :
126 : // XElementAccess
127 : virtual Type SAL_CALL getElementType() throw (RuntimeException, std::exception) SAL_OVERRIDE;
128 : virtual sal_Bool SAL_CALL hasElements() throw (RuntimeException, std::exception) SAL_OVERRIDE;
129 :
130 : // XEnumerationAccess
131 : virtual Reference< XEnumeration > SAL_CALL createEnumeration() throw (RuntimeException, std::exception) SAL_OVERRIDE;
132 :
133 : // XTimeContainer
134 : Reference< XAnimationNode > SAL_CALL insertBefore( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >& refChild ) throw (IllegalArgumentException, NoSuchElementException, ElementExistException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
135 : Reference< XAnimationNode > SAL_CALL insertAfter( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >& refChild ) throw (IllegalArgumentException, NoSuchElementException, ElementExistException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
136 : Reference< XAnimationNode > SAL_CALL replaceChild( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >& oldChild ) throw (IllegalArgumentException, NoSuchElementException, ElementExistException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
137 : Reference< XAnimationNode > SAL_CALL removeChild( const Reference< XAnimationNode >& oldChild ) throw (IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
138 : Reference< XAnimationNode > SAL_CALL appendChild( const Reference< XAnimationNode >& newChild ) throw (IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException, std::exception) SAL_OVERRIDE;
139 :
140 : private:
141 : // our first, last and only protection from mutli-threads!
142 : Mutex maMutex;
143 :
144 : sal_Int16 mnPresetClass;
145 : Reference< XInterface > mxParent;
146 :
147 : Any maBegin, maDuration, maEnd, maEndSync, maRepeatCount, maRepeatDuration, maTarget;
148 : sal_Int16 mnFill, mnFillDefault, mnRestart, mnRestartDefault;
149 : double mfAcceleration, mfDecelerate;
150 : bool mbAutoReverse;
151 : Sequence< NamedValue > maUserData;
152 :
153 : Reference< XAnimate > mxFirstNode;
154 : };
155 :
156 0 : Reference< XInterface > RandomAnimationNode_createInstance( sal_Int16 nPresetClass )
157 : {
158 0 : Reference< XInterface > xInt( static_cast<XWeak*>( new RandomAnimationNode( nPresetClass ) ) );
159 0 : return xInt;
160 : }
161 :
162 0 : Reference< XInterface > SAL_CALL RandomNode_createInstance( const Reference< XMultiServiceFactory > & )
163 : {
164 0 : Reference< XInterface > xInt( static_cast<XWeak*>( new RandomAnimationNode() ) );
165 0 : return xInt;
166 : }
167 :
168 34 : OUString RandomNode__getImplementationName() throw( RuntimeException )
169 : {
170 34 : return OUString( "sd::RandomAnimationNode" ) ;
171 : }
172 :
173 0 : Sequence< OUString > SAL_CALL RandomNode_getSupportedServiceNames() throw( RuntimeException )
174 : {
175 0 : Sequence< OUString > aSeq( 2 );
176 0 : aSeq[0] = "com.sun.star.animations.ParallelTimeContainer";
177 0 : aSeq[1] = "com.sun.star.comp.sd.RandomAnimationNode";
178 0 : return aSeq;
179 : }
180 :
181 0 : RandomAnimationNode::RandomAnimationNode( const RandomAnimationNode& rNode )
182 : : RandomAnimationNodeBase(),
183 : mnPresetClass( rNode.mnPresetClass ),
184 : maBegin( rNode.maBegin ),
185 : maDuration( rNode.maDuration ),
186 : maEnd( rNode.maEnd ),
187 : maEndSync( rNode.maEndSync ),
188 : maRepeatCount( rNode.maRepeatCount ),
189 : maRepeatDuration( rNode.maRepeatDuration ),
190 : maTarget( rNode.maTarget ),
191 : mnFill( rNode.mnFill ),
192 : mnFillDefault( rNode.mnFillDefault ),
193 : mnRestart( rNode.mnRestart ),
194 : mnRestartDefault( rNode.mnRestartDefault ),
195 : mfAcceleration( rNode.mfAcceleration ),
196 : mfDecelerate( rNode.mfDecelerate ),
197 : mbAutoReverse( rNode.mbAutoReverse ),
198 0 : maUserData( rNode.maUserData )
199 : {
200 0 : }
201 :
202 0 : RandomAnimationNode::RandomAnimationNode( sal_Int16 nPresetClass )
203 : {
204 0 : init( nPresetClass );
205 0 : }
206 :
207 0 : RandomAnimationNode::RandomAnimationNode()
208 : {
209 0 : init( 1 );
210 0 : }
211 :
212 0 : void RandomAnimationNode::init( sal_Int16 nPresetClass )
213 : {
214 0 : mnPresetClass = nPresetClass;
215 0 : mnFill = AnimationFill::DEFAULT;
216 0 : mnFillDefault = AnimationFill::INHERIT;
217 0 : mnRestart = AnimationRestart::DEFAULT;
218 0 : mnRestartDefault = AnimationRestart::INHERIT;
219 0 : mfAcceleration = 0.0;
220 0 : mfDecelerate = 0.0;
221 0 : mbAutoReverse = false;
222 0 : }
223 :
224 : // XInitialization
225 0 : void SAL_CALL RandomAnimationNode::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException, std::exception)
226 : {
227 0 : if( aArguments.getLength() != 1 )
228 0 : throw IllegalArgumentException();
229 :
230 0 : if( aArguments[0].getValueType() == ::cppu::UnoType<sal_Int16>::get() )
231 : {
232 0 : aArguments[0] >>= mnPresetClass;
233 : }
234 0 : else if( aArguments[0].getValueType() != ::cppu::UnoType<ParagraphTarget>::get() )
235 : {
236 0 : Reference< XShape > xShape;
237 0 : aArguments[0] >>= xShape;
238 0 : if( !xShape.is() )
239 0 : throw IllegalArgumentException();
240 : }
241 0 : maTarget = aArguments[0];
242 0 : }
243 :
244 : // XAnimationNode
245 0 : sal_Int16 SAL_CALL RandomAnimationNode::getType() throw (RuntimeException, std::exception)
246 : {
247 0 : Guard< Mutex > aGuard( maMutex );
248 0 : return ::com::sun::star::animations::AnimationNodeType::PAR;
249 : }
250 :
251 : // XAnimationNode
252 0 : Any SAL_CALL RandomAnimationNode::getBegin() throw (RuntimeException, std::exception)
253 : {
254 0 : Guard< Mutex > aGuard( maMutex );
255 0 : return maBegin;
256 : }
257 :
258 : // XAnimationNode
259 0 : void SAL_CALL RandomAnimationNode::setBegin( const Any& _begin ) throw (RuntimeException, std::exception)
260 : {
261 0 : Guard< Mutex > aGuard( maMutex );
262 0 : maBegin = _begin;
263 0 : }
264 :
265 : // XAnimationNode
266 0 : Any SAL_CALL RandomAnimationNode::getDuration() throw (RuntimeException, std::exception)
267 : {
268 0 : Guard< Mutex > aGuard( maMutex );
269 0 : return maDuration;
270 : }
271 :
272 : // XAnimationNode
273 0 : void SAL_CALL RandomAnimationNode::setDuration( const Any& _duration ) throw (RuntimeException, std::exception)
274 : {
275 0 : Guard< Mutex > aGuard( maMutex );
276 0 : maDuration = _duration;
277 0 : }
278 :
279 : // XAnimationNode
280 0 : Any SAL_CALL RandomAnimationNode::getEnd() throw (RuntimeException, std::exception)
281 : {
282 0 : Guard< Mutex > aGuard( maMutex );
283 0 : return maEnd;
284 : }
285 :
286 : // XAnimationNode
287 0 : void SAL_CALL RandomAnimationNode::setEnd( const Any& _end ) throw (RuntimeException, std::exception)
288 : {
289 0 : Guard< Mutex > aGuard( maMutex );
290 0 : maEnd = _end;
291 0 : }
292 :
293 : // XAnimationNode
294 0 : Any SAL_CALL RandomAnimationNode::getEndSync() throw (RuntimeException, std::exception)
295 : {
296 0 : Guard< Mutex > aGuard( maMutex );
297 0 : return maEndSync;
298 : }
299 :
300 : // XAnimationNode
301 0 : void SAL_CALL RandomAnimationNode::setEndSync( const Any& _endsync ) throw (RuntimeException, std::exception)
302 : {
303 0 : Guard< Mutex > aGuard( maMutex );
304 0 : maEndSync = _endsync;
305 0 : }
306 :
307 : // XAnimationNode
308 0 : Any SAL_CALL RandomAnimationNode::getRepeatCount() throw (RuntimeException, std::exception)
309 : {
310 0 : Guard< Mutex > aGuard( maMutex );
311 0 : return maRepeatCount;
312 : }
313 :
314 : // XAnimationNode
315 0 : void SAL_CALL RandomAnimationNode::setRepeatCount( const Any& _repeatcount ) throw (RuntimeException, std::exception)
316 : {
317 0 : Guard< Mutex > aGuard( maMutex );
318 0 : maRepeatCount = _repeatcount;
319 0 : }
320 :
321 : // XAnimationNode
322 0 : Any SAL_CALL RandomAnimationNode::getRepeatDuration() throw (RuntimeException, std::exception)
323 : {
324 0 : Guard< Mutex > aGuard( maMutex );
325 0 : return maRepeatDuration;
326 : }
327 :
328 : // XAnimationNode
329 0 : void SAL_CALL RandomAnimationNode::setRepeatDuration( const Any& _repeatduration ) throw (RuntimeException, std::exception)
330 : {
331 0 : Guard< Mutex > aGuard( maMutex );
332 0 : maRepeatDuration = _repeatduration;
333 0 : }
334 :
335 : // XAnimationNode
336 0 : sal_Int16 SAL_CALL RandomAnimationNode::getFill() throw (RuntimeException, std::exception)
337 : {
338 0 : Guard< Mutex > aGuard( maMutex );
339 0 : return mnFill;
340 : }
341 :
342 : // XAnimationNode
343 0 : void SAL_CALL RandomAnimationNode::setFill( sal_Int16 _fill ) throw (RuntimeException, std::exception)
344 : {
345 0 : Guard< Mutex > aGuard( maMutex );
346 0 : mnFill = _fill;
347 0 : }
348 :
349 : // XAnimationNode
350 0 : sal_Int16 SAL_CALL RandomAnimationNode::getFillDefault() throw (RuntimeException, std::exception)
351 : {
352 0 : Guard< Mutex > aGuard( maMutex );
353 0 : return mnFillDefault;
354 : }
355 :
356 : // XAnimationNode
357 0 : void SAL_CALL RandomAnimationNode::setFillDefault( sal_Int16 _filldefault ) throw (RuntimeException, std::exception)
358 : {
359 0 : Guard< Mutex > aGuard( maMutex );
360 0 : mnFillDefault = _filldefault;
361 0 : }
362 :
363 : // XAnimationNode
364 0 : sal_Int16 SAL_CALL RandomAnimationNode::getRestart() throw (RuntimeException, std::exception)
365 : {
366 0 : Guard< Mutex > aGuard( maMutex );
367 0 : return mnRestart;
368 : }
369 :
370 : // XAnimationNode
371 0 : void SAL_CALL RandomAnimationNode::setRestart( sal_Int16 _restart ) throw (RuntimeException, std::exception)
372 : {
373 0 : Guard< Mutex > aGuard( maMutex );
374 0 : mnRestart = _restart;
375 0 : }
376 :
377 : // XAnimationNode
378 0 : sal_Int16 SAL_CALL RandomAnimationNode::getRestartDefault() throw (RuntimeException, std::exception)
379 : {
380 0 : Guard< Mutex > aGuard( maMutex );
381 0 : return mnRestartDefault;
382 : }
383 :
384 : // XAnimationNode
385 0 : void SAL_CALL RandomAnimationNode::setRestartDefault( sal_Int16 _restartdefault ) throw (RuntimeException, std::exception)
386 : {
387 0 : Guard< Mutex > aGuard( maMutex );
388 0 : mnRestartDefault = _restartdefault;
389 0 : }
390 :
391 : // XAnimationNode
392 0 : double SAL_CALL RandomAnimationNode::getAcceleration() throw (RuntimeException, std::exception)
393 : {
394 0 : Guard< Mutex > aGuard( maMutex );
395 0 : return mfAcceleration;
396 : }
397 :
398 : // XAnimationNode
399 0 : void SAL_CALL RandomAnimationNode::setAcceleration( double _acceleration ) throw (RuntimeException, std::exception)
400 : {
401 0 : Guard< Mutex > aGuard( maMutex );
402 0 : mfAcceleration = _acceleration;
403 0 : }
404 :
405 : // XAnimationNode
406 0 : double SAL_CALL RandomAnimationNode::getDecelerate() throw (RuntimeException, std::exception)
407 : {
408 0 : Guard< Mutex > aGuard( maMutex );
409 0 : return mfDecelerate;
410 : }
411 :
412 : // XAnimationNode
413 0 : void SAL_CALL RandomAnimationNode::setDecelerate( double _decelerate ) throw (RuntimeException, std::exception)
414 : {
415 0 : Guard< Mutex > aGuard( maMutex );
416 0 : mfDecelerate = _decelerate;
417 0 : }
418 :
419 : // XAnimationNode
420 0 : sal_Bool SAL_CALL RandomAnimationNode::getAutoReverse() throw (RuntimeException, std::exception)
421 : {
422 0 : Guard< Mutex > aGuard( maMutex );
423 0 : return mbAutoReverse;
424 : }
425 :
426 : // XAnimationNode
427 0 : void SAL_CALL RandomAnimationNode::setAutoReverse( sal_Bool _autoreverse ) throw (RuntimeException, std::exception)
428 : {
429 0 : Guard< Mutex > aGuard( maMutex );
430 0 : mbAutoReverse = _autoreverse;
431 0 : }
432 :
433 0 : Sequence< NamedValue > SAL_CALL RandomAnimationNode::getUserData() throw (RuntimeException, std::exception)
434 : {
435 0 : Guard< Mutex > aGuard( maMutex );
436 0 : return maUserData;
437 : }
438 :
439 0 : void SAL_CALL RandomAnimationNode::setUserData( const Sequence< NamedValue >& _userdata ) throw (RuntimeException, std::exception)
440 : {
441 0 : Guard< Mutex > aGuard( maMutex );
442 0 : maUserData = _userdata;
443 0 : }
444 :
445 : // XChild
446 0 : Reference< XInterface > SAL_CALL RandomAnimationNode::getParent() throw (RuntimeException, std::exception)
447 : {
448 0 : Guard< Mutex > aGuard( maMutex );
449 0 : return mxParent;
450 : }
451 :
452 : // XChild
453 0 : void SAL_CALL RandomAnimationNode::setParent( const Reference< XInterface >& Parent ) throw (NoSupportException, RuntimeException, std::exception)
454 : {
455 0 : Guard< Mutex > aGuard( maMutex );
456 0 : mxParent = Parent;
457 0 : }
458 :
459 : // XCloneable
460 0 : Reference< XCloneable > SAL_CALL RandomAnimationNode::createClone() throw (RuntimeException, std::exception)
461 : {
462 0 : Reference< XCloneable > xNewNode( new RandomAnimationNode( *this ) );
463 0 : return xNewNode;
464 : }
465 :
466 : // XElementAccess
467 0 : Type SAL_CALL RandomAnimationNode::getElementType() throw (RuntimeException, std::exception)
468 : {
469 0 : return cppu::UnoType<XAnimationNode>::get();
470 : }
471 :
472 : // XElementAccess
473 0 : sal_Bool SAL_CALL RandomAnimationNode::hasElements() throw (RuntimeException, std::exception)
474 : {
475 0 : return sal_True;
476 : }
477 :
478 : // XEnumerationAccess
479 0 : Reference< XEnumeration > SAL_CALL RandomAnimationNode::createEnumeration()
480 : throw (RuntimeException, std::exception)
481 : {
482 0 : Guard< Mutex > aGuard( maMutex );
483 :
484 0 : if( !maTarget.hasValue() && mxFirstNode.is() )
485 : {
486 0 : Any aTarget( mxFirstNode->getTarget() );
487 0 : if( aTarget.hasValue() )
488 : {
489 0 : maTarget = aTarget;
490 0 : mxFirstNode.clear();
491 0 : }
492 : }
493 :
494 0 : Reference< XEnumeration > xEnum;
495 :
496 0 : Reference< XEnumerationAccess > aEnumAccess( CustomAnimationPresets::getCustomAnimationPresets().getRandomPreset( mnPresetClass ), UNO_QUERY );
497 :
498 0 : if( aEnumAccess.is() )
499 : {
500 0 : Reference< XEnumeration > xEnumeration( aEnumAccess->createEnumeration(), UNO_QUERY );
501 0 : if( xEnumeration.is() )
502 : {
503 0 : while( xEnumeration->hasMoreElements() )
504 : {
505 0 : Reference< XAnimate > xAnimate( xEnumeration->nextElement(), UNO_QUERY );
506 0 : if( xAnimate.is() )
507 0 : xAnimate->setTarget( maTarget );
508 0 : }
509 : }
510 0 : xEnum = aEnumAccess->createEnumeration();
511 : }
512 : else
513 : {
514 : // no presets? give empty node!
515 0 : Reference< XParallelTimeContainer > xTimeContainer = ParallelTimeContainer::create( comphelper::getProcessComponentContext() );
516 0 : xEnum = xTimeContainer->createEnumeration();
517 : }
518 :
519 0 : return xEnum;
520 : }
521 :
522 : // XTimeContainer
523 0 : Reference< XAnimationNode > SAL_CALL RandomAnimationNode::insertBefore( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >& )
524 : throw (IllegalArgumentException, NoSuchElementException, ElementExistException, WrappedTargetException, RuntimeException, std::exception)
525 : {
526 0 : return appendChild( newChild );
527 : }
528 :
529 : // XTimeContainer
530 0 : Reference< XAnimationNode > SAL_CALL RandomAnimationNode::insertAfter( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >& )
531 : throw (IllegalArgumentException, NoSuchElementException, ElementExistException, WrappedTargetException, RuntimeException, std::exception)
532 : {
533 0 : return appendChild( newChild );
534 : }
535 :
536 : // XTimeContainer
537 0 : Reference< XAnimationNode > SAL_CALL RandomAnimationNode::replaceChild( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >& )
538 : throw( IllegalArgumentException, NoSuchElementException, ElementExistException, WrappedTargetException, RuntimeException, std::exception)
539 : {
540 0 : return appendChild( newChild );
541 : }
542 :
543 : // XTimeContainer
544 0 : Reference< XAnimationNode > SAL_CALL RandomAnimationNode::removeChild( const Reference< XAnimationNode >& oldChild )
545 : throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
546 : {
547 0 : return oldChild;
548 : }
549 :
550 : // XTimeContainer
551 0 : Reference< XAnimationNode > SAL_CALL RandomAnimationNode::appendChild( const Reference< XAnimationNode >& newChild )
552 : throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException, std::exception)
553 : {
554 0 : Reference< XAnimate > xAnimate( newChild, UNO_QUERY );
555 0 : if( xAnimate.is() )
556 : {
557 0 : Any aTarget( xAnimate->getTarget() );
558 0 : if( aTarget.hasValue() )
559 0 : maTarget = aTarget;
560 : }
561 :
562 0 : if( !maTarget.hasValue() && !mxFirstNode.is() )
563 0 : mxFirstNode = xAnimate;
564 :
565 0 : return newChild;
566 : }
567 :
568 : // XServiceInfo
569 0 : OUString RandomAnimationNode::getImplementationName() throw(std::exception)
570 : {
571 0 : return RandomNode__getImplementationName();
572 : }
573 :
574 : // XServiceInfo
575 0 : sal_Bool RandomAnimationNode::supportsService(const OUString& ServiceName) throw(std::exception)
576 : {
577 0 : return cppu::supportsService(this, ServiceName);
578 : }
579 :
580 : // XServiceInfo
581 0 : Sequence< OUString > RandomAnimationNode::getSupportedServiceNames(void) throw(std::exception)
582 : {
583 0 : return RandomNode_getSupportedServiceNames();
584 : }
585 :
586 : }
587 :
588 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|