1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26
27 #include "ppt97animations.hxx"
28
29 // header for class SdrObject
30 #include <svx/svdobj.hxx>
31 // header for class SdPage
32 #include "sdpage.hxx"
33 // header for define DBG_ERROR
34 #include <tools/debug.hxx>
35 // header for define GetXShapeForSdrObject
36 #include <svx/unoapi.hxx>
37 #include "EffectMigration.hxx"
38 #include <CustomAnimationPreset.hxx>
39 #include <com/sun/star/drawing/XShape.hpp>
40 #include <com/sun/star/presentation/TextAnimationType.hpp>
41 #include <com/sun/star/presentation/EffectNodeType.hpp>
42 #include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
43
44 using namespace ::com::sun::star;
45
46 //---------------------------------------------------------------------------------------
47
ReadStream(SvStream & rIn)48 void Ppt97AnimationInfoAtom::ReadStream( SvStream& rIn )
49 {
50 rIn >> nDimColor;
51 rIn >> nFlags;
52 rIn >> nSoundRef;
53 rIn >> nDelayTime;
54 rIn >> nOrderID;
55 rIn >> nSlideCount;
56 rIn >> nBuildType;
57 rIn >> nFlyMethod;
58 rIn >> nFlyDirection;
59 rIn >> nAfterEffect;
60 rIn >> nSubEffect;
61 rIn >> nOLEVerb;
62 rIn >> nUnknown1;
63 rIn >> nUnknown2;
64 }
65
66 //---------------------------------------------------------------------------------------
67
68 #define MEMBER_CONSTRUCTOR_LIST() \
69 m_aAtom() \
70 , m_aSoundFileUrl() \
71 , m_bDirtyCache(true) \
72 , m_aPresetId() \
73 , m_aSubType() \
74 , m_bHasSpecialDuration(false) \
75 , m_fDurationInSeconds(0.001)
76
Ppt97Animation(SvStream & rInputStream)77 Ppt97Animation::Ppt97Animation( SvStream& rInputStream )
78 : MEMBER_CONSTRUCTOR_LIST()
79 {
80 m_aAtom.ReadStream( rInputStream );
81 }
82
Ppt97Animation(const Ppt97Animation & rAnimation)83 Ppt97Animation::Ppt97Animation( const Ppt97Animation& rAnimation )
84 : MEMBER_CONSTRUCTOR_LIST()
85 {
86 *this = rAnimation;
87 }
88
operator =(const Ppt97Animation & rAnimation)89 Ppt97Animation& Ppt97Animation::operator= ( const Ppt97Animation& rAnimation )
90 {
91 m_aAtom = rAnimation.m_aAtom;
92 m_aSoundFileUrl = rAnimation.m_aSoundFileUrl;
93 m_bDirtyCache = rAnimation.m_bDirtyCache;
94 m_aPresetId = rAnimation.m_aPresetId;
95 m_aSubType = rAnimation.m_aSubType;
96 m_bHasSpecialDuration = rAnimation.m_bHasSpecialDuration;
97 m_fDurationInSeconds = rAnimation.m_fDurationInSeconds;
98
99 return *this;
100 }
101
~Ppt97Animation()102 Ppt97Animation::~Ppt97Animation()
103 {
104 }
105
operator <(const Ppt97Animation & rAnimation) const106 bool Ppt97Animation::operator < ( const Ppt97Animation& rAnimation ) const
107 {
108 return m_aAtom.nOrderID < rAnimation.m_aAtom.nOrderID;
109 }
operator >(const Ppt97Animation & rAnimation) const110 bool Ppt97Animation::operator > ( const Ppt97Animation& rAnimation ) const
111 {
112 return m_aAtom.nOrderID > rAnimation.m_aAtom.nOrderID;
113 }
HasEffect() const114 bool Ppt97Animation::HasEffect() const
115 {
116 return m_aAtom.nBuildType != 0;
117 }
HasParagraphEffect() const118 bool Ppt97Animation::HasParagraphEffect() const
119 {
120 return m_aAtom.nBuildType > 1;
121 }
GetParagraphLevel() const122 sal_Int32 Ppt97Animation::GetParagraphLevel() const
123 {
124 sal_Int32 nParagraphLevel = 0;
125 if(m_aAtom.nBuildType>1)
126 nParagraphLevel = m_aAtom.nBuildType-1;
127 return nParagraphLevel;
128 }
HasSoundEffect() const129 bool Ppt97Animation::HasSoundEffect() const
130 {
131 return m_aAtom.nSoundRef && m_aAtom.nFlags & 0x0010;
132 }
HasStopPreviousSound() const133 bool Ppt97Animation::HasStopPreviousSound() const
134 {
135 return m_aAtom.nFlags & 0x0040;
136 }
HasReverseOrder() const137 bool Ppt97Animation::HasReverseOrder() const
138 {
139 return m_aAtom.nFlags & 0x001;
140 }
HasAnimateAssociatedShape() const141 bool Ppt97Animation::HasAnimateAssociatedShape() const
142 {
143 return m_aAtom.nFlags & 0x004000;
144 }
HasAfterEffect() const145 bool Ppt97Animation::HasAfterEffect() const
146 {
147 return m_aAtom.nAfterEffect != 0;
148 }
HasAfterEffect_ChangeColor() const149 bool Ppt97Animation::HasAfterEffect_ChangeColor() const
150 {
151 return m_aAtom.nAfterEffect == 1;
152 }
HasAfterEffect_DimAtNextEffect() const153 bool Ppt97Animation::HasAfterEffect_DimAtNextEffect() const
154 {
155 return m_aAtom.nAfterEffect == 2;
156 }
157 #ifdef FUTURE
HasAfterEffect_DimAfterEffect() const158 bool Ppt97Animation::HasAfterEffect_DimAfterEffect() const
159 {
160 return m_aAtom.nAfterEffect == 3;
161 }
162 #endif
GetSoundRef() const163 sal_uInt32 Ppt97Animation::GetSoundRef() const
164 {
165 return m_aAtom.nSoundRef;
166 }
SetSoundFileUrl(const::rtl::OUString & rSoundFileUrl)167 void Ppt97Animation::SetSoundFileUrl( const ::rtl::OUString& rSoundFileUrl )
168 {
169 m_aSoundFileUrl = rSoundFileUrl;
170 }
171
GetDelayTimeInSeconds() const172 double Ppt97Animation::GetDelayTimeInSeconds() const
173 {
174 return m_aAtom.nDelayTime != 0X7FFFFFFF ? m_aAtom.nDelayTime/1000.0 : 0.0;
175 }
176
GetSpecialDuration(double & rfDurationInSeconds) const177 bool Ppt97Animation::GetSpecialDuration( double& rfDurationInSeconds ) const
178 {
179 UpdateCacheData();
180 if( m_bHasSpecialDuration )
181 rfDurationInSeconds = m_fDurationInSeconds;
182 return m_bHasSpecialDuration;
183 }
184
GetSpecialTextIterationDelay(double & rfTextIterationDelay) const185 bool Ppt97Animation::GetSpecialTextIterationDelay( double& rfTextIterationDelay ) const
186 {
187 bool bRet = false;
188 switch(this->GetTextAnimationType())
189 {
190 case presentation::TextAnimationType::BY_LETTER:
191 rfTextIterationDelay = 0.075;
192 bRet = true;
193 break;
194 case presentation::TextAnimationType::BY_WORD:
195 rfTextIterationDelay = 0.3;
196 bRet = true;
197 break;
198 default:
199 break;
200 }
201 return bRet;
202 }
203
GetDimColor() const204 sal_Int32 Ppt97Animation::GetDimColor() const
205 {
206 return static_cast<sal_Int32>(m_aAtom.nDimColor);
207 }
208
SetDimColor(sal_Int32 nDimColor)209 void Ppt97Animation::SetDimColor( sal_Int32 nDimColor )
210 {
211 m_aAtom.nDimColor = nDimColor;
212 }
SetAnimateAssociatedShape(bool bAnimate)213 void Ppt97Animation::SetAnimateAssociatedShape( bool bAnimate )
214 {
215 if( !bAnimate )
216 {
217 //the appear effect cannot be animated without text
218 if( this->GetPresetId().equals( ::rtl::OUString::createFromAscii("ooo-entrance-appear") ) )
219 return;
220 //the random effect may be the appear effect and than has the same problem
221 if( this->GetPresetId().equals( ::rtl::OUString::createFromAscii("ooo-entrance-random") ) )
222 {
223 //this case is not 100% correct -> feel free to complete
224 //i consider this case as seldom and not that problematic and a simple correct fix is not in sight
225 DBG_WARNING("you tried to deselect the animation of the form for random animation-> this has been refused");
226 return;
227 }
228
229 }
230
231 if(bAnimate)
232 m_aAtom.nFlags = m_aAtom.nFlags | 0x004000;
233 else if( HasAnimateAssociatedShape() )
234 {
235 m_aAtom.nFlags = m_aAtom.nFlags ^ 0x004000;
236 }
237 }
238
GetEffectNodeType() const239 sal_Int16 Ppt97Animation::GetEffectNodeType() const //see com::sun::star::presentation::EffectNodeType
240 {
241 sal_Int16 nRet = presentation::EffectNodeType::ON_CLICK;
242 if( m_aAtom.nFlags & 0x04 )
243 {
244 nRet = presentation::EffectNodeType::AFTER_PREVIOUS;
245 }
246 return nRet;
247 }
248
GetTextAnimationType() const249 sal_Int16 Ppt97Animation::GetTextAnimationType() const
250 {
251 sal_Int16 nRet = presentation::TextAnimationType::BY_PARAGRAPH;
252 switch( m_aAtom.nSubEffect )
253 {
254 case 0:
255 break;
256 case 2:
257 nRet = presentation::TextAnimationType::BY_LETTER;
258 break;
259 default:
260 nRet = presentation::TextAnimationType::BY_WORD;
261 break;
262 }
263 return nRet;
264 }
GetPresetId() const265 ::rtl::OUString Ppt97Animation::GetPresetId() const
266 {
267 UpdateCacheData();
268 return m_aPresetId;
269 }
GetPresetSubType() const270 ::rtl::OUString Ppt97Animation::GetPresetSubType() const
271 {
272 UpdateCacheData();
273 return m_aSubType;
274 }
275
ClearCacheData() const276 void Ppt97Animation::ClearCacheData() const
277 {
278 m_aPresetId = m_aSubType = rtl::OUString();
279 m_bHasSpecialDuration = false;
280 m_fDurationInSeconds = 0.001;
281 }
UpdateCacheData() const282 void Ppt97Animation::UpdateCacheData() const
283 {
284 if( !m_bDirtyCache )
285 return;
286
287 ClearCacheData();
288
289 if( !HasEffect() )
290 {
291 m_bDirtyCache = false;
292 return;
293 }
294
295 switch( m_aAtom.nFlyMethod )
296 {
297 case 0x0:
298 //eRetval = ::com::sun::star::presentation::AnimationEffect_APPEAR;
299 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-appear"); // --- appear ---
300 break;
301 case 0x01:
302 //eRetval = ::com::sun::star::presentation::AnimationEffect_RANDOM;
303 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-random"); // --- random ---
304 break;
305 case 0x02: // --- blinds effect ---
306 {
307 switch ( m_aAtom.nFlyDirection )
308 {
309 case 0x0:
310 //eRetval = ::com::sun::star::presentation::AnimationEffect_VERTICAL_STRIPES;
311 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-venetian-blinds");
312 m_aSubType = ::rtl::OUString::createFromAscii("horizontal"); // horizontal
313 break;
314 case 0x1:
315 //eRetval = ::com::sun::star::presentation::AnimationEffect_HORIZONTAL_STRIPES;
316 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-venetian-blinds");
317 m_aSubType = ::rtl::OUString::createFromAscii("vertical"); // vertical
318 break;
319 }
320 }
321 break;
322 case 0x03: // --- (hor/ver) shifted appear ---
323 {
324 switch ( m_aAtom.nFlyDirection )
325 {
326 case 0x0:
327 //eRetval = ::com::sun::star::presentation::AnimationEffect_HORIZONTAL_CHECKERBOARD;
328 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-checkerboard");
329 m_aSubType = ::rtl::OUString::createFromAscii("across"); // vertical ???
330 break;
331 case 0x1:
332 //eRetval = ::com::sun::star::presentation::AnimationEffect_VERTICAL_CHECKERBOARD;
333 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-checkerboard");
334 m_aSubType = ::rtl::OUString::createFromAscii("downward"); // horizontal ???
335 break;
336 }
337 }
338 break;
339 case 0x05:
340 //eRetval = ::com::sun::star::presentation::AnimationEffect_DISSOLVE; // --- dissolve ----
341 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-dissolve-in");
342 break;
343 case 0x08: // --- (hor/ver) lines ---
344 {
345 switch ( m_aAtom.nFlyDirection )
346 {
347 case 0x0:
348 //eRetval = ::com::sun::star::presentation::AnimationEffect_HORIZONTAL_LINES;
349 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-random-bars");
350 m_aSubType = ::rtl::OUString::createFromAscii("vertical"); // horizontal ???
351 break;
352 case 0x1:
353 //eRetval = ::com::sun::star::presentation::AnimationEffect_VERTICAL_LINES;
354 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-random-bars");
355 m_aSubType = rtl::OUString::createFromAscii("horizontal"); // vertical ???
356 break;
357 }
358 }
359 break;
360 case 0x09: // --- diagonal ---
361 {
362 switch ( m_aAtom.nFlyDirection )
363 {
364 case 0x4:
365 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_LOWERRIGHT;
366 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-diagonal-squares");
367 m_aSubType = rtl::OUString::createFromAscii("left-to-top"); // to left top
368 break;
369 case 0x5:
370 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_LOWERLEFT;
371 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-diagonal-squares");
372 m_aSubType = rtl::OUString::createFromAscii("right-to-top"); // to right top
373 break;
374 case 0x6:
375 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_UPPERRIGHT;
376 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-diagonal-squares");
377 m_aSubType = rtl::OUString::createFromAscii("left-to-bottom"); // to left bottom
378 break;
379 case 0x7:
380 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_UPPERLEFT;
381 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-diagonal-squares");
382 m_aSubType = rtl::OUString::createFromAscii("right-to-bottom"); // to right bottom
383 break;
384 }
385 }
386 break;
387 case 0x0a: // --- roll/wipe ---
388 {
389 switch ( m_aAtom.nFlyDirection )
390 {
391 case 0x0:
392 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_RIGHT;
393 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-wipe");
394 m_aSubType = rtl::OUString::createFromAscii("from-right"); // from right
395 break;
396 case 0x1:
397 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_BOTTOM;
398 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-wipe");
399 m_aSubType = rtl::OUString::createFromAscii("from-bottom"); // from bottom
400 break;
401 case 0x2:
402 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_LEFT;
403 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-wipe");
404 m_aSubType = rtl::OUString::createFromAscii("from-left"); // from left
405 break;
406 case 0x3:
407 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_TOP;
408 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-wipe");
409 m_aSubType = rtl::OUString::createFromAscii("from-top"); // from top
410 break;
411 }
412 }
413 break;
414 case 0x0b: //--- fade in ---
415 {
416 switch ( m_aAtom.nFlyDirection )
417 {
418 case 0x0:
419 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_CENTER;
420 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-box");
421 m_aSubType = rtl::OUString::createFromAscii("out"); // from center
422 break;
423 case 0x1:
424 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_TO_CENTER;
425 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-box");
426 m_aSubType = rtl::OUString::createFromAscii("in"); // to center
427 break;
428 }
429 }
430 break;
431 case 0x0c: // --- text effects ---
432 {
433 switch ( m_aAtom.nFlyDirection )
434 {
435 case 0x0:
436 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_LEFT;
437 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in");
438 m_aSubType = rtl::OUString::createFromAscii("from-left");
439
440 break;
441 case 0x1:
442 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_TOP;
443 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in");
444 m_aSubType = rtl::OUString::createFromAscii("from-top");
445 break;
446 case 0x2:
447 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_RIGHT;
448 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in");
449 m_aSubType = rtl::OUString::createFromAscii("from-right");
450 break;
451 case 0x3:
452 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_BOTTOM;
453 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in");
454 m_aSubType = rtl::OUString::createFromAscii("from-bottom");
455 break;
456 case 0x4:
457 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_UPPERLEFT;
458 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in");
459 m_aSubType = rtl::OUString::createFromAscii("from-top-left");
460 break;
461 case 0x5:
462 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_UPPERRIGHT;
463 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in");
464 m_aSubType = rtl::OUString::createFromAscii("from-top-right");
465 break;
466 case 0x6:
467 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_LOWERLEFT;
468 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in");
469 m_aSubType = rtl::OUString::createFromAscii("from-bottom-left");
470 break;
471 case 0x7:
472 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_LOWERRIGHT;
473 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in");
474 m_aSubType = rtl::OUString::createFromAscii("from-bottom-right");
475 break;
476 case 0x8: // -- short text effects --
477 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_FROM_LEFT;
478 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-peek-in");
479 m_aSubType = rtl::OUString::createFromAscii("from-left");
480 break;
481 case 0x9:
482 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_FROM_BOTTOM;
483 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-peek-in");
484 m_aSubType = rtl::OUString::createFromAscii("from-bottom");
485 break;
486 case 0xa:
487 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_FROM_RIGHT;
488 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-peek-in");
489 m_aSubType = rtl::OUString::createFromAscii("from-right");
490 break;
491 case 0xb:
492 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_FROM_TOP;
493 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-peek-in");
494 m_aSubType = rtl::OUString::createFromAscii("from-top");
495 break;
496 case 0xc: // -- slow text effects --
497 {
498 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_LEFT;
499 //rSpeed = ::com::sun::star::presentation::AnimationSpeed_SLOW;
500 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in-slow");
501 m_aSubType = rtl::OUString::createFromAscii("from-left");
502 }
503 break;
504 case 0xd:
505 {
506 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_TOP;
507 //rSpeed = ::com::sun::star::presentation::AnimationSpeed_SLOW;
508 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in-slow");
509 m_aSubType = rtl::OUString::createFromAscii("from-top");
510 }
511 break;
512 case 0xe:
513 {
514 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_RIGHT;
515 //rSpeed = ::com::sun::star::presentation::AnimationSpeed_SLOW;
516 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in-slow");
517 m_aSubType = rtl::OUString::createFromAscii("from-right");
518 }
519 break;
520 case 0xf:
521 {
522 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_BOTTOM;
523 //rSpeed = ::com::sun::star::presentation::AnimationSpeed_SLOW;
524 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in-slow");
525 m_aSubType = rtl::OUString::createFromAscii("from-bottom");
526 }
527 break;
528 case 0x10: // --- zoom ---
529 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_CENTER;
530 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-zoom");
531 m_aSubType = rtl::OUString::createFromAscii("in");
532 break;
533 case 0x11:
534 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_CENTER;
535 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-zoom");
536 m_aSubType = rtl::OUString::createFromAscii("in-slightly");
537 break;
538 case 0x12:
539 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_TO_CENTER;
540 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-zoom");
541 m_aSubType = rtl::OUString::createFromAscii("out");
542 break;
543 case 0x13:
544 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_TO_CENTER;
545 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-zoom");
546 m_aSubType = rtl::OUString::createFromAscii("out-slightly");
547 break;
548 case 0x14:
549 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_CENTER;
550 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-zoom");
551 m_aSubType = rtl::OUString::createFromAscii("in-from-screen-center");
552 break;
553 case 0x15:
554 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_TO_CENTER;
555 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-zoom");
556 m_aSubType = rtl::OUString::createFromAscii("out-from-screen-center");
557 break;
558 case 0x16: // --- stretch ---
559 //eRetval = ::com::sun::star::presentation::AnimationEffect_HORIZONTAL_STRETCH;
560 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-stretchy");
561 m_aSubType = rtl::OUString::createFromAscii("across");
562 break;
563 case 0x17:
564 //eRetval = ::com::sun::star::presentation::AnimationEffect_STRETCH_FROM_LEFT;
565 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-stretchy");
566 m_aSubType = rtl::OUString::createFromAscii("from-left");
567 break;
568 case 0x18:
569 //eRetval = ::com::sun::star::presentation::AnimationEffect_STRETCH_FROM_TOP;
570 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-stretchy");
571 m_aSubType = rtl::OUString::createFromAscii("from-top");
572 break;
573 case 0x19:
574 //eRetval = ::com::sun::star::presentation::AnimationEffect_STRETCH_FROM_RIGHT;
575 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-stretchy");
576 m_aSubType = rtl::OUString::createFromAscii("from-right");
577 break;
578 case 0x1a:
579 //eRetval = ::com::sun::star::presentation::AnimationEffect_STRETCH_FROM_BOTTOM;
580 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-stretchy");
581 m_aSubType = rtl::OUString::createFromAscii("from-bottom");
582 break;
583 case 0x1b: // --- rotate ---
584 //eRetval = ::com::sun::star::presentation::AnimationEffect_HORIZONTAL_ROTATE;
585 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-swivel");
586 m_aSubType = rtl::OUString::createFromAscii("vertical");
587 break;
588 case 0x1c: // --- spirale ---
589 //eRetval = ::com::sun::star::presentation::AnimationEffect_SPIRALOUT_LEFT;
590 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-spiral-in");
591 break;
592 }
593 }
594 break;
595 case 0x0d: // --- open/close ---
596 {
597 switch ( m_aAtom.nFlyDirection )
598 {
599 case 0x0:
600 //eRetval = ::com::sun::star::presentation::AnimationEffect_OPEN_VERTICAL ; // ???
601 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-split");
602 m_aSubType = rtl::OUString::createFromAscii("horizontal-out"); //horizontal open
603 break;
604 case 0x1:
605 //eRetval = ::com::sun::star::presentation::AnimationEffect_CLOSE_VERTICAL; // ???
606 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-split");
607 m_aSubType = rtl::OUString::createFromAscii("horizontal-in"); //horizontal close
608 break;
609 case 0x2:
610 //eRetval = ::com::sun::star::presentation::AnimationEffect_OPEN_HORIZONTAL; // ???
611 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-split");
612 m_aSubType = rtl::OUString::createFromAscii("vertical-out"); // vertical open
613 break;
614 case 0x3:
615 //eRetval = ::com::sun::star::presentation::AnimationEffect_CLOSE_HORIZONTAL; // ???
616 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-split");
617 m_aSubType = rtl::OUString::createFromAscii("vertical-in"); // vertical close
618 break;
619 }
620 }
621 break;
622 case 0x0e: // --- blink ---
623 {
624 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-flash-once");
625 switch ( m_aAtom.nFlyDirection )
626 {
627 case 0x0: //fast
628 m_fDurationInSeconds = 0.075;
629 m_bHasSpecialDuration = true;
630 break;
631 case 0x1: //medium
632 m_fDurationInSeconds = 0.5;
633 m_bHasSpecialDuration = true;
634 break;
635 case 0x2: //slow
636 m_fDurationInSeconds = 1.0;
637 m_bHasSpecialDuration = true;
638 break;
639 }
640 }
641 break;
642 default:
643 {
644 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-appear");
645 DBG_ERROR("no effect mapped");
646 }
647 break;
648 }
649 m_bDirtyCache = false;
650 }
651
createAndSetCustomAnimationEffect(SdrObject * pObj)652 void Ppt97Animation::createAndSetCustomAnimationEffect( SdrObject* pObj )
653 {
654
655 if( !this->HasEffect() )
656 return;
657 if( !pObj || !pObj->GetPage() )
658 {
659 DBG_ERROR("no valid SdrObject or page found for ppt import");
660 return;
661 }
662
663 uno::Reference< drawing::XShape > xShape = GetXShapeForSdrObject( pObj );
664 if( !xShape.is() )
665 {
666 DBG_ERROR("no XShape interface found for ppt import");
667 return;
668 }
669 ::sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
670 if( !pMainSequence.get() )
671 {
672 DBG_ERROR("no MainSequence found for ppt import");
673 return;
674 }
675
676 const ::sd::CustomAnimationPresets& rPresets( ::sd::CustomAnimationPresets::getCustomAnimationPresets() );
677 ::sd::CustomAnimationPresetPtr pPreset( rPresets.getEffectDescriptor( this->GetPresetId() ) );
678 if( !pPreset.get() )
679 {
680 DBG_ERROR("no suiteable preset found for ppt import");
681 return;
682 }
683
684 //--------------start doing something
685
686 //1. ------ create an effect from the presets ------
687 ::sd::CustomAnimationEffectPtr pEffect( new ::sd::CustomAnimationEffect( pPreset->create( this->GetPresetSubType() ) ) );
688 if( !pEffect.get() )
689 {
690 DBG_ASSERT(pEffect.get(),"no suiteable effect found");
691 return;
692 }
693
694 //2. ------ adapt the created effect ------
695
696 // set the shape targeted by this effect
697 pEffect->setTarget( makeAny( xShape ) );
698
699 pEffect->setBegin( this->GetDelayTimeInSeconds() );
700
701 // some effects need a different duration than that of the mapped preset effect
702 double fDurationInSeconds = 1.0;//in secunden
703 if( this->GetSpecialDuration( fDurationInSeconds ) )
704 pEffect->setDuration( fDurationInSeconds );
705
706 // set after effect
707 if( this->HasAfterEffect() )
708 {
709 pEffect->setHasAfterEffect( sal_True );
710 if( this->HasAfterEffect_ChangeColor() )
711 pEffect->setDimColor( uno::makeAny( this->GetDimColor() ) );
712 else
713 pEffect->setAfterEffectOnNext( this->HasAfterEffect_DimAtNextEffect() );
714 }
715
716 // set sound effect
717 if( this->HasSoundEffect() )
718 pEffect->createAudio( uno::makeAny( m_aSoundFileUrl ) );
719
720 // text iteration
721 pEffect->setIterateType( this->GetTextAnimationType() );
722
723 // some effects need a different delay between text iteration than that of the mapped preset effect
724 double fTextIterationDelay = 1.0;
725 if( this->GetSpecialTextIterationDelay( fTextIterationDelay ) )
726 pEffect->setIterateInterval( fTextIterationDelay );
727
728 // is the effect started on click or after the last effect (Another possible value is EffectNodeType::WITH_PREVIOUS )
729 pEffect->setNodeType( this->GetEffectNodeType() );
730
731 //set stop sound effect
732 if( this->HasStopPreviousSound() )
733 pEffect->setStopAudio();
734
735 // append the effect to the main sequence
736 if( !this->HasParagraphEffect() )
737 {
738 if( this->HasAnimateAssociatedShape() )
739 pEffect->setTargetSubItem( presentation::ShapeAnimationSubType::AS_WHOLE );
740 else
741 pEffect->setTargetSubItem( presentation::ShapeAnimationSubType::AS_WHOLE ); //todo: set ONLY_TEXT again if that is fixed
742 //pEffect->setTargetSubItem( presentation::ShapeAnimationSubType::ONLY_TEXT );
743 }
744
745 //3. ------ put the created effect to the model and do some last changes fro paragraph effects ------
746 pMainSequence->append( pEffect );
747 if( this->HasParagraphEffect() )
748 {
749 sal_Int32 nParagraphLevel = this->GetParagraphLevel();
750 double fDelaySeconds = this->GetDelayTimeInSeconds();
751 sal_Bool bAnimateAssociatedShape = this->HasAnimateAssociatedShape();//or only text
752 sal_Bool bTextReverse = this->HasReverseOrder();
753
754 // now create effects for each paragraph
755 ::sd::CustomAnimationTextGroupPtr pGroup = pMainSequence->
756 createTextGroup( pEffect, nParagraphLevel, fDelaySeconds, bAnimateAssociatedShape, bTextReverse );
757
758 if( pGroup )
759 {
760 const ::sd::EffectSequence& rEffects = pGroup->getEffects();
761 ::sd::EffectSequence::const_iterator aIter = rEffects.begin();
762
763 ::sd::CustomAnimationEffectPtr pLastEffect;
764 sal_Int32 nIndex = 0;
765 for( ; aIter != rEffects.end(); aIter++ )
766 {
767 ::sd::CustomAnimationEffectPtr pGroupEffect(*aIter);
768
769 ////todo? if( nIndex > 1 && pLastEffect && this->HasSoundEffect() )
770 //// pLastEffect->setStopAudio();
771 if( nIndex < 2 )
772 {
773 pGroupEffect->setNodeType( this->GetEffectNodeType() );
774 }
775 else if( nIndex > 0 )
776 {
777 bool bAtParagraphBegin = false;
778 if(!bTextReverse)
779 bAtParagraphBegin = pGroupEffect->getParaDepth() < nParagraphLevel;
780 else
781 bAtParagraphBegin = !pLastEffect || pLastEffect->getParaDepth() < nParagraphLevel;
782 if( bAtParagraphBegin )
783 pGroupEffect->setNodeType( this->GetEffectNodeType() );
784 else if( this->GetTextAnimationType() == presentation::TextAnimationType::BY_PARAGRAPH )
785 pGroupEffect->setNodeType( presentation::EffectNodeType::WITH_PREVIOUS );
786 else
787 pGroupEffect->setNodeType( presentation::EffectNodeType::AFTER_PREVIOUS );
788 }
789 pLastEffect = pGroupEffect;
790 nIndex++;
791 }
792 }
793 }
794 pMainSequence->rebuild();
795 }
796