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