1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: EffectMigration.cxx,v $
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_sd.hxx"
33 #include <com/sun/star/presentation/EffectNodeType.hpp>
34 #include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
35 #include <com/sun/star/presentation/TextAnimationType.hpp>
36 #include <com/sun/star/presentation/ParagraphTarget.hpp>
37 #include <svx/unoshape.hxx>
38 #include <svx/svdotext.hxx>
39 #include "drawdoc.hxx"
41 #include <CustomAnimationPreset.hxx>
42 #include <TransitionPreset.hxx>
43 #include <EffectMigration.hxx>
44 #include <anminfo.hxx>
46 using namespace ::vos
;
48 using namespace ::com::sun::star::uno
;
49 using namespace ::com::sun::star::animations
;
50 using namespace ::com::sun::star::presentation
;
52 using ::com::sun::star::drawing::XShape
;
53 using ::rtl::OUString
;
55 struct deprecated_FadeEffect_conversion_table_entry
57 FadeEffect meFadeEffect
;
58 const sal_Char
* mpPresetId
;
60 deprecated_FadeEffect_conversion_table
[] =
62 // OOo 1.x transitions
63 { FadeEffect_FADE_FROM_LEFT
, "wipe-right" },
64 { FadeEffect_FADE_FROM_TOP
, "wipe-down" },
65 { FadeEffect_FADE_FROM_RIGHT
, "wipe-left" },
66 { FadeEffect_FADE_FROM_BOTTOM
, "wipe-up" },
68 { FadeEffect_CLOCKWISE
, "wheel-clockwise-1-spoke" },
70 { FadeEffect_UNCOVER_TO_LEFT
, "uncover-left" },
71 { FadeEffect_UNCOVER_TO_UPPERLEFT
, "uncover-left-up" },
72 { FadeEffect_UNCOVER_TO_TOP
, "uncover-up" },
73 { FadeEffect_UNCOVER_TO_UPPERRIGHT
, "uncover-right-up" },
74 { FadeEffect_UNCOVER_TO_RIGHT
, "uncover-right" },
75 { FadeEffect_UNCOVER_TO_LOWERRIGHT
, "uncover-right-down" },
76 { FadeEffect_UNCOVER_TO_BOTTOM
, "uncover-down" },
77 { FadeEffect_UNCOVER_TO_LOWERLEFT
, "uncover-left-down" },
79 { FadeEffect_VERTICAL_LINES
, "random-bars-vertical" },
80 { FadeEffect_HORIZONTAL_LINES
, "random-bars-horizontal" },
82 { FadeEffect_VERTICAL_CHECKERBOARD
, "checkerboard-down" },
83 { FadeEffect_HORIZONTAL_CHECKERBOARD
, "checkerboard-across" },
85 { FadeEffect_FADE_TO_CENTER
, "box-in" },
86 { FadeEffect_FADE_FROM_CENTER
, "box-out" },
88 { FadeEffect_VERTICAL_STRIPES
, "venetian-blinds-vertical" },
89 { FadeEffect_HORIZONTAL_STRIPES
, "venetian-blinds-horizontal" },
91 { FadeEffect_MOVE_FROM_LEFT
, "cover-right" },
92 { FadeEffect_MOVE_FROM_TOP
, "cover-down" },
93 { FadeEffect_MOVE_FROM_RIGHT
, "cover-left" },
94 { FadeEffect_MOVE_FROM_BOTTOM
, "cover-up" },
95 { FadeEffect_MOVE_FROM_UPPERLEFT
, "cover-right-down" },
96 { FadeEffect_MOVE_FROM_UPPERRIGHT
, "cover-left-down" },
97 { FadeEffect_MOVE_FROM_LOWERRIGHT
, "cover-left-up" },
98 { FadeEffect_MOVE_FROM_LOWERLEFT
, "cover-right-up" },
100 { FadeEffect_DISSOLVE
, "dissolve" },
102 { FadeEffect_RANDOM
, "random-transition" },
104 { FadeEffect_ROLL_FROM_LEFT
, "push-right" },
105 { FadeEffect_ROLL_FROM_TOP
, "push-down" },
106 { FadeEffect_ROLL_FROM_RIGHT
, "push-left" },
107 { FadeEffect_ROLL_FROM_BOTTOM
, "push-up" },
109 { FadeEffect_CLOSE_VERTICAL
, "split-horizontal-in" },
110 { FadeEffect_CLOSE_HORIZONTAL
, "split-vertical-in" },
111 { FadeEffect_OPEN_VERTICAL
, "split-horizontal-out" },
112 { FadeEffect_OPEN_HORIZONTAL
, "split-vertical-out" },
114 { FadeEffect_FADE_FROM_UPPERLEFT
, "diagonal-squares-right-down" },
115 { FadeEffect_FADE_FROM_UPPERRIGHT
, "diagonal-squares-left-down" },
116 { FadeEffect_FADE_FROM_LOWERLEFT
, "diagonal-squares-right-up" },
117 { FadeEffect_FADE_FROM_LOWERRIGHT
, "diagonal-squares-left-up" },
119 // OOo 1.x transitions not in OOo 2.x
120 { FadeEffect_CLOCKWISE
, "clock-wipe-twelve" },
121 { FadeEffect_COUNTERCLOCKWISE
, "reverse-clock-wipe-twelve" },
122 { FadeEffect_SPIRALIN_LEFT
, "spiral-wipe-top-left-clockwise" },
123 { FadeEffect_SPIRALIN_RIGHT
, "spiral-wipe-top-right-counter-clockwise" },
124 { FadeEffect_SPIRALOUT_LEFT
, "spiral-wipe-out-to-bottom-right-clockwise" },
125 { FadeEffect_SPIRALOUT_RIGHT
, "spiral-wipe-out-to-bottom-left-counter-clockwise" },
126 { FadeEffect_WAVYLINE_FROM_LEFT
, "snake-wipe-top-left-vertical" },
127 { FadeEffect_WAVYLINE_FROM_TOP
, "snake-wipe-top-left-horizontal" },
128 { FadeEffect_WAVYLINE_FROM_RIGHT
, "snake-wipe-bottom-right-vertical" },
129 { FadeEffect_WAVYLINE_FROM_BOTTOM
, "snake-wipe-bottom-right-horizontal" },
130 { FadeEffect_STRETCH_FROM_LEFT
, "wipe-right" }, // todo
131 { FadeEffect_STRETCH_FROM_TOP
, "wipe-down" }, // todo
132 { FadeEffect_STRETCH_FROM_RIGHT
, "wipe-left" }, // todo
133 { FadeEffect_STRETCH_FROM_BOTTOM
, "wipe-up" }, // todo
135 // OOo 1.x not available transitions
137 { FadeEffect_CLOCKWISE
, "wheel-clockwise-2-spokes" },
138 { FadeEffect_CLOCKWISE
, "wheel-clockwise-3-spokes" },
139 { FadeEffect_CLOCKWISE
, "wheel-clockwise-4-spokes" },
140 { FadeEffect_CLOCKWISE
, "wheel-clockwise-8-spokes" },
142 { FadeEffect_FADE_FROM_CENTER
, "shape-circle" },
143 { FadeEffect_FADE_FROM_CENTER
, "shape-diamond" },
144 { FadeEffect_FADE_FROM_CENTER
, "shape-plus" },
146 { FadeEffect_CLOCKWISE
, "wedge" },
148 { FadeEffect_DISSOLVE
, "fade-through-black" },
150 { FadeEffect_CLOCKWISE
, "zoom-rotate-in" },
152 { FadeEffect_HORIZONTAL_LINES
, "comb-horizontal" },
153 { FadeEffect_VERTICAL_LINES
, "comb-vertical" },
155 { FadeEffect_DISSOLVE
, "fade-smoothly" },
157 { FadeEffect_NONE
, 0 }
161 cut cut (same as NONE?)
162 cut-through-black cut toBlack
166 void EffectMigration::SetFadeEffect( SdPage
* pPage
, ::com::sun::star::presentation::FadeEffect eNewEffect
)
168 deprecated_FadeEffect_conversion_table_entry
* pEntry
= deprecated_FadeEffect_conversion_table
;
169 while( (pEntry
->meFadeEffect
!= FadeEffect_NONE
) && (pEntry
->meFadeEffect
!= eNewEffect
) )
172 if( pEntry
->mpPresetId
)
174 const OUString
aPresetId( OUString::createFromAscii( pEntry
->mpPresetId
) );
176 const TransitionPresetList
& rPresetList
= TransitionPreset::getTransitionPresetList();
178 TransitionPresetList::const_iterator
aIt( rPresetList
.begin());
179 const TransitionPresetList::const_iterator
aEndIt( rPresetList
.end());
180 for( ; aIt
!= aEndIt
; ++aIt
)
182 if( (*aIt
)->getPresetId() == aPresetId
)
184 pPage
->setTransitionType( (*aIt
)->getTransition() );
185 pPage
->setTransitionSubtype( (*aIt
)->getSubtype() );
186 pPage
->setTransitionDirection( (*aIt
)->getDirection() );
187 pPage
->setTransitionFadeColor( (*aIt
)->getFadeColor() );
194 pPage
->setTransitionType( 0 );
195 pPage
->setTransitionSubtype( 0 );
196 pPage
->setTransitionDirection( 0 );
197 pPage
->setTransitionFadeColor( 0 );
201 FadeEffect
EffectMigration::GetFadeEffect( const SdPage
* pPage
)
203 const TransitionPresetList
& rPresetList
= TransitionPreset::getTransitionPresetList();
204 TransitionPresetList::const_iterator
aIt( rPresetList
.begin());
205 const TransitionPresetList::const_iterator
aEndIt( rPresetList
.end());
206 for( ; aIt
!= aEndIt
; ++aIt
)
208 if( ( (*aIt
)->getTransition() == pPage
->getTransitionType() ) &&
209 ( (*aIt
)->getSubtype() == pPage
->getTransitionSubtype() ) &&
210 ( (*aIt
)->getDirection() == pPage
->getTransitionDirection() ) &&
211 ( (*aIt
)->getFadeColor() == pPage
->getTransitionFadeColor() ) )
213 const OUString
& aPresetId
= (*aIt
)->getPresetId();
215 deprecated_FadeEffect_conversion_table_entry
* pEntry
= deprecated_FadeEffect_conversion_table
;
216 while( (pEntry
->meFadeEffect
!= FadeEffect_NONE
) && (!aPresetId
.equalsAscii( pEntry
->mpPresetId
) ) )
219 return pEntry
->meFadeEffect
;
222 return FadeEffect_NONE
;
225 struct deprecated_AnimationEffect_conversion_table_entry
227 AnimationEffect meEffect
;
228 const sal_Char
* mpPresetId
;
229 const sal_Char
* mpPresetSubType
;
231 deprecated_AnimationEffect_conversion_table
[] =
233 // OOo 1.x entrance effects
234 { AnimationEffect_APPEAR
, "ooo-entrance-appear",0 },
236 { AnimationEffect_FADE_TO_CENTER
, "ooo-entrance-box","in" },
237 { AnimationEffect_FADE_FROM_CENTER
, "ooo-entrance-box","out" },
239 { AnimationEffect_VERTICAL_CHECKERBOARD
, "ooo-entrance-checkerboard","downward" },
240 { AnimationEffect_HORIZONTAL_CHECKERBOARD
, "ooo-entrance-checkerboard","across" },
242 { AnimationEffect_FADE_FROM_UPPERLEFT
, "ooo-entrance-diagonal-squares","right-to-bottom" },
243 { AnimationEffect_FADE_FROM_UPPERRIGHT
, "ooo-entrance-diagonal-squares","left-to-bottom" },
244 { AnimationEffect_FADE_FROM_LOWERLEFT
, "ooo-entrance-diagonal-squares","right-to-top" },
245 { AnimationEffect_FADE_FROM_LOWERRIGHT
, "ooo-entrance-diagonal-squares","left-to-top" },
247 { AnimationEffect_DISSOLVE
, "ooo-entrance-dissolve-in",0 },
249 { AnimationEffect_MOVE_FROM_LEFT
, "ooo-entrance-fly-in","from-left" },
250 { AnimationEffect_MOVE_FROM_TOP
, "ooo-entrance-fly-in","from-top" },
251 { AnimationEffect_MOVE_FROM_RIGHT
, "ooo-entrance-fly-in","from-right" },
252 { AnimationEffect_MOVE_FROM_BOTTOM
, "ooo-entrance-fly-in","from-bottom" },
253 { AnimationEffect_MOVE_FROM_UPPERLEFT
, "ooo-entrance-fly-in","from-top-left" },
254 { AnimationEffect_MOVE_FROM_UPPERRIGHT
, "ooo-entrance-fly-in","from-top-right" },
255 { AnimationEffect_MOVE_FROM_LOWERRIGHT
, "ooo-entrance-fly-in","from-bottom-right" },
256 { AnimationEffect_MOVE_FROM_LOWERLEFT
, "ooo-entrance-fly-in","from-bottom-left" },
258 { AnimationEffect_MOVE_FROM_BOTTOM
, "ooo-entrance-fly-in-slow", "from-bottom" },
259 { AnimationEffect_MOVE_FROM_LEFT
, "ooo-entrance-fly-in-slow", "from-left" },
260 { AnimationEffect_MOVE_FROM_RIGHT
, "ooo-entrance-fly-in-slow", "from-right" },
261 { AnimationEffect_MOVE_FROM_TOP
, "ooo-entrance-fly-in-slow", "from-top" },
263 { AnimationEffect_MOVE_SHORT_FROM_LEFT
, "ooo-entrance-peek-in","from-left" },
264 { AnimationEffect_MOVE_SHORT_FROM_TOP
, "ooo-entrance-peek-in","from-top" },
265 { AnimationEffect_MOVE_SHORT_FROM_RIGHT
, "ooo-entrance-peek-in","from-right" },
266 { AnimationEffect_MOVE_SHORT_FROM_BOTTOM
, "ooo-entrance-peek-in","from-bottom" },
268 { AnimationEffect_VERTICAL_LINES
, "ooo-entrance-random-bars","horizontal" },
269 { AnimationEffect_HORIZONTAL_LINES
, "ooo-entrance-random-bars","vertical" },
271 { AnimationEffect_RANDOM
, "ooo-entrance-random",0 },
273 { AnimationEffect_CLOSE_VERTICAL
, "ooo-entrance-split","horizontal-in" },
274 { AnimationEffect_CLOSE_HORIZONTAL
, "ooo-entrance-split","vertical-in" },
275 { AnimationEffect_OPEN_VERTICAL
, "ooo-entrance-split","horizontal-out" },
276 { AnimationEffect_OPEN_HORIZONTAL
, "ooo-entrance-split","vertical-out" },
278 { AnimationEffect_VERTICAL_STRIPES
, "ooo-entrance-venetian-blinds","horizontal" },
279 { AnimationEffect_HORIZONTAL_STRIPES
, "ooo-entrance-venetian-blinds","vertical" },
281 { AnimationEffect_FADE_FROM_LEFT
, "ooo-entrance-wipe","from-left" },
282 { AnimationEffect_FADE_FROM_TOP
, "ooo-entrance-wipe","from-bottom" },
283 { AnimationEffect_FADE_FROM_RIGHT
, "ooo-entrance-wipe","from-right" },
284 { AnimationEffect_FADE_FROM_BOTTOM
, "ooo-entrance-wipe","from-top" },
286 { AnimationEffect_HORIZONTAL_ROTATE
, "ooo-entrance-swivel","vertical" },
287 { AnimationEffect_VERTICAL_ROTATE
, "ooo-entrance-swivel","horizontal" },
289 { AnimationEffect_STRETCH_FROM_LEFT
, "ooo-entrance-stretchy","from-left" },
290 { AnimationEffect_STRETCH_FROM_UPPERLEFT
, "ooo-entrance-stretchy","from-top-left" },
291 { AnimationEffect_STRETCH_FROM_TOP
, "ooo-entrance-stretchy","from-top" },
292 { AnimationEffect_STRETCH_FROM_UPPERRIGHT
, "ooo-entrance-stretchy","from-top-right" },
293 { AnimationEffect_STRETCH_FROM_RIGHT
, "ooo-entrance-stretchy","from-right" },
294 { AnimationEffect_STRETCH_FROM_LOWERRIGHT
, "ooo-entrance-stretchy","from-bottom-right" },
295 { AnimationEffect_STRETCH_FROM_BOTTOM
, "ooo-entrance-stretchy","from-bottom" },
296 { AnimationEffect_STRETCH_FROM_LOWERLEFT
, "ooo-entrance-stretchy","from-bottom-left" },
298 { AnimationEffect_HORIZONTAL_STRETCH
, "ooo-entrance-expand", 0 },
300 { AnimationEffect_CLOCKWISE
, "ooo-entrance-wheel","1" },
301 { AnimationEffect_COUNTERCLOCKWISE
, "ooo-entrance-clock-wipe","counter-clockwise" },
303 { AnimationEffect_SPIRALIN_LEFT
, "ooo-entrance-spiral-wipe", "from-top-left-clockwise" },
304 { AnimationEffect_SPIRALIN_RIGHT
, "ooo-entrance-spiral-wipe", "from-top-right-counter-clockwise" },
305 { AnimationEffect_SPIRALOUT_LEFT
, "ooo-entrance-spiral-wipe", "from-center-clockwise" },
306 { AnimationEffect_SPIRALOUT_RIGHT
, "ooo-entrance-spiral-wipe", "from-center-counter-clockwise" },
308 { AnimationEffect_WAVYLINE_FROM_LEFT
, "ooo-entrance-snake-wipe","from-top-left-vertical" },
309 { AnimationEffect_WAVYLINE_FROM_TOP
, "ooo-entrance-snake-wipe","from-top-left-horizontal" },
310 { AnimationEffect_WAVYLINE_FROM_RIGHT
, "ooo-entrance-snake-wipe","from-bottom-right-vertical" },
311 { AnimationEffect_WAVYLINE_FROM_BOTTOM
, "ooo-entrance-snake-wipe","from-bottom-right-horizontal" },
313 // ooo 1.x exit effects
314 { AnimationEffect_HIDE
, "ooo-exit-disappear",0 },
315 { AnimationEffect_MOVE_TO_LEFT
, "ooo-exit-fly-out", "from-right" },
316 { AnimationEffect_MOVE_TO_TOP
, "ooo-exit-fly-out", "from-bottom" },
317 { AnimationEffect_MOVE_TO_RIGHT
, "ooo-exit-fly-out", "from-left" },
318 { AnimationEffect_MOVE_TO_BOTTOM
, "ooo-exit-fly-out", "from-top" },
319 { AnimationEffect_MOVE_TO_UPPERLEFT
, "ooo-exit-fly-out", "from-top-right" },
320 { AnimationEffect_MOVE_TO_UPPERRIGHT
, "ooo-exit-fly-out", "from-top-left" },
321 { AnimationEffect_MOVE_TO_LOWERRIGHT
, "ooo-exit-fly-out", "from-bottom-left" },
322 { AnimationEffect_MOVE_TO_LOWERLEFT
, "ooo-exit-fly-out", "from-bottom-right" },
323 { AnimationEffect_MOVE_SHORT_TO_LEFT
, "ooo-exit-peek-out", "from-right" },
324 { AnimationEffect_MOVE_SHORT_TO_UPPERLEFT
, "ooo-exit-peek-out", "from-right" },
325 { AnimationEffect_MOVE_SHORT_TO_TOP
, "ooo-exit-peek-out", "from-bottom" },
326 { AnimationEffect_MOVE_SHORT_TO_UPPERRIGHT
, "ooo-exit-peek-out", "from-bottom" },
327 { AnimationEffect_MOVE_SHORT_TO_RIGHT
, "ooo-exit-peek-out", "from-left" },
328 { AnimationEffect_MOVE_SHORT_TO_LOWERRIGHT
, "ooo-exit-peek-out","from-left" },
329 { AnimationEffect_MOVE_SHORT_TO_BOTTOM
, "ooo-exit-peek-out", "from-top" },
330 { AnimationEffect_MOVE_SHORT_TO_LOWERLEFT
, "ooo-exit-peek-out", "from-top" },
332 // no matching in OOo 2.x
333 { AnimationEffect_MOVE_SHORT_FROM_UPPERLEFT
, "ooo-entrance-peek-in","from-left" },
334 { AnimationEffect_MOVE_SHORT_FROM_UPPERRIGHT
, "ooo-entrance-peek-in","from-top" },
335 { AnimationEffect_MOVE_SHORT_FROM_LOWERRIGHT
, "ooo-entrance-peek-in","from-right" },
336 { AnimationEffect_MOVE_SHORT_FROM_LOWERLEFT
, "ooo-entrance-peek-in","from-bottom" },
337 { AnimationEffect_LASER_FROM_LEFT
, "ooo-entrance-fly-in","from-left" },
338 { AnimationEffect_LASER_FROM_TOP
, "ooo-entrance-fly-in","from-top" },
339 { AnimationEffect_LASER_FROM_RIGHT
, "ooo-entrance-fly-in","from-right" },
340 { AnimationEffect_LASER_FROM_BOTTOM
, "ooo-entrance-fly-in","from-bottom" },
341 { AnimationEffect_LASER_FROM_UPPERLEFT
, "ooo-entrance-fly-in","from-top-left" },
342 { AnimationEffect_LASER_FROM_UPPERRIGHT
, "ooo-entrance-fly-in","from-top-right" },
343 { AnimationEffect_LASER_FROM_LOWERLEFT
, "ooo-entrance-fly-in","from-bottom-left" },
344 { AnimationEffect_LASER_FROM_LOWERRIGHT
, "ooo-entrance-fly-in","from-bottom-right" },
346 // no matching in OOo 1.x
348 { AnimationEffect_FADE_TO_CENTER
, "ooo-entrance-circle", "in" },
349 { AnimationEffect_FADE_FROM_CENTER
, "ooo-entrance-circle", "out" },
350 { AnimationEffect_FADE_TO_CENTER
, "ooo-entrance-diamond", "in" },
351 { AnimationEffect_FADE_FROM_CENTER
, "ooo-entrance-diamond", "out" },
352 { AnimationEffect_FADE_TO_CENTER
, "ooo-entrance-plus", "in" },
353 { AnimationEffect_FADE_FROM_CENTER
, "ooo-entrance-plus", "out" },
354 { AnimationEffect_CLOCKWISE
, "ooo-entrance-wedge", 0 },
355 { AnimationEffect_CLOCKWISE
, "ooo-entrance-wheel", "2" },
356 { AnimationEffect_CLOCKWISE
, "ooo-entrance-wheel", "3" },
357 { AnimationEffect_CLOCKWISE
, "ooo-entrance-wheel", "4" },
358 { AnimationEffect_CLOCKWISE
, "ooo-entrance-wheel", "8" },
360 { AnimationEffect_MOVE_FROM_RIGHT
, "ooo-entrance-boomerang", 0 },
361 { AnimationEffect_MOVE_FROM_UPPERRIGHT
, "ooo-entrance-bounce", 0 },
362 { AnimationEffect_MOVE_FROM_BOTTOM
, "ooo-entrance-curve-up", 0 },
363 { AnimationEffect_MOVE_FROM_TOP
, "ooo-entrance-float", 0 },
364 { AnimationEffect_MOVE_FROM_LEFT
, "ooo-entrance-glide", 0 },
365 { AnimationEffect_MOVE_FROM_BOTTOM
, "ooo-entrance-magnify", 0 },
366 { AnimationEffect_HORIZONTAL_ROTATE
, "ooo-entrance-pinwheel", 0 },
367 { AnimationEffect_MOVE_FROM_LEFT
, "ooo-entrance-breaks", 0 },
368 { AnimationEffect_MOVE_FROM_LEFT
, "ooo-entrance-sling", 0 },
369 { AnimationEffect_MOVE_FROM_LEFT
, "ooo-entrance-spiral-in", 0 },
370 { AnimationEffect_MOVE_FROM_LEFT
, "ooo-entrance-thread", 0 },
371 { AnimationEffect_MOVE_FROM_BOTTOM
, "ooo-entrance-ascend", 0 },
372 { AnimationEffect_MOVE_FROM_BOTTOM
, "ooo-entrance-center-revolve", 0 },
373 { AnimationEffect_APPEAR
, "ooo-entrance-compress", 0 },
374 { AnimationEffect_MOVE_SHORT_FROM_TOP
, "ooo-entrance-descend", 0 },
375 { AnimationEffect_MOVE_SHORT_FROM_LEFT
, "ooo-entrance-ease-in", 0 },
376 { AnimationEffect_MOVE_FROM_BOTTOM
, "ooo-entrance-rise-up", 0 },
377 { AnimationEffect_HORIZONTAL_ROTATE
, "ooo-entrance-spin-in", 0 },
378 { AnimationEffect_STRETCH_FROM_LEFT
, "ooo-entrance-stretchy", "across" },
379 { AnimationEffect_STRETCH_FROM_TOP
, "ooo-entrance-stretchy", "downward" },
381 { AnimationEffect_FADE_FROM_CENTER
, "ooo-entrance-zoom","in" },
382 { AnimationEffect_FADE_FROM_CENTER
, "ooo-entrance-zoom","in-slightly" },
383 { AnimationEffect_FADE_FROM_CENTER
, "ooo-entrance-zoom","in-from-screen-center" },
384 { AnimationEffect_FADE_TO_CENTER
, "ooo-entrance-zoom","out" },
385 { AnimationEffect_FADE_TO_CENTER
, "ooo-entrance-zoom","out-slightly" },
386 { AnimationEffect_FADE_TO_CENTER
, "ooo-entrance-zoom","out-from-screen-center" },
388 { AnimationEffect_DISSOLVE
, "ooo-entrance-fade-in", 0 },
389 { AnimationEffect_DISSOLVE
, "ooo-entrance-fade-in-and-zoom", 0 },
390 { AnimationEffect_DISSOLVE
, "ooo-entrance-fade-in-and-swivel", 0 },
394 { AnimationEffect_ZOOM_IN_FROM_LEFT, "ooo-entrance-zoom","in" },
395 { AnimationEffect_ZOOM_IN_FROM_UPPERLEFT, "ooo-entrance-zoom","in" },
396 { AnimationEffect_ZOOM_IN_FROM_TOP, "ooo-entrance-zoom","in" },
397 { AnimationEffect_ZOOM_IN_FROM_UPPERRIGHT, "ooo-entrance-zoom","in" },
398 { AnimationEffect_ZOOM_IN_FROM_RIGHT, "ooo-entrance-zoom","in" },
399 { AnimationEffect_ZOOM_IN_FROM_LOWERRIGHT, "ooo-entrance-zoom","in" },
400 { AnimationEffect_ZOOM_IN_FROM_BOTTOM, "ooo-entrance-zoom","in" },
401 { AnimationEffect_ZOOM_IN_FROM_LOWERLEFT, "ooo-entrance-zoom","in" },
402 { AnimationEffect_ZOOM_IN_FROM_CENTER, "ooo-entrance-zoom","in" },
404 { AnimationEffect_ZOOM_OUT_FROM_LEFT, "ooo-entrance-appear",0 },
405 { AnimationEffect_ZOOM_OUT_FROM_UPPERLEFT, "ooo-entrance-appear",0 },
406 { AnimationEffect_ZOOM_OUT_FROM_TOP, "ooo-entrance-appear",0 },
407 { AnimationEffect_ZOOM_OUT_FROM_UPPERRIGHT, "ooo-entrance-appear",0 },
408 { AnimationEffect_ZOOM_OUT_FROM_RIGHT, "ooo-entrance-appear",0 },
409 { AnimationEffect_ZOOM_OUT_FROM_LOWERRIGHT, "ooo-entrance-appear",0 },
410 { AnimationEffect_ZOOM_OUT_FROM_BOTTOM, "ooo-entrance-appear",0 },
411 { AnimationEffect_ZOOM_OUT_FROM_LOWERLEFT, "ooo-entrance-appear",0 },
412 { AnimationEffect_ZOOM_OUT_FROM_CENTER, "ooo-entrance-appear",0 },
413 { AnimationEffect_PATH, "ooo-entrance-spiral-in",0 },
415 { AnimationEffect_NONE
, 0, 0 }
418 EffectSequence::iterator
ImplFindEffect( MainSequencePtr
& pMainSequence
, const Reference
< XShape
>& rShape
, sal_Int16 nSubItem
)
420 EffectSequence::iterator aIter
;
422 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); aIter
++ )
424 CustomAnimationEffectPtr
pEffect( (*aIter
) );
425 if( (pEffect
->getTargetShape() == rShape
) && (pEffect
->getTargetSubItem() == nSubItem
) )
432 static bool implIsInsideGroup( SdrObject
* pObj
)
434 return pObj
&& pObj
->GetObjList() && pObj
->GetObjList()->GetUpList();
437 void EffectMigration::SetAnimationEffect( SvxShape
* pShape
, AnimationEffect eEffect
)
439 DBG_ASSERT( pShape
&& pShape
->GetSdrObject() && pShape
->GetSdrObject()->GetPage(),
440 "sd::EffectMigration::SetAnimationEffect(), invalid argument!" );
441 if( !pShape
|| !pShape
->GetSdrObject() || !pShape
->GetSdrObject()->GetPage() )
444 SdrObject
* pObj
= pShape
->GetSdrObject();
445 if( implIsInsideGroup( pObj
) )
449 OUString aPresetSubType
;
451 if( !ConvertAnimationEffect( eEffect
, aPresetId
, aPresetSubType
) )
453 DBG_ERROR( "sd::EffectMigration::SetAnimationEffect(), no mapping for given AnimationEffect value" );
457 const CustomAnimationPresets
& rPresets
= CustomAnimationPresets::getCustomAnimationPresets();
459 CustomAnimationPresetPtr
pPreset( rPresets
.getEffectDescriptor( aPresetId
) );
460 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
462 if( pPreset
.get() && pMainSequence
.get() )
464 const Reference
< XShape
> xShape( pShape
);
466 EffectSequence::iterator
aIterOnlyBackground( ImplFindEffect( pMainSequence
, xShape
, ShapeAnimationSubType::ONLY_BACKGROUND
) );
467 EffectSequence::iterator
aIterAsWhole( ImplFindEffect( pMainSequence
, xShape
, ShapeAnimationSubType::AS_WHOLE
) );
468 const EffectSequence::iterator
aEnd( pMainSequence
->getEnd() );
470 bool bEffectCreated
= false;
472 if( (aIterOnlyBackground
== aEnd
) && (aIterAsWhole
== aEnd
) )
474 // check if there is already an text effect for this shape
475 EffectSequence::iterator
aIterOnlyText( ImplFindEffect( pMainSequence
, xShape
, ShapeAnimationSubType::ONLY_TEXT
) );
476 if( aIterOnlyText
!= aEnd
)
478 // check if this is an animation text group
479 sal_Int32 nGroupId
= (*aIterOnlyText
)->getGroupId();
482 CustomAnimationTextGroupPtr pGroup
= pMainSequence
->findGroup( nGroupId
);
485 // add an effect to animate the shape
486 pMainSequence
->setAnimateForm( pGroup
, true );
489 EffectSequence::iterator
aIter( ImplFindEffect( pMainSequence
, xShape
, ShapeAnimationSubType::ONLY_BACKGROUND
) );
493 if( ((*aIter
)->getPresetId() != aPresetId
) ||
494 ((*aIter
)->getPresetSubType() != aPresetSubType
) )
496 (*aIter
)->replaceNode( pPreset
->create( aPresetSubType
) );
497 pMainSequence
->rebuild();
498 bEffectCreated
= true;
505 if( !bEffectCreated
)
507 // if there is not yet an effect that target this shape, we generate one
508 // we insert the shape effect before it
509 Reference
< XAnimationNode
> xNode( pPreset
->create( aPresetSubType
) );
510 DBG_ASSERT( xNode
.is(), "EffectMigration::SetAnimationEffect(), could not create preset!" );
513 CustomAnimationEffectPtr
pEffect( new CustomAnimationEffect( xNode
) );
514 pEffect
->setTarget( makeAny( xShape
) );
515 SdPage
* pPage
= dynamic_cast< SdPage
* >( pObj
->GetPage() );
516 const bool bManual
= (pPage
== 0) || (pPage
->GetPresChange() == PRESCHANGE_MANUAL
);
518 pEffect
->setNodeType( EffectNodeType::AFTER_PREVIOUS
);
520 pMainSequence
->append( pEffect
);
522 if( ( pObj
->GetObjInventor() == SdrInventor
) && ( pObj
->GetObjIdentifier() == OBJ_OUTLINETEXT
) )
524 // special case for outline text, effects are always mapped to text group effect
526 createTextGroup( pEffect
, 10, bManual
? -1 : 0.0, sal_False
, sal_False
);
533 // if there is already an effect targeting this shape
535 CustomAnimationEffectPtr pEffect
;
536 if( aIterAsWhole
!= aEnd
)
538 pEffect
= (*aIterAsWhole
);
542 pEffect
= (*aIterOnlyBackground
);
547 if( (pEffect
->getPresetId() != aPresetId
) ||
548 (pEffect
->getPresetSubType() != aPresetSubType
) )
550 pMainSequence
->replace( pEffect
, pPreset
, aPresetSubType
);
557 // --------------------------------------------------------------------
559 AnimationEffect
EffectMigration::GetAnimationEffect( SvxShape
* pShape
)
562 OUString aPresetSubType
;
564 SdrObject
* pObj
= pShape
->GetSdrObject();
565 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
567 if( pMainSequence
.get() )
569 const Reference
< XShape
> xShape( pShape
);
571 EffectSequence::iterator aIter
;
573 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); aIter
++ )
575 CustomAnimationEffectPtr
pEffect( (*aIter
) );
576 if( pEffect
->getTargetShape() == xShape
)
578 if( (pEffect
->getTargetSubItem() == ShapeAnimationSubType::ONLY_BACKGROUND
) ||
579 (pEffect
->getTargetSubItem() == ShapeAnimationSubType::AS_WHOLE
))
581 if( pEffect
->getDuration() != 0.1 ) // ignore appear effects created from old text effect import
583 aPresetId
= (*aIter
)->getPresetId();
584 aPresetSubType
= (*aIter
)->getPresetSubType();
592 // now find old effect
593 AnimationEffect eEffect
= AnimationEffect_NONE
;
595 if( !ConvertPreset( aPresetId
, &aPresetSubType
, eEffect
) )
596 ConvertPreset( aPresetId
, 0, eEffect
);
602 // --------------------------------------------------------------------
604 void EffectMigration::SetTextAnimationEffect( SvxShape
* pShape
, AnimationEffect eEffect
)
606 DBG_ASSERT( pShape
&& pShape
->GetSdrObject() && pShape
->GetSdrObject()->GetPage(),
607 "sd::EffectMigration::SetAnimationEffect(), invalid argument!" );
608 if( !pShape
|| !pShape
->GetSdrObject() || !pShape
->GetSdrObject()->GetPage() )
611 SdrObject
* pObj
= pShape
->GetSdrObject();
612 if( implIsInsideGroup( pObj
) )
615 // first map the deprecated AnimationEffect to a preset and subtype
617 OUString aPresetSubType
;
619 if( !ConvertAnimationEffect( eEffect
, aPresetId
, aPresetSubType
) )
621 DBG_ERROR( "sd::EffectMigration::SetAnimationEffect(), no mapping for given AnimationEffect value" );
625 SdrTextObj
* pTextObj
= dynamic_cast< SdrTextObj
* >( pObj
);
627 // ignore old text effects on shape without text
628 if( (pTextObj
== 0) || (!pTextObj
->HasText()) )
631 const CustomAnimationPresets
& rPresets
= CustomAnimationPresets::getCustomAnimationPresets();
633 // create an effect from this preset
634 CustomAnimationPresetPtr
pPreset( rPresets
.getEffectDescriptor( aPresetId
) );
636 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
638 if( pPreset
.get() && pMainSequence
.get() )
640 const Reference
< XShape
> xShape( pShape
);
642 EffectSequence::iterator
aIterOnlyText( ImplFindEffect( pMainSequence
, xShape
, ShapeAnimationSubType::ONLY_TEXT
) );
643 const EffectSequence::iterator
aEnd( pMainSequence
->getEnd() );
645 CustomAnimationTextGroupPtr pGroup
;
647 // is there already an animation text group for this shape?
648 if( aIterOnlyText
!= aEnd
)
650 const sal_Int32 nGroupId
= (*aIterOnlyText
)->getGroupId();
652 pGroup
= pMainSequence
->findGroup( nGroupId
);
655 // if there is not yet a group, create it
656 if( pGroup
.get() == 0 )
658 CustomAnimationEffectPtr pShapeEffect
;
660 EffectSequence::iterator
aIterOnlyBackground( ImplFindEffect( pMainSequence
, xShape
, ShapeAnimationSubType::ONLY_BACKGROUND
) );
661 if( aIterOnlyBackground
!= aEnd
)
663 pShapeEffect
= (*aIterOnlyBackground
);
667 EffectSequence::iterator
aIterAsWhole( ImplFindEffect( pMainSequence
, xShape
, ShapeAnimationSubType::AS_WHOLE
) );
668 if( aIterAsWhole
!= aEnd
)
670 pShapeEffect
= (*aIterAsWhole
);
675 CustomAnimationPresetPtr
pShapePreset( rPresets
.getEffectDescriptor( OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo-entrance-appear" ) ) ) );
677 Reference
< XAnimationNode
> xNode( pPreset
->create( aEmpty
) );
678 DBG_ASSERT( xNode
.is(), "EffectMigration::SetTextAnimationEffect(), could not create preset!" );
681 pShapeEffect
.reset( new CustomAnimationEffect( xNode
) );
682 pShapeEffect
->setTarget( makeAny( xShape
) );
683 pShapeEffect
->setDuration( 0.1 );
684 pMainSequence
->append( pShapeEffect
);
686 SdPage
* pPage
= dynamic_cast< SdPage
* >( pObj
->GetPage() );
687 if( pPage
&& pPage
->GetPresChange() != PRESCHANGE_MANUAL
)
688 pShapeEffect
->setNodeType( EffectNodeType::AFTER_PREVIOUS
);
693 if( pShapeEffect
.get() )
695 SdPage
* pPage
= dynamic_cast< SdPage
* >( pObj
->GetPage() );
696 const bool bManual
= (pPage
== 0) || (pPage
->GetPresChange() == PRESCHANGE_MANUAL
);
698 // now create effects for each paragraph
701 createTextGroup( pShapeEffect
, 10, bManual
? -1 : 0.0, sal_True
, sal_False
);
705 if( pGroup
.get() != 0 )
707 const bool bLaserEffect
= (eEffect
>= AnimationEffect_LASER_FROM_LEFT
) && (eEffect
<= AnimationEffect_LASER_FROM_LOWERRIGHT
);
709 // now we have a group, so check if all effects are same as we like to have them
710 const EffectSequence
& rEffects
= pGroup
->getEffects();
712 EffectSequence::const_iterator aIter
;
713 for( aIter
= rEffects
.begin(); aIter
!= rEffects
.end(); aIter
++ )
715 // only work on paragraph targets
716 if( (*aIter
)->getTarget().getValueType() == ::getCppuType((const ParagraphTarget
*)0) )
718 if( ((*aIter
)->getPresetId() != aPresetId
) ||
719 ((*aIter
)->getPresetSubType() != aPresetSubType
) )
721 (*aIter
)->replaceNode( pPreset
->create( aPresetSubType
) );
726 (*aIter
)->setIterateType( TextAnimationType::BY_LETTER
);
727 (*aIter
)->setIterateInterval( 0.5 );// TODO:
739 pMainSequence
->rebuild();
743 // --------------------------------------------------------------------
745 AnimationEffect
EffectMigration::GetTextAnimationEffect( SvxShape
* pShape
)
748 OUString aPresetSubType
;
750 SdrObject
* pObj
= pShape
->GetSdrObject();
753 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
755 if( pMainSequence
.get() )
757 const Reference
< XShape
> xShape( pShape
);
758 EffectSequence::iterator
aIter( ImplFindEffect( pMainSequence
, xShape
, ShapeAnimationSubType::ONLY_TEXT
) );
759 if( aIter
!= pMainSequence
->getEnd() )
761 aPresetId
= (*aIter
)->getPresetId();
762 aPresetSubType
= (*aIter
)->getPresetSubType();
767 // now find old effect
768 AnimationEffect eEffect
= AnimationEffect_NONE
;
770 if( !ConvertPreset( aPresetId
, &aPresetSubType
, eEffect
) )
771 ConvertPreset( aPresetId
, 0, eEffect
);
776 // --------------------------------------------------------------------
778 bool EffectMigration::ConvertPreset( const OUString
& rPresetId
, const OUString
* pPresetSubType
, AnimationEffect
& rEffect
)
780 rEffect
= AnimationEffect_NONE
;
781 if( rPresetId
.getLength() )
783 // first try a match for preset id and subtype
784 deprecated_AnimationEffect_conversion_table_entry
* p
= deprecated_AnimationEffect_conversion_table
;
785 while( p
->mpPresetId
)
787 if( rPresetId
.equalsAscii( p
->mpPresetId
) &&
788 (( p
->mpPresetSubType
== 0 ) ||
789 ( pPresetSubType
== 0) ||
790 ( pPresetSubType
->equalsAscii( p
->mpPresetSubType
)) ) )
792 rEffect
= p
->meEffect
;
801 // empty preset id means AnimationEffect_NONE
806 // --------------------------------------------------------------------
808 bool EffectMigration::ConvertAnimationEffect( const AnimationEffect
& rEffect
, OUString
& rPresetId
, OUString
& rPresetSubType
)
810 deprecated_AnimationEffect_conversion_table_entry
* p
= deprecated_AnimationEffect_conversion_table
;
811 while( p
->mpPresetId
)
813 if( p
->meEffect
== rEffect
)
815 rPresetId
= OUString::createFromAscii( p
->mpPresetId
);
816 rPresetSubType
= OUString::createFromAscii( p
->mpPresetSubType
);
825 // --------------------------------------------------------------------
827 double EffectMigration::ConvertAnimationSpeed( AnimationSpeed eSpeed
)
832 case AnimationSpeed_SLOW
: fDuration
= 2.0; break;
833 case AnimationSpeed_FAST
: fDuration
= 0.5; break;
834 //case AnimationSpeed_MEDIUM:
836 fDuration
= 1.0; break;
840 // --------------------------------------------------------------------
842 void EffectMigration::SetAnimationSpeed( SvxShape
* pShape
, AnimationSpeed eSpeed
)
844 DBG_ASSERT( pShape
&& pShape
->GetSdrObject() && pShape
->GetSdrObject()->GetPage(),
845 "sd::EffectMigration::SetAnimationEffect(), invalid argument!" );
846 if( !pShape
|| !pShape
->GetSdrObject() || !pShape
->GetSdrObject()->GetPage() )
849 SdrObject
* pObj
= pShape
->GetSdrObject();
850 if( implIsInsideGroup( pObj
) )
853 double fDuration
= ConvertAnimationSpeed( eSpeed
);
855 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
857 const Reference
< XShape
> xShape( pShape
);
859 EffectSequence::iterator aIter
;
860 bool bNeedRebuild
= false;
862 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); aIter
++ )
864 CustomAnimationEffectPtr
pEffect( (*aIter
) );
865 if( pEffect
->getTargetShape() == xShape
)
867 if( pEffect
->getDuration() != 0.1 )
868 pEffect
->setDuration( fDuration
);
874 pMainSequence
->rebuild();
877 // --------------------------------------------------------------------
879 AnimationSpeed
EffectMigration::GetAnimationSpeed( SvxShape
* pShape
)
881 SdrObject
* pObj
= pShape
->GetSdrObject();
882 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
884 const Reference
< XShape
> xShape( pShape
);
886 EffectSequence::iterator aIter
;
888 double fDuration
= 1.0;
890 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); aIter
++ )
892 CustomAnimationEffectPtr
pEffect( (*aIter
) );
893 if( pEffect
->getTargetShape() == xShape
)
895 if( pEffect
->getDuration() != 0.1 )
897 fDuration
= pEffect
->getDuration();
903 return ConvertDuration( fDuration
);
906 // --------------------------------------------------------------------
908 AnimationSpeed
EffectMigration::ConvertDuration( double fDuration
)
910 AnimationSpeed eSpeed
;
912 if( fDuration
< 1.0 )
913 eSpeed
= AnimationSpeed_FAST
;
914 else if( fDuration
> 1.5 )
915 eSpeed
= AnimationSpeed_SLOW
;
917 eSpeed
= AnimationSpeed_MEDIUM
;
922 // --------------------------------------------------------------------
924 void EffectMigration::SetDimColor( SvxShape
* pShape
, sal_Int32 nColor
)
926 DBG_ASSERT( pShape
&& pShape
->GetSdrObject() && pShape
->GetSdrObject()->GetPage(),
927 "sd::EffectMigration::SetAnimationEffect(), invalid argument!" );
928 if( !pShape
|| !pShape
->GetSdrObject() || !pShape
->GetSdrObject()->GetPage() )
931 SdrObject
* pObj
= pShape
->GetSdrObject();
932 if( implIsInsideGroup( pObj
) )
935 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
937 const Reference
< XShape
> xShape( pShape
);
939 EffectSequence::iterator aIter
;
940 bool bNeedRebuild
= false;
942 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); aIter
++ )
944 CustomAnimationEffectPtr
pEffect( (*aIter
) );
945 if( pEffect
->getTargetShape() == xShape
)
947 pEffect
->setHasAfterEffect( true );
948 pEffect
->setDimColor( makeAny( nColor
) );
949 pEffect
->setAfterEffectOnNext( true );
955 pMainSequence
->rebuild();
958 // --------------------------------------------------------------------
960 sal_Int32
EffectMigration::GetDimColor( SvxShape
* pShape
)
962 sal_Int32 nColor
= 0;
965 SdrObject
* pObj
= pShape
->GetSdrObject();
966 if( pObj
&& pObj
->GetPage() )
968 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
970 const Reference
< XShape
> xShape( pShape
);
971 EffectSequence::iterator aIter
;
973 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); aIter
++ )
975 CustomAnimationEffectPtr
pEffect( (*aIter
) );
976 if( (pEffect
->getTargetShape() == xShape
) &&
977 pEffect
->getDimColor().hasValue() &&
978 pEffect
->hasAfterEffect())
980 pEffect
->getDimColor() >>= nColor
;
990 // --------------------------------------------------------------------
993 void EffectMigration::SetDimHide( SvxShape
* pShape
, sal_Bool bDimHide
)
995 DBG_ASSERT( pShape
&& pShape
->GetSdrObject() && pShape
->GetSdrObject()->GetPage(),
996 "sd::EffectMigration::SetAnimationEffect(), invalid argument!" );
997 if( !pShape
|| !pShape
->GetSdrObject() || !pShape
->GetSdrObject()->GetPage() )
1000 SdrObject
* pObj
= pShape
->GetSdrObject();
1001 if( implIsInsideGroup( pObj
) )
1006 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
1008 const Reference
< XShape
> xShape( pShape
);
1010 EffectSequence::iterator aIter
;
1011 bool bNeedRebuild
= false;
1013 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); aIter
++ )
1015 CustomAnimationEffectPtr
pEffect( (*aIter
) );
1016 if( pEffect
->getTargetShape() == xShape
)
1018 pEffect
->setHasAfterEffect( bDimHide
? true : false );
1020 pEffect
->setDimColor( aEmpty
);
1021 pEffect
->setAfterEffectOnNext( false );
1022 bNeedRebuild
= true;
1027 pMainSequence
->rebuild();
1030 // --------------------------------------------------------------------
1032 sal_Bool
EffectMigration::GetDimHide( SvxShape
* pShape
)
1034 sal_Bool bRet
= sal_False
;
1037 SdrObject
* pObj
= pShape
->GetSdrObject();
1038 if( pObj
&& pObj
->GetPage() )
1040 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
1042 const Reference
< XShape
> xShape( pShape
);
1044 EffectSequence::iterator aIter
;
1045 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); aIter
++ )
1047 CustomAnimationEffectPtr
pEffect( (*aIter
) );
1048 if( pEffect
->getTargetShape() == xShape
)
1050 bRet
= pEffect
->hasAfterEffect() &&
1051 !pEffect
->getDimColor().hasValue() &&
1052 (!pEffect
->IsAfterEffectOnNext());
1062 // --------------------------------------------------------------------
1064 void EffectMigration::SetDimPrevious( SvxShape
* pShape
, sal_Bool bDimPrevious
)
1066 DBG_ASSERT( pShape
&& pShape
->GetSdrObject() && pShape
->GetSdrObject()->GetPage(),
1067 "sd::EffectMigration::SetAnimationEffect(), invalid argument!" );
1068 if( !pShape
|| !pShape
->GetSdrObject() || !pShape
->GetSdrObject()->GetPage() )
1071 SdrObject
* pObj
= pShape
->GetSdrObject();
1072 if( implIsInsideGroup( pObj
) )
1078 aColor
<<= (sal_Int32
)COL_LIGHTGRAY
;
1080 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
1082 const Reference
< XShape
> xShape( pShape
);
1084 EffectSequence::iterator aIter
;
1085 bool bNeedRebuild
= false;
1087 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); aIter
++ )
1089 CustomAnimationEffectPtr
pEffect( (*aIter
) );
1090 if( pEffect
->getTargetShape() == xShape
)
1092 pEffect
->setHasAfterEffect( bDimPrevious
);
1093 if( !bDimPrevious
|| !pEffect
->getDimColor().hasValue() )
1094 pEffect
->setDimColor( aColor
);
1095 pEffect
->setAfterEffectOnNext( true );
1096 bNeedRebuild
= true;
1101 pMainSequence
->rebuild();
1104 // --------------------------------------------------------------------
1106 sal_Bool
EffectMigration::GetDimPrevious( SvxShape
* pShape
)
1108 sal_Bool bRet
= sal_False
;
1111 SdrObject
* pObj
= pShape
->GetSdrObject();
1112 if( pObj
&& pObj
->GetPage() )
1114 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
1116 const Reference
< XShape
> xShape( pShape
);
1118 EffectSequence::iterator aIter
;
1119 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); aIter
++ )
1121 CustomAnimationEffectPtr
pEffect( (*aIter
) );
1122 if( pEffect
->getTargetShape() == xShape
)
1124 bRet
= pEffect
->hasAfterEffect() &&
1125 pEffect
->getDimColor().hasValue() &&
1126 pEffect
->IsAfterEffectOnNext();
1136 // --------------------------------------------------------------------
1138 void EffectMigration::SetPresentationOrder( SvxShape
* pShape
, sal_Int32 nNewPos
)
1140 if( !pShape
|| !pShape
->GetSdrObject() || !pShape
->GetSdrObject()->GetPage() )
1143 SdrObject
* pObj
= pShape
->GetSdrObject();
1144 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
1146 EffectSequence
& rSequence
= pMainSequence
->getSequence();
1148 sal_Int32 nCurrentPos
= -1;
1149 std::vector
< std::vector
< EffectSequence::iterator
> > aEffectVector(1);
1151 if( !rSequence
.empty() )
1153 Reference
< XShape
> xThis( pShape
);
1154 Reference
< XShape
> xCurrent
;
1156 EffectSequence::iterator
aIter( rSequence
.begin() );
1157 EffectSequence::iterator
aEnd( rSequence
.end() );
1158 for( nPos
= 0; aIter
!= aEnd
; aIter
++ )
1160 CustomAnimationEffectPtr pEffect
= (*aIter
);
1162 if( !xCurrent
.is() )
1164 xCurrent
= pEffect
->getTargetShape();
1166 else if( pEffect
->getTargetShape() != xCurrent
)
1169 xCurrent
= pEffect
->getTargetShape();
1170 aEffectVector
.resize( nPos
+1 );
1173 // is this the first effect for xThis shape?
1174 if(( nCurrentPos
== -1 ) && ( xCurrent
== xThis
) )
1179 aEffectVector
[nPos
].push_back( aIter
);
1183 // check if there is at least one effect for xThis
1184 if( nCurrentPos
== -1 )
1186 DBG_ERROR("sd::EffectMigration::SetPresentationOrder() failed cause this shape has no effect" );
1190 // check trivial case
1191 if( nCurrentPos
!= nNewPos
)
1193 std::vector
< CustomAnimationEffectPtr
> aEffects
;
1195 std::vector
< EffectSequence::iterator
>::iterator
aIter( aEffectVector
[nCurrentPos
].begin() );
1196 std::vector
< EffectSequence::iterator
>::iterator
aEnd( aEffectVector
[nCurrentPos
].end() );
1197 while( aIter
!= aEnd
)
1199 aEffects
.push_back( (*(*aIter
)) );
1200 rSequence
.erase( (*aIter
++) );
1203 if( nNewPos
> nCurrentPos
)
1206 std::vector
< CustomAnimationEffectPtr
>::iterator
aTempIter( aEffects
.begin() );
1207 std::vector
< CustomAnimationEffectPtr
>::iterator
aTempEnd( aEffects
.end() );
1209 if( nNewPos
== (sal_Int32
)aEffectVector
.size() )
1211 while( aTempIter
!= aTempEnd
)
1213 rSequence
.push_back( (*aTempIter
++) );
1218 EffectSequence::iterator
aPos( aEffectVector
[nNewPos
][0] );
1219 while( aTempIter
!= aTempEnd
)
1221 rSequence
.insert( aPos
, (*aTempIter
++) );
1227 // --------------------------------------------------------------------
1229 /** Returns the position of the given SdrObject in the Presentation order.
1230 * This function returns -1 if the SdrObject is not in the Presentation order
1231 * or if its the path-object.
1233 sal_Int32
EffectMigration::GetPresentationOrder( SvxShape
* pShape
)
1235 sal_Int32 nPos
= -1, nFound
= -1;
1237 SdrObject
* pObj
= pShape
->GetSdrObject();
1238 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
1240 EffectSequence
& rSequence
= pMainSequence
->getSequence();
1242 Reference
< XShape
> xThis( pShape
);
1243 Reference
< XShape
> xCurrent
;
1245 EffectSequence::iterator
aIter( rSequence
.begin() );
1246 EffectSequence::iterator
aEnd( rSequence
.end() );
1247 for( ; aIter
!= aEnd
; aIter
++ )
1249 CustomAnimationEffectPtr pEffect
= (*aIter
);
1251 if( !xCurrent
.is() || pEffect
->getTargetShape() != xCurrent
)
1254 xCurrent
= pEffect
->getTargetShape();
1256 // is this the first effect for xThis shape?
1257 if( xCurrent
== xThis
)
1268 // --------------------------------------------------------------------
1270 void EffectMigration::UpdateSoundEffect( SvxShape
* pShape
, SdAnimationInfo
* pInfo
)
1274 SdrObject
* pObj
= pShape
->GetSdrObject();
1275 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
1277 const Reference
< XShape
> xShape( pShape
);
1279 EffectSequence::iterator aIter
;
1280 bool bNeedRebuild
= false;
1282 OUString aSoundFile
;
1283 if( pInfo
->mbSoundOn
)
1284 aSoundFile
= pInfo
->maSoundFile
;
1286 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); aIter
++ )
1288 CustomAnimationEffectPtr
pEffect( (*aIter
) );
1289 if( pEffect
->getTargetShape() == xShape
)
1291 if( aSoundFile
.getLength() )
1293 pEffect
->createAudio( makeAny( aSoundFile
) );
1297 pEffect
->removeAudio();
1299 bNeedRebuild
= true;
1304 pMainSequence
->rebuild();
1308 // --------------------------------------------------------------------
1310 OUString
EffectMigration::GetSoundFile( SvxShape
* pShape
)
1312 OUString aSoundFile
;
1316 SdrObject
* pObj
= pShape
->GetSdrObject();
1317 if( pObj
&& pObj
->GetPage() )
1319 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
1321 const Reference
< XShape
> xShape( pShape
);
1323 EffectSequence::iterator aIter
;
1325 for( aIter
= pMainSequence
->getBegin();
1326 (aSoundFile
.getLength() == 0) && (aIter
!= pMainSequence
->getEnd());
1329 CustomAnimationEffectPtr
pEffect( (*aIter
) );
1330 if( pEffect
->getTargetShape() == xShape
)
1332 if( pEffect
->getAudio().is() )
1333 pEffect
->getAudio()->getSource() >>= aSoundFile
;
1341 // --------------------------------------------------------------------
1343 sal_Bool
EffectMigration::GetSoundOn( SvxShape
* pShape
)
1345 return GetSoundFile( pShape
).getLength() != 0;