1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: slidetransition.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/ppt/slidetransition.hxx"
33 #include <com/sun/star/uno/Any.hxx>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/presentation/AnimationSpeed.hpp>
36 #include <com/sun/star/animations/TransitionType.hpp>
37 #include <com/sun/star/animations/TransitionSubType.hpp>
39 #include "oox/helper/helper.hxx"
40 #include "oox/helper/propertymap.hxx"
41 #include "oox/core/namespaces.hxx"
42 #include "pptfilterhelpers.hxx"
43 #include "properties.hxx"
47 using namespace ::com::sun::star::uno
;
48 using namespace ::com::sun::star::beans
;
49 using namespace ::com::sun::star::animations
;
50 using namespace ::com::sun::star::presentation
;
52 namespace oox
{ namespace ppt
{
55 SlideTransition::SlideTransition()
56 : mnTransitionType( 0 )
57 , mnTransitionSubType( 0 )
58 , mbTransitionDirectionNormal( true )
59 , mnAnimationSpeed( AnimationSpeed_FAST
)
68 SlideTransition::SlideTransition(const OUString
& sFilterName
)
69 : mnTransitionType( 0 )
70 , mnTransitionSubType( 0 )
71 , mbTransitionDirectionNormal( true )
72 , mnAnimationSpeed( AnimationSpeed_FAST
)
77 const transition
*p
= transition::find( sFilterName
);
80 mnTransitionType
= p
->mnType
;
81 mnTransitionSubType
= p
->mnSubType
;
82 mbTransitionDirectionNormal
= p
->mbDirection
;
87 void SlideTransition::setSlideProperties( PropertyMap
& aProps
)
91 aProps
[ PROP_TransitionType
] <<= mnTransitionType
;
92 aProps
[ PROP_TransitionSubtype
] <<= mnTransitionSubType
;
93 aProps
[ PROP_TransitionDirection
] <<= mbTransitionDirectionNormal
;
94 aProps
[ PROP_Speed
] <<= mnAnimationSpeed
;
95 aProps
[ PROP_TransitionFadeColor
] <<= mnFadeColor
;
96 if( mnAdvanceTime
!= -1 ) {
97 aProps
[ PROP_Duration
] <<= mnAdvanceTime
/1000;
98 aProps
[ PROP_Change
] <<= static_cast<sal_Int32
>(1);
104 OSL_ENSURE( false, "exception raised" );
108 void SlideTransition::setTransitionFilterProperties( const Reference
< XTransitionFilter
> & xFilter
)
112 xFilter
->setTransition( mnTransitionType
);
113 xFilter
->setSubtype( mnTransitionSubType
);
114 xFilter
->setDirection( mbTransitionDirectionNormal
);
115 xFilter
->setFadeColor( mnFadeColor
);
116 xFilter
->setMode( mbMode
);
121 OSL_ENSURE( false, "exception raised" );
126 void SlideTransition::setOoxTransitionSpeed( sal_Int32 nToken
)
130 /* In case you want to use time values in second,
131 * the speed values are located in the PPT97 importer
132 * sd/source/filter/ppt/ppt97animations.cxx:664
133 * (void Ppt97Animation::UpdateCacheData() const)
136 mnAnimationSpeed
= AnimationSpeed_FAST
;
139 mnAnimationSpeed
= AnimationSpeed_MEDIUM
;
142 mnAnimationSpeed
= AnimationSpeed_SLOW
;
145 // should not happen. just ignore
150 sal_Int16
SlideTransition::ooxToOdpEightDirections( ::sal_Int32 nOoxType
)
152 sal_Int16 nOdpDirection
;
153 nOdpDirection
= ooxToOdpBorderDirections( nOoxType
);
154 if( nOdpDirection
== 0 )
156 nOdpDirection
= ooxToOdpCornerDirections( nOoxType
);
158 return nOdpDirection
;
162 sal_Int16
SlideTransition::ooxToOdpBorderDirections( ::sal_Int32 nOoxType
)
164 sal_Int16 nOdpDirection
;
168 nOdpDirection
= TransitionSubType::FROMTOP
;
171 nOdpDirection
= TransitionSubType::FROMLEFT
;
174 nOdpDirection
= TransitionSubType::FROMRIGHT
;
177 nOdpDirection
= TransitionSubType::FROMBOTTOM
;
183 return nOdpDirection
;
186 sal_Int16
SlideTransition::ooxToOdpSideDirections( ::sal_Int32 nOoxType
)
188 sal_Int16 nOdpDirection
;
193 nOdpDirection
= TransitionSubType::TOPTOBOTTOM
;
197 nOdpDirection
= TransitionSubType::LEFTTORIGHT
;
203 return nOdpDirection
;
206 sal_Bool
SlideTransition::ooxToOdpSideDirectionsDirectionNormal( ::sal_Int32 nOoxType
)
208 sal_Bool nOdpDirection
= true;
213 nOdpDirection
= false;
216 return nOdpDirection
;
219 sal_Int16
SlideTransition::ooxToOdpCornerDirections( ::sal_Int32 nOoxType
)
221 sal_Int16 nOdpDirection
;
225 nOdpDirection
= TransitionSubType::FROMBOTTOMRIGHT
;
228 nOdpDirection
= TransitionSubType::FROMBOTTOMLEFT
;
231 nOdpDirection
= TransitionSubType::FROMTOPRIGHT
;
234 nOdpDirection
= TransitionSubType::FROMTOPLEFT
;
240 return nOdpDirection
;
244 sal_Int16
SlideTransition::ooxToOdpDirection( ::sal_Int32 nOoxType
)
250 nOdpDir
= TransitionSubType::VERTICAL
;
253 nOdpDir
= TransitionSubType::HORIZONTAL
;
262 void SlideTransition::setOoxTransitionType( ::sal_Int32 OoxType
, ::sal_Int32 param1
, ::sal_Int32 param2
)
266 case NMSP_PPT
|XML_blinds
:
267 mnTransitionType
= TransitionType::BLINDSWIPE
;
268 mnTransitionSubType
= ooxToOdpDirection( param1
);
270 case NMSP_PPT
|XML_checker
:
271 mnTransitionType
= TransitionType::CHECKERBOARDWIPE
;
275 mnTransitionSubType
= TransitionSubType::DOWN
;
278 mnTransitionSubType
= TransitionSubType::ACROSS
;
284 case NMSP_PPT
|XML_comb
:
285 mnTransitionType
= TransitionType::PUSHWIPE
;
289 mnTransitionSubType
= TransitionSubType::COMBVERTICAL
;
292 mnTransitionSubType
= TransitionSubType::COMBHORIZONTAL
;
298 case NMSP_PPT
|XML_cover
:
299 mnTransitionType
= TransitionType::SLIDEWIPE
;
300 mnTransitionSubType
= ooxToOdpEightDirections( param1
);
302 case NMSP_PPT
|XML_pull
: // uncover
303 mnTransitionType
= TransitionType::SLIDEWIPE
;
304 mnTransitionSubType
= ooxToOdpEightDirections( param1
);
305 mbTransitionDirectionNormal
= false;
307 case NMSP_PPT
|XML_cut
:
308 // The binfilter seems to ignore this transition.
309 // Fade to black instead if thrBlk is true.
312 mnTransitionType
= TransitionType::FADE
;
313 mnTransitionSubType
= TransitionSubType::FADEOVERCOLOR
;
315 OSL_TRACE( "OOX: cut transition fallback." );
317 case NMSP_PPT
|XML_fade
:
318 mnTransitionType
= TransitionType::FADE
;
321 mnTransitionSubType
= TransitionSubType::FADEOVERCOLOR
;
325 mnTransitionSubType
= TransitionSubType::CROSSFADE
;
328 case NMSP_PPT
|XML_push
:
329 mnTransitionType
= TransitionType::PUSHWIPE
;
330 mnTransitionSubType
= ooxToOdpBorderDirections( param1
);
332 case NMSP_PPT
|XML_wipe
:
333 mnTransitionType
= TransitionType::BARWIPE
;
334 mnTransitionSubType
= ooxToOdpSideDirections( param1
);
335 mbTransitionDirectionNormal
= ooxToOdpSideDirectionsDirectionNormal( param1
);
337 case NMSP_PPT
|XML_split
:
338 mnTransitionType
= TransitionType::BARNDOORWIPE
;
339 mnTransitionSubType
= ooxToOdpDirection( param1
);
340 if( param2
== XML_in
)
343 mbTransitionDirectionNormal
= false;
346 case NMSP_PPT
|XML_wheel
:
347 mnTransitionType
= TransitionType::PINWHEELWIPE
;
351 mnTransitionSubType
= TransitionSubType::ONEBLADE
;
354 mnTransitionSubType
= TransitionSubType::TWOBLADEVERTICAL
;
357 mnTransitionSubType
= TransitionSubType::THREEBLADE
;
360 mnTransitionSubType
= TransitionSubType::FOURBLADE
;
363 mnTransitionSubType
= TransitionSubType::EIGHTBLADE
;
366 OSL_TRACE( "OOX: strange number of blades for thw wheel-wipe %d", param1
);
369 mnTransitionSubType
= TransitionSubType::EIGHTBLADE
;
371 else if( param1
> 4 )
373 mnTransitionSubType
= TransitionSubType::FOURBLADE
;
375 else if( param1
== 0)
377 mnTransitionSubType
= TransitionSubType::ONEBLADE
;
382 case NMSP_PPT
|XML_randomBar
:
383 mnTransitionType
= TransitionType::RANDOMBARWIPE
;
384 mnTransitionSubType
= ooxToOdpDirection( param1
);
386 case NMSP_PPT
|XML_circle
:
387 mnTransitionType
= TransitionType::ELLIPSEWIPE
;
388 mnTransitionSubType
= TransitionSubType::CIRCLE
;
390 case NMSP_PPT
|XML_diamond
:
391 mnTransitionType
= TransitionType::IRISWIPE
;
392 mnTransitionSubType
= TransitionSubType::DIAMOND
;
394 case NMSP_PPT
|XML_dissolve
:
395 mnTransitionType
= TransitionType::DISSOLVE
;
396 mnTransitionSubType
= TransitionSubType::DEFAULT
;
398 case NMSP_PPT
|XML_newsflash
:
399 // this is what the PPT binary filter does.... not sure I agree.
400 mnTransitionType
= TransitionType::FOURBOXWIPE
;
401 mnTransitionSubType
= TransitionSubType::CORNERSOUT
;
403 case NMSP_PPT
|XML_plus
:
404 mnTransitionType
= TransitionType::FOURBOXWIPE
;
405 mnTransitionSubType
= TransitionSubType::CORNERSOUT
;
407 case NMSP_PPT
|XML_random
:
408 mnTransitionType
= TransitionType::RANDOM
;
409 mnTransitionSubType
= TransitionSubType::DEFAULT
;
411 case NMSP_PPT
|XML_wedge
:
412 mnTransitionType
= TransitionType::FANWIPE
;
413 mnTransitionSubType
= TransitionSubType::CENTERTOP
;
415 case NMSP_PPT
|XML_zoom
:
416 mnTransitionType
= TransitionType::ZOOM
;
417 mnTransitionSubType
= TransitionSubType::DEFAULT
;
420 mnTransitionType
= 0;