1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/presentation/EffectNodeType.hpp>
21 #include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
22 #include <com/sun/star/presentation/TextAnimationType.hpp>
23 #include <com/sun/star/presentation/ParagraphTarget.hpp>
24 #include <svx/unoshape.hxx>
25 #include <svx/svdotext.hxx>
26 #include <svx/svdopath.hxx>
27 #include "drawdoc.hxx"
29 #include <CustomAnimationPreset.hxx>
30 #include <TransitionPreset.hxx>
31 #include <EffectMigration.hxx>
32 #include <anminfo.hxx>
35 using namespace ::com::sun::star::uno
;
36 using namespace ::com::sun::star::animations
;
37 using namespace ::com::sun::star::presentation
;
39 using ::com::sun::star::drawing::XShape
;
41 struct deprecated_FadeEffect_conversion_table_entry
43 FadeEffect meFadeEffect
;
44 const sal_Char
* mpPresetId
;
46 deprecated_FadeEffect_conversion_table
[] =
48 // OOo 1.x transitions
49 { FadeEffect_FADE_FROM_LEFT
, "wipe-right" },
50 { FadeEffect_FADE_FROM_TOP
, "wipe-down" },
51 { FadeEffect_FADE_FROM_RIGHT
, "wipe-left" },
52 { FadeEffect_FADE_FROM_BOTTOM
, "wipe-up" },
54 { FadeEffect_CLOCKWISE
, "wheel-clockwise-1-spoke" },
56 { FadeEffect_UNCOVER_TO_LEFT
, "uncover-left" },
57 { FadeEffect_UNCOVER_TO_UPPERLEFT
, "uncover-left-up" },
58 { FadeEffect_UNCOVER_TO_TOP
, "uncover-up" },
59 { FadeEffect_UNCOVER_TO_UPPERRIGHT
, "uncover-right-up" },
60 { FadeEffect_UNCOVER_TO_RIGHT
, "uncover-right" },
61 { FadeEffect_UNCOVER_TO_LOWERRIGHT
, "uncover-right-down" },
62 { FadeEffect_UNCOVER_TO_BOTTOM
, "uncover-down" },
63 { FadeEffect_UNCOVER_TO_LOWERLEFT
, "uncover-left-down" },
65 { FadeEffect_VERTICAL_LINES
, "random-bars-vertical" },
66 { FadeEffect_HORIZONTAL_LINES
, "random-bars-horizontal" },
68 { FadeEffect_VERTICAL_CHECKERBOARD
, "checkerboard-down" },
69 { FadeEffect_HORIZONTAL_CHECKERBOARD
, "checkerboard-across" },
71 { FadeEffect_FADE_TO_CENTER
, "box-in" },
72 { FadeEffect_FADE_FROM_CENTER
, "box-out" },
74 { FadeEffect_VERTICAL_STRIPES
, "venetian-blinds-vertical" },
75 { FadeEffect_HORIZONTAL_STRIPES
, "venetian-blinds-horizontal" },
77 { FadeEffect_MOVE_FROM_LEFT
, "cover-right" },
78 { FadeEffect_MOVE_FROM_TOP
, "cover-down" },
79 { FadeEffect_MOVE_FROM_RIGHT
, "cover-left" },
80 { FadeEffect_MOVE_FROM_BOTTOM
, "cover-up" },
81 { FadeEffect_MOVE_FROM_UPPERLEFT
, "cover-right-down" },
82 { FadeEffect_MOVE_FROM_UPPERRIGHT
, "cover-left-down" },
83 { FadeEffect_MOVE_FROM_LOWERRIGHT
, "cover-left-up" },
84 { FadeEffect_MOVE_FROM_LOWERLEFT
, "cover-right-up" },
86 { FadeEffect_DISSOLVE
, "dissolve" },
88 { FadeEffect_RANDOM
, "random-transition" },
90 { FadeEffect_ROLL_FROM_LEFT
, "push-right" },
91 { FadeEffect_ROLL_FROM_TOP
, "push-down" },
92 { FadeEffect_ROLL_FROM_RIGHT
, "push-left" },
93 { FadeEffect_ROLL_FROM_BOTTOM
, "push-up" },
95 { FadeEffect_CLOSE_VERTICAL
, "split-horizontal-in" },
96 { FadeEffect_CLOSE_HORIZONTAL
, "split-vertical-in" },
97 { FadeEffect_OPEN_VERTICAL
, "split-horizontal-out" },
98 { FadeEffect_OPEN_HORIZONTAL
, "split-vertical-out" },
100 { FadeEffect_FADE_FROM_UPPERLEFT
, "diagonal-squares-right-down" },
101 { FadeEffect_FADE_FROM_UPPERRIGHT
, "diagonal-squares-left-down" },
102 { FadeEffect_FADE_FROM_LOWERLEFT
, "diagonal-squares-right-up" },
103 { FadeEffect_FADE_FROM_LOWERRIGHT
, "diagonal-squares-left-up" },
105 // OOo 1.x transitions not in OOo 2.x
106 { FadeEffect_CLOCKWISE
, "clock-wipe-twelve" },
107 { FadeEffect_COUNTERCLOCKWISE
, "reverse-clock-wipe-twelve" },
108 { FadeEffect_SPIRALIN_LEFT
, "spiral-wipe-top-left-clockwise" },
109 { FadeEffect_SPIRALIN_RIGHT
, "spiral-wipe-top-right-counter-clockwise" },
110 { FadeEffect_SPIRALOUT_LEFT
, "spiral-wipe-out-to-bottom-right-clockwise" },
111 { FadeEffect_SPIRALOUT_RIGHT
, "spiral-wipe-out-to-bottom-left-counter-clockwise" },
112 { FadeEffect_WAVYLINE_FROM_LEFT
, "snake-wipe-top-left-vertical" },
113 { FadeEffect_WAVYLINE_FROM_TOP
, "snake-wipe-top-left-horizontal" },
114 { FadeEffect_WAVYLINE_FROM_RIGHT
, "snake-wipe-bottom-right-vertical" },
115 { FadeEffect_WAVYLINE_FROM_BOTTOM
, "snake-wipe-bottom-right-horizontal" },
116 { FadeEffect_STRETCH_FROM_LEFT
, "wipe-right" }, // todo
117 { FadeEffect_STRETCH_FROM_TOP
, "wipe-down" }, // todo
118 { FadeEffect_STRETCH_FROM_RIGHT
, "wipe-left" }, // todo
119 { FadeEffect_STRETCH_FROM_BOTTOM
, "wipe-up" }, // todo
121 // OOo 1.x not available transitions
123 { FadeEffect_CLOCKWISE
, "wheel-clockwise-2-spokes" },
124 { FadeEffect_CLOCKWISE
, "wheel-clockwise-3-spokes" },
125 { FadeEffect_CLOCKWISE
, "wheel-clockwise-4-spokes" },
126 { FadeEffect_CLOCKWISE
, "wheel-clockwise-8-spokes" },
128 { FadeEffect_FADE_FROM_CENTER
, "shape-circle" },
129 { FadeEffect_FADE_FROM_CENTER
, "shape-diamond" },
130 { FadeEffect_FADE_FROM_CENTER
, "shape-plus" },
132 { FadeEffect_CLOCKWISE
, "wedge" },
134 { FadeEffect_DISSOLVE
, "fade-through-black" },
136 { FadeEffect_CLOCKWISE
, "zoom-rotate-in" },
138 { FadeEffect_HORIZONTAL_LINES
, "comb-horizontal" },
139 { FadeEffect_VERTICAL_LINES
, "comb-vertical" },
141 { FadeEffect_DISSOLVE
, "fade-smoothly" },
143 { FadeEffect_NONE
, 0 }
147 cut cut (same as NONE?)
148 cut-through-black cut toBlack
152 void EffectMigration::SetFadeEffect( SdPage
* pPage
, ::com::sun::star::presentation::FadeEffect eNewEffect
)
154 deprecated_FadeEffect_conversion_table_entry
* pEntry
= deprecated_FadeEffect_conversion_table
;
155 while( (pEntry
->meFadeEffect
!= FadeEffect_NONE
) && (pEntry
->meFadeEffect
!= eNewEffect
) )
158 if( pEntry
->mpPresetId
)
160 const OUString
aPresetId( OUString::createFromAscii( pEntry
->mpPresetId
) );
162 const TransitionPresetList
& rPresetList
= TransitionPreset::getTransitionPresetList();
164 TransitionPresetList::const_iterator
aIt( rPresetList
.begin());
165 const TransitionPresetList::const_iterator
aEndIt( rPresetList
.end());
166 for( ; aIt
!= aEndIt
; ++aIt
)
168 if( (*aIt
)->getPresetId() == aPresetId
)
170 pPage
->setTransitionType( (*aIt
)->getTransition() );
171 pPage
->setTransitionSubtype( (*aIt
)->getSubtype() );
172 pPage
->setTransitionDirection( (*aIt
)->getDirection() );
173 pPage
->setTransitionFadeColor( (*aIt
)->getFadeColor() );
180 pPage
->setTransitionType( 0 );
181 pPage
->setTransitionSubtype( 0 );
182 pPage
->setTransitionDirection( 0 );
183 pPage
->setTransitionFadeColor( 0 );
187 FadeEffect
EffectMigration::GetFadeEffect( const SdPage
* pPage
)
189 const TransitionPresetList
& rPresetList
= TransitionPreset::getTransitionPresetList();
190 TransitionPresetList::const_iterator
aIt( rPresetList
.begin());
191 const TransitionPresetList::const_iterator
aEndIt( rPresetList
.end());
192 for( ; aIt
!= aEndIt
; ++aIt
)
194 if( ( (*aIt
)->getTransition() == pPage
->getTransitionType() ) &&
195 ( (*aIt
)->getSubtype() == pPage
->getTransitionSubtype() ) &&
196 ( (*aIt
)->getDirection() == pPage
->getTransitionDirection() ) &&
197 ( (*aIt
)->getFadeColor() == pPage
->getTransitionFadeColor() ) )
199 const OUString
& aPresetId
= (*aIt
)->getPresetId();
201 deprecated_FadeEffect_conversion_table_entry
* pEntry
= deprecated_FadeEffect_conversion_table
;
202 while( (pEntry
->meFadeEffect
!= FadeEffect_NONE
) && (!aPresetId
.equalsAscii( pEntry
->mpPresetId
) ) )
205 return pEntry
->meFadeEffect
;
208 return FadeEffect_NONE
;
211 struct deprecated_AnimationEffect_conversion_table_entry
213 AnimationEffect meEffect
;
214 const sal_Char
* mpPresetId
;
215 const sal_Char
* mpPresetSubType
;
217 deprecated_AnimationEffect_conversion_table
[] =
219 // OOo 1.x entrance effects
220 { AnimationEffect_APPEAR
, "ooo-entrance-appear",0 },
222 { AnimationEffect_FADE_TO_CENTER
, "ooo-entrance-box","in" },
223 { AnimationEffect_FADE_FROM_CENTER
, "ooo-entrance-box","out" },
225 { AnimationEffect_VERTICAL_CHECKERBOARD
, "ooo-entrance-checkerboard","downward" },
226 { AnimationEffect_HORIZONTAL_CHECKERBOARD
, "ooo-entrance-checkerboard","across" },
228 { AnimationEffect_FADE_FROM_UPPERLEFT
, "ooo-entrance-diagonal-squares","right-to-bottom" },
229 { AnimationEffect_FADE_FROM_UPPERRIGHT
, "ooo-entrance-diagonal-squares","left-to-bottom" },
230 { AnimationEffect_FADE_FROM_LOWERLEFT
, "ooo-entrance-diagonal-squares","right-to-top" },
231 { AnimationEffect_FADE_FROM_LOWERRIGHT
, "ooo-entrance-diagonal-squares","left-to-top" },
233 { AnimationEffect_DISSOLVE
, "ooo-entrance-dissolve-in",0 },
235 { AnimationEffect_MOVE_FROM_LEFT
, "ooo-entrance-fly-in","from-left" },
236 { AnimationEffect_MOVE_FROM_TOP
, "ooo-entrance-fly-in","from-top" },
237 { AnimationEffect_MOVE_FROM_RIGHT
, "ooo-entrance-fly-in","from-right" },
238 { AnimationEffect_MOVE_FROM_BOTTOM
, "ooo-entrance-fly-in","from-bottom" },
239 { AnimationEffect_MOVE_FROM_UPPERLEFT
, "ooo-entrance-fly-in","from-top-left" },
240 { AnimationEffect_MOVE_FROM_UPPERRIGHT
, "ooo-entrance-fly-in","from-top-right" },
241 { AnimationEffect_MOVE_FROM_LOWERRIGHT
, "ooo-entrance-fly-in","from-bottom-right" },
242 { AnimationEffect_MOVE_FROM_LOWERLEFT
, "ooo-entrance-fly-in","from-bottom-left" },
244 { AnimationEffect_MOVE_FROM_BOTTOM
, "ooo-entrance-fly-in-slow", "from-bottom" },
245 { AnimationEffect_MOVE_FROM_LEFT
, "ooo-entrance-fly-in-slow", "from-left" },
246 { AnimationEffect_MOVE_FROM_RIGHT
, "ooo-entrance-fly-in-slow", "from-right" },
247 { AnimationEffect_MOVE_FROM_TOP
, "ooo-entrance-fly-in-slow", "from-top" },
249 { AnimationEffect_MOVE_SHORT_FROM_LEFT
, "ooo-entrance-peek-in","from-left" },
250 { AnimationEffect_MOVE_SHORT_FROM_TOP
, "ooo-entrance-peek-in","from-top" },
251 { AnimationEffect_MOVE_SHORT_FROM_RIGHT
, "ooo-entrance-peek-in","from-right" },
252 { AnimationEffect_MOVE_SHORT_FROM_BOTTOM
, "ooo-entrance-peek-in","from-bottom" },
254 { AnimationEffect_VERTICAL_LINES
, "ooo-entrance-random-bars","horizontal" },
255 { AnimationEffect_HORIZONTAL_LINES
, "ooo-entrance-random-bars","vertical" },
257 { AnimationEffect_RANDOM
, "ooo-entrance-random",0 },
259 { AnimationEffect_CLOSE_VERTICAL
, "ooo-entrance-split","horizontal-in" },
260 { AnimationEffect_CLOSE_HORIZONTAL
, "ooo-entrance-split","vertical-in" },
261 { AnimationEffect_OPEN_VERTICAL
, "ooo-entrance-split","horizontal-out" },
262 { AnimationEffect_OPEN_HORIZONTAL
, "ooo-entrance-split","vertical-out" },
264 { AnimationEffect_VERTICAL_STRIPES
, "ooo-entrance-venetian-blinds","horizontal" },
265 { AnimationEffect_HORIZONTAL_STRIPES
, "ooo-entrance-venetian-blinds","vertical" },
267 { AnimationEffect_FADE_FROM_LEFT
, "ooo-entrance-wipe","from-left" },
268 { AnimationEffect_FADE_FROM_TOP
, "ooo-entrance-wipe","from-bottom" },
269 { AnimationEffect_FADE_FROM_RIGHT
, "ooo-entrance-wipe","from-right" },
270 { AnimationEffect_FADE_FROM_BOTTOM
, "ooo-entrance-wipe","from-top" },
272 { AnimationEffect_HORIZONTAL_ROTATE
, "ooo-entrance-swivel","vertical" },
273 { AnimationEffect_VERTICAL_ROTATE
, "ooo-entrance-swivel","horizontal" },
275 { AnimationEffect_STRETCH_FROM_LEFT
, "ooo-entrance-stretchy","from-left" },
276 { AnimationEffect_STRETCH_FROM_UPPERLEFT
, "ooo-entrance-stretchy","from-top-left" },
277 { AnimationEffect_STRETCH_FROM_TOP
, "ooo-entrance-stretchy","from-top" },
278 { AnimationEffect_STRETCH_FROM_UPPERRIGHT
, "ooo-entrance-stretchy","from-top-right" },
279 { AnimationEffect_STRETCH_FROM_RIGHT
, "ooo-entrance-stretchy","from-right" },
280 { AnimationEffect_STRETCH_FROM_LOWERRIGHT
, "ooo-entrance-stretchy","from-bottom-right" },
281 { AnimationEffect_STRETCH_FROM_BOTTOM
, "ooo-entrance-stretchy","from-bottom" },
282 { AnimationEffect_STRETCH_FROM_LOWERLEFT
, "ooo-entrance-stretchy","from-bottom-left" },
284 { AnimationEffect_HORIZONTAL_STRETCH
, "ooo-entrance-expand", 0 },
286 { AnimationEffect_CLOCKWISE
, "ooo-entrance-wheel","1" },
287 { AnimationEffect_COUNTERCLOCKWISE
, "ooo-entrance-clock-wipe","counter-clockwise" },
289 { AnimationEffect_SPIRALIN_LEFT
, "ooo-entrance-spiral-wipe", "from-top-left-clockwise" },
290 { AnimationEffect_SPIRALIN_RIGHT
, "ooo-entrance-spiral-wipe", "from-top-right-counter-clockwise" },
291 { AnimationEffect_SPIRALOUT_LEFT
, "ooo-entrance-spiral-wipe", "from-center-clockwise" },
292 { AnimationEffect_SPIRALOUT_RIGHT
, "ooo-entrance-spiral-wipe", "from-center-counter-clockwise" },
294 { AnimationEffect_WAVYLINE_FROM_LEFT
, "ooo-entrance-snake-wipe","from-top-left-vertical" },
295 { AnimationEffect_WAVYLINE_FROM_TOP
, "ooo-entrance-snake-wipe","from-top-left-horizontal" },
296 { AnimationEffect_WAVYLINE_FROM_RIGHT
, "ooo-entrance-snake-wipe","from-bottom-right-vertical" },
297 { AnimationEffect_WAVYLINE_FROM_BOTTOM
, "ooo-entrance-snake-wipe","from-bottom-right-horizontal" },
299 // ooo 1.x exit effects
300 { AnimationEffect_HIDE
, "ooo-exit-disappear",0 },
301 { AnimationEffect_MOVE_TO_LEFT
, "ooo-exit-fly-out", "from-right" },
302 { AnimationEffect_MOVE_TO_TOP
, "ooo-exit-fly-out", "from-bottom" },
303 { AnimationEffect_MOVE_TO_RIGHT
, "ooo-exit-fly-out", "from-left" },
304 { AnimationEffect_MOVE_TO_BOTTOM
, "ooo-exit-fly-out", "from-top" },
305 { AnimationEffect_MOVE_TO_UPPERLEFT
, "ooo-exit-fly-out", "from-top-right" },
306 { AnimationEffect_MOVE_TO_UPPERRIGHT
, "ooo-exit-fly-out", "from-top-left" },
307 { AnimationEffect_MOVE_TO_LOWERRIGHT
, "ooo-exit-fly-out", "from-bottom-left" },
308 { AnimationEffect_MOVE_TO_LOWERLEFT
, "ooo-exit-fly-out", "from-bottom-right" },
309 { AnimationEffect_MOVE_SHORT_TO_LEFT
, "ooo-exit-peek-out", "from-right" },
310 { AnimationEffect_MOVE_SHORT_TO_UPPERLEFT
, "ooo-exit-peek-out", "from-right" },
311 { AnimationEffect_MOVE_SHORT_TO_TOP
, "ooo-exit-peek-out", "from-bottom" },
312 { AnimationEffect_MOVE_SHORT_TO_UPPERRIGHT
, "ooo-exit-peek-out", "from-bottom" },
313 { AnimationEffect_MOVE_SHORT_TO_RIGHT
, "ooo-exit-peek-out", "from-left" },
314 { AnimationEffect_MOVE_SHORT_TO_LOWERRIGHT
, "ooo-exit-peek-out","from-left" },
315 { AnimationEffect_MOVE_SHORT_TO_BOTTOM
, "ooo-exit-peek-out", "from-top" },
316 { AnimationEffect_MOVE_SHORT_TO_LOWERLEFT
, "ooo-exit-peek-out", "from-top" },
318 // no matching in OOo 2.x
319 { AnimationEffect_MOVE_SHORT_FROM_UPPERLEFT
, "ooo-entrance-peek-in","from-left" },
320 { AnimationEffect_MOVE_SHORT_FROM_UPPERRIGHT
, "ooo-entrance-peek-in","from-top" },
321 { AnimationEffect_MOVE_SHORT_FROM_LOWERRIGHT
, "ooo-entrance-peek-in","from-right" },
322 { AnimationEffect_MOVE_SHORT_FROM_LOWERLEFT
, "ooo-entrance-peek-in","from-bottom" },
323 { AnimationEffect_LASER_FROM_LEFT
, "ooo-entrance-fly-in","from-left" },
324 { AnimationEffect_LASER_FROM_TOP
, "ooo-entrance-fly-in","from-top" },
325 { AnimationEffect_LASER_FROM_RIGHT
, "ooo-entrance-fly-in","from-right" },
326 { AnimationEffect_LASER_FROM_BOTTOM
, "ooo-entrance-fly-in","from-bottom" },
327 { AnimationEffect_LASER_FROM_UPPERLEFT
, "ooo-entrance-fly-in","from-top-left" },
328 { AnimationEffect_LASER_FROM_UPPERRIGHT
, "ooo-entrance-fly-in","from-top-right" },
329 { AnimationEffect_LASER_FROM_LOWERLEFT
, "ooo-entrance-fly-in","from-bottom-left" },
330 { AnimationEffect_LASER_FROM_LOWERRIGHT
, "ooo-entrance-fly-in","from-bottom-right" },
332 // no matching in OOo 1.x
334 { AnimationEffect_FADE_TO_CENTER
, "ooo-entrance-circle", "in" },
335 { AnimationEffect_FADE_FROM_CENTER
, "ooo-entrance-circle", "out" },
336 { AnimationEffect_FADE_TO_CENTER
, "ooo-entrance-diamond", "in" },
337 { AnimationEffect_FADE_FROM_CENTER
, "ooo-entrance-diamond", "out" },
338 { AnimationEffect_FADE_TO_CENTER
, "ooo-entrance-plus", "in" },
339 { AnimationEffect_FADE_FROM_CENTER
, "ooo-entrance-plus", "out" },
340 { AnimationEffect_CLOCKWISE
, "ooo-entrance-wedge", 0 },
341 { AnimationEffect_CLOCKWISE
, "ooo-entrance-wheel", "2" },
342 { AnimationEffect_CLOCKWISE
, "ooo-entrance-wheel", "3" },
343 { AnimationEffect_CLOCKWISE
, "ooo-entrance-wheel", "4" },
344 { AnimationEffect_CLOCKWISE
, "ooo-entrance-wheel", "8" },
346 { AnimationEffect_MOVE_FROM_RIGHT
, "ooo-entrance-boomerang", 0 },
347 { AnimationEffect_MOVE_FROM_UPPERRIGHT
, "ooo-entrance-bounce", 0 },
348 { AnimationEffect_MOVE_FROM_BOTTOM
, "ooo-entrance-curve-up", 0 },
349 { AnimationEffect_MOVE_FROM_TOP
, "ooo-entrance-float", 0 },
350 { AnimationEffect_MOVE_FROM_LEFT
, "ooo-entrance-glide", 0 },
351 { AnimationEffect_MOVE_FROM_BOTTOM
, "ooo-entrance-magnify", 0 },
352 { AnimationEffect_HORIZONTAL_ROTATE
, "ooo-entrance-pinwheel", 0 },
353 { AnimationEffect_MOVE_FROM_LEFT
, "ooo-entrance-breaks", 0 },
354 { AnimationEffect_MOVE_FROM_LEFT
, "ooo-entrance-sling", 0 },
355 { AnimationEffect_MOVE_FROM_LEFT
, "ooo-entrance-spiral-in", 0 },
356 { AnimationEffect_MOVE_FROM_LEFT
, "ooo-entrance-thread", 0 },
357 { AnimationEffect_MOVE_FROM_BOTTOM
, "ooo-entrance-ascend", 0 },
358 { AnimationEffect_MOVE_FROM_BOTTOM
, "ooo-entrance-center-revolve", 0 },
359 { AnimationEffect_APPEAR
, "ooo-entrance-compress", 0 },
360 { AnimationEffect_MOVE_SHORT_FROM_TOP
, "ooo-entrance-descend", 0 },
361 { AnimationEffect_MOVE_SHORT_FROM_LEFT
, "ooo-entrance-ease-in", 0 },
362 { AnimationEffect_MOVE_FROM_BOTTOM
, "ooo-entrance-rise-up", 0 },
363 { AnimationEffect_HORIZONTAL_ROTATE
, "ooo-entrance-spin-in", 0 },
364 { AnimationEffect_STRETCH_FROM_LEFT
, "ooo-entrance-stretchy", "across" },
365 { AnimationEffect_STRETCH_FROM_TOP
, "ooo-entrance-stretchy", "downward" },
367 { AnimationEffect_FADE_FROM_CENTER
, "ooo-entrance-zoom","in" },
368 { AnimationEffect_FADE_FROM_CENTER
, "ooo-entrance-zoom","in-slightly" },
369 { AnimationEffect_FADE_FROM_CENTER
, "ooo-entrance-zoom","in-from-screen-center" },
370 { AnimationEffect_FADE_TO_CENTER
, "ooo-entrance-zoom","out" },
371 { AnimationEffect_FADE_TO_CENTER
, "ooo-entrance-zoom","out-slightly" },
372 { AnimationEffect_FADE_TO_CENTER
, "ooo-entrance-zoom","out-from-screen-center" },
374 { AnimationEffect_DISSOLVE
, "ooo-entrance-fade-in", 0 },
375 { AnimationEffect_DISSOLVE
, "ooo-entrance-fade-in-and-zoom", 0 },
376 { AnimationEffect_DISSOLVE
, "ooo-entrance-fade-in-and-swivel", 0 },
378 // still open (no matching effect: AnimationEffect_ZOOM_IN_FROM_*,
379 // AnimationEffect_ZOOM_OUT_FROM_*, AnimationEffect_PATH
381 { AnimationEffect_NONE
, 0, 0 }
384 EffectSequence::iterator
ImplFindEffect( MainSequencePtr
& pMainSequence
, const Reference
< XShape
>& rShape
, sal_Int16 nSubItem
)
386 EffectSequence::iterator aIter
;
388 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); ++aIter
)
390 CustomAnimationEffectPtr
pEffect( (*aIter
) );
391 if( (pEffect
->getTargetShape() == rShape
) && (pEffect
->getTargetSubItem() == nSubItem
) )
398 static bool implIsInsideGroup( SdrObject
* pObj
)
400 return pObj
&& pObj
->GetObjList() && pObj
->GetObjList()->GetUpList();
403 void EffectMigration::SetAnimationEffect( SvxShape
* pShape
, AnimationEffect eEffect
)
405 DBG_ASSERT( pShape
&& pShape
->GetSdrObject() && pShape
->GetSdrObject()->GetPage(),
406 "sd::EffectMigration::SetAnimationEffect(), invalid argument!" );
407 if( !pShape
|| !pShape
->GetSdrObject() || !pShape
->GetSdrObject()->GetPage() )
410 SdrObject
* pObj
= pShape
->GetSdrObject();
411 if( implIsInsideGroup( pObj
) )
415 OUString aPresetSubType
;
417 if( !ConvertAnimationEffect( eEffect
, aPresetId
, aPresetSubType
) )
419 OSL_FAIL( "sd::EffectMigration::SetAnimationEffect(), no mapping for given AnimationEffect value" );
423 const CustomAnimationPresets
& rPresets
= CustomAnimationPresets::getCustomAnimationPresets();
425 CustomAnimationPresetPtr
pPreset( rPresets
.getEffectDescriptor( aPresetId
) );
426 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
428 if( pPreset
.get() && pMainSequence
.get() )
430 const Reference
< XShape
> xShape( pShape
);
432 EffectSequence::iterator
aIterOnlyBackground( ImplFindEffect( pMainSequence
, xShape
, ShapeAnimationSubType::ONLY_BACKGROUND
) );
433 EffectSequence::iterator
aIterAsWhole( ImplFindEffect( pMainSequence
, xShape
, ShapeAnimationSubType::AS_WHOLE
) );
434 const EffectSequence::iterator
aEnd( pMainSequence
->getEnd() );
436 bool bEffectCreated
= false;
438 if( (aIterOnlyBackground
== aEnd
) && (aIterAsWhole
== aEnd
) )
440 // check if there is already an text effect for this shape
441 EffectSequence::iterator
aIterOnlyText( ImplFindEffect( pMainSequence
, xShape
, ShapeAnimationSubType::ONLY_TEXT
) );
442 if( aIterOnlyText
!= aEnd
)
444 // check if this is an animation text group
445 sal_Int32 nGroupId
= (*aIterOnlyText
)->getGroupId();
448 CustomAnimationTextGroupPtr pGroup
= pMainSequence
->findGroup( nGroupId
);
451 // add an effect to animate the shape
452 pMainSequence
->setAnimateForm( pGroup
, true );
455 EffectSequence::iterator
aIter( ImplFindEffect( pMainSequence
, xShape
, ShapeAnimationSubType::ONLY_BACKGROUND
) );
459 if( ((*aIter
)->getPresetId() != aPresetId
) ||
460 ((*aIter
)->getPresetSubType() != aPresetSubType
) )
462 (*aIter
)->replaceNode( pPreset
->create( aPresetSubType
) );
463 pMainSequence
->rebuild();
464 bEffectCreated
= true;
471 if( !bEffectCreated
)
473 // if there is not yet an effect that target this shape, we generate one
474 // we insert the shape effect before it
475 Reference
< XAnimationNode
> xNode( pPreset
->create( aPresetSubType
) );
476 DBG_ASSERT( xNode
.is(), "EffectMigration::SetAnimationEffect(), could not create preset!" );
479 CustomAnimationEffectPtr
pEffect( new CustomAnimationEffect( xNode
) );
480 pEffect
->setTarget( makeAny( xShape
) );
481 SdPage
* pPage
= dynamic_cast< SdPage
* >( pObj
->GetPage() );
482 const bool bManual
= (pPage
== 0) || (pPage
->GetPresChange() == PRESCHANGE_MANUAL
);
484 pEffect
->setNodeType( EffectNodeType::AFTER_PREVIOUS
);
486 pMainSequence
->append( pEffect
);
488 if( ( pObj
->GetObjInventor() == SdrInventor
) && ( pObj
->GetObjIdentifier() == OBJ_OUTLINETEXT
) )
490 // special case for outline text, effects are always mapped to text group effect
492 createTextGroup( pEffect
, 10, bManual
? -1 : 0.0, sal_False
, sal_False
);
499 // if there is already an effect targeting this shape
501 CustomAnimationEffectPtr pEffect
;
502 if( aIterAsWhole
!= aEnd
)
504 pEffect
= (*aIterAsWhole
);
508 pEffect
= (*aIterOnlyBackground
);
513 if( (pEffect
->getPresetId() != aPresetId
) ||
514 (pEffect
->getPresetSubType() != aPresetSubType
) )
516 pMainSequence
->replace( pEffect
, pPreset
, aPresetSubType
);
523 // --------------------------------------------------------------------
525 AnimationEffect
EffectMigration::GetAnimationEffect( SvxShape
* pShape
)
528 OUString aPresetSubType
;
530 SdrObject
* pObj
= pShape
->GetSdrObject();
531 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
533 if( pMainSequence
.get() )
535 const Reference
< XShape
> xShape( pShape
);
537 EffectSequence::iterator aIter
;
539 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); ++aIter
)
541 CustomAnimationEffectPtr
pEffect( (*aIter
) );
542 if( pEffect
->getTargetShape() == xShape
)
544 if( (pEffect
->getTargetSubItem() == ShapeAnimationSubType::ONLY_BACKGROUND
) ||
545 (pEffect
->getTargetSubItem() == ShapeAnimationSubType::AS_WHOLE
))
547 if( pEffect
->getDuration() != 0.1 ) // ignore appear effects created from old text effect import
549 aPresetId
= (*aIter
)->getPresetId();
550 aPresetSubType
= (*aIter
)->getPresetSubType();
558 // now find old effect
559 AnimationEffect eEffect
= AnimationEffect_NONE
;
561 if( !ConvertPreset( aPresetId
, &aPresetSubType
, eEffect
) )
562 ConvertPreset( aPresetId
, 0, eEffect
);
568 // --------------------------------------------------------------------
570 void EffectMigration::SetTextAnimationEffect( SvxShape
* pShape
, AnimationEffect eEffect
)
572 DBG_ASSERT( pShape
&& pShape
->GetSdrObject() && pShape
->GetSdrObject()->GetPage(),
573 "sd::EffectMigration::SetAnimationEffect(), invalid argument!" );
574 if( !pShape
|| !pShape
->GetSdrObject() || !pShape
->GetSdrObject()->GetPage() )
577 SdrObject
* pObj
= pShape
->GetSdrObject();
578 if( implIsInsideGroup( pObj
) )
581 // first map the deprecated AnimationEffect to a preset and subtype
583 OUString aPresetSubType
;
585 if( !ConvertAnimationEffect( eEffect
, aPresetId
, aPresetSubType
) )
587 OSL_FAIL( "sd::EffectMigration::SetAnimationEffect(), no mapping for given AnimationEffect value" );
591 SdrTextObj
* pTextObj
= dynamic_cast< SdrTextObj
* >( pObj
);
593 // ignore old text effects on shape without text
594 if( (pTextObj
== 0) || (!pTextObj
->HasText()) )
597 const CustomAnimationPresets
& rPresets
= CustomAnimationPresets::getCustomAnimationPresets();
599 // create an effect from this preset
600 CustomAnimationPresetPtr
pPreset( rPresets
.getEffectDescriptor( aPresetId
) );
602 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
604 if( pPreset
.get() && pMainSequence
.get() )
606 const Reference
< XShape
> xShape( pShape
);
608 EffectSequence::iterator
aIterOnlyText( ImplFindEffect( pMainSequence
, xShape
, ShapeAnimationSubType::ONLY_TEXT
) );
609 const EffectSequence::iterator
aEnd( pMainSequence
->getEnd() );
611 CustomAnimationTextGroupPtr pGroup
;
613 // is there already an animation text group for this shape?
614 if( aIterOnlyText
!= aEnd
)
616 const sal_Int32 nGroupId
= (*aIterOnlyText
)->getGroupId();
618 pGroup
= pMainSequence
->findGroup( nGroupId
);
621 // if there is not yet a group, create it
622 if( pGroup
.get() == 0 )
624 CustomAnimationEffectPtr pShapeEffect
;
626 EffectSequence::iterator
aIterOnlyBackground( ImplFindEffect( pMainSequence
, xShape
, ShapeAnimationSubType::ONLY_BACKGROUND
) );
627 if( aIterOnlyBackground
!= aEnd
)
629 pShapeEffect
= (*aIterOnlyBackground
);
633 EffectSequence::iterator
aIterAsWhole( ImplFindEffect( pMainSequence
, xShape
, ShapeAnimationSubType::AS_WHOLE
) );
634 if( aIterAsWhole
!= aEnd
)
636 pShapeEffect
= (*aIterAsWhole
);
641 CustomAnimationPresetPtr
pShapePreset( rPresets
.getEffectDescriptor( "ooo-entrance-appear" ) );
643 Reference
< XAnimationNode
> xNode( pPreset
->create( aEmpty
) );
644 DBG_ASSERT( xNode
.is(), "EffectMigration::SetTextAnimationEffect(), could not create preset!" );
647 pShapeEffect
.reset( new CustomAnimationEffect( xNode
) );
648 pShapeEffect
->setTarget( makeAny( xShape
) );
649 pShapeEffect
->setDuration( 0.1 );
650 pMainSequence
->append( pShapeEffect
);
652 SdPage
* pPage
= dynamic_cast< SdPage
* >( pObj
->GetPage() );
653 if( pPage
&& pPage
->GetPresChange() != PRESCHANGE_MANUAL
)
654 pShapeEffect
->setNodeType( EffectNodeType::AFTER_PREVIOUS
);
659 if( pShapeEffect
.get() )
661 SdPage
* pPage
= dynamic_cast< SdPage
* >( pObj
->GetPage() );
662 const bool bManual
= (pPage
== 0) || (pPage
->GetPresChange() == PRESCHANGE_MANUAL
);
664 // now create effects for each paragraph
667 createTextGroup( pShapeEffect
, 10, bManual
? -1 : 0.0, sal_True
, sal_False
);
671 if( pGroup
.get() != 0 )
673 const bool bLaserEffect
= (eEffect
>= AnimationEffect_LASER_FROM_LEFT
) && (eEffect
<= AnimationEffect_LASER_FROM_LOWERRIGHT
);
675 // now we have a group, so check if all effects are same as we like to have them
676 const EffectSequence
& rEffects
= pGroup
->getEffects();
678 EffectSequence::const_iterator aIter
;
679 for( aIter
= rEffects
.begin(); aIter
!= rEffects
.end(); ++aIter
)
681 // only work on paragraph targets
682 if( (*aIter
)->getTarget().getValueType() == ::getCppuType((const ParagraphTarget
*)0) )
684 if( ((*aIter
)->getPresetId() != aPresetId
) ||
685 ((*aIter
)->getPresetSubType() != aPresetSubType
) )
687 (*aIter
)->replaceNode( pPreset
->create( aPresetSubType
) );
692 (*aIter
)->setIterateType( TextAnimationType::BY_LETTER
);
693 (*aIter
)->setIterateInterval( 0.5 );// TODO:
705 pMainSequence
->rebuild();
709 // --------------------------------------------------------------------
711 AnimationEffect
EffectMigration::GetTextAnimationEffect( SvxShape
* pShape
)
714 OUString aPresetSubType
;
716 SdrObject
* pObj
= pShape
->GetSdrObject();
719 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
721 if( pMainSequence
.get() )
723 const Reference
< XShape
> xShape( pShape
);
724 EffectSequence::iterator
aIter( ImplFindEffect( pMainSequence
, xShape
, ShapeAnimationSubType::ONLY_TEXT
) );
725 if( aIter
!= pMainSequence
->getEnd() )
727 aPresetId
= (*aIter
)->getPresetId();
728 aPresetSubType
= (*aIter
)->getPresetSubType();
733 // now find old effect
734 AnimationEffect eEffect
= AnimationEffect_NONE
;
736 if( !ConvertPreset( aPresetId
, &aPresetSubType
, eEffect
) )
737 ConvertPreset( aPresetId
, 0, eEffect
);
742 // --------------------------------------------------------------------
744 bool EffectMigration::ConvertPreset( const OUString
& rPresetId
, const OUString
* pPresetSubType
, AnimationEffect
& rEffect
)
746 rEffect
= AnimationEffect_NONE
;
747 if( !rPresetId
.isEmpty() )
749 // first try a match for preset id and subtype
750 deprecated_AnimationEffect_conversion_table_entry
* p
= deprecated_AnimationEffect_conversion_table
;
751 while( p
->mpPresetId
)
753 if( rPresetId
.equalsAscii( p
->mpPresetId
) &&
754 (( p
->mpPresetSubType
== 0 ) ||
755 ( pPresetSubType
== 0) ||
756 ( pPresetSubType
->equalsAscii( p
->mpPresetSubType
)) ) )
758 rEffect
= p
->meEffect
;
767 // empty preset id means AnimationEffect_NONE
772 // --------------------------------------------------------------------
774 bool EffectMigration::ConvertAnimationEffect( const AnimationEffect
& rEffect
, OUString
& rPresetId
, OUString
& rPresetSubType
)
776 deprecated_AnimationEffect_conversion_table_entry
* p
= deprecated_AnimationEffect_conversion_table
;
777 while( p
->mpPresetId
)
779 if( p
->meEffect
== rEffect
)
781 rPresetId
= OUString::createFromAscii( p
->mpPresetId
);
782 rPresetSubType
= OUString::createFromAscii( p
->mpPresetSubType
);
791 // --------------------------------------------------------------------
793 double EffectMigration::ConvertAnimationSpeed( AnimationSpeed eSpeed
)
798 case AnimationSpeed_SLOW
: fDuration
= 2.0; break;
799 case AnimationSpeed_FAST
: fDuration
= 0.5; break;
801 fDuration
= 1.0; break;
805 // --------------------------------------------------------------------
807 void EffectMigration::SetAnimationSpeed( SvxShape
* pShape
, AnimationSpeed eSpeed
)
809 DBG_ASSERT( pShape
&& pShape
->GetSdrObject() && pShape
->GetSdrObject()->GetPage(),
810 "sd::EffectMigration::SetAnimationEffect(), invalid argument!" );
811 if( !pShape
|| !pShape
->GetSdrObject() || !pShape
->GetSdrObject()->GetPage() )
814 SdrObject
* pObj
= pShape
->GetSdrObject();
815 if( implIsInsideGroup( pObj
) )
818 double fDuration
= ConvertAnimationSpeed( eSpeed
);
820 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
822 const Reference
< XShape
> xShape( pShape
);
824 EffectSequence::iterator aIter
;
825 bool bNeedRebuild
= false;
827 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); ++aIter
)
829 CustomAnimationEffectPtr
pEffect( (*aIter
) );
830 if( pEffect
->getTargetShape() == xShape
)
832 if( pEffect
->getDuration() != 0.1 )
833 pEffect
->setDuration( fDuration
);
839 pMainSequence
->rebuild();
842 // --------------------------------------------------------------------
844 AnimationSpeed
EffectMigration::GetAnimationSpeed( SvxShape
* pShape
)
846 SdrObject
* pObj
= pShape
->GetSdrObject();
847 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
849 const Reference
< XShape
> xShape( pShape
);
851 EffectSequence::iterator aIter
;
853 double fDuration
= 1.0;
855 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); ++aIter
)
857 CustomAnimationEffectPtr
pEffect( (*aIter
) );
858 if( pEffect
->getTargetShape() == xShape
)
860 if( pEffect
->getDuration() != 0.1 )
862 fDuration
= pEffect
->getDuration();
868 return ConvertDuration( fDuration
);
871 // --------------------------------------------------------------------
873 AnimationSpeed
EffectMigration::ConvertDuration( double fDuration
)
875 AnimationSpeed eSpeed
;
877 if( fDuration
< 1.0 )
878 eSpeed
= AnimationSpeed_FAST
;
879 else if( fDuration
> 1.5 )
880 eSpeed
= AnimationSpeed_SLOW
;
882 eSpeed
= AnimationSpeed_MEDIUM
;
887 // --------------------------------------------------------------------
889 void EffectMigration::SetDimColor( SvxShape
* pShape
, sal_Int32 nColor
)
891 DBG_ASSERT( pShape
&& pShape
->GetSdrObject() && pShape
->GetSdrObject()->GetPage(),
892 "sd::EffectMigration::SetAnimationEffect(), invalid argument!" );
893 if( !pShape
|| !pShape
->GetSdrObject() || !pShape
->GetSdrObject()->GetPage() )
896 SdrObject
* pObj
= pShape
->GetSdrObject();
897 if( implIsInsideGroup( pObj
) )
900 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
902 const Reference
< XShape
> xShape( pShape
);
904 EffectSequence::iterator aIter
;
905 bool bNeedRebuild
= false;
907 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); ++aIter
)
909 CustomAnimationEffectPtr
pEffect( (*aIter
) );
910 if( pEffect
->getTargetShape() == xShape
)
912 pEffect
->setHasAfterEffect( true );
913 pEffect
->setDimColor( makeAny( nColor
) );
914 pEffect
->setAfterEffectOnNext( true );
920 pMainSequence
->rebuild();
923 // --------------------------------------------------------------------
925 sal_Int32
EffectMigration::GetDimColor( SvxShape
* pShape
)
927 sal_Int32 nColor
= 0;
930 SdrObject
* pObj
= pShape
->GetSdrObject();
931 if( pObj
&& pObj
->GetPage() )
933 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
935 const Reference
< XShape
> xShape( pShape
);
936 EffectSequence::iterator aIter
;
938 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); ++aIter
)
940 CustomAnimationEffectPtr
pEffect( (*aIter
) );
941 if( (pEffect
->getTargetShape() == xShape
) &&
942 pEffect
->getDimColor().hasValue() &&
943 pEffect
->hasAfterEffect())
945 pEffect
->getDimColor() >>= nColor
;
955 // --------------------------------------------------------------------
958 void EffectMigration::SetDimHide( SvxShape
* pShape
, sal_Bool bDimHide
)
960 DBG_ASSERT( pShape
&& pShape
->GetSdrObject() && pShape
->GetSdrObject()->GetPage(),
961 "sd::EffectMigration::SetAnimationEffect(), invalid argument!" );
962 if( !pShape
|| !pShape
->GetSdrObject() || !pShape
->GetSdrObject()->GetPage() )
965 SdrObject
* pObj
= pShape
->GetSdrObject();
966 if( implIsInsideGroup( pObj
) )
969 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
971 const Reference
< XShape
> xShape( pShape
);
973 EffectSequence::iterator aIter
;
974 bool bNeedRebuild
= false;
976 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); ++aIter
)
978 CustomAnimationEffectPtr
pEffect( (*aIter
) );
979 if( pEffect
->getTargetShape() == xShape
)
981 pEffect
->setHasAfterEffect( bDimHide
? true : false );
984 pEffect
->setDimColor( aEmpty
);
986 pEffect
->setAfterEffectOnNext( false );
992 pMainSequence
->rebuild();
995 // --------------------------------------------------------------------
997 sal_Bool
EffectMigration::GetDimHide( SvxShape
* pShape
)
999 sal_Bool bRet
= sal_False
;
1002 SdrObject
* pObj
= pShape
->GetSdrObject();
1003 if( pObj
&& pObj
->GetPage() )
1005 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
1007 const Reference
< XShape
> xShape( pShape
);
1009 EffectSequence::iterator aIter
;
1010 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); ++aIter
)
1012 CustomAnimationEffectPtr
pEffect( (*aIter
) );
1013 if( pEffect
->getTargetShape() == xShape
)
1015 bRet
= pEffect
->hasAfterEffect() &&
1016 !pEffect
->getDimColor().hasValue() &&
1017 (!pEffect
->IsAfterEffectOnNext());
1027 // --------------------------------------------------------------------
1029 void EffectMigration::SetDimPrevious( SvxShape
* pShape
, sal_Bool bDimPrevious
)
1031 DBG_ASSERT( pShape
&& pShape
->GetSdrObject() && pShape
->GetSdrObject()->GetPage(),
1032 "sd::EffectMigration::SetAnimationEffect(), invalid argument!" );
1033 if( !pShape
|| !pShape
->GetSdrObject() || !pShape
->GetSdrObject()->GetPage() )
1036 SdrObject
* pObj
= pShape
->GetSdrObject();
1037 if( implIsInsideGroup( pObj
) )
1043 aColor
<<= (sal_Int32
)COL_LIGHTGRAY
;
1045 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
1047 const Reference
< XShape
> xShape( pShape
);
1049 EffectSequence::iterator aIter
;
1050 bool bNeedRebuild
= false;
1052 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); ++aIter
)
1054 CustomAnimationEffectPtr
pEffect( (*aIter
) );
1055 if( pEffect
->getTargetShape() == xShape
)
1057 pEffect
->setHasAfterEffect( bDimPrevious
);
1058 if( !bDimPrevious
|| !pEffect
->getDimColor().hasValue() )
1059 pEffect
->setDimColor( aColor
);
1060 pEffect
->setAfterEffectOnNext( true );
1061 bNeedRebuild
= true;
1066 pMainSequence
->rebuild();
1069 // --------------------------------------------------------------------
1071 sal_Bool
EffectMigration::GetDimPrevious( SvxShape
* pShape
)
1073 sal_Bool bRet
= sal_False
;
1076 SdrObject
* pObj
= pShape
->GetSdrObject();
1077 if( pObj
&& pObj
->GetPage() )
1079 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
1081 const Reference
< XShape
> xShape( pShape
);
1083 EffectSequence::iterator aIter
;
1084 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); ++aIter
)
1086 CustomAnimationEffectPtr
pEffect( (*aIter
) );
1087 if( pEffect
->getTargetShape() == xShape
)
1089 bRet
= pEffect
->hasAfterEffect() &&
1090 pEffect
->getDimColor().hasValue() &&
1091 pEffect
->IsAfterEffectOnNext();
1101 // --------------------------------------------------------------------
1103 void EffectMigration::SetPresentationOrder( SvxShape
* pShape
, sal_Int32 nNewPos
)
1105 if( !pShape
|| !pShape
->GetSdrObject() || !pShape
->GetSdrObject()->GetPage() )
1108 SdrObject
* pObj
= pShape
->GetSdrObject();
1109 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
1111 EffectSequence
& rSequence
= pMainSequence
->getSequence();
1113 sal_Int32 nCurrentPos
= -1;
1114 std::vector
< std::vector
< EffectSequence::iterator
> > aEffectVector(1);
1116 if( !rSequence
.empty() )
1118 Reference
< XShape
> xThis( pShape
);
1119 Reference
< XShape
> xCurrent
;
1121 EffectSequence::iterator
aIter( rSequence
.begin() );
1122 EffectSequence::iterator
aEnd( rSequence
.end() );
1123 for( nPos
= 0; aIter
!= aEnd
; ++aIter
)
1125 CustomAnimationEffectPtr pEffect
= (*aIter
);
1127 if( !xCurrent
.is() )
1129 xCurrent
= pEffect
->getTargetShape();
1131 else if( pEffect
->getTargetShape() != xCurrent
)
1134 xCurrent
= pEffect
->getTargetShape();
1135 aEffectVector
.resize( nPos
+1 );
1138 // is this the first effect for xThis shape?
1139 if(( nCurrentPos
== -1 ) && ( xCurrent
== xThis
) )
1144 aEffectVector
[nPos
].push_back( aIter
);
1148 // check if there is at least one effect for xThis
1149 if( nCurrentPos
== -1 )
1151 OSL_FAIL("sd::EffectMigration::SetPresentationOrder() failed cause this shape has no effect" );
1155 // check trivial case
1156 if( nCurrentPos
!= nNewPos
)
1158 std::vector
< CustomAnimationEffectPtr
> aEffects
;
1160 std::vector
< EffectSequence::iterator
>::iterator
aIter( aEffectVector
[nCurrentPos
].begin() );
1161 std::vector
< EffectSequence::iterator
>::iterator
aEnd( aEffectVector
[nCurrentPos
].end() );
1162 while( aIter
!= aEnd
)
1164 aEffects
.push_back( (*(*aIter
)) );
1165 rSequence
.erase( (*aIter
++) );
1168 if( nNewPos
> nCurrentPos
)
1171 std::vector
< CustomAnimationEffectPtr
>::iterator
aTempIter( aEffects
.begin() );
1172 std::vector
< CustomAnimationEffectPtr
>::iterator
aTempEnd( aEffects
.end() );
1174 if( nNewPos
== (sal_Int32
)aEffectVector
.size() )
1176 while( aTempIter
!= aTempEnd
)
1178 rSequence
.push_back( (*aTempIter
++) );
1183 EffectSequence::iterator
aPos( aEffectVector
[nNewPos
][0] );
1184 while( aTempIter
!= aTempEnd
)
1186 rSequence
.insert( aPos
, (*aTempIter
++) );
1192 // --------------------------------------------------------------------
1194 /** Returns the position of the given SdrObject in the Presentation order.
1195 * This function returns -1 if the SdrObject is not in the Presentation order
1196 * or if its the path-object.
1198 sal_Int32
EffectMigration::GetPresentationOrder( SvxShape
* pShape
)
1200 sal_Int32 nPos
= -1, nFound
= -1;
1202 SdrObject
* pObj
= pShape
->GetSdrObject();
1203 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
1205 EffectSequence
& rSequence
= pMainSequence
->getSequence();
1207 Reference
< XShape
> xThis( pShape
);
1208 Reference
< XShape
> xCurrent
;
1210 EffectSequence::iterator
aIter( rSequence
.begin() );
1211 EffectSequence::iterator
aEnd( rSequence
.end() );
1212 for( ; aIter
!= aEnd
; ++aIter
)
1214 CustomAnimationEffectPtr pEffect
= (*aIter
);
1216 if( !xCurrent
.is() || pEffect
->getTargetShape() != xCurrent
)
1219 xCurrent
= pEffect
->getTargetShape();
1221 // is this the first effect for xThis shape?
1222 if( xCurrent
== xThis
)
1233 // --------------------------------------------------------------------
1235 void EffectMigration::UpdateSoundEffect( SvxShape
* pShape
, SdAnimationInfo
* pInfo
)
1239 SdrObject
* pObj
= pShape
->GetSdrObject();
1240 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
1242 const Reference
< XShape
> xShape( pShape
);
1244 EffectSequence::iterator aIter
;
1245 bool bNeedRebuild
= false;
1247 OUString aSoundFile
;
1248 if( pInfo
->mbSoundOn
)
1249 aSoundFile
= pInfo
->maSoundFile
;
1251 for( aIter
= pMainSequence
->getBegin(); aIter
!= pMainSequence
->getEnd(); ++aIter
)
1253 CustomAnimationEffectPtr
pEffect( (*aIter
) );
1254 if( pEffect
->getTargetShape() == xShape
)
1256 if( !aSoundFile
.isEmpty() )
1258 pEffect
->createAudio( makeAny( aSoundFile
) );
1262 pEffect
->removeAudio();
1264 bNeedRebuild
= true;
1269 pMainSequence
->rebuild();
1273 // --------------------------------------------------------------------
1275 OUString
EffectMigration::GetSoundFile( SvxShape
* pShape
)
1277 OUString aSoundFile
;
1281 SdrObject
* pObj
= pShape
->GetSdrObject();
1282 if( pObj
&& pObj
->GetPage() )
1284 sd::MainSequencePtr pMainSequence
= static_cast<SdPage
*>(pObj
->GetPage())->getMainSequence();
1286 const Reference
< XShape
> xShape( pShape
);
1288 EffectSequence::iterator aIter
;
1290 for( aIter
= pMainSequence
->getBegin();
1291 (aSoundFile
.isEmpty()) && (aIter
!= pMainSequence
->getEnd());
1294 CustomAnimationEffectPtr
pEffect( (*aIter
) );
1295 if( pEffect
->getTargetShape() == xShape
)
1297 if( pEffect
->getAudio().is() )
1298 pEffect
->getAudio()->getSource() >>= aSoundFile
;
1306 // --------------------------------------------------------------------
1308 sal_Bool
EffectMigration::GetSoundOn( SvxShape
* pShape
)
1310 return !GetSoundFile( pShape
).isEmpty();
1313 // --------------------------------------------------------------------
1315 void EffectMigration::SetAnimationPath( SvxShape
* pShape
, SdrPathObj
* pPathObj
)
1317 if( pShape
&& pPathObj
)
1319 SdrObject
* pObj
= pShape
->GetSdrObject();
1323 const Reference
< XShape
> xShape( pShape
);
1324 SdPage
* pPage
= dynamic_cast< SdPage
* >(pPathObj
->GetPage());
1327 boost::shared_ptr
< sd::MainSequence
> pMainSequence( pPage
->getMainSequence() );
1328 if( pMainSequence
.get() )
1329 CustomAnimationEffectPtr
pCreated( pMainSequence
->append( *pPathObj
, makeAny( xShape
), -1.0 ) );
1335 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */