/src/libreoffice/oox/source/ppt/timenode.cxx
Line | Count | Source |
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 <oox/ppt/timenode.hxx> |
21 | | |
22 | | #include <com/sun/star/beans/NamedValue.hpp> |
23 | | #include <com/sun/star/container/XEnumerationAccess.hpp> |
24 | | #include <com/sun/star/lang/XMultiServiceFactory.hpp> |
25 | | #include <com/sun/star/animations/XAnimateColor.hpp> |
26 | | #include <com/sun/star/animations/XAnimateMotion.hpp> |
27 | | #include <com/sun/star/animations/XAnimateTransform.hpp> |
28 | | #include <com/sun/star/animations/XCommand.hpp> |
29 | | #include <com/sun/star/animations/XAudio.hpp> |
30 | | #include <com/sun/star/animations/XIterateContainer.hpp> |
31 | | #include <com/sun/star/animations/XTimeContainer.hpp> |
32 | | #include <com/sun/star/animations/XTransitionFilter.hpp> |
33 | | #include <com/sun/star/animations/AnimationNodeType.hpp> |
34 | | #include <com/sun/star/animations/Event.hpp> |
35 | | #include <com/sun/star/animations/EventTrigger.hpp> |
36 | | #include <com/sun/star/io/WrongFormatException.hpp> |
37 | | #include <com/sun/star/presentation/EffectNodeType.hpp> |
38 | | #include <com/sun/star/uno/XComponentContext.hpp> |
39 | | |
40 | | #include <oox/core/xmlfilterbase.hxx> |
41 | | #include <oox/ppt/pptfilterhelpers.hxx> |
42 | | #include <oox/token/tokens.hxx> |
43 | | #include <sal/log.hxx> |
44 | | #include <comphelper/diagnose_ex.hxx> |
45 | | |
46 | | using namespace ::oox::core; |
47 | | using namespace ::com::sun::star::beans; |
48 | | using namespace ::com::sun::star::container; |
49 | | using namespace ::com::sun::star::uno; |
50 | | using namespace ::com::sun::star::lang; |
51 | | using namespace ::com::sun::star::animations; |
52 | | using namespace ::com::sun::star::presentation; |
53 | | |
54 | | namespace { |
55 | | |
56 | | void lcl_setAncestorSubItem( const Reference<XAnimationNode>& xParent, sal_Int16 nSubItem ) |
57 | 239 | { |
58 | | |
59 | 239 | Reference<XAnimationNode> xNode = xParent; |
60 | | |
61 | 1.43k | while ( xNode.is() ) |
62 | 1.19k | { |
63 | 1.19k | if ( xNode->getType() == AnimationNodeType::ANIMATE ) |
64 | 0 | { |
65 | 0 | Reference<XAnimate> xAnimate( xNode, UNO_QUERY ); |
66 | 0 | if ( xAnimate.is() ) |
67 | 0 | xAnimate->setSubItem( nSubItem ); |
68 | 0 | break; |
69 | 0 | } |
70 | 1.19k | else if ( xNode->getType() == AnimationNodeType::ITERATE ) |
71 | 0 | { |
72 | 0 | Reference<XIterateContainer> xIterateContainer( xNode, UNO_QUERY ); |
73 | 0 | if ( xIterateContainer.is() ) |
74 | 0 | xIterateContainer->setSubItem( nSubItem ); |
75 | 0 | break; |
76 | 0 | } |
77 | | |
78 | 1.19k | xNode.set( xNode->getParent(), UNO_QUERY ); |
79 | 1.19k | } |
80 | 239 | } |
81 | | |
82 | | } |
83 | | |
84 | | namespace oox::ppt { |
85 | | OUString TimeNode::getServiceName( sal_Int16 nNodeType ) |
86 | 1.15k | { |
87 | 1.15k | OUString sServiceName; |
88 | 1.15k | switch( nNodeType ) |
89 | 1.15k | { |
90 | 195 | case AnimationNodeType::PAR: |
91 | 195 | sServiceName = "com.sun.star.animations.ParallelTimeContainer"; |
92 | 195 | break; |
93 | 647 | case AnimationNodeType::SEQ: |
94 | 647 | sServiceName = "com.sun.star.animations.SequenceTimeContainer"; |
95 | 647 | break; |
96 | 70 | case AnimationNodeType::ANIMATE: |
97 | 70 | sServiceName = "com.sun.star.animations.Animate"; |
98 | 70 | break; |
99 | 0 | case AnimationNodeType::ITERATE: |
100 | 0 | sServiceName = "com.sun.star.animations.IterateContainer"; |
101 | 0 | break; |
102 | 10 | case AnimationNodeType::ANIMATECOLOR: |
103 | 10 | sServiceName = "com.sun.star.animations.AnimateColor"; |
104 | 10 | break; |
105 | 45 | case AnimationNodeType::TRANSITIONFILTER: |
106 | 45 | sServiceName = "com.sun.star.animations.TransitionFilter"; |
107 | 45 | break; |
108 | 1 | case AnimationNodeType::ANIMATEMOTION: |
109 | 1 | sServiceName = "com.sun.star.animations.AnimateMotion"; |
110 | 1 | break; |
111 | 70 | case AnimationNodeType::ANIMATETRANSFORM: |
112 | 70 | sServiceName = "com.sun.star.animations.AnimateTransform"; |
113 | 70 | break; |
114 | 0 | case AnimationNodeType::COMMAND: |
115 | 0 | sServiceName = "com.sun.star.animations.Command"; |
116 | 0 | break; |
117 | 113 | case AnimationNodeType::SET: |
118 | 113 | sServiceName = "com.sun.star.animations.AnimateSet"; |
119 | 113 | break; |
120 | 0 | case AnimationNodeType::AUDIO: |
121 | 0 | sServiceName = "com.sun.star.animations.Audio"; |
122 | 0 | break; |
123 | 0 | default: |
124 | 0 | SAL_INFO("oox.ppt","OOX: unhandled type " << nNodeType ); |
125 | 0 | break; |
126 | 1.15k | } |
127 | 1.15k | return sServiceName; |
128 | 1.15k | } |
129 | | |
130 | | TimeNode::TimeNode( sal_Int16 nNodeType ) |
131 | 1.91k | : mnNodeType( nNodeType ) |
132 | 1.91k | , mbHasEndSyncValue( false ) |
133 | 1.91k | { |
134 | 1.91k | } |
135 | | |
136 | | TimeNode::~TimeNode() |
137 | 1.91k | { |
138 | 1.91k | } |
139 | | |
140 | | void fixMainSequenceTiming( const css::uno::Reference< css::animations::XAnimationNode >& xNode ) |
141 | 1.68k | { |
142 | 1.68k | try |
143 | 1.68k | { |
144 | 1.68k | bool bFirst = true; |
145 | 1.68k | Reference< XEnumerationAccess > xEA( xNode, UNO_QUERY_THROW ); |
146 | 1.68k | Reference< XEnumeration > xE( xEA->createEnumeration(), UNO_SET_THROW ); |
147 | 2.98k | while( xE->hasMoreElements() ) |
148 | 1.29k | { |
149 | | // click node |
150 | 1.29k | Reference< XAnimationNode > xClickNode( xE->nextElement(), UNO_QUERY ); |
151 | | |
152 | 1.29k | Event aEvent; |
153 | 1.29k | aEvent.Trigger = EventTrigger::ON_NEXT; |
154 | 1.29k | aEvent.Repeat = 0; |
155 | 1.29k | xClickNode->setBegin( Any( aEvent ) ); |
156 | | |
157 | 1.29k | if( bFirst ) |
158 | 667 | { |
159 | 667 | bFirst = false; |
160 | 667 | Reference< XEnumerationAccess > xEA2( xClickNode, UNO_QUERY_THROW ); |
161 | 667 | Reference< XEnumeration > xE2( xEA2->createEnumeration(), UNO_SET_THROW ); |
162 | 667 | if( xE2->hasMoreElements() ) |
163 | 653 | { |
164 | | // with node |
165 | 653 | xE2->nextElement() >>= xEA2; |
166 | 653 | if( xEA2.is() ) |
167 | 653 | xE2 = xEA2->createEnumeration(); |
168 | 0 | else |
169 | 0 | xE2.clear(); |
170 | | |
171 | 653 | if( xE2.is() && xE2->hasMoreElements() ) |
172 | 650 | { |
173 | 650 | Reference< XAnimationNode > xEffectNode( xE2->nextElement(), UNO_QUERY_THROW ); |
174 | 650 | const Sequence< NamedValue > aUserData( xEffectNode->getUserData() ); |
175 | 650 | for( const NamedValue& rProp : aUserData ) |
176 | 1.47k | { |
177 | 1.47k | if ( rProp.Name == "node-type" ) |
178 | 619 | { |
179 | 619 | sal_Int16 nNodeType = 0; |
180 | 619 | rProp.Value >>= nNodeType; |
181 | 619 | if( nNodeType != css::presentation::EffectNodeType::ON_CLICK ) |
182 | 332 | { |
183 | | // first effect does not start on click, so correct |
184 | | // first click nodes begin to 0s |
185 | 332 | xClickNode->setBegin( Any( 0.0 ) ); |
186 | 332 | break; |
187 | 332 | } |
188 | 619 | } |
189 | 1.47k | } |
190 | 650 | } |
191 | 653 | } |
192 | 667 | } |
193 | 1.29k | } |
194 | 1.68k | } |
195 | 1.68k | catch( Exception& ) |
196 | 1.68k | { |
197 | 9 | SAL_INFO("oox.ppt","fixMainSequenceTiming(), exception caught!" ); |
198 | 9 | } |
199 | 1.68k | } |
200 | | |
201 | | void fixInteractiveSequenceTiming( const css::uno::Reference< css::animations::XAnimationNode >& xNode ) |
202 | 6 | { |
203 | 6 | try |
204 | 6 | { |
205 | 6 | Any aBegin( xNode->getBegin() ); |
206 | 6 | Any aEmpty; |
207 | 6 | xNode->setBegin( aEmpty ); |
208 | | |
209 | 6 | Reference< XEnumerationAccess > xEA( xNode, UNO_QUERY_THROW ); |
210 | 6 | Reference< XEnumeration > xE( xEA->createEnumeration(), UNO_SET_THROW ); |
211 | 15 | while( xE->hasMoreElements() ) |
212 | 9 | { |
213 | | // click node |
214 | 9 | Reference< XAnimationNode > xClickNode( xE->nextElement(), UNO_QUERY ); |
215 | 9 | xClickNode->setBegin( aBegin ); |
216 | 9 | } |
217 | 6 | } |
218 | 6 | catch( Exception& ) |
219 | 6 | { |
220 | 0 | SAL_INFO("oox.ppt","fixInteractiveSequenceTiming(), exception caught!" ); |
221 | 0 | } |
222 | 6 | } |
223 | | |
224 | | void TimeNode::addNode( const XmlFilterBase& rFilter, const Reference< XAnimationNode >& rxNode, const SlidePersistPtr & pSlide ) |
225 | 1.15k | { |
226 | 1.15k | try { |
227 | 1.15k | sal_Int16 nNodeType = mnNodeType; |
228 | | |
229 | 1.15k | if (mnNodeType == AnimationNodeType::PAR && maNodeProperties[NP_ITERATETYPE].hasValue()) |
230 | 0 | nNodeType = AnimationNodeType::ITERATE; |
231 | | |
232 | 1.15k | OUString sServiceName = getServiceName(nNodeType); |
233 | | |
234 | 1.15k | Reference< XAnimationNode > xNode = createAndInsert( rFilter, sServiceName, rxNode ); |
235 | 1.15k | if (!xNode) |
236 | 0 | return; |
237 | 1.15k | setNode(rFilter, xNode, pSlide, rxNode); |
238 | 1.15k | } |
239 | 1.15k | catch( const Exception& ) |
240 | 1.15k | { |
241 | 0 | TOOLS_INFO_EXCEPTION("oox.ppt","OOX: exception raised in TimeNode::addNode()" ); |
242 | 0 | } |
243 | 1.15k | } |
244 | | |
245 | | void TimeNode::setNode(const XmlFilterBase& rFilter, const Reference< XAnimationNode >& xNode, const SlidePersistPtr & pSlide, const Reference<XAnimationNode>& xParent) |
246 | 1.90k | { |
247 | 1.90k | SAL_WARN_IF( !xNode.is(), "oox.ppt", "null node passed" ); |
248 | | |
249 | 1.90k | try { |
250 | 1.90k | if( !msId.isEmpty() ) |
251 | 1.90k | { |
252 | 1.90k | pSlide->getAnimNodesMap()[ msId ] = xNode; |
253 | 1.90k | } |
254 | | |
255 | 1.90k | if( mpTarget ) |
256 | 309 | { |
257 | 309 | sal_Int16 nSubItem(0); |
258 | 309 | maNodeProperties[ NP_TARGET ] = mpTarget->convert( pSlide, nSubItem ); |
259 | 309 | if( mpTarget->mnType == XML_spTgt ) |
260 | 309 | { |
261 | 309 | if ( xNode->getType() == AnimationNodeType::ANIMATE || |
262 | 239 | xNode->getType() == AnimationNodeType::ITERATE ) |
263 | 70 | { |
264 | 70 | maNodeProperties[ NP_SUBITEM ] <<= nSubItem; |
265 | 70 | } |
266 | 239 | else |
267 | 239 | lcl_setAncestorSubItem( xParent, nSubItem ); |
268 | 309 | } |
269 | 309 | } |
270 | | |
271 | 1.90k | if( !maStCondList.empty() ) |
272 | 341 | { |
273 | 341 | Any aAny = AnimationCondition::convertList( pSlide, maStCondList ); |
274 | 341 | if( aAny.hasValue() ) |
275 | 341 | { |
276 | 341 | xNode->setBegin( aAny ); |
277 | 341 | } |
278 | | |
279 | 341 | } |
280 | 1.90k | if( !maEndCondList.empty() ) |
281 | 0 | { |
282 | 0 | Any aAny = AnimationCondition::convertList( pSlide, maEndCondList ); |
283 | 0 | if( aAny.hasValue() ) |
284 | 0 | { |
285 | 0 | xNode->setEnd( aAny ); |
286 | 0 | } |
287 | 0 | } |
288 | 1.90k | if( mbHasEndSyncValue ) |
289 | 0 | { |
290 | 0 | Any aValue = maEndSyncValue.convert( pSlide ); |
291 | 0 | xNode->setEndSync(aValue); |
292 | 0 | } |
293 | | |
294 | 1.90k | if( !maUserData.empty() ) |
295 | 1.47k | { |
296 | 1.47k | Sequence< NamedValue > aUserDataSeq( static_cast< sal_Int32 >( maUserData.size() ) ); |
297 | 1.47k | NamedValue* pValues = aUserDataSeq.getArray(); |
298 | 1.47k | for (auto const& elem : maUserData) |
299 | 1.62k | { |
300 | 1.62k | pValues->Name = elem.first; |
301 | 1.62k | pValues->Value = elem.second; |
302 | 1.62k | ++pValues; |
303 | 1.62k | } |
304 | 1.47k | maNodeProperties[ NP_USERDATA ] <<= aUserDataSeq; |
305 | 1.47k | } |
306 | | |
307 | 1.90k | Reference< XAnimate > xAnimate( xNode, UNO_QUERY ); |
308 | 1.90k | Reference< XAnimateColor > xAnimateColor( xNode, UNO_QUERY ); |
309 | 1.90k | Reference< XAnimateMotion > xAnimateMotion( xNode, UNO_QUERY ); |
310 | 1.90k | Reference< XAnimateTransform > xAnimateTransform( xNode, UNO_QUERY ); |
311 | 1.90k | Reference< XCommand > xCommand( xNode, UNO_QUERY ); |
312 | 1.90k | Reference< XAudio > xAudio( xNode, UNO_QUERY ); |
313 | 1.90k | Reference< XIterateContainer > xIterateContainer( xNode, UNO_QUERY ); |
314 | 1.90k | sal_Int16 nInt16 = 0; |
315 | 1.90k | bool bBool = false; |
316 | 1.90k | double fDouble = 0; |
317 | 1.90k | OUString sString; |
318 | 1.90k | Sequence< NamedValue > aSeq; |
319 | | |
320 | 61.0k | for( int i = 0; i < NP_SIZE_; i++) |
321 | 59.1k | { |
322 | 59.1k | Any & aValue( maNodeProperties[ i ] ); |
323 | 59.1k | if( aValue.hasValue() ) |
324 | 6.91k | { |
325 | 6.91k | switch( i ) |
326 | 6.91k | { |
327 | 231 | case NP_TO: |
328 | 231 | if( xAnimate.is() ) |
329 | 231 | xAnimate->setTo( aValue ); |
330 | 231 | break; |
331 | 92 | case NP_FROM: |
332 | 92 | if( xAnimate.is() ) |
333 | 92 | xAnimate->setFrom( aValue ); |
334 | 92 | break; |
335 | 8 | case NP_BY: |
336 | 8 | if( xAnimate.is() ) |
337 | 8 | xAnimate->setBy( aValue ); |
338 | 8 | break; |
339 | 0 | case NP_HIDEDURINGSHOW: |
340 | 0 | if (xAudio.is() && (aValue >>= bBool)) |
341 | 0 | { |
342 | 0 | xAudio->setHideDuringShow(bBool); |
343 | 0 | } |
344 | 0 | break; |
345 | 0 | case NP_ISNARRATION: |
346 | 0 | if (xAudio.is() && (aValue >>= bBool)) |
347 | 0 | { |
348 | 0 | xAudio->setNarration(bBool); |
349 | 0 | } |
350 | 0 | break; |
351 | 309 | case NP_TARGET: |
352 | | |
353 | 309 | if (xParent.is() && xParent->getType() == AnimationNodeType::ITERATE) |
354 | 0 | { |
355 | 0 | Reference<XIterateContainer> xParentContainer(xParent, UNO_QUERY); |
356 | 0 | if (xParentContainer.is()) |
357 | 0 | xParentContainer->setTarget(aValue); |
358 | 0 | } |
359 | 309 | else |
360 | 309 | { |
361 | 309 | if (xAnimate.is()) |
362 | 309 | xAnimate->setTarget(aValue); |
363 | 309 | if (xCommand.is()) |
364 | 0 | xCommand->setTarget(aValue); |
365 | 309 | if (xAudio.is()) |
366 | 0 | xAudio->setSource(aValue); |
367 | 309 | } |
368 | 309 | break; |
369 | 70 | case NP_SUBITEM: |
370 | 70 | if( aValue >>= nInt16 ) |
371 | 70 | { |
372 | 70 | if( xAnimate.is() ) |
373 | 70 | { |
374 | 70 | xAnimate->setSubItem( nInt16 ); |
375 | 70 | } |
376 | 0 | else if ( xIterateContainer.is() ) |
377 | 0 | { |
378 | 0 | xIterateContainer->setSubItem( nInt16 ); |
379 | 0 | } |
380 | 70 | } |
381 | 0 | else |
382 | 0 | { |
383 | 0 | SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); |
384 | 0 | } |
385 | 70 | break; |
386 | 197 | case NP_ATTRIBUTENAME: |
387 | 197 | if( xAnimate.is() ) |
388 | 197 | { |
389 | 197 | if( aValue >>= sString ) |
390 | 197 | xAnimate->setAttributeName( sString ); |
391 | 0 | else |
392 | 0 | { |
393 | 0 | SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); |
394 | 0 | } |
395 | 197 | } |
396 | 197 | break; |
397 | 197 | case NP_CALCMODE: |
398 | 70 | if( xAnimate.is() ) |
399 | 70 | { |
400 | 70 | if( aValue >>= nInt16 ) |
401 | 70 | xAnimate->setCalcMode( nInt16 ); |
402 | 0 | else |
403 | 0 | { |
404 | 0 | SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); |
405 | 0 | } |
406 | 70 | } |
407 | 70 | break; |
408 | 70 | case NP_KEYTIMES: |
409 | 24 | if( xAnimate.is() ) |
410 | 24 | { |
411 | 24 | Sequence<double> aKeyTimes; |
412 | 24 | if( aValue >>= aKeyTimes ) |
413 | 24 | xAnimate->setKeyTimes(aKeyTimes); |
414 | 0 | else |
415 | 0 | { |
416 | 0 | SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); |
417 | 0 | } |
418 | 24 | } |
419 | 24 | break; |
420 | 24 | case NP_VALUES: |
421 | 24 | if( xAnimate.is() ) |
422 | 24 | { |
423 | 24 | Sequence<Any> aValues; |
424 | 24 | if( aValue >>= aValues ) |
425 | 24 | xAnimate->setValues(aValues); |
426 | 0 | else |
427 | 0 | { |
428 | 0 | SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); |
429 | 0 | } |
430 | 24 | } |
431 | 24 | break; |
432 | 24 | case NP_FORMULA: |
433 | 8 | if( xAnimate.is() ) |
434 | 8 | { |
435 | 8 | if( aValue >>= sString ) |
436 | 8 | xAnimate->setFormula(sString); |
437 | 0 | else |
438 | 0 | { |
439 | 0 | SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); |
440 | 0 | } |
441 | 8 | } |
442 | 8 | break; |
443 | 10 | case NP_COLORINTERPOLATION: |
444 | 10 | if( xAnimateColor.is() ) |
445 | 10 | { |
446 | 10 | if( aValue >>= nInt16 ) |
447 | 10 | xAnimateColor->setColorInterpolation( nInt16 ); |
448 | 0 | else |
449 | 0 | { |
450 | 0 | SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); |
451 | 0 | } |
452 | 10 | } |
453 | 10 | break; |
454 | 10 | case NP_DIRECTION: |
455 | 10 | if( xAnimateColor.is() ) |
456 | 10 | { |
457 | 10 | if( aValue >>= bBool ) |
458 | 10 | xAnimateColor->setDirection( bBool ); |
459 | 0 | else |
460 | 0 | { |
461 | 0 | SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); |
462 | 0 | } |
463 | 10 | } |
464 | 10 | break; |
465 | 10 | case NP_PATH: |
466 | 1 | if( xAnimateMotion.is() ) |
467 | 1 | xAnimateMotion->setPath( aValue ); |
468 | 1 | break; |
469 | 71 | case NP_TRANSFORMTYPE: |
470 | 71 | if( xAnimateTransform.is() ) |
471 | 70 | { |
472 | 70 | if( aValue >>= nInt16 ) |
473 | 70 | xAnimateTransform->setTransformType( nInt16 ); |
474 | 0 | else |
475 | 0 | { |
476 | 0 | SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); |
477 | 0 | } |
478 | 70 | } |
479 | 71 | break; |
480 | 1.47k | case NP_USERDATA: |
481 | 1.47k | if( aValue >>= aSeq ) |
482 | 1.47k | xNode->setUserData( aSeq ); |
483 | 0 | else |
484 | 0 | { |
485 | 0 | SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); |
486 | 0 | } |
487 | 1.47k | break; |
488 | 1.47k | case NP_ACCELERATION: |
489 | 70 | if( aValue >>= fDouble ) |
490 | 70 | xNode->setAcceleration( fDouble ); |
491 | 0 | else |
492 | 0 | { |
493 | 0 | SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); |
494 | 0 | } |
495 | 70 | break; |
496 | 70 | case NP_DECELERATE: |
497 | 55 | if( aValue >>= fDouble ) |
498 | 55 | xNode->setDecelerate( fDouble ); |
499 | 0 | else |
500 | 0 | { |
501 | 0 | SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); |
502 | 0 | } |
503 | 55 | break; |
504 | 1.90k | case NP_AUTOREVERSE: |
505 | 1.90k | if( aValue >>= bBool ) |
506 | 1.90k | xNode->setAutoReverse( bBool ); |
507 | 0 | else |
508 | 0 | { |
509 | 0 | SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); |
510 | 0 | } |
511 | 1.90k | break; |
512 | 1.90k | case NP_DURATION: |
513 | 1.12k | xNode->setDuration( aValue ); |
514 | 1.12k | break; |
515 | 398 | case NP_FILL: |
516 | 398 | if( aValue >>= nInt16 ) |
517 | 398 | xNode->setFill( nInt16 ); |
518 | 0 | else |
519 | 0 | { |
520 | 0 | SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); |
521 | 0 | } |
522 | 398 | break; |
523 | 398 | case NP_REPEATCOUNT: |
524 | 0 | xNode->setRepeatCount( aValue ); |
525 | 0 | break; |
526 | 0 | case NP_REPEATDURATION: |
527 | 0 | xNode->setRepeatDuration( aValue ); |
528 | 0 | break; |
529 | 758 | case NP_RESTART: |
530 | 758 | if( aValue >>= nInt16 ) |
531 | 758 | xNode->setRestart( nInt16 ); |
532 | 0 | else |
533 | 0 | { |
534 | 0 | SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); |
535 | 0 | } |
536 | 758 | break; |
537 | 758 | case NP_COMMAND: |
538 | 0 | if( xCommand.is() ) |
539 | 0 | { |
540 | 0 | if( aValue >>= nInt16 ) |
541 | 0 | xCommand->setCommand( nInt16 ); |
542 | 0 | else |
543 | 0 | { |
544 | 0 | SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); |
545 | 0 | } |
546 | 0 | } |
547 | 0 | break; |
548 | 0 | case NP_PARAMETER: |
549 | 0 | if( xCommand.is() ) |
550 | 0 | xCommand->setParameter( aValue ); |
551 | 0 | break; |
552 | 0 | case NP_ITERATETYPE: |
553 | 0 | if( xIterateContainer.is() ) |
554 | 0 | { |
555 | 0 | if( aValue >>= nInt16 ) |
556 | 0 | xIterateContainer->setIterateType( nInt16 ); |
557 | 0 | else |
558 | 0 | { |
559 | 0 | SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); |
560 | 0 | } |
561 | 0 | } |
562 | 0 | break; |
563 | 0 | case NP_ITERATEINTERVAL: |
564 | 0 | if( xIterateContainer.is() ) |
565 | 0 | { |
566 | 0 | if( aValue >>= fDouble ) |
567 | 0 | xIterateContainer->setIterateInterval( fDouble ); |
568 | 0 | else |
569 | 0 | { |
570 | 0 | SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); |
571 | 0 | } |
572 | 0 | } |
573 | 0 | break; |
574 | 2 | default: |
575 | 2 | SAL_INFO("oox.ppt","ERR-OOX: unknown prop index " << i ); |
576 | 2 | break; |
577 | 6.91k | } |
578 | 6.91k | } |
579 | 59.1k | } |
580 | | |
581 | 1.90k | if (xAnimate.is() && xAnimate->getValues().getLength() != xAnimate->getKeyTimes().getLength()) |
582 | 0 | throw css::io::WrongFormatException(); |
583 | | |
584 | 1.90k | if( mnNodeType == AnimationNodeType::TRANSITIONFILTER ) |
585 | 45 | { |
586 | | |
587 | 45 | Reference< XTransitionFilter > xFilter( xNode, UNO_QUERY ); |
588 | 45 | maTransitionFilter.setTransitionFilterProperties( xFilter ); |
589 | 45 | } |
590 | | |
591 | 1.90k | std::for_each( |
592 | 1.90k | maChildren.begin(), maChildren.end(), |
593 | 1.90k | [&rFilter, &xNode, &pSlide] (TimeNodePtr const & child) { |
594 | 1.15k | child->addNode(rFilter, xNode, pSlide); |
595 | 1.15k | } ); |
596 | | |
597 | 1.90k | switch( mnNodeType ) |
598 | 1.90k | { |
599 | 647 | case AnimationNodeType::SEQ: |
600 | 647 | { |
601 | 647 | sal_Int16 nEnum = 0; |
602 | 647 | if( maUserData[ u"node-type"_ustr ] >>= nEnum ) |
603 | 647 | { |
604 | 647 | if( nEnum == EffectNodeType::MAIN_SEQUENCE ) |
605 | 647 | { |
606 | 647 | fixMainSequenceTiming( xNode ); |
607 | 647 | } |
608 | 0 | else if( nEnum == EffectNodeType::INTERACTIVE_SEQUENCE ) |
609 | 0 | { |
610 | 0 | fixInteractiveSequenceTiming( xNode ); |
611 | 0 | } |
612 | 647 | } |
613 | 647 | break; |
614 | 0 | } |
615 | 953 | case AnimationNodeType::PAR: |
616 | | // some other cut&paste... from AnimationImporter::importAnimationContainer() |
617 | 953 | break; |
618 | 1.90k | } |
619 | 1.90k | } |
620 | 1.90k | catch( const Exception& ) |
621 | 1.90k | { |
622 | 0 | TOOLS_INFO_EXCEPTION("oox.ppt","OOX: exception raised in TimeNode::setNode()"); |
623 | 0 | } |
624 | 1.90k | } |
625 | | |
626 | | Reference< XAnimationNode > TimeNode::createAndInsert( |
627 | | const XmlFilterBase& rFilter, |
628 | | const OUString& rServiceName, |
629 | | const Reference< XAnimationNode >& rxNode ) |
630 | 1.15k | { |
631 | 1.15k | try { |
632 | 1.15k | Reference< XAnimationNode > xNode( Reference<css::lang::XMultiServiceFactory>(rFilter.getComponentContext()->getServiceManager(), UNO_QUERY_THROW)->createInstance( rServiceName ), UNO_QUERY_THROW ); |
633 | 1.15k | Reference< XTimeContainer > xParentContainer( rxNode, UNO_QUERY_THROW ); |
634 | | |
635 | 1.15k | xParentContainer->appendChild( xNode ); |
636 | 1.15k | return xNode; |
637 | 1.15k | } |
638 | 1.15k | catch( const Exception& ) |
639 | 1.15k | { |
640 | 0 | TOOLS_INFO_EXCEPTION("oox.ppt", "OOX: exception raised in TimeNode::createAndInsert() trying to create a service " << rServiceName); |
641 | 0 | } |
642 | | |
643 | 0 | return Reference< XAnimationNode >(); |
644 | 1.15k | } |
645 | | |
646 | | void TimeNode::setId( sal_Int32 nId ) |
647 | 1.91k | { |
648 | 1.91k | msId = OUString::number(nId); |
649 | 1.91k | } |
650 | | |
651 | | void TimeNode::setTo( const Any & aTo ) |
652 | 231 | { |
653 | 231 | maNodeProperties[ NP_TO ] = aTo; |
654 | 231 | } |
655 | | |
656 | | void TimeNode::setFrom( const Any & aFrom ) |
657 | 92 | { |
658 | 92 | maNodeProperties[ NP_FROM ] = aFrom; |
659 | 92 | } |
660 | | |
661 | | void TimeNode::setBy( const Any & aBy ) |
662 | 8 | { |
663 | 8 | maNodeProperties[ NP_BY ] = aBy; |
664 | 8 | } |
665 | | |
666 | | } |
667 | | |
668 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |