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