xref: /trunk/main/xmloff/source/draw/animexp.cxx (revision 63bba73c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 
27 #include <tools/debug.hxx>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/presentation/AnimationSpeed.hpp>
30 #include "unointerfacetouniqueidentifiermapper.hxx"
31 
32 #include <list>
33 #include <comphelper/extract.hxx>
34 #include <tools/color.hxx>
35 #include <xmloff/xmltoken.hxx>
36 #include "xmloff/xmlnmspe.hxx"
37 #include <xmloff/xmluconv.hxx>
38 #include <xmloff/xmlexp.hxx>
39 #include <xmloff/xmlement.hxx>
40 #include <xmloff/nmspmap.hxx>
41 #include <xmloff/shapeexport.hxx>
42 #include "anim.hxx"
43 
44 using ::rtl::OUString;
45 using ::rtl::OUStringBuffer;
46 
47 using namespace ::std;
48 using namespace ::cppu;
49 using namespace ::com::sun::star;
50 using namespace ::com::sun::star::uno;
51 using namespace ::com::sun::star::drawing;
52 using namespace ::com::sun::star::beans;
53 using namespace ::com::sun::star::lang;
54 using namespace ::com::sun::star::presentation;
55 using namespace ::xmloff::token;
56 
57 
58 const struct Effect
59 {
60 	XMLEffect meKind;
61 	XMLEffectDirection meDirection;
62 	sal_Int16 mnStartScale;
63 	sal_Bool mbIn;
64 }
65 	AnimationEffectMap[] =
66 {
67 	{ EK_none, ED_none,				-1, sal_True },	// AnimationEffect_NONE
68 	{ EK_fade, ED_from_left,		-1, sal_True },	// AnimationEffect_FADE_FROM_LEFT
69 	{ EK_fade, ED_from_top,			-1, sal_True },	// AnimationEffect_FADE_FROM_TOP
70 	{ EK_fade, ED_from_right,		-1, sal_True },	// AnimationEffect_FADE_FROM_RIGHT
71 	{ EK_fade, ED_from_bottom,		-1, sal_True },	// AnimationEffect_FADE_FROM_BOTTOM
72 	{ EK_fade, ED_to_center,		-1, sal_True },	// AnimationEffect_FADE_TO_CENTER
73 	{ EK_fade, ED_from_center,		-1, sal_True },	// AnimationEffect_FADE_FROM_CENTER
74 	{ EK_move, ED_from_left,		-1, sal_True },	// AnimationEffect_MOVE_FROM_LEFT
75 	{ EK_move, ED_from_top,			-1, sal_True },	// AnimationEffect_MOVE_FROM_TOP
76 	{ EK_move, ED_from_right,		-1, sal_True },	// AnimationEffect_MOVE_FROM_RIGHT
77 	{ EK_move, ED_from_bottom,		-1, sal_True },	// AnimationEffect_MOVE_FROM_BOTTOM
78 	{ EK_stripes, ED_vertical,		-1, sal_True },	// AnimationEffect_VERTICAL_STRIPES
79 	{ EK_stripes, ED_horizontal,	-1, sal_True },	// AnimationEffect_HORIZONTAL_STRIPES
80 	{ EK_fade, ED_clockwise,		-1, sal_True },	// AnimationEffect_CLOCKWISE
81 	{ EK_fade, ED_cclockwise,		-1, sal_True },	// AnimationEffect_COUNTERCLOCKWISE
82 	{ EK_fade, ED_from_upperleft,	-1, sal_True },	// AnimationEffect_FADE_FROM_UPPERLEFT
83 	{ EK_fade, ED_from_upperright,	-1, sal_True },	// AnimationEffect_FADE_FROM_UPPERRIGHT
84 	{ EK_fade, ED_from_lowerleft,	-1, sal_True },	// AnimationEffect_FADE_FROM_LOWERLEFT
85 	{ EK_fade, ED_from_lowerright,	-1, sal_True },	// AnimationEffect_FADE_FROM_LOWERRIGHT
86 	{ EK_close,ED_vertical,			-1, sal_True },	// AnimationEffect_CLOSE_VERTICAL
87 	{ EK_close,ED_horizontal,		-1, sal_True },	// AnimationEffect_CLOSE_HORIZONTAL
88 	{ EK_open, ED_vertical,			-1, sal_True },	// AnimationEffect_OPEN_VERTICAL
89 	{ EK_open, ED_horizontal,		-1, sal_True },	// AnimationEffect_OPEN_HORIZONTAL
90 	{ EK_move, ED_path,				-1, sal_True },	// AnimationEffect_PATH
91 	{ EK_move, ED_to_left,			-1, sal_False },// AnimationEffect_MOVE_TO_LEFT
92 	{ EK_move, ED_to_top,			-1, sal_False },// AnimationEffect_MOVE_TO_TOP
93 	{ EK_move, ED_to_right,			-1, sal_False },// AnimationEffect_MOVE_TO_RIGHT
94 	{ EK_move, ED_to_bottom,		-1, sal_False },// AnimationEffect_MOVE_TO_BOTTOM
95 	{ EK_fade, ED_spiral_inward_left,	-1, sal_True },	// AnimationEffect_SPIRALIN_LEFT
96 	{ EK_fade, ED_spiral_inward_right,	-1, sal_True },	// AnimationEffect_SPIRALIN_RIGHT
97 	{ EK_fade, ED_spiral_outward_left,	-1, sal_True },	// AnimationEffect_SPIRALOUT_LEFT
98 	{ EK_fade, ED_spiral_outward_right,	-1, sal_True },	// AnimationEffect_SPIRALOUT_RIGHT
99 	{ EK_dissolve, ED_none,			-1, sal_True },	// AnimationEffect_DISSOLVE
100 	{ EK_wavyline, ED_from_left,	-1, sal_True },	// AnimationEffect_WAVYLINE_FROM_LEFT
101 	{ EK_wavyline, ED_from_top,		-1, sal_True },	// AnimationEffect_WAVYLINE_FROM_TOP
102 	{ EK_wavyline, ED_from_right,	-1, sal_True },	// AnimationEffect_WAVYLINE_FROM_RIGHT
103 	{ EK_wavyline, ED_from_bottom,	-1, sal_True },	// AnimationEffect_WAVYLINE_FROM_BOTTOM
104 	{ EK_random, ED_none,			-1, sal_True },	// AnimationEffect_RANDOM
105 	{ EK_lines,	ED_vertical,		-1, sal_True },	// AnimationEffect_VERTICAL_LINES
106 	{ EK_lines, ED_horizontal,		-1, sal_True },	// AnimationEffect_HORIZONTAL_LINES
107 	{ EK_laser, ED_from_left,		-1, sal_True },	// AnimationEffect_LASER_FROM_LEFT
108 	{ EK_laser, ED_from_top,		-1, sal_True },	// AnimationEffect_LASER_FROM_TOP
109 	{ EK_laser, ED_from_right,		-1, sal_True },	// AnimationEffect_LASER_FROM_RIGHT
110 	{ EK_laser, ED_from_bottom,		-1, sal_True },	// AnimationEffect_LASER_FROM_BOTTOM
111 	{ EK_laser, ED_from_upperleft,	-1, sal_True },	// AnimationEffect_LASER_FROM_UPPERLEFT
112 	{ EK_laser, ED_from_upperright, -1, sal_True },	// AnimationEffect_LASER_FROM_UPPERRIGHT
113 	{ EK_laser, ED_from_lowerleft,	-1, sal_True },	// AnimationEffect_LASER_FROM_LOWERLEFT
114 	{ EK_laser, ED_from_lowerright, -1, sal_True },	// AnimationEffect_LASER_FROM_LOWERRIGHT
115 	{ EK_appear,ED_none,			-1, sal_True },	// AnimationEffect_APPEAR
116 	{ EK_hide,	ED_none,			-1, sal_False },// AnimationEffect_HIDE
117 	{ EK_move,	ED_from_upperleft,	-1, sal_True },	// AnimationEffect_MOVE_FROM_UPPERLEFT
118 	{ EK_move,	ED_from_upperright, -1, sal_True },	// AnimationEffect_MOVE_FROM_UPPERRIGHT
119 	{ EK_move,	ED_from_lowerright, -1, sal_True },	// AnimationEffect_MOVE_FROM_LOWERRIGHT
120 	{ EK_move,	ED_from_lowerleft,	-1, sal_True },	// AnimationEffect_MOVE_FROM_LOWERLEFT
121 	{ EK_move,	ED_to_upperleft,	-1, sal_False },// AnimationEffect_MOVE_TO_UPPERLEFT
122 	{ EK_move,	ED_to_upperright,	-1, sal_False },// AnimationEffect_MOVE_TO_UPPERRIGHT
123 	{ EK_move,	ED_to_lowerright,	-1, sal_False },// AnimationEffect_MOVE_TO_LOWERRIGHT
124 	{ EK_move,	ED_to_lowerleft,	-1, sal_False },// AnimationEffect_MOVE_TO_LOWERLEFT
125 	{ EK_move_short, ED_from_left,	-1, sal_True },	// AnimationEffect_MOVE_SHORT_FROM_LEFT
126 	{ EK_move_short, ED_from_upperleft,	-1,	sal_True },	// AnimationEffect_MOVE_SHORT_FROM_UPPERLEFT
127 	{ EK_move_short, ED_from_top,		-1,	sal_True },	// AnimationEffect_MOVE_SHORT_FROM_TOP
128 	{ EK_move_short, ED_from_upperright,-1,	sal_True },	// AnimationEffect_MOVE_SHORT_FROM_UPPERRIGHT
129 	{ EK_move_short, ED_from_right,		-1,	sal_True },	// AnimationEffect_MOVE_SHORT_FROM_RIGHT
130 	{ EK_move_short, ED_from_lowerright,-1,	sal_True },	// AnimationEffect_MOVE_SHORT_FROM_LOWERRIGHT
131 	{ EK_move_short, ED_from_bottom,	-1,	sal_True },	// AnimationEffect_MOVE_SHORT_FROM_BOTTOM
132 	{ EK_move_short, ED_from_lowerleft, -1,	sal_True },	// AnimationEffect_MOVE_SHORT_FROM_LOWERLEFT
133 	{ EK_move_short, ED_to_left,		-1,	sal_False },// AnimationEffect_MOVE_SHORT_TO_LEFT
134 	{ EK_move_short, ED_to_upperleft,	-1,	sal_False },// AnimationEffect_MOVE_SHORT_TO_UPPERLEFT
135 	{ EK_move_short, ED_to_top,			-1,	sal_False },// AnimationEffect_MOVE_SHORT_TO_TOP
136 	{ EK_move_short, ED_to_upperright,	-1,	sal_False },// AnimationEffect_MOVE_SHORT_TO_UPPERRIGHT
137 	{ EK_move_short, ED_to_right,		-1,	sal_False },// AnimationEffect_MOVE_SHORT_TO_RIGHT
138 	{ EK_move_short, ED_to_lowerright,	-1,	sal_False },// AnimationEffect_MOVE_SHORT_TO_LOWERRIGHT
139 	{ EK_move_short, ED_to_bottom,		-1, sal_False },// AnimationEffect_MOVE_SHORT_TO_BOTTOM
140 	{ EK_move_short, ED_to_lowerleft,	-1, sal_False },// AnimationEffect_MOVE_SHORT_TO_LOWERLEFT
141 	{ EK_checkerboard, ED_vertical,		-1, sal_True },	// AnimationEffect_VERTICAL_CHECKERBOARD
142 	{ EK_checkerboard, ED_horizontal,	-1, sal_True },	// AnimationEffect_HORIZONTAL_CHECKERBOARD
143 	{ EK_rotate, ED_horizontal,		-1, sal_True },	// AnimationEffect_HORIZONTAL_ROTATE
144 	{ EK_rotate, ED_vertical,		-1, sal_True },	// AnimationEffect_VERTICAL_ROTATE
145 	{ EK_stretch,ED_horizontal,		-1, sal_True },	// AnimationEffect_HORIZONTAL_STRETCH
146 	{ EK_stretch,ED_vertical,		-1, sal_True },	// AnimationEffect_VERTICAL_STRETCH
147 	{ EK_stretch,ED_from_left,		-1, sal_True },	// AnimationEffect_STRETCH_FROM_LEFT
148 	{ EK_stretch,ED_from_upperleft, -1, sal_True },	// AnimationEffect_STRETCH_FROM_UPPERLEFT
149 	{ EK_stretch,ED_from_top,		-1, sal_True },	// AnimationEffect_STRETCH_FROM_TOP
150 	{ EK_stretch,ED_from_upperright,-1, sal_True },	// AnimationEffect_STRETCH_FROM_UPPERRIGHT
151 	{ EK_stretch,ED_from_right,		-1, sal_True },	// AnimationEffect_STRETCH_FROM_RIGHT
152 	{ EK_stretch,ED_from_lowerright,-1, sal_True },	// AnimationEffect_STRETCH_FROM_LOWERRIGHT
153 	{ EK_stretch,ED_from_bottom,	-1, sal_True },	// AnimationEffect_STRETCH_FROM_BOTTOM
154 	{ EK_stretch,ED_from_lowerleft, -1, sal_True },	// AnimationEffect_STRETCH_FROM_LOWERLEFT
155 	{ EK_move,	ED_none,			 0, sal_True },	// AnimationEffect_ZOOM_IN
156 	{ EK_move,	ED_none,			50, sal_True },	// AnimationEffect_ZOOM_IN_SMALL
157 	{ EK_move,	ED_spiral_inward_left,	 0, sal_True },	// AnimationEffect_ZOOM_IN_SPIRAL
158 	{ EK_move,	ED_none,		   400, sal_True },	// AnimationEffect_ZOOM_OUT
159 	{ EK_move,	ED_none,		   200, sal_True },	// AnimationEffect_ZOOM_OUT_SMALL
160 	{ EK_move,	ED_spiral_inward_left, 400, sal_True },	// AnimationEffect_ZOOM_OUT_SPIRAL
161 	{ EK_move,	ED_from_left,		 0, sal_True },	// AnimationEffect_ZOOM_IN_FROM_LEFT
162 	{ EK_move,	ED_from_upperleft,	 0, sal_True },	// AnimationEffect_ZOOM_IN_FROM_UPPERLEFT
163 	{ EK_move,	ED_from_top,		 0, sal_True },	// AnimationEffect_ZOOM_IN_FROM_TOP
164 	{ EK_move,	ED_from_upperright,	 0, sal_True },	// AnimationEffect_ZOOM_IN_FROM_UPPERRIGHT
165 	{ EK_move,	ED_from_right,		 0, sal_True },	// AnimationEffect_ZOOM_IN_FROM_RIGHT
166 	{ EK_move,	ED_from_lowerright,  0, sal_True },	// AnimationEffect_ZOOM_IN_FROM_LOWERRIGHT
167 	{ EK_move,	ED_from_bottom,		 0, sal_True },	// AnimationEffect_ZOOM_IN_FROM_BOTTOM
168 	{ EK_move,	ED_from_lowerleft,	 0, sal_True },	// AnimationEffect_ZOOM_IN_FROM_LOWERLEFT
169 	{ EK_move,	ED_from_center,		 0, sal_True },	// AnimationEffect_ZOOM_IN_FROM_CENTER
170 	{ EK_move,	ED_from_left,	   400, sal_True },	// AnimationEffect_ZOOM_OUT_FROM_LEFT
171 	{ EK_move,	ED_from_upperleft, 400, sal_True },	// AnimationEffect_ZOOM_OUT_FROM_UPPERLEFT
172 	{ EK_move,	ED_from_top,	   400, sal_True },	// AnimationEffect_ZOOM_OUT_FROM_TOP
173 	{ EK_move,	ED_from_upperright,400, sal_True },	// AnimationEffect_ZOOM_OUT_FROM_UPPERRIGHT
174 	{ EK_move,	ED_from_right,	   400, sal_True },	// AnimationEffect_ZOOM_OUT_FROM_RIGHT
175 	{ EK_move,	ED_from_lowerright,400, sal_True },	// AnimationEffect_ZOOM_OUT_FROM_LOWERRIGHT
176 	{ EK_move,	ED_from_bottom,	   400, sal_True },	// AnimationEffect_ZOOM_OUT_FROM_BOTTOM
177 	{ EK_move,	ED_from_lowerleft, 400, sal_True },	// AnimationEffect_ZOOM_OUT_FROM_LOWERLEFT
178 	{ EK_move,	ED_from_center,	   400, sal_True }	// AnimationEffect_ZOOM_OUT_FROM_CENTER
179 };
180 
SdXMLImplSetEffect(AnimationEffect eEffect,XMLEffect & eKind,XMLEffectDirection & eDirection,sal_Int16 & nStartScale,sal_Bool & bIn)181 void SdXMLImplSetEffect( AnimationEffect eEffect, XMLEffect& eKind, XMLEffectDirection& eDirection, sal_Int16& nStartScale, sal_Bool& bIn )
182 {
183 	if( eEffect < AnimationEffect_NONE || eEffect > AnimationEffect_ZOOM_OUT_FROM_CENTER )
184 	{
185 		DBG_ERROR( "unknown animation effect!" );
186 		eEffect = AnimationEffect_NONE;
187 	}
188 
189 	const Effect& rEffect = AnimationEffectMap[eEffect];
190 	eKind = rEffect.meKind;
191 	eDirection = rEffect.meDirection;
192 	nStartScale = rEffect.mnStartScale;
193 	bIn = rEffect.mbIn;
194 }
195 
196 enum XMLActionKind
197 {
198 	XMLE_SHOW,
199 	XMLE_HIDE,
200 	XMLE_DIM,
201 	XMLE_PLAY
202 };
203 
204 struct XMLEffectHint
205 {
206 	XMLActionKind	meKind;
207 	sal_Bool		mbTextEffect;
208 	Reference<XShape> mxShape;
209 
210 	XMLEffect		meEffect;
211 	XMLEffectDirection	meDirection;
212 	sal_Int16		mnStartScale;
213 
214 	AnimationSpeed	meSpeed;
215 	Color			maDimColor;
216 	OUString		maSoundURL;
217 	sal_Bool		mbPlayFull;
218 	sal_Int32		mnPresId;
219 	sal_Int32		mnPathShapeId;
220 
operator <XMLEffectHint221 	int operator<(const XMLEffectHint& rComp) const { return mnPresId < rComp.mnPresId; }
222 
XMLEffectHintXMLEffectHint223 	XMLEffectHint()
224 	:	meKind( XMLE_SHOW ), mbTextEffect( sal_False ),
225 		meEffect( EK_none ), meDirection( ED_none ), mnStartScale( -1 ),
226 		meSpeed( AnimationSpeed_SLOW ), maDimColor(0), mbPlayFull( sal_False ),
227 		mnPresId( 0 ), mnPathShapeId( -1 )
228 		{}
229 };
230 
231 class AnimExpImpl
232 {
233 public:
234 	list<XMLEffectHint> maEffects;
235 	UniReference< XMLShapeExport > mxShapeExp;
236 
237 	OUString msDimColor;
238 	OUString msDimHide;
239 	OUString msDimPrev;
240 	OUString msEffect;
241 	OUString msPlayFull;
242 	OUString msPresOrder;
243 	OUString msSound;
244 	OUString msSoundOn;
245 	OUString msSpeed;
246 	OUString msTextEffect;
247 	OUString msIsAnimation;
248 	OUString msAnimPath;
249 
AnimExpImpl()250 	AnimExpImpl()
251 	:	msDimColor( RTL_CONSTASCII_USTRINGPARAM( "DimColor" ) ),
252 		msDimHide( RTL_CONSTASCII_USTRINGPARAM( "DimHide" ) ),
253 		msDimPrev( RTL_CONSTASCII_USTRINGPARAM( "DimPrevious" ) ),
254 		msEffect( RTL_CONSTASCII_USTRINGPARAM( "Effect" ) ),
255 		msPlayFull( RTL_CONSTASCII_USTRINGPARAM( "PlayFull" ) ),
256 		msPresOrder( RTL_CONSTASCII_USTRINGPARAM( "PresentationOrder" ) ),
257 		msSound( RTL_CONSTASCII_USTRINGPARAM( "Sound" ) ),
258 		msSoundOn( RTL_CONSTASCII_USTRINGPARAM( "SoundOn" ) ),
259 		msSpeed( RTL_CONSTASCII_USTRINGPARAM( "Speed" ) ),
260 		msTextEffect( RTL_CONSTASCII_USTRINGPARAM( "TextEffect" ) ),
261 		msIsAnimation( RTL_CONSTASCII_USTRINGPARAM( "IsAnimation" ) ),
262 		msAnimPath( RTL_CONSTASCII_USTRINGPARAM( "AnimationPath" ) )
263 	{}
264 };
265 
XMLAnimationsExporter(XMLShapeExport * pShapeExp)266 XMLAnimationsExporter::XMLAnimationsExporter( XMLShapeExport* pShapeExp )
267 {
268 	mpImpl = new AnimExpImpl;
269 	mpImpl->mxShapeExp = pShapeExp;
270 }
271 
~XMLAnimationsExporter()272 XMLAnimationsExporter::~XMLAnimationsExporter()
273 {
274 	delete mpImpl;
275 	mpImpl = NULL;
276 }
277 
prepare(Reference<XShape> xShape,SvXMLExport &)278 void XMLAnimationsExporter::prepare( Reference< XShape > xShape, SvXMLExport& )
279 {
280 	try
281 	{
282 		// check for presentation shape service
283 		{
284 			Reference< XServiceInfo > xServiceInfo( xShape, UNO_QUERY );
285 			if( !xServiceInfo.is() || !xServiceInfo->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.Shape" ) ) ) )
286 				return;
287 		}
288 
289 		Reference< XPropertySet > xProps( xShape, UNO_QUERY );
290 		if( xProps.is() )
291 		{
292 			AnimationEffect eEffect;
293 			xProps->getPropertyValue( mpImpl->msEffect ) >>= eEffect;
294 			if( eEffect == AnimationEffect_PATH )
295 			{
296 				Reference< XShape > xPath;
297 				xProps->getPropertyValue( mpImpl->msAnimPath ) >>= xPath;
298 // strip		if( xPath.is() )
299 // strip			mrExport.getInterfaceToIdentifierMapper()->registerReference( xShape );
300 // strip			mpImpl->mxShapeExp->createShapeId( xPath );
301 			}
302 		}
303 	}
304 	catch( Exception e )
305 	{
306 		DBG_ERROR("exception catched while collection animation information!");
307 	}
308 }
309 
collect(Reference<XShape> xShape,SvXMLExport & rExport)310 void XMLAnimationsExporter::collect( Reference< XShape > xShape, SvXMLExport& rExport )
311 {
312 	try
313 	{
314 		// check for presentation shape service
315 		{
316 			Reference< XServiceInfo > xServiceInfo( xShape, UNO_QUERY );
317 			if( !xServiceInfo.is() || !xServiceInfo->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.Shape" ) ) ) )
318 				return;
319 		}
320 
321 		Reference< XPropertySet > xProps( xShape, UNO_QUERY );
322 		if( xProps.is() )
323 		{
324 			const OUString aEmptyStr;
325 
326 			Reference< XPropertySetInfo > xInfo( xProps->getPropertySetInfo() );
327 			AnimationEffect eEffect;
328 			XMLEffectHint aEffect;
329 
330 			if( any2bool( xProps->getPropertyValue( mpImpl->msSoundOn ) ) )
331 			{
332 				xProps->getPropertyValue( mpImpl->msSound ) >>= aEffect.maSoundURL;
333 				xProps->getPropertyValue( mpImpl->msPlayFull ) >>= aEffect.mbPlayFull;
334 			}
335 
336 			xProps->getPropertyValue( mpImpl->msPresOrder ) >>= aEffect.mnPresId;
337 			xProps->getPropertyValue( mpImpl->msSpeed ) >>= aEffect.meSpeed;
338 
339 
340 			sal_Bool bIsAnimation = false;
341 			xProps->getPropertyValue( mpImpl->msIsAnimation ) >>= bIsAnimation;
342 			if( bIsAnimation )
343 			{
344 				aEffect.meKind = XMLE_PLAY;
345 
346 				if( !aEffect.mxShape.is() )
347 				{
348 					rExport.getInterfaceToIdentifierMapper().registerReference( xShape );
349 					aEffect.mxShape = xShape;
350 				}
351 
352 				mpImpl->maEffects.push_back( aEffect );
353 			}
354 
355 			{
356 
357 				xProps->getPropertyValue( mpImpl->msEffect ) >>= eEffect;
358 				if( eEffect != AnimationEffect_NONE )
359 				{
360 					sal_Bool bIn = sal_True;
361 					SdXMLImplSetEffect( eEffect, aEffect.meEffect, aEffect.meDirection, aEffect.mnStartScale, bIn );
362 
363 					aEffect.meKind = bIn ? XMLE_SHOW : XMLE_HIDE;
364 
365 					if( !aEffect.mxShape.is() )
366 					{
367 						rExport.getInterfaceToIdentifierMapper().registerReference( xShape );
368 						aEffect.mxShape = xShape;
369 					}
370 
371 					if( eEffect == AnimationEffect_PATH )
372 					{
373 						Reference< XShape > xPath;
374 						xProps->getPropertyValue( mpImpl->msAnimPath ) >>= xPath;
375 						if( xPath.is() )
376 						{
377 // strip					mpImpl->mxShapeExp->createShapeId( xPath );
378 // strip					aEffect.mnPathShapeId = mpImpl->mxShapeExp->getShapeId( xPath );
379 						}
380 					}
381 					mpImpl->maEffects.push_back( aEffect );
382 
383 					aEffect.mnPathShapeId = -1;
384 					aEffect.maSoundURL = aEmptyStr;
385 				}
386 
387 				xProps->getPropertyValue( mpImpl->msTextEffect ) >>= eEffect;
388 				if( eEffect != AnimationEffect_NONE )
389 				{
390 					sal_Bool bIn = sal_True;
391 					SdXMLImplSetEffect( eEffect, aEffect.meEffect, aEffect.meDirection, aEffect.mnStartScale, bIn );
392 					aEffect.meKind = bIn ? XMLE_SHOW : XMLE_HIDE;
393 					aEffect.mbTextEffect = sal_True;
394 
395 					if( !aEffect.mxShape.is() )
396 					{
397 						rExport.getInterfaceToIdentifierMapper().registerReference( xShape );
398 						aEffect.mxShape = xShape;
399 					}
400 
401 					mpImpl->maEffects.push_back( aEffect );
402 					aEffect.mbTextEffect = sal_False;
403 					aEffect.maSoundURL = aEmptyStr;
404 				}
405 
406 				sal_Bool bDimPrev = false;
407 				sal_Bool bDimHide = false;
408 				xProps->getPropertyValue( mpImpl->msDimPrev ) >>= bDimPrev;
409 				xProps->getPropertyValue( mpImpl->msDimHide ) >>= bDimHide;
410 				if( bDimPrev || bDimHide )
411 				{
412 					aEffect.meKind = bDimPrev ? XMLE_DIM : XMLE_HIDE;
413 					aEffect.meEffect = EK_none;
414 					aEffect.meDirection = ED_none;
415 					aEffect.meSpeed = AnimationSpeed_MEDIUM;
416 					if( bDimPrev )
417 					{
418 						sal_Int32 nColor = 0;
419 						xProps->getPropertyValue( mpImpl->msDimColor ) >>= nColor;
420 						aEffect.maDimColor.SetColor( nColor );
421 					}
422 
423 					if( !aEffect.mxShape.is() )
424 					{
425 						rExport.getInterfaceToIdentifierMapper().registerReference( xShape );
426 						aEffect.mxShape = xShape;
427 					}
428 
429 					mpImpl->maEffects.push_back( aEffect );
430 					aEffect.maSoundURL = aEmptyStr;
431 				}
432 			}
433 		}
434 	}
435 	catch( Exception e )
436 	{
437 		DBG_ERROR("exception catched while collection animation information!");
438 	}
439 }
440 
exportAnimations(SvXMLExport & rExport)441 void XMLAnimationsExporter::exportAnimations( SvXMLExport& rExport )
442 {
443 	mpImpl->maEffects.sort();
444 
445 	list<XMLEffectHint>::iterator aIter = mpImpl->maEffects.begin();
446 	const list<XMLEffectHint>::iterator aEnd = mpImpl->maEffects.end();
447 
448 	OUStringBuffer sTmp;
449 
450 	if( aIter != aEnd )
451 	{
452 		SvXMLElementExport aElement( rExport, XML_NAMESPACE_PRESENTATION, XML_ANIMATIONS, sal_True, sal_True );
453 
454 		do
455 		{
456 			XMLEffectHint& rEffect = *aIter;
457 
458 			DBG_ASSERT( rEffect.mxShape.is(), "shape id creation failed for animation effect?" );
459 
460 			rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_SHAPE_ID, rExport.getInterfaceToIdentifierMapper().getIdentifier( rEffect.mxShape ) );
461 
462 			if( rEffect.meKind == XMLE_DIM )
463 			{
464 				// export a dim action;
465 
466 				SvXMLUnitConverter::convertColor( sTmp, rEffect.maDimColor );
467 				rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_COLOR, sTmp.makeStringAndClear() );
468 
469 				SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_DIM, sal_True, sal_True );
470 			}
471 			else if( rEffect.meKind == XMLE_PLAY )
472 			{
473 				if( rEffect.meSpeed != AnimationSpeed_MEDIUM )
474 				{
475 					SvXMLUnitConverter::convertEnum( sTmp, rEffect.meSpeed, aXML_AnimationSpeed_EnumMap );
476 					rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SPEED, sTmp.makeStringAndClear() );
477 				}
478 
479 				SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_PLAY, sal_True, sal_True );
480 			}
481 			else
482 			{
483 
484 				if( rEffect.meEffect != EK_none )
485 				{
486 					SvXMLUnitConverter::convertEnum( sTmp, rEffect.meEffect, aXML_AnimationEffect_EnumMap );
487 					rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_EFFECT, sTmp.makeStringAndClear() );
488 				}
489 
490 				if( rEffect.meDirection != ED_none )
491 				{
492 					SvXMLUnitConverter::convertEnum( sTmp, rEffect.meDirection, aXML_AnimationDirection_EnumMap );
493 					rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_DIRECTION, sTmp.makeStringAndClear() );
494 				}
495 
496 				if( rEffect.mnStartScale != -1 )
497 				{
498 					SvXMLUnitConverter::convertPercent( sTmp, rEffect.mnStartScale );
499 					rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_START_SCALE, sTmp.makeStringAndClear() );
500 				}
501 
502 				if( rEffect.meSpeed != AnimationSpeed_MEDIUM )
503 				{
504 					SvXMLUnitConverter::convertEnum( sTmp, rEffect.meSpeed, aXML_AnimationSpeed_EnumMap );
505 					rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SPEED, sTmp.makeStringAndClear() );
506 				}
507 
508 				if( rEffect.mnPathShapeId != -1 )
509 				{
510 					rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PATH_ID, OUString::valueOf( rEffect.mnPathShapeId ) );
511 				}
512 
513 				enum XMLTokenEnum eLocalName;
514 				if( rEffect.meKind == XMLE_SHOW )
515 				{
516 					if( rEffect.mbTextEffect )
517 						eLocalName = XML_SHOW_TEXT;
518 					else
519 						eLocalName = XML_SHOW_SHAPE;
520 				}
521 				else
522 				{
523 					if( rEffect.mbTextEffect )
524 						eLocalName = XML_HIDE_TEXT;
525 					else
526 						eLocalName = XML_HIDE_SHAPE;
527 				}
528 
529 				SvXMLElementExport aEle( rExport, XML_NAMESPACE_PRESENTATION, eLocalName, sal_True, sal_True );
530 				if( rEffect.maSoundURL.getLength() != 0 )
531 				{
532 					rExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, rExport.GetRelativeReference(rEffect.maSoundURL) );
533 					rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
534 					rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_NEW );
535 					rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONREQUEST );
536 					if( rEffect.mbPlayFull )
537 						rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PLAY_FULL, XML_TRUE );
538 
539 					SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_SOUND, sal_True, sal_True );
540 				}
541 			}
542 
543 			aIter++;
544 		}
545 		while( aIter != aEnd );
546 	}
547 
548 	mpImpl->maEffects.clear();
549 }
550