1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "oox/ppt/timenodelistcontext.hxx"
22 #include "comphelper/anytostring.hxx"
23 #include "cppuhelper/exc_hlp.hxx"
24 #include <osl/diagnose.h>
25 #include <rtl/math.hxx>
27 #include <com/sun/star/animations/XTimeContainer.hpp>
28 #include <com/sun/star/animations/XAnimationNode.hpp>
29 #include <com/sun/star/animations/XAnimateColor.hpp>
30 #include <com/sun/star/animations/XAnimateSet.hpp>
31 #include <com/sun/star/animations/XAnimateTransform.hpp>
32 #include <com/sun/star/animations/AnimationTransformType.hpp>
33 #include <com/sun/star/animations/AnimationCalcMode.hpp>
34 #include <com/sun/star/animations/AnimationColorSpace.hpp>
35 #include <com/sun/star/animations/AnimationNodeType.hpp>
36 #include <com/sun/star/animations/XCommand.hpp>
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #include <com/sun/star/presentation/EffectCommands.hpp>
39 #include <com/sun/star/beans/NamedValue.hpp>
41 #include "oox/helper/attributelist.hxx"
42 #include "oox/core/xmlfilterbase.hxx"
43 #include "oox/drawingml/drawingmltypes.hxx"
44 #include "oox/drawingml/colorchoicecontext.hxx"
45 #include "oox/ppt/slidetransition.hxx"
47 #include "animvariantcontext.hxx"
48 #include "commonbehaviorcontext.hxx"
49 #include "conditioncontext.hxx"
50 #include "commontimenodecontext.hxx"
51 #include "timeanimvaluecontext.hxx"
52 #include "animationtypes.hxx"
54 using namespace ::oox::core
;
55 using namespace ::oox::drawingml
;
56 using namespace ::com::sun::star
;
57 using namespace ::com::sun::star::uno
;
58 using namespace ::com::sun::star::lang
;
59 using namespace ::com::sun::star::animations
;
60 using namespace ::com::sun::star::presentation
;
61 using namespace ::com::sun::star::xml::sax
;
62 using ::com::sun::star::beans::NamedValue
;
64 namespace oox
{ namespace ppt
{
68 AnimColor(sal_Int16 cs
, sal_Int32 o
, sal_Int32 t
, sal_Int32 th
)
69 : colorSpace( cs
), one( o
), two( t
), three( th
)
79 case AnimationColorSpace::HSL
:
80 nColor
= ( ( ( one
* 128 ) / 360 ) & 0xff ) << 16
81 | ( ( ( two
* 128 ) / 1000 ) & 0xff ) << 8
82 | ( ( ( three
* 128 ) / 1000 ) & 0xff );
84 case AnimationColorSpace::RGB
:
85 nColor
= ( ( ( one
* 128 ) / 1000 ) & 0xff ) << 16
86 | ( ( ( two
* 128 ) / 1000 ) & 0xff ) << 8
87 | ( ( ( three
* 128 ) / 1000 ) & 0xff );
103 /** CT_TLMediaNodeAudio
104 CT_TLMediaNodeVideo */
105 class MediaNodeContext
106 : public TimeNodeContext
109 MediaNodeContext( FragmentHandler2
& rParent
, sal_Int32 aElement
,
110 const Reference
< XFastAttributeList
>& xAttribs
,
111 const TimeNodePtr
& pNode
)
112 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
113 , mbIsNarration( false )
114 , mbFullScrn( false )
116 AttributeList
attribs( xAttribs
);
120 case PPT_TOKEN( audio
):
121 mbIsNarration
= attribs
.getBool( XML_isNarration
, false );
123 case PPT_TOKEN( video
):
124 mbFullScrn
= attribs
.getBool( XML_fullScrn
, false );
131 virtual void onEndElement()
133 sal_Int32 aElement
= getCurrentElement();
134 if( aElement
== PPT_TOKEN( audio
) )
136 // TODO deal with mbIsNarration
138 else if( aElement
== PPT_TOKEN( video
) )
140 // TODO deal with mbFullScrn
144 virtual ::oox::core::ContextHandlerRef
onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
146 switch ( aElementToken
)
148 case PPT_TOKEN( cBhvr
):
149 return new CommonBehaviorContext ( *this, rAttribs
.getFastAttributeList(), mpNode
);
165 class SetTimeNodeContext
166 : public TimeNodeContext
169 SetTimeNodeContext( FragmentHandler2
& rParent
, sal_Int32 aElement
,
170 const Reference
< XFastAttributeList
>& xAttribs
,
171 const TimeNodePtr
& pNode
)
172 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
177 ~SetTimeNodeContext() throw ()
179 if( maTo
.hasValue() )
182 // HACK !!! discard and refactor
184 if( maTo
>>= aString
)
186 OSL_TRACE( "Magic conversion %s", OUSTRING_TO_CSTR( aString
) );
187 maTo
= makeAny( aString
== "visible" ? sal_True
: sal_False
);
188 if( !maTo
.has
<sal_Bool
>() )
189 OSL_TRACE( "conversion failed" );
191 mpNode
->setTo( maTo
);
196 virtual ::oox::core::ContextHandlerRef
onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
198 switch ( aElementToken
)
200 case PPT_TOKEN( cBhvr
):
201 return new CommonBehaviorContext ( *this, rAttribs
.getFastAttributeList(), mpNode
);
202 case PPT_TOKEN( to
):
204 return new AnimVariantContext( *this, aElementToken
, maTo
);
215 /** CT_TLCommandBehavior
217 class CmdTimeNodeContext
218 : public TimeNodeContext
221 CmdTimeNodeContext( FragmentHandler2
& rParent
, sal_Int32 aElement
,
222 const Reference
< XFastAttributeList
>& xAttribs
,
223 const TimeNodePtr
& pNode
)
224 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
229 case PPT_TOKEN( cmd
):
230 msCommand
= xAttribs
->getOptionalValue( XML_cmd
);
231 maType
= xAttribs
->getOptionalValueToken( XML_type
, 0 );
238 ~CmdTimeNodeContext() throw ()
242 virtual void onEndElement()
244 if( isCurrentElement( PPT_TOKEN( cmd
) ) )
247 // see sd/source/filter/ppt/pptinanimations.cxx
248 // in AnimationImporter::importCommandContainer()
250 // a good chunk of this code has been copied verbatim *sigh*
251 sal_Int16 nCommand
= EffectCommands::CUSTOM
;
252 NamedValue aParamValue
;
257 aParamValue
.Name
= "Verb";
258 // TODO make sure msCommand has what we want
259 aParamValue
.Value
<<= msCommand
.toInt32();
260 nCommand
= EffectCommands::VERB
;
264 if ( msCommand
== "onstopaudio" )
266 nCommand
= EffectCommands::STOPAUDIO
;
268 else if ( msCommand
== "play" )
270 nCommand
= EffectCommands::PLAY
;
272 else if( msCommand
.equalsAscii( "playFrom" ) )
274 const OUString
aMediaTime( msCommand
.copy( 9, msCommand
.getLength() - 10 ) );
275 rtl_math_ConversionStatus eStatus
;
276 double fMediaTime
= ::rtl::math::stringToDouble( aMediaTime
, (sal_Unicode
)('.'), (sal_Unicode
)(','), &eStatus
, NULL
);
277 if( eStatus
== rtl_math_ConversionStatus_Ok
)
279 aParamValue
.Name
= "MediaTime";
280 aParamValue
.Value
<<= fMediaTime
;
282 nCommand
= EffectCommands::PLAY
;
284 else if ( msCommand
== "togglePause" )
286 nCommand
= EffectCommands::TOGGLEPAUSE
;
288 else if ( msCommand
== "stop" )
290 nCommand
= EffectCommands::STOP
;
294 mpNode
->getNodeProperties()[ NP_COMMAND
] = makeAny((sal_Int16
)nCommand
);
295 if( nCommand
== EffectCommands::CUSTOM
)
297 OSL_TRACE("OOX: CmdTimeNodeContext::endFastElement(), unknown command!");
298 aParamValue
.Name
= "UserDefined";
299 aParamValue
.Value
<<= msCommand
;
301 if( aParamValue
.Value
.hasValue() )
303 Sequence
< NamedValue
> aParamSeq( &aParamValue
, 1 );
304 mpNode
->getNodeProperties()[ NP_PARAMETER
] = makeAny( aParamSeq
);
307 catch( RuntimeException
& )
309 OSL_TRACE( "OOX: Exception in CmdTimeNodeContext::endFastElement()" );
315 virtual ::oox::core::ContextHandlerRef
onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
317 switch ( aElementToken
)
319 case PPT_TOKEN( cBhvr
):
320 return new CommonBehaviorContext ( *this, rAttribs
.getFastAttributeList(), mpNode
);
334 /** CT_TLTimeNodeSequence
336 class SequenceTimeNodeContext
337 : public TimeNodeContext
340 SequenceTimeNodeContext( FragmentHandler2
& rParent
, sal_Int32 aElement
,
341 const Reference
< XFastAttributeList
>& xAttribs
,
342 const TimeNodePtr
& pNode
)
343 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
347 AttributeList
attribs(xAttribs
);
348 mbConcurrent
= attribs
.getBool( XML_concurrent
, false );
349 mnNextAc
= xAttribs
->getOptionalValueToken( XML_nextAc
, 0 );
350 mnPrevAc
= xAttribs
->getOptionalValueToken( XML_prevAc
, 0 );
353 ~SequenceTimeNodeContext() throw()
358 virtual ::oox::core::ContextHandlerRef
onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
360 switch ( aElementToken
)
362 case PPT_TOKEN( cTn
):
363 return new CommonTimeNodeContext( *this, aElementToken
, rAttribs
.getFastAttributeList(), mpNode
);
364 case PPT_TOKEN( nextCondLst
):
365 return new CondListContext( *this, aElementToken
, rAttribs
.getFastAttributeList(), mpNode
,
366 mpNode
->getNextCondition() );
367 case PPT_TOKEN( prevCondLst
):
368 return new CondListContext( *this, aElementToken
, rAttribs
.getFastAttributeList(), mpNode
,
369 mpNode
->getPrevCondition() );
378 sal_Int32 mnNextAc
, mnPrevAc
;
382 /** CT_TLTimeNodeParallel
383 * CT_TLTimeNodeExclusive
385 class ParallelExclTimeNodeContext
386 : public TimeNodeContext
389 ParallelExclTimeNodeContext( FragmentHandler2
& rParent
, sal_Int32 aElement
,
390 const Reference
< XFastAttributeList
>& xAttribs
,
391 const TimeNodePtr
& pNode
)
392 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
396 virtual ::oox::core::ContextHandlerRef
onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
398 switch ( aElementToken
)
400 case PPT_TOKEN( cTn
):
401 return new CommonTimeNodeContext( *this, aElementToken
, rAttribs
.getFastAttributeList(), mpNode
);
414 /** CT_TLAnimateColorBehavior */
415 class AnimColorContext
416 : public TimeNodeContext
419 AnimColorContext( FragmentHandler2
& rParent
, sal_Int32 aElement
,
420 const Reference
< XFastAttributeList
>& xAttribs
,
421 const TimeNodePtr
& pNode
) throw()
422 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
423 , mnColorSpace( xAttribs
->getOptionalValueToken( XML_clrSpc
, 0 ) )
424 , mnDir( xAttribs
->getOptionalValueToken( XML_dir
, 0 ) )
425 , mbHasByColor( false )
426 , m_byColor( AnimationColorSpace::RGB
, 0, 0, 0)
429 ~AnimColorContext() throw()
433 virtual void onEndElement()
436 if( isCurrentElement( mnElement
) )
438 NodePropertyMap
& pProps(mpNode
->getNodeProperties());
439 pProps
[ NP_DIRECTION
] = makeAny( mnDir
== XML_cw
);
440 pProps
[ NP_COLORINTERPOLATION
] = makeAny( mnColorSpace
== XML_hsl
? AnimationColorSpace::HSL
: AnimationColorSpace::RGB
);
441 const GraphicHelper
& rGraphicHelper
= getFilter().getGraphicHelper();
442 if( maToClr
.isUsed() )
443 mpNode
->setTo( Any( maToClr
.getColor( rGraphicHelper
) ) );
444 if( maFromClr
.isUsed() )
445 mpNode
->setFrom( Any( maFromClr
.getColor( rGraphicHelper
) ) );
447 mpNode
->setBy( Any ( m_byColor
.get() ) );
452 virtual ::oox::core::ContextHandlerRef
onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
454 switch ( aElementToken
)
456 case PPT_TOKEN( hsl
):
457 // CT_TLByHslColorTransform
461 m_byColor
.colorSpace
= AnimationColorSpace::HSL
;
462 m_byColor
.one
= rAttribs
.getInteger( XML_h
, 0 );
463 m_byColor
.two
= rAttribs
.getInteger( XML_s
, 0 );
464 m_byColor
.three
= rAttribs
.getInteger( XML_l
, 0 );
468 case PPT_TOKEN( rgb
):
472 // CT_TLByRgbColorTransform
473 m_byColor
.colorSpace
= AnimationColorSpace::RGB
;
474 m_byColor
.one
= rAttribs
.getInteger( XML_r
, 0 );
475 m_byColor
.two
= rAttribs
.getInteger( XML_g
, 0 );
476 m_byColor
.three
= rAttribs
.getInteger( XML_b
, 0 );
480 case PPT_TOKEN( by
):
481 // CT_TLByAnimateColorTransform
484 case PPT_TOKEN( cBhvr
):
485 return new CommonBehaviorContext ( *this, rAttribs
.getFastAttributeList(), mpNode
);
486 case PPT_TOKEN( to
):
488 return new ColorContext( *this, maToClr
);
489 case PPT_TOKEN( from
):
491 return new ColorContext( *this, maFromClr
);
502 sal_Int32 mnColorSpace
;
506 oox::drawingml::Color maToClr
;
507 oox::drawingml::Color maFromClr
;
511 /** CT_TLAnimateBehavior */
513 : public TimeNodeContext
516 AnimContext( FragmentHandler2
& rParent
, sal_Int32 aElement
,
517 const Reference
< XFastAttributeList
>& xAttribs
,
518 const TimeNodePtr
& pNode
) throw()
519 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
521 NodePropertyMap
& aProps( pNode
->getNodeProperties() );
522 sal_Int32 nCalcMode
= xAttribs
->getOptionalValueToken( XML_calcmode
, 0 );
529 nEnum
= AnimationCalcMode::DISCRETE
;
532 nEnum
= AnimationCalcMode::LINEAR
;
536 // TODO what value is good ?
537 nEnum
= AnimationCalcMode::DISCRETE
;
540 aProps
[ NP_CALCMODE
] = makeAny(nEnum
);
543 aStr
= xAttribs
->getOptionalValue( XML_from
);
544 if( !aStr
.isEmpty() )
546 pNode
->setFrom( makeAny( aStr
) );
548 aStr
= xAttribs
->getOptionalValue( XML_by
);
549 if( !aStr
.isEmpty() )
551 pNode
->setBy( makeAny( aStr
) );
553 aStr
= xAttribs
->getOptionalValue( XML_to
);
554 if( !aStr
.isEmpty() )
556 pNode
->setTo( makeAny( aStr
) );
558 mnValueType
= xAttribs
->getOptionalValueToken( XML_valueType
, 0 );
562 ~AnimContext() throw ()
564 ::std::list
< TimeAnimationValue
>::iterator iter
, end
;
565 int nKeyTimes
= maTavList
.size();
569 Sequence
< double > aKeyTimes( nKeyTimes
);
570 Sequence
< Any
> aValues( nKeyTimes
);
572 NodePropertyMap
& aProps( mpNode
->getNodeProperties() );
573 end
= maTavList
.end();
574 for(iter
= maTavList
.begin(), i
=0; iter
!= end
; ++iter
,++i
)
576 // TODO what to do if it is Timing_INFINITE ?
577 Any aTime
= GetTimeAnimateValueTime( iter
->msTime
);
578 aTime
>>= aKeyTimes
[i
];
579 aValues
[i
] = iter
->maValue
;
582 iter
->maValue
>>= aTest
;
583 if( !aTest
.isEmpty() )
585 aValues
[i
] = iter
->maValue
;
589 aProps
[ NP_FORMULA
] <<= iter
->msFormula
;
592 aProps
[ NP_VALUES
] <<= aValues
;
593 aProps
[ NP_KEYTIMES
] <<= aKeyTimes
;
598 virtual ::oox::core::ContextHandlerRef
onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
600 switch ( aElementToken
)
602 case PPT_TOKEN( cBhvr
):
603 return new CommonBehaviorContext ( *this, rAttribs
.getFastAttributeList(), mpNode
);
604 case PPT_TOKEN( tavLst
):
605 return new TimeAnimValueListContext ( *this, rAttribs
.getFastAttributeList(), maTavList
);
613 sal_Int32 mnValueType
;
614 TimeAnimationValueList maTavList
;
618 /** CT_TLAnimateScaleBehavior */
619 class AnimScaleContext
620 : public TimeNodeContext
623 AnimScaleContext( FragmentHandler2
& rParent
, sal_Int32 aElement
,
624 const Reference
< XFastAttributeList
>& xAttribs
,
625 const TimeNodePtr
& pNode
) throw()
626 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
627 , mbZoomContents( false )
629 AttributeList
attribs( xAttribs
);
630 // TODO what to do with mbZoomContents
631 mbZoomContents
= attribs
.getBool( XML_zoomContents
, false );
632 pNode
->getNodeProperties()[ NP_TRANSFORMTYPE
]
633 = makeAny((sal_Int16
)AnimationTransformType::SCALE
);
636 ~AnimScaleContext( ) throw( )
640 virtual void onEndElement()
642 if( isCurrentElement( mnElement
) )
644 if( maTo
.hasValue() )
646 mpNode
->setTo( maTo
);
648 if( maBy
.hasValue() )
650 mpNode
->setBy( maBy
);
652 if( maFrom
.hasValue() )
654 mpNode
->setFrom( maFrom
);
659 virtual ::oox::core::ContextHandlerRef
onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
661 switch ( aElementToken
)
663 case PPT_TOKEN( cBhvr
):
664 return new CommonBehaviorContext ( *this, rAttribs
.getFastAttributeList(), mpNode
);
665 case PPT_TOKEN( to
):
668 awt::Point p
= GetPointPercent( rAttribs
.getFastAttributeList() );
673 case PPT_TOKEN( from
):
676 awt::Point p
= GetPointPercent( rAttribs
.getFastAttributeList() );
681 case PPT_TOKEN( by
):
684 awt::Point p
= GetPointPercent( rAttribs
.getFastAttributeList() );
703 /** CT_TLAnimateRotationBehavior */
705 : public TimeNodeContext
708 AnimRotContext( FragmentHandler2
& rParent
, sal_Int32 aElement
,
709 const Reference
< XFastAttributeList
>& xAttribs
,
710 const TimeNodePtr
& pNode
) throw()
711 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
713 AttributeList
attribs( xAttribs
);
715 pNode
->getNodeProperties()[ NP_TRANSFORMTYPE
]
716 = makeAny((sal_Int16
)AnimationTransformType::ROTATE
);
717 // TODO make sure the units are OK
718 if(attribs
.hasAttribute( XML_by
) )
720 sal_Int32 nBy
= attribs
.getInteger( XML_by
, 0 );
721 pNode
->setBy( makeAny( nBy
) );
723 if(attribs
.hasAttribute( XML_from
) )
725 sal_Int32 nFrom
= attribs
.getInteger( XML_from
, 0 );
726 pNode
->setFrom( makeAny( nFrom
) );
728 if(attribs
.hasAttribute( XML_to
) )
730 sal_Int32 nTo
= attribs
.getInteger( XML_to
, 0 );
731 pNode
->setTo( makeAny( nTo
) );
735 ~AnimRotContext( ) throw( )
739 virtual ::oox::core::ContextHandlerRef
onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
741 switch ( aElementToken
)
743 case PPT_TOKEN( cBhvr
):
744 return new CommonBehaviorContext ( *this, rAttribs
.getFastAttributeList(), mpNode
);
755 /** CT_TLAnimateMotionBehavior */
756 class AnimMotionContext
757 : public TimeNodeContext
760 AnimMotionContext( FragmentHandler2
& rParent
, sal_Int32 aElement
,
761 const Reference
< XFastAttributeList
>& xAttribs
,
762 const TimeNodePtr
& pNode
) throw()
763 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
765 pNode
->getNodeProperties()[ NP_TRANSFORMTYPE
]
766 = makeAny((sal_Int16
)AnimationTransformType::TRANSLATE
);
768 AttributeList
attribs( xAttribs
);
769 sal_Int32 nOrigin
= xAttribs
->getOptionalValueToken( XML_origin
, 0 );
781 OUString aStr
= xAttribs
->getOptionalValue( XML_path
);
782 aStr
= aStr
.replace( 'E', ' ' );
784 pNode
->getNodeProperties()[ NP_PATH
] = makeAny(aStr
);
785 mnPathEditMode
= xAttribs
->getOptionalValueToken( XML_pathEditMode
, 0 );
786 msPtsTypes
= xAttribs
->getOptionalValue( XML_ptsTypes
);
787 mnAngle
= attribs
.getInteger( XML_rAng
, 0 );
788 // TODO make sure the units are right. Likely not.
791 ~AnimMotionContext( ) throw()
796 virtual ::oox::core::ContextHandlerRef
onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
798 switch ( aElementToken
)
800 case PPT_TOKEN( cBhvr
):
801 return new CommonBehaviorContext ( *this, rAttribs
.getFastAttributeList(), mpNode
);
802 case PPT_TOKEN( to
):
805 awt::Point p
= GetPointPercent( rAttribs
.getFastAttributeList() );
809 mpNode
->setTo( rAny
);
812 case PPT_TOKEN( from
):
815 awt::Point p
= GetPointPercent( rAttribs
.getFastAttributeList() );
819 mpNode
->setFrom( rAny
);
822 case PPT_TOKEN( by
):
825 awt::Point p
= GetPointPercent( rAttribs
.getFastAttributeList() );
829 mpNode
->setBy( rAny
);
832 case PPT_TOKEN( rCtr
):
835 awt::Point p
= GetPointPercent( rAttribs
.getFastAttributeList() );
848 sal_Int32 mnPathEditMode
;
853 /** CT_TLAnimateEffectBehavior */
854 class AnimEffectContext
855 : public TimeNodeContext
858 AnimEffectContext( FragmentHandler2
& rParent
, sal_Int32 aElement
,
859 const Reference
< XFastAttributeList
>& xAttribs
,
860 const TimeNodePtr
& pNode
) throw()
861 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
863 sal_Int32 nDir
= xAttribs
->getOptionalValueToken( XML_transition
, 0 );
864 OUString sFilter
= xAttribs
->getOptionalValue( XML_filter
);
866 // OUString sPrList = xAttribs->getOptionalValue( XML_prLst );
868 if( !sFilter
.isEmpty() )
870 SlideTransition
aFilter( sFilter
);
871 aFilter
.setMode( nDir
== XML_out
? false : true );
872 pNode
->setTransitionFilter( aFilter
);
877 ~AnimEffectContext( ) throw()
882 virtual ::oox::core::ContextHandlerRef
onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
884 switch ( aElementToken
)
886 case PPT_TOKEN( cBhvr
):
887 return new CommonBehaviorContext ( *this, rAttribs
.getFastAttributeList(), mpNode
);
888 case PPT_TOKEN( progress
):
889 return new AnimVariantContext( *this, aElementToken
, maProgress
);
905 TimeNodeContext
* TimeNodeContext::makeContext(
906 FragmentHandler2
& rParent
, sal_Int32 aElement
,
907 const Reference
< XFastAttributeList
>& xAttribs
,
908 const TimeNodePtr
& pNode
)
910 TimeNodeContext
*pCtx
= NULL
;
913 case PPT_TOKEN( animClr
):
914 pCtx
= new AnimColorContext( rParent
, aElement
, xAttribs
, pNode
);
916 case PPT_TOKEN( par
):
917 pCtx
= new ParallelExclTimeNodeContext( rParent
, aElement
, xAttribs
, pNode
);
919 case PPT_TOKEN( seq
):
920 pCtx
= new SequenceTimeNodeContext( rParent
, aElement
, xAttribs
, pNode
);
922 case PPT_TOKEN( excl
):
923 pCtx
= new ParallelExclTimeNodeContext( rParent
, aElement
, xAttribs
, pNode
);
925 case PPT_TOKEN( anim
):
926 pCtx
= new AnimContext ( rParent
, aElement
, xAttribs
, pNode
);
928 case PPT_TOKEN( animEffect
):
929 pCtx
= new AnimEffectContext( rParent
, aElement
, xAttribs
, pNode
);
931 case PPT_TOKEN( animMotion
):
932 pCtx
= new AnimMotionContext( rParent
, aElement
, xAttribs
, pNode
);
934 case PPT_TOKEN( animRot
):
935 pCtx
= new AnimRotContext( rParent
, aElement
, xAttribs
, pNode
);
937 case PPT_TOKEN( animScale
):
938 pCtx
= new AnimScaleContext( rParent
, aElement
, xAttribs
, pNode
);
940 case PPT_TOKEN( cmd
):
941 pCtx
= new CmdTimeNodeContext( rParent
, aElement
, xAttribs
, pNode
);
943 case PPT_TOKEN( set
):
944 pCtx
= new SetTimeNodeContext( rParent
, aElement
, xAttribs
, pNode
);
946 case PPT_TOKEN( audio
):
947 case PPT_TOKEN( video
):
948 pCtx
= new MediaNodeContext( rParent
, aElement
, xAttribs
, pNode
);
957 TimeNodeContext::TimeNodeContext( FragmentHandler2
& rParent
, sal_Int32 aElement
,
958 const Reference
< XFastAttributeList
>& /*xAttribs*/,
959 const TimeNodePtr
& pNode
) throw()
960 : FragmentHandler2( rParent
)
961 , mnElement( aElement
)
967 TimeNodeContext::~TimeNodeContext( ) throw()
973 TimeNodeListContext::TimeNodeListContext( FragmentHandler2
& rParent
, TimeNodePtrList
& aList
)
975 : FragmentHandler2( rParent
)
981 TimeNodeListContext::~TimeNodeListContext( ) throw()
986 ::oox::core::ContextHandlerRef
TimeNodeListContext::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
990 switch( aElementToken
)
992 case PPT_TOKEN( par
):
993 nNodeType
= AnimationNodeType::PAR
;
995 case PPT_TOKEN( seq
):
996 nNodeType
= AnimationNodeType::SEQ
;
998 case PPT_TOKEN( excl
):
999 // TODO pick the right type. We choose parallel for now as
1000 // there does not seem to be an "Exclusive"
1001 nNodeType
= AnimationNodeType::PAR
;
1003 case PPT_TOKEN( anim
):
1004 nNodeType
= AnimationNodeType::ANIMATE
;
1006 case PPT_TOKEN( animClr
):
1007 nNodeType
= AnimationNodeType::ANIMATECOLOR
;
1009 case PPT_TOKEN( animEffect
):
1010 nNodeType
= AnimationNodeType::TRANSITIONFILTER
;
1012 case PPT_TOKEN( animMotion
):
1013 nNodeType
= AnimationNodeType::ANIMATEMOTION
;
1015 case PPT_TOKEN( animRot
):
1016 case PPT_TOKEN( animScale
):
1017 nNodeType
= AnimationNodeType::ANIMATETRANSFORM
;
1019 case PPT_TOKEN( cmd
):
1020 nNodeType
= AnimationNodeType::COMMAND
;
1022 case PPT_TOKEN( set
):
1023 nNodeType
= AnimationNodeType::SET
;
1025 case PPT_TOKEN( audio
):
1026 nNodeType
= AnimationNodeType::AUDIO
;
1028 case PPT_TOKEN( video
):
1029 nNodeType
= AnimationNodeType::AUDIO
;
1030 OSL_TRACE( "OOX: video requested, gave Audio instead" );
1034 nNodeType
= AnimationNodeType::CUSTOM
;
1035 OSL_TRACE( "OOX: uhandled token %x", aElementToken
);
1039 TimeNodePtr
pNode(new TimeNode(nNodeType
));
1040 maList
.push_back( pNode
);
1041 FragmentHandler2
* pContext
= TimeNodeContext::makeContext( *this, aElementToken
, rAttribs
.getFastAttributeList(), pNode
);
1043 return pContext
? pContext
: this;
1049 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */