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: animationimport.cxx,v $
10 * $Revision: 1.15.62.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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
34 #include <tools/debug.hxx>
35 #include <tools/time.hxx>
36 #include "unointerfacetouniqueidentifiermapper.hxx"
37 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <com/sun/star/lang/XInitialization.hpp>
39 #include <com/sun/star/animations/AnimationTransformType.hpp>
40 #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
41 #include <com/sun/star/presentation/AnimationEffect.hpp>
42 #include <com/sun/star/presentation/AnimationSpeed.hpp>
43 #include <com/sun/star/animations/AnimationNodeType.hpp>
44 #include <com/sun/star/animations/XIterateContainer.hpp>
45 #include <com/sun/star/animations/XAnimateMotion.hpp>
46 #include <com/sun/star/animations/XAnimateColor.hpp>
47 #include <com/sun/star/animations/XAnimateTransform.hpp>
48 #include <com/sun/star/animations/XTransitionFilter.hpp>
49 #include <com/sun/star/animations/XCommand.hpp>
50 #include <com/sun/star/animations/XAudio.hpp>
51 #include <com/sun/star/animations/ValuePair.hpp>
52 #include <com/sun/star/animations/AnimationColorSpace.hpp>
53 #ifndef _COM_SUN_STAR_PRESENTATION_EffectPresetClass_HPP_
54 #include <com/sun/star/presentation/EffectPresetClass.hpp>
56 #include <com/sun/star/animations/Timing.hpp>
57 #include <com/sun/star/animations/Event.hpp>
58 #include <com/sun/star/beans/XPropertySet.hpp>
59 #include <com/sun/star/xml/sax/XAttributeList.hpp>
60 #include <com/sun/star/text/XTextCursor.hpp>
61 #include <com/sun/star/text/XTextRangeCompare.hpp>
62 #ifndef _COM_SUN_STAR_PRESENTATION_ParagraphTarget_HPP_
63 #include <com/sun/star/presentation/ParagraphTarget.hpp>
65 #include <com/sun/star/container/XEnumerationAccess.hpp>
66 #include <com/sun/star/beans/XPropertySet.hpp>
67 #include <com/sun/star/animations/EventTrigger.hpp>
68 #include <com/sun/star/presentation/EffectCommands.hpp>
69 #include <comphelper/processfactory.hxx>
70 #include <cppuhelper/implbase1.hxx>
73 #include <xmloff/xmltypes.hxx>
74 #include "sdpropls.hxx"
75 #include <xmloff/xmltoken.hxx>
76 #include <xmloff/xmlimp.hxx>
77 #include "xmlnmspe.hxx"
78 #include <xmloff/xmluconv.hxx>
79 #include <osl/mutex.hxx>
80 #include <xmloff/nmspmap.hxx>
83 #include "animations.hxx"
84 #include "animationimport.hxx"
86 using ::rtl::OUString
;
87 using ::rtl::OUStringBuffer
;
89 using namespace ::std
;
90 using namespace ::cppu
;
91 using namespace ::com::sun::star::beans
;
92 using namespace ::com::sun::star::animations
;
93 using namespace ::com::sun::star::presentation
;
94 using namespace ::com::sun::star::drawing
;
95 using namespace ::xmloff::token
;
97 using ::com::sun::star::xml::sax::XAttributeList
;
98 using ::com::sun::star::uno::Any
;
99 using ::com::sun::star::uno::makeAny
;
100 using ::com::sun::star::uno::UNO_QUERY
;
101 using ::com::sun::star::uno::UNO_QUERY_THROW
;
102 using ::com::sun::star::uno::Reference
;
103 using ::com::sun::star::uno::Sequence
;
104 using ::com::sun::star::uno::RuntimeException
;
105 using ::com::sun::star::uno::Exception
;
106 using ::com::sun::star::uno::XInterface
;
107 using ::com::sun::star::uno::Type
;
108 using ::com::sun::star::beans::NamedValue
;
109 using ::com::sun::star::text::XTextRange
;
110 using ::com::sun::star::text::XTextCursor
;
111 using ::com::sun::star::text::XTextRangeCompare
;
112 using ::com::sun::star::container::XEnumerationAccess
;
113 using ::com::sun::star::container::XEnumeration
;
114 using ::com::sun::star::lang::XMultiServiceFactory
;
115 using ::com::sun::star::lang::XInitialization
;
120 ///////////////////////////////////////////////////////////////////////
124 ///////////////////////////////////////////////////////////////////////
127 ///////////////////////////////////////////////////////////////////////
129 class AnimationsImportHelperImpl
132 SvXMLImport
& mrImport
;
134 SvXMLTokenMap
* mpAnimationNodeTokenMap
;
135 SvXMLTokenMap
* mpAnimationNodeAttributeTokenMap
;
138 AnimationsImportHelperImpl( SvXMLImport
& rImport
);
139 ~AnimationsImportHelperImpl();
141 const SvXMLTokenMap
& getAnimationNodeTokenMap();
142 const SvXMLTokenMap
& getAnimationNodeAttributeTokenMap();
144 Any
convertValue( XMLTokenEnum eAttributeName
, const OUString
& rValue
);
145 Sequence
< Any
> convertValueSequence( XMLTokenEnum eAttributeName
, const OUString
& rValue
);
147 Any
convertTarget( const OUString
& rValue
);
148 Any
convertPath( const OUString
& rValue
);
149 Any
convertTiming( const OUString
& rValue
);
150 Sequence
< double > convertKeyTimes( const OUString
& rValue
);
151 Sequence
< TimeFilterPair
> convertTimeFilter( const OUString
& rValue
);
153 bool convertAnimationValue( XMLTokenEnum eAttributeName
, Any
& rValue
);
154 const OUString mastrHSL
;
157 AnimationsImportHelperImpl::AnimationsImportHelperImpl( SvXMLImport
& rImport
)
158 : mrImport( rImport
),
159 mpAnimationNodeTokenMap( NULL
),
160 mpAnimationNodeAttributeTokenMap( NULL
),
161 mastrHSL( RTL_CONSTASCII_USTRINGPARAM( "hsl" ) )
165 AnimationsImportHelperImpl::~AnimationsImportHelperImpl()
167 delete mpAnimationNodeTokenMap
;
168 delete mpAnimationNodeAttributeTokenMap
;
171 const SvXMLTokenMap
& AnimationsImportHelperImpl::getAnimationNodeTokenMap()
173 if( mpAnimationNodeTokenMap
== NULL
)
175 static __FAR_DATA SvXMLTokenMapEntry aAnimationNodeTokenMap
[] =
177 { XML_NAMESPACE_ANIMATION
, XML_PAR
, (sal_uInt16
)AnimationNodeType::PAR
},
178 { XML_NAMESPACE_ANIMATION
, XML_SEQ
, (sal_uInt16
)AnimationNodeType::SEQ
},
179 { XML_NAMESPACE_ANIMATION
, XML_ITERATE
, (sal_uInt16
)AnimationNodeType::ITERATE
},
180 { XML_NAMESPACE_ANIMATION
, XML_ANIMATE
, (sal_uInt16
)AnimationNodeType::ANIMATE
},
181 { XML_NAMESPACE_ANIMATION
, XML_SET
, (sal_uInt16
)AnimationNodeType::SET
},
182 { XML_NAMESPACE_ANIMATION
, XML_ANIMATEMOTION
, (sal_uInt16
)AnimationNodeType::ANIMATEMOTION
},
183 { XML_NAMESPACE_ANIMATION
, XML_ANIMATECOLOR
, (sal_uInt16
)AnimationNodeType::ANIMATECOLOR
},
184 { XML_NAMESPACE_ANIMATION
, XML_ANIMATETRANSFORM
, (sal_uInt16
)AnimationNodeType::ANIMATETRANSFORM
},
185 { XML_NAMESPACE_ANIMATION
, XML_TRANSITIONFILTER
, (sal_uInt16
)AnimationNodeType::TRANSITIONFILTER
},
186 { XML_NAMESPACE_ANIMATION
, XML_AUDIO
, (sal_uInt16
)AnimationNodeType::AUDIO
},
187 { XML_NAMESPACE_ANIMATION
, XML_COMMAND
, (sal_uInt16
)AnimationNodeType::COMMAND
},
191 mpAnimationNodeTokenMap
= new SvXMLTokenMap( aAnimationNodeTokenMap
);
194 return *mpAnimationNodeTokenMap
;
197 enum AnimationNodeAttributes
236 ANA_TransitionSubType
,
249 const SvXMLTokenMap
& AnimationsImportHelperImpl::getAnimationNodeAttributeTokenMap()
251 if( mpAnimationNodeAttributeTokenMap
== NULL
)
253 static __FAR_DATA SvXMLTokenMapEntry aAnimationNodeAttributeTokenMap
[] =
255 { XML_NAMESPACE_SMIL
, XML_BEGIN
, (sal_uInt16
)ANA_Begin
},
256 { XML_NAMESPACE_SMIL
, XML_DUR
, (sal_uInt16
)ANA_Dur
},
257 { XML_NAMESPACE_SMIL
, XML_END
, (sal_uInt16
)ANA_End
},
258 { XML_NAMESPACE_SMIL
, XML_FILL
, (sal_uInt16
)ANA_Fill
},
259 { XML_NAMESPACE_SMIL
, XML_FILLDEFAULT
, (sal_uInt16
)ANA_FillDefault
},
260 { XML_NAMESPACE_SMIL
, XML_RESTART
, (sal_uInt16
)ANA_Restart
},
261 { XML_NAMESPACE_SMIL
, XML_RESTARTDEFAULT
, (sal_uInt16
)ANA_RestartDefault
},
262 { XML_NAMESPACE_SMIL
, XML_ACCELERATE
, (sal_uInt16
)ANA_Accelerate
},
263 { XML_NAMESPACE_SMIL
, XML_DECELERATE
, (sal_uInt16
)ANA_Decelerate
},
264 { XML_NAMESPACE_SMIL
, XML_AUTOREVERSE
, (sal_uInt16
)ANA_AutoReverse
},
265 { XML_NAMESPACE_SMIL
, XML_REPEATCOUNT
, (sal_uInt16
)ANA_RepeatCount
},
266 { XML_NAMESPACE_SMIL
, XML_REPEATDUR
, (sal_uInt16
)ANA_RepeatDur
},
267 { XML_NAMESPACE_SMIL
, XML_ENDSYNC
, (sal_uInt16
)ANA_EndSync
},
268 { XML_NAMESPACE_PRESENTATION
, XML_NODE_TYPE
, (sal_uInt16
)ANA_Node_Type
},
269 { XML_NAMESPACE_PRESENTATION
, XML_PRESET_ID
, (sal_uInt16
)ANA_Preset_ID
},
270 { XML_NAMESPACE_PRESENTATION
, XML_PRESET_SUB_TYPE
, (sal_uInt16
)ANA_Preset_Sub_Type
},
271 { XML_NAMESPACE_PRESENTATION
, XML_PRESET_CLASS
, (sal_uInt16
)ANA_Preset_Class
},
272 { XML_NAMESPACE_PRESENTATION
, XML_AFTER_EFFECT
, (sal_uInt16
)ANA_After_Effect
},
273 { XML_NAMESPACE_SMIL
, XML_TARGETELEMENT
, (sal_uInt16
)ANA_Target
},
274 { XML_NAMESPACE_XLINK
, XML_HREF
, (sal_uInt16
)ANA_XLink
},
275 { XML_NAMESPACE_PRESENTATION
, XML_MASTER_ELEMENT
, (sal_uInt16
)ANA_MasterElement
},
276 { XML_NAMESPACE_ANIMATION
, XML_SUB_ITEM
, (sal_uInt16
)ANA_SubItem
},
277 { XML_NAMESPACE_SMIL
, XML_ATTRIBUTENAME
, (sal_uInt16
)ANA_AttributeName
},
278 { XML_NAMESPACE_SMIL
, XML_VALUES
, (sal_uInt16
)ANA_Values
},
279 { XML_NAMESPACE_SMIL
, XML_FROM
, (sal_uInt16
)ANA_From
},
280 { XML_NAMESPACE_SMIL
, XML_BY
, (sal_uInt16
)ANA_By
},
281 { XML_NAMESPACE_SMIL
, XML_TO
, (sal_uInt16
)ANA_To
},
282 { XML_NAMESPACE_SMIL
, XML_KEYTIMES
, (sal_uInt16
)ANA_KeyTimes
},
283 { XML_NAMESPACE_SMIL
, XML_CALCMODE
, (sal_uInt16
)ANA_CalcMode
},
284 { XML_NAMESPACE_SMIL
, XML_ACCUMULATE
, (sal_uInt16
)ANA_Accumulate
},
285 { XML_NAMESPACE_PRESENTATION
, XML_ADDITIVE
, (sal_uInt16
)ANA_AdditiveMode
},
286 { XML_NAMESPACE_SMIL
, XML_ADDITIVE
, (sal_uInt16
)ANA_AdditiveMode
},
287 { XML_NAMESPACE_SMIL
, XML_KEYSPLINES
, (sal_uInt16
)ANA_KeySplines
},
288 { XML_NAMESPACE_SVG
, XML_PATH
, (sal_uInt16
)ANA_Path
},
289 { XML_NAMESPACE_ANIMATION
, XML_COLOR_INTERPOLATION
, (sal_uInt16
)ANA_ColorSpace
},
290 { XML_NAMESPACE_ANIMATION
, XML_COLOR_INTERPOLATION_DIRECTION
, (sal_uInt16
)ANA_ColorDirection
},
291 { XML_NAMESPACE_SVG
, XML_TYPE
, (sal_uInt16
)ANA_TransformType
},
292 { XML_NAMESPACE_SMIL
, XML_TYPE
, (sal_uInt16
)ANA_TransitionType
},
293 { XML_NAMESPACE_SMIL
, XML_SUBTYPE
, (sal_uInt16
)ANA_TransitionSubType
},
294 { XML_NAMESPACE_SMIL
, XML_MODE
, (sal_uInt16
)ANA_Mode
},
295 { XML_NAMESPACE_SMIL
, XML_DIRECTION
, (sal_uInt16
)ANA_Direction
},
296 { XML_NAMESPACE_SMIL
, XML_FADECOLOR
, (sal_uInt16
)ANA_FadeColor
},
297 { XML_NAMESPACE_ANIMATION
, XML_ITERATE_TYPE
, (sal_uInt16
)ANA_IterateType
},
298 { XML_NAMESPACE_ANIMATION
, XML_ITERATE_INTERVAL
, (sal_uInt16
)ANA_IterateInterval
},
299 { XML_NAMESPACE_ANIMATION
, XML_FORMULA
, (sal_uInt16
)ANA_Formula
},
300 { XML_NAMESPACE_ANIMATION
, XML_ID
, (sal_uInt16
)ANA_ID
},
301 { XML_NAMESPACE_XML
, XML_ID
, (sal_uInt16
)ANA_ID
},
302 { XML_NAMESPACE_PRESENTATION
, XML_GROUP_ID
, (sal_uInt16
)ANA_Group_Id
},
303 { XML_NAMESPACE_ANIMATION
, XML_AUDIO_LEVEL
, (sal_uInt16
)ANA_Volume
},
304 { XML_NAMESPACE_ANIMATION
, XML_COMMAND
, (sal_uInt16
)ANA_Command
},
309 mpAnimationNodeAttributeTokenMap
= new SvXMLTokenMap( aAnimationNodeAttributeTokenMap
);
312 return *mpAnimationNodeAttributeTokenMap
;
315 static bool isDouble( const OUString
& rValue
)
317 sal_Int32 nLength
= rValue
.getLength();
318 const sal_Unicode
* pStr
= rValue
.getStr();
321 if( (*pStr
>= '0' && *pStr
<= '9') || *pStr
== '-' || *pStr
== '.' || *pStr
== '+' || *pStr
== 'e' || *pStr
== 'E' )
335 static bool isTime( const OUString
& rValue
)
337 sal_Int32 nLength
= rValue
.getLength();
338 const sal_Unicode
* pStr
;
339 for( pStr
= rValue
.getStr(); nLength
; pStr
++, nLength
-- )
341 if( !( (*pStr
>= '0' && *pStr
<= '9') || *pStr
== '-' || *pStr
== '.' || *pStr
== '+' || *pStr
== 'e' || *pStr
== 'E' ) )
345 // return true if this is a double (if someone forgot the 's' we silently ignore it)
346 // or if its a double that ends with a 's' or 'S'
347 return (nLength
== 0) || ((*pStr
== 's' || *pStr
== 'S') && (nLength
== 1));
350 static sal_Int32
count_codes( const OUString
& rString
, sal_Unicode nCode
)
352 sal_Int32 nCount
= 0;
353 sal_Int32 fromIndex
= 0;
357 fromIndex
= rString
.indexOf( nCode
, fromIndex
);
358 if( fromIndex
== -1 )
368 Any
AnimationsImportHelperImpl::convertTarget( const OUString
& rValue
)
372 Reference
< XInterface
> xRef( mrImport
.getInterfaceToIdentifierMapper().getReference( rValue
) );
374 Reference
< XShape
> _xShape( xRef
, UNO_QUERY
);
376 return makeAny( _xShape
);
378 Reference
< XTextCursor
> xTextCursor( xRef
, UNO_QUERY
);
379 if( xTextCursor
.is() )
381 Reference
< XTextRange
> xStart( xTextCursor
->getStart() ), xRange
;
382 Reference
< XShape
> xShape( xTextCursor
->getText(), UNO_QUERY_THROW
);
383 Reference
< XTextRangeCompare
> xTextRangeCompare( xShape
, UNO_QUERY_THROW
);
385 Reference
< XEnumerationAccess
> xParaEnumAccess( xShape
, UNO_QUERY_THROW
);
386 Reference
< XEnumeration
> xEnumeration( xParaEnumAccess
->createEnumeration(), UNO_QUERY_THROW
);
387 sal_Int16 nParagraph
= 0;
389 while( xEnumeration
->hasMoreElements() )
391 xEnumeration
->nextElement() >>= xRange
;
393 // break if start of selection is prior to end of current paragraph
394 if( xRange
.is() && (xTextRangeCompare
->compareRegionEnds( xStart
, xRange
) >= 0 ) )
396 return makeAny( ParagraphTarget( xShape
, nParagraph
) );
403 catch( RuntimeException
& )
405 DBG_ERROR( "xmloff::AnimationsImportImpl::convertTarget(), RuntimeException catched!" );
412 Any
AnimationsImportHelperImpl::convertValue( XMLTokenEnum eAttributeName
, const OUString
& rValue
)
414 sal_Int32 nCommaPos
= -1, nPos
;
415 sal_Int32 nOpenBrakets
= 0;
416 for( nPos
= 0; (nPos
< rValue
.getLength()) && (nCommaPos
== -1); nPos
++ )
418 switch( rValue
[nPos
] )
421 if( nOpenBrakets
== 0 )
440 aPair
.First
= convertValue( eAttributeName
, rValue
.copy( 0, nCommaPos
) );
441 aPair
.Second
= convertValue( eAttributeName
, rValue
.copy( nCommaPos
+1, rValue
.getLength() - nCommaPos
- 1 ) );
442 return makeAny( aPair
);
447 sal_Int32 nType
= XML_TYPE_STRING
;
449 if( rValue
.getLength() ) switch( eAttributeName
)
457 return makeAny( rValue
);
464 case XML_ROTATE
: nType
= XML_TYPE_DOUBLE
; break;
465 case XML_TEXT_ROTATION_ANGLE
:nType
= XML_TYPE_TEXT_ROTATION_ANGLE
; break;
467 case XML_STROKE_COLOR
:
469 case XML_COLOR
: nType
= XML_TYPE_COLOR
; break;
470 case XML_FILL
: nType
= XML_SD_TYPE_FILLSTYLE
; break;
471 case XML_STROKE
: nType
= XML_SD_TYPE_STROKE
; break;
472 case XML_FONT_WEIGHT
: nType
= XML_TYPE_TEXT_WEIGHT
; break;
473 case XML_FONT_STYLE
: nType
= XML_TYPE_TEXT_POSTURE
; break;
474 case XML_TEXT_UNDERLINE
: nType
= XML_TYPE_TEXT_UNDERLINE_STYLE
; break;
475 case XML_FONT_SIZE
: nType
= XML_TYPE_DOUBLE_PERCENT
; break;
476 case XML_VISIBILITY
: nType
= XML_SD_TYPE_PRESPAGE_VISIBILITY
; break;
479 if( rValue
.getLength() )
484 const XMLPropertyHandler
* pHandler
= mrImport
.GetShapeImport()->GetSdPropHdlFactory()->GetPropertyHandler( nType
);
486 pHandler
->importXML( rValue
, aAny
, mrImport
.GetMM100UnitConverter() );
491 if( rValue.getLength() == 0 )
496 else if( rValue.indexOf( '#' ) == 0 )
500 SvXMLUnitConverter::convertColor( aColor, rValue );
502 return makeAny( static_cast< sal_Int32 >( aColor.GetRGBColor() ) );
504 else if( rValue.indexOf( '$' ) != -1 )
507 return makeAny( rValue );
511 if( isDouble( rValue ) )
513 return makeAny( rValue.toDouble() );
517 return makeAny( rValue );
524 Sequence
< Any
> AnimationsImportHelperImpl::convertValueSequence( XMLTokenEnum eAttributeName
, const OUString
& rValue
)
526 Sequence
< Any
> aValues
;
528 // do we have any value at all?
529 if( rValue
.getLength() )
531 sal_Int32 nElements
= count_codes( rValue
, (sal_Unicode
)';') + 1; // a non empty string has at least one value
533 // prepare the sequence
534 aValues
.realloc( nElements
);
537 Any
* pValues
= aValues
.getArray();
538 sal_Int32 nIndex
, nElement
;
539 for( nIndex
= 0, nElement
= 0; nElements
&& (nIndex
>= 0); nElements
-- )
541 *pValues
++ = convertValue( eAttributeName
, rValue
.getToken( 0, ';', nIndex
) );
548 Any
AnimationsImportHelperImpl::convertTiming( const OUString
& rValue
)
552 // do we have any value at all?
553 if( rValue
.getLength() )
556 sal_Int32 nElements
= count_codes( rValue
, (sal_Unicode
)';' ) + 1; // a non empty string has at least one value
560 if( IsXMLToken( rValue
, XML_MEDIA
) )
562 aAny
<<= Timing_MEDIA
;
564 else if( IsXMLToken( rValue
, XML_INDEFINITE
) )
566 aAny
<<= Timing_INDEFINITE
;
568 else if( isTime( rValue
) )
570 aAny
<<= rValue
.toDouble();
578 OUString aEventTrigger
;
580 sal_Int32 nPos
= rValue
.indexOf( (sal_Unicode
)'+' );
583 aEventTrigger
= rValue
;
587 aEventTrigger
= rValue
.copy( 0, nPos
);
590 aEvent
.Offset
<<= convertTiming( rValue
.copy( nPos
+ 1 ) );
593 nPos
= aEventTrigger
.indexOf( (sal_Unicode
)'.' );
596 aEvent
.Source
<<= mrImport
.getInterfaceToIdentifierMapper().getReference( aEventTrigger
.copy( 0, nPos
) );
597 aEventTrigger
= aEventTrigger
.copy( nPos
+ 1 );
601 if( SvXMLUnitConverter::convertEnum( nEnum
, aEventTrigger
, getAnimationsEnumMap(Animations_EnumMap_EventTrigger
) ) )
603 aEvent
.Trigger
= (sal_Int16
)nEnum
;
607 DBG_ERROR("AnimationsImportHelperImpl::convertTiming(), unknown event trigger!");
616 Sequence
< Any
> aValues( nElements
);
617 Any
* pValues
= aValues
.getArray();
618 sal_Int32 nIndex
= 0;
619 while( (nElements
--) && (nIndex
>= 0) )
620 *pValues
++ = convertTiming( rValue
.getToken( 0, ';', nIndex
) );
628 Sequence
< double > AnimationsImportHelperImpl::convertKeyTimes( const OUString
& rValue
)
630 sal_Int32 nElements
= 0;
632 if( rValue
.getLength() )
633 nElements
= count_codes( rValue
, (sal_Unicode
)';' ) + 1; // a non empty string has at least one value
635 Sequence
< double > aKeyTimes( nElements
);
639 double* pValues
= aKeyTimes
.getArray();
640 sal_Int32 nIndex
= 0;
641 while( (nElements
--) && (nIndex
>= 0) )
642 *pValues
++ = rValue
.getToken( 0, ';', nIndex
).toDouble();
648 Sequence
< TimeFilterPair
> AnimationsImportHelperImpl::convertTimeFilter( const OUString
& rValue
)
650 sal_Int32 nElements
= 0;
652 if( rValue
.getLength() )
653 nElements
= count_codes( rValue
, (sal_Unicode
)';' ) + 1; // a non empty string has at least one value
655 Sequence
< TimeFilterPair
> aTimeFilter( nElements
);
659 TimeFilterPair
* pValues
= aTimeFilter
.getArray();
660 sal_Int32 nIndex
= 0;
661 while( (nElements
--) && (nIndex
>= 0) )
663 const OUString
aToken( rValue
.getToken( 0, ';', nIndex
) );
665 sal_Int32 nPos
= aToken
.indexOf( ',' );
668 pValues
->Time
= aToken
.copy( 0, nPos
).toDouble();
669 pValues
->Progress
= aToken
.copy( nPos
+1, aToken
.getLength() - nPos
- 1 ).toDouble();
678 Any
AnimationsImportHelperImpl::convertPath( const OUString
& rValue
)
680 return makeAny( rValue
);
683 ///////////////////////////////////////////////////////////////////////
685 TYPEINIT1( AnimationNodeContext
, SvXMLImportContext
);
687 AnimationNodeContext::AnimationNodeContext(
688 const Reference
< XAnimationNode
>& xParentNode
,
689 SvXMLImport
& rImport
, sal_uInt16 nPrfx
, const rtl::OUString
& rLocalName
,
690 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
691 AnimationsImportHelperImpl
* pHelper
/* = NULL */ )
692 : SvXMLImportContext(rImport
, nPrfx
, rLocalName
),
694 mbRootContext( pHelper
== NULL
)
700 mpHelper
= new AnimationsImportHelperImpl( rImport
);
701 mxNode
= xParentNode
;
705 Reference
< XMultiServiceFactory
> xFactory( ::comphelper::getProcessServiceFactory() );
707 sal_Int16 nPresetClass
= EffectPresetClass::CUSTOM
;
709 const sal_Char
* pServiceName
= 0;
711 sal_Int16 nNodeType
= (sal_Int16
)mpHelper
->getAnimationNodeTokenMap().Get( nPrfx
, rLocalName
);
714 case AnimationNodeType::SEQ
: pServiceName
= "com.sun.star.animations.SequenceTimeContainer"; break;
715 case AnimationNodeType::ITERATE
: pServiceName
= "com.sun.star.animations.IterateContainer"; break;
716 case AnimationNodeType::ANIMATE
: pServiceName
= "com.sun.star.animations.Animate"; break;
717 case AnimationNodeType::SET
: pServiceName
= "com.sun.star.animations.AnimateSet"; break;
718 case AnimationNodeType::ANIMATEMOTION
: pServiceName
= "com.sun.star.animations.AnimateMotion"; break;
719 case AnimationNodeType::ANIMATECOLOR
: pServiceName
= "com.sun.star.animations.AnimateColor"; break;
720 case AnimationNodeType::ANIMATETRANSFORM
: pServiceName
= "com.sun.star.animations.AnimateTransform"; break;
721 case AnimationNodeType::TRANSITIONFILTER
: pServiceName
= "com.sun.star.animations.TransitionFilter"; break;
722 case AnimationNodeType::AUDIO
: pServiceName
= "com.sun.star.animations.Audio"; break;
723 case AnimationNodeType::COMMAND
: pServiceName
= "com.sun.star.animations.Command"; break;
724 case AnimationNodeType::PAR
:
726 const sal_Int16 nCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
727 sal_Int16 nAttribute
;
728 for( nAttribute
= 0; nAttribute
< nCount
; nAttribute
++ )
731 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList
->getNameByIndex( nAttribute
), &aLocalName
);
732 if( (nPrefix
== XML_NAMESPACE_PRESENTATION
) && IsXMLToken( aLocalName
, XML_PRESET_ID
) )
734 const OUString
& rValue
= xAttrList
->getValueByIndex( nAttribute
);
735 if( rValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ooo-entrance-random" ) ) )
737 nPresetClass
= EffectPresetClass::ENTRANCE
;
739 else if( rValue
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ooo-exit-random" ) ) )
741 nPresetClass
= EffectPresetClass::EXIT
;
744 if( nPresetClass
!= EffectPresetClass::CUSTOM
)
746 pServiceName
= "com.sun.star.comp.sd.RandomAnimationNode";
752 pServiceName
= "com.sun.star.animations.ParallelTimeContainer";
759 if( pServiceName
&& xFactory
.is() )
761 mxNode
= Reference
< XAnimationNode
>( xFactory
->createInstance(
762 OUString::createFromAscii(pServiceName
) ), UNO_QUERY_THROW
);
764 if( nPresetClass
!= EffectPresetClass::CUSTOM
)
766 Reference
< XInitialization
> xInit( mxNode
, UNO_QUERY_THROW
);
767 const Any
aAny( makeAny( nPresetClass
) );
768 Sequence
< Any
> aArgs( &aAny
, 1 ) ;
769 xInit
->initialize( aArgs
);
772 init_node( xAttrList
);
774 Reference
< XTimeContainer
> xParentContainer( xParentNode
, UNO_QUERY_THROW
);
775 xParentContainer
->appendChild( mxNode
);
779 catch( RuntimeException
& )
781 DBG_ERROR( "xmloff::AnimationsImportImpl::AnimationsImportImpl(), RuntimeException catched!" );
785 AnimationNodeContext::~AnimationNodeContext()
791 void AnimationNodeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& )
793 // code of StartElement is moved to init_node that is now called
794 // in c'tor before appending this node to its parent.
795 // This is needed for random nodes that need the correct target
796 // set when child nodes are appended.
799 void AnimationNodeContext::init_node( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
801 if( mxNode
.is() ) try
803 const sal_Int16 nNodeType
= mxNode
->getType();
805 // query for optional interfaces that are often used later
806 Reference
< XAnimate
> xAnimate( mxNode
, UNO_QUERY
);
807 Reference
< XCommand
> xCommand( mxNode
, UNO_QUERY
);
808 Reference
< XTransitionFilter
> xTransitionFilter( mxNode
, UNO_QUERY
);
809 Reference
< XIterateContainer
> xIter( mxNode
, UNO_QUERY
);
811 std::list
< NamedValue
> aUserData
;
812 XMLTokenEnum meAttributeName
= XML_TOKEN_INVALID
;
813 OUString aFrom
, aBy
, aTo
, aValues
;
815 const sal_Int16 nCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
817 sal_Int16 nAttribute
;
818 for( nAttribute
= 0; nAttribute
< nCount
; nAttribute
++ )
820 const OUString
& rAttrName
= xAttrList
->getNameByIndex( nAttribute
);
821 const OUString
& rValue
= xAttrList
->getValueByIndex( nAttribute
);
824 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName
, &aLocalName
);
825 switch( mpHelper
->getAnimationNodeAttributeTokenMap().Get( nPrefix
, aLocalName
) )
829 mxNode
->setBegin( mpHelper
->convertTiming( rValue
) );
834 mxNode
->setDuration( mpHelper
->convertTiming( rValue
) );
839 mxNode
->setEnd( mpHelper
->convertTiming( rValue
) );
844 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_Fill
) ) )
845 mxNode
->setFill( (sal_Int16
)nEnum
);
848 case ANA_FillDefault
:
850 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_FillDefault
) ) )
851 mxNode
->setFillDefault( (sal_Int16
)nEnum
);
856 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_Restart
) ) )
857 mxNode
->setRestart( (sal_Int16
)nEnum
);
860 case ANA_RestartDefault
:
862 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_RestartDefault
) ) )
863 mxNode
->setRestartDefault( (sal_Int16
)nEnum
);
868 if( isDouble( rValue
) )
869 mxNode
->setAcceleration( rValue
.toDouble() );
874 if( isDouble( rValue
) )
875 mxNode
->setDecelerate( rValue
.toDouble() );
878 case ANA_AutoReverse
:
881 if( SvXMLUnitConverter::convertBool( bTemp
, rValue
) )
882 mxNode
->setAutoReverse( bTemp
);
885 case ANA_RepeatCount
:
887 mxNode
->setRepeatCount( mpHelper
->convertTiming( rValue
) );
892 mxNode
->setRepeatDuration( mpHelper
->convertTiming( rValue
) );
897 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_Endsync
) ) )
898 mxNode
->setEndSync( makeAny( (sal_Int16
)nEnum
) );
903 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_EffectNodeType
) ) )
904 aUserData
.push_back( NamedValue( GetXMLToken( XML_NODE_TYPE
), makeAny( (sal_Int16
)nEnum
) ) );
909 aUserData
.push_back( NamedValue( GetXMLToken( XML_PRESET_ID
), makeAny( rValue
) ) );
912 case ANA_Preset_Sub_Type
:
914 aUserData
.push_back( NamedValue( GetXMLToken( XML_PRESET_SUB_TYPE
), makeAny( rValue
) ) );
917 case ANA_Preset_Class
:
919 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_EffectPresetClass
) ) )
920 aUserData
.push_back( NamedValue( GetXMLToken( XML_PRESET_CLASS
), makeAny( (sal_Int16
)nEnum
) ) );
923 case ANA_After_Effect
:
926 if( SvXMLUnitConverter::convertBool( bTemp
, rValue
) )
927 aUserData
.push_back( NamedValue( GetXMLToken( XML_AFTER_EFFECT
), makeAny( bTemp
) ) );
932 if( nNodeType
== AnimationNodeType::AUDIO
)
934 Reference
< XAudio
> xAudio( mxNode
, UNO_QUERY_THROW
);
935 xAudio
->setSource( makeAny( GetImport().GetAbsoluteReference( rValue
) ) );
940 // fall through intented!
944 Any
aTarget( mpHelper
->convertTarget( rValue
) );
948 xAnimate
->setTarget( aTarget
);
950 else if( xIter
.is() )
952 xIter
->setTarget( aTarget
);
954 else if( xCommand
.is() )
956 xCommand
->setTarget( aTarget
);
964 if( nNodeType
== AnimationNodeType::AUDIO
)
966 if( isDouble( rValue
) )
968 Reference
< XAudio
> xAudio( mxNode
, UNO_QUERY_THROW
);
969 xAudio
->setVolume( rValue
.toDouble() );
975 case ANA_MasterElement
:
977 Reference
< XAnimationNode
> xMaster( GetImport().getInterfaceToIdentifierMapper().getReference( rValue
), UNO_QUERY
);
978 aUserData
.push_back( NamedValue( GetXMLToken( XML_MASTER_ELEMENT
), makeAny( xMaster
) ) );
984 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_SubItem
) ) )
988 xAnimate
->setSubItem( (sal_Int16
)nEnum
);
990 else if( xIter
.is() )
992 xIter
->setSubItem( (sal_Int16
)nEnum
);
998 case ANA_AttributeName
:
1002 OUString
aName( rValue
);
1004 ImplAttributeNameConversion
* p
= getAnimationAttributeNamesConversionList();
1005 while( p
->mpAPIName
)
1007 if( IsXMLToken( aName
, p
->meXMLToken
) )
1009 aName
= OUString::createFromAscii( p
->mpAPIName
);
1010 meAttributeName
= p
->meXMLToken
;
1017 xAnimate
->setAttributeName( aName
);
1049 xAnimate
->setKeyTimes( mpHelper
->convertKeyTimes( rValue
) );
1056 xAnimate
->setFormula( rValue
);
1062 if( rValue
.getLength() )
1064 Reference
< XInterface
> xRef( mxNode
, UNO_QUERY
);
1065 GetImport().getInterfaceToIdentifierMapper().registerReference( rValue
, xRef
);
1074 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_CalcMode
) ) )
1075 xAnimate
->setCalcMode( (sal_Int16
)nEnum
);
1080 case ANA_Accumulate
:
1083 xAnimate
->setAccumulate( IsXMLToken( rValue
, XML_SUM
) );
1087 case ANA_AdditiveMode
:
1091 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_AdditiveMode
) ) )
1092 xAnimate
->setAdditive( (sal_Int16
)nEnum
);
1097 case ANA_KeySplines
:
1100 xAnimate
->setTimeFilter( mpHelper
->convertTimeFilter( rValue
) );
1106 Reference
< XAnimateMotion
> xAnimateMotion( mxNode
, UNO_QUERY
);
1107 if( xAnimateMotion
.is() )
1108 xAnimateMotion
->setPath( mpHelper
->convertPath( rValue
) );
1112 case ANA_ColorSpace
:
1114 Reference
< XAnimateColor
> xAnimateColor( mxNode
, UNO_QUERY
);
1115 if( xAnimateColor
.is() )
1116 xAnimateColor
->setColorInterpolation( IsXMLToken( rValue
, XML_HSL
) ? AnimationColorSpace::HSL
: AnimationColorSpace::RGB
);
1120 case ANA_ColorDirection
:
1122 Reference
< XAnimateColor
> xAnimateColor( mxNode
, UNO_QUERY
);
1123 if( xAnimateColor
.is() )
1124 xAnimateColor
->setDirection( IsXMLToken( rValue
, XML_CLOCKWISE
) );
1128 case ANA_TransformType
:
1130 Reference
< XAnimateTransform
> xTransform( mxNode
, UNO_QUERY
);
1131 if( xTransform
.is() )
1133 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_TransformType
) ) )
1135 xTransform
->setTransformType( (sal_Int16
)nEnum
);
1138 case AnimationTransformType::SCALE
: meAttributeName
= XML_SCALE
; break;
1139 case AnimationTransformType::ROTATE
: meAttributeName
= XML_ROTATE
; break;
1140 case AnimationTransformType::SKEWX
: meAttributeName
= XML_SKEWX
; break;
1141 case AnimationTransformType::SKEWY
: meAttributeName
= XML_SKEWY
; break;
1142 //case AnimationTransformType::TRANSLATE:
1144 meAttributeName
= XML_TRANSLATE
; break;
1151 case ANA_TransitionType
:
1153 if( xTransitionFilter
.is() )
1155 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_TransitionType
) ) )
1156 xTransitionFilter
->setTransition( (sal_Int16
)nEnum
);
1161 case ANA_TransitionSubType
:
1163 if( xTransitionFilter
.is() )
1165 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_TransitionSubType
) ) )
1166 xTransitionFilter
->setSubtype( (sal_Int16
)nEnum
);
1173 if( xTransitionFilter
.is() )
1174 xTransitionFilter
->setMode( IsXMLToken( rValue
, XML_IN
) );
1180 if( xTransitionFilter
.is() )
1181 xTransitionFilter
->setDirection( IsXMLToken( rValue
, XML_FORWARD
) );
1187 if( xTransitionFilter
.is() )
1190 SvXMLUnitConverter::convertColor( aColor
, rValue
);
1191 xTransitionFilter
->setFadeColor( static_cast< sal_Int32
>( aColor
.GetRGBColor() ) );
1196 case ANA_IterateType
:
1198 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_IterateType
) ) )
1201 xIter
->setIterateType( (sal_Int16
)nEnum
);
1206 case ANA_IterateInterval
:
1210 double fInterval
= 0.0;
1211 if( rValue
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("P")) )
1214 sal_Int32 nSecondsFraction
= 0;
1215 if( SvXMLUnitConverter::convertTimeDuration( rValue
, aTime
, &nSecondsFraction
) )
1217 fInterval
= ((((aTime
.GetHour() * 60) + aTime
.GetMin()) * 60) + aTime
.GetSec()) + (nSecondsFraction
/ 1000.0);
1222 fInterval
= rValue
.toDouble();
1225 xIter
->setIterateInterval( fInterval
);
1232 aUserData
.push_back( NamedValue( aLocalName
, makeAny( rValue
.toInt32() ) ) );
1238 if( xCommand
.is() && nNodeType
== AnimationNodeType::COMMAND
)
1240 if( SvXMLUnitConverter::convertEnum( nEnum
, rValue
, getAnimationsEnumMap(Animations_EnumMap_Command
) ) )
1242 xCommand
->setCommand( (sal_Int16
)nEnum
);
1249 // push all unknown attributes within the presentation namespace as user data
1250 if( nPrefix
== XML_NAMESPACE_PRESENTATION
)
1252 aUserData
.push_back( NamedValue( aLocalName
, makeAny( rValue
) ) );
1257 sal_Int32 nUserDataCount
= aUserData
.size();
1258 if( nUserDataCount
)
1260 Sequence
< NamedValue
> aUnoUserData( nUserDataCount
);
1261 NamedValue
* pData
= aUnoUserData
.getArray();
1262 std::list
< NamedValue
>::iterator
aIter( aUserData
.begin() );
1263 const std::list
< NamedValue
>::iterator
aEnd( aUserData
.end() );
1264 while( aIter
!= aEnd
)
1265 *pData
++ = (*aIter
++);
1267 mxNode
->setUserData( aUnoUserData
);
1273 if( aFrom
.getLength() )
1274 xAnimate
->setFrom( mpHelper
->convertValue( meAttributeName
, aFrom
) );
1276 if( aBy
.getLength() )
1277 xAnimate
->setBy( mpHelper
->convertValue( meAttributeName
, aBy
) );
1279 if( aTo
.getLength() )
1280 xAnimate
->setTo( mpHelper
->convertValue( meAttributeName
, aTo
) );
1282 if( aValues
.getLength() )
1283 xAnimate
->setValues( mpHelper
->convertValueSequence( meAttributeName
, aValues
) );
1286 catch( RuntimeException
& )
1288 DBG_ERROR( "xmloff::AnimationNodeContext::StartElement(), RuntimeException catched!" );
1292 SvXMLImportContext
* AnimationNodeContext::CreateChildContext( USHORT nPrefix
, const ::rtl::OUString
& rLocalName
,
1293 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
1296 return new AnimationNodeContext( mxNode
, GetImport(), nPrefix
, rLocalName
, xAttrList
, mpHelper
);
1298 return new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
1301 // --------------------------------------------------------------------
1303 class AnimationsImport
: public SvXMLImport
, public XAnimationNodeSupplier
1306 AnimationsImport( const Reference
< XMultiServiceFactory
> & rSMgr
);
1307 ~AnimationsImport() throw ();
1309 SvXMLImportContext
* CreateContext(USHORT nPrefix
, const OUString
& rLocalName
, const Reference
<XAttributeList
>& xAttrList
);
1312 virtual Any SAL_CALL
queryInterface( const Type
& aType
) throw (RuntimeException
);
1313 virtual void SAL_CALL
acquire() throw ();
1314 virtual void SAL_CALL
release() throw ();
1316 // XAnimationNodeSupplier
1317 Reference
< XAnimationNode
> SAL_CALL
getAnimationNode() throw (RuntimeException
);
1320 virtual OUString SAL_CALL
getImplementationName() throw(RuntimeException
);
1321 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw(RuntimeException
);
1322 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw(RuntimeException
);
1325 Reference
< XAnimationNode
> mxRootNode
;
1328 AnimationsImport::AnimationsImport( const Reference
< XMultiServiceFactory
> & rSMgr
)
1329 : SvXMLImport( rSMgr
, true )
1332 GetNamespaceMap().Add(
1333 GetXMLToken(XML_NP_PRESENTATION
),
1334 GetXMLToken(XML_N_PRESENTATION
),
1335 XML_NAMESPACE_PRESENTATION
);
1337 GetNamespaceMap().Add(
1338 GetXMLToken(XML_NP_SMIL
),
1339 GetXMLToken(XML_N_SMIL
),
1340 XML_NAMESPACE_SMIL
);
1342 GetNamespaceMap().Add(
1343 GetXMLToken(XML_NP_ANIMATION
),
1344 GetXMLToken(XML_N_ANIMATION
),
1345 XML_NAMESPACE_ANIMATION
);
1347 mxRootNode
= Reference
< XAnimationNode
>::query(rSMgr
->createInstance(
1348 OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.animations.SequenceTimeContainer"))));
1351 AnimationsImport::~AnimationsImport() throw ()
1356 Any SAL_CALL
AnimationsImport::queryInterface( const Type
& aType
) throw (RuntimeException
)
1358 if ( aType
== ::getCppuType((Reference
<XAnimationNodeSupplier
> *)0) )
1360 return makeAny( Reference
<XAnimationNodeSupplier
>( this ) );
1364 return SvXMLImport::queryInterface( aType
);
1368 void SAL_CALL
AnimationsImport::acquire() throw ()
1370 SvXMLImport::acquire();
1373 void SAL_CALL
AnimationsImport::release() throw ()
1375 SvXMLImport::release();
1378 SvXMLImportContext
*AnimationsImport::CreateContext(USHORT nPrefix
, const OUString
& rLocalName
, const Reference
<XAttributeList
>& xAttrList
)
1380 SvXMLImportContext
* pContext
= 0;
1382 if( (XML_NAMESPACE_ANIMATION
== nPrefix
) && IsXMLToken( rLocalName
, XML_SEQ
) )
1384 pContext
= new AnimationNodeContext( mxRootNode
, *this, nPrefix
, rLocalName
, xAttrList
);
1388 pContext
= SvXMLImport::CreateContext(nPrefix
, rLocalName
, xAttrList
);
1394 // XAnimationNodeSupplier
1395 Reference
< XAnimationNode
> SAL_CALL
AnimationsImport::getAnimationNode() throw (RuntimeException
)
1400 void AnimationNodeContext::postProcessRootNode( SvXMLImport
& /*rImport*/, const Reference
< XAnimationNode
>& xRootNode
, Reference
< XPropertySet
>& xPageProps
)
1402 if( xRootNode
.is() && xPageProps
.is() ) try
1404 Reference
< XEnumerationAccess
> xEnumerationAccess( xRootNode
, UNO_QUERY_THROW
);
1405 Reference
< XEnumeration
> xEnumeration( xEnumerationAccess
->createEnumeration(), UNO_QUERY_THROW
);
1406 if( xEnumeration
->hasMoreElements() )
1408 Reference
< XAnimationNode
> xNode( xEnumeration
->nextElement(), UNO_QUERY_THROW
);
1409 if( xNode
->getType() == AnimationNodeType::PAR
)
1412 if( (xNode
->getBegin() >>= aEvent
) && (aEvent
.Trigger
== EventTrigger::BEGIN_EVENT
) )
1414 // found transition node
1415 Reference
< XEnumerationAccess
> xChildEnumerationAccess( xNode
, UNO_QUERY_THROW
);
1416 Reference
< XEnumeration
> xChildEnumeration( xChildEnumerationAccess
->createEnumeration(), UNO_QUERY_THROW
);
1417 while( xChildEnumeration
->hasMoreElements() )
1419 Reference
< XAnimationNode
> xChildNode( xChildEnumeration
->nextElement(), UNO_QUERY_THROW
);
1420 switch( xChildNode
->getType() )
1422 case AnimationNodeType::TRANSITIONFILTER
:
1424 Reference
< XTransitionFilter
> xTransFilter( xChildNode
, UNO_QUERY_THROW
);
1427 xPageProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TransitionType" ) ), Any( xTransFilter
->getTransition() ) );
1428 xPageProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TransitionSubtype" ) ), Any( xTransFilter
->getSubtype() ) );
1429 xPageProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TransitionDirection" ) ), Any( xTransFilter
->getDirection() ) );
1430 xPageProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TransitionFadeColor" ) ), Any( xTransFilter
->getFadeColor() ) );
1433 if( xTransFilter
->getDuration() >>= fDuration
)
1434 xPageProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TransitionDuration" ) ), Any( fDuration
) );
1439 case AnimationNodeType::COMMAND
:
1441 Reference
< XCommand
> xCommand( xChildNode
, UNO_QUERY_THROW
);
1442 if( xCommand
->getCommand() == EffectCommands::STOPAUDIO
)
1444 xPageProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Sound" ) ), Any(sal_True
) );
1449 case AnimationNodeType::AUDIO
:
1451 Reference
< XAudio
> xAudio( xChildNode
, UNO_QUERY_THROW
);
1453 if( (xAudio
->getSource() >>= sSoundURL
) && (sSoundURL
.getLength() != 0) )
1455 xPageProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Sound" ) ), Any(sSoundURL
) );
1458 if( (xAudio
->getRepeatCount() >>= eTiming
) && (eTiming
== Timing_INDEFINITE
) )
1459 xPageProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LoopSound" ) ), Any( sal_True
) );
1467 Reference
< XTimeContainer
> xRootContainer( xRootNode
, UNO_QUERY_THROW
);
1468 xRootContainer
->removeChild( xNode
);
1475 DBG_ERROR("xmloff::AnimationsImport::postProcessRootNode(), exception caught!");
1479 } // namespace xmloff
1481 Sequence
< OUString
> SAL_CALL
AnimationsImport_getSupportedServiceNames() throw()
1483 const OUString
aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Xmloff.AnimationsImport" ) );
1484 const Sequence
< OUString
> aSeq( &aServiceName
, 1 );
1488 OUString SAL_CALL
AnimationsImport_getImplementationName() throw()
1490 return OUString( RTL_CONSTASCII_USTRINGPARAM( "xmloff::AnimationsImport" ) );
1493 Reference
< XInterface
> SAL_CALL
AnimationsImport_createInstance(const Reference
< XMultiServiceFactory
> & rSMgr
) throw( Exception
)
1495 return (cppu::OWeakObject
*)new xmloff::AnimationsImport( rSMgr
);
1502 OUString SAL_CALL
AnimationsImport::getImplementationName() throw(RuntimeException
)
1504 return AnimationsImport_getImplementationName();
1507 sal_Bool SAL_CALL
AnimationsImport::supportsService( const OUString
& ServiceName
) throw(RuntimeException
)
1509 return ServiceName
.equalsAscii( "com.sun.star.comp.Xmloff.AnimationsImport" );
1512 Sequence
< OUString
> SAL_CALL
AnimationsImport::getSupportedServiceNames() throw(RuntimeException
)
1514 return AnimationsImport_getSupportedServiceNames();
1517 } // namespace xmloff