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