merge the formfield patch from ooo-build
[ooovba.git] / sd / source / filter / ppt / ppt97animations.cxx
blob9448059c1c795159a602eddff6a812cc905b884e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ppt97animations.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "ppt97animations.hxx"
36 // header for class SdrObject
37 #include <svx/svdobj.hxx>
38 // header for class SdPage
39 #include "sdpage.hxx"
40 // header for define DBG_ERROR
41 #include <tools/debug.hxx>
42 // header for define GetXShapeForSdrObject
43 #include <svx/unoapi.hxx>
44 #include "EffectMigration.hxx"
45 #include <CustomAnimationPreset.hxx>
46 #include <com/sun/star/drawing/XShape.hpp>
47 #include <com/sun/star/presentation/TextAnimationType.hpp>
48 #include <com/sun/star/presentation/EffectNodeType.hpp>
49 #include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
51 using namespace ::com::sun::star;
53 //---------------------------------------------------------------------------------------
55 void Ppt97AnimationInfoAtom::ReadStream( SvStream& rIn )
57 rIn >> nDimColor;
58 rIn >> nFlags;
59 rIn >> nSoundRef;
60 rIn >> nDelayTime;
61 rIn >> nOrderID;
62 rIn >> nSlideCount;
63 rIn >> nBuildType;
64 rIn >> nFlyMethod;
65 rIn >> nFlyDirection;
66 rIn >> nAfterEffect;
67 rIn >> nSubEffect;
68 rIn >> nOLEVerb;
69 rIn >> nUnknown1;
70 rIn >> nUnknown2;
73 //---------------------------------------------------------------------------------------
75 #define MEMBER_CONSTRUCTOR_LIST() \
76 m_aAtom() \
77 , m_aSoundFileUrl() \
78 , m_bDirtyCache(true) \
79 , m_aPresetId() \
80 , m_aSubType() \
81 , m_bHasSpecialDuration(false) \
82 , m_fDurationInSeconds(0.001)
84 Ppt97Animation::Ppt97Animation( SvStream& rInputStream )
85 : MEMBER_CONSTRUCTOR_LIST()
87 m_aAtom.ReadStream( rInputStream );
90 Ppt97Animation::Ppt97Animation()
91 : MEMBER_CONSTRUCTOR_LIST()
95 Ppt97Animation::Ppt97Animation( const Ppt97Animation& rAnimation )
96 : MEMBER_CONSTRUCTOR_LIST()
98 *this = rAnimation;
101 Ppt97Animation& Ppt97Animation::operator= ( const Ppt97Animation& rAnimation )
103 m_aAtom = rAnimation.m_aAtom;
104 m_aSoundFileUrl = rAnimation.m_aSoundFileUrl;
105 m_bDirtyCache = rAnimation.m_bDirtyCache;
106 m_aPresetId = rAnimation.m_aPresetId;
107 m_aSubType = rAnimation.m_aSubType;
108 m_bHasSpecialDuration = rAnimation.m_bHasSpecialDuration;
109 m_fDurationInSeconds = rAnimation.m_fDurationInSeconds;
111 return *this;
114 Ppt97Animation::~Ppt97Animation()
118 bool Ppt97Animation::operator < ( const Ppt97Animation& rAnimation ) const
120 return m_aAtom.nOrderID < rAnimation.m_aAtom.nOrderID;
122 bool Ppt97Animation::operator > ( const Ppt97Animation& rAnimation ) const
124 return m_aAtom.nOrderID > rAnimation.m_aAtom.nOrderID;
126 bool Ppt97Animation::HasEffect() const
128 return m_aAtom.nBuildType != 0;
130 bool Ppt97Animation::HasParagraphEffect() const
132 return m_aAtom.nBuildType > 1;
134 sal_Int32 Ppt97Animation::GetParagraphLevel() const
136 sal_Int32 nParagraphLevel = 0;
137 if(m_aAtom.nBuildType>1)
138 nParagraphLevel = m_aAtom.nBuildType-1;
139 return nParagraphLevel;
141 bool Ppt97Animation::HasSoundEffect() const
143 return m_aAtom.nSoundRef && m_aAtom.nFlags & 0x0010;
145 bool Ppt97Animation::HasStopPreviousSound() const
147 return m_aAtom.nFlags & 0x0040;
149 bool Ppt97Animation::HasReverseOrder() const
151 return m_aAtom.nFlags & 0x001;
153 bool Ppt97Animation::HasAnimateAssociatedShape() const
155 return m_aAtom.nFlags & 0x004000;
157 bool Ppt97Animation::HasAfterEffect() const
159 return m_aAtom.nAfterEffect != 0;
161 bool Ppt97Animation::HasAfterEffect_ChangeColor() const
163 return m_aAtom.nAfterEffect == 1;
165 bool Ppt97Animation::HasAfterEffect_DimAtNextEffect() const
167 return m_aAtom.nAfterEffect == 2;
169 bool Ppt97Animation::HasAfterEffect_DimAfterEffect() const
171 return m_aAtom.nAfterEffect == 3;
174 UINT32 Ppt97Animation::GetSoundRef() const
176 return m_aAtom.nSoundRef;
178 void Ppt97Animation::SetSoundFileUrl( const ::rtl::OUString& rSoundFileUrl )
180 m_aSoundFileUrl = rSoundFileUrl;
183 double Ppt97Animation::GetDelayTimeInSeconds() const
185 return m_aAtom.nDelayTime != 0X7FFFFFFF ? m_aAtom.nDelayTime/1000.0 : 0.0;
188 bool Ppt97Animation::GetSpecialDuration( double& rfDurationInSeconds ) const
190 UpdateCacheData();
191 if( m_bHasSpecialDuration )
192 rfDurationInSeconds = m_fDurationInSeconds;
193 return m_bHasSpecialDuration;
196 bool Ppt97Animation::GetSpecialTextIterationDelay( double& rfTextIterationDelay ) const
198 bool bRet = false;
199 switch(this->GetTextAnimationType())
201 case presentation::TextAnimationType::BY_LETTER:
202 rfTextIterationDelay = 0.075;
203 bRet = true;
204 break;
205 case presentation::TextAnimationType::BY_WORD:
206 rfTextIterationDelay = 0.3;
207 bRet = true;
208 break;
209 default:
210 break;
212 return bRet;
215 sal_Int32 Ppt97Animation::GetDimColor() const
217 return static_cast<sal_Int32>(m_aAtom.nDimColor);
220 void Ppt97Animation::SetDimColor( sal_Int32 nDimColor )
222 m_aAtom.nDimColor = nDimColor;
224 void Ppt97Animation::SetAnimateAssociatedShape( bool bAnimate )
226 if( !bAnimate )
228 //the appear effect cannot be animated without text
229 if( this->GetPresetId().equals( ::rtl::OUString::createFromAscii("ooo-entrance-appear") ) )
230 return;
231 //the random effect may be the appear effect and than has the same problem
232 if( this->GetPresetId().equals( ::rtl::OUString::createFromAscii("ooo-entrance-random") ) )
234 //this case is not 100% correct -> feel free to complete
235 //i consider this case as seldom and not that problematic and a simple correct fix is not in sight
236 DBG_WARNING("you tried to deselect the animation of the form for random animation-> this has been refused");
237 return;
242 if(bAnimate)
243 m_aAtom.nFlags = m_aAtom.nFlags | 0x004000;
244 else if( HasAnimateAssociatedShape() )
246 m_aAtom.nFlags = m_aAtom.nFlags ^ 0x004000;
250 sal_Int16 Ppt97Animation::GetEffectNodeType() const //see com::sun::star::presentation::EffectNodeType
252 sal_Int16 nRet = presentation::EffectNodeType::ON_CLICK;
253 if( m_aAtom.nFlags & 0x04 )
255 nRet = presentation::EffectNodeType::AFTER_PREVIOUS;
257 return nRet;
260 sal_Int16 Ppt97Animation::GetTextAnimationType() const
262 sal_Int16 nRet = presentation::TextAnimationType::BY_PARAGRAPH;
263 switch( m_aAtom.nSubEffect )
265 case 0:
266 break;
267 case 2:
268 nRet = presentation::TextAnimationType::BY_LETTER;
269 break;
270 default:
271 nRet = presentation::TextAnimationType::BY_WORD;
272 break;
274 return nRet;
276 ::rtl::OUString Ppt97Animation::GetPresetId() const
278 UpdateCacheData();
279 return m_aPresetId;
281 ::rtl::OUString Ppt97Animation::GetPresetSubType() const
283 UpdateCacheData();
284 return m_aSubType;
287 void Ppt97Animation::ClearCacheData() const
289 m_aPresetId = m_aSubType = rtl::OUString();
290 m_bHasSpecialDuration = false;
291 m_fDurationInSeconds = 0.001;
293 void Ppt97Animation::UpdateCacheData() const
295 if( !m_bDirtyCache )
296 return;
298 ClearCacheData();
300 if( !HasEffect() )
302 m_bDirtyCache = false;
303 return;
306 switch( m_aAtom.nFlyMethod )
308 case 0x0:
309 //eRetval = ::com::sun::star::presentation::AnimationEffect_APPEAR;
310 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-appear"); // --- appear ---
311 break;
312 case 0x01:
313 //eRetval = ::com::sun::star::presentation::AnimationEffect_RANDOM;
314 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-random"); // --- random ---
315 break;
316 case 0x02: // --- blinds effect ---
318 switch ( m_aAtom.nFlyDirection )
320 case 0x0:
321 //eRetval = ::com::sun::star::presentation::AnimationEffect_VERTICAL_STRIPES;
322 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-venetian-blinds");
323 m_aSubType = ::rtl::OUString::createFromAscii("horizontal"); // horizontal
324 break;
325 case 0x1:
326 //eRetval = ::com::sun::star::presentation::AnimationEffect_HORIZONTAL_STRIPES;
327 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-venetian-blinds");
328 m_aSubType = ::rtl::OUString::createFromAscii("vertical"); // vertical
329 break;
332 break;
333 case 0x03: // --- (hor/ver) shifted appear ---
335 switch ( m_aAtom.nFlyDirection )
337 case 0x0:
338 //eRetval = ::com::sun::star::presentation::AnimationEffect_HORIZONTAL_CHECKERBOARD;
339 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-checkerboard");
340 m_aSubType = ::rtl::OUString::createFromAscii("across"); // vertical ???
341 break;
342 case 0x1:
343 //eRetval = ::com::sun::star::presentation::AnimationEffect_VERTICAL_CHECKERBOARD;
344 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-checkerboard");
345 m_aSubType = ::rtl::OUString::createFromAscii("downward"); // horizontal ???
346 break;
349 break;
350 case 0x05:
351 //eRetval = ::com::sun::star::presentation::AnimationEffect_DISSOLVE; // --- dissolve ----
352 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-dissolve-in");
353 break;
354 case 0x08: // --- (hor/ver) lines ---
356 switch ( m_aAtom.nFlyDirection )
358 case 0x0:
359 //eRetval = ::com::sun::star::presentation::AnimationEffect_HORIZONTAL_LINES;
360 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-random-bars");
361 m_aSubType = ::rtl::OUString::createFromAscii("vertical"); // horizontal ???
362 break;
363 case 0x1:
364 //eRetval = ::com::sun::star::presentation::AnimationEffect_VERTICAL_LINES;
365 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-random-bars");
366 m_aSubType = rtl::OUString::createFromAscii("horizontal"); // vertical ???
367 break;
370 break;
371 case 0x09: // --- diagonal ---
373 switch ( m_aAtom.nFlyDirection )
375 case 0x4:
376 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_LOWERRIGHT;
377 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-diagonal-squares");
378 m_aSubType = rtl::OUString::createFromAscii("left-to-top"); // to left top
379 break;
380 case 0x5:
381 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_LOWERLEFT;
382 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-diagonal-squares");
383 m_aSubType = rtl::OUString::createFromAscii("right-to-top"); // to right top
384 break;
385 case 0x6:
386 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_UPPERRIGHT;
387 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-diagonal-squares");
388 m_aSubType = rtl::OUString::createFromAscii("left-to-bottom"); // to left bottom
389 break;
390 case 0x7:
391 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_UPPERLEFT;
392 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-diagonal-squares");
393 m_aSubType = rtl::OUString::createFromAscii("right-to-bottom"); // to right bottom
394 break;
397 break;
398 case 0x0a: // --- roll/wipe ---
400 switch ( m_aAtom.nFlyDirection )
402 case 0x0:
403 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_RIGHT;
404 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-wipe");
405 m_aSubType = rtl::OUString::createFromAscii("from-right"); // from right
406 break;
407 case 0x1:
408 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_BOTTOM;
409 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-wipe");
410 m_aSubType = rtl::OUString::createFromAscii("from-bottom"); // from bottom
411 break;
412 case 0x2:
413 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_LEFT;
414 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-wipe");
415 m_aSubType = rtl::OUString::createFromAscii("from-left"); // from left
416 break;
417 case 0x3:
418 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_TOP;
419 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-wipe");
420 m_aSubType = rtl::OUString::createFromAscii("from-top"); // from top
421 break;
424 break;
425 case 0x0b: //--- fade in ---
427 switch ( m_aAtom.nFlyDirection )
429 case 0x0:
430 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_CENTER;
431 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-box");
432 m_aSubType = rtl::OUString::createFromAscii("out"); // from center
433 break;
434 case 0x1:
435 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_TO_CENTER;
436 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-box");
437 m_aSubType = rtl::OUString::createFromAscii("in"); // to center
438 break;
441 break;
442 case 0x0c: // --- text effects ---
444 switch ( m_aAtom.nFlyDirection )
446 case 0x0:
447 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_LEFT;
448 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in");
449 m_aSubType = rtl::OUString::createFromAscii("from-left");
451 break;
452 case 0x1:
453 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_TOP;
454 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in");
455 m_aSubType = rtl::OUString::createFromAscii("from-top");
456 break;
457 case 0x2:
458 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_RIGHT;
459 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in");
460 m_aSubType = rtl::OUString::createFromAscii("from-right");
461 break;
462 case 0x3:
463 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_BOTTOM;
464 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in");
465 m_aSubType = rtl::OUString::createFromAscii("from-bottom");
466 break;
467 case 0x4:
468 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_UPPERLEFT;
469 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in");
470 m_aSubType = rtl::OUString::createFromAscii("from-top-left");
471 break;
472 case 0x5:
473 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_UPPERRIGHT;
474 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in");
475 m_aSubType = rtl::OUString::createFromAscii("from-top-right");
476 break;
477 case 0x6:
478 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_LOWERLEFT;
479 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in");
480 m_aSubType = rtl::OUString::createFromAscii("from-bottom-left");
481 break;
482 case 0x7:
483 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_LOWERRIGHT;
484 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in");
485 m_aSubType = rtl::OUString::createFromAscii("from-bottom-right");
486 break;
487 case 0x8: // -- short text effects --
488 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_FROM_LEFT;
489 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-peek-in");
490 m_aSubType = rtl::OUString::createFromAscii("from-left");
491 break;
492 case 0x9:
493 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_FROM_BOTTOM;
494 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-peek-in");
495 m_aSubType = rtl::OUString::createFromAscii("from-bottom");
496 break;
497 case 0xa:
498 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_FROM_RIGHT;
499 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-peek-in");
500 m_aSubType = rtl::OUString::createFromAscii("from-right");
501 break;
502 case 0xb:
503 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_SHORT_FROM_TOP;
504 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-peek-in");
505 m_aSubType = rtl::OUString::createFromAscii("from-top");
506 break;
507 case 0xc: // -- slow text effects --
509 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_LEFT;
510 //rSpeed = ::com::sun::star::presentation::AnimationSpeed_SLOW;
511 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in-slow");
512 m_aSubType = rtl::OUString::createFromAscii("from-left");
514 break;
515 case 0xd:
517 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_TOP;
518 //rSpeed = ::com::sun::star::presentation::AnimationSpeed_SLOW;
519 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in-slow");
520 m_aSubType = rtl::OUString::createFromAscii("from-top");
522 break;
523 case 0xe:
525 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_RIGHT;
526 //rSpeed = ::com::sun::star::presentation::AnimationSpeed_SLOW;
527 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in-slow");
528 m_aSubType = rtl::OUString::createFromAscii("from-right");
530 break;
531 case 0xf:
533 //eRetval = ::com::sun::star::presentation::AnimationEffect_MOVE_FROM_BOTTOM;
534 //rSpeed = ::com::sun::star::presentation::AnimationSpeed_SLOW;
535 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-fly-in-slow");
536 m_aSubType = rtl::OUString::createFromAscii("from-bottom");
538 break;
539 case 0x10: // --- zoom ---
540 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_CENTER;
541 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-zoom");
542 m_aSubType = rtl::OUString::createFromAscii("in");
543 break;
544 case 0x11:
545 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_CENTER;
546 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-zoom");
547 m_aSubType = rtl::OUString::createFromAscii("in-slightly");
548 break;
549 case 0x12:
550 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_TO_CENTER;
551 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-zoom");
552 m_aSubType = rtl::OUString::createFromAscii("out");
553 break;
554 case 0x13:
555 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_TO_CENTER;
556 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-zoom");
557 m_aSubType = rtl::OUString::createFromAscii("out-slightly");
558 break;
559 case 0x14:
560 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_FROM_CENTER;
561 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-zoom");
562 m_aSubType = rtl::OUString::createFromAscii("in-from-screen-center");
563 break;
564 case 0x15:
565 //eRetval = ::com::sun::star::presentation::AnimationEffect_FADE_TO_CENTER;
566 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-zoom");
567 m_aSubType = rtl::OUString::createFromAscii("out-from-screen-center");
568 break;
569 case 0x16: // --- stretch ---
570 //eRetval = ::com::sun::star::presentation::AnimationEffect_HORIZONTAL_STRETCH;
571 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-stretchy");
572 m_aSubType = rtl::OUString::createFromAscii("across");
573 break;
574 case 0x17:
575 //eRetval = ::com::sun::star::presentation::AnimationEffect_STRETCH_FROM_LEFT;
576 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-stretchy");
577 m_aSubType = rtl::OUString::createFromAscii("from-left");
578 break;
579 case 0x18:
580 //eRetval = ::com::sun::star::presentation::AnimationEffect_STRETCH_FROM_TOP;
581 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-stretchy");
582 m_aSubType = rtl::OUString::createFromAscii("from-top");
583 break;
584 case 0x19:
585 //eRetval = ::com::sun::star::presentation::AnimationEffect_STRETCH_FROM_RIGHT;
586 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-stretchy");
587 m_aSubType = rtl::OUString::createFromAscii("from-right");
588 break;
589 case 0x1a:
590 //eRetval = ::com::sun::star::presentation::AnimationEffect_STRETCH_FROM_BOTTOM;
591 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-stretchy");
592 m_aSubType = rtl::OUString::createFromAscii("from-bottom");
593 break;
594 case 0x1b: // --- rotate ---
595 //eRetval = ::com::sun::star::presentation::AnimationEffect_HORIZONTAL_ROTATE;
596 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-swivel");
597 m_aSubType = rtl::OUString::createFromAscii("vertical");
598 break;
599 case 0x1c: // --- spirale ---
600 //eRetval = ::com::sun::star::presentation::AnimationEffect_SPIRALOUT_LEFT;
601 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-spiral-in");
602 break;
605 break;
606 case 0x0d: // --- open/close ---
608 switch ( m_aAtom.nFlyDirection )
610 case 0x0:
611 //eRetval = ::com::sun::star::presentation::AnimationEffect_OPEN_VERTICAL ; // ???
612 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-split");
613 m_aSubType = rtl::OUString::createFromAscii("horizontal-out"); //horizontal open
614 break;
615 case 0x1:
616 //eRetval = ::com::sun::star::presentation::AnimationEffect_CLOSE_VERTICAL; // ???
617 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-split");
618 m_aSubType = rtl::OUString::createFromAscii("horizontal-in"); //horizontal close
619 break;
620 case 0x2:
621 //eRetval = ::com::sun::star::presentation::AnimationEffect_OPEN_HORIZONTAL; // ???
622 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-split");
623 m_aSubType = rtl::OUString::createFromAscii("vertical-out"); // vertical open
624 break;
625 case 0x3:
626 //eRetval = ::com::sun::star::presentation::AnimationEffect_CLOSE_HORIZONTAL; // ???
627 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-split");
628 m_aSubType = rtl::OUString::createFromAscii("vertical-in"); // vertical close
629 break;
632 break;
633 case 0x0e: // --- blink ---
635 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-flash-once");
636 switch ( m_aAtom.nFlyDirection )
638 case 0x0: //fast
639 m_fDurationInSeconds = 0.075;
640 m_bHasSpecialDuration = true;
641 break;
642 case 0x1: //medium
643 m_fDurationInSeconds = 0.5;
644 m_bHasSpecialDuration = true;
645 break;
646 case 0x2: //slow
647 m_fDurationInSeconds = 1.0;
648 m_bHasSpecialDuration = true;
649 break;
652 break;
653 default:
655 m_aPresetId = ::rtl::OUString::createFromAscii("ooo-entrance-appear");
656 DBG_ERROR("no effect mapped");
658 break;
660 m_bDirtyCache = false;
663 void Ppt97Animation::createAndSetCustomAnimationEffect( SdrObject* pObj )
666 if( !this->HasEffect() )
667 return;
668 if( !pObj || !pObj->GetPage() )
670 DBG_ERROR("no valid SdrObject or page found for ppt import");
671 return;
674 uno::Reference< drawing::XShape > xShape = GetXShapeForSdrObject( pObj );
675 if( !xShape.is() )
677 DBG_ERROR("no XShape interface found for ppt import");
678 return;
680 ::sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
681 if( !pMainSequence.get() )
683 DBG_ERROR("no MainSequence found for ppt import");
684 return;
687 const ::sd::CustomAnimationPresets& rPresets( ::sd::CustomAnimationPresets::getCustomAnimationPresets() );
688 ::sd::CustomAnimationPresetPtr pPreset( rPresets.getEffectDescriptor( this->GetPresetId() ) );
689 if( !pPreset.get() )
691 DBG_ERROR("no suiteable preset found for ppt import");
692 return;
695 //--------------start doing something
697 //1. ------ create an effect from the presets ------
698 ::sd::CustomAnimationEffectPtr pEffect( new ::sd::CustomAnimationEffect( pPreset->create( this->GetPresetSubType() ) ) );
699 if( !pEffect.get() )
701 DBG_ASSERT(pEffect.get(),"no suiteable effect found");
702 return;
705 //2. ------ adapt the created effect ------
707 // set the shape targeted by this effect
708 pEffect->setTarget( makeAny( xShape ) );
710 pEffect->setBegin( this->GetDelayTimeInSeconds() );
712 // some effects need a different duration than that of the mapped preset effect
713 double fDurationInSeconds = 1.0;//in secunden
714 if( this->GetSpecialDuration( fDurationInSeconds ) )
715 pEffect->setDuration( fDurationInSeconds );
717 // set after effect
718 if( this->HasAfterEffect() )
720 pEffect->setHasAfterEffect( sal_True );
721 if( this->HasAfterEffect_ChangeColor() )
722 pEffect->setDimColor( uno::makeAny( this->GetDimColor() ) );
723 else
724 pEffect->setAfterEffectOnNext( this->HasAfterEffect_DimAtNextEffect() );
727 // set sound effect
728 if( this->HasSoundEffect() )
729 pEffect->createAudio( uno::makeAny( m_aSoundFileUrl ) );
731 // text iteration
732 pEffect->setIterateType( this->GetTextAnimationType() );
734 // some effects need a different delay between text iteration than that of the mapped preset effect
735 double fTextIterationDelay = 1.0;
736 if( this->GetSpecialTextIterationDelay( fTextIterationDelay ) )
737 pEffect->setIterateInterval( fTextIterationDelay );
739 // is the effect started on click or after the last effect (Another possible value is EffectNodeType::WITH_PREVIOUS )
740 pEffect->setNodeType( this->GetEffectNodeType() );
742 //set stop sound effect
743 if( this->HasStopPreviousSound() )
744 pEffect->setStopAudio();
746 // append the effect to the main sequence
747 if( !this->HasParagraphEffect() )
749 if( this->HasAnimateAssociatedShape() )
750 pEffect->setTargetSubItem( presentation::ShapeAnimationSubType::AS_WHOLE );
751 else
752 pEffect->setTargetSubItem( presentation::ShapeAnimationSubType::AS_WHOLE ); //todo: set ONLY_TEXT again if that is fixed
753 //pEffect->setTargetSubItem( presentation::ShapeAnimationSubType::ONLY_TEXT );
756 //3. ------ put the created effect to the model and do some last changes fro paragraph effects ------
757 pMainSequence->append( pEffect );
758 if( this->HasParagraphEffect() )
760 sal_Int32 nParagraphLevel = this->GetParagraphLevel();
761 double fDelaySeconds = this->GetDelayTimeInSeconds();
762 sal_Bool bAnimateAssociatedShape = this->HasAnimateAssociatedShape();//or only text
763 sal_Bool bTextReverse = this->HasReverseOrder();
765 // now create effects for each paragraph
766 ::sd::CustomAnimationTextGroupPtr pGroup = pMainSequence->
767 createTextGroup( pEffect, nParagraphLevel, fDelaySeconds, bAnimateAssociatedShape, bTextReverse );
769 if( pGroup )
771 const ::sd::EffectSequence& rEffects = pGroup->getEffects();
772 ::sd::EffectSequence::const_iterator aIter = rEffects.begin();
774 ::sd::CustomAnimationEffectPtr pLastEffect;
775 sal_Int32 nIndex = 0;
776 for( ; aIter != rEffects.end(); aIter++ )
778 ::sd::CustomAnimationEffectPtr pGroupEffect(*aIter);
780 ////todo? if( nIndex > 1 && pLastEffect && this->HasSoundEffect() )
781 //// pLastEffect->setStopAudio();
782 if( nIndex < 2 )
784 pGroupEffect->setNodeType( this->GetEffectNodeType() );
786 else if( nIndex > 0 )
788 bool bAtParagraphBegin = false;
789 if(!bTextReverse)
790 bAtParagraphBegin = pGroupEffect->getParaDepth() < nParagraphLevel;
791 else
792 bAtParagraphBegin = !pLastEffect || pLastEffect->getParaDepth() < nParagraphLevel;
793 if( bAtParagraphBegin )
794 pGroupEffect->setNodeType( this->GetEffectNodeType() );
795 else if( this->GetTextAnimationType() == presentation::TextAnimationType::BY_PARAGRAPH )
796 pGroupEffect->setNodeType( presentation::EffectNodeType::WITH_PREVIOUS );
797 else
798 pGroupEffect->setNodeType( presentation::EffectNodeType::AFTER_PREVIOUS );
800 pLastEffect = pGroupEffect;
801 nIndex++;
805 pMainSequence->rebuild();