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