xref: /trunk/main/xmloff/source/draw/animimp.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmloff.hxx"
30 
31 #include <tools/debug.hxx>
32 #include "unointerfacetouniqueidentifiermapper.hxx"
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/presentation/AnimationEffect.hpp>
35 #include <com/sun/star/presentation/AnimationSpeed.hpp>
36 #include <com/sun/star/beans/XPropertySet.hpp>
37 #include <com/sun/star/xml/sax/XAttributeList.hpp>
38 
39 #include <list>
40 #include <tools/color.hxx>
41 #include <comphelper/extract.hxx>
42 #include <xmloff/xmltoken.hxx>
43 #include <xmloff/xmlimp.hxx>
44 #include "xmloff/xmlnmspe.hxx"
45 #include <xmloff/xmluconv.hxx>
46 /*
47 #include <xmloff/xmlement.hxx>
48 */
49 #include <xmloff/nmspmap.hxx>
50 #include "anim.hxx"
51 #include "animimp.hxx"
52 
53 using ::rtl::OUString;
54 using ::rtl::OUStringBuffer;
55 
56 using namespace ::std;
57 using namespace ::cppu;
58 using namespace ::com::sun::star;
59 using namespace ::com::sun::star::xml;
60 using namespace ::com::sun::star::xml::sax;
61 using namespace ::com::sun::star::uno;
62 using namespace ::com::sun::star::drawing;
63 using namespace ::com::sun::star::beans;
64 using namespace ::com::sun::star::lang;
65 using namespace ::com::sun::star::presentation;
66 using namespace ::xmloff::token;
67 
68 SvXMLEnumMapEntry aXML_AnimationEffect_EnumMap[] =
69 {
70 	{ XML_NONE,		    EK_none },
71 	{ XML_FADE,		    EK_fade },
72 	{ XML_MOVE,		    EK_move },
73 	{ XML_STRIPES,		EK_stripes },
74 	{ XML_OPEN,		    EK_open },
75 	{ XML_CLOSE,		EK_close },
76 	{ XML_DISSOLVE,	    EK_dissolve },
77 	{ XML_WAVYLINE,	    EK_wavyline },
78 	{ XML_RANDOM,		EK_random },
79 	{ XML_LINES,		EK_lines },
80 	{ XML_LASER,		EK_laser },
81 	{ XML_APPEAR,		EK_appear },
82 	{ XML_HIDE,		    EK_hide },
83 	{ XML_MOVE_SHORT,	EK_move_short },
84     { XML_CHECKERBOARD, EK_checkerboard },
85 	{ XML_ROTATE,		EK_rotate },
86 	{ XML_STRETCH,		EK_stretch },
87     { XML_TOKEN_INVALID, 0 }
88 };
89 
90 SvXMLEnumMapEntry aXML_AnimationDirection_EnumMap[] =
91 {
92 	{ XML_NONE,			    ED_none },
93 	{ XML_FROM_LEFT,		ED_from_left },
94 	{ XML_FROM_TOP,		    ED_from_top },
95 	{ XML_FROM_RIGHT,		ED_from_right },
96 	{ XML_FROM_BOTTOM,		ED_from_bottom },
97 	{ XML_FROM_CENTER,		ED_from_center },
98 	{ XML_FROM_UPPER_LEFT,	ED_from_upperleft },
99 	{ XML_FROM_UPPER_RIGHT, ED_from_upperright },
100 	{ XML_FROM_LOWER_LEFT,	ED_from_lowerleft },
101     { XML_FROM_LOWER_RIGHT, ED_from_lowerright },
102 	{ XML_TO_LEFT,			ED_to_left },
103 	{ XML_TO_TOP,			ED_to_top },
104 	{ XML_TO_RIGHT,		    ED_to_right },
105 	{ XML_TO_BOTTOM,		ED_to_bottom },
106 	{ XML_TO_UPPER_LEFT,	ED_to_upperleft },
107 	{ XML_TO_UPPER_RIGHT,	ED_to_upperright },
108 	{ XML_TO_LOWER_RIGHT,	ED_to_lowerright },
109 	{ XML_TO_LOWER_LEFT,	ED_to_lowerleft },
110 	{ XML_PATH,			    ED_path },
111 	{ XML_SPIRAL_INWARD_LEFT, ED_spiral_inward_left },
112 	{ XML_SPIRAL_INWARD_RIGHT,ED_spiral_inward_right },
113 	{ XML_SPIRAL_OUTWARD_LEFT, ED_spiral_outward_left },
114 	{ XML_SPIRAL_OUTWARD_RIGHT, ED_spiral_outward_right },
115 	{ XML_VERTICAL,		    ED_vertical },
116 	{ XML_HORIZONTAL,		ED_horizontal },
117 	{ XML_TO_CENTER,		ED_to_center },
118 	{ XML_CLOCKWISE,		ED_clockwise },
119 	{ XML_COUNTER_CLOCKWISE,ED_cclockwise },
120 	{ XML_TOKEN_INVALID, 0 }
121 };
122 
123 SvXMLEnumMapEntry aXML_AnimationSpeed_EnumMap[] =
124 {
125 	{ XML_SLOW,	    AnimationSpeed_SLOW },
126 	{ XML_MEDIUM,	AnimationSpeed_MEDIUM },
127 	{ XML_FAST,	    AnimationSpeed_FAST },
128 	{ XML_TOKEN_INVALID, 0 }
129 };
130 
131 AnimationEffect ImplSdXMLgetEffect( XMLEffect eKind, XMLEffectDirection eDirection, sal_Int16 nStartScale, sal_Bool /*bIn*/ )
132 {
133 	switch( eKind )
134 	{
135 	case EK_fade:
136 		switch( eDirection )
137 		{
138 		case ED_from_left:			return AnimationEffect_FADE_FROM_LEFT;
139 		case ED_from_top:			return AnimationEffect_FADE_FROM_TOP;
140 		case ED_from_right:			return AnimationEffect_FADE_FROM_RIGHT;
141 		case ED_from_bottom:		return AnimationEffect_FADE_FROM_BOTTOM;
142 		case ED_from_center:		return AnimationEffect_FADE_FROM_CENTER;
143 		case ED_from_upperleft:		return AnimationEffect_FADE_FROM_UPPERLEFT;
144 		case ED_from_upperright:	return AnimationEffect_FADE_FROM_UPPERRIGHT;
145 		case ED_from_lowerleft:		return AnimationEffect_FADE_FROM_LOWERLEFT;
146 		case ED_from_lowerright:	return AnimationEffect_FADE_FROM_LOWERRIGHT;
147 		case ED_to_center:			return AnimationEffect_FADE_TO_CENTER;
148 		case ED_clockwise:			return AnimationEffect_CLOCKWISE;
149 		case ED_cclockwise:			return AnimationEffect_COUNTERCLOCKWISE;
150 		case ED_spiral_inward_left:	return AnimationEffect_SPIRALIN_LEFT;
151 		case ED_spiral_inward_right:return AnimationEffect_SPIRALIN_RIGHT;
152 		case ED_spiral_outward_left:return AnimationEffect_SPIRALOUT_LEFT;
153 		case ED_spiral_outward_right:return AnimationEffect_SPIRALOUT_RIGHT;
154 		default:					return AnimationEffect_FADE_FROM_LEFT;
155 		}
156 	case EK_move:
157 		if( nStartScale == 200 )
158 		{
159 			return AnimationEffect_ZOOM_OUT_SMALL;
160 		}
161 		else if( nStartScale == 50 )
162 		{
163 			return AnimationEffect_ZOOM_IN_SMALL;
164 		}
165 		else if( nStartScale < 100 )
166 		{
167 			switch( eDirection )
168 			{
169 			case ED_from_left:			return AnimationEffect_ZOOM_IN_FROM_LEFT;
170 			case ED_from_top:			return AnimationEffect_ZOOM_IN_FROM_TOP;
171 			case ED_from_right:			return AnimationEffect_ZOOM_IN_FROM_RIGHT;
172 			case ED_from_bottom:		return AnimationEffect_ZOOM_IN_FROM_BOTTOM;
173 			case ED_from_upperleft:		return AnimationEffect_ZOOM_IN_FROM_UPPERLEFT;
174 			case ED_from_upperright:	return AnimationEffect_ZOOM_IN_FROM_UPPERRIGHT;
175 			case ED_from_lowerleft:		return AnimationEffect_ZOOM_IN_FROM_LOWERLEFT;
176 			case ED_from_lowerright:	return AnimationEffect_ZOOM_IN_FROM_LOWERRIGHT;
177 			case ED_from_center:		return AnimationEffect_ZOOM_IN_FROM_CENTER;
178 			case ED_spiral_inward_left:	return AnimationEffect_ZOOM_IN_SPIRAL;
179 			case ED_to_left:			return AnimationEffect_MOVE_TO_LEFT;
180 			case ED_to_top:				return AnimationEffect_MOVE_TO_TOP;
181 			case ED_to_right:			return AnimationEffect_MOVE_TO_RIGHT;
182 			case ED_to_bottom:			return AnimationEffect_MOVE_TO_BOTTOM;
183 			case ED_to_upperleft:		return AnimationEffect_MOVE_TO_UPPERLEFT;
184 			case ED_to_upperright:		return AnimationEffect_MOVE_TO_UPPERRIGHT;
185 			case ED_to_lowerright:		return AnimationEffect_MOVE_TO_LOWERRIGHT;
186 			case ED_to_lowerleft:		return AnimationEffect_MOVE_TO_LOWERLEFT;
187 			default:					return AnimationEffect_ZOOM_IN;
188 			}
189 		}
190 		else if( nStartScale > 100 )
191 		{
192 			switch( eDirection )
193 			{
194 			case ED_from_left:			return AnimationEffect_ZOOM_OUT_FROM_LEFT;
195 			case ED_from_top:			return AnimationEffect_ZOOM_OUT_FROM_TOP;
196 			case ED_from_right:			return AnimationEffect_ZOOM_OUT_FROM_RIGHT;
197 			case ED_from_bottom:		return AnimationEffect_ZOOM_OUT_FROM_BOTTOM;
198 			case ED_from_upperleft:		return AnimationEffect_ZOOM_OUT_FROM_UPPERLEFT;
199 			case ED_from_upperright:	return AnimationEffect_ZOOM_OUT_FROM_UPPERRIGHT;
200 			case ED_from_lowerleft:		return AnimationEffect_ZOOM_OUT_FROM_LOWERLEFT;
201 			case ED_from_lowerright:	return AnimationEffect_ZOOM_OUT_FROM_LOWERRIGHT;
202 			case ED_from_center:		return AnimationEffect_ZOOM_OUT_FROM_CENTER;
203 			case ED_spiral_inward_left:	return AnimationEffect_ZOOM_OUT_SPIRAL;
204 			default:					return AnimationEffect_ZOOM_OUT;
205 			}
206 		}
207 		else
208 		{
209 			switch( eDirection )
210 			{
211 			case ED_from_left:			return AnimationEffect_MOVE_FROM_LEFT;
212 			case ED_from_top:			return AnimationEffect_MOVE_FROM_TOP;
213 			case ED_from_right:			return AnimationEffect_MOVE_FROM_RIGHT;
214 			case ED_from_bottom:		return AnimationEffect_MOVE_FROM_BOTTOM;
215 			case ED_from_upperleft:		return AnimationEffect_MOVE_FROM_UPPERLEFT;
216 			case ED_from_upperright:	return AnimationEffect_MOVE_FROM_UPPERRIGHT;
217 			case ED_from_lowerleft:		return AnimationEffect_MOVE_FROM_LOWERLEFT;
218 			case ED_from_lowerright:	return AnimationEffect_MOVE_FROM_LOWERRIGHT;
219 			case ED_path:				return AnimationEffect_PATH;
220 			case ED_to_top:				return AnimationEffect_MOVE_TO_TOP;
221 			case ED_to_right:			return AnimationEffect_MOVE_TO_RIGHT;
222 			case ED_to_bottom:			return AnimationEffect_MOVE_TO_BOTTOM;
223 			case ED_to_upperleft:		return AnimationEffect_MOVE_TO_UPPERLEFT;
224 			case ED_to_upperright:		return AnimationEffect_MOVE_TO_UPPERRIGHT;
225 			case ED_to_lowerright:		return AnimationEffect_MOVE_TO_LOWERRIGHT;
226 			case ED_to_lowerleft:		return AnimationEffect_MOVE_TO_LOWERLEFT;
227 			default:
228 				break;
229 			}
230 		}
231 		return AnimationEffect_MOVE_FROM_LEFT;
232 	case EK_stripes:
233 		if( eDirection == ED_vertical )
234 			return AnimationEffect_VERTICAL_STRIPES;
235 		else
236 			return AnimationEffect_HORIZONTAL_STRIPES;
237 	case EK_open:
238 		if( eDirection == ED_vertical )
239 			return AnimationEffect_OPEN_VERTICAL;
240 		else
241 			return AnimationEffect_OPEN_HORIZONTAL;
242 	case EK_close:
243 		if( eDirection == ED_vertical )
244 			return AnimationEffect_CLOSE_VERTICAL;
245 		else
246 			return AnimationEffect_CLOSE_HORIZONTAL;
247 	case EK_dissolve:
248 		return AnimationEffect_DISSOLVE;
249 	case EK_wavyline:
250 		switch( eDirection )
251 		{
252 		case ED_from_left:			return AnimationEffect_WAVYLINE_FROM_LEFT;
253 		case ED_from_top:			return AnimationEffect_WAVYLINE_FROM_TOP;
254 		case ED_from_right:			return AnimationEffect_WAVYLINE_FROM_RIGHT;
255 		case ED_from_bottom:		return AnimationEffect_WAVYLINE_FROM_BOTTOM;
256 		default:					return AnimationEffect_WAVYLINE_FROM_LEFT;
257 		}
258 	case EK_random:
259 		return AnimationEffect_RANDOM;
260 	case EK_lines:
261 		if( eDirection == ED_vertical )
262 			return AnimationEffect_VERTICAL_LINES;
263 		else
264 			return AnimationEffect_HORIZONTAL_LINES;
265 	case EK_laser:
266 		switch( eDirection )
267 		{
268 		case ED_from_left:			return AnimationEffect_LASER_FROM_LEFT;
269 		case ED_from_top:			return AnimationEffect_LASER_FROM_TOP;
270 		case ED_from_right:			return AnimationEffect_LASER_FROM_RIGHT;
271 		case ED_from_bottom:		return AnimationEffect_LASER_FROM_BOTTOM;
272 		case ED_from_upperleft:		return AnimationEffect_LASER_FROM_UPPERLEFT;
273 		case ED_from_upperright:	return AnimationEffect_LASER_FROM_UPPERRIGHT;
274 		case ED_from_lowerleft:		return AnimationEffect_LASER_FROM_LOWERLEFT;
275 		case ED_from_lowerright:	return AnimationEffect_LASER_FROM_LOWERRIGHT;
276 		default:					return AnimationEffect_LASER_FROM_LEFT;
277 		}
278 	case EK_appear:
279 		return AnimationEffect_APPEAR;
280 	case EK_hide:
281 		return AnimationEffect_HIDE;
282 	case EK_move_short:
283 		switch( eDirection )
284 		{
285 		case ED_from_left:			return AnimationEffect_MOVE_SHORT_FROM_LEFT;
286 		case ED_from_top:			return AnimationEffect_MOVE_SHORT_FROM_TOP;
287 		case ED_from_right:			return AnimationEffect_MOVE_SHORT_FROM_RIGHT;
288 		case ED_from_bottom:		return AnimationEffect_MOVE_SHORT_FROM_BOTTOM;
289 		case ED_from_upperleft:		return AnimationEffect_MOVE_SHORT_FROM_UPPERLEFT;
290 		case ED_from_upperright:	return AnimationEffect_MOVE_SHORT_FROM_UPPERRIGHT;
291 		case ED_from_lowerleft:		return AnimationEffect_MOVE_SHORT_FROM_LOWERLEFT;
292 		case ED_from_lowerright:	return AnimationEffect_MOVE_SHORT_FROM_LOWERRIGHT;
293 		case ED_to_left:			return AnimationEffect_MOVE_SHORT_TO_LEFT;
294 		case ED_to_upperleft:		return AnimationEffect_MOVE_SHORT_TO_UPPERLEFT;
295 		case ED_to_top:				return AnimationEffect_MOVE_SHORT_TO_TOP;
296 		case ED_to_upperright:		return AnimationEffect_MOVE_SHORT_TO_UPPERRIGHT;
297 		case ED_to_right:			return AnimationEffect_MOVE_SHORT_TO_RIGHT;
298 		case ED_to_lowerright:		return AnimationEffect_MOVE_SHORT_TO_LOWERRIGHT;
299 		case ED_to_bottom:			return AnimationEffect_MOVE_SHORT_TO_BOTTOM;
300 		case ED_to_lowerleft:		return AnimationEffect_MOVE_SHORT_TO_LOWERLEFT;
301 		default:					return AnimationEffect_MOVE_SHORT_FROM_LEFT;
302 		}
303 	case EK_checkerboard:
304 		if( eDirection == ED_vertical )
305 			return AnimationEffect_VERTICAL_CHECKERBOARD;
306 		else
307 			return AnimationEffect_HORIZONTAL_CHECKERBOARD;
308 	case EK_rotate:
309 		if( eDirection == ED_vertical )
310 			return AnimationEffect_VERTICAL_ROTATE;
311 		else
312 			return AnimationEffect_HORIZONTAL_ROTATE;
313 	case EK_stretch:
314 		switch( eDirection )
315 		{
316 		case ED_from_left:			return AnimationEffect_STRETCH_FROM_LEFT;
317 		case ED_from_top:			return AnimationEffect_STRETCH_FROM_TOP;
318 		case ED_from_right:			return AnimationEffect_STRETCH_FROM_RIGHT;
319 		case ED_from_bottom:		return AnimationEffect_STRETCH_FROM_BOTTOM;
320 		case ED_from_upperleft:		return AnimationEffect_STRETCH_FROM_UPPERLEFT;
321 		case ED_from_upperright:	return AnimationEffect_STRETCH_FROM_UPPERRIGHT;
322 		case ED_from_lowerleft:		return AnimationEffect_STRETCH_FROM_LOWERLEFT;
323 		case ED_from_lowerright:	return AnimationEffect_STRETCH_FROM_LOWERRIGHT;
324 		case ED_vertical:			return AnimationEffect_VERTICAL_STRETCH;
325 		case ED_horizontal:			return AnimationEffect_HORIZONTAL_STRETCH;
326 		default:
327 			break;
328 		}
329 		return AnimationEffect_STRETCH_FROM_LEFT;
330 	default:
331 		return AnimationEffect_NONE;
332 	}
333 }
334 
335 ///////////////////////////////////////////////////////////////////////
336 
337 class AnimImpImpl
338 {
339 public:
340 	Reference< XPropertySet > mxLastShape;
341 	OUString maLastShapeId;
342 
343 	OUString msDimColor;
344 	OUString msDimHide;
345 	OUString msDimPrev;
346 	OUString msEffect;
347 	OUString msPlayFull;
348 	OUString msPresOrder;
349 	OUString msSound;
350 	OUString msSoundOn;
351 	OUString msSpeed;
352 	OUString msTextEffect;
353 	OUString msPresShapeService;
354 	OUString msAnimPath;
355 	OUString msIsAnimation;
356 
357 	AnimImpImpl()
358 	:	msDimColor( RTL_CONSTASCII_USTRINGPARAM( "DimColor" ) ),
359 		msDimHide( RTL_CONSTASCII_USTRINGPARAM( "DimHide" ) ),
360 		msDimPrev( RTL_CONSTASCII_USTRINGPARAM( "DimPrevious" ) ),
361 		msEffect( RTL_CONSTASCII_USTRINGPARAM( "Effect" ) ),
362 		msPlayFull( RTL_CONSTASCII_USTRINGPARAM( "PlayFull" ) ),
363 		msPresOrder( RTL_CONSTASCII_USTRINGPARAM( "PresentationOrder" ) ),
364 		msSound( RTL_CONSTASCII_USTRINGPARAM( "Sound" ) ),
365 		msSoundOn( RTL_CONSTASCII_USTRINGPARAM( "SoundOn" ) ),
366 		msSpeed( RTL_CONSTASCII_USTRINGPARAM( "Speed" ) ),
367 		msTextEffect( RTL_CONSTASCII_USTRINGPARAM( "TextEffect" ) ),
368 		msPresShapeService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.Shape" ) ),
369 		msAnimPath( RTL_CONSTASCII_USTRINGPARAM( "AnimationPath" ) ),
370 		msIsAnimation( RTL_CONSTASCII_USTRINGPARAM( "IsAnimation" ) )
371 	{}
372 };
373 
374 ///////////////////////////////////////////////////////////////////////
375 
376 enum XMLActionKind
377 {
378 	XMLE_SHOW,
379 	XMLE_HIDE,
380 	XMLE_DIM,
381 	XMLE_PLAY
382 };
383 
384 class XMLAnimationsEffectContext : public SvXMLImportContext
385 {
386 public:
387 	AnimImpImpl*	mpImpl;
388 
389 	XMLActionKind	meKind;
390 	sal_Bool		mbTextEffect;
391 	OUString		maShapeId;
392 
393 	XMLEffect		meEffect;
394 	XMLEffectDirection	meDirection;
395 	sal_Int16		mnStartScale;
396 
397 	AnimationSpeed	meSpeed;
398 	Color			maDimColor;
399 	OUString		maSoundURL;
400 	sal_Bool		mbPlayFull;
401 	OUString		maPathShapeId;
402 
403 public:
404 	TYPEINFO();
405 
406 	XMLAnimationsEffectContext( SvXMLImport& rImport,
407 		sal_uInt16 nPrfx,
408 		const OUString& rLocalName,
409 		const Reference< XAttributeList >& xAttrList,
410 		AnimImpImpl* pImpl);
411 	virtual ~XMLAnimationsEffectContext();
412 
413 	virtual void EndElement();
414 
415 	virtual SvXMLImportContext * CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName,
416 		const Reference< XAttributeList >& xAttrList );
417 };
418 
419 class XMLAnimationsSoundContext : public SvXMLImportContext
420 {
421 	XMLAnimationsEffectContext*	mpParent;
422 
423 public:
424 	TYPEINFO();
425 
426 	XMLAnimationsSoundContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, XMLAnimationsEffectContext* pParent );
427 	virtual ~XMLAnimationsSoundContext();
428 };
429 
430 TYPEINIT1( XMLAnimationsSoundContext, SvXMLImportContext );
431 
432 XMLAnimationsSoundContext::XMLAnimationsSoundContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, XMLAnimationsEffectContext* pParent )
433 : SvXMLImportContext( rImport, nPrfx, rLocalName ), mpParent( pParent )
434 {
435 	if( mpParent && nPrfx == XML_NAMESPACE_PRESENTATION && IsXMLToken( rLocalName, XML_SOUND ) )
436 	{
437 		const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
438 		for(sal_Int16 i=0; i < nAttrCount; i++)
439 		{
440 			OUString sAttrName = xAttrList->getNameByIndex( i );
441 			OUString aLocalName;
442 			sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
443 			OUString sValue = xAttrList->getValueByIndex( i );
444 
445 			switch( nPrefix )
446 			{
447 			case XML_NAMESPACE_XLINK:
448 				if( IsXMLToken( aLocalName, XML_HREF ) )
449 				{
450 					mpParent->maSoundURL = rImport.GetAbsoluteReference(sValue);
451 				}
452 				break;
453 			case XML_NAMESPACE_PRESENTATION:
454 				if( IsXMLToken( aLocalName, XML_PLAY_FULL ) )
455 				{
456 					mpParent->mbPlayFull = IsXMLToken( sValue, XML_TRUE );
457 				}
458 			}
459 		}
460 	}
461 }
462 
463 XMLAnimationsSoundContext::~XMLAnimationsSoundContext()
464 {
465 }
466 
467 
468 TYPEINIT1( XMLAnimationsEffectContext, SvXMLImportContext );
469 
470 XMLAnimationsEffectContext::XMLAnimationsEffectContext( SvXMLImport& rImport,  sal_uInt16 nPrfx, const OUString& rLocalName,  const Reference< XAttributeList >& xAttrList, AnimImpImpl* pImpl )
471 :	SvXMLImportContext(rImport, nPrfx, rLocalName),
472 	mpImpl( pImpl ),
473 	meKind( XMLE_SHOW ), mbTextEffect( sal_False ),
474 	meEffect( EK_none ), meDirection( ED_none ), mnStartScale( 100 ),
475 	meSpeed( AnimationSpeed_MEDIUM ), maDimColor(0), mbPlayFull( sal_False )
476 {
477 	if( IsXMLToken( rLocalName, XML_SHOW_SHAPE ) )
478 	{
479 		meKind = XMLE_SHOW;
480 	}
481 	else if( IsXMLToken( rLocalName, XML_SHOW_TEXT ) )
482 	{
483 		meKind = XMLE_SHOW;
484 		mbTextEffect = sal_True;
485 	}
486 	else if( IsXMLToken( rLocalName, XML_HIDE_SHAPE ) )
487 	{
488 		meKind = XMLE_HIDE;
489 	}
490 	else if( IsXMLToken( rLocalName, XML_HIDE_TEXT ) )
491 	{
492 		meKind = XMLE_HIDE;
493 		mbTextEffect = sal_True;
494 	}
495 	else if( IsXMLToken( rLocalName, XML_DIM ) )
496 	{
497 		meKind = XMLE_DIM;
498 	}
499 	else if( IsXMLToken( rLocalName, XML_PLAY ) )
500 	{
501 		meKind = XMLE_PLAY;
502 	}
503 	else
504 	{
505 		// unknown action, overread
506 		return;
507 	}
508 
509 	// read attributes
510 	const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
511 	for(sal_Int16 i=0; i < nAttrCount; i++)
512 	{
513 		OUString sAttrName = xAttrList->getNameByIndex( i );
514 		OUString aLocalName;
515 		sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
516 		OUString sValue = xAttrList->getValueByIndex( i );
517 
518 		switch( nPrefix )
519 		{
520 		case XML_NAMESPACE_DRAW:
521 			if( IsXMLToken( aLocalName, XML_SHAPE_ID ) )
522 			{
523 				maShapeId = sValue;
524 			}
525 			else if( IsXMLToken( aLocalName, XML_COLOR ) )
526 			{
527 				SvXMLUnitConverter::convertColor(maDimColor, sValue);
528 			}
529 			break;
530 
531 		case XML_NAMESPACE_PRESENTATION:
532 			if( IsXMLToken( aLocalName, XML_EFFECT ) )
533 			{
534 				sal_uInt16 eEnum;
535 				if( SvXMLUnitConverter::convertEnum( eEnum, sValue, aXML_AnimationEffect_EnumMap ) )
536 					meEffect = (XMLEffect)eEnum;
537 			}
538 			else if( IsXMLToken(aLocalName, XML_DIRECTION ) )
539 			{
540 				sal_uInt16 eEnum;
541 				if( SvXMLUnitConverter::convertEnum( eEnum, sValue, aXML_AnimationDirection_EnumMap ) )
542 					meDirection = (XMLEffectDirection)eEnum;
543 			}
544 			else if( IsXMLToken( aLocalName, XML_START_SCALE ) )
545 			{
546 				sal_Int32 nScale;
547 				if( SvXMLUnitConverter::convertPercent( nScale, sValue ) )
548 					mnStartScale = (sal_Int16)nScale;
549 			}
550 			else if( IsXMLToken( aLocalName, XML_SPEED ) )
551 			{
552 				sal_uInt16 eEnum;
553 				if( SvXMLUnitConverter::convertEnum( eEnum, sValue, aXML_AnimationSpeed_EnumMap ) )
554 					meSpeed = (AnimationSpeed)eEnum;
555 			}
556 			else if( IsXMLToken( aLocalName, XML_PATH_ID ) )
557 			{
558 				maPathShapeId = sValue;
559 			}
560 			break;
561 		}
562 	}
563 }
564 
565 XMLAnimationsEffectContext::~XMLAnimationsEffectContext()
566 {
567 }
568 
569 SvXMLImportContext * XMLAnimationsEffectContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList>& xAttrList )
570 {
571 	return new XMLAnimationsSoundContext( GetImport(), nPrefix, rLocalName, xAttrList, this );
572 }
573 
574 void XMLAnimationsEffectContext::EndElement()
575 {
576 	// set effect on shape
577 
578 	try
579 	{
580 		UniReference< XMLShapeImportHelper > xShapeImport( GetImport().GetShapeImport() );
581 		Any aAny;
582 
583 		if( maShapeId.getLength() )
584 		{
585 			Reference< XPropertySet > xSet;
586 			if( mpImpl->maLastShapeId != maShapeId )
587 			{
588 				xSet = Reference< XPropertySet >::query( GetImport().getInterfaceToIdentifierMapper().getReference( maShapeId ) );
589 				if( xSet.is() )
590 				{
591 					// check for presentation shape service
592 					{
593 						Reference< XServiceInfo > xServiceInfo( xSet, UNO_QUERY );
594 						if( !xServiceInfo.is() || !xServiceInfo->supportsService( mpImpl->msPresShapeService ) )
595 							return;
596 					}
597 
598 					mpImpl->maLastShapeId = maShapeId;
599 					mpImpl->mxLastShape = xSet;
600 				}
601 			}
602 			else
603 			{
604 				xSet = mpImpl->mxLastShape;
605 			}
606 
607 			if( xSet.is() )
608 			{
609 				if( meKind == XMLE_DIM )
610 				{
611 					aAny <<= (sal_Bool)sal_True;
612 					xSet->setPropertyValue( mpImpl->msDimPrev, aAny );
613 
614 					aAny <<= (sal_Int32)maDimColor.GetColor();
615 					xSet->setPropertyValue( mpImpl->msDimColor, aAny );
616 				}
617 				else if( meKind == XMLE_PLAY )
618 				{
619 					aAny <<= (sal_Bool)sal_True;
620 					xSet->setPropertyValue( mpImpl->msIsAnimation, aAny );
621 
622 					aAny <<= meSpeed;
623 					xSet->setPropertyValue( mpImpl->msSpeed, aAny );
624 				}
625 				else
626 				{
627 					if( meKind == XMLE_HIDE && !mbTextEffect && meEffect == EK_none )
628 					{
629 						aAny = bool2any( sal_True );
630 						xSet->setPropertyValue( mpImpl->msDimHide, aAny );
631 					}
632 					else
633 					{
634 						const AnimationEffect eEffect = ImplSdXMLgetEffect( meEffect, meDirection, mnStartScale, meKind == XMLE_SHOW );
635 
636 						xSet->setPropertyValue( mbTextEffect ? mpImpl->msTextEffect : mpImpl->msEffect, makeAny( eEffect ) );
637 						xSet->setPropertyValue( mpImpl->msSpeed, makeAny( meSpeed ) );
638 
639 						if( eEffect == AnimationEffect_PATH && maPathShapeId.getLength() )
640 						{
641 							Reference< XShape > xPath( GetImport().getInterfaceToIdentifierMapper().getReference( maPathShapeId ), UNO_QUERY );
642 							if( xPath.is() )
643 								xSet->setPropertyValue( mpImpl->msAnimPath, makeAny( xPath ) );
644 						}
645 					}
646 				}
647 			}
648 			if( maSoundURL.getLength() != 0 )
649 			{
650 				if( xSet.is() )
651 				{
652 					aAny <<= maSoundURL;
653 					xSet->setPropertyValue( mpImpl->msSound, aAny );
654 
655 					aAny <<= bool2any( mbPlayFull );
656 					xSet->setPropertyValue( mpImpl->msPlayFull, aAny );
657 
658 					aAny <<= bool2any( sal_True );
659 					xSet->setPropertyValue( mpImpl->msSoundOn, aAny );
660 				}
661 				else
662 				{
663 					DBG_ERROR("XMLAnimationsEffectContext::EndElement - Sound URL without a XPropertySet!");
664 				}
665 			}
666 		}
667 	}
668 	catch( Exception e )
669 	{
670 		DBG_ERROR( "exception catched while importing animation information!" );
671 	}
672 }
673 
674 ///////////////////////////////////////////////////////////////////////
675 
676 TYPEINIT1( XMLAnimationsContext, SvXMLImportContext );
677 
678 XMLAnimationsContext::XMLAnimationsContext( SvXMLImport& rImport, sal_uInt16 nPrfx,	const rtl::OUString& rLocalName,
679 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& )
680 : SvXMLImportContext(rImport, nPrfx, rLocalName)
681 {
682 	mpImpl = new AnimImpImpl();
683 }
684 
685 XMLAnimationsContext::~XMLAnimationsContext()
686 {
687 	delete mpImpl;
688 }
689 
690 SvXMLImportContext * XMLAnimationsContext::CreateChildContext( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName,
691 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList )
692 {
693 	return new XMLAnimationsEffectContext( GetImport(), nPrefix, rLocalName,  xAttrList, mpImpl );
694 }
695