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/XAnimationNodeSupplier.hpp>
21 : #include <com/sun/star/animations/AnimationFill.hpp>
22 : #include <com/sun/star/animations/AnimationRestart.hpp>
23 : #include <com/sun/star/animations/Timing.hpp>
24 : #include <com/sun/star/animations/Event.hpp>
25 : #include <com/sun/star/animations/AnimationEndSync.hpp>
26 : #include <com/sun/star/animations/Command.hpp>
27 : #include <com/sun/star/animations/EventTrigger.hpp>
28 : #include <com/sun/star/animations/AnimationNodeType.hpp>
29 : #include <com/sun/star/animations/AnimationTransformType.hpp>
30 : #include <com/sun/star/animations/AnimationCalcMode.hpp>
31 : #include <com/sun/star/animations/AnimationValueType.hpp>
32 : #include <com/sun/star/animations/AnimationAdditiveMode.hpp>
33 : #include <com/sun/star/animations/XIterateContainer.hpp>
34 : #include <com/sun/star/animations/XAnimateSet.hpp>
35 : #include <com/sun/star/animations/XAudio.hpp>
36 : #include <com/sun/star/animations/XCommand.hpp>
37 : #include <com/sun/star/animations/XTransitionFilter.hpp>
38 : #include <com/sun/star/animations/XAnimateColor.hpp>
39 : #include <com/sun/star/animations/XAnimateMotion.hpp>
40 : #include <com/sun/star/animations/XAnimateTransform.hpp>
41 : #include <com/sun/star/animations/ValuePair.hpp>
42 : #include <com/sun/star/animations/AnimationColorSpace.hpp>
43 : #include <com/sun/star/presentation/EffectNodeType.hpp>
44 : #include <com/sun/star/presentation/EffectPresetClass.hpp>
45 : #include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
46 : #include <com/sun/star/presentation/EffectCommands.hpp>
47 : #include <com/sun/star/beans/NamedValue.hpp>
48 : #include <com/sun/star/drawing/FillStyle.hpp>
49 : #include <com/sun/star/drawing/LineStyle.hpp>
50 : #include <com/sun/star/awt/FontWeight.hpp>
51 : #include <com/sun/star/awt/FontUnderline.hpp>
52 : #include <com/sun/star/awt/FontSlant.hpp>
53 : #include <com/sun/star/container/XEnumerationAccess.hpp>
54 : #include <com/sun/star/presentation/ParagraphTarget.hpp>
55 : #include <com/sun/star/presentation/TextAnimationType.hpp>
56 : #include <comphelper/processfactory.hxx>
57 : #include <rtl/ustrbuf.hxx>
58 : #include <rtl/math.hxx>
59 :
60 : #include <vcl/vclenum.hxx>
61 : #include <svx/svdotext.hxx>
62 : #include <editeng/outlobj.hxx>
63 : #include <editeng/editobj.hxx>
64 : #include <pptinanimations.hxx>
65 : #include <pptatom.hxx>
66 : #include "pptin.hxx"
67 : #include "randomnode.hxx"
68 : #include <algorithm>
69 :
70 : using ::std::map;
71 : using ::com::sun::star::beans::NamedValue;
72 : using ::com::sun::star::container::XEnumerationAccess;
73 : using ::com::sun::star::container::XEnumeration;
74 : using ::com::sun::star::lang::XMultiServiceFactory;
75 :
76 : using namespace ::com::sun::star::uno;
77 : using namespace ::com::sun::star::drawing;
78 : using namespace ::com::sun::star::animations;
79 : using namespace ::com::sun::star::presentation;
80 :
81 : namespace ppt
82 : {
83 :
84 2 : const transition* transition::find( const OUString& rName )
85 : {
86 2 : const transition* p = gTransitions;
87 :
88 66 : while( p->mpName )
89 : {
90 64 : if( rName.equalsAscii( p->mpName ) )
91 2 : return p;
92 :
93 62 : p++;
94 : }
95 :
96 0 : return NULL;
97 : }
98 :
99 624 : SvStream& operator>>(SvStream& rIn, AnimationNode& rNode )
100 : {
101 624 : rIn.ReadInt32( rNode.mnU1 );
102 624 : rIn.ReadInt32( rNode.mnRestart );
103 624 : rIn.ReadInt32( rNode.mnGroupType );
104 624 : rIn.ReadInt32( rNode.mnFill );
105 624 : rIn.ReadInt32( rNode.mnU3 );
106 624 : rIn.ReadInt32( rNode.mnU4 );
107 624 : rIn.ReadInt32( rNode.mnDuration );
108 624 : rIn.ReadInt32( rNode.mnNodeType );
109 :
110 624 : return rIn;
111 : }
112 :
113 408 : static bool convertMeasure( OUString& rString )
114 : {
115 408 : bool bRet = false;
116 :
117 408 : const sal_Char* pSource[] = { "ppt_x", "ppt_y", "ppt_w", "ppt_h", NULL };
118 408 : const sal_Char* pDest[] = { "x", "y", "width", "height", NULL };
119 408 : sal_Int32 nIndex = 0;
120 :
121 408 : const sal_Char** ps = pSource;
122 408 : const sal_Char** pd = pDest;
123 :
124 2448 : while( *ps )
125 : {
126 1632 : const OUString aSearch( OUString::createFromAscii( *ps ) );
127 3672 : while( (nIndex = rString.indexOf( aSearch, nIndex )) != -1 )
128 : {
129 408 : sal_Int32 nLength = aSearch.getLength();
130 408 : if( nIndex && (rString[nIndex-1] == '#' ) )
131 : {
132 408 : nIndex--;
133 408 : nLength++;
134 : }
135 :
136 408 : const OUString aNew( OUString::createFromAscii( *pd ) );
137 408 : rString = rString.replaceAt( nIndex, nLength, aNew );
138 408 : nIndex += aNew.getLength();
139 408 : bRet = true;
140 408 : }
141 1632 : ps++;
142 1632 : pd++;
143 1632 : }
144 :
145 408 : return bRet;
146 : }
147 :
148 6582 : bool PropertySet::hasProperty( sal_Int32 nProperty ) const
149 : {
150 6582 : return maProperties.find( nProperty ) != maProperties.end();
151 : }
152 :
153 700 : Any PropertySet::getProperty( sal_Int32 nProperty ) const
154 : {
155 700 : PropertySetMap_t::const_iterator aIter( maProperties.find( nProperty ) );
156 700 : if( aIter != maProperties.end() )
157 700 : return (*aIter).second;
158 : else
159 0 : return Any();
160 : }
161 :
162 : /** this adds an any to another any.
163 : if rNewValue is empty, rOldValue is returned.
164 : if rOldValue is empty, rNewValue is returned.
165 : if rOldValue contains a value, a sequence with rOldValue and rNewValue is returned.
166 : if rOldValue contains a sequence, a new sequence with the old sequence and rNewValue is returned.
167 : */
168 376 : static Any addToSequence( const Any& rOldValue, const Any& rNewValue )
169 : {
170 376 : if( !rNewValue.hasValue() )
171 : {
172 0 : return rOldValue;
173 : }
174 376 : else if( !rOldValue.hasValue() )
175 : {
176 374 : return rNewValue;
177 : }
178 : else
179 : {
180 2 : Sequence< Any > aNewSeq;
181 2 : if( rOldValue >>= aNewSeq )
182 : {
183 0 : sal_Int32 nSize = aNewSeq.getLength();
184 0 : aNewSeq.realloc(nSize+1);
185 0 : aNewSeq[nSize] = rNewValue;
186 : }
187 : else
188 : {
189 2 : aNewSeq.realloc(2);
190 2 : aNewSeq[0] = rOldValue;
191 2 : aNewSeq[1] = rNewValue;
192 : }
193 2 : return makeAny( aNewSeq );
194 : }
195 : }
196 :
197 76 : AnimationImporter::AnimationImporter( ImplSdPPTImport* pPPTImport, SvStream& rStCtrl )
198 76 : : mpPPTImport( pPPTImport ), mrStCtrl( rStCtrl )
199 : {
200 76 : }
201 :
202 76 : int AnimationImporter::import( const Reference< XDrawPage >& xPage, const DffRecordHeader& rProgTagContentHd )
203 : {
204 76 : int nNodes = 0;
205 :
206 : #ifdef DBG_ANIM_LOG
207 : static int ppt_anim_debug_stream_number = 1;
208 : OUString ppt_anim_debug_filename("ppt-animation-import-debug-output-");
209 : ppt_anim_debug_filename += OUString::number(ppt_anim_debug_stream_number++);
210 : ppt_anim_debug_filename += ".xml";
211 : mpFile = fopen( OUStringToOString( ppt_anim_debug_filename, RTL_TEXTENCODING_UTF8).getStr() , "w+" );
212 : #endif
213 76 : dump("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
214 :
215 76 : Reference< XAnimationNodeSupplier > xNodeSupplier( xPage, UNO_QUERY );
216 76 : if( xNodeSupplier.is() )
217 : {
218 76 : mxRootNode = xNodeSupplier->getAnimationNode();
219 76 : if( mxRootNode.is() )
220 : {
221 76 : Reference< XAnimationNode > xParent;
222 :
223 152 : boost::scoped_ptr<Atom> pAtom(Atom::import( rProgTagContentHd, mrStCtrl ));
224 76 : if( pAtom )
225 : {
226 76 : nNodes = importAnimationContainer( pAtom.get(), xParent );
227 : }
228 :
229 152 : processAfterEffectNodes();
230 : }
231 : }
232 :
233 : #ifdef DBG_ANIM_LOG
234 : fclose( mpFile );
235 : #endif
236 :
237 76 : return nNodes;
238 : }
239 :
240 76 : void AnimationImporter::processAfterEffectNodes()
241 : {
242 76 : std::for_each( maAfterEffectNodes.begin(), maAfterEffectNodes.end(), sd::stl_process_after_effect_node_func );
243 76 : }
244 :
245 548 : Reference< XAnimationNode > AnimationImporter::createNode( const Atom* pAtom, const AnimationNode& rNode )
246 : {
247 548 : const char* pServiceName = NULL;
248 :
249 548 : switch( rNode.mnGroupType )
250 : {
251 : case mso_Anim_GroupType_PAR:
252 206 : if( pAtom->hasChildAtom( DFF_msofbtAnimIteration ) )
253 0 : pServiceName = "com.sun.star.animations.IterateContainer";
254 : else
255 206 : pServiceName = "com.sun.star.animations.ParallelTimeContainer";
256 206 : break;
257 : case mso_Anim_GroupType_SEQ:
258 32 : pServiceName = "com.sun.star.animations.SequenceTimeContainer";
259 32 : break;
260 : case mso_Anim_GroupType_NODE:
261 : {
262 310 : switch( rNode.mnNodeType )
263 : {
264 : case mso_Anim_Behaviour_FILTER:
265 : case mso_Anim_Behaviour_ANIMATION:
266 310 : if( pAtom->hasChildAtom( DFF_msofbtAnimateSet ) )
267 104 : pServiceName = "com.sun.star.animations.AnimateSet";
268 206 : else if( pAtom->hasChildAtom( DFF_msofbtAnimateColor ) )
269 0 : pServiceName = "com.sun.star.animations.AnimateColor";
270 206 : else if( pAtom->hasChildAtom( DFF_msofbtAnimateScale ) )
271 0 : pServiceName = "com.sun.star.animations.AnimateTransform";
272 206 : else if( pAtom->hasChildAtom( DFF_msofbtAnimateRotation ) )
273 0 : pServiceName = "com.sun.star.animations.AnimateTransform";
274 206 : else if( pAtom->hasChildAtom( DFF_msofbtAnimateMotion ) )
275 0 : pServiceName = "com.sun.star.animations.AnimateMotion";
276 206 : else if( pAtom->hasChildAtom( DFF_msofbtAnimateFilter ) )
277 2 : pServiceName = "com.sun.star.animations.TransitionFilter";
278 204 : else if( pAtom->hasChildAtom( DFF_msofbtAnimCommand ) )
279 0 : pServiceName = "com.sun.star.animations.Command";
280 : else
281 204 : pServiceName = "com.sun.star.animations.Animate";
282 310 : break;
283 : }
284 310 : break;
285 : }
286 : case mso_Anim_GroupType_MEDIA:
287 0 : pServiceName = "com.sun.star.animations.Audio";
288 0 : break;
289 :
290 : default:
291 0 : pServiceName = "com.sun.star.animations.Animate";
292 0 : break;
293 : }
294 :
295 548 : Reference< XAnimationNode > xNode;
296 548 : if( pServiceName )
297 : {
298 548 : Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
299 1096 : const OUString aServiceName( OUString::createFromAscii(pServiceName) );
300 1096 : Reference< XInterface > xFac( xContext->getServiceManager()->createInstanceWithContext(aServiceName, xContext) );
301 1096 : xNode.set(xFac , UNO_QUERY );
302 : }
303 :
304 : DBG_ASSERT( xNode.is(), "sd::AnimationImporter::createNode(), node creation failed!" );
305 548 : return xNode;
306 : }
307 :
308 548 : static bool is_random( const AnimationNode& rNode, const PropertySet& rSet, sal_Int32& rPresetClass )
309 : {
310 548 : if( rNode.mnGroupType != mso_Anim_GroupType_PAR )
311 342 : return false;
312 :
313 206 : if( !rSet.hasProperty( DFF_ANIM_PRESET_ID ) || !rSet.hasProperty( DFF_ANIM_PRESET_CLASS ) )
314 102 : return false;
315 :
316 104 : sal_Int32 nPresetId = 0;
317 104 : if( !(rSet.getProperty( DFF_ANIM_PRESET_ID ) >>= nPresetId) || (nPresetId != 24) )
318 104 : return false;
319 :
320 0 : sal_Int32 nPresetClass = 0;
321 0 : if( !(rSet.getProperty( DFF_ANIM_PRESET_CLASS ) >>= nPresetClass) )
322 0 : return false;
323 :
324 0 : switch( nPresetClass )
325 : {
326 0 : case DFF_ANIM_PRESS_CLASS_ENTRANCE: rPresetClass = EffectPresetClass::ENTRANCE; return true;
327 0 : case DFF_ANIM_PRESS_CLASS_EXIT: rPresetClass = EffectPresetClass::EXIT; return true;
328 : }
329 0 : return false;
330 : }
331 :
332 624 : int AnimationImporter::importAnimationContainer( const Atom* pAtom, const Reference< XAnimationNode >& xParent )
333 : {
334 624 : int nNodes = 0;
335 624 : if( pAtom->seekToContent() )
336 : {
337 624 : AnimationNode aNode;
338 624 : const Atom* pAnimationNodeAtom = pAtom->findFirstChildAtom( DFF_msofbtAnimNode );
339 624 : if( pAnimationNodeAtom && pAnimationNodeAtom->seekToContent() )
340 624 : mrStCtrl >> aNode;
341 :
342 624 : PropertySet aSet;
343 624 : const Atom* pAnimationPropertySetAtom = pAtom->findFirstChildAtom( DFF_msofbtAnimPropertySet );
344 624 : if( pAnimationPropertySetAtom )
345 624 : importPropertySetContainer( pAnimationPropertySetAtom, aSet );
346 :
347 1248 : Reference< XAnimationNode > xNode;
348 :
349 624 : if( xParent.is() )
350 : {
351 : sal_Int32 nPresetClass;
352 548 : if( is_random( aNode, aSet, nPresetClass ) )
353 : {
354 : // create a random animation node with the given preset class
355 0 : xNode.set( sd::RandomAnimationNode_createInstance( (sal_Int16)nPresetClass ), UNO_QUERY );
356 : }
357 :
358 548 : if( !xNode.is() )
359 : {
360 : // create a node for the given atom
361 548 : xNode = createNode( pAtom, aNode );
362 : }
363 : }
364 : else
365 : {
366 : // if we have no parent we fill the root node
367 76 : xNode = mxRootNode;
368 : }
369 :
370 : // import if we have a node and its not random
371 624 : if( xNode.is() )
372 : {
373 624 : fillNode( xNode, aNode, aSet );
374 :
375 624 : switch( aNode.mnGroupType )
376 : {
377 : case mso_Anim_GroupType_PAR:
378 : {
379 282 : dump( "<par" );
380 282 : dump( aNode );
381 282 : dump( aSet );
382 282 : nNodes += importTimeContainer( pAtom, xNode );
383 282 : dump( "</par>\n" );
384 :
385 : // for iteration containers, map target from children to iteration
386 282 : Reference< XIterateContainer > xIter( xNode, UNO_QUERY );
387 282 : if( xIter.is() )
388 : {
389 0 : double fDuration = 0.0;
390 0 : Any aTarget, aEmpty;
391 0 : Reference< XEnumerationAccess > xEnumerationAccess( xNode, UNO_QUERY );
392 0 : if( xEnumerationAccess.is() )
393 : {
394 0 : Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY );
395 0 : if( xEnumeration.is() )
396 : {
397 0 : while( xEnumeration->hasMoreElements() )
398 : {
399 0 : Reference< XAnimate > xChildNode( xEnumeration->nextElement(), UNO_QUERY );
400 0 : if( xChildNode.is() )
401 : {
402 0 : double fChildBegin = 0.0;
403 0 : double fChildDuration = 0.0;
404 0 : xChildNode->getBegin() >>= fChildBegin;
405 0 : xChildNode->getDuration() >>= fChildDuration;
406 :
407 0 : fChildDuration += fChildBegin;
408 0 : if( fChildDuration > fDuration )
409 0 : fDuration = fChildDuration;
410 :
411 0 : if( !aTarget.hasValue() )
412 0 : aTarget = xChildNode->getTarget();
413 :
414 0 : xChildNode->setTarget( aEmpty );
415 : }
416 0 : }
417 0 : }
418 : }
419 :
420 0 : xIter->setTarget( aTarget );
421 :
422 0 : double fIterateInterval = xIter->getIterateInterval() * fDuration / 100;
423 0 : xIter->setIterateInterval( fIterateInterval );
424 282 : }
425 : }
426 282 : break;
427 :
428 : case mso_Anim_GroupType_SEQ:
429 : {
430 32 : dump( "<seq" );
431 32 : dump( aNode );
432 32 : dump( aSet );
433 32 : nNodes += importTimeContainer( pAtom, xNode );
434 32 : dump( "</seq>\n" );
435 :
436 32 : if( aSet.hasProperty( DFF_ANIM_NODE_TYPE ) )
437 : {
438 32 : sal_Int32 nPPTNodeType = 0;
439 32 : if( aSet.getProperty( DFF_ANIM_NODE_TYPE ) >>= nPPTNodeType )
440 : {
441 32 : switch(nPPTNodeType)
442 : {
443 : case DFF_ANIM_NODE_TYPE_MAIN_SEQUENCE:
444 32 : fixMainSequenceTiming( xNode );
445 32 : break;
446 : case DFF_ANIM_NODE_TYPE_INTERACTIVE_SEQ:
447 0 : fixInteractiveSequenceTiming( xNode );
448 0 : break;
449 : }
450 : }
451 : }
452 : }
453 32 : break;
454 :
455 : case mso_Anim_GroupType_NODE:
456 : {
457 : #ifdef DBG_ANIM_LOG
458 : if( pAtom->hasChildAtom( DFF_msofbtAnimateSet ) )
459 : {
460 : dump( "<set" );
461 : }
462 : else if( pAtom->hasChildAtom( DFF_msofbtAnimateColor ) )
463 : {
464 : dump( "<animateColor" );
465 : }
466 : else if( pAtom->hasChildAtom( DFF_msofbtAnimateScale ) )
467 : {
468 : dump( "<animateScale" );
469 : }
470 : else if( pAtom->hasChildAtom( DFF_msofbtAnimateRotation ) )
471 : {
472 : dump( "<animateRotation" );
473 : }
474 : else if( pAtom->hasChildAtom( DFF_msofbtAnimateMotion ) )
475 : {
476 : dump( "<animateMotion" );
477 : }
478 : else if( pAtom->hasChildAtom( DFF_msofbtAnimate ) )
479 : {
480 : dump( "<animate" );
481 : }
482 : else if( pAtom->hasChildAtom( DFF_msofbtAnimateFilter ) )
483 : {
484 : dump( "<animateFilter" );
485 : }
486 : else if( pAtom->hasChildAtom( DFF_msofbtAnimCommand ) )
487 : {
488 : dump( "<command" );
489 : }
490 : else
491 : {
492 : OSL_FAIL( "unknown node atom!" );
493 : dump_atom_header( pAtom, true, false );
494 : dump_atom( pAtom );
495 : dump_atom_header( pAtom, false, false );
496 : break;
497 : }
498 : dump( aNode );
499 : dump( aSet );
500 : #endif
501 310 : int nANCNodes = importAnimationNodeContainer( pAtom, xNode );
502 310 : if( !convertAnimationNode( xNode, xParent ) )
503 2 : xNode = 0;
504 : else
505 308 : nNodes += nANCNodes;
506 310 : dump( "/>\n");
507 :
508 : }
509 310 : break;
510 :
511 : case mso_Anim_GroupType_MEDIA:
512 : {
513 0 : dump( "<audio" );
514 0 : dump( aNode );
515 0 : dump( aSet );
516 0 : nNodes += importAudioContainer( pAtom, xNode );
517 0 : dump( "</audio>\n" );
518 : }
519 0 : break;
520 :
521 : default:
522 : OSL_FAIL( "unknown group atom!" );
523 :
524 0 : dump_atom_header( pAtom, true, false );
525 0 : dump_atom( pAtom );
526 0 : dump_atom_header( pAtom, false, false );
527 0 : break;
528 :
529 : }
530 : }
531 :
532 624 : if( xParent.is() && xNode.is() )
533 : {
534 546 : Reference< XTimeContainer > xParentContainer( xParent, UNO_QUERY );
535 : DBG_ASSERT( xParentContainer.is(), "parent is no container, then why do I have a child here?" );
536 546 : if( xParentContainer.is() )
537 : {
538 546 : xParentContainer->appendChild( xNode );
539 546 : }
540 624 : }
541 : }
542 :
543 624 : return nNodes;
544 : }
545 :
546 32 : void AnimationImporter::fixMainSequenceTiming( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode )
547 : {
548 : try
549 : {
550 32 : bool bFirst = true;
551 32 : Reference< XEnumerationAccess > xEA( xNode, UNO_QUERY_THROW );
552 64 : Reference< XEnumeration > xE( xEA->createEnumeration(), UNO_QUERY_THROW );
553 108 : while( xE->hasMoreElements() )
554 : {
555 : // click node
556 44 : Reference< XAnimationNode > xClickNode( xE->nextElement(), UNO_QUERY );
557 :
558 88 : Event aEvent;
559 44 : aEvent.Trigger = EventTrigger::ON_NEXT;
560 44 : aEvent.Repeat = 0;
561 44 : xClickNode->setBegin( makeAny( aEvent ) );
562 :
563 44 : if( bFirst )
564 : {
565 22 : bFirst = false;
566 22 : Reference< XEnumerationAccess > xEA2( xClickNode, UNO_QUERY_THROW );
567 44 : Reference< XEnumeration > xE2( xEA2->createEnumeration(), UNO_QUERY_THROW );
568 22 : if( xE2->hasMoreElements() )
569 : {
570 : // with node
571 22 : xE2->nextElement() >>= xEA2;
572 22 : if( xEA2.is() )
573 22 : xE2.set(xEA2->createEnumeration(), css::uno::UNO_QUERY);
574 : else
575 0 : xE2.clear();
576 :
577 22 : if( xE2.is() && xE2->hasMoreElements() )
578 : {
579 22 : Reference< XAnimationNode > xEffectNode( xE2->nextElement(), UNO_QUERY_THROW );
580 44 : const Sequence< NamedValue > aUserData( xEffectNode->getUserData() );
581 22 : const NamedValue* p = aUserData.getConstArray();
582 22 : sal_Int32 nLength = aUserData.getLength();
583 130 : while( nLength-- )
584 : {
585 88 : if ( p->Name == "node-type" )
586 : {
587 22 : sal_Int16 nNodeType = 0;
588 22 : p->Value >>= nNodeType;
589 22 : if( nNodeType != ::com::sun::star::presentation::EffectNodeType::ON_CLICK )
590 : {
591 : // first effect does not start on click, so correct
592 : // first click nodes begin to 0s
593 2 : xClickNode->setBegin( makeAny( (double)0.0 ) );
594 2 : break;
595 : }
596 : }
597 86 : p++;
598 22 : }
599 : }
600 22 : }
601 : }
602 76 : }
603 : }
604 0 : catch( Exception& )
605 : {
606 : OSL_FAIL("sd::AnimationImporter::fixMainSequenceTiming(), exception caught!" );
607 : }
608 32 : }
609 :
610 0 : void AnimationImporter::fixInteractiveSequenceTiming( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode )
611 : {
612 : try
613 : {
614 0 : Any aBegin( xNode->getBegin() );
615 0 : Any aEmpty;
616 0 : xNode->setBegin( aEmpty );
617 :
618 0 : Reference< XEnumerationAccess > xEA( xNode, UNO_QUERY_THROW );
619 0 : Reference< XEnumeration > xE( xEA->createEnumeration(), UNO_QUERY_THROW );
620 0 : while( xE->hasMoreElements() )
621 : {
622 : // click node
623 0 : Reference< XAnimationNode > xClickNode( xE->nextElement(), UNO_QUERY );
624 0 : xClickNode->setBegin( aBegin );
625 0 : }
626 : }
627 0 : catch( Exception& )
628 : {
629 : OSL_FAIL("sd::AnimationImporter::fixInteractiveSequenceTiming(), exception caught!" );
630 : }
631 0 : }
632 :
633 310 : bool AnimationImporter::convertAnimationNode( const Reference< XAnimationNode >& xNode, const Reference< XAnimationNode >& xParent )
634 : {
635 310 : Reference< XAnimate > xAnimate( xNode, UNO_QUERY );
636 310 : if( !xAnimate.is() )
637 0 : return true;
638 :
639 310 : if( !xAnimate->getTarget().hasValue() )
640 2 : return false;
641 :
642 308 : const sal_Int16 nNodeType = xNode->getType();
643 :
644 308 : if( nNodeType == AnimationNodeType::TRANSITIONFILTER )
645 2 : return true;
646 :
647 612 : OUString aAttributeName( xAnimate->getAttributeName() );
648 :
649 306 : if( (nNodeType == AnimationNodeType::SET) && aAttributeName == "fill.on" )
650 0 : return false;
651 :
652 306 : const ImplAttributeNameConversion* p = gImplConversionList;
653 :
654 306 : MS_AttributeNames eAttribute = MS_UNKNOWN;
655 :
656 306 : if( (nNodeType == AnimationNodeType::ANIMATEMOTION) ||
657 : (nNodeType == AnimationNodeType::ANIMATETRANSFORM) )
658 : {
659 0 : OUString aEmpty;
660 0 : aAttributeName = aEmpty;
661 : }
662 : else
663 : {
664 2652 : while( p->mpMSName )
665 : {
666 2346 : if( aAttributeName.equalsAscii( p->mpMSName ) )
667 306 : break;
668 :
669 2040 : p++;
670 : }
671 :
672 : DBG_ASSERT( p->mpMSName || aAttributeName.isEmpty(), "sd::AnimationImporter::convertAnimationNode(), unknown attribute!" );
673 : #ifdef DBG_ANIM_LOG
674 : if( p->mpMSName == 0 ) dump( "<error text=\"sd::AnimationImporter::convertAnimationNode(), unknown attribute!\"/>\n" );
675 : #endif
676 :
677 306 : eAttribute = p->meAttribute;
678 :
679 306 : if( p->mpAPIName )
680 306 : aAttributeName = OUString::createFromAscii( p->mpAPIName );
681 : }
682 :
683 306 : xAnimate->setAttributeName( aAttributeName );
684 :
685 306 : if( eAttribute != MS_UNKNOWN )
686 : {
687 306 : Any aAny( xAnimate->getFrom() );
688 306 : if( aAny.hasValue() )
689 : {
690 0 : if( convertAnimationValue( eAttribute, aAny ) )
691 0 : xAnimate->setFrom( aAny );
692 : }
693 :
694 306 : aAny = xAnimate->getBy();
695 306 : if( aAny.hasValue() )
696 : {
697 0 : if( convertAnimationValue( eAttribute, aAny ) )
698 0 : xAnimate->setBy( aAny );
699 : }
700 :
701 306 : aAny = xAnimate->getTo();
702 306 : if( aAny.hasValue() )
703 : {
704 102 : if( convertAnimationValue( eAttribute, aAny ) )
705 102 : xAnimate->setTo( aAny );
706 : }
707 :
708 612 : Sequence< Any > aValues( xAnimate->getValues() );
709 306 : sal_Int32 nValues = aValues.getLength();
710 306 : if( nValues )
711 : {
712 204 : Any* p2 = aValues.getArray();
713 816 : while( nValues-- )
714 408 : convertAnimationValue( eAttribute, *p2++ );
715 :
716 204 : xAnimate->setValues( aValues );
717 : }
718 :
719 612 : OUString aFormula( xAnimate->getFormula() );
720 306 : if( !aFormula.isEmpty() )
721 : {
722 0 : if( convertMeasure( aFormula ) )
723 0 : xAnimate->setFormula( aFormula );
724 306 : }
725 : }
726 :
727 : // check for after-affect
728 612 : Sequence< NamedValue > aUserData( xNode->getUserData() );
729 306 : NamedValue* pValue = aUserData.getArray();
730 306 : NamedValue* pLastValue = pValue;
731 306 : sal_Int32 nLength = aUserData.getLength(), nRemoved = 0;
732 :
733 306 : bool bAfterEffect = false;
734 306 : sal_Int32 nMasterRel = 0;
735 306 : for( ; nLength--; pValue++ )
736 : {
737 0 : if ( pValue->Name == "after-effect" )
738 : {
739 0 : pValue->Value >>= bAfterEffect;
740 0 : nRemoved++;
741 : }
742 0 : else if ( pValue->Name == "master-rel" )
743 : {
744 0 : pValue->Value >>= nMasterRel;
745 0 : nRemoved++;
746 : }
747 : else
748 : {
749 0 : if( nRemoved )
750 0 : *pLastValue = *pValue;
751 0 : pLastValue++;
752 : }
753 : }
754 :
755 306 : if( nRemoved )
756 : {
757 0 : aUserData.realloc( aUserData.getLength() - nRemoved );
758 0 : xNode->setUserData( aUserData );
759 : }
760 :
761 : // if its an after effect node, add it to the list for
762 : // later processing
763 : // after effect nodes are not inserted at their import
764 : // position, so return false in this case
765 306 : if( bAfterEffect )
766 : {
767 0 : if( nMasterRel != 2 )
768 : {
769 0 : Event aEvent;
770 :
771 0 : aEvent.Source <<= xParent;
772 0 : aEvent.Trigger = EventTrigger::END_EVENT;
773 0 : aEvent.Repeat = 0;
774 :
775 0 : xNode->setBegin( makeAny( aEvent ) );
776 : }
777 :
778 : // add to after effect nodes for later processing
779 0 : sd::AfterEffectNode aNode( xNode, xParent, nMasterRel == 2 );
780 0 : maAfterEffectNodes.push_back( aNode );
781 0 : return false;
782 : }
783 :
784 616 : return true;
785 : }
786 :
787 0 : static int lcl_gethex( int nChar )
788 : {
789 0 : if( nChar >= '0' && nChar <= '9' )
790 0 : return nChar - '0';
791 0 : else if( nChar >= 'a' && nChar <= 'f' )
792 0 : return nChar - 'a' + 10;
793 0 : else if( nChar >= 'A' && nChar <= 'F' )
794 0 : return nChar - 'A' + 10;
795 : else
796 0 : return 0;
797 : }
798 :
799 510 : bool AnimationImporter::convertAnimationValue( MS_AttributeNames eAttribute, Any& rValue )
800 : {
801 510 : bool bRet = false;
802 510 : switch( eAttribute )
803 : {
804 : case MS_PPT_X:
805 : case MS_PPT_Y:
806 : case MS_PPT_W:
807 : case MS_PPT_H:
808 : {
809 408 : OUString aString;
810 :
811 408 : if( rValue.getValueType() == cppu::UnoType<ValuePair>::get() )
812 : {
813 0 : ValuePair aValuePair;
814 0 : if( rValue >>= aValuePair )
815 : {
816 0 : if( aValuePair.First >>= aString )
817 : {
818 0 : if( convertMeasure( aString ) )
819 : {
820 0 : aValuePair.First <<= aString;
821 0 : bRet = true;
822 : }
823 : }
824 :
825 0 : if( aValuePair.Second >>= aString )
826 : {
827 0 : if( convertMeasure( aString ) )
828 : {
829 0 : aValuePair.Second <<= aString;
830 0 : bRet = true;
831 : }
832 : }
833 0 : }
834 : }
835 408 : else if( rValue.getValueType() == cppu::UnoType<OUString>::get() )
836 : {
837 408 : if( rValue >>= aString )
838 : {
839 408 : bRet = convertMeasure( aString );
840 :
841 408 : if( bRet )
842 408 : rValue <<= aString;
843 : }
844 408 : }
845 : }
846 408 : break;
847 :
848 : case MS_XSHEAR:
849 : case MS_R:
850 : {
851 0 : OUString aString;
852 0 : if( rValue >>= aString )
853 : {
854 0 : rValue <<= aString.toDouble();
855 0 : bRet = true;
856 0 : }
857 : }
858 0 : break;
859 :
860 : case MS_STYLEROTATION:
861 : {
862 0 : if( rValue.getValueType() == cppu::UnoType<OUString>::get() )
863 : {
864 0 : OUString aString;
865 0 : rValue >>= aString;
866 0 : rValue <<= (sal_Int16)aString.toDouble();
867 0 : bRet = true;
868 : }
869 0 : else if( rValue.getValueType() == cppu::UnoType<double>::get() )
870 : {
871 0 : double fValue = 0.0;
872 0 : rValue >>= fValue;
873 0 : rValue <<= (sal_Int16)fValue;
874 0 : bRet = true;
875 : }
876 : }
877 0 : break;
878 :
879 : case MS_FILLCOLOR:
880 : case MS_STROKECOLOR:
881 : case MS_STYLECOLOR:
882 : case MS_PPT_C:
883 : {
884 0 : OUString aString;
885 0 : if( rValue >>= aString )
886 : {
887 0 : if( aString.getLength() >= 7 && aString[0] == '#' )
888 : {
889 0 : Color aColor;
890 0 : aColor.SetRed( (sal_uInt8)(lcl_gethex( aString[1] ) * 16 + lcl_gethex( aString[2] )) );
891 0 : aColor.SetGreen( (sal_uInt8)(lcl_gethex( aString[3] ) * 16 + lcl_gethex( aString[4] )) );
892 0 : aColor.SetBlue( (sal_uInt8)(lcl_gethex( aString[5] ) * 16 + lcl_gethex( aString[6] )) );
893 0 : rValue <<= (sal_Int32)aColor.GetColor();
894 0 : bRet = true;
895 : }
896 0 : else if( aString.matchAsciiL( "rgb(", 4, 0 ) )
897 : {
898 0 : aString = aString.copy( 4, aString.getLength() - 5 );
899 0 : Color aColor;
900 0 : sal_Int32 index = 0;
901 0 : aColor.SetRed( (sal_uInt8)aString.getToken( 0, (sal_Unicode)',', index ).toInt32() );
902 0 : aColor.SetGreen( (sal_uInt8)aString.getToken( 0, (sal_Unicode)',', index ).toInt32() );
903 0 : aColor.SetRed( (sal_uInt8)aString.getToken( 0, (sal_Unicode)',', index ).toInt32() );
904 0 : rValue <<= (sal_Int32)aColor.GetColor();
905 0 : bRet = true;
906 : }
907 0 : else if( aString.matchAsciiL( "hsl(", 4, 0 ) )
908 : {
909 0 : sal_Int32 index = 0;
910 0 : sal_Int32 nA = aString.getToken( 0, (sal_Unicode)',', index ).toInt32();
911 0 : sal_Int32 nB = aString.getToken( 0, (sal_Unicode)',', index ).toInt32();
912 0 : sal_Int32 nC = aString.getToken( 0, (sal_Unicode)',', index ).toInt32();
913 0 : dump( "hsl(%ld", nA );
914 0 : dump( ",%ld", nB );
915 0 : dump( ",%ld)", nC );
916 0 : Sequence< double > aHSL( 3 );
917 0 : aHSL[0] = nA * 360.0/255.0;
918 0 : aHSL[1] = nB / 255.0;
919 0 : aHSL[2] = nC / 255.0;
920 0 : rValue <<= aHSL;
921 0 : bRet = true;
922 : }
923 0 : }
924 : }
925 0 : break;
926 :
927 : case MS_FILLTYPE:
928 : {
929 0 : OUString aString;
930 0 : if( rValue >>= aString )
931 : {
932 0 : rValue <<= aString == "solid" ? FillStyle_SOLID : FillStyle_NONE;
933 0 : bRet = true;
934 0 : }
935 : }
936 0 : break;
937 :
938 : case MS_STROKEON:
939 : {
940 0 : OUString aString;
941 0 : if( rValue >>= aString )
942 : {
943 0 : rValue <<= aString == "true" ? ::com::sun::star::drawing::LineStyle_SOLID : ::com::sun::star::drawing::LineStyle_NONE;
944 0 : bRet = true;
945 0 : }
946 : }
947 0 : break;
948 :
949 : case MS_FONTWEIGHT:
950 : {
951 0 : OUString aString;
952 0 : if( rValue >>= aString )
953 : {
954 0 : rValue <<= aString == "bold" ? com::sun::star::awt::FontWeight::BOLD : com::sun::star::awt::FontWeight::NORMAL;
955 0 : bRet = true;
956 0 : }
957 : }
958 0 : break;
959 :
960 : case MS_STYLEFONTSTYLE:
961 : {
962 0 : OUString aString;
963 0 : if( rValue >>= aString )
964 : {
965 0 : rValue <<= aString == "italic" ? com::sun::star::awt::FontSlant_ITALIC : com::sun::star::awt::FontSlant_NONE;
966 0 : bRet = true;
967 0 : }
968 : }
969 0 : break;
970 :
971 : case MS_STYLEUNDERLINE:
972 : {
973 0 : OUString aString;
974 0 : if( rValue >>= aString )
975 : {
976 0 : rValue <<= aString == "true" ? com::sun::star::awt::FontUnderline::SINGLE : com::sun::star::awt::FontUnderline::NONE;
977 0 : bRet = true;
978 0 : }
979 : }
980 0 : break;
981 :
982 : case MS_STYLEOPACITY:
983 : case MS_STYLEFONTSIZE:
984 : {
985 0 : OUString aString;
986 0 : if( rValue >>= aString )
987 : {
988 0 : rValue <<= (float)aString.toDouble();
989 0 : bRet = true;
990 0 : }
991 : }
992 0 : break;
993 :
994 : case MS_STYLEVISIBILITY:
995 : {
996 102 : OUString aString;
997 102 : if( rValue >>= aString )
998 : {
999 102 : rValue <<= aString == "visible" ? sal_True : sal_False;
1000 102 : bRet = true;
1001 102 : }
1002 : }
1003 102 : break;
1004 : default:
1005 0 : break;
1006 : }
1007 :
1008 510 : return bRet;
1009 : }
1010 :
1011 104 : static OUString getConvertedSubType( sal_Int16 nPresetClass, sal_Int32 nPresetId, sal_Int32 nPresetSubType )
1012 : {
1013 104 : const sal_Char* pStr = 0;
1014 :
1015 104 : if( (nPresetClass == EffectPresetClass::ENTRANCE) || (nPresetClass == EffectPresetClass::EXIT) )
1016 : {
1017 : // skip wheel effect
1018 104 : if( nPresetId != 21 )
1019 : {
1020 104 : if( nPresetId == 5 )
1021 : {
1022 : // checkerboard
1023 0 : switch( nPresetSubType )
1024 : {
1025 0 : case 5: pStr = "downward"; break;
1026 0 : case 10: pStr = "across"; break;
1027 : }
1028 : }
1029 104 : else if( nPresetId == 17 )
1030 : {
1031 : // stretch
1032 0 : if( nPresetSubType == 10 )
1033 0 : pStr = "across";
1034 : }
1035 104 : else if( nPresetId == 18 )
1036 : {
1037 : // strips
1038 0 : switch( nPresetSubType )
1039 : {
1040 0 : case 3: pStr = "right-to-top"; break;
1041 0 : case 6: pStr = "right-to-bottom"; break;
1042 0 : case 9: pStr = "left-to-top"; break;
1043 0 : case 12: pStr = "left-to-bottom"; break;
1044 : }
1045 : }
1046 :
1047 104 : if( pStr == 0 )
1048 : {
1049 104 : const convert_subtype* p = gConvertArray;
1050 :
1051 530 : while( p->mpStrSubType )
1052 : {
1053 426 : if( p->mnID == nPresetSubType )
1054 : {
1055 104 : pStr = p->mpStrSubType;
1056 104 : break;
1057 : }
1058 322 : p++;
1059 : }
1060 : }
1061 : }
1062 : }
1063 :
1064 104 : if( pStr )
1065 104 : return OUString::createFromAscii( pStr );
1066 : else
1067 0 : return OUString::number( nPresetSubType );
1068 : }
1069 :
1070 624 : void AnimationImporter::fillNode( Reference< XAnimationNode >& xNode, const AnimationNode& rNode, const PropertySet& rSet )
1071 : {
1072 624 : bool bAfterEffect = false;
1073 :
1074 : // attribute Restart
1075 624 : if( rNode.mnRestart )
1076 : {
1077 66 : sal_Int16 nRestart = AnimationRestart::DEFAULT;
1078 66 : switch( rNode.mnRestart )
1079 : {
1080 0 : case 1: nRestart = AnimationRestart::ALWAYS; break;
1081 0 : case 2: nRestart = AnimationRestart::WHEN_NOT_ACTIVE; break;
1082 66 : case 3: nRestart = AnimationRestart::NEVER; break;
1083 : }
1084 66 : xNode->setRestart( nRestart );
1085 : }
1086 :
1087 : // attribute Fill
1088 624 : if( rNode.mnFill )
1089 : {
1090 534 : sal_Int16 nFill = AnimationFill::DEFAULT;
1091 534 : switch( rNode.mnFill )
1092 : {
1093 0 : case 1: nFill = AnimationFill::REMOVE; break;
1094 0 : case 2: nFill = AnimationFill::FREEZE; break;
1095 534 : case 3: nFill = AnimationFill::HOLD; break;
1096 0 : case 4: nFill = AnimationFill::TRANSITION; break;
1097 : }
1098 534 : xNode->setFill( nFill );
1099 : }
1100 :
1101 : // attribute Duration
1102 624 : if( rNode.mnDuration )
1103 : {
1104 408 : Any aDuration;
1105 408 : if( rNode.mnDuration > 0 )
1106 : {
1107 310 : aDuration <<= (double)(rNode.mnDuration / 1000.0);
1108 : }
1109 98 : else if( rNode.mnDuration < 0 )
1110 : {
1111 98 : aDuration <<= Timing_INDEFINITE;
1112 : }
1113 408 : xNode->setDuration( aDuration );
1114 : }
1115 :
1116 : // TODO: DFF_ANIM_PATH_EDIT_MODE
1117 624 : if( rSet.hasProperty( DFF_ANIM_PATH_EDIT_MODE ) )
1118 : {
1119 : sal_Int32 nPathEditMode ;
1120 0 : if( rSet.getProperty( DFF_ANIM_PATH_EDIT_MODE ) >>= nPathEditMode )
1121 : {
1122 : }
1123 : }
1124 :
1125 : // set user data
1126 624 : Sequence< NamedValue > aUserData;
1127 :
1128 : // attribute Type
1129 624 : if( rSet.hasProperty( DFF_ANIM_NODE_TYPE ) )
1130 : {
1131 212 : sal_Int32 nPPTNodeType = 0;
1132 212 : if( rSet.getProperty( DFF_ANIM_NODE_TYPE ) >>= nPPTNodeType )
1133 : {
1134 212 : sal_Int16 nNodeType = ::com::sun::star::presentation::EffectNodeType::DEFAULT;
1135 212 : switch( nPPTNodeType )
1136 : {
1137 42 : case DFF_ANIM_NODE_TYPE_ON_CLICK: nNodeType = ::com::sun::star::presentation::EffectNodeType::ON_CLICK; break;
1138 48 : case DFF_ANIM_NODE_TYPE_WITH_PREVIOUS: nNodeType = ::com::sun::star::presentation::EffectNodeType::WITH_PREVIOUS; break;
1139 14 : case DFF_ANIM_NODE_TYPE_AFTER_PREVIOUS: nNodeType = ::com::sun::star::presentation::EffectNodeType::AFTER_PREVIOUS; break;
1140 32 : case DFF_ANIM_NODE_TYPE_MAIN_SEQUENCE: nNodeType = ::com::sun::star::presentation::EffectNodeType::MAIN_SEQUENCE; break;
1141 76 : case DFF_ANIM_NODE_TYPE_TIMING_ROOT: nNodeType = ::com::sun::star::presentation::EffectNodeType::TIMING_ROOT; break;
1142 0 : case DFF_ANIM_NODE_TYPE_INTERACTIVE_SEQ:nNodeType = ::com::sun::star::presentation::EffectNodeType::INTERACTIVE_SEQUENCE; break;
1143 : }
1144 :
1145 212 : sal_Int32 nSize = aUserData.getLength();
1146 212 : aUserData.realloc(nSize+1);
1147 212 : aUserData[nSize].Name = "node-type";
1148 212 : aUserData[nSize].Value <<= nNodeType;
1149 : }
1150 : }
1151 :
1152 624 : if( rSet.hasProperty( DFF_ANIM_GROUP_ID ) )
1153 : {
1154 : sal_Int32 nGroupId;
1155 40 : if( rSet.getProperty( DFF_ANIM_GROUP_ID ) >>= nGroupId )
1156 : {
1157 40 : sal_Int32 nSize = aUserData.getLength();
1158 40 : aUserData.realloc(nSize+1);
1159 40 : aUserData[nSize].Name = "group-id";
1160 40 : aUserData[nSize].Value <<= nGroupId;
1161 : }
1162 : }
1163 :
1164 624 : sal_Int16 nEffectPresetClass = EffectPresetClass::CUSTOM;
1165 624 : sal_Int32 nPresetId = 0;
1166 :
1167 624 : if( rSet.hasProperty( DFF_ANIM_PRESET_CLASS ) )
1168 : {
1169 104 : sal_Int32 nPresetClass = 0;
1170 104 : if ( rSet.getProperty( DFF_ANIM_PRESET_CLASS ) >>= nPresetClass )
1171 : {
1172 104 : switch( nPresetClass )
1173 : {
1174 104 : case DFF_ANIM_PRESS_CLASS_ENTRANCE: nEffectPresetClass = EffectPresetClass::ENTRANCE; break;
1175 0 : case DFF_ANIM_PRESS_CLASS_EXIT: nEffectPresetClass = EffectPresetClass::EXIT; break;
1176 0 : case DFF_ANIM_PRESS_CLASS_EMPHASIS: nEffectPresetClass = EffectPresetClass::EMPHASIS; break;
1177 0 : case DFF_ANIM_PRESS_CLASS_MOTIONPATH: nEffectPresetClass = EffectPresetClass::MOTIONPATH; break;
1178 0 : case DFF_ANIM_PRESS_CLASS_OLE_ACTION: nEffectPresetClass = EffectPresetClass::OLEACTION; break;
1179 0 : case DFF_ANIM_PRESS_CLASS_MEDIACALL: nEffectPresetClass = EffectPresetClass::MEDIACALL; break;
1180 : }
1181 104 : sal_Int32 nSize = aUserData.getLength();
1182 104 : aUserData.realloc(nSize+1);
1183 104 : aUserData[nSize].Name = "preset-class";
1184 104 : aUserData[nSize].Value <<= nEffectPresetClass;
1185 : }
1186 : }
1187 :
1188 624 : if( rSet.hasProperty( DFF_ANIM_PRESET_ID ) )
1189 : {
1190 104 : if( rSet.getProperty( DFF_ANIM_PRESET_ID ) >>= nPresetId )
1191 : {
1192 104 : sal_Int32 nSize = aUserData.getLength();
1193 104 : aUserData.realloc(nSize+1);
1194 104 : aUserData[nSize].Name = "preset-id";
1195 :
1196 104 : const preset_maping* p = gPresetMaping;
1197 314 : while( p->mpStrPresetId && ((p->mnPresetClass != nEffectPresetClass) || (p->mnPresetId != nPresetId )) )
1198 106 : p++;
1199 :
1200 104 : if( p->mpStrPresetId )
1201 : {
1202 104 : aUserData[nSize].Value <<= OUString::createFromAscii( p->mpStrPresetId );
1203 : }
1204 : else
1205 : {
1206 0 : OUStringBuffer sBuffer;
1207 0 : sBuffer.appendAscii( "ppt_" );
1208 0 : switch( nEffectPresetClass )
1209 : {
1210 0 : case EffectPresetClass::ENTRANCE: sBuffer.appendAscii( "entrance_" ); break;
1211 0 : case EffectPresetClass::EXIT: sBuffer.appendAscii( "exit_" ); break;
1212 0 : case EffectPresetClass::EMPHASIS: sBuffer.appendAscii( "emphasis_" ); break;
1213 0 : case EffectPresetClass::MOTIONPATH: sBuffer.appendAscii( "motionpath_" ); break;
1214 0 : case EffectPresetClass::OLEACTION: sBuffer.appendAscii( "oleaction_" ); break;
1215 0 : case EffectPresetClass::MEDIACALL: sBuffer.appendAscii( "mediacall_" ); break;
1216 : }
1217 0 : sBuffer.append( nPresetId );
1218 :
1219 0 : aUserData[nSize].Value <<= sBuffer.makeStringAndClear();
1220 : }
1221 : }
1222 : }
1223 :
1224 624 : if( rSet.hasProperty( DFF_ANIM_PRESET_SUB_TYPE ) )
1225 : {
1226 104 : sal_Int32 nPresetSubType = 0;
1227 104 : if( (rSet.getProperty( DFF_ANIM_PRESET_SUB_TYPE ) >>= nPresetSubType) )
1228 : {
1229 104 : if( nPresetSubType )
1230 : {
1231 104 : sal_Int32 nSize = aUserData.getLength();
1232 104 : aUserData.realloc(nSize+1);
1233 104 : aUserData[nSize].Name = "preset-sub-type";
1234 104 : aUserData[nSize].Value <<= getConvertedSubType( nEffectPresetClass, nPresetId, nPresetSubType );
1235 : }
1236 : }
1237 : }
1238 :
1239 624 : if( rSet.hasProperty( DFF_ANIM_AFTEREFFECT ) )
1240 : {
1241 0 : if( rSet.getProperty( DFF_ANIM_AFTEREFFECT ) >>= bAfterEffect )
1242 : {
1243 0 : sal_Int32 nSize = aUserData.getLength();
1244 0 : aUserData.realloc(nSize+1);
1245 0 : aUserData[nSize].Name = "after-effect";
1246 0 : aUserData[nSize].Value <<= bAfterEffect;
1247 : }
1248 : }
1249 :
1250 624 : if( bAfterEffect && rSet.hasProperty( DFF_ANIM_MASTERREL ) )
1251 : {
1252 0 : sal_Int32 nMasterRel = 2;
1253 0 : if( rSet.getProperty( DFF_ANIM_MASTERREL ) >>= nMasterRel )
1254 : {
1255 0 : sal_Int32 nSize = aUserData.getLength();
1256 0 : aUserData.realloc(nSize+1);
1257 0 : aUserData[nSize].Name = "master-rel";
1258 0 : aUserData[nSize].Value <<= nMasterRel;
1259 : }
1260 : }
1261 :
1262 624 : xNode->setUserData( aUserData );
1263 :
1264 : // TODO: DFF_ANIM_ID
1265 624 : if( rSet.hasProperty( DFF_ANIM_ID ) )
1266 : {
1267 0 : OUString aString;
1268 0 : rSet.getProperty( DFF_ANIM_ID ) >>= aString;
1269 : //if( !aString.isEmpty() )
1270 : //{
1271 : //}
1272 : }
1273 :
1274 : // TODO: DFF_ANIM_EVENT_FILTER
1275 624 : if( rSet.hasProperty( DFF_ANIM_EVENT_FILTER ) )
1276 : {
1277 0 : OUString aString;
1278 0 : rSet.getProperty( DFF_ANIM_EVENT_FILTER ) >>= aString;
1279 : //if( !aString.isEmpty() )
1280 : //{
1281 : //}
1282 : }
1283 :
1284 : // DFF_ANIM_TIMEFILTER
1285 624 : if( rSet.hasProperty( DFF_ANIM_TIMEFILTER ) )
1286 : {
1287 0 : Reference< XAnimate > xAnim( xNode, UNO_QUERY );
1288 0 : if( xAnim.is() )
1289 : {
1290 0 : OUString aString;
1291 0 : rSet.getProperty( DFF_ANIM_TIMEFILTER ) >>= aString;
1292 0 : if( !aString.isEmpty() )
1293 : {
1294 0 : sal_Int32 nElements = 1; // a non empty string has at least one value
1295 :
1296 0 : sal_Int32 fromIndex = 0;
1297 : while(true)
1298 : {
1299 0 : fromIndex = aString.indexOf( (sal_Unicode)';', fromIndex );
1300 0 : if( fromIndex == -1 )
1301 0 : break;
1302 :
1303 0 : fromIndex++;
1304 0 : nElements++;
1305 : }
1306 :
1307 0 : Sequence< TimeFilterPair > aTimeFilter( nElements );
1308 :
1309 0 : TimeFilterPair* pValues = aTimeFilter.getArray();
1310 0 : sal_Int32 nIndex = 0;
1311 0 : while( (nElements--) && (nIndex >= 0) )
1312 : {
1313 0 : const OUString aToken( aString.getToken( 0, ';', nIndex ) );
1314 :
1315 0 : sal_Int32 nPos = aToken.indexOf( ',' );
1316 0 : if( nPos >= 0 )
1317 : {
1318 0 : pValues->Time = aToken.copy( 0, nPos ).toDouble();
1319 0 : pValues->Progress = aToken.copy( nPos+1, aToken.getLength() - nPos - 1 ).toDouble();
1320 : }
1321 0 : pValues++;
1322 0 : }
1323 :
1324 0 : xAnim->setTimeFilter( aTimeFilter );
1325 0 : }
1326 0 : }
1327 : }
1328 :
1329 : // TODO: DFF_ANIM_ENDAFTERSLIDE / DFF_ANIM_VOLUME handling. git history has sample code
1330 624 : Reference< XAnimateColor > xColor( xNode, UNO_QUERY );
1331 624 : if( xColor.is() )
1332 : {
1333 0 : if( rSet.hasProperty( DFF_ANIM_DIRECTION ) )
1334 : {
1335 0 : bool bDirection = false;
1336 0 : if( rSet.getProperty( DFF_ANIM_DIRECTION ) >>= bDirection )
1337 0 : xColor->setDirection( !bDirection );
1338 : }
1339 :
1340 0 : if( rSet.hasProperty( DFF_ANIM_COLORSPACE ) )
1341 : {
1342 0 : sal_Int32 nColorSpace = 0;
1343 0 : rSet.getProperty( DFF_ANIM_COLORSPACE ) >>= nColorSpace;
1344 0 : xColor->setColorInterpolation( (nColorSpace == 0) ? AnimationColorSpace::RGB : AnimationColorSpace::HSL );
1345 : }
1346 624 : }
1347 624 : }
1348 :
1349 314 : int AnimationImporter::importTimeContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
1350 : {
1351 314 : int nNodes = 0;
1352 :
1353 : DBG_ASSERT( pAtom && xNode.is(), "invalid call to ppt::AnimationImporter::importTimeContainer()!");
1354 314 : if( pAtom && xNode.is() )
1355 : {
1356 314 : importAnimationEvents( pAtom, xNode );
1357 314 : importAnimationValues( pAtom, xNode );
1358 314 : importAnimationActions( pAtom, xNode );
1359 :
1360 314 : dump(">\n");
1361 :
1362 : // import sub containers
1363 314 : const Atom* pChildAtom = pAtom->findFirstChildAtom();
1364 :
1365 2108 : while( pChildAtom )
1366 : {
1367 1480 : switch( pChildAtom->getType() )
1368 : {
1369 : case DFF_msofbtAnimNode:
1370 : case DFF_msofbtAnimEvent:
1371 : case DFF_msofbtAnimValue:
1372 : case DFF_msofbtAnimAction:
1373 : case DFF_msofbtAnimPropertySet:
1374 932 : break;
1375 :
1376 : case DFF_msofbtAnimSubGoup :
1377 : {
1378 0 : if( pChildAtom->hasChildAtom( DFF_msofbtAnimCommand ) )
1379 : {
1380 0 : Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
1381 0 : Reference< XAnimationNode > xChildNode( Command::create(xContext), UNO_QUERY_THROW );
1382 0 : nNodes += importAnimationNodeContainer( pChildAtom, xChildNode );
1383 0 : Reference< XTimeContainer > xParentContainer( xNode, UNO_QUERY );
1384 0 : if( xParentContainer.is() && xChildNode.is() )
1385 0 : xParentContainer->appendChild( xChildNode );
1386 : }
1387 : else
1388 : {
1389 0 : nNodes += importAnimationContainer( pChildAtom, xNode );
1390 : }
1391 : }
1392 0 : break;
1393 : case DFF_msofbtAnimGroup :
1394 : {
1395 548 : nNodes += importAnimationContainer( pChildAtom, xNode );
1396 : }
1397 548 : break;
1398 : case DFF_msofbtAnimIteration:
1399 : {
1400 0 : if( pChildAtom->seekToContent() )
1401 : {
1402 : float fInterval;
1403 : sal_Int32 nTextUnitEffect, nU1, nU2, nU3;
1404 :
1405 0 : mrStCtrl.ReadFloat( fInterval ).ReadInt32( nTextUnitEffect ).ReadInt32( nU1 ).ReadInt32( nU2 ).ReadInt32( nU3 );
1406 :
1407 0 : Reference< XIterateContainer > xIter( xNode, UNO_QUERY );
1408 0 : if( xIter.is() )
1409 : {
1410 0 : sal_Int16 nIterateType = TextAnimationType::BY_PARAGRAPH;
1411 0 : switch( nTextUnitEffect )
1412 : {
1413 0 : case 1: nIterateType = TextAnimationType::BY_WORD; break;
1414 0 : case 2: nIterateType = TextAnimationType::BY_LETTER; break;
1415 : }
1416 0 : xIter->setIterateType( nIterateType );
1417 0 : xIter->setIterateInterval( (double)fInterval );
1418 : }
1419 :
1420 0 : nNodes++;
1421 :
1422 0 : dump( "<iterate" );
1423 0 : dump( " iterateType=\"%s\"", (nTextUnitEffect == 0) ? "byElement" : (nTextUnitEffect == 1) ? "byWord" : "byLetter" );
1424 0 : dump( " iterateInterval=\"%g\"", fInterval );
1425 0 : dump( " u1=\"%ld\"", nU1 );
1426 0 : dump( " u2=\"%ld\"", nU2 );
1427 0 : dump( " u3=\"%ld\"/>\n", nU3 );
1428 : }
1429 : }
1430 0 : break;
1431 :
1432 : case 0xf136:
1433 : {
1434 : #ifdef DBG_ANIM_LOG
1435 : sal_uInt32 nU1, nU2;
1436 : mrStCtrl >> nU1 >> nU2;
1437 :
1438 : fprintf( mpFile, "<unknown_0xf136 nU1=\"%ld\" nU2=\"%ld\"/>\n", nU1, nU2 );
1439 : #endif
1440 : }
1441 0 : break;
1442 :
1443 : default:
1444 : {
1445 0 : dump_atom_header( pChildAtom, true, false );
1446 0 : dump_atom( pChildAtom );
1447 0 : dump_atom_header( pChildAtom, false, false );
1448 : }
1449 0 : break;
1450 : }
1451 :
1452 1480 : pChildAtom = pAtom->findNextChildAtom( pChildAtom );
1453 : }
1454 : }
1455 :
1456 314 : return nNodes;
1457 : }
1458 :
1459 310 : int AnimationImporter::importAnimationNodeContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
1460 : {
1461 310 : int nNodes = 0;
1462 :
1463 : DBG_ASSERT( pAtom && xNode.is(), "invalid call to ppt::AnimationImporter::importAnimationNodeContainer()!");
1464 310 : if( pAtom && xNode.is() )
1465 : {
1466 310 : importAnimationEvents( pAtom, xNode );
1467 310 : importAnimationValues( pAtom, xNode );
1468 310 : importAnimationActions( pAtom, xNode );
1469 :
1470 310 : const Atom* pChildAtom = pAtom->findFirstChildAtom();
1471 :
1472 1654 : while( pChildAtom )
1473 : {
1474 1034 : nNodes ++;
1475 1034 : switch( pChildAtom->getType() )
1476 : {
1477 : case DFF_msofbtAnimNode:
1478 : case DFF_msofbtAnimEvent:
1479 : case DFF_msofbtAnimValue:
1480 : case DFF_msofbtAnimAction:
1481 : case DFF_msofbtAnimPropertySet:
1482 724 : break;
1483 :
1484 : case DFF_msofbtAnimateFilter:
1485 2 : importAnimateFilterContainer( pChildAtom, xNode );
1486 2 : break;
1487 :
1488 : case DFF_msofbtAnimateSet:
1489 104 : importAnimateSetContainer( pChildAtom, xNode );
1490 104 : break;
1491 :
1492 : case DFF_msofbtAnimate:
1493 204 : importAnimateContainer( pChildAtom, xNode );
1494 204 : break;
1495 :
1496 : case DFF_msofbtAnimateScale:
1497 0 : importAnimateScaleContainer( pChildAtom, xNode );
1498 0 : break;
1499 :
1500 : case DFF_msofbtAnimateColor:
1501 0 : importAnimateColorContainer( pChildAtom, xNode );
1502 0 : break;
1503 :
1504 : case DFF_msofbtAnimateRotation:
1505 0 : importAnimateRotationContainer( pChildAtom, xNode );
1506 0 : break;
1507 :
1508 : case DFF_msofbtAnimateMotion:
1509 0 : importAnimateMotionContainer( pChildAtom, xNode );
1510 0 : break;
1511 :
1512 : case DFF_msofbtAnimCommand:
1513 0 : importCommandContainer( pChildAtom, xNode );
1514 0 : break;
1515 :
1516 : default:
1517 : {
1518 0 : nNodes --;
1519 0 : dump_atom_header( pChildAtom, true, false );
1520 0 : dump_atom( pChildAtom );
1521 0 : dump_atom_header( pChildAtom, false, false );
1522 : }
1523 0 : break;
1524 : }
1525 :
1526 1034 : pChildAtom = pAtom->findNextChildAtom( pChildAtom );
1527 : }
1528 : }
1529 :
1530 310 : return nNodes;
1531 : }
1532 :
1533 2 : void AnimationImporter::importAnimateFilterContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
1534 : {
1535 2 : Reference< XTransitionFilter > xFilter( xNode, UNO_QUERY );
1536 :
1537 : DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimateFilter && xFilter.is(), "invalid call to ppt::AnimationImporter::importAnimateFilterContainer()!");
1538 2 : if( pAtom && xFilter.is() )
1539 : {
1540 2 : sal_uInt32 nBits = 0;
1541 :
1542 2 : const Atom* pChildAtom = pAtom->findFirstChildAtom();
1543 :
1544 10 : while( pChildAtom )
1545 : {
1546 6 : if( !pChildAtom->isContainer() )
1547 : {
1548 4 : if( !pChildAtom->seekToContent() )
1549 0 : break;
1550 : }
1551 :
1552 6 : switch( pChildAtom->getType() )
1553 : {
1554 : case DFF_msofbtAnimateFilterData:
1555 : {
1556 : sal_uInt32 transition;
1557 2 : mrStCtrl.ReadUInt32( nBits );
1558 2 : mrStCtrl.ReadUInt32( transition );
1559 :
1560 2 : if( nBits & 1 )
1561 2 : xFilter->setMode( transition == 0 );
1562 :
1563 2 : dump( " transition=\"%s\"", (transition == 0) ? "in" : "out" );
1564 : }
1565 2 : break;
1566 :
1567 : case DFF_msofbtAnimAttributeValue:
1568 : {
1569 2 : if( (nBits & 2 ) && ( pChildAtom->getInstance() == 1 ) )
1570 : {
1571 2 : Any aAny;
1572 2 : if ( importAttributeValue( pChildAtom, aAny ) )
1573 : {
1574 2 : OUString filter;
1575 2 : aAny >>= filter;
1576 :
1577 2 : dump( " filter=\"%s\"", filter );
1578 :
1579 2 : const transition* pTransition = transition::find( filter );
1580 2 : if( pTransition )
1581 : {
1582 2 : xFilter->setTransition( pTransition->mnType );
1583 2 : xFilter->setSubtype( pTransition->mnSubType );
1584 2 : xFilter->setDirection( pTransition->mbDirection );
1585 : }
1586 : else
1587 : {
1588 : OSL_FAIL( "unknown transition!" );
1589 2 : }
1590 2 : }
1591 : }
1592 : }
1593 2 : break;
1594 :
1595 : case DFF_msofbtAnimateTarget:
1596 2 : importAnimateAttributeTargetContainer( pChildAtom, xNode );
1597 2 : break;
1598 :
1599 : default:
1600 0 : dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
1601 0 : break;
1602 :
1603 : }
1604 :
1605 6 : pChildAtom = pAtom->findNextChildAtom( pChildAtom );
1606 : }
1607 2 : }
1608 2 : }
1609 :
1610 310 : void AnimationImporter::importAnimateAttributeTargetContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
1611 : {
1612 : DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimateTarget, "invalid call to ppt::AnimationImporter::importAnimateAttributeTargetContainer()!");
1613 :
1614 310 : Any aTarget;
1615 :
1616 620 : Reference< XAnimate > xAnimate( xNode, UNO_QUERY );
1617 :
1618 310 : bool bWrongContext = false;
1619 :
1620 310 : if( pAtom )
1621 : {
1622 310 : const Atom* pChildAtom = pAtom->findFirstChildAtom();
1623 :
1624 1546 : while( pChildAtom )
1625 : {
1626 926 : if( !pChildAtom->isContainer() )
1627 : {
1628 310 : if( !pChildAtom->seekToContent() )
1629 0 : break;
1630 : }
1631 :
1632 926 : switch( pChildAtom->getType() )
1633 : {
1634 : case DFF_msofbtAnimPropertySet:
1635 : {
1636 0 : PropertySet aSet;
1637 0 : importPropertySetContainer( pChildAtom, aSet );
1638 0 : if( aSet.hasProperty( DFF_ANIM_RUNTIMECONTEXT ) )
1639 : {
1640 0 : OUString aContext;
1641 0 : if( aSet.getProperty( DFF_ANIM_RUNTIMECONTEXT ) >>= aContext )
1642 : {
1643 0 : if( aContext != "PPT" )
1644 0 : bWrongContext = true;
1645 0 : }
1646 : }
1647 :
1648 0 : dump( aSet );
1649 : }
1650 0 : break;
1651 :
1652 : case DFF_msofbtAnimateTargetSettings:
1653 : {
1654 310 : if( xAnimate.is() )
1655 : {
1656 : sal_uInt32 nBits;
1657 : sal_uInt32 nAdditive;
1658 : sal_uInt32 nAccumulate;
1659 : sal_uInt32 nTransformType;
1660 :
1661 310 : mrStCtrl.ReadUInt32( nBits ).ReadUInt32( nAdditive ).ReadUInt32( nAccumulate ).ReadUInt32( nTransformType );
1662 :
1663 : // nBits %0001: additive, %0010: accumulate, %0100: attributeName, %1000: transformtype
1664 : // nAdditive 0 = base, 1 = sum, 2 = replace, 3 = multiply, 4 = none
1665 : // nAccumulate 0 = none, 1 = always
1666 : // nTransformType 0: "property" else "image"
1667 :
1668 310 : if( nBits & 3 )
1669 : {
1670 204 : if( xAnimate.is() )
1671 : {
1672 204 : if( nBits & 1 )
1673 : {
1674 204 : sal_Int16 nTemp = AnimationAdditiveMode::BASE;
1675 204 : switch( nAdditive )
1676 : {
1677 0 : case 1: nTemp = AnimationAdditiveMode::SUM; break;
1678 0 : case 2: nTemp = AnimationAdditiveMode::REPLACE; break;
1679 0 : case 3: nTemp = AnimationAdditiveMode::MULTIPLY; break;
1680 0 : case 4: nTemp = AnimationAdditiveMode::NONE; break;
1681 : }
1682 204 : xAnimate->setAdditive( nTemp );
1683 : }
1684 :
1685 204 : if( nBits & 2 )
1686 : {
1687 0 : xAnimate->setAccumulate( (nAccumulate == 0) ? sal_True : sal_False );
1688 : }
1689 : }
1690 : }
1691 : #ifdef DBG_ANIM_LOG
1692 : if( nBits & 1 )
1693 : fprintf( mpFile, " additive=\"%s\"", (nAdditive == 0) ? "base" : (nAdditive == 2) ? "replace" : (nAdditive == 1) ? "sum" : (nAdditive == 3 ) ? "multiply" : (nAdditive == 4) ? "none" : "unknown" );
1694 :
1695 : if( nBits & 2 )
1696 : fprintf( mpFile, " accumulate=\"%s\"", (nAccumulate == 0) ? "none" : "always" );
1697 :
1698 : if( nBits & 8 )
1699 : fprintf( mpFile, " transformType=\"%s\"", (nTransformType == 0) ? "property" : "image" );
1700 : #endif
1701 : }
1702 : }
1703 310 : break;
1704 :
1705 : case DFF_msofbtAnimateAttributeNames:
1706 : {
1707 308 : if( xAnimate.is() )
1708 : {
1709 308 : OUString aAttributeName;
1710 308 : importAttributeNamesContainer( pChildAtom, aAttributeName );
1711 308 : if( xAnimate.is() )
1712 308 : xAnimate->setAttributeName( aAttributeName );
1713 308 : dump( " attributeName=\"%s\"", aAttributeName );
1714 : }
1715 : }
1716 308 : break;
1717 :
1718 : case DFF_msofbtAnimateTargetElement:
1719 : {
1720 : sal_Int16 nSubType;
1721 308 : importTargetElementContainer( pChildAtom, aTarget, nSubType );
1722 308 : if( xAnimate.is() )
1723 308 : xAnimate->setSubItem( nSubType );
1724 :
1725 308 : dump( " target=\"" );
1726 308 : dump_target( aTarget );
1727 308 : dump( "\"" );
1728 : }
1729 308 : break;
1730 :
1731 : default:
1732 0 : dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
1733 0 : break;
1734 : }
1735 :
1736 926 : pChildAtom = pAtom->findNextChildAtom( pChildAtom );
1737 : }
1738 : }
1739 :
1740 310 : if( bWrongContext )
1741 0 : aTarget.clear();
1742 :
1743 310 : if( xAnimate.is() )
1744 310 : xAnimate->setTarget( aTarget );
1745 : else
1746 : {
1747 0 : Reference< XCommand > xCommand( xNode, UNO_QUERY );
1748 0 : if( xCommand.is() )
1749 0 : xCommand->setTarget( aTarget );
1750 310 : }
1751 310 : }
1752 :
1753 0 : sal_Int16 AnimationImporter::implGetColorSpace( sal_Int32 nMode, sal_Int32 /*nA*/, sal_Int32 /*nB*/, sal_Int32 /*nC*/ )
1754 : {
1755 0 : switch( nMode )
1756 : {
1757 : case 2: // index
1758 : // FALLTHROUGH intended
1759 : default:
1760 : // FALLTHROUGH intended
1761 : case 0: // rgb
1762 0 : return AnimationColorSpace::RGB;
1763 :
1764 : case 1: // hsl
1765 0 : return AnimationColorSpace::HSL;
1766 : }
1767 : }
1768 :
1769 0 : Any AnimationImporter::implGetColorAny( sal_Int32 nMode, sal_Int32 nA, sal_Int32 nB, sal_Int32 nC )
1770 : {
1771 0 : switch( nMode )
1772 : {
1773 : case 0: // rgb
1774 : {
1775 0 : dump( "rgb(%ld", nA );
1776 0 : dump( ",%ld", nB );
1777 0 : dump( ",%ld)", nC );
1778 0 : Color aColor( (sal_uInt8)nA, (sal_uInt8)nB, (sal_uInt8)nC );
1779 0 : return makeAny( (sal_Int32)aColor.GetRGBColor() );
1780 : }
1781 : case 1: // hsl
1782 : {
1783 0 : dump( "hsl(%ld", nA );
1784 0 : dump( ",%ld", nB );
1785 0 : dump( ",%ld)", nC );
1786 0 : Sequence< double > aHSL( 3 );
1787 0 : aHSL[0] = nA * 360.0/255.0;
1788 0 : aHSL[1] = nB / 255.0;
1789 0 : aHSL[2] = nC / 255.0;
1790 0 : return makeAny( aHSL );
1791 : }
1792 :
1793 : case 2: // index
1794 : {
1795 0 : Color aColor;
1796 0 : mpPPTImport->GetColorFromPalette((sal_uInt16)nA, aColor );
1797 0 : dump( "index(%ld", nA );
1798 0 : dump( " [%ld", (sal_Int32)aColor.GetRed() );
1799 0 : dump( ",%ld", (sal_Int32)aColor.GetGreen() );
1800 0 : dump( ",%ld])", (sal_Int32)aColor.GetBlue() );
1801 0 : return makeAny( (sal_Int32)aColor.GetRGBColor() );
1802 : }
1803 :
1804 : default:
1805 : {
1806 0 : dump( "unknown_%ld(", nMode );
1807 0 : dump( "%ld", nA );
1808 0 : dump( ",%ld", nB );
1809 0 : dump( ",%ld)", nC );
1810 : OSL_FAIL( "ppt::implGetColorAny(), unhandled color type" );
1811 :
1812 0 : Any aAny;
1813 0 : return aAny;
1814 : }
1815 : }
1816 : }
1817 :
1818 0 : void AnimationImporter::importAnimateColorContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
1819 : {
1820 0 : Reference< XAnimateColor > xColor( xNode, UNO_QUERY );
1821 :
1822 : DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimateColor && xColor.is(), "invalid call to ppt::AnimationImporter::importAnimateColorContainer()!");
1823 0 : if( pAtom && xColor.is() )
1824 : {
1825 0 : const Atom* pChildAtom = pAtom->findFirstChildAtom();
1826 :
1827 0 : while( pChildAtom )
1828 : {
1829 0 : if( !pChildAtom->isContainer() )
1830 : {
1831 0 : if( !pChildAtom->seekToContent() )
1832 0 : break;
1833 : }
1834 :
1835 0 : switch( pChildAtom->getType() )
1836 : {
1837 : case DFF_msofbtAnimateColorData:
1838 : {
1839 : sal_uInt32 nBits;
1840 : sal_Int32 nByMode, nByA, nByB, nByC;
1841 : sal_Int32 nFromMode, nFromA, nFromB, nFromC;
1842 : sal_Int32 nToMode, nToA, nToB, nToC;
1843 0 : mrStCtrl.ReadUInt32( nBits );
1844 0 : mrStCtrl.ReadInt32( nByMode ).ReadInt32( nByA ).ReadInt32( nByB ).ReadInt32( nByC );
1845 0 : mrStCtrl.ReadInt32( nFromMode ).ReadInt32( nFromA ).ReadInt32( nFromB ).ReadInt32( nFromC );
1846 0 : mrStCtrl.ReadInt32( nToMode ).ReadInt32( nToA ).ReadInt32( nToB ).ReadInt32( nToC );
1847 :
1848 0 : if( nBits & 1 )
1849 : {
1850 0 : dump( " by=\"" );
1851 0 : xColor->setBy( implGetColorAny( nByMode, nByA, nByB, nByC ) );
1852 0 : xColor->setColorInterpolation( implGetColorSpace( nByMode, nByA, nByB, nByC ) );
1853 0 : dump( "\"");
1854 : }
1855 :
1856 0 : if( nBits & 2 )
1857 : {
1858 0 : dump( " from=\"" );
1859 0 : xColor->setFrom( implGetColorAny( nFromMode, nFromA, nFromB, nFromC ) );
1860 0 : xColor->setColorInterpolation( implGetColorSpace( nFromMode, nFromA, nFromB, nFromC ) );
1861 0 : dump( "\"");
1862 : }
1863 :
1864 0 : if( nBits & 4 )
1865 : {
1866 0 : dump( " to=\"" );
1867 0 : xColor->setTo( implGetColorAny( nToMode, nToA, nToB, nToC ) );
1868 0 : xColor->setColorInterpolation( implGetColorSpace( nToMode, nToA, nToB, nToC ) );
1869 0 : dump( "\"");
1870 : }
1871 : }
1872 0 : break;
1873 :
1874 : case DFF_msofbtAnimateTarget:
1875 0 : importAnimateAttributeTargetContainer( pChildAtom, xNode );
1876 0 : break;
1877 :
1878 : default:
1879 0 : dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
1880 0 : break;
1881 : }
1882 :
1883 0 : pChildAtom = pAtom->findNextChildAtom( pChildAtom );
1884 : }
1885 0 : }
1886 0 : }
1887 :
1888 104 : void AnimationImporter::importAnimateSetContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
1889 : {
1890 104 : Reference< XAnimateSet > xSet( xNode, UNO_QUERY );
1891 :
1892 : DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimateSet && xSet.is(), "invalid call to ppt::AnimationImporter::importAnimateSetContainer()!");
1893 104 : if( pAtom && xSet.is() )
1894 : {
1895 104 : const Atom* pChildAtom = pAtom->findFirstChildAtom();
1896 :
1897 520 : while( pChildAtom )
1898 : {
1899 312 : if( !pChildAtom->isContainer() )
1900 : {
1901 208 : if( !pChildAtom->seekToContent() )
1902 0 : break;
1903 : }
1904 :
1905 312 : switch( pChildAtom->getType() )
1906 : {
1907 : case DFF_msofbtAnimateSetData:
1908 : {
1909 : sal_Int32 nU1, nU2;
1910 104 : mrStCtrl.ReadInt32( nU1 ).ReadInt32( nU2 );
1911 :
1912 104 : dump( " set_1=\"%ld\"", nU1 ),
1913 104 : dump( " set_2=\"%ld\"", nU2 );
1914 : }
1915 104 : break;
1916 :
1917 : case DFF_msofbtAnimAttributeValue:
1918 : {
1919 104 : Any aTo;
1920 104 : if ( importAttributeValue( pChildAtom, aTo ) )
1921 : {
1922 104 : xSet->setTo( aTo );
1923 :
1924 104 : dump( " value=\"" );
1925 104 : dump( aTo );
1926 104 : dump( "\"" );
1927 104 : }
1928 : }
1929 104 : break;
1930 :
1931 : case DFF_msofbtAnimateTarget:
1932 104 : importAnimateAttributeTargetContainer( pChildAtom, xNode );
1933 104 : break;
1934 :
1935 : default:
1936 0 : dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
1937 0 : break;
1938 : }
1939 :
1940 312 : pChildAtom = pAtom->findNextChildAtom( pChildAtom );
1941 : }
1942 104 : }
1943 104 : }
1944 :
1945 204 : void AnimationImporter::importAnimateContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
1946 : {
1947 204 : Reference< XAnimate > xAnim( xNode, UNO_QUERY );
1948 :
1949 : DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimate && xAnim.is(), "invalid call to ppt::AnimationImporter::importAnimateContainer()!");
1950 204 : if( pAtom && xAnim.is() )
1951 : {
1952 204 : const Atom* pChildAtom = pAtom->findFirstChildAtom();
1953 :
1954 1020 : while( pChildAtom )
1955 : {
1956 612 : if( !pChildAtom->isContainer() )
1957 : {
1958 204 : if( !pChildAtom->seekToContent() )
1959 0 : break;
1960 : }
1961 :
1962 612 : switch( pChildAtom->getType() )
1963 : {
1964 : case DFF_msofbtAnimateData:
1965 : {
1966 : sal_uInt32 nCalcmode, nBits, nValueType;
1967 204 : mrStCtrl.ReadUInt32( nCalcmode ).ReadUInt32( nBits ).ReadUInt32( nValueType );
1968 :
1969 204 : if( nBits & 0x08 )
1970 : {
1971 204 : sal_Int16 n = (nCalcmode == 1) ? AnimationCalcMode::LINEAR : /* (nCalcmode == 2) ? AnimationCalcMode::FORMULA : */ AnimationCalcMode::DISCRETE;
1972 204 : xAnim->setCalcMode( n );
1973 204 : dump( " calcmode=\"%s\"", (nCalcmode == 0) ? "discrete" : (nCalcmode == 1) ? "linear" : (nCalcmode == 2) ? "formula" : "unknown" );
1974 : }
1975 :
1976 204 : if( nBits & 0x30 )
1977 : {
1978 204 : sal_Int16 n = (nValueType == 1) ? AnimationValueType::NUMBER : (nValueType == 2 ) ? AnimationValueType::COLOR : AnimationValueType::STRING;
1979 204 : xAnim->setValueType( n );
1980 204 : dump( " valueType=\"%s\"", (nValueType == 0) ? "string" : (nValueType == 1) ? "number" : (nValueType == 2) ? "color" : "unknown" );
1981 : }
1982 : }
1983 204 : break;
1984 :
1985 : case DFF_msofbtAnimateTarget:
1986 204 : importAnimateAttributeTargetContainer( pChildAtom, xNode );
1987 204 : break;
1988 :
1989 : case DFF_msofbtAnimKeyPoints:
1990 204 : importAnimateKeyPoints( pChildAtom, xNode );
1991 204 : break;
1992 :
1993 : case DFF_msofbtAnimAttributeValue:
1994 : {
1995 0 : Any a;
1996 0 : if ( importAttributeValue( pChildAtom, a ) )
1997 : {
1998 0 : switch( pChildAtom->getInstance() )
1999 : {
2000 0 : case 1: xAnim->setBy( a ); dump( " by=\"" ); break;
2001 0 : case 2: xAnim->setFrom( a ); dump( " from=\"" ); break;
2002 0 : case 3: xAnim->setTo( a ); dump( " to=\"" ); break;
2003 : default:
2004 0 : dump( " unknown_value=\"" );
2005 : }
2006 :
2007 0 : dump( a );
2008 0 : dump( "\"" );
2009 0 : }
2010 : }
2011 0 : break;
2012 : default:
2013 0 : dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
2014 0 : break;
2015 : }
2016 :
2017 612 : pChildAtom = pAtom->findNextChildAtom( pChildAtom );
2018 : }
2019 204 : }
2020 204 : }
2021 :
2022 0 : void AnimationImporter::importAnimateMotionContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
2023 : {
2024 0 : Reference< XAnimateMotion > xMotion( xNode, UNO_QUERY );
2025 :
2026 : DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimateMotion && xMotion.is(), "invalid call to ppt::AnimationImporter::importAnimateMotionContainer()!");
2027 0 : if( pAtom && xMotion.is() )
2028 : {
2029 0 : const Atom* pChildAtom = pAtom->findFirstChildAtom();
2030 :
2031 0 : while( pChildAtom )
2032 : {
2033 0 : if( !pChildAtom->isContainer() )
2034 : {
2035 0 : if( !pChildAtom->seekToContent() )
2036 0 : break;
2037 : }
2038 :
2039 0 : switch( pChildAtom->getType() )
2040 : {
2041 : case DFF_msofbtAnimateMotionData:
2042 : {
2043 : sal_uInt32 nBits, nOrigin;
2044 : float fByX, fByY, fFromX, fFromY, fToX, fToY;
2045 :
2046 0 : mrStCtrl.ReadUInt32( nBits ).ReadFloat( fByX ).ReadFloat( fByY ).ReadFloat( fFromX ).ReadFloat( fFromY ).ReadFloat( fToX ).ReadFloat( fToY ).ReadUInt32( nOrigin );
2047 :
2048 : #ifdef DBG_ANIM_LOG
2049 : if( nBits & 1 )
2050 : fprintf( mpFile, " by=\"%g,%g\"", (double)fByX, (double)fByY );
2051 :
2052 : if( nBits & 2 )
2053 : fprintf( mpFile, " from=\"%g,%g\"", (double)fFromX, (double)fFromY );
2054 :
2055 : if( nBits & 4 )
2056 : fprintf( mpFile, " to=\"%g,%g\"", (double)fToX, (double)fToY );
2057 :
2058 : if( nBits & 8 )
2059 : fprintf( mpFile, " origin=\"%s\"", (nOrigin == 1) ? "parent" : (nOrigin == 2) ? "layout" : "unknown" );
2060 :
2061 : #endif
2062 : }
2063 0 : break;
2064 :
2065 : case DFF_msofbtAnimAttributeValue:
2066 : {
2067 0 : Any aPath;
2068 0 : if ( importAttributeValue( pChildAtom, aPath ) )
2069 : {
2070 0 : OUString aStr;
2071 0 : if ( aPath >>= aStr )
2072 : {
2073 : // E can appear inside a number, so we only check for its presence at the end
2074 0 : aStr = aStr.trim();
2075 0 : if (aStr.endsWith("E"))
2076 0 : aStr = aStr.copy(0, aStr.getLength() - 1);
2077 0 : aStr = aStr.trim();
2078 0 : aPath <<= aStr;
2079 0 : xMotion->setPath( aPath );
2080 0 : dump( " path=\"" );
2081 0 : dump( aPath );
2082 0 : dump( "\"" );
2083 0 : }
2084 0 : }
2085 : }
2086 0 : break;
2087 :
2088 : case DFF_msofbtAnimateTarget:
2089 0 : importAnimateAttributeTargetContainer( pChildAtom, xNode );
2090 0 : break;
2091 :
2092 : default:
2093 0 : dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
2094 0 : break;
2095 : }
2096 :
2097 0 : pChildAtom = pAtom->findNextChildAtom( pChildAtom );
2098 : }
2099 0 : }
2100 0 : }
2101 :
2102 0 : void AnimationImporter::importCommandContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
2103 : {
2104 0 : Reference< XCommand > xCommand( xNode, UNO_QUERY );
2105 : DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimCommand && xCommand.is(), "invalid call to ppt::AnimationImporter::importCommandContainer()!");
2106 0 : if( pAtom && xCommand.is() )
2107 : {
2108 0 : sal_Int32 nBits = 0;
2109 0 : Any aValue;
2110 :
2111 0 : const Atom* pChildAtom = pAtom->findFirstChildAtom();
2112 :
2113 0 : while( pChildAtom )
2114 : {
2115 0 : if( !pChildAtom->isContainer() )
2116 : {
2117 0 : if( !pChildAtom->seekToContent() )
2118 0 : break;
2119 : }
2120 :
2121 0 : switch( pChildAtom->getType() )
2122 : {
2123 : case DFF_msofbtCommandData:
2124 : {
2125 : sal_Int32 nCommandType;
2126 : // looks like U1 is a bitset, bit 1 enables the type and bit 2 enables
2127 : // a propertyvalue that follows
2128 0 : mrStCtrl.ReadInt32( nBits );
2129 0 : mrStCtrl.ReadInt32( nCommandType );
2130 :
2131 0 : if( nBits & 1 )
2132 : {
2133 0 : dump( " type=\"%s\"", (nCommandType == 0) ? "event" : ( nCommandType == 1) ? "call" : "verb" );
2134 : }
2135 : }
2136 0 : break;
2137 :
2138 : case DFF_msofbtAnimAttributeValue:
2139 : {
2140 0 : if ( importAttributeValue( pChildAtom, aValue ) )
2141 : {
2142 0 : if( nBits & 2 )
2143 : {
2144 0 : dump( " cmd=\"" );
2145 0 : dump( aValue );
2146 0 : dump( "\"" );
2147 : }
2148 : }
2149 : }
2150 0 : break;
2151 :
2152 : case DFF_msofbtAnimateTarget:
2153 0 : importAnimateAttributeTargetContainer( pChildAtom, xNode );
2154 0 : break;
2155 :
2156 : default:
2157 0 : dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
2158 0 : break;
2159 : }
2160 :
2161 0 : pChildAtom = pAtom->findNextChildAtom( pChildAtom );
2162 : }
2163 :
2164 0 : if( nBits & 3 )
2165 : {
2166 0 : OUString aParam;
2167 0 : aValue >>= aParam;
2168 :
2169 0 : sal_Int16 nCommand = EffectCommands::CUSTOM;
2170 :
2171 0 : NamedValue aParamValue;
2172 :
2173 0 : if ( aParam == "onstopaudio" )
2174 : {
2175 0 : nCommand = EffectCommands::STOPAUDIO;
2176 : }
2177 0 : else if ( aParam == "play" )
2178 : {
2179 0 : nCommand = EffectCommands::PLAY;
2180 : }
2181 0 : else if( aParam.startsWith( "playFrom" ) )
2182 : {
2183 0 : const OUString aMediaTime( aParam.copy( 9, aParam.getLength() - 10 ) );
2184 : rtl_math_ConversionStatus eStatus;
2185 0 : double fMediaTime = ::rtl::math::stringToDouble( aMediaTime, (sal_Unicode)('.'), (sal_Unicode)(','), &eStatus, NULL );
2186 0 : if( eStatus == rtl_math_ConversionStatus_Ok )
2187 : {
2188 0 : aParamValue.Name = "MediaTime";
2189 0 : aParamValue.Value <<= fMediaTime;
2190 : }
2191 0 : nCommand = EffectCommands::PLAY;
2192 : }
2193 0 : else if ( aParam == "togglePause" )
2194 : {
2195 0 : nCommand = EffectCommands::TOGGLEPAUSE;
2196 : }
2197 0 : else if ( aParam == "stop" )
2198 : {
2199 0 : nCommand = EffectCommands::STOP;
2200 : }
2201 :
2202 0 : xCommand->setCommand( nCommand );
2203 0 : if( nCommand == EffectCommands::CUSTOM )
2204 : {
2205 : OSL_FAIL("sd::AnimationImporter::importCommandContainer(), unknown command!");
2206 0 : aParamValue.Name = "UserDefined";
2207 0 : aParamValue.Value <<= aParam;
2208 : }
2209 :
2210 0 : if( aParamValue.Value.hasValue() )
2211 : {
2212 0 : Sequence< NamedValue > aParamSeq( &aParamValue, 1 );
2213 0 : xCommand->setParameter( makeAny( aParamSeq ) );
2214 0 : }
2215 0 : }
2216 0 : }
2217 0 : }
2218 :
2219 0 : int AnimationImporter::importAudioContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
2220 : {
2221 0 : int nNodes = 0;
2222 :
2223 0 : Reference< XAudio > xAudio( xNode, UNO_QUERY );
2224 : DBG_ASSERT( pAtom && xAudio.is() &&
2225 : ( (pAtom->getType() == DFF_msofbtAnimGroup) ||
2226 : (pAtom->getType() == DFF_msofbtAnimSubGoup) ), "invalid call to ppt::AnimationImporter::importAudioContainer()!");
2227 0 : if( pAtom && xAudio.is() )
2228 : {
2229 0 : importAnimationEvents( pAtom, xNode );
2230 0 : importAnimationValues( pAtom, xNode );
2231 0 : importAnimationActions( pAtom, xNode );
2232 :
2233 0 : dump(">\n");
2234 :
2235 0 : const Atom* pChildAtom = pAtom->findFirstChildAtom();
2236 :
2237 0 : while( pChildAtom )
2238 : {
2239 0 : if( !pChildAtom->isContainer() )
2240 : {
2241 0 : if( !pChildAtom->seekToContent() )
2242 0 : break;
2243 : }
2244 :
2245 0 : switch( pChildAtom->getType() )
2246 : {
2247 : case DFF_msofbtAnimNode:
2248 : case DFF_msofbtAnimEvent:
2249 : case DFF_msofbtAnimValue:
2250 : case DFF_msofbtAnimAction:
2251 : case DFF_msofbtAnimPropertySet:
2252 0 : break;
2253 :
2254 : case DFF_msofbtAnimAttributeValue:
2255 : {
2256 0 : Any aValue;
2257 0 : if ( importAttributeValue( pChildAtom, aValue ) )
2258 : {
2259 0 : nNodes ++;
2260 0 : dump( " value=\"" );
2261 0 : dump( aValue );
2262 0 : dump( "\"" );
2263 0 : }
2264 : }
2265 0 : break;
2266 :
2267 : case DFF_msofbtAnimateTargetElement:
2268 : {
2269 : sal_Int16 nSubType;
2270 0 : Any aSource;
2271 0 : importTargetElementContainer( pChildAtom, aSource, nSubType );
2272 0 : if( xAudio.is() ) {
2273 0 : xAudio->setSource( aSource );
2274 0 : nNodes ++;
2275 0 : }
2276 : }
2277 0 : break;
2278 :
2279 : default:
2280 0 : dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
2281 0 : break;
2282 : }
2283 :
2284 0 : pChildAtom = pAtom->findNextChildAtom( pChildAtom );
2285 : }
2286 :
2287 : // TODO: What to do with them?
2288 0 : Any aEmpty;
2289 0 : xAudio->setBegin( aEmpty );
2290 0 : xAudio->setEnd( aEmpty );
2291 : }
2292 :
2293 0 : return nNodes;
2294 : }
2295 :
2296 0 : void AnimationImporter::importAnimateScaleContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
2297 : {
2298 0 : Reference< XAnimateTransform > xTransform( xNode, UNO_QUERY );
2299 :
2300 : DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimateScale && xTransform.is(), "invalid call to ppt::AnimationImporter::importAnimateScaleContainer()!");
2301 0 : if( pAtom && xTransform.is() )
2302 : {
2303 0 : xTransform->setTransformType( AnimationTransformType::SCALE );
2304 :
2305 0 : const Atom* pChildAtom = pAtom->findFirstChildAtom();
2306 :
2307 0 : while( pChildAtom )
2308 : {
2309 0 : if( !pChildAtom->isContainer() )
2310 : {
2311 0 : if( !pChildAtom->seekToContent() )
2312 0 : break;
2313 : }
2314 :
2315 0 : switch( pChildAtom->getType() )
2316 : {
2317 : case DFF_msofbtAnimateScaleData:
2318 : {
2319 : sal_uInt32 nBits, nZoomContents;
2320 : float fByX, fByY, fFromX, fFromY, fToX, fToY;
2321 :
2322 : // nBits %001: by, %010: from, %100: to, %1000: zoomContents(bool)
2323 0 : mrStCtrl.ReadUInt32( nBits ).ReadFloat( fByX ).ReadFloat( fByY ).ReadFloat( fFromX ).ReadFloat( fFromY ).ReadFloat( fToX ).ReadFloat( fToY ).ReadUInt32( nZoomContents );
2324 :
2325 0 : ValuePair aPair;
2326 : // 'from' value
2327 0 : if( nBits & 2 )
2328 : {
2329 0 : aPair.First <<= (double)fFromX / 100.0;
2330 0 : aPair.Second <<= (double)fFromY / 100.0;
2331 0 : xTransform->setFrom( makeAny( aPair ) );
2332 : }
2333 :
2334 : // 'to' value
2335 0 : if( nBits & 4 )
2336 : {
2337 0 : aPair.First <<= (double)fToX / 100.0;
2338 0 : aPair.Second <<= (double)fToY / 100.0;
2339 0 : xTransform->setTo( makeAny( aPair ) );
2340 : }
2341 :
2342 : // 'by' value
2343 0 : if( nBits & 1 )
2344 : {
2345 0 : aPair.First <<= (double)fByX / 100.0;
2346 0 : aPair.Second <<= (double)fByY / 100.0;
2347 :
2348 0 : if( nBits & 2 )
2349 : {
2350 : // 'from' value given, import normally
2351 0 : xTransform->setBy( makeAny( aPair ) );
2352 : }
2353 : else
2354 : {
2355 : // mapping 'by' to 'to', if no 'from' is
2356 : // given. This is due to a non-conformity in
2357 : // PPT, which exports animateScale effects
2358 : // with a sole 'by' value, but with the
2359 : // semantics of a sole 'to' animation
2360 0 : xTransform->setTo( makeAny( aPair ) );
2361 : }
2362 0 : }
2363 :
2364 : #ifdef DBG_ANIM_LOG
2365 : if( nBits & 1 )
2366 : fprintf( mpFile, " by=\"%g,%g\"", (double)fByX, (double)fByY );
2367 :
2368 : if( nBits & 2 )
2369 : fprintf( mpFile, " from=\"%g,%g\"", (double)fFromX, (double)fFromY );
2370 :
2371 : if( nBits & 4 )
2372 : fprintf( mpFile, " to=\"%g,%g\"", (double)fToX, (double)fToY );
2373 :
2374 : if( nBits & 8 )
2375 : fprintf( mpFile, " zoomContents=\"%s\"", nZoomContents ? "true" : "false" );
2376 : #endif
2377 : }
2378 0 : break;
2379 :
2380 : case DFF_msofbtAnimateTarget:
2381 0 : importAnimateAttributeTargetContainer( pChildAtom, xNode );
2382 0 : break;
2383 :
2384 : default:
2385 0 : dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
2386 0 : break;
2387 : }
2388 :
2389 0 : pChildAtom = pAtom->findNextChildAtom( pChildAtom );
2390 : }
2391 0 : }
2392 0 : }
2393 :
2394 0 : void AnimationImporter::importAnimateRotationContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
2395 : {
2396 0 : Reference< XAnimateTransform > xTransform( xNode, UNO_QUERY );
2397 :
2398 : DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimateRotation && xTransform.is(), "invalid call to ppt::AnimationImporter::importAnimateRotationContainer()!");
2399 0 : if( pAtom && xTransform.is() )
2400 : {
2401 0 : xTransform->setTransformType( AnimationTransformType::ROTATE );
2402 :
2403 0 : const Atom* pChildAtom = pAtom->findFirstChildAtom();
2404 :
2405 0 : while( pChildAtom )
2406 : {
2407 0 : if( !pChildAtom->isContainer() )
2408 : {
2409 0 : if( !pChildAtom->seekToContent() )
2410 0 : break;
2411 : }
2412 :
2413 0 : switch( pChildAtom->getType() )
2414 : {
2415 : case DFF_msofbtAnimateRotationData:
2416 : {
2417 : sal_uInt32 nBits, nU1;
2418 : float fBy, fFrom, fTo;
2419 :
2420 : // nBits %001: by, %010: from, %100: to, %1000: zoomContents(bool)
2421 0 : mrStCtrl.ReadUInt32( nBits ).ReadFloat( fBy ).ReadFloat( fFrom ).ReadFloat( fTo ).ReadUInt32( nU1 );
2422 :
2423 0 : if( nBits & 1 )
2424 0 : xTransform->setBy( makeAny( (double) fBy ) );
2425 :
2426 0 : if( nBits & 2 )
2427 0 : xTransform->setFrom( makeAny( (double) fFrom ) );
2428 :
2429 0 : if( nBits & 4 )
2430 0 : xTransform->setTo( makeAny( (double) fTo ) );
2431 :
2432 : #ifdef DBG_ANIM_LOG
2433 : if( nBits & 1 )
2434 : fprintf( mpFile, " by=\"%g\"", (double)fBy );
2435 :
2436 : if( nBits & 2 )
2437 : fprintf( mpFile, " from=\"%g\"", (double)fFrom );
2438 :
2439 : if( nBits & 4 )
2440 : fprintf( mpFile, " to=\"%g\"", (double)fTo );
2441 :
2442 : if( nU1 )
2443 : fprintf( mpFile, " rotation_1=\"%ld\"", nU1 );
2444 : #endif
2445 : }
2446 0 : break;
2447 :
2448 : case DFF_msofbtAnimateTarget:
2449 0 : importAnimateAttributeTargetContainer( pChildAtom, xNode );
2450 0 : break;
2451 :
2452 : default:
2453 0 : dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
2454 0 : break;
2455 : }
2456 :
2457 0 : pChildAtom = pAtom->findNextChildAtom( pChildAtom );
2458 : }
2459 0 : }
2460 0 : }
2461 :
2462 308 : bool AnimationImporter::importAttributeNamesContainer( const Atom* pAtom, OUString& rAttributeNames )
2463 : {
2464 308 : OUStringBuffer aNames;
2465 :
2466 : DBG_ASSERT( pAtom && (pAtom->getType() == DFF_msofbtAnimateAttributeNames), "invalid call to ppt::AnimationImporter::importAttributeName()!" );
2467 308 : if( pAtom )
2468 : {
2469 308 : const Atom* pAttributeValueAtom = pAtom->findFirstChildAtom( DFF_msofbtAnimAttributeValue );
2470 :
2471 924 : while( pAttributeValueAtom )
2472 : {
2473 308 : Any aAny;
2474 308 : if ( importAttributeValue( pAttributeValueAtom, aAny ) )
2475 : {
2476 308 : OUString aName;
2477 308 : if( aAny >>= aName )
2478 : {
2479 308 : if( !aNames.isEmpty() )
2480 0 : aNames.append( ';' );
2481 :
2482 308 : aNames.append( aName );
2483 308 : }
2484 : }
2485 : else
2486 : {
2487 : OSL_FAIL( "error during ppt::AnimationImporter::importAttributeName()!" );
2488 : }
2489 :
2490 308 : pAttributeValueAtom = pAtom->findNextChildAtom( DFF_msofbtAnimAttributeValue, pAttributeValueAtom );
2491 308 : }
2492 : }
2493 :
2494 308 : rAttributeNames = aNames.makeStringAndClear();
2495 308 : return true;
2496 : }
2497 :
2498 624 : void AnimationImporter::importAnimationValues( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
2499 : {
2500 : DBG_ASSERT( pAtom, "invalid call to ppt::AnimationImporter::importAnimationValues()!" );
2501 :
2502 624 : if( pAtom )
2503 : {
2504 624 : const Atom* pValueAtom = pAtom->findFirstChildAtom( DFF_msofbtAnimValue );
2505 :
2506 1248 : while( pValueAtom && pValueAtom->seekToContent() )
2507 : {
2508 : sal_uInt32 nType;
2509 0 : mrStCtrl.ReadUInt32( nType );
2510 0 : switch( nType )
2511 : {
2512 : case 0:
2513 : {
2514 : float fRepeat;
2515 0 : mrStCtrl.ReadFloat( fRepeat );
2516 0 : xNode->setRepeatCount( (fRepeat < ((float)3.40282346638528860e+38)) ? makeAny( (double)fRepeat ) : makeAny( Timing_INDEFINITE ) );
2517 :
2518 : #ifdef DBG_ANIM_LOG
2519 : if( (fRepeat < ((float)3.40282346638528860e+38)) )
2520 : {
2521 : dump( " repeat=\"%g\"", (double)fRepeat );
2522 : }
2523 : else
2524 : {
2525 : dump( " repeat=\"indefinite\"" );
2526 : }
2527 : #endif
2528 : }
2529 0 : break;
2530 :
2531 : case 3:
2532 : {
2533 : float faccelerate;
2534 0 : mrStCtrl.ReadFloat( faccelerate );
2535 0 : xNode->setAcceleration( faccelerate );
2536 0 : dump( " accelerate=\"%g\"", (double)faccelerate );
2537 : }
2538 0 : break;
2539 :
2540 : case 4:
2541 : {
2542 : float fdecelerate;
2543 0 : mrStCtrl.ReadFloat( fdecelerate );
2544 0 : xNode->setDecelerate( fdecelerate );
2545 0 : dump( " decelerate=\"%g\"", (double)fdecelerate );
2546 : }
2547 0 : break;
2548 :
2549 : case 5:
2550 : {
2551 : sal_Int32 nAutoreverse;
2552 0 : mrStCtrl.ReadInt32( nAutoreverse );
2553 0 : xNode->setAutoReverse( nAutoreverse != 0 );
2554 0 : dump( " autoreverse=\"%#lx\"", nAutoreverse );
2555 : }
2556 0 : break;
2557 :
2558 : default:
2559 : {
2560 : sal_uInt32 nUnknown;
2561 0 : mrStCtrl.ReadUInt32( nUnknown );
2562 : #ifdef DBG_ANIM_LOG
2563 : fprintf(mpFile, " attribute_%d=\"%#lx\"", nType, nUnknown );
2564 : #endif
2565 : }
2566 0 : break;
2567 : }
2568 :
2569 0 : pValueAtom = pAtom->findNextChildAtom( DFF_msofbtAnimValue, pValueAtom );
2570 : }
2571 : }
2572 624 : }
2573 :
2574 204 : void AnimationImporter::importAnimateKeyPoints( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
2575 : {
2576 204 : Reference< XAnimate > xAnim( xNode, UNO_QUERY );
2577 :
2578 : DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimKeyPoints && xAnim.is(), "invalid call to ppt::AnimationImporter::importAnimateKeyPoints()!" );
2579 :
2580 204 : if( pAtom && xAnim.is() )
2581 : {
2582 : // first count keytimes
2583 204 : const Atom* pIter = NULL;
2584 204 : int nKeyTimes = 0;
2585 :
2586 816 : while( (pIter = pAtom->findNextChildAtom( DFF_msofbtAnimKeyTime, pIter )) != 0 )
2587 408 : nKeyTimes++;
2588 :
2589 204 : Sequence< double > aKeyTimes( nKeyTimes );
2590 408 : Sequence< Any > aValues( nKeyTimes );
2591 408 : OUString aFormula;
2592 :
2593 204 : pIter = pAtom->findFirstChildAtom(DFF_msofbtAnimKeyTime);
2594 : int nKeyTime;
2595 : sal_Int32 nTemp;
2596 612 : for( nKeyTime = 0; (nKeyTime < nKeyTimes) && pIter; nKeyTime++ )
2597 : {
2598 408 : if( pIter->seekToContent() )
2599 : {
2600 408 : mrStCtrl.ReadInt32( nTemp );
2601 408 : double fTemp = (double)nTemp / 1000.0;
2602 408 : aKeyTimes[nKeyTime] = fTemp;
2603 :
2604 408 : const Atom* pValue = pAtom->findNextChildAtom(pIter);
2605 408 : if( pValue && pValue->getType() == DFF_msofbtAnimAttributeValue )
2606 : {
2607 816 : Any aValue1, aValue2;
2608 408 : if( importAttributeValue( pValue, aValue1 ) )
2609 : {
2610 408 : pValue = pAtom->findNextChildAtom(pValue);
2611 408 : if( pValue && pValue->getType() == DFF_msofbtAnimAttributeValue )
2612 408 : importAttributeValue( pValue, aValue2 );
2613 :
2614 408 : bool bCouldBeFormula = false;
2615 408 : bool bHasValue = aValue2.hasValue();
2616 408 : if( bHasValue )
2617 : {
2618 408 : if( aValue2.getValueType() == cppu::UnoType<OUString>::get() )
2619 : {
2620 408 : OUString aTest;
2621 408 : aValue2 >>= aTest;
2622 408 : bHasValue = !aTest.isEmpty();
2623 408 : bCouldBeFormula = true;
2624 : }
2625 : }
2626 :
2627 408 : if( bHasValue && bCouldBeFormula && (aValue1.getValueType() == cppu::UnoType<double>::get() ))
2628 : {
2629 0 : aValue2 >>= aFormula;
2630 0 : bHasValue = false;
2631 : }
2632 :
2633 408 : if( bHasValue )
2634 : {
2635 0 : aValues[nKeyTime] = makeAny( ValuePair( aValue1, aValue2 ) );
2636 : }
2637 : else
2638 : {
2639 408 : aValues[nKeyTime] = aValue1;
2640 : }
2641 408 : }
2642 : }
2643 : }
2644 408 : pIter = pAtom->findNextChildAtom(DFF_msofbtAnimKeyTime, pIter);
2645 : }
2646 :
2647 : #ifdef DBG_ANIM_LOG
2648 : dump( " keyTimes=\"" );
2649 : for( int i=0; i<nKeyTimes; ++i )
2650 : dump( "%f;", aKeyTimes[i] );
2651 :
2652 : if( !aFormula.isEmpty() )
2653 : {
2654 : dump( "formula=\"%s", aFormula );
2655 : }
2656 :
2657 : dump( "\" values=\"" );
2658 : double nVal;
2659 : OUString aStr;
2660 : for( int i=0; i<nKeyTimes; ++i )
2661 : {
2662 : if( i != 0 )
2663 : dump( ";" );
2664 :
2665 : if( aValues[i] >>= aStr )
2666 : dump( "%s",
2667 : OUStringToOString( aStr,
2668 : RTL_TEXTENCODING_ASCII_US ).getStr() );
2669 : else if( aValues[i] >>= nVal )
2670 : dump( "%f", nVal );
2671 : else
2672 : {
2673 : ValuePair aValuePair;
2674 :
2675 : if( aValues[i] >>= aValuePair )
2676 : {
2677 : if( aValuePair.First >>= aStr )
2678 : dump( "%s",
2679 : OUStringToOString( aStr,
2680 : RTL_TEXTENCODING_ASCII_US ).getStr() );
2681 : else if( aValuePair.First >>= nVal )
2682 : dump( "%f", nVal );
2683 : else
2684 : dump( "%X", (sal_Int64)&aValuePair.First );
2685 :
2686 : if( aValuePair.Second >>= aStr )
2687 : dump( ",%s",
2688 : OUStringToOString( aStr,
2689 : RTL_TEXTENCODING_ASCII_US ).getStr() );
2690 : else if( aValuePair.Second >>= nVal )
2691 : dump( ",%f", nVal );
2692 : else
2693 : dump( ",%X", (sal_Int64)&aValuePair.Second );
2694 : }
2695 : }
2696 : }
2697 : dump( "\"" );
2698 : #endif
2699 :
2700 204 : xAnim->setKeyTimes( aKeyTimes );
2701 204 : xAnim->setValues( aValues );
2702 408 : xAnim->setFormula( aFormula );
2703 204 : }
2704 204 : }
2705 :
2706 1794 : bool AnimationImporter::importAttributeValue( const Atom* pAtom, Any& rAny )
2707 : {
2708 : DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimAttributeValue, "invalid call to ppt::AnimationImporter::importAttributeValue()!" );
2709 :
2710 1794 : bool bOk = false;
2711 :
2712 1794 : if( pAtom && pAtom->seekToContent() )
2713 : {
2714 1794 : sal_uInt32 nRecLen = pAtom->getLength();
2715 1794 : if ( nRecLen >= 1 )
2716 : {
2717 : sal_Int8 nType;
2718 1794 : mrStCtrl.ReadSChar( nType );
2719 1794 : switch( nType )
2720 : {
2721 : case DFF_ANIM_PROP_TYPE_BYTE :
2722 : {
2723 0 : if ( nRecLen == 2 )
2724 : {
2725 : sal_uInt8 nByte;
2726 0 : mrStCtrl.ReadUChar( nByte );
2727 0 : rAny <<= nByte;
2728 :
2729 0 : bOk = true;
2730 : }
2731 : }
2732 0 : break;
2733 :
2734 : case DFF_ANIM_PROP_TYPE_INT32 :
2735 : {
2736 564 : if ( nRecLen == 5 )
2737 : {
2738 : sal_uInt32 nInt32;
2739 564 : mrStCtrl.ReadUInt32( nInt32 );
2740 564 : rAny <<= nInt32;
2741 :
2742 564 : bOk = true;
2743 : }
2744 : }
2745 564 : break;
2746 :
2747 : case DFF_ANIM_PROP_TYPE_FLOAT:
2748 : {
2749 0 : if( nRecLen == 5 )
2750 : {
2751 : float fFloat;
2752 0 : mrStCtrl.ReadFloat( fFloat );
2753 0 : rAny <<= (double)fFloat;
2754 :
2755 0 : bOk = true;
2756 : }
2757 : }
2758 0 : break;
2759 :
2760 : case DFF_ANIM_PROP_TYPE_UNISTRING :
2761 : {
2762 1230 : if ( ( nRecLen & 1 ) && ( nRecLen > 1 ) )
2763 : {
2764 1230 : OUString aOUString = SvxMSDffManager::MSDFFReadZString( mrStCtrl, nRecLen - 1, true );
2765 1230 : rAny <<= aOUString;
2766 :
2767 1230 : bOk = true;
2768 : }
2769 : }
2770 1230 : break;
2771 : }
2772 : }
2773 : }
2774 :
2775 : DBG_ASSERT( bOk, "invalid value inside ppt::AnimationImporter::importAttributeValue()!" );
2776 1794 : return bOk;
2777 : }
2778 :
2779 624 : void AnimationImporter::importAnimationEvents( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
2780 : {
2781 : DBG_ASSERT( xNode.is() && pAtom, "invalid call to ppt::AnimationImporter::importAnimationEvents()!" );
2782 :
2783 1248 : Any aBegin, aEnd, aNext, aPrev;
2784 :
2785 624 : const Atom* pEventAtom = pAtom->findFirstChildAtom( DFF_msofbtAnimEvent );
2786 1624 : while( pEventAtom )
2787 : {
2788 376 : Any* pEvents = NULL;
2789 :
2790 376 : switch( pEventAtom->getInstance() )
2791 : {
2792 312 : case 1: pEvents = &aBegin; break;
2793 0 : case 2: pEvents = &aEnd; break;
2794 32 : case 3: pEvents = &aNext; break;
2795 32 : case 4: pEvents = &aPrev; break;
2796 : }
2797 :
2798 376 : if( pEvents )
2799 : {
2800 376 : Event aEvent;
2801 376 : aEvent.Trigger = EventTrigger::NONE;
2802 376 : aEvent.Repeat = 0;
2803 :
2804 376 : const Atom* pChildAtom = pEventAtom->findFirstChildAtom();
2805 :
2806 1192 : while( pChildAtom && pChildAtom->seekToContent() )
2807 : {
2808 440 : switch( pChildAtom->getType() )
2809 : {
2810 : case DFF_msofbtAnimTrigger:
2811 : {
2812 : sal_Int32 nU1, nTrigger, nU3, nBegin;
2813 376 : mrStCtrl.ReadInt32( nU1 );
2814 376 : mrStCtrl.ReadInt32( nTrigger );
2815 376 : mrStCtrl.ReadInt32( nU3 );
2816 376 : mrStCtrl.ReadInt32( nBegin );
2817 :
2818 376 : switch( nTrigger )
2819 : {
2820 310 : case 0: aEvent.Trigger = EventTrigger::NONE; break;
2821 2 : case 1: aEvent.Trigger = EventTrigger::ON_BEGIN; break;
2822 0 : case 2: aEvent.Trigger = EventTrigger::ON_END; break;
2823 0 : case 3: aEvent.Trigger = EventTrigger::BEGIN_EVENT; break;
2824 0 : case 4: aEvent.Trigger = EventTrigger::END_EVENT; break;
2825 0 : case 5: aEvent.Trigger = EventTrigger::ON_CLICK; break;
2826 0 : case 6: aEvent.Trigger = EventTrigger::ON_DBL_CLICK; break;
2827 0 : case 7: aEvent.Trigger = EventTrigger::ON_MOUSE_ENTER; break;
2828 0 : case 8: aEvent.Trigger = EventTrigger::ON_MOUSE_LEAVE; break;
2829 32 : case 9: aEvent.Trigger = EventTrigger::ON_NEXT; break;
2830 32 : case 10: aEvent.Trigger = EventTrigger::ON_PREV; break;
2831 0 : case 11: aEvent.Trigger = EventTrigger::ON_STOP_AUDIO; break;
2832 : }
2833 :
2834 376 : if( (nBegin != 0) || (aEvent.Trigger == EventTrigger::NONE) )
2835 66 : aEvent.Offset = (nBegin == -1) ? makeAny( Timing_INDEFINITE ) : makeAny( (double)(nBegin / 1000.0) );
2836 : }
2837 376 : break;
2838 : case DFF_msofbtAnimateTargetElement:
2839 : {
2840 : sal_Int16 nSubType;
2841 64 : importTargetElementContainer( pChildAtom, aEvent.Source, nSubType );
2842 : }
2843 64 : break;
2844 : default:
2845 : {
2846 : OSL_FAIL("unknown atom inside ppt::AnimationImporter::importAnimationEvents()!");
2847 : }
2848 : }
2849 :
2850 440 : pChildAtom = pEventAtom->findNextChildAtom( pChildAtom );
2851 : }
2852 :
2853 376 : *pEvents = addToSequence( *pEvents, (aEvent.Trigger == EventTrigger::NONE) ? aEvent.Offset : makeAny( aEvent ) );
2854 : }
2855 :
2856 376 : pEventAtom = pAtom->findNextChildAtom( DFF_msofbtAnimEvent, pEventAtom );
2857 : }
2858 :
2859 624 : xNode->setBegin( aBegin );
2860 1248 : xNode->setEnd( aEnd );
2861 : // TODO: xNode->setNext( aNext );
2862 : // TODO: xNode->setPrev( aNext );
2863 :
2864 : #ifdef DBG_ANIM_LOG
2865 : if( aBegin.hasValue() )
2866 : {
2867 : dump( " begin=\"" );
2868 : dump( aBegin );
2869 : dump( "\"" );
2870 : }
2871 :
2872 : if( aEnd.hasValue() )
2873 : {
2874 : dump( " end=\"" );
2875 : dump( aEnd );
2876 : dump( "\"" );
2877 : }
2878 :
2879 : if( aNext.hasValue() )
2880 : {
2881 : dump( " next=\"" );
2882 : dump( aNext );
2883 : dump( "\"" );
2884 : }
2885 :
2886 : if( aPrev.hasValue() )
2887 : {
2888 : dump( " prev=\"" );
2889 : dump( aPrev );
2890 : dump( "\"" );
2891 : }
2892 : #endif
2893 624 : }
2894 :
2895 624 : void AnimationImporter::importAnimationActions( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
2896 : {
2897 : DBG_ASSERT( pAtom && xNode.is(), "invalid call to ppt::AnimationImporter::importAnimationActions()!");
2898 :
2899 624 : if( pAtom )
2900 : {
2901 624 : const Atom* pActionAtom = pAtom->findFirstChildAtom( DFF_msofbtAnimAction );
2902 :
2903 624 : if( pActionAtom && pActionAtom->seekToContent() )
2904 : {
2905 : sal_Int32 nConcurrent, nNextAction, nEndSync, nU4, nU5;
2906 32 : mrStCtrl.ReadInt32( nConcurrent );
2907 32 : mrStCtrl.ReadInt32( nNextAction );
2908 32 : mrStCtrl.ReadInt32( nEndSync );
2909 32 : mrStCtrl.ReadInt32( nU4 );
2910 32 : mrStCtrl.ReadInt32( nU5 );
2911 :
2912 32 : if( nEndSync == 1 )
2913 0 : xNode->setEndSync( makeAny( AnimationEndSync::ALL ) );
2914 :
2915 : #ifdef DBG_ANIM_LOG
2916 : dump( " concurrent=\"%s\"", nConcurrent == 0 ? "disabled" : (nConcurrent == 1 ? "enabled" : "unknown") );
2917 :
2918 : dump( " nextAction=\"%s\"", nNextAction == 0 ? "none" : (nNextAction == 1 ? "seek" : "unknown") );
2919 :
2920 : if( nEndSync != 0 )
2921 : {
2922 : dump( " endSync=\"%s\"", nEndSync == 1 ? "all" : "unknown" );
2923 : }
2924 :
2925 : dump( " action_4=\"%#lx\"", nU4 );
2926 : dump( " action_5=\"%#lx\"", nU5 );
2927 : #endif
2928 : }
2929 : }
2930 624 : }
2931 :
2932 372 : sal_Int32 AnimationImporter::importTargetElementContainer( const Atom* pAtom, Any& rTarget, sal_Int16& rSubType )
2933 : {
2934 372 : rSubType = ShapeAnimationSubType::AS_WHOLE;
2935 372 : sal_Int32 nRefMode = -1;
2936 :
2937 : DBG_ASSERT( pAtom && (pAtom->getType() == DFF_msofbtAnimateTargetElement), "invalid call to ppt::AnimationImporter::importTargetElementContainer()!" );
2938 372 : if( pAtom )
2939 : {
2940 372 : const Atom* pChildAtom = pAtom->findFirstChildAtom();
2941 1118 : while( pChildAtom && pChildAtom->seekToContent() )
2942 : {
2943 374 : switch( pChildAtom->getType() )
2944 : {
2945 : case DFF_msofbtAnimReference:
2946 : {
2947 : sal_Int32 nRefType,nRefId;
2948 : sal_Int32 begin,end;
2949 308 : mrStCtrl.ReadInt32( nRefMode );
2950 308 : mrStCtrl.ReadInt32( nRefType );
2951 308 : mrStCtrl.ReadInt32( nRefId );
2952 308 : mrStCtrl.ReadInt32( begin );
2953 308 : mrStCtrl.ReadInt32( end );
2954 :
2955 308 : switch( nRefType )
2956 : {
2957 : case 1: // shape
2958 : {
2959 308 : SdrObject* pSdrObject = mpPPTImport->getShapeForId( nRefId );
2960 308 : if( pSdrObject == NULL )
2961 0 : break;
2962 :
2963 308 : rTarget <<= pSdrObject->getUnoShape();
2964 :
2965 308 : switch( nRefMode )
2966 : {
2967 0 : case 6: rSubType = ShapeAnimationSubType::ONLY_BACKGROUND; break;
2968 0 : case 8: rSubType = ShapeAnimationSubType::ONLY_TEXT; break;
2969 : case 2: // one paragraph
2970 : {
2971 104 : if( ((begin == -1) && (end == -1)) || !pSdrObject->ISA( SdrTextObj ) )
2972 0 : break;
2973 :
2974 104 : SdrTextObj* pTextObj = static_cast< SdrTextObj* >( pSdrObject );
2975 :
2976 104 : const OutlinerParaObject* pOPO = pTextObj->GetOutlinerParaObject();
2977 104 : if( pOPO == NULL )
2978 0 : break;
2979 :
2980 104 : const EditTextObject& rEditTextObject = pOPO->GetTextObject();
2981 :
2982 104 : const sal_Int32 nParaCount = rEditTextObject.GetParagraphCount();
2983 :
2984 104 : sal_Int32 nPara = 0;
2985 :
2986 774 : while( (nPara < nParaCount) && (begin > 0) )
2987 : {
2988 566 : sal_Int32 nParaLength = rEditTextObject.GetText( nPara ).getLength() + 1;
2989 566 : begin -= nParaLength;
2990 566 : end -= nParaLength;
2991 566 : nPara++;
2992 : }
2993 :
2994 104 : if( nPara < nParaCount )
2995 : {
2996 104 : ParagraphTarget aParaTarget;
2997 104 : rTarget >>= aParaTarget.Shape;
2998 : /* FIXME: Paragraph should be sal_Int32 as well */
2999 104 : aParaTarget.Paragraph = static_cast<sal_Int16>(nPara);
3000 104 : rTarget = makeAny( aParaTarget );
3001 :
3002 104 : rSubType = ShapeAnimationSubType::ONLY_TEXT;
3003 104 : dump( " paragraph %d,", (sal_Int32)nPara);
3004 104 : dump( " %d characters", (sal_Int32)end );
3005 : }
3006 : }
3007 : }
3008 : }
3009 308 : break;
3010 :
3011 : case 2: // sound
3012 : {
3013 0 : OUString aSoundURL( ((ImplSdPPTImport*)mpPPTImport)->ReadSound( nRefId ) );
3014 0 : rTarget <<= aSoundURL;
3015 0 : dump( " srcRef=\"%s\"", aSoundURL );
3016 : }
3017 0 : break;
3018 : case 3: // audio object
3019 : case 4: // video object
3020 : {
3021 0 : SdrObject* pSdrObject = mpPPTImport->getShapeForId( nRefId );
3022 0 : if( pSdrObject == NULL )
3023 0 : break;
3024 :
3025 0 : rTarget <<= pSdrObject->getUnoShape();
3026 : }
3027 0 : break;
3028 : default:
3029 : OSL_FAIL("unknown reference type");
3030 : }
3031 :
3032 : }
3033 308 : break;
3034 : case 0x2b01:
3035 : {
3036 : sal_Int32 nU1;
3037 62 : mrStCtrl.ReadInt32( nU1 );
3038 : }
3039 62 : break;
3040 : default:
3041 : OSL_FAIL("unknown atom inside ppt::AnimationImporter::importTargetElementContainer()!");
3042 4 : break;
3043 : }
3044 :
3045 374 : pChildAtom = pAtom->findNextChildAtom( pChildAtom );
3046 :
3047 : }
3048 : }
3049 :
3050 372 : return nRefMode;
3051 : }
3052 :
3053 624 : void AnimationImporter::importPropertySetContainer( const Atom* pAtom, PropertySet& rSet )
3054 : {
3055 : DBG_ASSERT( pAtom && (pAtom->getType() == DFF_msofbtAnimPropertySet), "invalid call to ppt::AnimationImporter::importPropertySetContainer()!" );
3056 :
3057 624 : if( pAtom )
3058 : {
3059 624 : const Atom* pChildAtom = pAtom->findFirstChildAtom();
3060 1812 : while( pChildAtom )
3061 : {
3062 564 : if( pChildAtom->getType() == DFF_msofbtAnimAttributeValue )
3063 : {
3064 564 : Any aAny;
3065 564 : (void)importAttributeValue( pChildAtom, aAny );
3066 564 : rSet.maProperties[ pChildAtom->getInstance() ] = aAny;
3067 : }
3068 : else
3069 : {
3070 : OSL_FAIL("unknown atom inside ppt::AnimationImporter::importPropertySetContainer()!");
3071 : }
3072 :
3073 564 : pChildAtom = pAtom->findNextChildAtom( pChildAtom );
3074 : }
3075 : }
3076 624 : }
3077 :
3078 : #ifdef DBG_ANIM_LOG
3079 : void AnimationImporter::dump_atom_header( const Atom* pAtom, bool bOpen, bool bAppend )
3080 : {
3081 : if( pAtom )
3082 : {
3083 : const char* pTitle;
3084 :
3085 : switch( pAtom->getType() )
3086 : {
3087 : case DFF_msofbtAnimEvent: pTitle = "AnimEvent"; break;
3088 : case DFF_msofbtAnimTrigger: pTitle = "AnimTrigger"; break;
3089 : case DFF_msofbtAnimateMotion: pTitle = "AnimateMotion"; break;
3090 : case DFF_msofbtAnimPropertySet: pTitle = "AnimPropertySet"; break;
3091 : case DFF_msofbtAnimateAttributeNames: pTitle = "AnimAttributeName"; break;
3092 : case DFF_msofbtAnimAttributeValue: pTitle = "AnimAttributeValue"; break;
3093 : case DFF_msofbtAnimGroup: pTitle = "AnimGroup"; break;
3094 : case DFF_msofbtAnimNode: pTitle = "AnimNode"; break;
3095 : case DFF_msofbtAnimValue: pTitle = "AnimValue"; break;
3096 : case DFF_msofbtAnimateFilter: pTitle = "animateFilter"; break;
3097 : case DFF_msofbtAnimate: pTitle = "animate"; break;
3098 : case DFF_msofbtAnimateSet: pTitle = "set"; break;
3099 : case DFF_msofbtAnimKeyTime: pTitle = "AnimKeyTime"; break;
3100 : case DFF_msofbtAnimKeyPoints: pTitle = "AnimKeyPoints"; break;
3101 : case DFF_msofbtAnimReference: pTitle = "AnimReference"; break;
3102 : case DFF_msofbtAnimateTargetElement: pTitle = "AnimTargetElementContainer"; break;
3103 : case DFF_msofbtAnimAction: pTitle = "AnimAction"; break;
3104 : case DFF_msofbtAnimCommand: pTitle = "AnimCommand"; break;
3105 : case DFF_msofbtAnimateTarget: pTitle = "TransformationTarget"; break;
3106 : case DFF_msofbtAnimateTargetSettings: pTitle = "TransformationTargetSettings"; break;
3107 : case DFF_msofbtAnimIteration: pTitle = "iterate"; break;
3108 : case DFF_msofbtAnimateColorData: pTitle = "colorData"; break;
3109 : case DFF_msofbtAnimateScaleData: pTitle = "scaleData"; break;
3110 : case DFF_msofbtAnimateSetData: pTitle = "setData"; break;
3111 :
3112 : default:
3113 : {
3114 : static char buffer[128];
3115 : sprintf( buffer, "unknown_%#x", pAtom->getType() );
3116 : pTitle = buffer;
3117 : }
3118 : }
3119 :
3120 : if( bOpen )
3121 : {
3122 : fprintf(mpFile, "<%s", pTitle );
3123 :
3124 : fprintf(mpFile, " instance=\"%hu\"%s",
3125 : pAtom->getInstance(),
3126 : bAppend ? "" : ">\n");
3127 : }
3128 : else
3129 : {
3130 : if( bAppend )
3131 : fprintf(mpFile,"/>\n");
3132 : else
3133 : fprintf(mpFile, "</%s>\n", pTitle );
3134 : }
3135 : }
3136 : }
3137 :
3138 : void AnimationImporter::dump( sal_uInt32 nLen, bool bNewLine )
3139 : {
3140 : char * faul = "0123456789abcdef";
3141 :
3142 : sal_uInt32 i = 0;
3143 : int b = 0;
3144 : sal_Int8 nData;
3145 :
3146 : for( i = 0; i < nLen; i++ )
3147 : {
3148 : mrStCtrl >> nData;
3149 :
3150 : fprintf( mpFile, "%c%c ", faul[ (nData >> 4) & 0x0f ], faul[ nData & 0x0f ] );
3151 :
3152 : b++;
3153 : if( bNewLine && (b == 32) )
3154 : {
3155 : fprintf(mpFile,"\n");
3156 : b = 0;
3157 : }
3158 : }
3159 : if( (b != 0) && bNewLine )
3160 : fprintf(mpFile,"\n");
3161 : }
3162 :
3163 : void AnimationImporter::dump_atom( const Atom* pAtom, bool bNewLine )
3164 : {
3165 : if( pAtom )
3166 : {
3167 : if( pAtom->isContainer() )
3168 : {
3169 : const Atom* pChildAtom = pAtom->findFirstChildAtom();
3170 : while( pChildAtom )
3171 : {
3172 : if( pChildAtom->getType() == DFF_msofbtAnimAttributeValue )
3173 : {
3174 : fprintf(mpFile, "<attributeValue instance=\"%hu\"", pChildAtom->getInstance() );
3175 :
3176 : Any aValue;
3177 : if( importAttributeValue( pChildAtom, aValue ) )
3178 : {
3179 : sal_Int32 nInt;
3180 : OUString aString;
3181 : double fDouble;
3182 :
3183 : if( aValue >>= nInt )
3184 : {
3185 : fprintf(mpFile, " value=\"%ld\"", nInt );
3186 : }
3187 : else if( aValue >>= aString )
3188 : {
3189 : fprintf(mpFile, " value=\"%s\"",
3190 : OUStringToOString(aString,
3191 : RTL_TEXTENCODING_UTF8).getStr());
3192 : }
3193 : else if( aValue >>= fDouble )
3194 : {
3195 : fprintf(mpFile, " value=\"%g\"", fDouble );
3196 : }
3197 : }
3198 : else
3199 : {
3200 : if( pChildAtom->seekToContent() )
3201 : {
3202 : fprintf(mpFile, " value=\"" );
3203 : dump_atom( pChildAtom, false );
3204 : fprintf(mpFile, "\"");
3205 : }
3206 : }
3207 :
3208 : fprintf(mpFile, "/>\n" );
3209 : }
3210 : else
3211 : {
3212 : dump_atom_header( pChildAtom, true, pChildAtom->getType() == DFF_msofbtAnimAttributeValue );
3213 : dump_atom( pChildAtom );
3214 : dump_atom_header( pChildAtom, false, pChildAtom->getType() == DFF_msofbtAnimAttributeValue );
3215 : }
3216 :
3217 : pChildAtom = pAtom->findNextChildAtom(pChildAtom);
3218 : }
3219 : }
3220 : else if( pAtom->seekToContent() )
3221 : {
3222 : dump( pAtom->getLength(), bNewLine );
3223 : }
3224 : }
3225 : }
3226 :
3227 : void AnimationImporter::dump_anim_group( const Atom* pAtom, const AnimationNode& rNode, const PropertySet& rSet, bool bOpen )
3228 : {
3229 : fprintf( mpFile, bOpen ? "<" : "</" );
3230 :
3231 : switch( rNode.mnGroupType )
3232 : {
3233 : case mso_Anim_GroupType_PAR:
3234 : fprintf( mpFile, "par" );
3235 : break;
3236 : case mso_Anim_GroupType_SEQ:
3237 : fprintf( mpFile, "seq" );
3238 : break;
3239 : case mso_Anim_GroupType_NODE:
3240 : switch( rNode.mnNodeType )
3241 : {
3242 : case mso_Anim_Behaviour_FILTER:
3243 : fprintf( mpFile, "animateFilter" );
3244 : break;
3245 : case mso_Anim_Behaviour_ANIMATION:
3246 : if( pAtom->hasChildAtom( DFF_msofbtAnimateSet ) )
3247 : fprintf( mpFile, "set" );
3248 : else if( pAtom->hasChildAtom( DFF_msofbtAnimateColor ) )
3249 : fprintf( mpFile, "animateColor" );
3250 : else if( pAtom->hasChildAtom( DFF_msofbtAnimateScale ) )
3251 : fprintf( mpFile, "animateScale" );
3252 : else if( pAtom->hasChildAtom( DFF_msofbtAnimateRotation ) )
3253 : fprintf( mpFile, "animateRotation" );
3254 : else if( pAtom->hasChildAtom( DFF_msofbtAnimateMotion ) )
3255 : fprintf( mpFile, "animateMotion" );
3256 : else if( pAtom->hasChildAtom( DFF_msofbtAnimCommand ) )
3257 : fprintf( mpFile, "command" );
3258 : else
3259 : fprintf( mpFile, "animation" );
3260 : break;
3261 : default:
3262 : {
3263 : fprintf( mpFile, "unknown_node_%#lx", rNode.mnNodeType );
3264 : }
3265 : break;
3266 : }
3267 : break;
3268 : case mso_Anim_GroupType_MEDIA:
3269 : fprintf( mpFile, "media" );
3270 : break;
3271 : default:
3272 : fprintf( mpFile, "unknown_group_%#lx", rNode.mnGroupType );
3273 : break;
3274 : }
3275 :
3276 : if( bOpen )
3277 : {
3278 : dump( rNode );
3279 : dump( rSet );
3280 : }
3281 :
3282 : fprintf(mpFile,">\n");
3283 : }
3284 :
3285 : void AnimationImporter::dump( const AnimationNode& rNode )
3286 : {
3287 : // dump animation node
3288 : if( rNode.mnRestart != 0 )
3289 : {
3290 : fprintf(mpFile," restart=\"%s\"",
3291 : rNode.mnRestart == 1 ? "always" : (rNode.mnRestart == 2 ? "whenOff" : (rNode.mnRestart == 3 ? "never" : "unknown")) );
3292 : }
3293 :
3294 : if( rNode.mnFill )
3295 : {
3296 : fprintf(mpFile," fill=\"%s\"",
3297 : rNode.mnFill == 1 ? "remove" : (rNode.mnFill == 3 ? "hold" : (rNode.mnFill == 2 ? "freeze" : "unknown")) );
3298 : }
3299 :
3300 : if( rNode.mnDuration > 0 )
3301 : {
3302 : double fSeconds = rNode.mnDuration;
3303 : fSeconds /= 1000.0;
3304 : fprintf(mpFile, " dur=\"%g\"", fSeconds);
3305 : }
3306 : else if( rNode.mnDuration < 0 )
3307 : {
3308 : fprintf(mpFile, " dur=\"indefinite\"" );
3309 : }
3310 :
3311 : if( rNode.mnU1 ) fprintf(mpFile," u1=\"%#lx\"", rNode.mnU1);
3312 : if( rNode.mnU3 ) fprintf(mpFile," u3=\"%#lx\"", rNode.mnU3);
3313 : if( rNode.mnU4 ) fprintf(mpFile," u4=\"%#lx\"", rNode.mnU4);
3314 : }
3315 :
3316 : void AnimationImporter::dump( Any& rAny )
3317 : {
3318 : Sequence< Any > aSeq;
3319 : sal_Int32 nInt;
3320 : double fDouble;
3321 : OUString aString;
3322 : sal_Bool bBool;
3323 : Event aEvent;
3324 : Timing aTiming;
3325 :
3326 : if( rAny >>= aSeq )
3327 : {
3328 : const sal_Int32 nSize = aSeq.getLength();
3329 : sal_Int32 nIndex = 0;
3330 : while( nIndex < nSize )
3331 : {
3332 : dump( aSeq[nIndex++] );
3333 : if(nIndex < nSize)
3334 : fprintf( mpFile, "," );
3335 : }
3336 : }
3337 : else if( rAny >>= aString )
3338 : {
3339 : fprintf( mpFile, "%s", OUStringToOString(aString,
3340 : RTL_TEXTENCODING_UTF8).getStr() );
3341 : }
3342 : else if( rAny >>= nInt )
3343 : {
3344 : fprintf( mpFile, "%ld", nInt );
3345 : }
3346 : else if( rAny >>= bBool )
3347 : {
3348 : fprintf( mpFile, "%s", bBool ? "true" : "false" );
3349 : }
3350 : else if( rAny >>= fDouble )
3351 : {
3352 : fprintf( mpFile, "%g", fDouble );
3353 : }
3354 : else if( rAny >>= aTiming )
3355 : {
3356 : fprintf( mpFile, "%s", aTiming == (Timing_INDEFINITE) ? "indefinite" : "media" );
3357 : }
3358 : else if( rAny >>= aEvent )
3359 : {
3360 : static const char* triggers[] =
3361 : {
3362 : "none","onbegin","onend","begin",
3363 : "end","onclick","ondoubleclick","onmouseenter",
3364 : "onmouseleave","onpptnext","onpptprev","onstopaudio"
3365 : };
3366 :
3367 : if( aEvent.Trigger != EventTrigger::NONE )
3368 : {
3369 : if( aEvent.Source.hasValue() )
3370 : {
3371 : dump_target( aEvent.Source );
3372 : dump( "." );
3373 : }
3374 :
3375 : dump( triggers[ aEvent.Trigger ] );
3376 : }
3377 :
3378 : if( aEvent.Offset.hasValue() )
3379 : {
3380 : double fOffset;
3381 : if( aEvent.Offset >>= fOffset )
3382 : fprintf( mpFile, "%g", fOffset );
3383 : else
3384 : dump( "indefinite" );
3385 : }
3386 : }
3387 : }
3388 :
3389 : void AnimationImporter::dump( const PropertySet& rSet )
3390 : {
3391 : // dump property set
3392 :
3393 : map< sal_Int32, Any >::const_iterator aIter( rSet.maProperties.begin() );
3394 : const map< sal_Int32, Any >::const_iterator aEnd( rSet.maProperties.end() );
3395 : while( aIter != aEnd )
3396 : {
3397 : bool bKnown = false;
3398 :
3399 : const sal_Int32 nInstance = (*aIter).first;
3400 : Any aAny( (*aIter).second );
3401 :
3402 : switch ( nInstance )
3403 : {
3404 : case DFF_ANIM_COLORSPACE:
3405 : {
3406 : sal_Int32 nColorSpace;
3407 : if( aAny >>= nColorSpace )
3408 : {
3409 : fprintf( mpFile, " colorSpace=\"%s\"", (nColorSpace == 0) ? "rgb" : (nColorSpace == 1) ? "hsl" : "unknown" );
3410 : bKnown = true;
3411 : }
3412 : }
3413 : break;
3414 :
3415 : case DFF_ANIM_DIRECTION:
3416 : {
3417 : sal_Bool bDirection;
3418 : if( aAny >>= bDirection )
3419 : {
3420 : fprintf( mpFile, " direction=\"%s\"", bDirection ? "cclockwise" : "clockwise" );
3421 : bKnown = true;
3422 : }
3423 : else
3424 : {
3425 : sal_Int32 nMasterRel;
3426 : if( aAny >>= nMasterRel )
3427 : {
3428 : fprintf( mpFile, " direction=\"%s\"", nMasterRel == 0 ? "sameClick" : ( nMasterRel == 2 ? "nextClick" : "lastClick" ) );
3429 : bKnown = true;
3430 : }
3431 : }
3432 : }
3433 : break;
3434 :
3435 : case DFF_ANIM_OVERRIDE: // TODO
3436 : {
3437 : sal_Int32 nOverride;
3438 : if( aAny >>= nOverride )
3439 : {
3440 : fprintf( mpFile, " override=\"%s\"", (nOverride == 1) ? "childStyle" : (nOverride == 0) ? "normal" : "unknown" );
3441 : bKnown = true;
3442 : }
3443 : }
3444 : break;
3445 :
3446 : case DFF_ANIM_PATH_EDIT_MODE:
3447 : {
3448 : sal_Bool bPathEditMode;
3449 : if( aAny >>= bPathEditMode )
3450 : {
3451 : fprintf( mpFile, " pptPathEditMode=\"%s\"", bPathEditMode ? "relative" : "fixed" );
3452 : bKnown = true;
3453 : }
3454 : }
3455 : break;
3456 :
3457 : case DFF_ANIM_PRESET_ID :
3458 : {
3459 : sal_Int32 nPresetId ;
3460 : if( aAny >>= nPresetId )
3461 : {
3462 : fprintf(mpFile, " presetid=\"%ld\"", nPresetId );
3463 : bKnown = true;
3464 : }
3465 : }
3466 : break;
3467 :
3468 : case DFF_ANIM_PRESET_SUB_TYPE :
3469 : {
3470 : sal_Int32 nPointsType ;
3471 : if( aAny >>= nPointsType )
3472 : {
3473 : fprintf(mpFile, " presetSubType=\"%ld\"", nPointsType );
3474 : bKnown = true;
3475 : }
3476 : }
3477 : break;
3478 :
3479 : case DFF_ANIM_PRESET_CLASS :
3480 : {
3481 : sal_Int32 nPresetClass;
3482 : if ( aAny >>= nPresetClass )
3483 : {
3484 : const char* pMode;
3485 : switch( nPresetClass )
3486 : {
3487 : case DFF_ANIM_PRESS_CLASS_USER_DEFINED: pMode = "userdefined"; break;
3488 : case DFF_ANIM_PRESS_CLASS_ENTRANCE: pMode = "entrance"; break;
3489 : case DFF_ANIM_PRESS_CLASS_EXIT: pMode = "exit"; break;
3490 : case DFF_ANIM_PRESS_CLASS_EMPHASIS: pMode = "emphasis"; break;
3491 : case DFF_ANIM_PRESS_CLASS_MOTIONPATH: pMode = "motionpath"; break;
3492 : case DFF_ANIM_PRESS_CLASS_OLE_ACTION: pMode = "oleaction"; break;
3493 : case DFF_ANIM_PRESS_CLASS_MEDIACALL: pMode = "mediacall"; break;
3494 : default:
3495 : {
3496 : static char buffer[128];
3497 : sprintf( buffer, "%ld", nPresetClass );
3498 : pMode = buffer;
3499 : }
3500 : break;
3501 : }
3502 :
3503 : fprintf(mpFile, " class=\"%s\"", pMode);
3504 : bKnown = true;
3505 : }
3506 : }
3507 : break;
3508 :
3509 : case DFF_ANIM_NODE_TYPE :
3510 : {
3511 : sal_Int32 nNodeType;
3512 : if ( aAny >>= nNodeType )
3513 : {
3514 : const char* pNode;
3515 : switch( nNodeType )
3516 : {
3517 : case DFF_ANIM_NODE_TYPE_ON_CLICK: pNode = "onclick"; break;
3518 : case DFF_ANIM_NODE_TYPE_WITH_PREVIOUS: pNode = "withprevious"; break;
3519 : case DFF_ANIM_NODE_TYPE_AFTER_PREVIOUS: pNode = "afterprevious"; break;
3520 : case DFF_ANIM_NODE_TYPE_MAIN_SEQUENCE: pNode = "mainsequence"; break;
3521 : case DFF_ANIM_NODE_TYPE_TIMING_ROOT: pNode = "timingroot"; break;
3522 : case DFF_ANIM_NODE_TYPE_INTERACTIVE_SEQ:pNode = "interactivesequence"; break;
3523 : default :
3524 : {
3525 : static char buffer[128];
3526 : sprintf( buffer, "%ld", nNodeType );
3527 : pNode = buffer;
3528 : }
3529 : break;
3530 : }
3531 :
3532 : fprintf(mpFile, " nodeType=\"%s\"", pNode);
3533 : bKnown = true;
3534 : }
3535 : }
3536 : break;
3537 :
3538 : case DFF_ANIM_GROUP_ID:
3539 : {
3540 : sal_Int32 nGroupId;
3541 : if ( aAny >>= nGroupId )
3542 : {
3543 : fprintf( mpFile, " groupId=\"%ld\"", nGroupId );
3544 : bKnown = true;
3545 : }
3546 : }
3547 : break;
3548 :
3549 : case DFF_ANIM_ID:
3550 : {
3551 : OUString aString;
3552 : if( aAny >>= aString )
3553 : {
3554 : fprintf( mpFile, " id=\"%s\"",
3555 : OUStringToOString(aString,
3556 : RTL_TEXTENCODING_UTF8).getStr() );
3557 : bKnown = true;
3558 : }
3559 : }
3560 : break;
3561 :
3562 : case DFF_ANIM_EVENT_FILTER:
3563 : {
3564 : OUString aString;
3565 : if( aAny >>= aString )
3566 : {
3567 : fprintf( mpFile, " eventFilter=\"%s\"",
3568 : OUStringToOString(aString,
3569 : RTL_TEXTENCODING_UTF8).getStr() );
3570 : bKnown = true;
3571 : }
3572 : }
3573 : break;
3574 :
3575 : case DFF_ANIM_ENDAFTERSLIDE:
3576 : {
3577 : sal_Int32 nEndAfterSlide;
3578 : if( aAny >>= nEndAfterSlide )
3579 : {
3580 : fprintf(mpFile, " endAfterSlide=\"%ld\"", nEndAfterSlide );
3581 : bKnown = true;
3582 : }
3583 : }
3584 :
3585 : case DFF_ANIM_TIMEFILTER:
3586 : {
3587 : OUString aString;
3588 : if( aAny >>= aString )
3589 : {
3590 : fprintf( mpFile, " timeFilter=\"%s\"",
3591 : OUStringToOString(aString,
3592 : RTL_TEXTENCODING_UTF8).getStr() );
3593 : bKnown = true;
3594 : }
3595 : }
3596 : break;
3597 :
3598 : case DFF_ANIM_RUNTIMECONTEXT:
3599 : {
3600 : OUString aString;
3601 : if( aAny >>= aString )
3602 : {
3603 : fprintf( mpFile, " runtimeContext=\"%s\"",
3604 : OUStringToOString(aString,
3605 : RTL_TEXTENCODING_UTF8).getStr() );
3606 : bKnown = true;
3607 : }
3608 : }
3609 : break;
3610 :
3611 : case DFF_ANIM_VOLUME:
3612 : {
3613 : double fVolume(0.0);
3614 : if( aAny >>= fVolume )
3615 : {
3616 : fprintf( mpFile, " volume=\"%g%%\"", (double)(fVolume * 100.0) );
3617 : bKnown = true;
3618 : }
3619 : }
3620 : break;
3621 :
3622 : case DFF_ANIM_AFTEREFFECT:
3623 : {
3624 : sal_Bool bAfterEffect;
3625 : if( aAny >>= bAfterEffect )
3626 : {
3627 : fprintf( mpFile, "afterEffect=\"%s\"", bAfterEffect ? "true" : "false" );
3628 : bKnown = true;
3629 : }
3630 : }
3631 : break;
3632 :
3633 : }
3634 :
3635 : if( !bKnown )
3636 : {
3637 : fprintf( mpFile, " unknown_%lu=\"", nInstance );
3638 : dump( aAny );
3639 : fprintf( mpFile, "\"" );
3640 : }
3641 :
3642 : ++aIter;
3643 : }
3644 : }
3645 :
3646 : void AnimationImporter::dump_target( Any& rAny )
3647 : {
3648 : Any aSource, aSourceData;
3649 : Sequence< Any > aSeq;
3650 : if( rAny >>= aSeq )
3651 : {
3652 : if( aSeq.getLength() >= 1 ) aSource = aSeq[0];
3653 : if( aSeq.getLength() >= 2 ) aSourceData = aSeq[1];
3654 : }
3655 : else
3656 : {
3657 : aSource = rAny;
3658 : }
3659 :
3660 : Reference< XShape > xShape;
3661 : aSource >>= xShape;
3662 : if( xShape.is() )
3663 : {
3664 : OUString aStr( xShape->getShapeType() );
3665 : dump( aStr );
3666 :
3667 : if( aSourceData.hasValue() )
3668 : {
3669 : dump( "(" );
3670 : dump( aSourceData );
3671 : dump( ")" );
3672 : }
3673 : }
3674 : }
3675 :
3676 : void AnimationImporter::dump( const char * pText )
3677 : {
3678 : fprintf( mpFile, "%s", pText );
3679 : }
3680 :
3681 : void AnimationImporter::dump( const OUString& rString )
3682 : {
3683 : fprintf( mpFile, OUStringToOString(rString,
3684 : RTL_TEXTENCODING_UTF8).getStr() );
3685 : }
3686 :
3687 : void AnimationImporter::dump( const char * pText, sal_Int64 nInt )
3688 : {
3689 : fprintf( mpFile, pText, nInt );
3690 : }
3691 :
3692 : void AnimationImporter::dump( const char * pText, sal_Int32 nInt )
3693 : {
3694 : fprintf( mpFile, pText, nInt );
3695 : }
3696 :
3697 : void AnimationImporter::dump( const char * pText, double fDouble )
3698 : {
3699 : fprintf( mpFile, pText, fDouble );
3700 : }
3701 :
3702 : void AnimationImporter::dump( const char * pText, const char * pText2 )
3703 : {
3704 : fprintf( mpFile, pText, pText2 );
3705 : }
3706 :
3707 : void AnimationImporter::dump( const char * pText, const OUString& rString )
3708 : {
3709 : fprintf( mpFile, pText, OUStringToOString(rString,
3710 : RTL_TEXTENCODING_UTF8).getStr() );
3711 : }
3712 :
3713 : #else
3714 :
3715 0 : void AnimationImporter::dump_atom_header( const Atom* , bool , bool )
3716 : {
3717 0 : }
3718 :
3719 0 : void AnimationImporter::dump_atom( const Atom* , bool )
3720 : {
3721 0 : }
3722 :
3723 308 : void AnimationImporter::dump_target( ::com::sun::star::uno::Any& )
3724 : {
3725 308 : }
3726 :
3727 104 : void AnimationImporter::dump( ::com::sun::star::uno::Any& )
3728 : {
3729 104 : }
3730 :
3731 314 : void AnimationImporter::dump( const PropertySet& )
3732 : {
3733 314 : }
3734 :
3735 314 : void AnimationImporter::dump( const AnimationNode& )
3736 : {
3737 314 : }
3738 :
3739 2152 : void AnimationImporter::dump( const char * )
3740 : {
3741 2152 : }
3742 :
3743 416 : void AnimationImporter::dump( const char * , sal_Int32 )
3744 : {
3745 416 : }
3746 :
3747 0 : void AnimationImporter::dump( const char * , double )
3748 : {
3749 0 : }
3750 :
3751 410 : void AnimationImporter::dump( const char * , const char * )
3752 : {
3753 410 : }
3754 :
3755 310 : void AnimationImporter::dump( const char * , const OUString& )
3756 : {
3757 310 : }
3758 :
3759 : #endif
3760 :
3761 24 : } // namespace ppt;
3762 :
3763 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|