/src/libreoffice/oox/source/ppt/slidetransitioncontext.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <oox/ppt/slidetransitioncontext.hxx> |
21 | | |
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> |
27 | | |
28 | | using namespace ::com::sun::star; |
29 | | using namespace ::oox::core; |
30 | | |
31 | | namespace oox::ppt { |
32 | | |
33 | | SlideTransitionContext::SlideTransitionContext( FragmentHandler2 const & rParent, const AttributeList& rAttribs, PropertyMap & aProperties ) |
34 | 722 | : FragmentHandler2( rParent ) |
35 | 722 | , maSlideProperties( aProperties ) |
36 | 722 | , mbHasTransition( false ) |
37 | 722 | , mbHasTransitionDuration( false ) |
38 | 722 | { |
39 | | // ST_TransitionSpeed |
40 | 722 | maTransition.setOoxTransitionSpeed( rAttribs.getToken( XML_spd, XML_fast ) ); |
41 | | |
42 | | // p14:dur |
43 | 722 | sal_Int32 nDurationInMs = rAttribs.getInteger( P14_TOKEN( dur ), -1 ); |
44 | 722 | if( nDurationInMs > -1 ) |
45 | 32 | { |
46 | | // In MSO 0 is visible as 0.01s |
47 | 32 | if( nDurationInMs == 0.0 ) |
48 | 0 | nDurationInMs = 10; |
49 | 32 | maTransition.setOoxTransitionSpeed( nDurationInMs / 1000.0 ); |
50 | 32 | mbHasTransitionDuration = true; |
51 | 32 | } |
52 | | |
53 | | // TODO |
54 | 722 | rAttribs.getBool( XML_advClick, true ); |
55 | | |
56 | | // careful. if missing, no auto advance... 0 looks like a valid value |
57 | | // for auto advance |
58 | 722 | if(rAttribs.hasAttribute( XML_advTm )) |
59 | 0 | maTransition.setOoxAdvanceTime( rAttribs.getInteger( XML_advTm, -1 ) ); |
60 | 722 | } |
61 | | |
62 | | SlideTransitionContext::~SlideTransitionContext() noexcept |
63 | 722 | { |
64 | | |
65 | 722 | } |
66 | | |
67 | | ::oox::core::ContextHandlerRef SlideTransitionContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) |
68 | 689 | { |
69 | 689 | switch( aElementToken ) |
70 | 689 | { |
71 | 0 | case PPT_TOKEN( blinds ): |
72 | 6 | case PPT_TOKEN( checker ): |
73 | 6 | case PPT_TOKEN( comb ): |
74 | 6 | case PPT_TOKEN( randomBar ): |
75 | 6 | if (!mbHasTransition) |
76 | 6 | { |
77 | 6 | mbHasTransition = true; |
78 | 6 | maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_dir, XML_horz ), 0); |
79 | 6 | } |
80 | 6 | return this; |
81 | 0 | case PPT_TOKEN( cover ): |
82 | 0 | case PPT_TOKEN( pull ): |
83 | 0 | case PPT_TOKEN( push ): |
84 | 0 | case PPT_TOKEN( wipe ): |
85 | 0 | if (!mbHasTransition) |
86 | 0 | { |
87 | 0 | mbHasTransition = true; |
88 | 0 | maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_dir, XML_l ), 0 ); |
89 | 0 | } |
90 | 0 | return this; |
91 | 0 | case PPT_TOKEN( cut ): |
92 | 27 | case PPT_TOKEN( fade ): |
93 | 27 | if (!mbHasTransition) |
94 | 27 | { |
95 | 27 | mbHasTransition = true; |
96 | 27 | maTransition.setOoxTransitionType( aElementToken, sal_Int32(rAttribs.getBool( XML_thruBlk, false )), 0); |
97 | 27 | } |
98 | 27 | return this; |
99 | 0 | case PPT_TOKEN( split ): |
100 | 0 | if (!mbHasTransition) |
101 | 0 | { |
102 | 0 | mbHasTransition = true; |
103 | 0 | maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_orient, XML_horz ), rAttribs.getToken( XML_dir, XML_out ) ); |
104 | 0 | } |
105 | 0 | return this; |
106 | 0 | case PPT_TOKEN( zoom ): |
107 | 0 | if (!mbHasTransition) |
108 | 0 | { |
109 | 0 | mbHasTransition = true; |
110 | 0 | maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_dir, XML_out ), 0 ); |
111 | 0 | } |
112 | 0 | return this; |
113 | 0 | case PPT_TOKEN( wheel ): |
114 | 0 | if (!mbHasTransition) |
115 | 0 | { |
116 | 0 | mbHasTransition = true; |
117 | 0 | maTransition.setOoxTransitionType( aElementToken, rAttribs.getUnsigned( XML_spokes, 4 ), 0 ); |
118 | | // unsignedInt |
119 | 0 | } |
120 | 0 | return this; |
121 | 0 | case PPT_TOKEN( circle ): |
122 | 0 | case PPT_TOKEN( diamond ): |
123 | 620 | case PPT_TOKEN( dissolve ): |
124 | 620 | case PPT_TOKEN( newsflash ): |
125 | 620 | case PPT_TOKEN( plus ): |
126 | 620 | case PPT_TOKEN( random ): |
127 | 620 | case PPT_TOKEN( wedge ): |
128 | 620 | case P14_TOKEN( vortex ): |
129 | 620 | case P14_TOKEN( ripple ): |
130 | 620 | case P14_TOKEN( glitter ): |
131 | 620 | case P14_TOKEN( honeycomb ): |
132 | 620 | case P14_TOKEN( flash ): |
133 | | // CT_Empty |
134 | 620 | if (!mbHasTransition) |
135 | 620 | { |
136 | 620 | mbHasTransition = true; |
137 | 620 | maTransition.setOoxTransitionType( aElementToken, 0, 0 ); |
138 | 620 | } |
139 | 620 | return this; |
140 | | |
141 | 0 | case PPT_TOKEN( sndAc ): // CT_TransitionSoundAction |
142 | | //"Sound" |
143 | 0 | return new SoundActionContext ( *this, maSlideProperties ); |
144 | 0 | case PPT_TOKEN( extLst ): // CT_OfficeArtExtensionList |
145 | 0 | return this; |
146 | | |
147 | 0 | case P14_TOKEN(prism): |
148 | 0 | if (!mbHasTransition) |
149 | 0 | { |
150 | 0 | mbHasTransition = true; |
151 | 0 | maTransition.setOoxTransitionType(aElementToken, sal_Int32(rAttribs.getBool(XML_isInverted, false)), 0); |
152 | 0 | } |
153 | 0 | return this; |
154 | 0 | case P15_TOKEN(prstTrans): |
155 | 0 | if (!mbHasTransition) |
156 | 0 | { |
157 | 0 | mbHasTransition = true; |
158 | 0 | maTransition.setPresetTransition(rAttribs.getStringDefaulted(XML_prst)); |
159 | 0 | } |
160 | 0 | return this; |
161 | 36 | case PPT_TOKEN( strips ): |
162 | 36 | if (!mbHasTransition) |
163 | 36 | { |
164 | 36 | mbHasTransition = true; |
165 | 36 | maTransition.setOoxTransitionType( aElementToken, rAttribs.getToken( XML_dir, XML_ld ), 0 ); |
166 | 36 | } |
167 | 36 | return this; |
168 | | |
169 | | |
170 | 0 | default: |
171 | 0 | break; |
172 | 689 | } |
173 | | |
174 | 0 | return this; |
175 | 689 | } |
176 | | |
177 | | void SlideTransitionContext::onEndElement() |
178 | 1.41k | { |
179 | 1.41k | if( isCurrentElement(PPT_TOKEN( transition )) ) |
180 | 722 | { |
181 | 722 | if( mbHasTransition || mbHasTransitionDuration ) |
182 | 707 | { |
183 | 707 | maTransition.setSlideProperties( maSlideProperties ); |
184 | 707 | mbHasTransition = false; |
185 | 707 | } |
186 | 722 | } |
187 | 1.41k | } |
188 | | |
189 | | } |
190 | | |
191 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |