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/util/XCloneable.hpp>
21 : #include <com/sun/star/util/theMacroExpander.hpp>
22 : #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
23 : #include <com/sun/star/container/XNameAccess.hpp>
24 : #include <com/sun/star/configuration/theDefaultProvider.hpp>
25 : #include <com/sun/star/xml/sax/InputSource.hpp>
26 : #include <com/sun/star/xml/sax/Parser.hpp>
27 : #include <com/sun/star/xml/sax/SAXParseException.hpp>
28 : #include <com/sun/star/beans/PropertyValue.hpp>
29 : #include <com/sun/star/presentation/EffectPresetClass.hpp>
30 : #include <com/sun/star/beans/NamedValue.hpp>
31 : #include <unotools/streamwrap.hxx>
32 : #include <comphelper/processfactory.hxx>
33 : #include <comphelper/string.hxx>
34 : #include <unotools/pathoptions.hxx>
35 : #include <tools/stream.hxx>
36 :
37 : #include <tools/debug.hxx>
38 : #include <rtl/uri.hxx>
39 : #include <rtl/strbuf.hxx>
40 : #include <vcl/svapp.hxx>
41 : #include <osl/mutex.hxx>
42 : #include <unotools/ucbstreamhelper.hxx>
43 : #include <CustomAnimationPreset.hxx>
44 :
45 : #include <algorithm>
46 :
47 : using namespace ::com::sun::star;
48 : using namespace ::com::sun::star::uno;
49 : using namespace ::com::sun::star::animations;
50 : using namespace ::com::sun::star::presentation;
51 :
52 : using ::com::sun::star::io::XInputStream;
53 : using ::com::sun::star::lang::XMultiServiceFactory;
54 : using ::com::sun::star::container::XNameAccess;
55 : using ::com::sun::star::beans::PropertyValue;
56 : using ::com::sun::star::util::XCloneable;
57 : using ::com::sun::star::beans::NamedValue;
58 :
59 : namespace sd {
60 :
61 1 : static Reference< XNameAccess > getNodeAccess( const Reference< XMultiServiceFactory >& xConfigProvider, const OUString& rNodePath )
62 : {
63 1 : Reference< XNameAccess > xConfigAccess;
64 :
65 : try
66 : {
67 1 : Sequence< Any > aArgs( 1 );
68 2 : PropertyValue aPropValue;
69 1 : aPropValue.Name = "nodepath";
70 1 : aPropValue.Value <<= rNodePath;
71 1 : aArgs[0] <<= aPropValue;
72 :
73 2 : xConfigAccess = Reference< XNameAccess >::query(
74 1 : xConfigProvider->createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess" ,
75 3 : aArgs ));
76 : }
77 0 : catch (const Exception&)
78 : {
79 : OSL_FAIL( "sd::getNodeAccess(), Exception caught!" );
80 : }
81 :
82 1 : return xConfigAccess;
83 : }
84 :
85 1 : void implImportLabels( const Reference< XMultiServiceFactory >& xConfigProvider, const OUString& rNodePath, UStringMap& rStringMap )
86 : {
87 : try
88 : {
89 1 : Reference< XNameAccess > xConfigAccess( getNodeAccess( xConfigProvider, rNodePath ) );
90 1 : if( xConfigAccess.is() )
91 : {
92 1 : OUString aLabel( "Label" );
93 2 : Reference< XNameAccess > xNameAccess;
94 2 : Sequence< OUString > aNames( xConfigAccess->getElementNames() );
95 1 : const OUString* p = aNames.getConstArray();
96 1 : sal_Int32 n = aNames.getLength();
97 74 : while(n--)
98 : {
99 72 : xConfigAccess->getByName( *p ) >>= xNameAccess;
100 72 : if( xNameAccess.is() )
101 : {
102 72 : OUString aUIName;
103 72 : xNameAccess->getByName( aLabel ) >>= aUIName;
104 72 : if( !aUIName.isEmpty() )
105 : {
106 72 : rStringMap[ *p ] = aUIName;
107 72 : }
108 : }
109 :
110 72 : p++;
111 1 : }
112 1 : }
113 : }
114 0 : catch (const lang::WrappedTargetException&)
115 : {
116 : OSL_FAIL( "sd::implImportLabels(), WrappedTargetException caught!" );
117 : }
118 0 : catch (const Exception&)
119 : {
120 : OSL_FAIL( "sd::implImportLabels(), Exception caught!" );
121 : }
122 1 : }
123 :
124 0 : CustomAnimationPreset::CustomAnimationPreset( CustomAnimationEffectPtr pEffect )
125 : {
126 0 : maPresetId = pEffect->getPresetId();
127 0 : maProperty = pEffect->getProperty();
128 0 : mnPresetClass = pEffect->getPresetClass();
129 :
130 0 : add( pEffect );
131 :
132 0 : mfDuration = pEffect->getDuration();
133 0 : maDefaultSubTyp = pEffect->getPresetSubType();
134 :
135 0 : mbIsTextOnly = false;
136 :
137 0 : Sequence< NamedValue > aUserData( pEffect->getNode()->getUserData() );
138 0 : sal_Int32 nLength = aUserData.getLength();
139 0 : const NamedValue* p = aUserData.getConstArray();
140 :
141 0 : while( nLength-- )
142 : {
143 0 : if ( p->Name == "text-only" )
144 : {
145 0 : mbIsTextOnly = true;
146 0 : break;
147 : }
148 0 : p++;
149 0 : }
150 :
151 0 : }
152 :
153 0 : void CustomAnimationPreset::add( CustomAnimationEffectPtr pEffect )
154 : {
155 0 : maSubTypes[ pEffect->getPresetSubType() ] = pEffect;
156 0 : }
157 :
158 0 : UStringList CustomAnimationPreset::getSubTypes()
159 : {
160 0 : UStringList aSubTypes;
161 :
162 0 : if( maSubTypes.size() > 1 )
163 : {
164 0 : EffectsSubTypeMap::iterator aIter( maSubTypes.begin() );
165 0 : const EffectsSubTypeMap::iterator aEnd( maSubTypes.end() );
166 0 : while( aIter != aEnd )
167 0 : aSubTypes.push_back( (*aIter++).first );
168 : }
169 :
170 0 : return aSubTypes;
171 : }
172 :
173 0 : Reference< XAnimationNode > CustomAnimationPreset::create( const OUString& rstrSubType )
174 : {
175 : try
176 : {
177 0 : OUString strSubType( rstrSubType );
178 0 : if( strSubType.isEmpty() )
179 0 : strSubType = maDefaultSubTyp;
180 :
181 0 : CustomAnimationEffectPtr pEffect = maSubTypes[strSubType];
182 0 : if( pEffect.get() )
183 : {
184 0 : Reference< XCloneable > xCloneable( pEffect->getNode(), UNO_QUERY_THROW );
185 0 : Reference< XAnimationNode > xNode( xCloneable->createClone(), UNO_QUERY_THROW );
186 0 : return xNode;
187 0 : }
188 : }
189 0 : catch (const Exception&)
190 : {
191 : OSL_FAIL( "sd::CustomAnimationPresets::create(), exception caught!" );
192 : }
193 :
194 0 : Reference< XAnimationNode > xNode;
195 0 : return xNode;
196 : }
197 :
198 0 : UStringList CustomAnimationPreset::getProperties() const
199 : {
200 0 : String aProperties( maProperty );
201 0 : sal_uInt16 nTokens = comphelper::string::getTokenCount(aProperties, ';');
202 : sal_uInt16 nToken;
203 0 : UStringList aPropertyList;
204 0 : for( nToken = 0; nToken < nTokens; nToken++ )
205 0 : aPropertyList.push_back( aProperties.GetToken( nToken ) );
206 :
207 0 : return aPropertyList;
208 :
209 : }
210 :
211 0 : bool CustomAnimationPreset::hasProperty( const OUString& rProperty )const
212 : {
213 0 : String aProperties( maProperty );
214 0 : String aProperty( rProperty );
215 0 : sal_uInt16 nTokens = comphelper::string::getTokenCount(aProperties, ';');
216 : sal_uInt16 nToken;
217 0 : for( nToken = 0; nToken < nTokens; nToken++ )
218 : {
219 0 : if( aProperties.GetToken( nToken ) == aProperty )
220 0 : return true;
221 : }
222 :
223 0 : return false;
224 : }
225 :
226 0 : CustomAnimationPresets::CustomAnimationPresets()
227 : {
228 0 : }
229 :
230 0 : CustomAnimationPresets::~CustomAnimationPresets()
231 : {
232 0 : }
233 :
234 0 : void CustomAnimationPresets::init()
235 : {
236 0 : importResources();
237 0 : }
238 :
239 2 : Reference< XAnimationNode > implImportEffects( const Reference< XMultiServiceFactory >& xServiceFactory, const OUString& rPath )
240 : {
241 2 : Reference< XAnimationNode > xRootNode;
242 :
243 : try
244 : {
245 : // create stream
246 2 : SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( rPath, STREAM_READ );
247 2 : Reference<XInputStream> xInputStream( new utl::OInputStreamWrapper( pIStm, sal_True ) );
248 :
249 : // prepare ParserInputSrouce
250 4 : xml::sax::InputSource aParserInput;
251 2 : aParserInput.sSystemId = rPath;
252 2 : aParserInput.aInputStream = xInputStream;
253 :
254 : // get parser
255 4 : Reference< xml::sax::XParser > xParser = xml::sax::Parser::create( comphelper::getComponentContext(xServiceFactory) );
256 :
257 : // get filter
258 4 : Reference< xml::sax::XDocumentHandler > xFilter( xServiceFactory->createInstance("com.sun.star.comp.Xmloff.AnimationsImport" ), UNO_QUERY );
259 :
260 : DBG_ASSERT( xFilter.is(), "Can't instantiate filter component." );
261 2 : if( !xFilter.is() )
262 0 : return xRootNode;
263 :
264 : // connect parser and filter
265 2 : xParser->setDocumentHandler( xFilter );
266 :
267 : // finally, parser the stream
268 2 : xParser->parseStream( aParserInput );
269 :
270 4 : Reference< XAnimationNodeSupplier > xAnimationNodeSupplier( xFilter, UNO_QUERY );
271 2 : if( xAnimationNodeSupplier.is() )
272 4 : xRootNode = xAnimationNodeSupplier->getAnimationNode();
273 : }
274 0 : catch (const xml::sax::SAXParseException&)
275 : {
276 : OSL_FAIL( "sd::implImportEffects(), SAXParseException caught!" );
277 : }
278 0 : catch (const xml::sax::SAXException&)
279 : {
280 : OSL_FAIL( "sd::implImportEffects(), SAXException caught!" );
281 : }
282 0 : catch (const io::IOException&)
283 : {
284 : OSL_FAIL( "sd::implImportEffects(), IOException caught!" );
285 : }
286 0 : catch (const Exception&)
287 : {
288 : OSL_FAIL( "sd::importEffects(), Exception caught!" );
289 : }
290 :
291 2 : return xRootNode;
292 : }
293 :
294 : #define EXPAND_PROTOCOL "vnd.sun.star.expand:"
295 :
296 0 : void CustomAnimationPresets::importEffects()
297 : {
298 : try
299 : {
300 : uno::Reference< uno::XComponentContext > xContext(
301 0 : comphelper::getProcessComponentContext() );
302 : Reference< XMultiServiceFactory > xServiceFactory(
303 0 : xContext->getServiceManager(), UNO_QUERY_THROW );
304 :
305 : uno::Reference< util::XMacroExpander > xMacroExpander =
306 0 : util::theMacroExpander::get(xContext);
307 :
308 : Reference< XMultiServiceFactory > xConfigProvider =
309 0 : configuration::theDefaultProvider::get( xContext );
310 :
311 : // read path to transition effects files from config
312 : Any propValue = uno::makeAny(
313 : beans::PropertyValue(
314 : "nodepath", -1,
315 : uno::makeAny( OUString( "/org.openoffice.Office.Impress/Misc" )),
316 0 : beans::PropertyState_DIRECT_VALUE ) );
317 :
318 : Reference<container::XNameAccess> xNameAccess(
319 0 : xConfigProvider->createInstanceWithArguments(
320 : "com.sun.star.configuration.ConfigurationAccess",
321 0 : Sequence<Any>( &propValue, 1 ) ), UNO_QUERY_THROW );
322 0 : uno::Sequence< OUString > aFiles;
323 0 : xNameAccess->getByName( "EffectFiles" ) >>= aFiles;
324 :
325 0 : for( sal_Int32 i=0; i<aFiles.getLength(); ++i )
326 : {
327 0 : OUString aURL = aFiles[i];
328 0 : if( aURL.startsWith( EXPAND_PROTOCOL ) )
329 : {
330 : // cut protocol
331 0 : OUString aMacro( aURL.copy( sizeof ( EXPAND_PROTOCOL ) -1 ) );
332 : // decode uric class chars
333 0 : aMacro = rtl::Uri::decode( aMacro, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
334 : // expand macro string
335 0 : aURL = xMacroExpander->expandMacros( aMacro );
336 : }
337 :
338 0 : mxRootNode = implImportEffects( xServiceFactory, aURL );
339 :
340 0 : if( mxRootNode.is() )
341 : {
342 0 : Reference< XTimeContainer > xRootContainer( mxRootNode, UNO_QUERY_THROW );
343 0 : EffectSequenceHelper aSequence( xRootContainer );
344 :
345 0 : EffectSequence::iterator aIter( aSequence.getBegin() );
346 0 : const EffectSequence::iterator aEnd( aSequence.getEnd() );
347 :
348 0 : while( aIter != aEnd )
349 : {
350 0 : CustomAnimationEffectPtr pEffect = (*aIter);
351 :
352 0 : const OUString aPresetId( pEffect->getPresetId() );
353 0 : CustomAnimationPresetPtr pDescriptor = getEffectDescriptor( aPresetId );
354 0 : if( pDescriptor.get() )
355 0 : pDescriptor->add( pEffect );
356 : else
357 : {
358 0 : pDescriptor.reset( new CustomAnimationPreset( pEffect ) );
359 0 : pDescriptor->maLabel = getUINameForPresetId( pEffect->getPresetId() );
360 0 : maEffectDiscriptorMap[aPresetId] = pDescriptor;
361 : }
362 :
363 0 : ++aIter;
364 0 : }
365 : }
366 0 : }
367 : }
368 0 : catch (const xml::sax::SAXParseException&)
369 : {
370 : OSL_FAIL( "sd::CustomAnimationPresets::importEffects(), SAXParseException caught!" );
371 : }
372 0 : catch (const xml::sax::SAXException&)
373 : {
374 : OSL_FAIL( "sd::CustomAnimationPresets::importEffects(), SAXException caught!" );
375 : }
376 0 : catch (const io::IOException&)
377 : {
378 : OSL_FAIL( "sd::CustomAnimationPresets::importEffects(), IOException caught!" );
379 : }
380 0 : catch (const Exception&)
381 : {
382 : OSL_FAIL( "sd::CustomAnimationPresets::importEffects(), Exception caught!" );
383 : }
384 0 : }
385 :
386 0 : void CustomAnimationPresets::importResources()
387 : {
388 : try
389 : {
390 : // Get service factory
391 0 : Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() );
392 :
393 : Reference< XMultiServiceFactory > xConfigProvider =
394 0 : configuration::theDefaultProvider::get( xContext );
395 :
396 0 : const OUString aPropertyPath("/org.openoffice.Office.UI.Effects/UserInterface/Properties" );
397 0 : implImportLabels( xConfigProvider, aPropertyPath, maPropertyNameMap );
398 :
399 0 : const OUString aEffectsPath( "/org.openoffice.Office.UI.Effects/UserInterface/Effects" );
400 0 : implImportLabels( xConfigProvider, aEffectsPath, maEffectNameMap );
401 :
402 0 : importEffects();
403 :
404 0 : const OUString aEntrancePath( "/org.openoffice.Office.UI.Effects/Presets/Entrance" );
405 0 : importPresets( xConfigProvider, aEntrancePath, maEntrancePresets );
406 :
407 0 : const OUString aEmphasisPath( "/org.openoffice.Office.UI.Effects/Presets/Emphasis" );
408 0 : importPresets( xConfigProvider, aEmphasisPath, maEmphasisPresets );
409 :
410 0 : const OUString aExitPath( "/org.openoffice.Office.UI.Effects/Presets/Exit" );
411 0 : importPresets( xConfigProvider, aExitPath, maExitPresets );
412 :
413 0 : const OUString aMotionPathsPath( "/org.openoffice.Office.UI.Effects/Presets/MotionPaths" );
414 0 : importPresets( xConfigProvider, aMotionPathsPath, maMotionPathsPresets );
415 :
416 0 : const OUString aMiscPath( "/org.openoffice.Office.UI.Effects/Presets/Misc" );
417 0 : importPresets( xConfigProvider, aMiscPath, maMiscPresets );
418 : }
419 0 : catch (const lang::WrappedTargetException&)
420 : {
421 : OSL_FAIL( "sd::CustomAnimationPresets::importResources(), WrappedTargetException caught!" );
422 : }
423 0 : catch (const Exception&)
424 : {
425 : OSL_FAIL( "sd::CustomAnimationPresets::importResources(), Exception caught!" );
426 : }
427 0 : }
428 :
429 0 : void CustomAnimationPresets::importPresets( const Reference< XMultiServiceFactory >& xConfigProvider, const OUString& rNodePath, PresetCategoryList& rPresetMap )
430 : {
431 : #ifdef DEBUG
432 : String aMissedPresetIds;
433 : #endif
434 :
435 : try
436 : {
437 0 : Reference< XNameAccess > xTypeAccess( getNodeAccess( xConfigProvider, rNodePath ) );
438 0 : if( xTypeAccess.is() )
439 : {
440 0 : Reference< XNameAccess > xCategoryAccess;
441 0 : const OUString aEffectsName( "Effects" );
442 0 : const OUString aLabelName( "Label" );
443 :
444 0 : Sequence< OUString > aNames( xTypeAccess->getElementNames() );
445 0 : const OUString* p = aNames.getConstArray();
446 0 : sal_Int32 n = aNames.getLength();
447 0 : while(n--)
448 : {
449 0 : xTypeAccess->getByName( *p ) >>= xCategoryAccess;
450 :
451 0 : if( xCategoryAccess.is() && xCategoryAccess->hasByName( aLabelName ) && xCategoryAccess->hasByName( aEffectsName ) )
452 : {
453 0 : OUString aLabel;
454 0 : xCategoryAccess->getByName( aLabelName ) >>= aLabel;
455 :
456 0 : Sequence< OUString > aEffects;
457 0 : xCategoryAccess->getByName( aEffectsName ) >>= aEffects;
458 :
459 0 : EffectDescriptorList aEffectsList;
460 :
461 0 : const OUString* pEffectNames = aEffects.getConstArray();
462 0 : sal_Int32 nEffectCount = aEffects.getLength();
463 0 : while( nEffectCount-- )
464 : {
465 0 : CustomAnimationPresetPtr pEffect = getEffectDescriptor( *pEffectNames );
466 0 : if( pEffect.get() )
467 : {
468 0 : aEffectsList.push_back( pEffect );
469 : }
470 : #ifdef DEBUG
471 : else
472 : {
473 : aMissedPresetIds += String(*pEffectNames);
474 : aMissedPresetIds += String( "\n" );
475 : }
476 : #endif
477 0 : pEffectNames++;
478 0 : }
479 0 : rPresetMap.push_back( PresetCategoryPtr( new PresetCategory( aLabel, aEffectsList ) ) );
480 : }
481 :
482 0 : p++;
483 0 : }
484 0 : }
485 : }
486 0 : catch (const Exception&)
487 : {
488 : OSL_FAIL( "sd::CustomAnimationPresets::importPresets(), Exception caught!" );
489 : }
490 :
491 : #ifdef DEBUG
492 : if( aMissedPresetIds.Len() )
493 : {
494 : OStringBuffer aTmp("sd::CustomAnimationPresets::importPresets(), invalid preset id!\n");
495 : aTmp.append(OUStringToOString(aMissedPresetIds,
496 : RTL_TEXTENCODING_ASCII_US));
497 : OSL_FAIL(aTmp.getStr());
498 : }
499 : #endif
500 0 : }
501 :
502 0 : CustomAnimationPresetPtr CustomAnimationPresets::getEffectDescriptor( const OUString& rPresetId ) const
503 : {
504 0 : EffectDescriptorMap::const_iterator aIter( maEffectDiscriptorMap.find( rPresetId ) );
505 :
506 0 : if( aIter != maEffectDiscriptorMap.end() )
507 : {
508 0 : return (*aIter).second;
509 : }
510 : else
511 : {
512 0 : return CustomAnimationPresetPtr((CustomAnimationPreset*)0);
513 : }
514 : }
515 :
516 0 : const OUString& CustomAnimationPresets::getUINameForPresetId( const OUString& rPresetId ) const
517 : {
518 0 : return translateName( rPresetId, maEffectNameMap );
519 : }
520 :
521 0 : const OUString& CustomAnimationPresets::getUINameForProperty( const OUString& rPresetId ) const
522 : {
523 0 : return translateName( rPresetId, maPropertyNameMap );
524 : }
525 :
526 0 : const OUString& CustomAnimationPresets::translateName( const OUString& rId, const UStringMap& rNameMap ) const
527 : {
528 0 : UStringMap::const_iterator aIter( rNameMap.find( rId ) );
529 :
530 0 : if( aIter != rNameMap.end() )
531 : {
532 0 : return (*aIter).second;
533 : }
534 : else
535 : {
536 0 : return rId;
537 : }
538 : }
539 0 : void CustomAnimationPresets::changePresetSubType( CustomAnimationEffectPtr pEffect, const OUString& rPresetSubType ) const
540 : {
541 0 : if( pEffect.get() && pEffect->getPresetSubType() != rPresetSubType )
542 : {
543 0 : CustomAnimationPresetPtr pDescriptor( getEffectDescriptor( pEffect->getPresetId() ) );
544 :
545 0 : if( pDescriptor.get() )
546 : {
547 0 : Reference< XAnimationNode > xNewNode( pDescriptor->create( rPresetSubType ) );
548 0 : if( xNewNode.is() )
549 0 : pEffect->replaceNode( xNewNode );
550 0 : }
551 : }
552 0 : }
553 :
554 : CustomAnimationPresets* CustomAnimationPresets::mpCustomAnimationPresets = 0;
555 :
556 0 : const CustomAnimationPresets& CustomAnimationPresets::getCustomAnimationPresets()
557 : {
558 0 : if( !mpCustomAnimationPresets )
559 : {
560 0 : SolarMutexGuard aGuard;
561 :
562 0 : if( !mpCustomAnimationPresets )
563 : {
564 0 : mpCustomAnimationPresets = new sd::CustomAnimationPresets();
565 0 : mpCustomAnimationPresets->init();
566 0 : }
567 : }
568 :
569 0 : return *mpCustomAnimationPresets;
570 : }
571 :
572 0 : Reference< XAnimationNode > CustomAnimationPresets::getRandomPreset( sal_Int16 nPresetClass ) const
573 : {
574 0 : Reference< XAnimationNode > xNode;
575 :
576 0 : const PresetCategoryList* pCategoryList = 0;
577 0 : switch( nPresetClass )
578 : {
579 0 : case EffectPresetClass::ENTRANCE: pCategoryList = &maEntrancePresets; break;
580 0 : case EffectPresetClass::EXIT: pCategoryList = &maExitPresets; break;
581 0 : case EffectPresetClass::EMPHASIS: pCategoryList = &maEmphasisPresets; break;
582 0 : case EffectPresetClass::MOTIONPATH: pCategoryList = &maMotionPathsPresets; break;
583 : default:
584 0 : pCategoryList = 0;
585 : }
586 :
587 0 : if( pCategoryList && pCategoryList->size() )
588 : {
589 0 : sal_Int32 nCategory = (rand() * pCategoryList->size() / RAND_MAX);
590 :
591 0 : PresetCategoryPtr pCategory = (*pCategoryList)[nCategory];
592 0 : if( pCategory.get() && !pCategory->maEffects.empty() )
593 : {
594 0 : sal_Int32 nDescriptor = (rand() * pCategory->maEffects.size() / RAND_MAX);
595 0 : CustomAnimationPresetPtr pPreset = pCategory->maEffects[nDescriptor];
596 0 : if( pPreset.get() )
597 : {
598 0 : UStringList aSubTypes = pPreset->getSubTypes();
599 :
600 0 : OUString aSubType;
601 0 : if( !aSubTypes.empty() )
602 : {
603 0 : sal_Int32 nSubType = (rand() * aSubTypes.size() / RAND_MAX);
604 0 : aSubType = aSubTypes[nSubType];
605 : }
606 0 : xNode = pPreset->create( aSubType );
607 0 : }
608 0 : }
609 : }
610 :
611 0 : return xNode;
612 : }
613 :
614 :
615 33 : }
616 :
617 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|