xref: /aoo42x/main/sd/source/core/EffectMigration.cxx (revision 5b190011)
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_sd.hxx"
26 #include <com/sun/star/presentation/EffectNodeType.hpp>
27 #include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
28 #include <com/sun/star/presentation/TextAnimationType.hpp>
29 #include <com/sun/star/presentation/ParagraphTarget.hpp>
30 #include <svx/unoshape.hxx>
31 #include <svx/svdotext.hxx>
32 #include <svx/svdopath.hxx>
33 #include "drawdoc.hxx"
34 #include "sdpage.hxx"
35 #include <CustomAnimationPreset.hxx>
36 #include <TransitionPreset.hxx>
37 #include <EffectMigration.hxx>
38 #include <anminfo.hxx>
39 
40 using namespace ::vos;
41 using namespace ::sd;
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star::animations;
44 using namespace ::com::sun::star::presentation;
45 
46 using ::com::sun::star::drawing::XShape;
47 using ::rtl::OUString;
48 
49 struct deprecated_FadeEffect_conversion_table_entry
50 {
51 	FadeEffect	meFadeEffect;
52 	const sal_Char* mpPresetId;
53 }
54 deprecated_FadeEffect_conversion_table[] =
55 {
56 // OOo 1.x transitions
57 	{ FadeEffect_FADE_FROM_LEFT,			"wipe-right" },
58 	{ FadeEffect_FADE_FROM_TOP,				"wipe-down" },
59 	{ FadeEffect_FADE_FROM_RIGHT,			"wipe-left" },
60 	{ FadeEffect_FADE_FROM_BOTTOM,			"wipe-up" },
61 
62 	{ FadeEffect_CLOCKWISE,					"wheel-clockwise-1-spoke" },
63 
64 	{ FadeEffect_UNCOVER_TO_LEFT,			"uncover-left" },
65 	{ FadeEffect_UNCOVER_TO_UPPERLEFT,		"uncover-left-up" },
66 	{ FadeEffect_UNCOVER_TO_TOP,			"uncover-up" },
67 	{ FadeEffect_UNCOVER_TO_UPPERRIGHT,		"uncover-right-up" },
68 	{ FadeEffect_UNCOVER_TO_RIGHT,			"uncover-right" },
69 	{ FadeEffect_UNCOVER_TO_LOWERRIGHT,		"uncover-right-down" },
70 	{ FadeEffect_UNCOVER_TO_BOTTOM,			"uncover-down" },
71 	{ FadeEffect_UNCOVER_TO_LOWERLEFT,		"uncover-left-down" },
72 
73 	{ FadeEffect_VERTICAL_LINES,			"random-bars-vertical" },
74 	{ FadeEffect_HORIZONTAL_LINES,			"random-bars-horizontal" },
75 
76 	{ FadeEffect_VERTICAL_CHECKERBOARD,		"checkerboard-down" },
77 	{ FadeEffect_HORIZONTAL_CHECKERBOARD,	"checkerboard-across" },
78 
79 	{ FadeEffect_FADE_TO_CENTER,			"box-in" },
80 	{ FadeEffect_FADE_FROM_CENTER,			"box-out" },
81 
82 	{ FadeEffect_VERTICAL_STRIPES,			"venetian-blinds-vertical" },
83 	{ FadeEffect_HORIZONTAL_STRIPES,		"venetian-blinds-horizontal" },
84 
85 	{ FadeEffect_MOVE_FROM_LEFT,			"cover-right" },
86 	{ FadeEffect_MOVE_FROM_TOP,				"cover-down" },
87 	{ FadeEffect_MOVE_FROM_RIGHT,			"cover-left" },
88 	{ FadeEffect_MOVE_FROM_BOTTOM,			"cover-up" },
89 	{ FadeEffect_MOVE_FROM_UPPERLEFT,		"cover-right-down" },
90 	{ FadeEffect_MOVE_FROM_UPPERRIGHT,		"cover-left-down" },
91 	{ FadeEffect_MOVE_FROM_LOWERRIGHT,		"cover-left-up" },
92 	{ FadeEffect_MOVE_FROM_LOWERLEFT,		"cover-right-up" },
93 
94 	{ FadeEffect_DISSOLVE,					"dissolve" },
95 
96 	{ FadeEffect_RANDOM,					"random-transition" },
97 
98 	{ FadeEffect_ROLL_FROM_LEFT,			"push-right" },
99 	{ FadeEffect_ROLL_FROM_TOP,				"push-down" },
100 	{ FadeEffect_ROLL_FROM_RIGHT,			"push-left" },
101 	{ FadeEffect_ROLL_FROM_BOTTOM,			"push-up" },
102 
103 	{ FadeEffect_CLOSE_VERTICAL,			"split-horizontal-in" },
104 	{ FadeEffect_CLOSE_HORIZONTAL,			"split-vertical-in" },
105 	{ FadeEffect_OPEN_VERTICAL,				"split-horizontal-out" },
106 	{ FadeEffect_OPEN_HORIZONTAL,			"split-vertical-out" },
107 
108 	{ FadeEffect_FADE_FROM_UPPERLEFT,		"diagonal-squares-right-down" },
109 	{ FadeEffect_FADE_FROM_UPPERRIGHT,		"diagonal-squares-left-down" },
110 	{ FadeEffect_FADE_FROM_LOWERLEFT,		"diagonal-squares-right-up" },
111 	{ FadeEffect_FADE_FROM_LOWERRIGHT,		"diagonal-squares-left-up" },
112 
113 // OOo 1.x transitions not in OOo 2.x
114 	{ FadeEffect_CLOCKWISE,					"clock-wipe-twelve" },
115 	{ FadeEffect_COUNTERCLOCKWISE,			"reverse-clock-wipe-twelve" },
116 	{ FadeEffect_SPIRALIN_LEFT,				"spiral-wipe-top-left-clockwise" },
117 	{ FadeEffect_SPIRALIN_RIGHT,			"spiral-wipe-top-right-counter-clockwise" },
118 	{ FadeEffect_SPIRALOUT_LEFT,			"spiral-wipe-out-to-bottom-right-clockwise" },
119 	{ FadeEffect_SPIRALOUT_RIGHT,			"spiral-wipe-out-to-bottom-left-counter-clockwise" },
120 	{ FadeEffect_WAVYLINE_FROM_LEFT,		"snake-wipe-top-left-vertical" },
121 	{ FadeEffect_WAVYLINE_FROM_TOP,			"snake-wipe-top-left-horizontal" },
122 	{ FadeEffect_WAVYLINE_FROM_RIGHT,		"snake-wipe-bottom-right-vertical" },
123 	{ FadeEffect_WAVYLINE_FROM_BOTTOM,		"snake-wipe-bottom-right-horizontal" },
124 	{ FadeEffect_STRETCH_FROM_LEFT,			"wipe-right" },	// todo
125 	{ FadeEffect_STRETCH_FROM_TOP,			"wipe-down" },	// todo
126 	{ FadeEffect_STRETCH_FROM_RIGHT,		"wipe-left" },	// todo
127 	{ FadeEffect_STRETCH_FROM_BOTTOM,		"wipe-up" },	// todo
128 
129 // OOo 1.x not available transitions
130 
131 	{ FadeEffect_CLOCKWISE,					"wheel-clockwise-2-spokes" },
132 	{ FadeEffect_CLOCKWISE,					"wheel-clockwise-3-spokes" },
133 	{ FadeEffect_CLOCKWISE,					"wheel-clockwise-4-spokes" },
134 	{ FadeEffect_CLOCKWISE,					"wheel-clockwise-8-spokes" },
135 
136 	{ FadeEffect_FADE_FROM_CENTER,			"shape-circle" },
137 	{ FadeEffect_FADE_FROM_CENTER,			"shape-diamond" },
138 	{ FadeEffect_FADE_FROM_CENTER,			"shape-plus" },
139 
140 	{ FadeEffect_CLOCKWISE,					"wedge" },
141 
142 	{ FadeEffect_DISSOLVE,					"fade-through-black" },
143 
144 	{ FadeEffect_CLOCKWISE,					"zoom-rotate-in" },
145 
146 	{ FadeEffect_HORIZONTAL_LINES,			"comb-horizontal" },
147 	{ FadeEffect_VERTICAL_LINES,			"comb-vertical" },
148 
149 	{ FadeEffect_DISSOLVE,					"fade-smoothly" },
150 
151 	{ FadeEffect_NONE, 0 }
152 };
153 
154 /* todo
155 cut                             cut                                 (same as NONE?)
156 cut-through-black               cut         toBlack
157 wedge                           wedge
158 */
159 
160 void EffectMigration::SetFadeEffect( SdPage* pPage, ::com::sun::star::presentation::FadeEffect eNewEffect)
161 {
162 	deprecated_FadeEffect_conversion_table_entry* pEntry = deprecated_FadeEffect_conversion_table;
163 	while( (pEntry->meFadeEffect != FadeEffect_NONE) && (pEntry->meFadeEffect != eNewEffect) )
164 		pEntry++;
165 
166 	if( pEntry->mpPresetId )
167 	{
168 		const OUString aPresetId( OUString::createFromAscii( pEntry->mpPresetId ) );
169 
170 		const TransitionPresetList& rPresetList = TransitionPreset::getTransitionPresetList();
171 
172         TransitionPresetList::const_iterator aIt( rPresetList.begin());
173         const TransitionPresetList::const_iterator aEndIt( rPresetList.end());
174         for( ; aIt != aEndIt; ++aIt )
175         {
176             if( (*aIt)->getPresetId() == aPresetId)
177             {
178 				pPage->setTransitionType( (*aIt)->getTransition() );
179 				pPage->setTransitionSubtype( (*aIt)->getSubtype() );
180 				pPage->setTransitionDirection( (*aIt)->getDirection() );
181 				pPage->setTransitionFadeColor( (*aIt)->getFadeColor() );
182 				break;
183             }
184         }
185 	}
186 	else
187 	{
188 		pPage->setTransitionType( 0 );
189 		pPage->setTransitionSubtype( 0 );
190 		pPage->setTransitionDirection( 0 );
191 		pPage->setTransitionFadeColor( 0 );
192 	}
193 }
194 
195 FadeEffect EffectMigration::GetFadeEffect( const SdPage* pPage )
196 {
197 	const TransitionPresetList & rPresetList = TransitionPreset::getTransitionPresetList();
198     TransitionPresetList::const_iterator aIt( rPresetList.begin());
199     const TransitionPresetList::const_iterator aEndIt( rPresetList.end());
200     for( ; aIt != aEndIt; ++aIt )
201     {
202         if( ( (*aIt)->getTransition() == pPage->getTransitionType() ) &&
203 			( (*aIt)->getSubtype() == pPage->getTransitionSubtype() ) &&
204 			( (*aIt)->getDirection() == pPage->getTransitionDirection() ) &&
205 			( (*aIt)->getFadeColor() == pPage->getTransitionFadeColor() ) )
206 		{
207 			const OUString& aPresetId = (*aIt)->getPresetId();
208 
209 			deprecated_FadeEffect_conversion_table_entry* pEntry = deprecated_FadeEffect_conversion_table;
210 			while( (pEntry->meFadeEffect != FadeEffect_NONE) && (!aPresetId.equalsAscii( pEntry->mpPresetId ) ) )
211 				pEntry++;
212 
213 			return pEntry->meFadeEffect;
214 		}
215 	}
216 	return FadeEffect_NONE;
217 }
218 
219 struct deprecated_AnimationEffect_conversion_table_entry
220 {
221 	AnimationEffect	meEffect;
222 	const sal_Char* mpPresetId;
223 	const sal_Char* mpPresetSubType;
224 }
225 deprecated_AnimationEffect_conversion_table[] =
226 {
227 // OOo 1.x entrance effects
228 	{ AnimationEffect_APPEAR, "ooo-entrance-appear",0 },
229 
230 	{ AnimationEffect_FADE_TO_CENTER, "ooo-entrance-box","in" },
231 	{ AnimationEffect_FADE_FROM_CENTER, "ooo-entrance-box","out" },
232 
233 	{ AnimationEffect_VERTICAL_CHECKERBOARD, "ooo-entrance-checkerboard","downward" },
234 	{ AnimationEffect_HORIZONTAL_CHECKERBOARD, "ooo-entrance-checkerboard","across" },
235 
236 	{ AnimationEffect_FADE_FROM_UPPERLEFT, "ooo-entrance-diagonal-squares","right-to-bottom" },
237 	{ AnimationEffect_FADE_FROM_UPPERRIGHT, "ooo-entrance-diagonal-squares","left-to-bottom" },
238 	{ AnimationEffect_FADE_FROM_LOWERLEFT, "ooo-entrance-diagonal-squares","right-to-top" },
239 	{ AnimationEffect_FADE_FROM_LOWERRIGHT, "ooo-entrance-diagonal-squares","left-to-top" },
240 
241 	{ AnimationEffect_DISSOLVE, "ooo-entrance-dissolve-in",0 },
242 
243 	{ AnimationEffect_MOVE_FROM_LEFT, "ooo-entrance-fly-in","from-left" },
244 	{ AnimationEffect_MOVE_FROM_TOP, "ooo-entrance-fly-in","from-top" },
245 	{ AnimationEffect_MOVE_FROM_RIGHT, "ooo-entrance-fly-in","from-right" },
246 	{ AnimationEffect_MOVE_FROM_BOTTOM, "ooo-entrance-fly-in","from-bottom" },
247 	{ AnimationEffect_MOVE_FROM_UPPERLEFT, "ooo-entrance-fly-in","from-top-left" },
248 	{ AnimationEffect_MOVE_FROM_UPPERRIGHT, "ooo-entrance-fly-in","from-top-right" },
249 	{ AnimationEffect_MOVE_FROM_LOWERRIGHT, "ooo-entrance-fly-in","from-bottom-right" },
250 	{ AnimationEffect_MOVE_FROM_LOWERLEFT, "ooo-entrance-fly-in","from-bottom-left" },
251 
252 	{ AnimationEffect_MOVE_FROM_BOTTOM,	"ooo-entrance-fly-in-slow", "from-bottom" },
253 	{ AnimationEffect_MOVE_FROM_LEFT, "ooo-entrance-fly-in-slow", "from-left" },
254 	{ AnimationEffect_MOVE_FROM_RIGHT, "ooo-entrance-fly-in-slow", "from-right" },
255 	{ AnimationEffect_MOVE_FROM_TOP, "ooo-entrance-fly-in-slow", "from-top" },
256 
257 	{ AnimationEffect_MOVE_SHORT_FROM_LEFT, "ooo-entrance-peek-in","from-left" },
258 	{ AnimationEffect_MOVE_SHORT_FROM_TOP, "ooo-entrance-peek-in","from-top" },
259 	{ AnimationEffect_MOVE_SHORT_FROM_RIGHT, "ooo-entrance-peek-in","from-right" },
260 	{ AnimationEffect_MOVE_SHORT_FROM_BOTTOM, "ooo-entrance-peek-in","from-bottom" },
261 
262 	{ AnimationEffect_VERTICAL_LINES, "ooo-entrance-random-bars","horizontal" },
263 	{ AnimationEffect_HORIZONTAL_LINES, "ooo-entrance-random-bars","vertical" },
264 
265 	{ AnimationEffect_RANDOM, "ooo-entrance-random",0 },
266 
267 	{ AnimationEffect_CLOSE_VERTICAL, "ooo-entrance-split","horizontal-in" },
268 	{ AnimationEffect_CLOSE_HORIZONTAL, "ooo-entrance-split","vertical-in" },
269 	{ AnimationEffect_OPEN_VERTICAL, "ooo-entrance-split","horizontal-out" },
270 	{ AnimationEffect_OPEN_HORIZONTAL, "ooo-entrance-split","vertical-out" },
271 
272 	{ AnimationEffect_VERTICAL_STRIPES, "ooo-entrance-venetian-blinds","horizontal" },
273 	{ AnimationEffect_HORIZONTAL_STRIPES, "ooo-entrance-venetian-blinds","vertical" },
274 
275 	{ AnimationEffect_FADE_FROM_LEFT, "ooo-entrance-wipe","from-left" },
276 	{ AnimationEffect_FADE_FROM_TOP, "ooo-entrance-wipe","from-bottom" },
277 	{ AnimationEffect_FADE_FROM_RIGHT, "ooo-entrance-wipe","from-right" },
278 	{ AnimationEffect_FADE_FROM_BOTTOM, "ooo-entrance-wipe","from-top" },
279 
280 	{ AnimationEffect_HORIZONTAL_ROTATE, "ooo-entrance-swivel","vertical" },
281 	{ AnimationEffect_VERTICAL_ROTATE, "ooo-entrance-swivel","horizontal" },
282 
283 	{ AnimationEffect_STRETCH_FROM_LEFT, "ooo-entrance-stretchy","from-left" },
284 	{ AnimationEffect_STRETCH_FROM_UPPERLEFT, "ooo-entrance-stretchy","from-top-left" },
285 	{ AnimationEffect_STRETCH_FROM_TOP, "ooo-entrance-stretchy","from-top" },
286 	{ AnimationEffect_STRETCH_FROM_UPPERRIGHT, "ooo-entrance-stretchy","from-top-right" },
287 	{ AnimationEffect_STRETCH_FROM_RIGHT, "ooo-entrance-stretchy","from-right" },
288 	{ AnimationEffect_STRETCH_FROM_LOWERRIGHT, "ooo-entrance-stretchy","from-bottom-right" },
289 	{ AnimationEffect_STRETCH_FROM_BOTTOM, "ooo-entrance-stretchy","from-bottom" },
290 	{ AnimationEffect_STRETCH_FROM_LOWERLEFT, "ooo-entrance-stretchy","from-bottom-left" },
291 
292 	{ AnimationEffect_HORIZONTAL_STRETCH, "ooo-entrance-expand", 0 },
293 
294 	{ AnimationEffect_CLOCKWISE, "ooo-entrance-wheel","1" },
295 	{ AnimationEffect_COUNTERCLOCKWISE, "ooo-entrance-clock-wipe","counter-clockwise" },
296 
297 	{ AnimationEffect_SPIRALIN_LEFT, "ooo-entrance-spiral-wipe", "from-top-left-clockwise" },
298 	{ AnimationEffect_SPIRALIN_RIGHT, "ooo-entrance-spiral-wipe", "from-top-right-counter-clockwise" },
299 	{ AnimationEffect_SPIRALOUT_LEFT, "ooo-entrance-spiral-wipe", "from-center-clockwise" },
300 	{ AnimationEffect_SPIRALOUT_RIGHT, "ooo-entrance-spiral-wipe", "from-center-counter-clockwise" },
301 
302 	{ AnimationEffect_WAVYLINE_FROM_LEFT, "ooo-entrance-snake-wipe","from-top-left-vertical" },
303 	{ AnimationEffect_WAVYLINE_FROM_TOP, "ooo-entrance-snake-wipe","from-top-left-horizontal" },
304 	{ AnimationEffect_WAVYLINE_FROM_RIGHT, "ooo-entrance-snake-wipe","from-bottom-right-vertical" },
305 	{ AnimationEffect_WAVYLINE_FROM_BOTTOM, "ooo-entrance-snake-wipe","from-bottom-right-horizontal" },
306 
307 // ooo 1.x exit effects
308 	{ AnimationEffect_HIDE, "ooo-exit-disappear",0 },
309 	{ AnimationEffect_MOVE_TO_LEFT, "ooo-exit-fly-out", "from-right" },
310 	{ AnimationEffect_MOVE_TO_TOP, "ooo-exit-fly-out", "from-bottom" },
311 	{ AnimationEffect_MOVE_TO_RIGHT, "ooo-exit-fly-out", "from-left" },
312 	{ AnimationEffect_MOVE_TO_BOTTOM, "ooo-exit-fly-out", "from-top" },
313 	{ AnimationEffect_MOVE_TO_UPPERLEFT, "ooo-exit-fly-out", "from-top-right" },
314 	{ AnimationEffect_MOVE_TO_UPPERRIGHT, "ooo-exit-fly-out", "from-top-left" },
315 	{ AnimationEffect_MOVE_TO_LOWERRIGHT, "ooo-exit-fly-out", "from-bottom-left" },
316 	{ AnimationEffect_MOVE_TO_LOWERLEFT, "ooo-exit-fly-out", "from-bottom-right" },
317 	{ AnimationEffect_MOVE_SHORT_TO_LEFT, "ooo-exit-peek-out", "from-right" },
318 	{ AnimationEffect_MOVE_SHORT_TO_UPPERLEFT, "ooo-exit-peek-out", "from-right" },
319 	{ AnimationEffect_MOVE_SHORT_TO_TOP, "ooo-exit-peek-out", "from-bottom" },
320 	{ AnimationEffect_MOVE_SHORT_TO_UPPERRIGHT, "ooo-exit-peek-out", "from-bottom" },
321 	{ AnimationEffect_MOVE_SHORT_TO_RIGHT, "ooo-exit-peek-out", "from-left" },
322 	{ AnimationEffect_MOVE_SHORT_TO_LOWERRIGHT, "ooo-exit-peek-out","from-left" },
323 	{ AnimationEffect_MOVE_SHORT_TO_BOTTOM, "ooo-exit-peek-out", "from-top" },
324 	{ AnimationEffect_MOVE_SHORT_TO_LOWERLEFT, "ooo-exit-peek-out", "from-top" },
325 
326 // no matching in OOo 2.x
327 	{ AnimationEffect_MOVE_SHORT_FROM_UPPERLEFT, "ooo-entrance-peek-in","from-left" },
328 	{ AnimationEffect_MOVE_SHORT_FROM_UPPERRIGHT, "ooo-entrance-peek-in","from-top" },
329 	{ AnimationEffect_MOVE_SHORT_FROM_LOWERRIGHT, "ooo-entrance-peek-in","from-right" },
330 	{ AnimationEffect_MOVE_SHORT_FROM_LOWERLEFT, "ooo-entrance-peek-in","from-bottom" },
331 	{ AnimationEffect_LASER_FROM_LEFT, "ooo-entrance-fly-in","from-left" },
332 	{ AnimationEffect_LASER_FROM_TOP, "ooo-entrance-fly-in","from-top" },
333 	{ AnimationEffect_LASER_FROM_RIGHT, "ooo-entrance-fly-in","from-right" },
334 	{ AnimationEffect_LASER_FROM_BOTTOM, "ooo-entrance-fly-in","from-bottom" },
335 	{ AnimationEffect_LASER_FROM_UPPERLEFT, "ooo-entrance-fly-in","from-top-left" },
336 	{ AnimationEffect_LASER_FROM_UPPERRIGHT, "ooo-entrance-fly-in","from-top-right" },
337 	{ AnimationEffect_LASER_FROM_LOWERLEFT, "ooo-entrance-fly-in","from-bottom-left" },
338 	{ AnimationEffect_LASER_FROM_LOWERRIGHT, "ooo-entrance-fly-in","from-bottom-right" },
339 
340 // no matching in OOo 1.x
341 
342 	{ AnimationEffect_FADE_TO_CENTER, "ooo-entrance-circle", "in" },
343 	{ AnimationEffect_FADE_FROM_CENTER, "ooo-entrance-circle", "out" },
344 	{ AnimationEffect_FADE_TO_CENTER, "ooo-entrance-diamond", "in" },
345 	{ AnimationEffect_FADE_FROM_CENTER, "ooo-entrance-diamond", "out" },
346 	{ AnimationEffect_FADE_TO_CENTER, "ooo-entrance-plus", "in" },
347 	{ AnimationEffect_FADE_FROM_CENTER, "ooo-entrance-plus", "out" },
348 	{ AnimationEffect_CLOCKWISE, "ooo-entrance-wedge", 0 },
349 	{ AnimationEffect_CLOCKWISE, "ooo-entrance-wheel", "2" },
350 	{ AnimationEffect_CLOCKWISE, "ooo-entrance-wheel", "3" },
351 	{ AnimationEffect_CLOCKWISE, "ooo-entrance-wheel", "4" },
352 	{ AnimationEffect_CLOCKWISE, "ooo-entrance-wheel", "8" },
353 
354 	{ AnimationEffect_MOVE_FROM_RIGHT, "ooo-entrance-boomerang", 0 },
355 	{ AnimationEffect_MOVE_FROM_UPPERRIGHT, "ooo-entrance-bounce", 0 },
356 	{ AnimationEffect_MOVE_FROM_BOTTOM, "ooo-entrance-curve-up", 0 },
357 	{ AnimationEffect_MOVE_FROM_TOP, "ooo-entrance-float", 0 },
358 	{ AnimationEffect_MOVE_FROM_LEFT, "ooo-entrance-glide", 0 },
359 	{ AnimationEffect_MOVE_FROM_BOTTOM, "ooo-entrance-magnify", 0 },
360 	{ AnimationEffect_HORIZONTAL_ROTATE, "ooo-entrance-pinwheel", 0 },
361 	{ AnimationEffect_MOVE_FROM_LEFT, "ooo-entrance-breaks", 0 },
362 	{ AnimationEffect_MOVE_FROM_LEFT, "ooo-entrance-sling", 0 },
363 	{ AnimationEffect_MOVE_FROM_LEFT, "ooo-entrance-spiral-in", 0 },
364 	{ AnimationEffect_MOVE_FROM_LEFT, "ooo-entrance-thread", 0 },
365 	{ AnimationEffect_MOVE_FROM_BOTTOM, "ooo-entrance-ascend", 0 },
366 	{ AnimationEffect_MOVE_FROM_BOTTOM, "ooo-entrance-center-revolve", 0 },
367 	{ AnimationEffect_APPEAR, "ooo-entrance-compress", 0 },
368 	{ AnimationEffect_MOVE_SHORT_FROM_TOP, "ooo-entrance-descend", 0 },
369 	{ AnimationEffect_MOVE_SHORT_FROM_LEFT, "ooo-entrance-ease-in", 0 },
370 	{ AnimationEffect_MOVE_FROM_BOTTOM, "ooo-entrance-rise-up", 0 },
371 	{ AnimationEffect_HORIZONTAL_ROTATE, "ooo-entrance-spin-in", 0 },
372 	{ AnimationEffect_STRETCH_FROM_LEFT, "ooo-entrance-stretchy", "across" },
373 	{ AnimationEffect_STRETCH_FROM_TOP, "ooo-entrance-stretchy", "downward" },
374 
375 	{ AnimationEffect_FADE_FROM_CENTER, "ooo-entrance-zoom","in" },
376 	{ AnimationEffect_FADE_FROM_CENTER, "ooo-entrance-zoom","in-slightly" },
377 	{ AnimationEffect_FADE_FROM_CENTER, "ooo-entrance-zoom","in-from-screen-center" },
378 	{ AnimationEffect_FADE_TO_CENTER, "ooo-entrance-zoom","out" },
379 	{ AnimationEffect_FADE_TO_CENTER, "ooo-entrance-zoom","out-slightly" },
380 	{ AnimationEffect_FADE_TO_CENTER, "ooo-entrance-zoom","out-from-screen-center" },
381 
382 	{ AnimationEffect_DISSOLVE, "ooo-entrance-fade-in", 0 },
383 	{ AnimationEffect_DISSOLVE, "ooo-entrance-fade-in-and-zoom", 0 },
384 	{ AnimationEffect_DISSOLVE, "ooo-entrance-fade-in-and-swivel", 0 },
385 
386 // open
387 /*
388 	{ AnimationEffect_ZOOM_IN_FROM_LEFT, "ooo-entrance-zoom","in" },
389 	{ AnimationEffect_ZOOM_IN_FROM_UPPERLEFT, "ooo-entrance-zoom","in" },
390 	{ AnimationEffect_ZOOM_IN_FROM_TOP, "ooo-entrance-zoom","in" },
391 	{ AnimationEffect_ZOOM_IN_FROM_UPPERRIGHT, "ooo-entrance-zoom","in" },
392 	{ AnimationEffect_ZOOM_IN_FROM_RIGHT, "ooo-entrance-zoom","in" },
393 	{ AnimationEffect_ZOOM_IN_FROM_LOWERRIGHT, "ooo-entrance-zoom","in" },
394 	{ AnimationEffect_ZOOM_IN_FROM_BOTTOM, "ooo-entrance-zoom","in" },
395 	{ AnimationEffect_ZOOM_IN_FROM_LOWERLEFT, "ooo-entrance-zoom","in" },
396 	{ AnimationEffect_ZOOM_IN_FROM_CENTER, "ooo-entrance-zoom","in" },
397 
398 	{ AnimationEffect_ZOOM_OUT_FROM_LEFT, "ooo-entrance-appear",0 },
399 	{ AnimationEffect_ZOOM_OUT_FROM_UPPERLEFT, "ooo-entrance-appear",0 },
400 	{ AnimationEffect_ZOOM_OUT_FROM_TOP, "ooo-entrance-appear",0 },
401 	{ AnimationEffect_ZOOM_OUT_FROM_UPPERRIGHT, "ooo-entrance-appear",0 },
402 	{ AnimationEffect_ZOOM_OUT_FROM_RIGHT, "ooo-entrance-appear",0 },
403 	{ AnimationEffect_ZOOM_OUT_FROM_LOWERRIGHT, "ooo-entrance-appear",0 },
404 	{ AnimationEffect_ZOOM_OUT_FROM_BOTTOM, "ooo-entrance-appear",0 },
405 	{ AnimationEffect_ZOOM_OUT_FROM_LOWERLEFT, "ooo-entrance-appear",0 },
406 	{ AnimationEffect_ZOOM_OUT_FROM_CENTER, "ooo-entrance-appear",0 },
407 	{ AnimationEffect_PATH, "ooo-entrance-spiral-in",0 },
408 */
409 	{ AnimationEffect_NONE, 0, 0 }
410 };
411 
412 EffectSequence::iterator ImplFindEffect( MainSequencePtr& pMainSequence, const Reference< XShape >& rShape, sal_Int16 nSubItem )
413 {
414 	EffectSequence::iterator aIter;
415 
416 	for( aIter = pMainSequence->getBegin(); aIter != pMainSequence->getEnd(); aIter++ )
417 	{
418 		CustomAnimationEffectPtr pEffect( (*aIter) );
419 		if( (pEffect->getTargetShape() == rShape) && (pEffect->getTargetSubItem() == nSubItem) )
420 			break;
421 	}
422 
423 	return aIter;
424 }
425 
426 static bool implIsInsideGroup( SdrObject* pObj )
427 {
428 	return pObj && pObj->GetObjList() && pObj->GetObjList()->GetUpList();
429 }
430 
431 void EffectMigration::SetAnimationEffect( SvxShape* pShape, AnimationEffect eEffect )
432 {
433 	DBG_ASSERT( pShape && pShape->GetSdrObject() && pShape->GetSdrObject()->GetPage(),
434 				"sd::EffectMigration::SetAnimationEffect(), invalid argument!" );
435 	if( !pShape || !pShape->GetSdrObject() || !pShape->GetSdrObject()->GetPage() )
436 		return;
437 
438 	SdrObject* pObj = pShape->GetSdrObject();
439 	if( implIsInsideGroup( pObj ) )
440 		return;
441 
442 	OUString aPresetId;
443 	OUString aPresetSubType;
444 
445 	if( !ConvertAnimationEffect( eEffect, aPresetId, aPresetSubType ) )
446 	{
447 		DBG_ERROR( "sd::EffectMigration::SetAnimationEffect(), no mapping for given AnimationEffect value" );
448 		return;
449 	}
450 
451 	const CustomAnimationPresets& rPresets = CustomAnimationPresets::getCustomAnimationPresets();
452 
453 	CustomAnimationPresetPtr pPreset( rPresets.getEffectDescriptor( aPresetId ) );
454 	sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
455 
456 	if( pPreset.get() && pMainSequence.get() )
457 	{
458 		const Reference< XShape > xShape( pShape );
459 
460 		EffectSequence::iterator aIterOnlyBackground( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::ONLY_BACKGROUND ) );
461 		EffectSequence::iterator aIterAsWhole( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::AS_WHOLE ) );
462 		const EffectSequence::iterator aEnd( pMainSequence->getEnd() );
463 
464 		bool bEffectCreated = false;
465 
466 		if( (aIterOnlyBackground == aEnd) && (aIterAsWhole == aEnd) )
467 		{
468 			// check if there is already an text effect for this shape
469 			EffectSequence::iterator aIterOnlyText( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::ONLY_TEXT ) );
470 			if( aIterOnlyText != aEnd )
471 			{
472 				// check if this is an animation text group
473 				sal_Int32 nGroupId = (*aIterOnlyText)->getGroupId();
474 				if( nGroupId >= 0 )
475 				{
476 					CustomAnimationTextGroupPtr pGroup = pMainSequence->findGroup( nGroupId );
477 					if( pGroup.get() )
478 					{
479 						// add an effect to animate the shape
480 						pMainSequence->setAnimateForm( pGroup, true );
481 
482 						// find this effect
483 						EffectSequence::iterator aIter( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::ONLY_BACKGROUND ) );
484 
485 						if( aIter != aEnd )
486 						{
487 							if( ((*aIter)->getPresetId() != aPresetId) ||
488 								((*aIter)->getPresetSubType() != aPresetSubType) )
489 							{
490 								(*aIter)->replaceNode( pPreset->create( aPresetSubType ) );
491 								pMainSequence->rebuild();
492 								bEffectCreated = true;
493 							}
494 						}
495 					}
496 				}
497 			}
498 
499 			if( !bEffectCreated )
500 			{
501 				// if there is not yet an effect that target this shape, we generate one
502 				// we insert the shape effect before it
503 				Reference< XAnimationNode > xNode( pPreset->create( aPresetSubType ) );
504 				DBG_ASSERT( xNode.is(), "EffectMigration::SetAnimationEffect(), could not create preset!" );
505 				if( xNode.is() )
506 				{
507 					CustomAnimationEffectPtr pEffect( new CustomAnimationEffect( xNode ) );
508 					pEffect->setTarget( makeAny( xShape ) );
509 					SdPage* pPage = dynamic_cast< SdPage* >( pObj->GetPage() );
510 					const bool bManual = (pPage == 0) || (pPage->GetPresChange() == PRESCHANGE_MANUAL);
511 					if( !bManual )
512 						pEffect->setNodeType( EffectNodeType::AFTER_PREVIOUS );
513 
514 					pMainSequence->append( pEffect );
515 
516 					if( ( pObj->GetObjInventor() == SdrInventor ) && ( pObj->GetObjIdentifier() == OBJ_OUTLINETEXT ) )
517 					{
518 						// special case for outline text, effects are always mapped to text group effect
519 						pMainSequence->
520 							createTextGroup( pEffect, 10, bManual ? -1 : 0.0, sal_False, sal_False );
521 					}
522 				}
523 			}
524 		}
525 		else
526 		{
527 			// if there is already an effect targeting this shape
528 			// just replace it
529 			CustomAnimationEffectPtr pEffect;
530 			if( aIterAsWhole != aEnd )
531 			{
532 				pEffect = (*aIterAsWhole);
533 			}
534 			else
535 			{
536 				pEffect = (*aIterOnlyBackground);
537 			}
538 
539 			if( pEffect.get() )
540 			{
541 				if( (pEffect->getPresetId() != aPresetId) ||
542 					(pEffect->getPresetSubType() != aPresetSubType) )
543 				{
544 					pMainSequence->replace( pEffect, pPreset, aPresetSubType );
545 				}
546 			}
547 		}
548 	}
549 }
550 
551 // --------------------------------------------------------------------
552 
553 AnimationEffect EffectMigration::GetAnimationEffect( SvxShape* pShape )
554 {
555 	OUString aPresetId;
556 	OUString aPresetSubType;
557 
558 	SdrObject* pObj = pShape->GetSdrObject();
559 	sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
560 
561 	if( pMainSequence.get() )
562 	{
563 		const Reference< XShape > xShape( pShape );
564 
565 		EffectSequence::iterator aIter;
566 
567 		for( aIter = pMainSequence->getBegin(); aIter != pMainSequence->getEnd(); aIter++ )
568 		{
569 			CustomAnimationEffectPtr pEffect( (*aIter) );
570 			if( pEffect->getTargetShape() == xShape )
571 			{
572 				if( (pEffect->getTargetSubItem() == ShapeAnimationSubType::ONLY_BACKGROUND) ||
573 					(pEffect->getTargetSubItem() == ShapeAnimationSubType::AS_WHOLE))
574 				{
575 					if( pEffect->getDuration() != 0.1 ) // ignore appear effects created from old text effect import
576 					{
577 						aPresetId = (*aIter)->getPresetId();
578 						aPresetSubType = (*aIter)->getPresetSubType();
579 						break;
580 					}
581 				}
582 			}
583 		}
584 	}
585 
586 	// now find old effect
587 	AnimationEffect	eEffect = AnimationEffect_NONE;
588 
589 	if( !ConvertPreset( aPresetId, &aPresetSubType, eEffect ) )
590 		ConvertPreset( aPresetId, 0, eEffect );
591 
592 	return eEffect;
593 }
594 
595 
596 // --------------------------------------------------------------------
597 
598 void EffectMigration::SetTextAnimationEffect( SvxShape* pShape, AnimationEffect eEffect )
599 {
600 	DBG_ASSERT( pShape && pShape->GetSdrObject() && pShape->GetSdrObject()->GetPage(),
601 				"sd::EffectMigration::SetAnimationEffect(), invalid argument!" );
602 	if( !pShape || !pShape->GetSdrObject() || !pShape->GetSdrObject()->GetPage() )
603 		return;
604 
605 	SdrObject* pObj = pShape->GetSdrObject();
606 	if( implIsInsideGroup( pObj ) )
607 		return;
608 
609 	// first map the deprecated AnimationEffect to a preset and subtype
610 	OUString aPresetId;
611 	OUString aPresetSubType;
612 
613 	if( !ConvertAnimationEffect( eEffect, aPresetId, aPresetSubType ) )
614 	{
615 		DBG_ERROR( "sd::EffectMigration::SetAnimationEffect(), no mapping for given AnimationEffect value" );
616 		return;
617 	}
618 
619 	SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
620 
621 	// ignore old text effects on shape without text
622 	if( (pTextObj == 0) || (!pTextObj->HasText()) )
623 		return;
624 
625 	const CustomAnimationPresets& rPresets = CustomAnimationPresets::getCustomAnimationPresets();
626 
627 	// create an effect from this preset
628 	CustomAnimationPresetPtr pPreset( rPresets.getEffectDescriptor( aPresetId ) );
629 
630 	sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
631 
632 	if( pPreset.get() && pMainSequence.get() )
633 	{
634 		const Reference< XShape > xShape( pShape );
635 
636 		EffectSequence::iterator aIterOnlyText( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::ONLY_TEXT ) );
637 		const EffectSequence::iterator aEnd( pMainSequence->getEnd() );
638 
639 		CustomAnimationTextGroupPtr pGroup;
640 
641 		// is there already an animation text group for this shape?
642 		if( aIterOnlyText != aEnd )
643 		{
644 			const sal_Int32 nGroupId = (*aIterOnlyText)->getGroupId();
645 			if( nGroupId >= 0 )
646 				pGroup = pMainSequence->findGroup( nGroupId );
647 		}
648 
649 		// if there is not yet a group, create it
650 		if( pGroup.get() == 0 )
651 		{
652 			CustomAnimationEffectPtr pShapeEffect;
653 
654 			EffectSequence::iterator aIterOnlyBackground( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::ONLY_BACKGROUND ) );
655 			if( aIterOnlyBackground != aEnd )
656 			{
657 				pShapeEffect = (*aIterOnlyBackground);
658 			}
659 			else
660 			{
661 				EffectSequence::iterator aIterAsWhole( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::AS_WHOLE ) );
662 				if( aIterAsWhole != aEnd )
663 				{
664 					pShapeEffect = (*aIterAsWhole);
665 				}
666 				else
667 				{
668 					OUString aEmpty;
669 					CustomAnimationPresetPtr pShapePreset( rPresets.getEffectDescriptor( OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo-entrance-appear" ) ) ) );
670 
671 					Reference< XAnimationNode > xNode( pPreset->create( aEmpty ) );
672 					DBG_ASSERT( xNode.is(), "EffectMigration::SetTextAnimationEffect(), could not create preset!" );
673 					if( xNode.is() )
674 					{
675 						pShapeEffect.reset( new CustomAnimationEffect( xNode ) );
676 						pShapeEffect->setTarget( makeAny( xShape ) );
677 						pShapeEffect->setDuration( 0.1 );
678 						pMainSequence->append( pShapeEffect );
679 
680 						SdPage* pPage = dynamic_cast< SdPage* >( pObj->GetPage() );
681 						if( pPage && pPage->GetPresChange() != PRESCHANGE_MANUAL )
682 							pShapeEffect->setNodeType( EffectNodeType::AFTER_PREVIOUS );
683 					}
684 				}
685 			}
686 
687 			if( pShapeEffect.get() )
688 			{
689 				SdPage* pPage = dynamic_cast< SdPage* >( pObj->GetPage() );
690 				const bool bManual = (pPage == 0) || (pPage->GetPresChange() == PRESCHANGE_MANUAL);
691 
692 				// now create effects for each paragraph
693 				pGroup =
694 					pMainSequence->
695 						createTextGroup( pShapeEffect, 10, bManual ? -1 : 0.0, sal_True, sal_False );
696 			}
697 		}
698 
699 		if( pGroup.get() != 0 )
700 		{
701 			const bool bLaserEffect = (eEffect >= AnimationEffect_LASER_FROM_LEFT) && (eEffect <= AnimationEffect_LASER_FROM_LOWERRIGHT);
702 
703 			// now we have a group, so check if all effects are same as we like to have them
704 			const EffectSequence& rEffects = pGroup->getEffects();
705 
706 			EffectSequence::const_iterator aIter;
707 			for( aIter = rEffects.begin(); aIter != rEffects.end(); aIter++ )
708 			{
709 				// only work on paragraph targets
710 				if( (*aIter)->getTarget().getValueType() == ::getCppuType((const ParagraphTarget*)0) )
711 				{
712 					if( ((*aIter)->getPresetId() != aPresetId) ||
713 						((*aIter)->getPresetSubType() != aPresetSubType) )
714 					{
715 						(*aIter)->replaceNode( pPreset->create( aPresetSubType ) );
716 					}
717 
718 					if( bLaserEffect )
719                     {
720 						(*aIter)->setIterateType( TextAnimationType::BY_LETTER );
721 						(*aIter)->setIterateInterval( 0.5 );// TODO:
722                                                              // Determine
723                                                              // interval
724                                                              // according
725                                                              // to
726                                                              // total
727                                                              // effect
728                                                              // duration
729                     }
730 				}
731 			}
732 		}
733 		pMainSequence->rebuild();
734 	}
735 }
736 
737 // --------------------------------------------------------------------
738 
739 AnimationEffect EffectMigration::GetTextAnimationEffect( SvxShape* pShape )
740 {
741 	OUString aPresetId;
742 	OUString aPresetSubType;
743 
744 	SdrObject* pObj = pShape->GetSdrObject();
745 	if( pObj )
746 	{
747 		sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
748 
749 		if( pMainSequence.get() )
750 		{
751 			const Reference< XShape > xShape( pShape );
752 			EffectSequence::iterator aIter( ImplFindEffect( pMainSequence, xShape, ShapeAnimationSubType::ONLY_TEXT ) );
753 			if( aIter != pMainSequence->getEnd() )
754 			{
755 				aPresetId = (*aIter)->getPresetId();
756 				aPresetSubType = (*aIter)->getPresetSubType();
757 			}
758 		}
759 	}
760 
761 	// now find old effect
762 	AnimationEffect	eEffect = AnimationEffect_NONE;
763 
764 	if( !ConvertPreset( aPresetId, &aPresetSubType, eEffect ) )
765 		ConvertPreset( aPresetId, 0, eEffect );
766 
767 	return eEffect;
768 }
769 
770 // --------------------------------------------------------------------
771 
772 bool EffectMigration::ConvertPreset( const OUString& rPresetId, const OUString* pPresetSubType, AnimationEffect& rEffect )
773 {
774 	rEffect = AnimationEffect_NONE;
775 	if( rPresetId.getLength() )
776 	{
777 		// first try a match for preset id and subtype
778 		deprecated_AnimationEffect_conversion_table_entry* p = deprecated_AnimationEffect_conversion_table;
779 		while( p->mpPresetId )
780 		{
781 			if( rPresetId.equalsAscii( p->mpPresetId ) &&
782 				(( p->mpPresetSubType == 0 ) ||
783 				 ( pPresetSubType == 0) ||
784 				 ( pPresetSubType->equalsAscii( p->mpPresetSubType )) ) )
785 			{
786 				rEffect = p->meEffect;
787 				return true;
788 			}
789 			p++;
790 		}
791 		return false;
792 	}
793 	else
794 	{
795 		// empty preset id means AnimationEffect_NONE
796 		return true;
797 	}
798 }
799 
800 // --------------------------------------------------------------------
801 
802 bool EffectMigration::ConvertAnimationEffect( const AnimationEffect& rEffect, OUString& rPresetId, OUString& rPresetSubType )
803 {
804 	deprecated_AnimationEffect_conversion_table_entry* p = deprecated_AnimationEffect_conversion_table;
805 	while( p->mpPresetId )
806 	{
807 		if( p->meEffect == rEffect )
808 		{
809 			rPresetId = OUString::createFromAscii( p->mpPresetId );
810 			rPresetSubType = OUString::createFromAscii( p->mpPresetSubType );
811 			return true;
812 		}
813 		p++;
814 	}
815 
816 	return false;
817 }
818 
819 // --------------------------------------------------------------------
820 
821 double EffectMigration::ConvertAnimationSpeed( AnimationSpeed eSpeed )
822 {
823 	double fDuration;
824 	switch( eSpeed )
825 	{
826 	case AnimationSpeed_SLOW: fDuration = 2.0; break;
827 	case AnimationSpeed_FAST: fDuration = 0.5; break;
828 	//case AnimationSpeed_MEDIUM:
829 	default:
830 		fDuration = 1.0; break;
831 	}
832 	return fDuration;
833 }
834 // --------------------------------------------------------------------
835 
836 void EffectMigration::SetAnimationSpeed( SvxShape* pShape, AnimationSpeed eSpeed )
837 {
838 	DBG_ASSERT( pShape && pShape->GetSdrObject() && pShape->GetSdrObject()->GetPage(),
839 				"sd::EffectMigration::SetAnimationEffect(), invalid argument!" );
840 	if( !pShape || !pShape->GetSdrObject() || !pShape->GetSdrObject()->GetPage() )
841 		return;
842 
843 	SdrObject* pObj = pShape->GetSdrObject();
844 	if( implIsInsideGroup( pObj ) )
845 		return;
846 
847 	double fDuration = ConvertAnimationSpeed( eSpeed );
848 
849 	sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
850 
851 	const Reference< XShape > xShape( pShape );
852 
853 	EffectSequence::iterator aIter;
854 	bool bNeedRebuild = false;
855 
856 	for( aIter = pMainSequence->getBegin(); aIter != pMainSequence->getEnd(); aIter++ )
857 	{
858 		CustomAnimationEffectPtr pEffect( (*aIter) );
859 		if( pEffect->getTargetShape() == xShape )
860 		{
861 			if( pEffect->getDuration() != 0.1 )
862 				pEffect->setDuration( fDuration );
863 			bNeedRebuild = true;
864 		}
865 	}
866 
867 	if( bNeedRebuild )
868 		pMainSequence->rebuild();
869 }
870 
871 // --------------------------------------------------------------------
872 
873 AnimationSpeed EffectMigration::GetAnimationSpeed( SvxShape* pShape )
874 {
875 	SdrObject* pObj = pShape->GetSdrObject();
876 	sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
877 
878 	const Reference< XShape > xShape( pShape );
879 
880 	EffectSequence::iterator aIter;
881 
882 	double fDuration = 1.0;
883 
884 	for( aIter = pMainSequence->getBegin(); aIter != pMainSequence->getEnd(); aIter++ )
885 	{
886 		CustomAnimationEffectPtr pEffect( (*aIter) );
887 		if( pEffect->getTargetShape() == xShape )
888 		{
889 			if( pEffect->getDuration() != 0.1 )
890 			{
891 				fDuration = pEffect->getDuration();
892 				break;
893 			}
894 		}
895 	}
896 
897 	return ConvertDuration( fDuration );
898 }
899 
900 // --------------------------------------------------------------------
901 
902 AnimationSpeed EffectMigration::ConvertDuration( double fDuration )
903 {
904 	AnimationSpeed eSpeed;
905 
906 	if( fDuration < 1.0 )
907 		eSpeed = AnimationSpeed_FAST;
908 	else if( fDuration > 1.5 )
909 		eSpeed = AnimationSpeed_SLOW;
910 	else
911 		eSpeed = AnimationSpeed_MEDIUM;
912 
913 	return eSpeed;
914 }
915 
916 // --------------------------------------------------------------------
917 
918 void EffectMigration::SetDimColor( SvxShape* pShape, sal_Int32 nColor )
919 {
920 	DBG_ASSERT( pShape && pShape->GetSdrObject() && pShape->GetSdrObject()->GetPage(),
921 				"sd::EffectMigration::SetAnimationEffect(), invalid argument!" );
922 	if( !pShape || !pShape->GetSdrObject() || !pShape->GetSdrObject()->GetPage() )
923 		return;
924 
925 	SdrObject* pObj = pShape->GetSdrObject();
926 	if( implIsInsideGroup( pObj ) )
927 		return;
928 
929 	sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
930 
931 	const Reference< XShape > xShape( pShape );
932 
933 	EffectSequence::iterator aIter;
934 	bool bNeedRebuild = false;
935 
936 	for( aIter = pMainSequence->getBegin(); aIter != pMainSequence->getEnd(); aIter++ )
937 	{
938 		CustomAnimationEffectPtr pEffect( (*aIter) );
939 		if( pEffect->getTargetShape() == xShape )
940 		{
941 			pEffect->setHasAfterEffect( true );
942 			pEffect->setDimColor( makeAny( nColor ) );
943 			pEffect->setAfterEffectOnNext( true );
944 			bNeedRebuild = true;
945 		}
946 	}
947 
948 	if( bNeedRebuild )
949 		pMainSequence->rebuild();
950 }
951 
952 // --------------------------------------------------------------------
953 
954 sal_Int32 EffectMigration::GetDimColor( SvxShape* pShape )
955 {
956 	sal_Int32 nColor = 0;
957 	if( pShape )
958 	{
959 		SdrObject* pObj = pShape->GetSdrObject();
960 		if( pObj && pObj->GetPage() )
961 		{
962 			sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
963 
964 			const Reference< XShape > xShape( pShape );
965 			EffectSequence::iterator aIter;
966 
967 			for( aIter = pMainSequence->getBegin(); aIter != pMainSequence->getEnd(); aIter++ )
968 			{
969 				CustomAnimationEffectPtr pEffect( (*aIter) );
970 				if( (pEffect->getTargetShape() == xShape) &&
971 					pEffect->getDimColor().hasValue() &&
972 					pEffect->hasAfterEffect())
973 				{
974 					pEffect->getDimColor() >>= nColor;
975 					break;
976 				}
977 			}
978 		}
979 	}
980 
981 	return nColor;
982 }
983 
984 // --------------------------------------------------------------------
985 
986 
987 void EffectMigration::SetDimHide( SvxShape* pShape, sal_Bool bDimHide )
988 {
989 	DBG_ASSERT( pShape && pShape->GetSdrObject() && pShape->GetSdrObject()->GetPage(),
990 				"sd::EffectMigration::SetAnimationEffect(), invalid argument!" );
991 	if( !pShape || !pShape->GetSdrObject() || !pShape->GetSdrObject()->GetPage() )
992 		return;
993 
994 	SdrObject* pObj = pShape->GetSdrObject();
995 	if( implIsInsideGroup( pObj ) )
996 		return;
997 
998 	Any aEmpty;
999 
1000 	sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
1001 
1002 	const Reference< XShape > xShape( pShape );
1003 
1004 	EffectSequence::iterator aIter;
1005 	bool bNeedRebuild = false;
1006 
1007 	for( aIter = pMainSequence->getBegin(); aIter != pMainSequence->getEnd(); aIter++ )
1008 	{
1009 		CustomAnimationEffectPtr pEffect( (*aIter) );
1010 		if( pEffect->getTargetShape() == xShape )
1011 		{
1012 			pEffect->setHasAfterEffect( bDimHide ? true : false );
1013 			if( bDimHide )
1014 				pEffect->setDimColor( aEmpty );
1015 			pEffect->setAfterEffectOnNext( false );
1016 			bNeedRebuild = true;
1017 		}
1018 	}
1019 
1020 	if( bNeedRebuild )
1021 		pMainSequence->rebuild();
1022 }
1023 
1024 // --------------------------------------------------------------------
1025 
1026 sal_Bool EffectMigration::GetDimHide( SvxShape* pShape )
1027 {
1028 	sal_Bool bRet = sal_False;
1029 	if( pShape )
1030 	{
1031 		SdrObject* pObj = pShape->GetSdrObject();
1032 		if( pObj && pObj->GetPage() )
1033 		{
1034 			sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
1035 
1036 			const Reference< XShape > xShape( pShape );
1037 
1038 			EffectSequence::iterator aIter;
1039 			for( aIter = pMainSequence->getBegin(); aIter != pMainSequence->getEnd(); aIter++ )
1040 			{
1041 				CustomAnimationEffectPtr pEffect( (*aIter) );
1042 				if( pEffect->getTargetShape() == xShape )
1043 				{
1044 					bRet = pEffect->hasAfterEffect() &&
1045 							!pEffect->getDimColor().hasValue() &&
1046 							(!pEffect->IsAfterEffectOnNext());
1047 					break;
1048 				}
1049 			}
1050 		}
1051 	}
1052 
1053 	return bRet;
1054 }
1055 
1056 // --------------------------------------------------------------------
1057 
1058 void EffectMigration::SetDimPrevious( SvxShape* pShape, sal_Bool bDimPrevious )
1059 {
1060 	DBG_ASSERT( pShape && pShape->GetSdrObject() && pShape->GetSdrObject()->GetPage(),
1061 				"sd::EffectMigration::SetAnimationEffect(), invalid argument!" );
1062 	if( !pShape || !pShape->GetSdrObject() || !pShape->GetSdrObject()->GetPage() )
1063 		return;
1064 
1065 	SdrObject* pObj = pShape->GetSdrObject();
1066 	if( implIsInsideGroup( pObj ) )
1067 		return;
1068 
1069 	Any aColor;
1070 
1071 	if( bDimPrevious )
1072 		aColor <<= (sal_Int32)COL_LIGHTGRAY;
1073 
1074 	sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
1075 
1076 	const Reference< XShape > xShape( pShape );
1077 
1078 	EffectSequence::iterator aIter;
1079 	bool bNeedRebuild = false;
1080 
1081 	for( aIter = pMainSequence->getBegin(); aIter != pMainSequence->getEnd(); aIter++ )
1082 	{
1083 		CustomAnimationEffectPtr pEffect( (*aIter) );
1084 		if( pEffect->getTargetShape() == xShape )
1085 		{
1086 			pEffect->setHasAfterEffect( bDimPrevious );
1087 			if( !bDimPrevious || !pEffect->getDimColor().hasValue() )
1088 				pEffect->setDimColor( aColor );
1089 			pEffect->setAfterEffectOnNext( true );
1090 			bNeedRebuild = true;
1091 		}
1092 	}
1093 
1094 	if( bNeedRebuild )
1095 		pMainSequence->rebuild();
1096 }
1097 
1098 // --------------------------------------------------------------------
1099 
1100 sal_Bool EffectMigration::GetDimPrevious( SvxShape* pShape )
1101 {
1102 	sal_Bool bRet = sal_False;
1103 	if( pShape )
1104 	{
1105 		SdrObject* pObj = pShape->GetSdrObject();
1106 		if( pObj && pObj->GetPage() )
1107 		{
1108 			sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
1109 
1110 			const Reference< XShape > xShape( pShape );
1111 
1112 			EffectSequence::iterator aIter;
1113 			for( aIter = pMainSequence->getBegin(); aIter != pMainSequence->getEnd(); aIter++ )
1114 			{
1115 				CustomAnimationEffectPtr pEffect( (*aIter) );
1116 				if( pEffect->getTargetShape() == xShape )
1117 				{
1118 					bRet = pEffect->hasAfterEffect() &&
1119 							pEffect->getDimColor().hasValue() &&
1120 							pEffect->IsAfterEffectOnNext();
1121 					break;
1122 				}
1123 			}
1124 		}
1125 	}
1126 
1127 	return bRet;
1128 }
1129 
1130 // --------------------------------------------------------------------
1131 
1132 void EffectMigration::SetPresentationOrder( SvxShape* pShape, sal_Int32 nNewPos )
1133 {
1134 	if( !pShape || !pShape->GetSdrObject() || !pShape->GetSdrObject()->GetPage() )
1135 		return;
1136 
1137 	SdrObject* pObj = pShape->GetSdrObject();
1138 	sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
1139 
1140 	EffectSequence& rSequence = pMainSequence->getSequence();
1141 	sal_Int32 nPos;
1142 	sal_Int32 nCurrentPos = -1;
1143 	std::vector< std::vector< EffectSequence::iterator > > aEffectVector(1);
1144 
1145 	if( !rSequence.empty() )
1146 	{
1147 		Reference< XShape > xThis( pShape );
1148 		Reference< XShape > xCurrent;
1149 
1150 		EffectSequence::iterator aIter( rSequence.begin() );
1151 		EffectSequence::iterator aEnd( rSequence.end() );
1152 		for( nPos = 0; aIter != aEnd; aIter++ )
1153 		{
1154 			CustomAnimationEffectPtr pEffect = (*aIter);
1155 
1156 			if( !xCurrent.is() )
1157 			{
1158 				xCurrent = pEffect->getTargetShape();
1159 			}
1160 			else if( pEffect->getTargetShape() != xCurrent )
1161 			{
1162 				nPos++;
1163 				xCurrent = pEffect->getTargetShape();
1164 				aEffectVector.resize( nPos+1 );
1165 			}
1166 
1167 			// is this the first effect for xThis shape?
1168 			if(( nCurrentPos == -1 ) && ( xCurrent == xThis ) )
1169 			{
1170 				nCurrentPos = nPos;
1171 			}
1172 
1173 			aEffectVector[nPos].push_back( aIter );
1174 		}
1175 	}
1176 
1177 	// check if there is at least one effect for xThis
1178 	if( nCurrentPos == -1 )
1179 	{
1180 		DBG_ERROR("sd::EffectMigration::SetPresentationOrder() failed cause this shape has no effect" );
1181 		return;
1182 	}
1183 
1184 	// check trivial case
1185 	if( nCurrentPos != nNewPos )
1186 	{
1187 		std::vector< CustomAnimationEffectPtr > aEffects;
1188 
1189 		std::vector< EffectSequence::iterator >::iterator aIter( aEffectVector[nCurrentPos].begin() );
1190 		std::vector< EffectSequence::iterator >::iterator aEnd( aEffectVector[nCurrentPos].end() );
1191 		while( aIter != aEnd )
1192 		{
1193 			aEffects.push_back( (*(*aIter)) );
1194 			rSequence.erase( (*aIter++) );
1195 		}
1196 
1197 		if( nNewPos > nCurrentPos )
1198 			nNewPos++;
1199 
1200 		std::vector< CustomAnimationEffectPtr >::iterator aTempIter( aEffects.begin() );
1201 		std::vector< CustomAnimationEffectPtr >::iterator aTempEnd( aEffects.end() );
1202 
1203 		if( nNewPos == (sal_Int32)aEffectVector.size() )
1204 		{
1205 			while( aTempIter != aTempEnd )
1206 			{
1207 				rSequence.push_back( (*aTempIter++) );
1208 			}
1209 		}
1210 		else
1211 		{
1212 			EffectSequence::iterator aPos( aEffectVector[nNewPos][0] );
1213 			while( aTempIter != aTempEnd )
1214 			{
1215 				rSequence.insert( aPos, (*aTempIter++) );
1216 			}
1217 		}
1218 	}
1219 }
1220 
1221 // --------------------------------------------------------------------
1222 
1223 /** Returns the position of the given SdrObject in the Presentation order.
1224  *  This function returns -1 if the SdrObject is not in the Presentation order
1225  *  or if its the path-object.
1226  */
1227 sal_Int32 EffectMigration::GetPresentationOrder( SvxShape* pShape )
1228 {
1229 	sal_Int32 nPos = -1, nFound = -1;
1230 
1231 	SdrObject* pObj = pShape->GetSdrObject();
1232 	sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
1233 
1234 	EffectSequence& rSequence = pMainSequence->getSequence();
1235 
1236 	Reference< XShape > xThis( pShape );
1237 	Reference< XShape > xCurrent;
1238 
1239 	EffectSequence::iterator aIter( rSequence.begin() );
1240 	EffectSequence::iterator aEnd( rSequence.end() );
1241 	for( ; aIter != aEnd; aIter++ )
1242 	{
1243 		CustomAnimationEffectPtr pEffect = (*aIter);
1244 
1245 		if( !xCurrent.is() || pEffect->getTargetShape() != xCurrent )
1246 		{
1247 			nPos++;
1248 			xCurrent = pEffect->getTargetShape();
1249 
1250 			// is this the first effect for xThis shape?
1251 			if( xCurrent == xThis )
1252 			{
1253 				nFound = nPos;
1254 				break;
1255 			}
1256 		}
1257 	}
1258 
1259 	return nFound;
1260 }
1261 
1262 // --------------------------------------------------------------------
1263 
1264 void EffectMigration::UpdateSoundEffect( SvxShape* pShape, SdAnimationInfo* pInfo )
1265 {
1266 	if( pInfo )
1267 	{
1268 		SdrObject* pObj = pShape->GetSdrObject();
1269 		sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
1270 
1271 		const Reference< XShape > xShape( pShape );
1272 
1273 		EffectSequence::iterator aIter;
1274 		bool bNeedRebuild = false;
1275 
1276 		OUString aSoundFile;
1277 		if( pInfo->mbSoundOn )
1278 			aSoundFile = pInfo->maSoundFile;
1279 
1280 		for( aIter = pMainSequence->getBegin(); aIter != pMainSequence->getEnd(); aIter++ )
1281 		{
1282 			CustomAnimationEffectPtr pEffect( (*aIter) );
1283 			if( pEffect->getTargetShape() == xShape )
1284 			{
1285 				if( aSoundFile.getLength() )
1286 				{
1287 					pEffect->createAudio( makeAny( aSoundFile ) );
1288 				}
1289 				else
1290 				{
1291 					pEffect->removeAudio();
1292 				}
1293 				bNeedRebuild = true;
1294 			}
1295 		}
1296 
1297 		if( bNeedRebuild )
1298 			pMainSequence->rebuild();
1299 	}
1300 }
1301 
1302 // --------------------------------------------------------------------
1303 
1304 OUString EffectMigration::GetSoundFile( SvxShape* pShape )
1305 {
1306 	OUString aSoundFile;
1307 
1308 	if( pShape )
1309 	{
1310 		SdrObject* pObj = pShape->GetSdrObject();
1311 		if( pObj && pObj->GetPage() )
1312 		{
1313 			sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
1314 
1315 			const Reference< XShape > xShape( pShape );
1316 
1317 			EffectSequence::iterator aIter;
1318 
1319 			for(	aIter = pMainSequence->getBegin();
1320 					(aSoundFile.getLength() == 0) && (aIter != pMainSequence->getEnd());
1321 					aIter++ )
1322 			{
1323 				CustomAnimationEffectPtr pEffect( (*aIter) );
1324 				if( pEffect->getTargetShape() == xShape )
1325 				{
1326 					if( pEffect->getAudio().is() )
1327 						pEffect->getAudio()->getSource() >>= aSoundFile;
1328 				}
1329 			}
1330 		}
1331 	}
1332 	return aSoundFile;
1333 }
1334 
1335 // --------------------------------------------------------------------
1336 
1337 sal_Bool EffectMigration::GetSoundOn( SvxShape* pShape )
1338 {
1339 	return GetSoundFile( pShape ).getLength() != 0;
1340 }
1341 
1342 // --------------------------------------------------------------------
1343 
1344 void EffectMigration::SetAnimationPath( SvxShape* pShape, SdrPathObj* pPathObj )
1345 {
1346 	if( pShape && pPathObj )
1347 	{
1348 		SdrObject* pObj = pShape->GetSdrObject();
1349 
1350 		if( pObj )
1351 		{
1352 			//sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
1353 
1354 			const Reference< XShape > xShape( pShape );
1355 			SdPage* pPage = dynamic_cast< SdPage* >( pPathObj ? pPathObj->GetPage() : 0 );
1356 			if( pPage )
1357 			{
1358 				boost::shared_ptr< sd::MainSequence > pMainSequence( pPage->getMainSequence() );
1359 				if( pMainSequence.get() )
1360 					CustomAnimationEffectPtr pCreated( pMainSequence->append( *pPathObj, makeAny( xShape ), -1.0 ) );
1361 			}
1362 		}
1363 	}
1364 }
1365 
1366 
1367