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 <oox/ppt/backgroundproperties.hxx>
23 #include <oox/ppt/soundactioncontext.hxx>
24 #include <oox/helper/attributelist.hxx>
25 #include <oox/token/namespaces.hxx>
26 #include <oox/token/tokens.hxx>
28 using namespace ::com::sun::star
;
29 using namespace ::oox::core
;
30 using namespace ::oox::drawingml
;
31 using namespace ::com::sun::star::uno
;
32 using namespace ::com::sun::star::xml::sax
;
36 SlideTransitionContext::SlideTransitionContext( FragmentHandler2
const & rParent
, const AttributeList
& rAttribs
, PropertyMap
& aProperties
)
37 : FragmentHandler2( rParent
)
38 , maSlideProperties( aProperties
)
39 , mbHasTransition( false )
40 , mbHasTransitionDuration( false )
43 maTransition
.setOoxTransitionSpeed( rAttribs
.getToken( XML_spd
, XML_fast
) );
46 sal_Int32 nDurationInMs
= rAttribs
.getInteger( P14_TOKEN( dur
), -1 );
47 if( nDurationInMs
> -1 )
49 // In MSO 0 is visible as 0.01s
50 if( nDurationInMs
== 0.0 )
52 maTransition
.setOoxTransitionSpeed( nDurationInMs
/ 1000.0 );
53 mbHasTransitionDuration
= true;
57 rAttribs
.getBool( XML_advClick
, true );
59 // careful. if missing, no auto advance... 0 looks like a valid value
61 if(rAttribs
.hasAttribute( XML_advTm
))
62 maTransition
.setOoxAdvanceTime( rAttribs
.getInteger( XML_advTm
, -1 ) );
65 SlideTransitionContext::~SlideTransitionContext() noexcept
70 ::oox::core::ContextHandlerRef
SlideTransitionContext::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
72 switch( aElementToken
)
74 case PPT_TOKEN( blinds
):
75 case PPT_TOKEN( checker
):
76 case PPT_TOKEN( comb
):
77 case PPT_TOKEN( randomBar
):
80 mbHasTransition
= true;
81 maTransition
.setOoxTransitionType( aElementToken
, rAttribs
.getToken( XML_dir
, XML_horz
), 0);
84 case PPT_TOKEN( cover
):
85 case PPT_TOKEN( pull
):
88 mbHasTransition
= true;
89 maTransition
.setOoxTransitionType( aElementToken
, rAttribs
.getToken( XML_dir
, XML_l
), 0 );
92 case PPT_TOKEN( cut
):
93 case PPT_TOKEN( fade
):
96 mbHasTransition
= true;
97 maTransition
.setOoxTransitionType( aElementToken
, sal_Int32(rAttribs
.getBool( XML_thruBlk
, false )), 0);
100 case PPT_TOKEN( push
):
101 case PPT_TOKEN( wipe
):
102 if (!mbHasTransition
)
104 mbHasTransition
= true;
105 maTransition
.setOoxTransitionType( aElementToken
, rAttribs
.getToken( XML_dir
, XML_l
), 0 );
108 case PPT_TOKEN( split
):
109 if (!mbHasTransition
)
111 mbHasTransition
= true;
112 maTransition
.setOoxTransitionType( aElementToken
, rAttribs
.getToken( XML_orient
, XML_horz
), rAttribs
.getToken( XML_dir
, XML_out
) );
115 case PPT_TOKEN( zoom
):
116 if (!mbHasTransition
)
118 mbHasTransition
= true;
119 maTransition
.setOoxTransitionType( aElementToken
, rAttribs
.getToken( XML_dir
, XML_out
), 0 );
122 case PPT_TOKEN( wheel
):
123 if (!mbHasTransition
)
125 mbHasTransition
= true;
126 maTransition
.setOoxTransitionType( aElementToken
, rAttribs
.getUnsigned( XML_spokes
, 4 ), 0 );
130 case PPT_TOKEN( circle
):
131 case PPT_TOKEN( diamond
):
132 case PPT_TOKEN( dissolve
):
133 case PPT_TOKEN( newsflash
):
134 case PPT_TOKEN( plus
):
135 case PPT_TOKEN( random
):
136 case PPT_TOKEN( wedge
):
137 case P14_TOKEN( vortex
):
138 case P14_TOKEN( ripple
):
139 case P14_TOKEN( glitter
):
140 case P14_TOKEN( honeycomb
):
141 case P14_TOKEN( flash
):
143 if (!mbHasTransition
)
145 mbHasTransition
= true;
146 maTransition
.setOoxTransitionType( aElementToken
, 0, 0 );
150 case PPT_TOKEN( sndAc
): // CT_TransitionSoundAction
152 return new SoundActionContext ( *this, maSlideProperties
);
153 case PPT_TOKEN( extLst
): // CT_OfficeArtExtensionList
156 case P14_TOKEN(prism
):
157 if (!mbHasTransition
)
159 mbHasTransition
= true;
160 maTransition
.setOoxTransitionType(aElementToken
, sal_Int32(rAttribs
.getBool(XML_isInverted
, false)), 0);
163 case P15_TOKEN(prstTrans
):
164 if (!mbHasTransition
)
166 mbHasTransition
= true;
167 maTransition
.setPresetTransition(rAttribs
.getStringDefaulted(XML_prst
));
170 case PPT_TOKEN( strips
):
171 if (!mbHasTransition
)
173 mbHasTransition
= true;
174 maTransition
.setOoxTransitionType( aElementToken
, rAttribs
.getToken( XML_dir
, XML_ld
), 0 );
186 void SlideTransitionContext::onEndElement()
188 if( isCurrentElement(PPT_TOKEN( transition
)) )
190 if( mbHasTransition
|| mbHasTransitionDuration
)
192 maTransition
.setSlideProperties( maSlideProperties
);
193 mbHasTransition
= false;
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */