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/beans/XPropertySet.hpp>
23 #include <com/sun/star/animations/TransitionType.hpp>
24 #include <com/sun/star/animations/TransitionSubType.hpp>
25 #include <com/sun/star/animations/XTransitionFilter.hpp>
27 #include <osl/diagnose.h>
29 #include "oox/helper/helper.hxx"
30 #include "oox/helper/propertymap.hxx"
31 #include <oox/token/namespaces.hxx>
32 #include <oox/token/properties.hxx>
33 #include <oox/token/tokens.hxx>
34 #include <oox/ppt/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 bOdpDirection
= true;
197 bOdpDirection
= false;
200 return bOdpDirection
;
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
):
293 mnTransitionType
= TransitionType::BARWIPE
;
294 mnTransitionSubType
= TransitionSubType::FADEOVERCOLOR
;
296 SAL_WARN("oox.ppt", "OOX: cut transition fallback." );
298 case PPT_TOKEN( fade
):
299 mnTransitionType
= TransitionType::FADE
;
302 mnTransitionSubType
= TransitionSubType::FADEOVERCOLOR
;
306 mnTransitionSubType
= TransitionSubType::CROSSFADE
;
309 case PPT_TOKEN( push
):
310 mnTransitionType
= TransitionType::PUSHWIPE
;
311 mnTransitionSubType
= ooxToOdpBorderDirections( param1
);
313 case PPT_TOKEN( wipe
):
314 mnTransitionType
= TransitionType::BARWIPE
;
315 mnTransitionSubType
= ooxToOdpSideDirections( param1
);
316 mbTransitionDirectionNormal
= ooxToOdpSideDirectionsDirectionNormal( param1
);
318 case PPT_TOKEN( split
):
319 mnTransitionType
= TransitionType::BARNDOORWIPE
;
320 mnTransitionSubType
= ooxToOdpDirection( param1
);
321 if( param2
== XML_in
)
324 mbTransitionDirectionNormal
= false;
327 case PPT_TOKEN( wheel
):
328 mnTransitionType
= TransitionType::PINWHEELWIPE
;
332 mnTransitionSubType
= TransitionSubType::ONEBLADE
;
335 mnTransitionSubType
= TransitionSubType::TWOBLADEVERTICAL
;
338 mnTransitionSubType
= TransitionSubType::THREEBLADE
;
341 mnTransitionSubType
= TransitionSubType::FOURBLADE
;
344 mnTransitionSubType
= TransitionSubType::EIGHTBLADE
;
349 "strange number of blades for thw wheel-wipe " << param1
);
352 mnTransitionSubType
= TransitionSubType::EIGHTBLADE
;
354 else if( param1
> 4 )
356 mnTransitionSubType
= TransitionSubType::FOURBLADE
;
358 else if( param1
== 0)
360 mnTransitionSubType
= TransitionSubType::ONEBLADE
;
365 case PPT_TOKEN( randomBar
):
366 mnTransitionType
= TransitionType::RANDOMBARWIPE
;
367 mnTransitionSubType
= ooxToOdpDirection( param1
);
369 case PPT_TOKEN( circle
):
370 mnTransitionType
= TransitionType::ELLIPSEWIPE
;
371 mnTransitionSubType
= TransitionSubType::CIRCLE
;
373 case PPT_TOKEN( diamond
):
374 mnTransitionType
= TransitionType::IRISWIPE
;
375 mnTransitionSubType
= TransitionSubType::DIAMOND
;
377 case PPT_TOKEN( dissolve
):
378 mnTransitionType
= TransitionType::DISSOLVE
;
379 mnTransitionSubType
= TransitionSubType::DEFAULT
;
381 case PPT_TOKEN( newsflash
):
382 mnTransitionType
= TransitionType::ZOOM
;
383 mnTransitionSubType
= TransitionSubType::ROTATEIN
;
385 case PPT_TOKEN( plus
):
386 mnTransitionType
= TransitionType::FOURBOXWIPE
;
387 mnTransitionSubType
= TransitionSubType::CORNERSOUT
;
389 case PPT_TOKEN( random
):
390 mnTransitionType
= TransitionType::RANDOM
;
391 mnTransitionSubType
= TransitionSubType::DEFAULT
;
393 case PPT_TOKEN( wedge
):
394 mnTransitionType
= TransitionType::FANWIPE
;
395 mnTransitionSubType
= TransitionSubType::CENTERTOP
;
397 case PPT_TOKEN( zoom
):
398 mnTransitionType
= TransitionType::ZOOM
;
399 mnTransitionSubType
= TransitionSubType::DEFAULT
;
401 case P14_TOKEN(prism
):
402 mnTransitionType
= TransitionType::MISCSHAPEWIPE
;
404 mnTransitionSubType
= TransitionSubType::CORNERSIN
;
406 mnTransitionSubType
= TransitionSubType::CORNERSOUT
;
408 case P14_TOKEN(vortex
):
409 mnTransitionType
= TransitionType::MISCSHAPEWIPE
;
410 mnTransitionSubType
= TransitionSubType::VERTICAL
;
412 case P14_TOKEN(ripple
):
413 mnTransitionType
= TransitionType::MISCSHAPEWIPE
;
414 mnTransitionSubType
= TransitionSubType::HORIZONTAL
;
416 case P14_TOKEN(glitter
):
417 mnTransitionType
= TransitionType::MISCSHAPEWIPE
;
418 mnTransitionSubType
= TransitionSubType::DIAMOND
;
420 case P14_TOKEN(honeycomb
):
421 mnTransitionType
= TransitionType::MISCSHAPEWIPE
;
422 mnTransitionSubType
= TransitionSubType::HEART
;
425 mnTransitionType
= 0;
430 void SlideTransition::setPresetTransition(OUString
const & sPresetTransition
)
432 if (sPresetTransition
== "fallOver")
434 mnTransitionType
= TransitionType::MISCSHAPEWIPE
;
435 mnTransitionSubType
= TransitionSubType::LEFTTORIGHT
;
439 mnTransitionType
= 0;
445 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */