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 <xmloff/unointerfacetouniqueidentifiermapper.hxx>
21 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
22 #include <com/sun/star/lang/XServiceInfo.hpp>
23 #include <com/sun/star/lang/XInitialization.hpp>
24 #include <com/sun/star/animations/AnimationTransformType.hpp>
25 #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
26 #include <com/sun/star/presentation/AnimationEffect.hpp>
27 #include <com/sun/star/presentation/AnimationSpeed.hpp>
28 #include <com/sun/star/animations/AnimationNodeType.hpp>
29 #include <com/sun/star/animations/SequenceTimeContainer.hpp>
30 #include <com/sun/star/animations/XIterateContainer.hpp>
31 #include <com/sun/star/animations/XAnimateMotion.hpp>
32 #include <com/sun/star/animations/XAnimateColor.hpp>
33 #include <com/sun/star/animations/XAnimateTransform.hpp>
34 #include <com/sun/star/animations/XTransitionFilter.hpp>
35 #include <com/sun/star/animations/XCommand.hpp>
36 #include <com/sun/star/animations/XAudio.hpp>
37 #include <com/sun/star/animations/ValuePair.hpp>
38 #include <com/sun/star/animations/AnimationColorSpace.hpp>
39 #include <com/sun/star/presentation/EffectPresetClass.hpp>
40 #include <com/sun/star/animations/Timing.hpp>
41 #include <com/sun/star/animations/Event.hpp>
42 #include <com/sun/star/beans/XPropertySet.hpp>
43 #include <com/sun/star/xml/sax/XAttributeList.hpp>
44 #include <com/sun/star/text/XTextCursor.hpp>
45 #include <com/sun/star/text/XTextRangeCompare.hpp>
46 #include <com/sun/star/presentation/ParagraphTarget.hpp>
47 #include <com/sun/star/container/XEnumerationAccess.hpp>
48 #include <com/sun/star/animations/EventTrigger.hpp>
49 #include <com/sun/star/presentation/EffectCommands.hpp>
50 #include <com/sun/star/util/Duration.hpp>
51 #include <comphelper/processfactory.hxx>
52 #include <cppuhelper/implbase1.hxx>
54 #include <sax/tools/converter.hxx>
57 #include <xmloff/xmltypes.hxx>
58 #include "sdpropls.hxx"
59 #include <xmloff/xmltoken.hxx>
60 #include <xmloff/xmlimp.hxx>
61 #include <xmloff/xmlnmspe.hxx>
62 #include <xmloff/xmluconv.hxx>
63 #include <osl/mutex.hxx>
64 #include <osl/diagnose.h>
65 #include <xmloff/nmspmap.hxx>
66 #include <xmloff/xmlprhdl.hxx>
70 #include "animations.hxx"
71 #include "animationimport.hxx"
73 using namespace ::std
;
74 using namespace ::cppu
;
75 using namespace ::com::sun::star::beans
;
76 using namespace ::com::sun::star::animations
;
77 using namespace ::com::sun::star::presentation
;
78 using namespace ::com::sun::star::drawing
;
79 using namespace ::com::sun::star::uno
;
80 using namespace ::xmloff::token
;
82 using ::com::sun::star::xml::sax::XAttributeList
;
83 using ::com::sun::star::beans::NamedValue
;
84 using ::com::sun::star::text::XTextRange
;
85 using ::com::sun::star::text::XTextCursor
;
86 using ::com::sun::star::text::XTextRangeCompare
;
87 using ::com::sun::star::container::XEnumerationAccess
;
88 using ::com::sun::star::container::XEnumeration
;
89 using ::com::sun::star::lang::XMultiServiceFactory
;
90 using ::com::sun::star::lang::XInitialization
;
92 Sequence
< OUString
> SAL_CALL
AnimationsImport_getSupportedServiceNames() throw()
94 const OUString
aServiceName( "com.sun.star.comp.Xmloff.AnimationsImport" );
95 const Sequence
< OUString
> aSeq( &aServiceName
, 1 );
99 OUString SAL_CALL
AnimationsImport_getImplementationName() throw()
101 return OUString( "xmloff::AnimationsImport" );
107 class AnimationsImportHelperImpl
110 SvXMLImport
& mrImport
;
112 SvXMLTokenMap
* mpAnimationNodeTokenMap
;
113 SvXMLTokenMap
* mpAnimationNodeAttributeTokenMap
;
116 AnimationsImportHelperImpl( SvXMLImport
& rImport
);
117 ~AnimationsImportHelperImpl();
119 const SvXMLTokenMap
& getAnimationNodeTokenMap();
120 const SvXMLTokenMap
& getAnimationNodeAttributeTokenMap();
122 Any
convertValue( XMLTokenEnum eAttributeName
, const OUString
& rValue
);
123 Sequence
< Any
> convertValueSequence( XMLTokenEnum eAttributeName
, const OUString
& rValue
);
125 Any
convertTarget( const OUString
& rValue
);
126 static Any
convertPath( const OUString
& rValue
);
127 Any
convertTiming( const OUString
& rValue
);
128 static Sequence
< double > convertKeyTimes( const OUString
& rValue
);
129 static Sequence
< TimeFilterPair
> convertTimeFilter( const OUString
& rValue
);
131 const OUString mastrHSL
;
134 AnimationsImportHelperImpl::AnimationsImportHelperImpl( SvXMLImport
& rImport
)
135 : mrImport( rImport
),
136 mpAnimationNodeTokenMap( NULL
),
137 mpAnimationNodeAttributeTokenMap( NULL
),
142 AnimationsImportHelperImpl::~AnimationsImportHelperImpl()
144 delete mpAnimationNodeTokenMap
;
145 delete mpAnimationNodeAttributeTokenMap
;
148 const SvXMLTokenMap
& AnimationsImportHelperImpl::getAnimationNodeTokenMap()
150 if( mpAnimationNodeTokenMap
== NULL
)
152 static const SvXMLTokenMapEntry aAnimationNodeTokenMap
[] =
154 { XML_NAMESPACE_ANIMATION
, XML_PAR
, (sal_uInt16
)AnimationNodeType::PAR
},
155 { XML_NAMESPACE_ANIMATION
, XML_SEQ
, (sal_uInt16
)AnimationNodeType::SEQ
},
156 { XML_NAMESPACE_ANIMATION
, XML_ITERATE
, (sal_uInt16
)AnimationNodeType::ITERATE
},
157 { XML_NAMESPACE_ANIMATION
, XML_ANIMATE
, (sal_uInt16
)AnimationNodeType::ANIMATE
},
158 { XML_NAMESPACE_ANIMATION
, XML_SET
, (sal_uInt16
)AnimationNodeType::SET
},
159 { XML_NAMESPACE_ANIMATION
, XML_ANIMATEMOTION
, (sal_uInt16
)AnimationNodeType::ANIMATEMOTION
},
160 { XML_NAMESPACE_ANIMATION
, XML_ANIMATECOLOR
, (sal_uInt16
)AnimationNodeType::ANIMATECOLOR
},
161 { XML_NAMESPACE_ANIMATION
, XML_ANIMATETRANSFORM
, (sal_uInt16
)AnimationNodeType::ANIMATETRANSFORM
},
162 { XML_NAMESPACE_ANIMATION
, XML_TRANSITIONFILTER
, (sal_uInt16
)AnimationNodeType::TRANSITIONFILTER
},
163 { XML_NAMESPACE_ANIMATION
, XML_AUDIO
, (sal_uInt16
)AnimationNodeType::AUDIO
},
164 { XML_NAMESPACE_ANIMATION
, XML_COMMAND
, (sal_uInt16
)AnimationNodeType::COMMAND
},
168 mpAnimationNodeTokenMap
= new SvXMLTokenMap( aAnimationNodeTokenMap
);
171 return *mpAnimationNodeTokenMap
;
174 enum AnimationNodeAttributes
213 ANA_TransitionSubType
,
227 const SvXMLTokenMap
& AnimationsImportHelperImpl::getAnimationNodeAttributeTokenMap()
229 if( mpAnimationNodeAttributeTokenMap
== NULL
)
231 static const SvXMLTokenMapEntry aAnimationNodeAttributeTokenMap
[] =
233 { XML_NAMESPACE_SMIL
, XML_BEGIN
, (sal_uInt16
)ANA_Begin
},
234 { XML_NAMESPACE_SMIL
, XML_DUR
, (sal_uInt16
)ANA_Dur
},
235 { XML_NAMESPACE_SMIL
, XML_END
, (sal_uInt16
)ANA_End
},
236 { XML_NAMESPACE_SMIL
, XML_FILL
, (sal_uInt16
)ANA_Fill
},
237 { XML_NAMESPACE_SMIL
, XML_FILLDEFAULT
, (sal_uInt16
)ANA_FillDefault
},
238 { XML_NAMESPACE_SMIL
, XML_RESTART
, (sal_uInt16
)ANA_Restart
},
239 { XML_NAMESPACE_SMIL
, XML_RESTARTDEFAULT
, (sal_uInt16
)ANA_RestartDefault
},
240 { XML_NAMESPACE_SMIL
, XML_ACCELERATE
, (sal_uInt16
)ANA_Accelerate
},
241 { XML_NAMESPACE_SMIL
, XML_DECELERATE
, (sal_uInt16
)ANA_Decelerate
},
242 { XML_NAMESPACE_SMIL
, XML_AUTOREVERSE
, (sal_uInt16
)ANA_AutoReverse
},
243 { XML_NAMESPACE_SMIL
, XML_REPEATCOUNT
, (sal_uInt16
)ANA_RepeatCount
},
244 { XML_NAMESPACE_SMIL
, XML_REPEATDUR
, (sal_uInt16
)ANA_RepeatDur
},
245 { XML_NAMESPACE_SMIL
, XML_ENDSYNC
, (sal_uInt16
)ANA_EndSync
},
246 { XML_NAMESPACE_PRESENTATION
, XML_NODE_TYPE
, (sal_uInt16
)ANA_Node_Type
},
247 { XML_NAMESPACE_PRESENTATION
, XML_PRESET_ID
, (sal_uInt16
)ANA_Preset_ID
},
248 { XML_NAMESPACE_PRESENTATION
, XML_PRESET_SUB_TYPE
, (sal_uInt16
)ANA_Preset_Sub_Type
},
249 { XML_NAMESPACE_PRESENTATION
, XML_PRESET_CLASS
, (sal_uInt16
)ANA_Preset_Class
},
250 { XML_NAMESPACE_PRESENTATION
, XML_AFTER_EFFECT
, (sal_uInt16
)ANA_After_Effect
},
251 { XML_NAMESPACE_SMIL
, XML_TARGETELEMENT
, (sal_uInt16
)ANA_Target
},
252 { XML_NAMESPACE_XLINK
, XML_HREF
, (sal_uInt16
)ANA_XLink
},
253 { XML_NAMESPACE_PRESENTATION
, XML_MASTER_ELEMENT
, (sal_uInt16
)ANA_MasterElement
},
254 { XML_NAMESPACE_ANIMATION
, XML_SUB_ITEM
, (sal_uInt16
)ANA_SubItem
},
255 { XML_NAMESPACE_SMIL
, XML_ATTRIBUTENAME
, (sal_uInt16
)ANA_AttributeName
},
256 { XML_NAMESPACE_SMIL
, XML_VALUES
, (sal_uInt16
)ANA_Values
},
257 { XML_NAMESPACE_SMIL
, XML_FROM
, (sal_uInt16
)ANA_From
},
258 { XML_NAMESPACE_SMIL
, XML_BY
, (sal_uInt16
)ANA_By
},
259 { XML_NAMESPACE_SMIL
, XML_TO
, (sal_uInt16
)ANA_To
},
260 { XML_NAMESPACE_SMIL
, XML_KEYTIMES
, (sal_uInt16
)ANA_KeyTimes
},
261 { XML_NAMESPACE_SMIL
, XML_CALCMODE
, (sal_uInt16
)ANA_CalcMode
},
262 { XML_NAMESPACE_SMIL
, XML_ACCUMULATE
, (sal_uInt16
)ANA_Accumulate
},
263 { XML_NAMESPACE_PRESENTATION
, XML_ADDITIVE
, (sal_uInt16
)ANA_AdditiveMode
},
264 { XML_NAMESPACE_SMIL
, XML_ADDITIVE
, (sal_uInt16
)ANA_AdditiveMode
},
265 { XML_NAMESPACE_SMIL
, XML_KEYSPLINES
, (sal_uInt16
)ANA_KeySplines
},
266 { XML_NAMESPACE_SVG
, XML_PATH
, (sal_uInt16
)ANA_Path
},
267 { XML_NAMESPACE_ANIMATION
, XML_COLOR_INTERPOLATION
, (sal_uInt16
)ANA_ColorSpace
},
268 { XML_NAMESPACE_ANIMATION
, XML_COLOR_INTERPOLATION_DIRECTION
, (sal_uInt16
)ANA_ColorDirection
},
269 { XML_NAMESPACE_SVG
, XML_TYPE
, (sal_uInt16
)ANA_TransformType
},
270 { XML_NAMESPACE_SMIL
, XML_TYPE
, (sal_uInt16
)ANA_TransitionType
},
271 { XML_NAMESPACE_SMIL
, XML_SUBTYPE
, (sal_uInt16
)ANA_TransitionSubType
},
272 { XML_NAMESPACE_SMIL
, XML_MODE
, (sal_uInt16
)ANA_Mode
},
273 { XML_NAMESPACE_SMIL
, XML_DIRECTION
, (sal_uInt16
)ANA_Direction
},
274 { XML_NAMESPACE_SMIL
, XML_FADECOLOR
, (sal_uInt16
)ANA_FadeColor
},
275 { XML_NAMESPACE_ANIMATION
, XML_ITERATE_TYPE
, (sal_uInt16
)ANA_IterateType
},
276 { XML_NAMESPACE_ANIMATION
, XML_ITERATE_INTERVAL
, (sal_uInt16
)ANA_IterateInterval
},
277 { XML_NAMESPACE_ANIMATION
, XML_FORMULA
, (sal_uInt16
)ANA_Formula
},
278 { XML_NAMESPACE_ANIMATION
, XML_ID
, (sal_uInt16
)ANA_ANIMID
},
279 { XML_NAMESPACE_XML
, XML_ID
, (sal_uInt16
)ANA_XMLID
},
280 { XML_NAMESPACE_PRESENTATION
, XML_GROUP_ID
, (sal_uInt16
)ANA_Group_Id
},
281 { XML_NAMESPACE_ANIMATION
, XML_AUDIO_LEVEL
, (sal_uInt16
)ANA_Volume
},
282 { XML_NAMESPACE_ANIMATION
, XML_COMMAND
, (sal_uInt16
)ANA_Command
},
287 mpAnimationNodeAttributeTokenMap
= new SvXMLTokenMap( aAnimationNodeAttributeTokenMap
);
290 return *mpAnimationNodeAttributeTokenMap
;
293 static bool isDouble( const OUString
& rValue
)
295 sal_Int32 nLength
= rValue
.getLength();
296 const sal_Unicode
* pStr
= rValue
.getStr();
299 if( (*pStr
>= '0' && *pStr
<= '9') || *pStr
== '-' || *pStr
== '.' || *pStr
== '+' || *pStr
== 'e' || *pStr
== 'E' )
313 static bool isTime( const OUString
& rValue
)
315 sal_Int32 nLength
= rValue
.getLength();
316 const sal_Unicode
* pStr
;
317 for( pStr
= rValue
.getStr(); nLength
; pStr
++, nLength
-- )
319 if( !( (*pStr
>= '0' && *pStr
<= '9') || *pStr
== '-' || *pStr
== '.' || *pStr
== '+' || *pStr
== 'e' || *pStr
== 'E' ) )
323 // return true if this is a double (if someone forgot the 's' we silently ignore it)
324 // or if it's a double that ends with a 's' or 'S'
325 return (nLength
== 0) || ((*pStr
== 's' || *pStr
== 'S') && (nLength
== 1));
328 static sal_Int32
count_codes( const OUString
& rString
, sal_Unicode nCode
)
330 sal_Int32 nCount
= 0;
331 sal_Int32 fromIndex
= 0;
335 fromIndex
= rString
.indexOf( nCode
, fromIndex
);
336 if( fromIndex
== -1 )
346 Any
AnimationsImportHelperImpl::convertTarget( const OUString
& rValue
)
350 Reference
< XInterface
> xRef( mrImport
.getInterfaceToIdentifierMapper().getReference( rValue
) );
352 Reference
< XShape
> _xShape( xRef
, UNO_QUERY
);
354 return makeAny( _xShape
);
356 Reference
< XTextCursor
> xTextCursor( xRef
, UNO_QUERY
);
357 if( xTextCursor
.is() )
359 Reference
< XTextRange
> xStart( xTextCursor
->getStart() ), xRange
;
360 Reference
< XShape
> xShape( xTextCursor
->getText(), UNO_QUERY_THROW
);
361 Reference
< XTextRangeCompare
> xTextRangeCompare( xShape
, UNO_QUERY_THROW
);
363 Reference
< XEnumerationAccess
> xParaEnumAccess( xShape
, UNO_QUERY_THROW
);
364 Reference
< XEnumeration
> xEnumeration( xParaEnumAccess
->createEnumeration(), UNO_QUERY_THROW
);
365 sal_Int16 nParagraph
= 0;
367 while( xEnumeration
->hasMoreElements() )
369 xEnumeration
->nextElement() >>= xRange
;
371 // break if start of selection is prior to end of current paragraph
372 if( xRange
.is() && (xTextRangeCompare
->compareRegionEnds( xStart
, xRange
) >= 0 ) )
374 return makeAny( ParagraphTarget( xShape
, nParagraph
) );
381 catch (const RuntimeException
&)
383 OSL_FAIL( "xmloff::AnimationsImportImpl::convertTarget(), RuntimeException caught!" );
390 Any
AnimationsImportHelperImpl::convertValue( XMLTokenEnum eAttributeName
, const OUString
& rValue
)
392 sal_Int32 nCommaPos
= -1, nPos
;
393 sal_Int32 nOpenBrakets
= 0;
394 for( nPos
= 0; (nPos
< rValue
.getLength()) && (nCommaPos
== -1); nPos
++ )
396 switch( rValue
[nPos
] )
399 if( nOpenBrakets
== 0 )
418 aPair
.First
= convertValue( eAttributeName
, rValue
.copy( 0, nCommaPos
) );
419 aPair
.Second
= convertValue( eAttributeName
, rValue
.copy( nCommaPos
+1, rValue
.getLength() - nCommaPos
- 1 ) );
420 return makeAny( aPair
);
425 sal_Int32 nType
= XML_TYPE_STRING
;
427 if( rValue
.getLength() ) switch( eAttributeName
)
435 return makeAny( rValue
);
442 case XML_ROTATE
: nType
= XML_TYPE_DOUBLE
; break;
443 case XML_TEXT_ROTATION_ANGLE
:nType
= XML_TYPE_TEXT_ROTATION_ANGLE
; break;
445 case XML_STROKE_COLOR
:
447 case XML_COLOR
: nType
= XML_TYPE_COLOR
; break;
448 case XML_FILL
: nType
= XML_SD_TYPE_FILLSTYLE
; break;
449 case XML_STROKE
: nType
= XML_SD_TYPE_STROKE
; break;
450 case XML_FONT_WEIGHT
: nType
= XML_TYPE_TEXT_WEIGHT
; break;
451 case XML_FONT_STYLE
: nType
= XML_TYPE_TEXT_POSTURE
; break;
452 case XML_TEXT_UNDERLINE
: nType
= XML_TYPE_TEXT_UNDERLINE_STYLE
; break;
453 case XML_FONT_SIZE
: nType
= XML_TYPE_DOUBLE_PERCENT
; break;
454 case XML_VISIBILITY
: nType
= XML_SD_TYPE_PRESPAGE_VISIBILITY
; break;
457 if( !rValue
.isEmpty() )
462 const XMLPropertyHandler
* pHandler
= mrImport
.GetShapeImport()->GetSdPropHdlFactory()->GetPropertyHandler( nType
);
464 pHandler
->importXML( rValue
, aAny
, mrImport
.GetMM100UnitConverter() );
470 Sequence
< Any
> AnimationsImportHelperImpl::convertValueSequence( XMLTokenEnum eAttributeName
, const OUString
& rValue
)
472 Sequence
< Any
> aValues
;
474 // do we have any value at all?
475 if( !rValue
.isEmpty() )
477 sal_Int32 nElements
= count_codes( rValue
, (sal_Unicode
)';') + 1; // a non empty string has at least one value
479 // prepare the sequence
480 aValues
.realloc( nElements
);
483 Any
* pValues
= aValues
.getArray();
485 for( nIndex
= 0; nElements
&& (nIndex
>= 0); nElements
-- )
487 *pValues
++ = convertValue( eAttributeName
, rValue
.getToken( 0, ';', nIndex
) );
494 Any
AnimationsImportHelperImpl::convertTiming( const OUString
& rValue
)
498 // do we have any value at all?
499 if( !rValue
.isEmpty() )
502 sal_Int32 nElements
= count_codes( rValue
, (sal_Unicode
)';' ) + 1; // a non empty string has at least one value
506 if( IsXMLToken( rValue
, XML_MEDIA
) )
508 aAny
<<= Timing_MEDIA
;
510 else if( IsXMLToken( rValue
, XML_INDEFINITE
) )
512 aAny
<<= Timing_INDEFINITE
;
514 else if( isTime( rValue
) )
516 aAny
<<= rValue
.toDouble();
524 OUString aEventTrigger
;
526 sal_Int32 nPos
= rValue
.indexOf( (sal_Unicode
)'+' );
529 aEventTrigger
= rValue
;
533 aEventTrigger
= rValue
.copy( 0, nPos
);
536 aEvent
.Offset
<<= convertTiming( rValue
.copy( nPos
+ 1 ) );
539 nPos
= aEventTrigger
.indexOf( (sal_Unicode
)'.' );
542 aEvent
.Source
<<= mrImport
.getInterfaceToIdentifierMapper().getReference( aEventTrigger
.copy( 0, nPos
) );
543 aEventTrigger
= aEventTrigger
.copy( nPos
+ 1 );
547 if( SvXMLUnitConverter::convertEnum( nEnum
, aEventTrigger
, getAnimationsEnumMap(Animations_EnumMap_EventTrigger
) ) )
549 aEvent
.Trigger
= (sal_Int16
)nEnum
;
553 OSL_FAIL("AnimationsImportHelperImpl::convertTiming(), unknown event trigger!");
562 Sequence
< Any
> aValues( nElements
);
563 Any
* pValues
= aValues
.getArray();
564 sal_Int32 nIndex
= 0;
565 while( (nElements
--) && (nIndex
>= 0) )
566 *pValues
++ = convertTiming( rValue
.getToken( 0, ';', nIndex
) );
574 Sequence
< double > AnimationsImportHelperImpl::convertKeyTimes( const OUString
& rValue
)
576 sal_Int32 nElements
= 0;
578 if( !rValue
.isEmpty() )
579 nElements
= count_codes( rValue
, (sal_Unicode
)';' ) + 1; // a non empty string has at least one value
581 Sequence
< double > aKeyTimes( nElements
);
585 double* pValues
= aKeyTimes
.getArray();
586 sal_Int32 nIndex
= 0;
587 while( (nElements
--) && (nIndex
>= 0) )
588 *pValues
++ = rValue
.getToken( 0, ';', nIndex
).toDouble();
594 Sequence
< TimeFilterPair
> AnimationsImportHelperImpl::convertTimeFilter( const OUString
& rValue
)
596 sal_Int32 nElements
= 0;
598 if( !rValue
.isEmpty() )
599 nElements
= count_codes( rValue
, (sal_Unicode
)';' ) + 1; // a non empty string has at least one value
601 Sequence
< TimeFilterPair
> aTimeFilter( nElements
);
605 TimeFilterPair
* pValues
= aTimeFilter
.getArray();
606 sal_Int32 nIndex
= 0;
607 while( (nElements
--) && (nIndex
>= 0) )
609 const OUString
aToken( rValue
.getToken( 0, ';', nIndex
) );
611 sal_Int32 nPos
= aToken
.indexOf( ',' );
614 pValues
->Time
= aToken
.copy( 0, nPos
).toDouble();
615 pValues
->Progress
= aToken
.copy( nPos
+1, aToken
.getLength() - nPos
- 1 ).toDouble();
624 Any
AnimationsImportHelperImpl::convertPath( const OUString
& rValue
)
626 return makeAny( rValue
);
629 TYPEINIT1( AnimationNodeContext
, SvXMLImportContext
);
631 AnimationNodeContext::AnimationNodeContext(
632 const Reference
< XAnimationNode
>& xParentNode
,
633 SvXMLImport
& rImport
, sal_uInt16 nPrfx
, const OUString
& rLocalName
,
634 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
635 AnimationsImportHelperImpl
* pHelper
/* = NULL */ )
636 : SvXMLImportContext(rImport
, nPrfx
, rLocalName
),
638 mbRootContext( pHelper
== NULL
)
644 mpHelper
= new AnimationsImportHelperImpl( rImport
);
645 mxNode
= xParentNode
;
649 sal_Int16 nPresetClass
= EffectPresetClass::CUSTOM
;
651 const sal_Char
* pServiceName
= 0;
653 sal_Int16 nNodeType
= (sal_Int16
)mpHelper
->getAnimationNodeTokenMap().Get( nPrfx
, rLocalName
);
656 case AnimationNodeType::SEQ
: pServiceName
= "com.sun.star.animations.SequenceTimeContainer"; break;
657 case AnimationNodeType::ITERATE
: pServiceName
= "com.sun.star.animations.IterateContainer"; break;
658 case AnimationNodeType::ANIMATE
: pServiceName
= "com.sun.star.animations.Animate"; break;
659 case AnimationNodeType::SET
: pServiceName
= "com.sun.star.animations.AnimateSet"; break;
660 case AnimationNodeType::ANIMATEMOTION
: pServiceName
= "com.sun.star.animations.AnimateMotion"; break;
661 case AnimationNodeType::ANIMATECOLOR
: pServiceName
= "com.sun.star.animations.AnimateColor"; break;
662 case AnimationNodeType::ANIMATETRANSFORM
: pServiceName
= "com.sun.star.animations.AnimateTransform"; break;
663 case AnimationNodeType::TRANSITIONFILTER
: pServiceName
= "com.sun.star.animations.TransitionFilter"; break;
664 case AnimationNodeType::AUDIO
: pServiceName
= "com.sun.star.animations.Audio"; break;
665 case AnimationNodeType::COMMAND
: pServiceName
= "com.sun.star.animations.Command"; break;
666 case AnimationNodeType::PAR
:
668 const sal_Int16 nCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
669 sal_Int16 nAttribute
;
670 for( nAttribute
= 0; nAttribute
< nCount
; nAttribute
++ )
673 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList
->getNameByIndex( nAttribute
), &aLocalName
);
674 if( (nPrefix
== XML_NAMESPACE_PRESENTATION
) && IsXMLToken( aLocalName
, XML_PRESET_ID
) )
676 const OUString
& rValue
= xAttrList
->getValueByIndex( nAttribute
);
677 if ( rValue
== "ooo-entrance-random" )
679 nPresetClass
= EffectPresetClass::ENTRANCE
;
681 else if ( rValue
== "ooo-exit-random" )
683 nPresetClass
= EffectPresetClass::EXIT
;
686 if( nPresetClass
!= EffectPresetClass::CUSTOM
)
688 pServiceName
= "com.sun.star.comp.sd.RandomAnimationNode";
694 pServiceName
= "com.sun.star.animations.ParallelTimeContainer";
703 Reference
< XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
705 mxNode
= Reference
< XAnimationNode
>(
706 xContext
->getServiceManager()->createInstanceWithContext(OUString::createFromAscii(pServiceName
), xContext
),
709 if( nPresetClass
!= EffectPresetClass::CUSTOM
)
711 Reference
< XInitialization
> xInit( mxNode
, UNO_QUERY_THROW
);
712 const Any
aAny( makeAny( nPresetClass
) );
713 Sequence
< Any
> aArgs( &aAny
, 1 ) ;
714 xInit
->initialize( aArgs
);
717 init_node( xAttrList
);
719 Reference
< XTimeContainer
> xParentContainer( xParentNode
, UNO_QUERY_THROW
);
720 xParentContainer
->appendChild( mxNode
);
724 catch (const RuntimeException
&)
726 OSL_FAIL( "xmloff::AnimationsImportImpl::AnimationsImportImpl(), RuntimeException caught!" );
730 AnimationNodeContext::~AnimationNodeContext()
736 void AnimationNodeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& )
738 // code of StartElement is moved to init_node that is now called
739 // in c'tor before appending this node to its parent.
740 // This is needed for random nodes that need the correct target
741 // set when child nodes are appended.
744 void AnimationNodeContext::init_node( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
746 if( mxNode
.is() ) try
748 const sal_Int16 nNodeType
= mxNode
->getType();
750 // query for optional interfaces that are often used later
751 Reference
< XAnimate
> xAnimate( mxNode
, UNO_QUERY
);
752 Reference
< XCommand
> xCommand( mxNode
, UNO_QUERY
);
753 Reference
< XTransitionFilter
> xTransitionFilter( mxNode
, UNO_QUERY
);
754 Reference
< XIterateContainer
> xIter( mxNode
, UNO_QUERY
);
756 std::list
< NamedValue
> aUserData
;
757 XMLTokenEnum meAttributeName
= XML_TOKEN_INVALID
;
758 OUString aFrom
, aBy
, aTo
, aValues
;
759 bool bHaveXmlId( false );
762 const sal_Int16 nCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
764 sal_Int16 nAttribute
;
765 for( nAttribute
= 0; nAttribute
< nCount
; nAttribute
++ )
767 const OUString
& rAttrName
= xAttrList
->getNameByIndex( nAttribute
);
768 const OUString
& rValue
= xAttrList
->getValueByIndex( nAttribute
);
771 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName
, &aLocalName
);
772 switch( mpHelper
->getAnimationNodeAttributeTokenMap().Get( nPrefix
, aLocalName
) )
776 mxNode
->setBegin( mpHelper
->convertTiming( rValue
) );
781 mxNode
->setDuration( mpHelper
->convertTiming( rValue
) );
786 mxNode
->setEnd( mpHelper
->convertTiming( rValue
) );
791 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_Fill
) ) )
792 mxNode
->setFill( (sal_Int16
)nEnum
);
795 case ANA_FillDefault
:
797 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_FillDefault
) ) )
798 mxNode
->setFillDefault( (sal_Int16
)nEnum
);
803 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_Restart
) ) )
804 mxNode
->setRestart( (sal_Int16
)nEnum
);
807 case ANA_RestartDefault
:
809 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_RestartDefault
) ) )
810 mxNode
->setRestartDefault( (sal_Int16
)nEnum
);
815 if( isDouble( rValue
) )
816 mxNode
->setAcceleration( rValue
.toDouble() );
821 if( isDouble( rValue
) )
822 mxNode
->setDecelerate( rValue
.toDouble() );
825 case ANA_AutoReverse
:
828 if (::sax::Converter::convertBool( bTemp
, rValue
))
829 mxNode
->setAutoReverse( bTemp
);
832 case ANA_RepeatCount
:
834 mxNode
->setRepeatCount( mpHelper
->convertTiming( rValue
) );
839 mxNode
->setRepeatDuration( mpHelper
->convertTiming( rValue
) );
844 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_Endsync
) ) )
845 mxNode
->setEndSync( makeAny( (sal_Int16
)nEnum
) );
850 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_EffectNodeType
) ) )
851 aUserData
.push_back( NamedValue( GetXMLToken( XML_NODE_TYPE
), makeAny( (sal_Int16
)nEnum
) ) );
856 aUserData
.push_back( NamedValue( GetXMLToken( XML_PRESET_ID
), makeAny( rValue
) ) );
859 case ANA_Preset_Sub_Type
:
861 aUserData
.push_back( NamedValue( GetXMLToken( XML_PRESET_SUB_TYPE
), makeAny( rValue
) ) );
864 case ANA_Preset_Class
:
866 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_EffectPresetClass
) ) )
867 aUserData
.push_back( NamedValue( GetXMLToken( XML_PRESET_CLASS
), makeAny( (sal_Int16
)nEnum
) ) );
870 case ANA_After_Effect
:
873 if (::sax::Converter::convertBool( bTemp
, rValue
))
874 aUserData
.push_back( NamedValue( GetXMLToken( XML_AFTER_EFFECT
), makeAny( bTemp
) ) );
879 if( nNodeType
== AnimationNodeType::AUDIO
)
881 Reference
< XAudio
> xAudio( mxNode
, UNO_QUERY_THROW
);
882 xAudio
->setSource( makeAny( GetImport().GetAbsoluteReference( rValue
) ) );
887 // fall through intended!
891 Any
aTarget( mpHelper
->convertTarget( rValue
) );
895 xAnimate
->setTarget( aTarget
);
897 else if( xIter
.is() )
899 xIter
->setTarget( aTarget
);
901 else if( xCommand
.is() )
903 xCommand
->setTarget( aTarget
);
911 if( nNodeType
== AnimationNodeType::AUDIO
)
913 if( isDouble( rValue
) )
915 Reference
< XAudio
> xAudio( mxNode
, UNO_QUERY_THROW
);
916 xAudio
->setVolume( rValue
.toDouble() );
922 case ANA_MasterElement
:
924 Reference
< XAnimationNode
> xMaster( GetImport().getInterfaceToIdentifierMapper().getReference( rValue
), UNO_QUERY
);
925 aUserData
.push_back( NamedValue( GetXMLToken( XML_MASTER_ELEMENT
), makeAny( xMaster
) ) );
931 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_SubItem
) ) )
935 xAnimate
->setSubItem( (sal_Int16
)nEnum
);
937 else if( xIter
.is() )
939 xIter
->setSubItem( (sal_Int16
)nEnum
);
945 case ANA_AttributeName
:
949 OUString
aName( rValue
);
951 const struct ImplAttributeNameConversion
* p
= getAnimationAttributeNamesConversionList();
952 while( p
->mpAPIName
)
954 if( IsXMLToken( aName
, p
->meXMLToken
) )
956 aName
= OUString::createFromAscii( p
->mpAPIName
);
957 meAttributeName
= p
->meXMLToken
;
964 xAnimate
->setAttributeName( aName
);
996 xAnimate
->setKeyTimes( AnimationsImportHelperImpl::convertKeyTimes( rValue
) );
1003 xAnimate
->setFormula( rValue
);
1009 if (!bHaveXmlId
) { sXmlId
= rValue
; }
1023 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_CalcMode
) ) )
1024 xAnimate
->setCalcMode( (sal_Int16
)nEnum
);
1029 case ANA_Accumulate
:
1032 xAnimate
->setAccumulate( IsXMLToken( rValue
, XML_SUM
) );
1036 case ANA_AdditiveMode
:
1040 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_AdditiveMode
) ) )
1041 xAnimate
->setAdditive( (sal_Int16
)nEnum
);
1046 case ANA_KeySplines
:
1049 xAnimate
->setTimeFilter( AnimationsImportHelperImpl::convertTimeFilter( rValue
) );
1055 Reference
< XAnimateMotion
> xAnimateMotion( mxNode
, UNO_QUERY
);
1056 if( xAnimateMotion
.is() )
1057 xAnimateMotion
->setPath( AnimationsImportHelperImpl::convertPath( rValue
) );
1061 case ANA_ColorSpace
:
1063 Reference
< XAnimateColor
> xAnimateColor( mxNode
, UNO_QUERY
);
1064 if( xAnimateColor
.is() )
1065 xAnimateColor
->setColorInterpolation( IsXMLToken( rValue
, XML_HSL
) ? AnimationColorSpace::HSL
: AnimationColorSpace::RGB
);
1069 case ANA_ColorDirection
:
1071 Reference
< XAnimateColor
> xAnimateColor( mxNode
, UNO_QUERY
);
1072 if( xAnimateColor
.is() )
1073 xAnimateColor
->setDirection( IsXMLToken( rValue
, XML_CLOCKWISE
) );
1077 case ANA_TransformType
:
1079 Reference
< XAnimateTransform
> xTransform( mxNode
, UNO_QUERY
);
1080 if( xTransform
.is() )
1082 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_TransformType
) ) )
1084 xTransform
->setTransformType( (sal_Int16
)nEnum
);
1087 case AnimationTransformType::SCALE
: meAttributeName
= XML_SCALE
; break;
1088 case AnimationTransformType::ROTATE
: meAttributeName
= XML_ROTATE
; break;
1089 case AnimationTransformType::SKEWX
: meAttributeName
= XML_SKEWX
; break;
1090 case AnimationTransformType::SKEWY
: meAttributeName
= XML_SKEWY
; break;
1091 //case AnimationTransformType::TRANSLATE:
1093 meAttributeName
= XML_TRANSLATE
; break;
1100 case ANA_TransitionType
:
1102 if( xTransitionFilter
.is() )
1104 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_TransitionType
) ) )
1105 xTransitionFilter
->setTransition( (sal_Int16
)nEnum
);
1110 case ANA_TransitionSubType
:
1112 if( xTransitionFilter
.is() )
1114 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_TransitionSubType
) ) )
1115 xTransitionFilter
->setSubtype( (sal_Int16
)nEnum
);
1122 if( xTransitionFilter
.is() )
1123 xTransitionFilter
->setMode( IsXMLToken( rValue
, XML_IN
) );
1129 if( xTransitionFilter
.is() )
1130 xTransitionFilter
->setDirection( IsXMLToken( rValue
, XML_FORWARD
) );
1136 if( xTransitionFilter
.is() )
1138 sal_Int32
nColor(0);
1139 ::sax::Converter::convertColor(nColor
, rValue
);
1140 xTransitionFilter
->setFadeColor(nColor
);
1145 case ANA_IterateType
:
1147 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_IterateType
) ) )
1150 xIter
->setIterateType( (sal_Int16
)nEnum
);
1155 case ANA_IterateInterval
:
1159 double fInterval
= 0.0;
1160 if( rValue
.match("P") )
1162 ::com::sun::star::util::Duration aDuration
;
1163 if (::sax::Converter::convertDuration(aDuration
, rValue
))
1165 fInterval
= ((((aDuration
.Hours
* 60)
1166 + aDuration
.Minutes
) * 60) + aDuration
.Seconds
)
1167 + (aDuration
.NanoSeconds
/ 1000000000.0);
1172 fInterval
= rValue
.toDouble();
1175 xIter
->setIterateInterval( fInterval
);
1182 aUserData
.push_back( NamedValue( aLocalName
, makeAny( rValue
.toInt32() ) ) );
1188 if( xCommand
.is() && nNodeType
== AnimationNodeType::COMMAND
)
1190 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_Command
) ) )
1192 xCommand
->setCommand( (sal_Int16
)nEnum
);
1199 // push all unknown attributes within the presentation namespace as user data
1200 if( nPrefix
== XML_NAMESPACE_PRESENTATION
)
1202 aUserData
.push_back( NamedValue( aLocalName
, makeAny( rValue
) ) );
1207 if (!sXmlId
.isEmpty())
1209 Reference
< XInterface
> const xRef( mxNode
, UNO_QUERY
);
1210 GetImport().getInterfaceToIdentifierMapper().registerReference(
1214 sal_Int32 nUserDataCount
= aUserData
.size();
1215 if( nUserDataCount
)
1217 Sequence
< NamedValue
> aUnoUserData( nUserDataCount
);
1218 NamedValue
* pData
= aUnoUserData
.getArray();
1219 std::list
< NamedValue
>::iterator
aIter( aUserData
.begin() );
1220 const std::list
< NamedValue
>::iterator
aEnd( aUserData
.end() );
1221 while( aIter
!= aEnd
)
1222 *pData
++ = (*aIter
++);
1224 mxNode
->setUserData( aUnoUserData
);
1230 if( !aFrom
.isEmpty() )
1231 xAnimate
->setFrom( mpHelper
->convertValue( meAttributeName
, aFrom
) );
1233 if( !aBy
.isEmpty() )
1234 xAnimate
->setBy( mpHelper
->convertValue( meAttributeName
, aBy
) );
1236 if( !aTo
.isEmpty() )
1237 xAnimate
->setTo( mpHelper
->convertValue( meAttributeName
, aTo
) );
1239 if( !aValues
.isEmpty() )
1240 xAnimate
->setValues( mpHelper
->convertValueSequence( meAttributeName
, aValues
) );
1243 catch (const RuntimeException
&)
1245 OSL_FAIL( "xmloff::AnimationNodeContext::StartElement(), RuntimeException caught!" );
1249 SvXMLImportContext
* AnimationNodeContext::CreateChildContext( sal_uInt16 nPrefix
, const OUString
& rLocalName
,
1250 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
1253 return new AnimationNodeContext( mxNode
, GetImport(), nPrefix
, rLocalName
, xAttrList
, mpHelper
);
1255 return new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
1258 class AnimationsImport
: public SvXMLImport
, public XAnimationNodeSupplier
1261 AnimationsImport( const Reference
< XComponentContext
> & rxContext
);
1262 virtual ~AnimationsImport() throw ();
1264 SvXMLImportContext
* CreateContext(sal_uInt16 nPrefix
, const OUString
& rLocalName
, const Reference
<XAttributeList
>& xAttrList
) SAL_OVERRIDE
;
1267 virtual Any SAL_CALL
queryInterface( const Type
& aType
) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
1268 virtual void SAL_CALL
acquire() throw () SAL_OVERRIDE
;
1269 virtual void SAL_CALL
release() throw () SAL_OVERRIDE
;
1271 // XAnimationNodeSupplier
1272 Reference
< XAnimationNode
> SAL_CALL
getAnimationNode() throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
1275 Reference
< XAnimationNode
> mxRootNode
;
1278 AnimationsImport::AnimationsImport( const Reference
< XComponentContext
> & rxContext
)
1279 : SvXMLImport( rxContext
, AnimationsImport_getImplementationName(), SvXMLImportFlags::META
)
1280 //FIXME: the above "IMPORT_META" used to be a nonsensical "true", question
1281 // remainst whether this should be IMPORT_META (same numerical value as
1282 // true) or default IMPORT_ALL
1285 GetNamespaceMap().Add(
1286 GetXMLToken(XML_NP_PRESENTATION
),
1287 GetXMLToken(XML_N_PRESENTATION
),
1288 XML_NAMESPACE_PRESENTATION
);
1290 GetNamespaceMap().Add(
1291 GetXMLToken(XML_NP_SMIL
),
1292 GetXMLToken(XML_N_SMIL
),
1293 XML_NAMESPACE_SMIL
);
1295 GetNamespaceMap().Add(
1296 GetXMLToken(XML_NP_ANIMATION
),
1297 GetXMLToken(XML_N_ANIMATION
),
1298 XML_NAMESPACE_ANIMATION
);
1300 mxRootNode
= Reference
<XAnimationNode
>( SequenceTimeContainer::create(rxContext
), UNO_QUERY_THROW
);
1303 AnimationsImport::~AnimationsImport() throw ()
1308 Any SAL_CALL
AnimationsImport::queryInterface( const Type
& aType
) throw (RuntimeException
, std::exception
)
1310 if ( aType
== cppu::UnoType
<XAnimationNodeSupplier
>::get())
1312 return makeAny( Reference
<XAnimationNodeSupplier
>( this ) );
1316 return SvXMLImport::queryInterface( aType
);
1320 void SAL_CALL
AnimationsImport::acquire() throw ()
1322 SvXMLImport::acquire();
1325 void SAL_CALL
AnimationsImport::release() throw ()
1327 SvXMLImport::release();
1330 SvXMLImportContext
*AnimationsImport::CreateContext(sal_uInt16 nPrefix
, const OUString
& rLocalName
, const Reference
<XAttributeList
>& xAttrList
)
1332 SvXMLImportContext
* pContext
= 0;
1334 if( (XML_NAMESPACE_ANIMATION
== nPrefix
) && IsXMLToken( rLocalName
, XML_SEQ
) )
1336 pContext
= new AnimationNodeContext( mxRootNode
, *this, nPrefix
, rLocalName
, xAttrList
);
1340 pContext
= SvXMLImport::CreateContext(nPrefix
, rLocalName
, xAttrList
);
1346 // XAnimationNodeSupplier
1347 Reference
< XAnimationNode
> SAL_CALL
AnimationsImport::getAnimationNode() throw (RuntimeException
, std::exception
)
1352 void AnimationNodeContext::postProcessRootNode( SvXMLImport
& /*rImport*/, const Reference
< XAnimationNode
>& xRootNode
, Reference
< XPropertySet
>& xPageProps
)
1354 if( xRootNode
.is() && xPageProps
.is() ) try
1356 Reference
< XEnumerationAccess
> xEnumerationAccess( xRootNode
, UNO_QUERY_THROW
);
1357 Reference
< XEnumeration
> xEnumeration( xEnumerationAccess
->createEnumeration(), UNO_QUERY_THROW
);
1358 if( xEnumeration
->hasMoreElements() )
1360 Reference
< XAnimationNode
> xNode( xEnumeration
->nextElement(), UNO_QUERY_THROW
);
1361 if( xNode
->getType() == AnimationNodeType::PAR
)
1364 if( (xNode
->getBegin() >>= aEvent
) && (aEvent
.Trigger
== EventTrigger::BEGIN_EVENT
) )
1366 // found transition node
1367 Reference
< XEnumerationAccess
> xChildEnumerationAccess( xNode
, UNO_QUERY_THROW
);
1368 Reference
< XEnumeration
> xChildEnumeration( xChildEnumerationAccess
->createEnumeration(), UNO_QUERY_THROW
);
1369 while( xChildEnumeration
->hasMoreElements() )
1371 Reference
< XAnimationNode
> xChildNode( xChildEnumeration
->nextElement(), UNO_QUERY_THROW
);
1372 switch( xChildNode
->getType() )
1374 case AnimationNodeType::TRANSITIONFILTER
:
1376 Reference
< XTransitionFilter
> xTransFilter( xChildNode
, UNO_QUERY_THROW
);
1378 xPageProps
->setPropertyValue("TransitionType", Any( xTransFilter
->getTransition() ) );
1379 xPageProps
->setPropertyValue("TransitionSubtype", Any( xTransFilter
->getSubtype() ) );
1380 xPageProps
->setPropertyValue("TransitionDirection", Any( xTransFilter
->getDirection() ) );
1381 xPageProps
->setPropertyValue("TransitionFadeColor", Any( xTransFilter
->getFadeColor() ) );
1384 if( xTransFilter
->getDuration() >>= fDuration
)
1385 xPageProps
->setPropertyValue("TransitionDuration", Any( fDuration
) );
1390 case AnimationNodeType::COMMAND
:
1392 Reference
< XCommand
> xCommand( xChildNode
, UNO_QUERY_THROW
);
1393 if( xCommand
->getCommand() == EffectCommands::STOPAUDIO
)
1395 xPageProps
->setPropertyValue("Sound", Any(sal_True
) );
1400 case AnimationNodeType::AUDIO
:
1402 Reference
< XAudio
> xAudio( xChildNode
, UNO_QUERY_THROW
);
1404 if( (xAudio
->getSource() >>= sSoundURL
) && !sSoundURL
.isEmpty() )
1406 xPageProps
->setPropertyValue("Sound", Any(sSoundURL
) );
1409 if( (xAudio
->getRepeatCount() >>= eTiming
) && (eTiming
== Timing_INDEFINITE
) )
1410 xPageProps
->setPropertyValue("LoopSound", Any( sal_True
) );
1418 Reference
< XTimeContainer
> xRootContainer( xRootNode
, UNO_QUERY_THROW
);
1419 xRootContainer
->removeChild( xNode
);
1424 catch (const Exception
&)
1426 OSL_FAIL("xmloff::AnimationsImport::postProcessRootNode(), exception caught!");
1430 } // namespace xmloff
1432 Reference
< XInterface
> SAL_CALL
AnimationsImport_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
)
1434 return (cppu::OWeakObject
*)new xmloff::AnimationsImport( comphelper::getComponentContext(rSMgr
) );
1437 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */