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 <osl/diagnose.h>
30 #include "oox/helper/helper.hxx"
31 #include "oox/helper/propertymap.hxx"
32 #include "oox/token/namespaces.hxx"
33 #include "oox/token/tokens.hxx"
34 #include "pptfilterhelpers.hxx"
36 using namespace ::com::sun::star::uno
;
37 using namespace ::com::sun::star::beans
;
38 using namespace ::com::sun::star::animations
;
39 using namespace ::com::sun::star::presentation
;
41 namespace oox
{ namespace ppt
{
43 SlideTransition::SlideTransition()
44 : mnTransitionType( 0 )
45 , mnTransitionSubType( 0 )
46 , mbTransitionDirectionNormal( true )
47 , 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
;
73 void SlideTransition::setSlideProperties( PropertyMap
& aProps
)
77 aProps
.setProperty( PROP_TransitionType
, mnTransitionType
);
78 aProps
.setProperty( PROP_TransitionSubtype
, mnTransitionSubType
);
79 aProps
.setProperty( PROP_TransitionDirection
, mbTransitionDirectionNormal
);
80 aProps
.setProperty( PROP_Speed
, mnAnimationSpeed
);
81 aProps
.setProperty( PROP_TransitionFadeColor
, mnFadeColor
);
82 if( mnAdvanceTime
!= -1 ) {
83 aProps
.setProperty( PROP_Duration
, mnAdvanceTime
/1000);
84 aProps
.setProperty( PROP_Change
, static_cast<sal_Int32
>(1));
90 OSL_FAIL( "exception raised" );
94 void SlideTransition::setTransitionFilterProperties( const Reference
< XTransitionFilter
> & xFilter
)
98 xFilter
->setTransition( mnTransitionType
);
99 xFilter
->setSubtype( mnTransitionSubType
);
100 xFilter
->setDirection( mbTransitionDirectionNormal
);
101 xFilter
->setFadeColor( mnFadeColor
);
102 xFilter
->setMode( mbMode
);
107 OSL_FAIL( "exception raised" );
111 void SlideTransition::setOoxTransitionSpeed( sal_Int32 nToken
)
115 /* In case you want to use time values in second,
116 * the speed values are located in the PPT97 importer
117 * sd/source/filter/ppt/ppt97animations.cxx:664
118 * (void Ppt97Animation::UpdateCacheData() const)
121 mnAnimationSpeed
= AnimationSpeed_FAST
;
124 mnAnimationSpeed
= AnimationSpeed_MEDIUM
;
127 mnAnimationSpeed
= AnimationSpeed_SLOW
;
130 // should not happen. just ignore
135 sal_Int16
SlideTransition::ooxToOdpEightDirections( ::sal_Int32 nOoxType
)
137 sal_Int16 nOdpDirection
;
138 nOdpDirection
= ooxToOdpBorderDirections( nOoxType
);
139 if( nOdpDirection
== 0 )
141 nOdpDirection
= ooxToOdpCornerDirections( nOoxType
);
143 return nOdpDirection
;
146 sal_Int16
SlideTransition::ooxToOdpBorderDirections( ::sal_Int32 nOoxType
)
148 sal_Int16 nOdpDirection
;
152 nOdpDirection
= TransitionSubType::FROMTOP
;
155 nOdpDirection
= TransitionSubType::FROMLEFT
;
158 nOdpDirection
= TransitionSubType::FROMRIGHT
;
161 nOdpDirection
= TransitionSubType::FROMBOTTOM
;
167 return nOdpDirection
;
170 sal_Int16
SlideTransition::ooxToOdpSideDirections( ::sal_Int32 nOoxType
)
172 sal_Int16 nOdpDirection
;
177 nOdpDirection
= TransitionSubType::TOPTOBOTTOM
;
181 nOdpDirection
= TransitionSubType::LEFTTORIGHT
;
187 return nOdpDirection
;
190 bool SlideTransition::ooxToOdpSideDirectionsDirectionNormal( ::sal_Int32 nOoxType
)
192 bool nOdpDirection
= true;
197 nOdpDirection
= false;
200 return nOdpDirection
;
203 sal_Int16
SlideTransition::ooxToOdpCornerDirections( ::sal_Int32 nOoxType
)
205 sal_Int16 nOdpDirection
;
209 nOdpDirection
= TransitionSubType::FROMBOTTOMRIGHT
;
212 nOdpDirection
= TransitionSubType::FROMBOTTOMLEFT
;
215 nOdpDirection
= TransitionSubType::FROMTOPRIGHT
;
218 nOdpDirection
= TransitionSubType::FROMTOPLEFT
;
224 return nOdpDirection
;
227 sal_Int16
SlideTransition::ooxToOdpDirection( ::sal_Int32 nOoxType
)
233 nOdpDir
= TransitionSubType::VERTICAL
;
236 nOdpDir
= TransitionSubType::HORIZONTAL
;
245 void SlideTransition::setOoxTransitionType( ::sal_Int32 OoxType
, ::sal_Int32 param1
, ::sal_Int32 param2
)
249 case PPT_TOKEN( blinds
):
250 mnTransitionType
= TransitionType::BLINDSWIPE
;
251 mnTransitionSubType
= ooxToOdpDirection( param1
);
253 case PPT_TOKEN( checker
):
254 mnTransitionType
= TransitionType::CHECKERBOARDWIPE
;
258 mnTransitionSubType
= TransitionSubType::DOWN
;
261 mnTransitionSubType
= TransitionSubType::ACROSS
;
267 case PPT_TOKEN( comb
):
268 mnTransitionType
= TransitionType::PUSHWIPE
;
272 mnTransitionSubType
= TransitionSubType::COMBVERTICAL
;
275 mnTransitionSubType
= TransitionSubType::COMBHORIZONTAL
;
281 case PPT_TOKEN( cover
):
282 mnTransitionType
= TransitionType::SLIDEWIPE
;
283 mnTransitionSubType
= ooxToOdpEightDirections( param1
);
285 case PPT_TOKEN( pull
): // uncover
286 mnTransitionType
= TransitionType::SLIDEWIPE
;
287 mnTransitionSubType
= ooxToOdpEightDirections( param1
);
288 mbTransitionDirectionNormal
= false;
290 case PPT_TOKEN( cut
):
291 // The binfilter seems to ignore this transition.
292 // Fade to black instead if thrBlk is true.
295 mnTransitionType
= TransitionType::FADE
;
296 mnTransitionSubType
= TransitionSubType::FADEOVERCOLOR
;
298 OSL_TRACE( "OOX: cut transition fallback." );
300 case PPT_TOKEN( fade
):
301 mnTransitionType
= TransitionType::FADE
;
304 mnTransitionSubType
= TransitionSubType::FADEOVERCOLOR
;
308 mnTransitionSubType
= TransitionSubType::CROSSFADE
;
311 case PPT_TOKEN( push
):
312 mnTransitionType
= TransitionType::PUSHWIPE
;
313 mnTransitionSubType
= ooxToOdpBorderDirections( param1
);
315 case PPT_TOKEN( wipe
):
316 mnTransitionType
= TransitionType::BARWIPE
;
317 mnTransitionSubType
= ooxToOdpSideDirections( param1
);
318 mbTransitionDirectionNormal
= ooxToOdpSideDirectionsDirectionNormal( param1
);
320 case PPT_TOKEN( split
):
321 mnTransitionType
= TransitionType::BARNDOORWIPE
;
322 mnTransitionSubType
= ooxToOdpDirection( param1
);
323 if( param2
== XML_in
)
326 mbTransitionDirectionNormal
= false;
329 case PPT_TOKEN( wheel
):
330 mnTransitionType
= TransitionType::PINWHEELWIPE
;
334 mnTransitionSubType
= TransitionSubType::ONEBLADE
;
337 mnTransitionSubType
= TransitionSubType::TWOBLADEVERTICAL
;
340 mnTransitionSubType
= TransitionSubType::THREEBLADE
;
343 mnTransitionSubType
= TransitionSubType::FOURBLADE
;
346 mnTransitionSubType
= TransitionSubType::EIGHTBLADE
;
351 "strange number of blades for thw wheel-wipe " << param1
);
354 mnTransitionSubType
= TransitionSubType::EIGHTBLADE
;
356 else if( param1
> 4 )
358 mnTransitionSubType
= TransitionSubType::FOURBLADE
;
360 else if( param1
== 0)
362 mnTransitionSubType
= TransitionSubType::ONEBLADE
;
367 case PPT_TOKEN( randomBar
):
368 mnTransitionType
= TransitionType::RANDOMBARWIPE
;
369 mnTransitionSubType
= ooxToOdpDirection( param1
);
371 case PPT_TOKEN( circle
):
372 mnTransitionType
= TransitionType::ELLIPSEWIPE
;
373 mnTransitionSubType
= TransitionSubType::CIRCLE
;
375 case PPT_TOKEN( diamond
):
376 mnTransitionType
= TransitionType::IRISWIPE
;
377 mnTransitionSubType
= TransitionSubType::DIAMOND
;
379 case PPT_TOKEN( dissolve
):
380 mnTransitionType
= TransitionType::DISSOLVE
;
381 mnTransitionSubType
= TransitionSubType::DEFAULT
;
383 case PPT_TOKEN( newsflash
):
384 // this is what the PPT binary filter does.... not sure I agree.
385 mnTransitionType
= TransitionType::FOURBOXWIPE
;
386 mnTransitionSubType
= TransitionSubType::CORNERSOUT
;
388 case PPT_TOKEN( plus
):
389 mnTransitionType
= TransitionType::FOURBOXWIPE
;
390 mnTransitionSubType
= TransitionSubType::CORNERSOUT
;
392 case PPT_TOKEN( random
):
393 mnTransitionType
= TransitionType::RANDOM
;
394 mnTransitionSubType
= TransitionSubType::DEFAULT
;
396 case PPT_TOKEN( wedge
):
397 mnTransitionType
= TransitionType::FANWIPE
;
398 mnTransitionSubType
= TransitionSubType::CENTERTOP
;
400 case PPT_TOKEN( zoom
):
401 mnTransitionType
= TransitionType::ZOOM
;
402 mnTransitionSubType
= TransitionSubType::DEFAULT
;
405 mnTransitionType
= 0;
412 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */