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