1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "oox/ppt/slidetransition.hxx"
22 #include <com/sun/star/uno/Any.hxx>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/presentation/AnimationSpeed.hpp>
25 #include <com/sun/star/animations/TransitionType.hpp>
26 #include <com/sun/star/animations/TransitionSubType.hpp>
28 #include "oox/helper/helper.hxx"
29 #include "oox/helper/propertymap.hxx"
30 #include "oox/token/namespaces.hxx"
31 #include "oox/token/tokens.hxx"
32 #include "pptfilterhelpers.hxx"
34 using namespace ::com::sun::star::uno
;
35 using namespace ::com::sun::star::beans
;
36 using namespace ::com::sun::star::animations
;
37 using namespace ::com::sun::star::presentation
;
39 namespace oox
{ namespace ppt
{
42 SlideTransition::SlideTransition()
43 : mnTransitionType( 0 )
44 , mnTransitionSubType( 0 )
45 , mbTransitionDirectionNormal( true )
46 , mnAnimationSpeed( AnimationSpeed_FAST
)
55 SlideTransition::SlideTransition(const OUString
& sFilterName
)
56 : mnTransitionType( 0 )
57 , mnTransitionSubType( 0 )
58 , mbTransitionDirectionNormal( true )
59 , mnAnimationSpeed( AnimationSpeed_FAST
)
64 const transition
*p
= transition::find( sFilterName
);
67 mnTransitionType
= p
->mnType
;
68 mnTransitionSubType
= p
->mnSubType
;
69 mbTransitionDirectionNormal
= p
->mbDirection
;
74 void SlideTransition::setSlideProperties( PropertyMap
& aProps
)
78 aProps
[ PROP_TransitionType
] <<= mnTransitionType
;
79 aProps
[ PROP_TransitionSubtype
] <<= mnTransitionSubType
;
80 aProps
[ PROP_TransitionDirection
] <<= mbTransitionDirectionNormal
;
81 aProps
[ PROP_Speed
] <<= mnAnimationSpeed
;
82 aProps
[ PROP_TransitionFadeColor
] <<= mnFadeColor
;
83 if( mnAdvanceTime
!= -1 ) {
84 aProps
[ PROP_Duration
] <<= mnAdvanceTime
/1000;
85 aProps
[ PROP_Change
] <<= static_cast<sal_Int32
>(1);
91 OSL_FAIL( "exception raised" );
95 void SlideTransition::setTransitionFilterProperties( const Reference
< XTransitionFilter
> & xFilter
)
99 xFilter
->setTransition( mnTransitionType
);
100 xFilter
->setSubtype( mnTransitionSubType
);
101 xFilter
->setDirection( mbTransitionDirectionNormal
);
102 xFilter
->setFadeColor( mnFadeColor
);
103 xFilter
->setMode( mbMode
);
108 OSL_FAIL( "exception raised" );
113 void SlideTransition::setOoxTransitionSpeed( sal_Int32 nToken
)
117 /* In case you want to use time values in second,
118 * the speed values are located in the PPT97 importer
119 * sd/source/filter/ppt/ppt97animations.cxx:664
120 * (void Ppt97Animation::UpdateCacheData() const)
123 mnAnimationSpeed
= AnimationSpeed_FAST
;
126 mnAnimationSpeed
= AnimationSpeed_MEDIUM
;
129 mnAnimationSpeed
= AnimationSpeed_SLOW
;
132 // should not happen. just ignore
137 sal_Int16
SlideTransition::ooxToOdpEightDirections( ::sal_Int32 nOoxType
)
139 sal_Int16 nOdpDirection
;
140 nOdpDirection
= ooxToOdpBorderDirections( nOoxType
);
141 if( nOdpDirection
== 0 )
143 nOdpDirection
= ooxToOdpCornerDirections( nOoxType
);
145 return nOdpDirection
;
149 sal_Int16
SlideTransition::ooxToOdpBorderDirections( ::sal_Int32 nOoxType
)
151 sal_Int16 nOdpDirection
;
155 nOdpDirection
= TransitionSubType::FROMTOP
;
158 nOdpDirection
= TransitionSubType::FROMLEFT
;
161 nOdpDirection
= TransitionSubType::FROMRIGHT
;
164 nOdpDirection
= TransitionSubType::FROMBOTTOM
;
170 return nOdpDirection
;
173 sal_Int16
SlideTransition::ooxToOdpSideDirections( ::sal_Int32 nOoxType
)
175 sal_Int16 nOdpDirection
;
180 nOdpDirection
= TransitionSubType::TOPTOBOTTOM
;
184 nOdpDirection
= TransitionSubType::LEFTTORIGHT
;
190 return nOdpDirection
;
193 sal_Bool
SlideTransition::ooxToOdpSideDirectionsDirectionNormal( ::sal_Int32 nOoxType
)
195 sal_Bool nOdpDirection
= true;
200 nOdpDirection
= false;
203 return nOdpDirection
;
206 sal_Int16
SlideTransition::ooxToOdpCornerDirections( ::sal_Int32 nOoxType
)
208 sal_Int16 nOdpDirection
;
212 nOdpDirection
= TransitionSubType::FROMBOTTOMRIGHT
;
215 nOdpDirection
= TransitionSubType::FROMBOTTOMLEFT
;
218 nOdpDirection
= TransitionSubType::FROMTOPRIGHT
;
221 nOdpDirection
= TransitionSubType::FROMTOPLEFT
;
227 return nOdpDirection
;
231 sal_Int16
SlideTransition::ooxToOdpDirection( ::sal_Int32 nOoxType
)
237 nOdpDir
= TransitionSubType::VERTICAL
;
240 nOdpDir
= TransitionSubType::HORIZONTAL
;
249 void SlideTransition::setOoxTransitionType( ::sal_Int32 OoxType
, ::sal_Int32 param1
, ::sal_Int32 param2
)
253 case PPT_TOKEN( blinds
):
254 mnTransitionType
= TransitionType::BLINDSWIPE
;
255 mnTransitionSubType
= ooxToOdpDirection( param1
);
257 case PPT_TOKEN( checker
):
258 mnTransitionType
= TransitionType::CHECKERBOARDWIPE
;
262 mnTransitionSubType
= TransitionSubType::DOWN
;
265 mnTransitionSubType
= TransitionSubType::ACROSS
;
271 case PPT_TOKEN( comb
):
272 mnTransitionType
= TransitionType::PUSHWIPE
;
276 mnTransitionSubType
= TransitionSubType::COMBVERTICAL
;
279 mnTransitionSubType
= TransitionSubType::COMBHORIZONTAL
;
285 case PPT_TOKEN( cover
):
286 mnTransitionType
= TransitionType::SLIDEWIPE
;
287 mnTransitionSubType
= ooxToOdpEightDirections( param1
);
289 case PPT_TOKEN( pull
): // uncover
290 mnTransitionType
= TransitionType::SLIDEWIPE
;
291 mnTransitionSubType
= ooxToOdpEightDirections( param1
);
292 mbTransitionDirectionNormal
= false;
294 case PPT_TOKEN( cut
):
295 // The binfilter seems to ignore this transition.
296 // Fade to black instead if thrBlk is true.
299 mnTransitionType
= TransitionType::FADE
;
300 mnTransitionSubType
= TransitionSubType::FADEOVERCOLOR
;
302 OSL_TRACE( "OOX: cut transition fallback." );
304 case PPT_TOKEN( fade
):
305 mnTransitionType
= TransitionType::FADE
;
308 mnTransitionSubType
= TransitionSubType::FADEOVERCOLOR
;
312 mnTransitionSubType
= TransitionSubType::CROSSFADE
;
315 case PPT_TOKEN( push
):
316 mnTransitionType
= TransitionType::PUSHWIPE
;
317 mnTransitionSubType
= ooxToOdpBorderDirections( param1
);
319 case PPT_TOKEN( wipe
):
320 mnTransitionType
= TransitionType::BARWIPE
;
321 mnTransitionSubType
= ooxToOdpSideDirections( param1
);
322 mbTransitionDirectionNormal
= ooxToOdpSideDirectionsDirectionNormal( param1
);
324 case PPT_TOKEN( split
):
325 mnTransitionType
= TransitionType::BARNDOORWIPE
;
326 mnTransitionSubType
= ooxToOdpDirection( param1
);
327 if( param2
== XML_in
)
330 mbTransitionDirectionNormal
= false;
333 case PPT_TOKEN( wheel
):
334 mnTransitionType
= TransitionType::PINWHEELWIPE
;
338 mnTransitionSubType
= TransitionSubType::ONEBLADE
;
341 mnTransitionSubType
= TransitionSubType::TWOBLADEVERTICAL
;
344 mnTransitionSubType
= TransitionSubType::THREEBLADE
;
347 mnTransitionSubType
= TransitionSubType::FOURBLADE
;
350 mnTransitionSubType
= TransitionSubType::EIGHTBLADE
;
353 OSL_TRACE( "OOX: strange number of blades for thw wheel-wipe %d", param1
);
356 mnTransitionSubType
= TransitionSubType::EIGHTBLADE
;
358 else if( param1
> 4 )
360 mnTransitionSubType
= TransitionSubType::FOURBLADE
;
362 else if( param1
== 0)
364 mnTransitionSubType
= TransitionSubType::ONEBLADE
;
369 case PPT_TOKEN( randomBar
):
370 mnTransitionType
= TransitionType::RANDOMBARWIPE
;
371 mnTransitionSubType
= ooxToOdpDirection( param1
);
373 case PPT_TOKEN( circle
):
374 mnTransitionType
= TransitionType::ELLIPSEWIPE
;
375 mnTransitionSubType
= TransitionSubType::CIRCLE
;
377 case PPT_TOKEN( diamond
):
378 mnTransitionType
= TransitionType::IRISWIPE
;
379 mnTransitionSubType
= TransitionSubType::DIAMOND
;
381 case PPT_TOKEN( dissolve
):
382 mnTransitionType
= TransitionType::DISSOLVE
;
383 mnTransitionSubType
= TransitionSubType::DEFAULT
;
385 case PPT_TOKEN( newsflash
):
386 // this is what the PPT binary filter does.... not sure I agree.
387 mnTransitionType
= TransitionType::FOURBOXWIPE
;
388 mnTransitionSubType
= TransitionSubType::CORNERSOUT
;
390 case PPT_TOKEN( plus
):
391 mnTransitionType
= TransitionType::FOURBOXWIPE
;
392 mnTransitionSubType
= TransitionSubType::CORNERSOUT
;
394 case PPT_TOKEN( random
):
395 mnTransitionType
= TransitionType::RANDOM
;
396 mnTransitionSubType
= TransitionSubType::DEFAULT
;
398 case PPT_TOKEN( wedge
):
399 mnTransitionType
= TransitionType::FANWIPE
;
400 mnTransitionSubType
= TransitionSubType::CENTERTOP
;
402 case PPT_TOKEN( zoom
):
403 mnTransitionType
= TransitionType::ZOOM
;
404 mnTransitionSubType
= TransitionSubType::DEFAULT
;
407 mnTransitionType
= 0;
415 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */