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/slidetransitioncontext.hxx>
22 #include <cppuhelper/exc_hlp.hxx>
24 #include <com/sun/star/beans/XMultiPropertySet.hpp>
25 #include <com/sun/star/container/XNamed.hpp>
27 #include <oox/ppt/backgroundproperties.hxx>
28 #include <oox/ppt/slidefragmenthandler.hxx>
29 #include <oox/ppt/soundactioncontext.hxx>
30 #include <oox/drawingml/shapegroupcontext.hxx>
31 #include <oox/helper/attributelist.hxx>
32 #include <oox/token/namespaces.hxx>
33 #include <oox/token/tokens.hxx>
34 #include <oox/token/properties.hxx>
36 using namespace ::com::sun::star
;
37 using namespace ::oox::core
;
38 using namespace ::oox::drawingml
;
39 using namespace ::com::sun::star::uno
;
40 using namespace ::com::sun::star::xml::sax
;
41 using namespace ::com::sun::star::container
;
43 namespace oox
{ namespace ppt
{
45 SlideTransitionContext::SlideTransitionContext( FragmentHandler2
const & rParent
, const AttributeList
& rAttribs
, PropertyMap
& aProperties
) throw()
46 : FragmentHandler2( rParent
)
47 , maSlideProperties( aProperties
)
48 , mbHasTransition( false )
49 , mbHasTransitionDuration( false )
52 maTransition
.setOoxTransitionSpeed( rAttribs
.getToken( XML_spd
, XML_fast
) );
55 sal_Int32 nDurationInMs
= rAttribs
.getInteger( P14_TOKEN( dur
), -1 );
56 if( nDurationInMs
> -1 )
58 // In MSO 0 is visible as 0.01s
59 if( nDurationInMs
== 0.0 )
61 maTransition
.setOoxTransitionSpeed( nDurationInMs
/ 1000.0 );
62 mbHasTransitionDuration
= true;
66 rAttribs
.getBool( XML_advClick
, true );
68 // careful. if missing, no auto advance... 0 looks like a valid value
70 if(rAttribs
.hasAttribute( XML_advTm
))
71 maTransition
.setOoxAdvanceTime( rAttribs
.getInteger( XML_advTm
, -1 ) );
74 SlideTransitionContext::~SlideTransitionContext() throw()
79 ::oox::core::ContextHandlerRef
SlideTransitionContext::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
81 switch( aElementToken
)
83 case PPT_TOKEN( blinds
):
84 case PPT_TOKEN( checker
):
85 case PPT_TOKEN( comb
):
86 case PPT_TOKEN( randomBar
):
89 mbHasTransition
= true;
90 maTransition
.setOoxTransitionType( aElementToken
, rAttribs
.getToken( XML_dir
, XML_horz
), 0);
93 case PPT_TOKEN( cover
):
94 case PPT_TOKEN( pull
):
97 mbHasTransition
= true;
98 maTransition
.setOoxTransitionType( aElementToken
, rAttribs
.getToken( XML_dir
, XML_l
), 0 );
101 case PPT_TOKEN( cut
):
102 case PPT_TOKEN( fade
):
103 if (!mbHasTransition
)
105 mbHasTransition
= true;
106 maTransition
.setOoxTransitionType( aElementToken
, sal_Int32(rAttribs
.getBool( XML_thruBlk
, false )), 0);
109 case PPT_TOKEN( push
):
110 case PPT_TOKEN( wipe
):
111 if (!mbHasTransition
)
113 mbHasTransition
= true;
114 maTransition
.setOoxTransitionType( aElementToken
, rAttribs
.getToken( XML_dir
, XML_l
), 0 );
117 case PPT_TOKEN( split
):
118 if (!mbHasTransition
)
120 mbHasTransition
= true;
121 maTransition
.setOoxTransitionType( aElementToken
, rAttribs
.getToken( XML_orient
, XML_horz
), rAttribs
.getToken( XML_dir
, XML_out
) );
124 case PPT_TOKEN( zoom
):
125 if (!mbHasTransition
)
127 mbHasTransition
= true;
128 maTransition
.setOoxTransitionType( aElementToken
, rAttribs
.getToken( XML_dir
, XML_out
), 0 );
131 case PPT_TOKEN( wheel
):
132 if (!mbHasTransition
)
134 mbHasTransition
= true;
135 maTransition
.setOoxTransitionType( aElementToken
, rAttribs
.getUnsigned( XML_spokes
, 4 ), 0 );
139 case PPT_TOKEN( circle
):
140 case PPT_TOKEN( diamond
):
141 case PPT_TOKEN( dissolve
):
142 case PPT_TOKEN( newsflash
):
143 case PPT_TOKEN( plus
):
144 case PPT_TOKEN( random
):
145 case PPT_TOKEN( wedge
):
146 case P14_TOKEN( vortex
):
147 case P14_TOKEN( ripple
):
148 case P14_TOKEN( glitter
):
149 case P14_TOKEN( honeycomb
):
151 if (!mbHasTransition
)
153 mbHasTransition
= true;
154 maTransition
.setOoxTransitionType( aElementToken
, 0, 0 );
158 case PPT_TOKEN( sndAc
): // CT_TransitionSoundAction
160 return new SoundActionContext ( *this, maSlideProperties
);
161 case PPT_TOKEN( extLst
): // CT_OfficeArtExtensionList
164 case P14_TOKEN(prism
):
165 if (!mbHasTransition
)
167 mbHasTransition
= true;
168 maTransition
.setOoxTransitionType(aElementToken
, sal_Int32(rAttribs
.getBool(XML_isInverted
, false)), 0);
171 case P15_TOKEN(prstTrans
):
172 if (!mbHasTransition
)
174 mbHasTransition
= true;
175 maTransition
.setPresetTransition(rAttribs
.getString(XML_prst
, ""));
187 void SlideTransitionContext::onEndElement()
189 if( isCurrentElement(PPT_TOKEN( transition
)) )
191 if( mbHasTransition
|| mbHasTransitionDuration
)
193 maTransition
.setSlideProperties( maSlideProperties
);
194 mbHasTransition
= false;
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */