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