1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: timenodelistcontext.cxx,v $
10 * $Revision: 1.4.20.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/ppt/timenodelistcontext.hxx"
33 #include "comphelper/anytostring.hxx"
34 #include "cppuhelper/exc_hlp.hxx"
35 #include <osl/diagnose.h>
36 #include <rtl/math.hxx>
38 #include <com/sun/star/animations/XTimeContainer.hpp>
39 #include <com/sun/star/animations/XAnimationNode.hpp>
40 #include <com/sun/star/animations/XAnimateColor.hpp>
41 #include <com/sun/star/animations/XAnimateSet.hpp>
42 #include <com/sun/star/animations/XAnimateTransform.hpp>
43 #include <com/sun/star/animations/AnimationTransformType.hpp>
44 #include <com/sun/star/animations/AnimationCalcMode.hpp>
45 #include <com/sun/star/animations/AnimationColorSpace.hpp>
46 #include <com/sun/star/animations/AnimationNodeType.hpp>
47 #include <com/sun/star/animations/XCommand.hpp>
48 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
49 #include <com/sun/star/presentation/EffectCommands.hpp>
50 #include <com/sun/star/beans/NamedValue.hpp>
52 #include "oox/helper/attributelist.hxx"
53 #include "oox/core/namespaces.hxx"
54 #include "oox/core/xmlfilterbase.hxx"
55 #include "oox/drawingml/drawingmltypes.hxx"
56 #include "oox/drawingml/colorchoicecontext.hxx"
57 #include "oox/ppt/slidetransition.hxx"
60 #include "animvariantcontext.hxx"
61 #include "commonbehaviorcontext.hxx"
62 #include "conditioncontext.hxx"
63 #include "commontimenodecontext.hxx"
64 #include "timeanimvaluecontext.hxx"
65 #include "animationtypes.hxx"
67 using namespace ::oox::core
;
68 using namespace ::oox::drawingml
;
69 using namespace ::com::sun::star::uno
;
70 using namespace ::com::sun::star::lang
;
71 using namespace ::com::sun::star::animations
;
72 using namespace ::com::sun::star::presentation
;
73 using namespace ::com::sun::star::xml::sax
;
74 using namespace ::com::sun::star::awt
;
75 using ::com::sun::star::beans::NamedValue
;
77 using ::rtl::OUString
;
79 namespace oox
{ namespace ppt
{
83 AnimColor(sal_Int16 cs
, sal_Int32 o
, sal_Int32 t
, sal_Int32 th
)
84 : colorSpace( cs
), one( o
), two( t
), three( th
)
94 case AnimationColorSpace::HSL
:
95 nColor
= ( ( ( one
* 128 ) / 360 ) & 0xff ) << 16
96 | ( ( ( two
* 128 ) / 1000 ) & 0xff ) << 8
97 | ( ( ( three
* 128 ) / 1000 ) & 0xff );
99 case AnimationColorSpace::RGB
:
100 nColor
= ( ( ( one
* 128 ) / 1000 ) & 0xff ) << 16
101 | ( ( ( two
* 128 ) / 1000 ) & 0xff ) << 8
102 | ( ( ( three
* 128 ) / 1000 ) & 0xff );
111 sal_Int16 colorSpace
;
118 /** CT_TLMediaNodeAudio
119 CT_TLMediaNodeVideo */
120 class MediaNodeContext
121 : public TimeNodeContext
124 MediaNodeContext( ContextHandler
& rParent
, sal_Int32 aElement
,
125 const Reference
< XFastAttributeList
>& xAttribs
,
126 const TimeNodePtr
& pNode
)
127 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
128 , mbIsNarration( false )
129 , mbFullScrn( false )
131 AttributeList
attribs( xAttribs
);
135 case NMSP_PPT
|XML_audio
:
136 mbIsNarration
= attribs
.getBool( XML_isNarration
, false );
138 case NMSP_PPT
|XML_video
:
139 mbFullScrn
= attribs
.getBool( XML_fullScrn
, false );
146 virtual void SAL_CALL
endFastElement( sal_Int32 aElement
)
147 throw ( SAXException
, RuntimeException
)
149 if( aElement
== ( NMSP_PPT
|XML_audio
) )
151 // TODO deal with mbIsNarration
153 else if( aElement
== ( NMSP_PPT
|XML_video
) )
155 // TODO deal with mbFullScrn
159 virtual Reference
< XFastContextHandler
> SAL_CALL
createFastChildContext( ::sal_Int32 aElementToken
,
160 const Reference
< XFastAttributeList
>& xAttribs
)
161 throw ( SAXException
, RuntimeException
)
163 Reference
< XFastContextHandler
> xRet
;
165 switch ( aElementToken
)
167 case NMSP_PPT
|XML_cBhvr
:
168 xRet
.set( new CommonBehaviorContext ( *this, xAttribs
, mpNode
) );
188 class SetTimeNodeContext
189 : public TimeNodeContext
192 SetTimeNodeContext( ContextHandler
& rParent
, sal_Int32 aElement
,
193 const Reference
< XFastAttributeList
>& xAttribs
,
194 const TimeNodePtr
& pNode
)
195 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
200 ~SetTimeNodeContext() throw ()
202 if( maTo
.hasValue() )
205 // HACK !!! discard and refactor
207 if( maTo
>>= aString
)
209 OSL_TRACE( "Magic conversion %s", OUSTRING_TO_CSTR( aString
) );
210 maTo
= makeAny( aString
.equalsAscii( "visible" ) ? sal_True
: sal_False
);
211 if( !maTo
.has
<sal_Bool
>() )
212 OSL_TRACE( "conversion failed" );
214 mpNode
->setTo( maTo
);
219 virtual void SAL_CALL
endFastElement( sal_Int32
/*aElement*/ )
220 throw ( SAXException
, RuntimeException
)
225 virtual Reference
< XFastContextHandler
> SAL_CALL
createFastChildContext( ::sal_Int32 aElementToken
,
226 const Reference
< XFastAttributeList
>& xAttribs
)
227 throw ( SAXException
, RuntimeException
)
229 Reference
< XFastContextHandler
> xRet
;
231 switch ( aElementToken
)
233 case NMSP_PPT
|XML_cBhvr
:
234 xRet
.set( new CommonBehaviorContext ( *this, xAttribs
, mpNode
) );
236 case NMSP_PPT
|XML_to
:
238 xRet
.set( new AnimVariantContext( *this, aElementToken
, maTo
) );
253 /** CT_TLCommandBehavior
255 class CmdTimeNodeContext
256 : public TimeNodeContext
259 CmdTimeNodeContext( ContextHandler
& rParent
, sal_Int32 aElement
,
260 const Reference
< XFastAttributeList
>& xAttribs
,
261 const TimeNodePtr
& pNode
)
262 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
267 case NMSP_PPT
|XML_cmd
:
268 msCommand
= xAttribs
->getOptionalValue( XML_cmd
);
269 maType
= xAttribs
->getOptionalValueToken( XML_type
, 0 );
276 ~CmdTimeNodeContext() throw ()
280 virtual void SAL_CALL
endFastElement( sal_Int32 aElement
)
281 throw ( SAXException
, RuntimeException
)
283 if( aElement
== ( NMSP_PPT
|XML_cmd
) )
286 // see sd/source/filter/ppt/pptinanimations.cxx
287 // in AnimationImporter::importCommandContainer()
289 // a good chunk of this code has been copied verbatim *sigh*
290 sal_Int16 nCommand
= EffectCommands::CUSTOM
;
291 NamedValue aParamValue
;
296 aParamValue
.Name
= OUString(RTL_CONSTASCII_USTRINGPARAM("Verb"));
297 // TODO make sure msCommand has what we want
298 aParamValue
.Value
<<= msCommand
.toInt32();
299 nCommand
= EffectCommands::VERB
;
303 if( msCommand
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "onstopaudio" ) ) )
305 nCommand
= EffectCommands::STOPAUDIO
;
307 else if( msCommand
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("play") ) )
309 nCommand
= EffectCommands::PLAY
;
311 else if( msCommand
.compareToAscii( RTL_CONSTASCII_STRINGPARAM("playFrom") ) == 0 )
313 const OUString
aMediaTime( msCommand
.copy( 9, msCommand
.getLength() - 10 ) );
314 rtl_math_ConversionStatus eStatus
;
315 double fMediaTime
= ::rtl::math::stringToDouble( aMediaTime
, (sal_Unicode
)('.'), (sal_Unicode
)(','), &eStatus
, NULL
);
316 if( eStatus
== rtl_math_ConversionStatus_Ok
)
318 aParamValue
.Name
= CREATE_OUSTRING("MediaTime");
319 aParamValue
.Value
<<= fMediaTime
;
321 nCommand
= EffectCommands::PLAY
;
323 else if( msCommand
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("togglePause") ) )
325 nCommand
= EffectCommands::TOGGLEPAUSE
;
327 else if( msCommand
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("stop") ) )
329 nCommand
= EffectCommands::STOP
;
333 mpNode
->getNodeProperties()[ NP_COMMAND
] = makeAny((sal_Int16
)nCommand
);
334 if( nCommand
== EffectCommands::CUSTOM
)
336 OSL_TRACE("OOX: CmdTimeNodeContext::endFastElement(), unknown command!");
337 aParamValue
.Name
= CREATE_OUSTRING("UserDefined");
338 aParamValue
.Value
<<= msCommand
;
340 if( aParamValue
.Value
.hasValue() )
342 Sequence
< NamedValue
> aParamSeq( &aParamValue
, 1 );
343 mpNode
->getNodeProperties()[ NP_PARAMETER
] = makeAny( aParamSeq
);
346 catch( RuntimeException
& )
348 OSL_TRACE( "OOX: Exception in CmdTimeNodeContext::endFastElement()" );
354 virtual Reference
< XFastContextHandler
> SAL_CALL
createFastChildContext( ::sal_Int32 aElementToken
,
355 const Reference
< XFastAttributeList
>& xAttribs
)
356 throw ( SAXException
, RuntimeException
)
358 Reference
< XFastContextHandler
> xRet
;
360 switch ( aElementToken
)
362 case NMSP_PPT
|XML_cBhvr
:
363 xRet
.set( new CommonBehaviorContext ( *this, xAttribs
, mpNode
) );
381 /** CT_TLTimeNodeSequence
383 class SequenceTimeNodeContext
384 : public TimeNodeContext
387 SequenceTimeNodeContext( ContextHandler
& rParent
, sal_Int32 aElement
,
388 const Reference
< XFastAttributeList
>& xAttribs
,
389 const TimeNodePtr
& pNode
)
390 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
394 AttributeList
attribs(xAttribs
);
395 mbConcurrent
= attribs
.getBool( XML_concurrent
, false );
396 // ST_TLNextActionType { none, seek }
397 mnNextAc
= xAttribs
->getOptionalValueToken( XML_nextAc
, 0 );
398 // ST_TLPreviousActionType { none, skipTimed }
399 mnPrevAc
= xAttribs
->getOptionalValueToken( XML_prevAc
, 0 );
402 ~SequenceTimeNodeContext() throw()
407 virtual Reference
< XFastContextHandler
> SAL_CALL
createFastChildContext( ::sal_Int32 aElementToken
,
408 const Reference
< XFastAttributeList
>& xAttribs
)
409 throw ( SAXException
, RuntimeException
)
411 Reference
< XFastContextHandler
> xRet
;
413 switch ( aElementToken
)
415 case NMSP_PPT
|XML_cTn
:
416 xRet
.set( new CommonTimeNodeContext( *this, aElementToken
, xAttribs
, mpNode
) );
418 case NMSP_PPT
|XML_nextCondLst
:
419 xRet
.set( new CondListContext( *this, aElementToken
, xAttribs
, mpNode
,
420 mpNode
->getNextCondition() ) );
422 case NMSP_PPT
|XML_prevCondLst
:
423 xRet
.set( new CondListContext( *this, aElementToken
, xAttribs
, mpNode
,
424 mpNode
->getPrevCondition() ) );
437 sal_Int32 mnNextAc
, mnPrevAc
;
441 /** CT_TLTimeNodeParallel
442 * CT_TLTimeNodeExclusive
444 class ParallelExclTimeNodeContext
445 : public TimeNodeContext
448 ParallelExclTimeNodeContext( ContextHandler
& rParent
, sal_Int32 aElement
,
449 const Reference
< XFastAttributeList
>& xAttribs
,
450 const TimeNodePtr
& pNode
)
451 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
455 virtual Reference
< XFastContextHandler
> SAL_CALL
createFastChildContext( ::sal_Int32 aElementToken
,
456 const Reference
< XFastAttributeList
>& xAttribs
)
457 throw ( SAXException
, RuntimeException
)
459 Reference
< XFastContextHandler
> xRet
;
461 switch ( aElementToken
)
463 case NMSP_PPT
|XML_cTn
:
464 xRet
.set( new CommonTimeNodeContext( *this, aElementToken
, xAttribs
, mpNode
) );
481 /** CT_TLAnimateColorBehavior */
482 class AnimColorContext
483 : public TimeNodeContext
486 AnimColorContext( ContextHandler
& rParent
, sal_Int32 aElement
,
487 const Reference
< XFastAttributeList
>& xAttribs
,
488 const TimeNodePtr
& pNode
) throw()
489 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
490 // ST_TLAnimateColorSpace ( XML_rgb, XML_hsl }
491 , mnColorSpace( xAttribs
->getOptionalValueToken( XML_clrSpc
, 0 ) )
492 // ST_TLAnimateColorDirection { XML_cw, XML_ccw }
493 , mnDir( xAttribs
->getOptionalValueToken( XML_dir
, 0 ) )
494 , mbHasByColor( false )
495 , m_byColor( AnimationColorSpace::RGB
, 0, 0, 0)
498 ~AnimColorContext() throw()
502 virtual void SAL_CALL
endFastElement( sal_Int32 aElement
) throw ( SAXException
, RuntimeException
)
505 if( aElement
== mnElement
)
507 NodePropertyMap
& pProps(mpNode
->getNodeProperties());
508 pProps
[ NP_DIRECTION
] = makeAny( mnDir
== XML_cw
);
509 pProps
[ NP_COLORINTERPOLATION
] = makeAny( mnColorSpace
== XML_hsl
? AnimationColorSpace::HSL
: AnimationColorSpace::RGB
);
510 if( maToClr
.isUsed() )
512 mpNode
->setTo( Any( maToClr
.getColor( getFilter() ) ) );
514 if( maFromClr
.isUsed() )
516 mpNode
->setFrom( Any( maFromClr
.getColor( getFilter() ) ) );
520 mpNode
->setBy( Any ( m_byColor
.get() ) );
527 virtual Reference
< XFastContextHandler
> SAL_CALL
createFastChildContext( ::sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw ( SAXException
, RuntimeException
)
529 Reference
< XFastContextHandler
> xRet
;
531 switch ( aElementToken
)
533 case NMSP_PPT
|XML_hsl
:
534 // CT_TLByHslColorTransform
538 m_byColor
.colorSpace
= AnimationColorSpace::HSL
;
539 m_byColor
.one
= xAttribs
->getOptionalValue( XML_h
).toInt32( );
540 m_byColor
.two
= xAttribs
->getOptionalValue( XML_s
).toInt32( );
541 m_byColor
.three
= xAttribs
->getOptionalValue( XML_l
).toInt32( );
546 case NMSP_PPT
|XML_rgb
:
550 // CT_TLByRgbColorTransform
551 m_byColor
.colorSpace
= AnimationColorSpace::RGB
;
552 m_byColor
.one
= xAttribs
->getOptionalValue( XML_r
).toInt32();
553 m_byColor
.two
= xAttribs
->getOptionalValue( XML_g
).toInt32();
554 m_byColor
.three
= xAttribs
->getOptionalValue( XML_b
).toInt32();
559 case NMSP_PPT
|XML_by
:
560 // CT_TLByAnimateColorTransform
564 case NMSP_PPT
|XML_cBhvr
:
565 xRet
.set( new CommonBehaviorContext ( *this, xAttribs
, mpNode
) );
567 case NMSP_PPT
|XML_to
:
569 xRet
.set( new ColorContext( *this, maToClr
) );
571 case NMSP_PPT
|XML_from
:
573 xRet
.set( new ColorContext( *this, maFromClr
) );
588 sal_Int32 mnColorSpace
;
592 oox::drawingml::Color maToClr
;
593 oox::drawingml::Color maFromClr
;
597 /** CT_TLAnimateBehavior */
599 : public TimeNodeContext
602 AnimContext( ContextHandler
& rParent
, sal_Int32 aElement
,
603 const Reference
< XFastAttributeList
>& xAttribs
,
604 const TimeNodePtr
& pNode
) throw()
605 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
607 NodePropertyMap
& aProps( pNode
->getNodeProperties() );
608 sal_Int32 nCalcMode
= xAttribs
->getOptionalValueToken( XML_calcmode
, 0 );
615 nEnum
= AnimationCalcMode::DISCRETE
;
618 nEnum
= AnimationCalcMode::LINEAR
;
622 // TODO what value is good ?
623 nEnum
= AnimationCalcMode::DISCRETE
;
626 aProps
[ NP_CALCMODE
] = makeAny(nEnum
);
629 aStr
= xAttribs
->getOptionalValue( XML_from
);
630 if( aStr
.getLength() )
632 pNode
->setFrom( makeAny( aStr
) );
634 aStr
= xAttribs
->getOptionalValue( XML_by
);
635 if( aStr
.getLength() )
637 pNode
->setBy( makeAny( aStr
) );
639 aStr
= xAttribs
->getOptionalValue( XML_to
);
640 if( aStr
.getLength() )
642 pNode
->setTo( makeAny( aStr
) );
644 mnValueType
= xAttribs
->getOptionalValueToken( XML_valueType
, 0 );
648 ~AnimContext() throw ()
650 ::std::list
< TimeAnimationValue
>::iterator iter
, end
;
651 int nKeyTimes
= maTavList
.size();
655 Sequence
< double > aKeyTimes( nKeyTimes
);
656 Sequence
< Any
> aValues( nKeyTimes
);
658 NodePropertyMap
& aProps( mpNode
->getNodeProperties() );
659 end
= maTavList
.end();
660 for(iter
= maTavList
.begin(), i
=0; iter
!= end
; iter
++,i
++)
662 // TODO what to do if it is Timing_INFINITE ?
663 Any aTime
= GetTimeAnimateValueTime( iter
->msTime
);
664 aTime
>>= aKeyTimes
[i
];
665 aValues
[i
] = iter
->maValue
;
668 iter
->maValue
>>= aTest
;
669 if( aTest
.getLength() != 0 )
671 aValues
[i
] = iter
->maValue
;
675 aProps
[ NP_FORMULA
] <<= iter
->msFormula
;
678 aProps
[ NP_VALUES
] <<= aValues
;
679 aProps
[ NP_KEYTIMES
] <<= aKeyTimes
;
684 virtual Reference
< XFastContextHandler
> SAL_CALL
createFastChildContext( ::sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw ( SAXException
, RuntimeException
)
686 Reference
< XFastContextHandler
> xRet
;
688 switch ( aElementToken
)
690 case NMSP_PPT
|XML_cBhvr
:
691 xRet
.set( new CommonBehaviorContext ( *this, xAttribs
, mpNode
) );
693 case NMSP_PPT
|XML_tavLst
:
694 xRet
.set( new TimeAnimValueListContext ( *this, xAttribs
, maTavList
) );
706 sal_Int32 mnValueType
;
707 TimeAnimationValueList maTavList
;
711 /** CT_TLAnimateScaleBehavior */
712 class AnimScaleContext
713 : public TimeNodeContext
716 AnimScaleContext( ContextHandler
& rParent
, sal_Int32 aElement
,
717 const Reference
< XFastAttributeList
>& xAttribs
,
718 const TimeNodePtr
& pNode
) throw()
719 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
720 , mbZoomContents( false )
722 AttributeList
attribs( xAttribs
);
723 // TODO what to do with mbZoomContents
724 mbZoomContents
= attribs
.getBool( XML_zoomContents
, false );
725 pNode
->getNodeProperties()[ NP_TRANSFORMTYPE
]
726 = makeAny((sal_Int16
)AnimationTransformType::SCALE
);
729 ~AnimScaleContext( ) throw( )
733 virtual void SAL_CALL
endFastElement( sal_Int32 aElement
) throw ( SAXException
, RuntimeException
)
735 if( aElement
== mnElement
)
737 if( maTo
.hasValue() )
739 mpNode
->setTo( maTo
);
741 if( maBy
.hasValue() )
743 mpNode
->setBy( maBy
);
745 if( maFrom
.hasValue() )
747 mpNode
->setFrom( maFrom
);
752 virtual Reference
< XFastContextHandler
> SAL_CALL
createFastChildContext( ::sal_Int32 aElementToken
,
753 const Reference
< XFastAttributeList
>& xAttribs
)
754 throw ( SAXException
, RuntimeException
)
756 Reference
< XFastContextHandler
> xRet
;
758 switch ( aElementToken
)
760 case NMSP_PPT
|XML_cBhvr
:
761 xRet
.set( new CommonBehaviorContext ( *this, xAttribs
, mpNode
) );
763 case NMSP_PPT
|XML_to
:
766 Point p
= GetPointPercent( xAttribs
);
771 case NMSP_PPT
|XML_from
:
774 Point p
= GetPointPercent( xAttribs
);
779 case NMSP_PPT
|XML_by
:
782 Point p
= GetPointPercent( xAttribs
);
804 /** CT_TLAnimateRotationBehavior */
806 : public TimeNodeContext
809 AnimRotContext( ContextHandler
& rParent
, sal_Int32 aElement
,
810 const Reference
< XFastAttributeList
>& xAttribs
,
811 const TimeNodePtr
& pNode
) throw()
812 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
814 AttributeList
attribs( xAttribs
);
816 pNode
->getNodeProperties()[ NP_TRANSFORMTYPE
]
817 = makeAny((sal_Int16
)AnimationTransformType::ROTATE
);
818 // TODO make sure the units are OK
819 if(attribs
.hasAttribute( XML_by
) )
821 sal_Int32 nBy
= attribs
.getInteger( XML_by
, 0 );
822 pNode
->setBy( makeAny( nBy
) );
824 if(attribs
.hasAttribute( XML_from
) )
826 sal_Int32 nFrom
= attribs
.getInteger( XML_from
, 0 );
827 pNode
->setFrom( makeAny( nFrom
) );
829 if(attribs
.hasAttribute( XML_to
) )
831 sal_Int32 nTo
= attribs
.getInteger( XML_to
, 0 );
832 pNode
->setTo( makeAny( nTo
) );
836 ~AnimRotContext( ) throw( )
840 virtual Reference
< XFastContextHandler
> SAL_CALL
createFastChildContext( ::sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw ( SAXException
, RuntimeException
)
842 Reference
< XFastContextHandler
> xRet
;
844 switch ( aElementToken
)
846 case NMSP_PPT
|XML_cBhvr
:
847 xRet
.set( new CommonBehaviorContext ( *this, xAttribs
, mpNode
) );
862 /** CT_TLAnimateMotionBehavior */
863 class AnimMotionContext
864 : public TimeNodeContext
867 AnimMotionContext( ContextHandler
& rParent
, sal_Int32 aElement
,
868 const Reference
< XFastAttributeList
>& xAttribs
,
869 const TimeNodePtr
& pNode
) throw()
870 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
872 pNode
->getNodeProperties()[ NP_TRANSFORMTYPE
]
873 = makeAny((sal_Int16
)AnimationTransformType::TRANSLATE
);
875 AttributeList
attribs( xAttribs
);
876 // ST_TLAnimateMotionBehaviorOrigin { parent, layour }
877 sal_Int32 nOrigin
= xAttribs
->getOptionalValueToken( XML_origin
, 0 );
889 OUString aStr
= xAttribs
->getOptionalValue( XML_path
);
890 aStr
= aStr
.replace( 'E', ' ' );
892 pNode
->getNodeProperties()[ NP_PATH
] = makeAny(aStr
);
894 // ST_TLAnimateMotionPathEditMode{ fixed, relative }
895 mnPathEditMode
= xAttribs
->getOptionalValueToken( XML_pathEditMode
, 0 );
896 msPtsTypes
= xAttribs
->getOptionalValue( XML_ptsTypes
);
897 mnAngle
= attribs
.getInteger( XML_rAng
, 0 );
898 // TODO make sure the units are right. Likely not.
901 ~AnimMotionContext( ) throw()
906 virtual Reference
< XFastContextHandler
> SAL_CALL
createFastChildContext( ::sal_Int32 aElementToken
,
907 const Reference
< XFastAttributeList
>& xAttribs
)
908 throw ( SAXException
, RuntimeException
)
910 Reference
< XFastContextHandler
> xRet
;
912 switch ( aElementToken
)
914 case NMSP_PPT
|XML_cBhvr
:
915 xRet
.set( new CommonBehaviorContext ( *this, xAttribs
, mpNode
) );
917 case NMSP_PPT
|XML_to
:
920 Point p
= GetPointPercent( xAttribs
);
924 mpNode
->setTo( rAny
);
927 case NMSP_PPT
|XML_from
:
930 Point p
= GetPointPercent( xAttribs
);
934 mpNode
->setFrom( rAny
);
937 case NMSP_PPT
|XML_by
:
940 Point p
= GetPointPercent( xAttribs
);
944 mpNode
->setBy( rAny
);
947 case NMSP_PPT
|XML_rCtr
:
950 Point p
= GetPointPercent( xAttribs
);
965 sal_Int32 mnPathEditMode
;
970 /** CT_TLAnimateEffectBehavior */
971 class AnimEffectContext
972 : public TimeNodeContext
975 AnimEffectContext( ContextHandler
& rParent
, sal_Int32 aElement
,
976 const Reference
< XFastAttributeList
>& xAttribs
,
977 const TimeNodePtr
& pNode
) throw()
978 : TimeNodeContext( rParent
, aElement
, xAttribs
, pNode
)
980 sal_Int32 nDir
= xAttribs
->getOptionalValueToken( XML_transition
, 0 );
981 OUString sFilter
= xAttribs
->getOptionalValue( XML_filter
);
983 // OUString sPrList = xAttribs->getOptionalValue( XML_prLst );
985 if( sFilter
.getLength() )
987 SlideTransition
aFilter( sFilter
);
988 aFilter
.setMode( nDir
== XML_out
? false : true );
989 pNode
->setTransitionFilter( aFilter
);
994 ~AnimEffectContext( ) throw()
999 virtual Reference
< XFastContextHandler
> SAL_CALL
createFastChildContext( ::sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw ( SAXException
, RuntimeException
)
1001 Reference
< XFastContextHandler
> xRet
;
1003 switch ( aElementToken
)
1005 case NMSP_PPT
|XML_cBhvr
:
1006 xRet
.set( new CommonBehaviorContext ( *this, xAttribs
, mpNode
) );
1008 case NMSP_PPT
|XML_progress
:
1009 xRet
.set( new AnimVariantContext( *this, aElementToken
, maProgress
) );
1029 TimeNodeContext
* TimeNodeContext::makeContext(
1030 ContextHandler
& rParent
, sal_Int32 aElement
,
1031 const Reference
< XFastAttributeList
>& xAttribs
,
1032 const TimeNodePtr
& pNode
)
1034 TimeNodeContext
*pCtx
= NULL
;
1037 case NMSP_PPT
|XML_animClr
:
1038 pCtx
= new AnimColorContext( rParent
, aElement
, xAttribs
, pNode
);
1040 case NMSP_PPT
|XML_par
:
1041 pCtx
= new ParallelExclTimeNodeContext( rParent
, aElement
, xAttribs
, pNode
);
1043 case NMSP_PPT
|XML_seq
:
1044 pCtx
= new SequenceTimeNodeContext( rParent
, aElement
, xAttribs
, pNode
);
1046 case NMSP_PPT
|XML_excl
:
1047 pCtx
= new ParallelExclTimeNodeContext( rParent
, aElement
, xAttribs
, pNode
);
1049 case NMSP_PPT
|XML_anim
:
1050 pCtx
= new AnimContext ( rParent
, aElement
, xAttribs
, pNode
);
1052 case NMSP_PPT
|XML_animEffect
:
1053 pCtx
= new AnimEffectContext( rParent
, aElement
, xAttribs
, pNode
);
1055 case NMSP_PPT
|XML_animMotion
:
1056 pCtx
= new AnimMotionContext( rParent
, aElement
, xAttribs
, pNode
);
1058 case NMSP_PPT
|XML_animRot
:
1059 pCtx
= new AnimRotContext( rParent
, aElement
, xAttribs
, pNode
);
1061 case NMSP_PPT
|XML_animScale
:
1062 pCtx
= new AnimScaleContext( rParent
, aElement
, xAttribs
, pNode
);
1064 case NMSP_PPT
|XML_cmd
:
1065 pCtx
= new CmdTimeNodeContext( rParent
, aElement
, xAttribs
, pNode
);
1067 case NMSP_PPT
|XML_set
:
1068 pCtx
= new SetTimeNodeContext( rParent
, aElement
, xAttribs
, pNode
);
1070 case NMSP_PPT
|XML_audio
:
1071 case NMSP_PPT
|XML_video
:
1072 pCtx
= new MediaNodeContext( rParent
, aElement
, xAttribs
, pNode
);
1081 TimeNodeContext::TimeNodeContext( ContextHandler
& rParent
, sal_Int32 aElement
,
1082 const Reference
< XFastAttributeList
>& /*xAttribs*/,
1083 const TimeNodePtr
& pNode
) throw()
1084 : ContextHandler( rParent
)
1085 , mnElement( aElement
)
1091 TimeNodeContext::~TimeNodeContext( ) throw()
1097 TimeNodeListContext::TimeNodeListContext( ContextHandler
& rParent
, TimeNodePtrList
& aList
)
1099 : ContextHandler( rParent
)
1105 TimeNodeListContext::~TimeNodeListContext( ) throw()
1110 Reference
< XFastContextHandler
> SAL_CALL
TimeNodeListContext::createFastChildContext( ::sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw (SAXException
, RuntimeException
)
1112 Reference
< XFastContextHandler
> xRet
;
1114 sal_Int16 nNodeType
;
1116 switch( aElementToken
)
1118 case NMSP_PPT
|XML_par
:
1119 nNodeType
= AnimationNodeType::PAR
;
1121 case NMSP_PPT
|XML_seq
:
1122 nNodeType
= AnimationNodeType::SEQ
;
1124 case NMSP_PPT
|XML_excl
:
1125 // TODO pick the right type. We choose parallel for now as
1126 // there does not seem to be an "Exclusive"
1127 nNodeType
= AnimationNodeType::PAR
;
1129 case NMSP_PPT
|XML_anim
:
1130 nNodeType
= AnimationNodeType::ANIMATE
;
1132 case NMSP_PPT
|XML_animClr
:
1133 nNodeType
= AnimationNodeType::ANIMATECOLOR
;
1135 case NMSP_PPT
|XML_animEffect
:
1136 nNodeType
= AnimationNodeType::TRANSITIONFILTER
;
1138 case NMSP_PPT
|XML_animMotion
:
1139 nNodeType
= AnimationNodeType::ANIMATEMOTION
;
1141 case NMSP_PPT
|XML_animRot
:
1142 case NMSP_PPT
|XML_animScale
:
1143 nNodeType
= AnimationNodeType::ANIMATETRANSFORM
;
1145 case NMSP_PPT
|XML_cmd
:
1146 nNodeType
= AnimationNodeType::COMMAND
;
1148 case NMSP_PPT
|XML_set
:
1149 nNodeType
= AnimationNodeType::SET
;
1151 case NMSP_PPT
|XML_audio
:
1152 nNodeType
= AnimationNodeType::AUDIO
;
1154 case NMSP_PPT
|XML_video
:
1155 nNodeType
= AnimationNodeType::AUDIO
;
1156 OSL_TRACE( "OOX: video requested, gave Audio instead" );
1160 nNodeType
= AnimationNodeType::CUSTOM
;
1161 OSL_TRACE( "OOX: uhandled token %x", aElementToken
);
1165 TimeNodePtr
pNode(new TimeNode(nNodeType
));
1166 maList
.push_back( pNode
);
1167 ContextHandler
* pContext
= TimeNodeContext::makeContext( *this, aElementToken
, xAttribs
, pNode
);
1168 xRet
.set( pContext
? pContext
: this );