merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / draw / animexp.cxx
bloba374770a8a7a71f64243068182d32a74ddc3537a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: animexp.cxx,v $
10 * $Revision: 1.23 $
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 <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/presentation/AnimationSpeed.hpp>
37 #include "unointerfacetouniqueidentifiermapper.hxx"
39 #include <list>
40 #include <comphelper/extract.hxx>
41 #include <tools/color.hxx>
42 #include <xmloff/xmltoken.hxx>
43 #include "xmlnmspe.hxx"
44 #include <xmloff/xmluconv.hxx>
45 #include <xmloff/xmlexp.hxx>
46 #include <xmloff/xmlement.hxx>
47 #include <xmloff/nmspmap.hxx>
48 #include <xmloff/shapeexport.hxx>
49 #include "anim.hxx"
51 using ::rtl::OUString;
52 using ::rtl::OUStringBuffer;
54 using namespace ::std;
55 using namespace ::cppu;
56 using namespace ::com::sun::star;
57 using namespace ::com::sun::star::uno;
58 using namespace ::com::sun::star::drawing;
59 using namespace ::com::sun::star::beans;
60 using namespace ::com::sun::star::lang;
61 using namespace ::com::sun::star::presentation;
62 using namespace ::xmloff::token;
65 const struct Effect
67 XMLEffect meKind;
68 XMLEffectDirection meDirection;
69 sal_Int16 mnStartScale;
70 sal_Bool mbIn;
72 AnimationEffectMap[] =
74 { EK_none, ED_none, -1, sal_True }, // AnimationEffect_NONE
75 { EK_fade, ED_from_left, -1, sal_True }, // AnimationEffect_FADE_FROM_LEFT
76 { EK_fade, ED_from_top, -1, sal_True }, // AnimationEffect_FADE_FROM_TOP
77 { EK_fade, ED_from_right, -1, sal_True }, // AnimationEffect_FADE_FROM_RIGHT
78 { EK_fade, ED_from_bottom, -1, sal_True }, // AnimationEffect_FADE_FROM_BOTTOM
79 { EK_fade, ED_to_center, -1, sal_True }, // AnimationEffect_FADE_TO_CENTER
80 { EK_fade, ED_from_center, -1, sal_True }, // AnimationEffect_FADE_FROM_CENTER
81 { EK_move, ED_from_left, -1, sal_True }, // AnimationEffect_MOVE_FROM_LEFT
82 { EK_move, ED_from_top, -1, sal_True }, // AnimationEffect_MOVE_FROM_TOP
83 { EK_move, ED_from_right, -1, sal_True }, // AnimationEffect_MOVE_FROM_RIGHT
84 { EK_move, ED_from_bottom, -1, sal_True }, // AnimationEffect_MOVE_FROM_BOTTOM
85 { EK_stripes, ED_vertical, -1, sal_True }, // AnimationEffect_VERTICAL_STRIPES
86 { EK_stripes, ED_horizontal, -1, sal_True }, // AnimationEffect_HORIZONTAL_STRIPES
87 { EK_fade, ED_clockwise, -1, sal_True }, // AnimationEffect_CLOCKWISE
88 { EK_fade, ED_cclockwise, -1, sal_True }, // AnimationEffect_COUNTERCLOCKWISE
89 { EK_fade, ED_from_upperleft, -1, sal_True }, // AnimationEffect_FADE_FROM_UPPERLEFT
90 { EK_fade, ED_from_upperright, -1, sal_True }, // AnimationEffect_FADE_FROM_UPPERRIGHT
91 { EK_fade, ED_from_lowerleft, -1, sal_True }, // AnimationEffect_FADE_FROM_LOWERLEFT
92 { EK_fade, ED_from_lowerright, -1, sal_True }, // AnimationEffect_FADE_FROM_LOWERRIGHT
93 { EK_close,ED_vertical, -1, sal_True }, // AnimationEffect_CLOSE_VERTICAL
94 { EK_close,ED_horizontal, -1, sal_True }, // AnimationEffect_CLOSE_HORIZONTAL
95 { EK_open, ED_vertical, -1, sal_True }, // AnimationEffect_OPEN_VERTICAL
96 { EK_open, ED_horizontal, -1, sal_True }, // AnimationEffect_OPEN_HORIZONTAL
97 { EK_move, ED_path, -1, sal_True }, // AnimationEffect_PATH
98 { EK_move, ED_to_left, -1, sal_False },// AnimationEffect_MOVE_TO_LEFT
99 { EK_move, ED_to_top, -1, sal_False },// AnimationEffect_MOVE_TO_TOP
100 { EK_move, ED_to_right, -1, sal_False },// AnimationEffect_MOVE_TO_RIGHT
101 { EK_move, ED_to_bottom, -1, sal_False },// AnimationEffect_MOVE_TO_BOTTOM
102 { EK_fade, ED_spiral_inward_left, -1, sal_True }, // AnimationEffect_SPIRALIN_LEFT
103 { EK_fade, ED_spiral_inward_right, -1, sal_True }, // AnimationEffect_SPIRALIN_RIGHT
104 { EK_fade, ED_spiral_outward_left, -1, sal_True }, // AnimationEffect_SPIRALOUT_LEFT
105 { EK_fade, ED_spiral_outward_right, -1, sal_True }, // AnimationEffect_SPIRALOUT_RIGHT
106 { EK_dissolve, ED_none, -1, sal_True }, // AnimationEffect_DISSOLVE
107 { EK_wavyline, ED_from_left, -1, sal_True }, // AnimationEffect_WAVYLINE_FROM_LEFT
108 { EK_wavyline, ED_from_top, -1, sal_True }, // AnimationEffect_WAVYLINE_FROM_TOP
109 { EK_wavyline, ED_from_right, -1, sal_True }, // AnimationEffect_WAVYLINE_FROM_RIGHT
110 { EK_wavyline, ED_from_bottom, -1, sal_True }, // AnimationEffect_WAVYLINE_FROM_BOTTOM
111 { EK_random, ED_none, -1, sal_True }, // AnimationEffect_RANDOM
112 { EK_lines, ED_vertical, -1, sal_True }, // AnimationEffect_VERTICAL_LINES
113 { EK_lines, ED_horizontal, -1, sal_True }, // AnimationEffect_HORIZONTAL_LINES
114 { EK_laser, ED_from_left, -1, sal_True }, // AnimationEffect_LASER_FROM_LEFT
115 { EK_laser, ED_from_top, -1, sal_True }, // AnimationEffect_LASER_FROM_TOP
116 { EK_laser, ED_from_right, -1, sal_True }, // AnimationEffect_LASER_FROM_RIGHT
117 { EK_laser, ED_from_bottom, -1, sal_True }, // AnimationEffect_LASER_FROM_BOTTOM
118 { EK_laser, ED_from_upperleft, -1, sal_True }, // AnimationEffect_LASER_FROM_UPPERLEFT
119 { EK_laser, ED_from_upperright, -1, sal_True }, // AnimationEffect_LASER_FROM_UPPERRIGHT
120 { EK_laser, ED_from_lowerleft, -1, sal_True }, // AnimationEffect_LASER_FROM_LOWERLEFT
121 { EK_laser, ED_from_lowerright, -1, sal_True }, // AnimationEffect_LASER_FROM_LOWERRIGHT
122 { EK_appear,ED_none, -1, sal_True }, // AnimationEffect_APPEAR
123 { EK_hide, ED_none, -1, sal_False },// AnimationEffect_HIDE
124 { EK_move, ED_from_upperleft, -1, sal_True }, // AnimationEffect_MOVE_FROM_UPPERLEFT
125 { EK_move, ED_from_upperright, -1, sal_True }, // AnimationEffect_MOVE_FROM_UPPERRIGHT
126 { EK_move, ED_from_lowerright, -1, sal_True }, // AnimationEffect_MOVE_FROM_LOWERRIGHT
127 { EK_move, ED_from_lowerleft, -1, sal_True }, // AnimationEffect_MOVE_FROM_LOWERLEFT
128 { EK_move, ED_to_upperleft, -1, sal_False },// AnimationEffect_MOVE_TO_UPPERLEFT
129 { EK_move, ED_to_upperright, -1, sal_False },// AnimationEffect_MOVE_TO_UPPERRIGHT
130 { EK_move, ED_to_lowerright, -1, sal_False },// AnimationEffect_MOVE_TO_LOWERRIGHT
131 { EK_move, ED_to_lowerleft, -1, sal_False },// AnimationEffect_MOVE_TO_LOWERLEFT
132 { EK_move_short, ED_from_left, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_LEFT
133 { EK_move_short, ED_from_upperleft, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_UPPERLEFT
134 { EK_move_short, ED_from_top, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_TOP
135 { EK_move_short, ED_from_upperright,-1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_UPPERRIGHT
136 { EK_move_short, ED_from_right, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_RIGHT
137 { EK_move_short, ED_from_lowerright,-1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_LOWERRIGHT
138 { EK_move_short, ED_from_bottom, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_BOTTOM
139 { EK_move_short, ED_from_lowerleft, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_LOWERLEFT
140 { EK_move_short, ED_to_left, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_LEFT
141 { EK_move_short, ED_to_upperleft, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_UPPERLEFT
142 { EK_move_short, ED_to_top, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_TOP
143 { EK_move_short, ED_to_upperright, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_UPPERRIGHT
144 { EK_move_short, ED_to_right, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_RIGHT
145 { EK_move_short, ED_to_lowerright, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_LOWERRIGHT
146 { EK_move_short, ED_to_bottom, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_BOTTOM
147 { EK_move_short, ED_to_lowerleft, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_LOWERLEFT
148 { EK_checkerboard, ED_vertical, -1, sal_True }, // AnimationEffect_VERTICAL_CHECKERBOARD
149 { EK_checkerboard, ED_horizontal, -1, sal_True }, // AnimationEffect_HORIZONTAL_CHECKERBOARD
150 { EK_rotate, ED_horizontal, -1, sal_True }, // AnimationEffect_HORIZONTAL_ROTATE
151 { EK_rotate, ED_vertical, -1, sal_True }, // AnimationEffect_VERTICAL_ROTATE
152 { EK_stretch,ED_horizontal, -1, sal_True }, // AnimationEffect_HORIZONTAL_STRETCH
153 { EK_stretch,ED_vertical, -1, sal_True }, // AnimationEffect_VERTICAL_STRETCH
154 { EK_stretch,ED_from_left, -1, sal_True }, // AnimationEffect_STRETCH_FROM_LEFT
155 { EK_stretch,ED_from_upperleft, -1, sal_True }, // AnimationEffect_STRETCH_FROM_UPPERLEFT
156 { EK_stretch,ED_from_top, -1, sal_True }, // AnimationEffect_STRETCH_FROM_TOP
157 { EK_stretch,ED_from_upperright,-1, sal_True }, // AnimationEffect_STRETCH_FROM_UPPERRIGHT
158 { EK_stretch,ED_from_right, -1, sal_True }, // AnimationEffect_STRETCH_FROM_RIGHT
159 { EK_stretch,ED_from_lowerright,-1, sal_True }, // AnimationEffect_STRETCH_FROM_LOWERRIGHT
160 { EK_stretch,ED_from_bottom, -1, sal_True }, // AnimationEffect_STRETCH_FROM_BOTTOM
161 { EK_stretch,ED_from_lowerleft, -1, sal_True }, // AnimationEffect_STRETCH_FROM_LOWERLEFT
162 { EK_move, ED_none, 0, sal_True }, // AnimationEffect_ZOOM_IN
163 { EK_move, ED_none, 50, sal_True }, // AnimationEffect_ZOOM_IN_SMALL
164 { EK_move, ED_spiral_inward_left, 0, sal_True }, // AnimationEffect_ZOOM_IN_SPIRAL
165 { EK_move, ED_none, 400, sal_True }, // AnimationEffect_ZOOM_OUT
166 { EK_move, ED_none, 200, sal_True }, // AnimationEffect_ZOOM_OUT_SMALL
167 { EK_move, ED_spiral_inward_left, 400, sal_True }, // AnimationEffect_ZOOM_OUT_SPIRAL
168 { EK_move, ED_from_left, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_LEFT
169 { EK_move, ED_from_upperleft, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_UPPERLEFT
170 { EK_move, ED_from_top, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_TOP
171 { EK_move, ED_from_upperright, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_UPPERRIGHT
172 { EK_move, ED_from_right, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_RIGHT
173 { EK_move, ED_from_lowerright, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_LOWERRIGHT
174 { EK_move, ED_from_bottom, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_BOTTOM
175 { EK_move, ED_from_lowerleft, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_LOWERLEFT
176 { EK_move, ED_from_center, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_CENTER
177 { EK_move, ED_from_left, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_LEFT
178 { EK_move, ED_from_upperleft, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_UPPERLEFT
179 { EK_move, ED_from_top, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_TOP
180 { EK_move, ED_from_upperright,400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_UPPERRIGHT
181 { EK_move, ED_from_right, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_RIGHT
182 { EK_move, ED_from_lowerright,400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_LOWERRIGHT
183 { EK_move, ED_from_bottom, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_BOTTOM
184 { EK_move, ED_from_lowerleft, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_LOWERLEFT
185 { EK_move, ED_from_center, 400, sal_True } // AnimationEffect_ZOOM_OUT_FROM_CENTER
188 void SdXMLImplSetEffect( AnimationEffect eEffect, XMLEffect& eKind, XMLEffectDirection& eDirection, sal_Int16& nStartScale, sal_Bool& bIn )
190 if( eEffect < AnimationEffect_NONE || eEffect > AnimationEffect_ZOOM_OUT_FROM_CENTER )
192 DBG_ERROR( "unknown animation effect!" );
193 eEffect = AnimationEffect_NONE;
196 const Effect& rEffect = AnimationEffectMap[eEffect];
197 eKind = rEffect.meKind;
198 eDirection = rEffect.meDirection;
199 nStartScale = rEffect.mnStartScale;
200 bIn = rEffect.mbIn;
203 enum XMLActionKind
205 XMLE_SHOW,
206 XMLE_HIDE,
207 XMLE_DIM,
208 XMLE_PLAY
211 struct XMLEffectHint
213 XMLActionKind meKind;
214 sal_Bool mbTextEffect;
215 Reference<XShape> mxShape;
217 XMLEffect meEffect;
218 XMLEffectDirection meDirection;
219 sal_Int16 mnStartScale;
221 AnimationSpeed meSpeed;
222 Color maDimColor;
223 OUString maSoundURL;
224 sal_Bool mbPlayFull;
225 sal_Int32 mnPresId;
226 sal_Int32 mnPathShapeId;
228 int operator<(const XMLEffectHint& rComp) const { return mnPresId < rComp.mnPresId; }
230 XMLEffectHint()
231 : meKind( XMLE_SHOW ), mbTextEffect( sal_False ),
232 meEffect( EK_none ), meDirection( ED_none ), mnStartScale( -1 ),
233 meSpeed( AnimationSpeed_SLOW ), maDimColor(0), mbPlayFull( sal_False ),
234 mnPresId( 0 ), mnPathShapeId( -1 )
238 class AnimExpImpl
240 public:
241 list<XMLEffectHint> maEffects;
242 UniReference< XMLShapeExport > mxShapeExp;
244 OUString msDimColor;
245 OUString msDimHide;
246 OUString msDimPrev;
247 OUString msEffect;
248 OUString msPlayFull;
249 OUString msPresOrder;
250 OUString msSound;
251 OUString msSoundOn;
252 OUString msSpeed;
253 OUString msTextEffect;
254 OUString msIsAnimation;
255 OUString msAnimPath;
257 AnimExpImpl()
258 : msDimColor( RTL_CONSTASCII_USTRINGPARAM( "DimColor" ) ),
259 msDimHide( RTL_CONSTASCII_USTRINGPARAM( "DimHide" ) ),
260 msDimPrev( RTL_CONSTASCII_USTRINGPARAM( "DimPrevious" ) ),
261 msEffect( RTL_CONSTASCII_USTRINGPARAM( "Effect" ) ),
262 msPlayFull( RTL_CONSTASCII_USTRINGPARAM( "PlayFull" ) ),
263 msPresOrder( RTL_CONSTASCII_USTRINGPARAM( "PresentationOrder" ) ),
264 msSound( RTL_CONSTASCII_USTRINGPARAM( "Sound" ) ),
265 msSoundOn( RTL_CONSTASCII_USTRINGPARAM( "SoundOn" ) ),
266 msSpeed( RTL_CONSTASCII_USTRINGPARAM( "Speed" ) ),
267 msTextEffect( RTL_CONSTASCII_USTRINGPARAM( "TextEffect" ) ),
268 msIsAnimation( RTL_CONSTASCII_USTRINGPARAM( "IsAnimation" ) ),
269 msAnimPath( RTL_CONSTASCII_USTRINGPARAM( "AnimationPath" ) )
273 XMLAnimationsExporter::XMLAnimationsExporter( XMLShapeExport* pShapeExp )
275 mpImpl = new AnimExpImpl;
276 mpImpl->mxShapeExp = pShapeExp;
279 XMLAnimationsExporter::~XMLAnimationsExporter()
281 delete mpImpl;
282 mpImpl = NULL;
285 void XMLAnimationsExporter::prepare( Reference< XShape > xShape, SvXMLExport& )
289 // check for presentation shape service
291 Reference< XServiceInfo > xServiceInfo( xShape, UNO_QUERY );
292 if( !xServiceInfo.is() || !xServiceInfo->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.Shape" ) ) ) )
293 return;
296 Reference< XPropertySet > xProps( xShape, UNO_QUERY );
297 if( xProps.is() )
299 AnimationEffect eEffect;
300 xProps->getPropertyValue( mpImpl->msEffect ) >>= eEffect;
301 if( eEffect == AnimationEffect_PATH )
303 Reference< XShape > xPath;
304 xProps->getPropertyValue( mpImpl->msAnimPath ) >>= xPath;
305 // strip if( xPath.is() )
306 // strip mrExport.getInterfaceToIdentifierMapper()->registerReference( xShape );
307 // strip mpImpl->mxShapeExp->createShapeId( xPath );
311 catch( Exception e )
313 DBG_ERROR("exception catched while collection animation information!");
317 void XMLAnimationsExporter::collect( Reference< XShape > xShape, SvXMLExport& rExport )
321 // check for presentation shape service
323 Reference< XServiceInfo > xServiceInfo( xShape, UNO_QUERY );
324 if( !xServiceInfo.is() || !xServiceInfo->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.Shape" ) ) ) )
325 return;
328 Reference< XPropertySet > xProps( xShape, UNO_QUERY );
329 if( xProps.is() )
331 const OUString aEmptyStr;
333 Reference< XPropertySetInfo > xInfo( xProps->getPropertySetInfo() );
334 AnimationEffect eEffect;
335 XMLEffectHint aEffect;
337 if( any2bool( xProps->getPropertyValue( mpImpl->msSoundOn ) ) )
339 xProps->getPropertyValue( mpImpl->msSound ) >>= aEffect.maSoundURL;
340 xProps->getPropertyValue( mpImpl->msPlayFull ) >>= aEffect.mbPlayFull;
343 xProps->getPropertyValue( mpImpl->msPresOrder ) >>= aEffect.mnPresId;
344 xProps->getPropertyValue( mpImpl->msSpeed ) >>= aEffect.meSpeed;
347 sal_Bool bIsAnimation = false;
348 xProps->getPropertyValue( mpImpl->msIsAnimation ) >>= bIsAnimation;
349 if( bIsAnimation )
351 aEffect.meKind = XMLE_PLAY;
353 if( !aEffect.mxShape.is() )
355 rExport.getInterfaceToIdentifierMapper().registerReference( xShape );
356 aEffect.mxShape = xShape;
359 mpImpl->maEffects.push_back( aEffect );
364 xProps->getPropertyValue( mpImpl->msEffect ) >>= eEffect;
365 if( eEffect != AnimationEffect_NONE )
367 sal_Bool bIn = sal_True;
368 SdXMLImplSetEffect( eEffect, aEffect.meEffect, aEffect.meDirection, aEffect.mnStartScale, bIn );
370 aEffect.meKind = bIn ? XMLE_SHOW : XMLE_HIDE;
372 if( !aEffect.mxShape.is() )
374 rExport.getInterfaceToIdentifierMapper().registerReference( xShape );
375 aEffect.mxShape = xShape;
378 if( eEffect == AnimationEffect_PATH )
380 Reference< XShape > xPath;
381 xProps->getPropertyValue( mpImpl->msAnimPath ) >>= xPath;
382 if( xPath.is() )
384 // strip mpImpl->mxShapeExp->createShapeId( xPath );
385 // strip aEffect.mnPathShapeId = mpImpl->mxShapeExp->getShapeId( xPath );
388 mpImpl->maEffects.push_back( aEffect );
390 aEffect.mnPathShapeId = -1;
391 aEffect.maSoundURL = aEmptyStr;
394 xProps->getPropertyValue( mpImpl->msTextEffect ) >>= eEffect;
395 if( eEffect != AnimationEffect_NONE )
397 sal_Bool bIn = sal_True;
398 SdXMLImplSetEffect( eEffect, aEffect.meEffect, aEffect.meDirection, aEffect.mnStartScale, bIn );
399 aEffect.meKind = bIn ? XMLE_SHOW : XMLE_HIDE;
400 aEffect.mbTextEffect = sal_True;
402 if( !aEffect.mxShape.is() )
404 rExport.getInterfaceToIdentifierMapper().registerReference( xShape );
405 aEffect.mxShape = xShape;
408 mpImpl->maEffects.push_back( aEffect );
409 aEffect.mbTextEffect = sal_False;
410 aEffect.maSoundURL = aEmptyStr;
413 sal_Bool bDimPrev = false;
414 sal_Bool bDimHide = false;
415 xProps->getPropertyValue( mpImpl->msDimPrev ) >>= bDimPrev;
416 xProps->getPropertyValue( mpImpl->msDimHide ) >>= bDimHide;
417 if( bDimPrev || bDimHide )
419 aEffect.meKind = bDimPrev ? XMLE_DIM : XMLE_HIDE;
420 aEffect.meEffect = EK_none;
421 aEffect.meDirection = ED_none;
422 aEffect.meSpeed = AnimationSpeed_MEDIUM;
423 if( bDimPrev )
425 sal_Int32 nColor = 0;
426 xProps->getPropertyValue( mpImpl->msDimColor ) >>= nColor;
427 aEffect.maDimColor.SetColor( nColor );
430 if( !aEffect.mxShape.is() )
432 rExport.getInterfaceToIdentifierMapper().registerReference( xShape );
433 aEffect.mxShape = xShape;
436 mpImpl->maEffects.push_back( aEffect );
437 aEffect.maSoundURL = aEmptyStr;
442 catch( Exception e )
444 DBG_ERROR("exception catched while collection animation information!");
448 void XMLAnimationsExporter::exportAnimations( SvXMLExport& rExport )
450 mpImpl->maEffects.sort();
452 list<XMLEffectHint>::iterator aIter = mpImpl->maEffects.begin();
453 const list<XMLEffectHint>::iterator aEnd = mpImpl->maEffects.end();
455 OUStringBuffer sTmp;
457 if( aIter != aEnd )
459 SvXMLElementExport aElement( rExport, XML_NAMESPACE_PRESENTATION, XML_ANIMATIONS, sal_True, sal_True );
463 XMLEffectHint& rEffect = *aIter;
465 DBG_ASSERT( rEffect.mxShape.is(), "shape id creation failed for animation effect?" );
467 rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_SHAPE_ID, rExport.getInterfaceToIdentifierMapper().getIdentifier( rEffect.mxShape ) );
469 if( rEffect.meKind == XMLE_DIM )
471 // export a dim action;
473 SvXMLUnitConverter::convertColor( sTmp, rEffect.maDimColor );
474 rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_COLOR, sTmp.makeStringAndClear() );
476 SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_DIM, sal_True, sal_True );
478 else if( rEffect.meKind == XMLE_PLAY )
480 if( rEffect.meSpeed != AnimationSpeed_MEDIUM )
482 SvXMLUnitConverter::convertEnum( sTmp, rEffect.meSpeed, aXML_AnimationSpeed_EnumMap );
483 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SPEED, sTmp.makeStringAndClear() );
486 SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_PLAY, sal_True, sal_True );
488 else
491 if( rEffect.meEffect != EK_none )
493 SvXMLUnitConverter::convertEnum( sTmp, rEffect.meEffect, aXML_AnimationEffect_EnumMap );
494 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_EFFECT, sTmp.makeStringAndClear() );
497 if( rEffect.meDirection != ED_none )
499 SvXMLUnitConverter::convertEnum( sTmp, rEffect.meDirection, aXML_AnimationDirection_EnumMap );
500 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_DIRECTION, sTmp.makeStringAndClear() );
503 if( rEffect.mnStartScale != -1 )
505 SvXMLUnitConverter::convertPercent( sTmp, rEffect.mnStartScale );
506 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_START_SCALE, sTmp.makeStringAndClear() );
509 if( rEffect.meSpeed != AnimationSpeed_MEDIUM )
511 SvXMLUnitConverter::convertEnum( sTmp, rEffect.meSpeed, aXML_AnimationSpeed_EnumMap );
512 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SPEED, sTmp.makeStringAndClear() );
515 if( rEffect.mnPathShapeId != -1 )
517 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PATH_ID, OUString::valueOf( rEffect.mnPathShapeId ) );
520 enum XMLTokenEnum eLocalName;
521 if( rEffect.meKind == XMLE_SHOW )
523 if( rEffect.mbTextEffect )
524 eLocalName = XML_SHOW_TEXT;
525 else
526 eLocalName = XML_SHOW_SHAPE;
528 else
530 if( rEffect.mbTextEffect )
531 eLocalName = XML_HIDE_TEXT;
532 else
533 eLocalName = XML_HIDE_SHAPE;
536 SvXMLElementExport aEle( rExport, XML_NAMESPACE_PRESENTATION, eLocalName, sal_True, sal_True );
537 if( rEffect.maSoundURL.getLength() != 0 )
539 rExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, rExport.GetRelativeReference(rEffect.maSoundURL) );
540 rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
541 rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_NEW );
542 rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONREQUEST );
543 if( rEffect.mbPlayFull )
544 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PLAY_FULL, XML_TRUE );
546 SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_SOUND, sal_True, sal_True );
550 aIter++;
552 while( aIter != aEnd );
555 mpImpl->maEffects.clear();