/src/libreoffice/xmloff/source/draw/animimp.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 <sal/config.h> |
21 | | |
22 | | #include <xmloff/unointerfacetouniqueidentifiermapper.hxx> |
23 | | #include <com/sun/star/lang/XServiceInfo.hpp> |
24 | | #include <com/sun/star/presentation/AnimationEffect.hpp> |
25 | | #include <com/sun/star/presentation/AnimationSpeed.hpp> |
26 | | #include <com/sun/star/beans/XPropertySet.hpp> |
27 | | #include <com/sun/star/drawing/XShape.hpp> |
28 | | |
29 | | #include <sax/tools/converter.hxx> |
30 | | #include <sal/log.hxx> |
31 | | #include <comphelper/diagnose_ex.hxx> |
32 | | |
33 | | #include <xmloff/xmltoken.hxx> |
34 | | #include <xmloff/xmlimp.hxx> |
35 | | #include <xmloff/xmlnamespace.hxx> |
36 | | #include <xmloff/xmluconv.hxx> |
37 | | #include <anim.hxx> |
38 | | #include <animimp.hxx> |
39 | | |
40 | | using namespace ::com::sun::star; |
41 | | using namespace ::com::sun::star::xml; |
42 | | using namespace ::com::sun::star::xml::sax; |
43 | | using namespace ::com::sun::star::uno; |
44 | | using namespace ::com::sun::star::drawing; |
45 | | using namespace ::com::sun::star::beans; |
46 | | using namespace ::com::sun::star::lang; |
47 | | using namespace ::com::sun::star::presentation; |
48 | | using namespace ::xmloff::token; |
49 | | |
50 | | const SvXMLEnumMapEntry<XMLEffect> aXML_AnimationEffect_EnumMap[] = |
51 | | { |
52 | | { XML_NONE, EK_none }, |
53 | | { XML_FADE, EK_fade }, |
54 | | { XML_MOVE, EK_move }, |
55 | | { XML_STRIPES, EK_stripes }, |
56 | | { XML_OPEN, EK_open }, |
57 | | { XML_CLOSE, EK_close }, |
58 | | { XML_DISSOLVE, EK_dissolve }, |
59 | | { XML_WAVYLINE, EK_wavyline }, |
60 | | { XML_RANDOM, EK_random }, |
61 | | { XML_LINES, EK_lines }, |
62 | | { XML_LASER, EK_laser }, |
63 | | { XML_APPEAR, EK_appear }, |
64 | | { XML_HIDE, EK_hide }, |
65 | | { XML_MOVE_SHORT, EK_move_short }, |
66 | | { XML_CHECKERBOARD, EK_checkerboard }, |
67 | | { XML_ROTATE, EK_rotate }, |
68 | | { XML_STRETCH, EK_stretch }, |
69 | | { XML_TOKEN_INVALID, XMLEffect(0) } |
70 | | }; |
71 | | |
72 | | const SvXMLEnumMapEntry<XMLEffectDirection> aXML_AnimationDirection_EnumMap[] = |
73 | | { |
74 | | { XML_NONE, ED_none }, |
75 | | { XML_FROM_LEFT, ED_from_left }, |
76 | | { XML_FROM_TOP, ED_from_top }, |
77 | | { XML_FROM_RIGHT, ED_from_right }, |
78 | | { XML_FROM_BOTTOM, ED_from_bottom }, |
79 | | { XML_FROM_CENTER, ED_from_center }, |
80 | | { XML_FROM_UPPER_LEFT, ED_from_upperleft }, |
81 | | { XML_FROM_UPPER_RIGHT, ED_from_upperright }, |
82 | | { XML_FROM_LOWER_LEFT, ED_from_lowerleft }, |
83 | | { XML_FROM_LOWER_RIGHT, ED_from_lowerright }, |
84 | | { XML_TO_LEFT, ED_to_left }, |
85 | | { XML_TO_TOP, ED_to_top }, |
86 | | { XML_TO_RIGHT, ED_to_right }, |
87 | | { XML_TO_BOTTOM, ED_to_bottom }, |
88 | | { XML_TO_UPPER_LEFT, ED_to_upperleft }, |
89 | | { XML_TO_UPPER_RIGHT, ED_to_upperright }, |
90 | | { XML_TO_LOWER_RIGHT, ED_to_lowerright }, |
91 | | { XML_TO_LOWER_LEFT, ED_to_lowerleft }, |
92 | | { XML_PATH, ED_path }, |
93 | | { XML_SPIRAL_INWARD_LEFT, ED_spiral_inward_left }, |
94 | | { XML_SPIRAL_INWARD_RIGHT,ED_spiral_inward_right }, |
95 | | { XML_SPIRAL_OUTWARD_LEFT, ED_spiral_outward_left }, |
96 | | { XML_SPIRAL_OUTWARD_RIGHT, ED_spiral_outward_right }, |
97 | | { XML_VERTICAL, ED_vertical }, |
98 | | { XML_HORIZONTAL, ED_horizontal }, |
99 | | { XML_TO_CENTER, ED_to_center }, |
100 | | { XML_CLOCKWISE, ED_clockwise }, |
101 | | { XML_COUNTER_CLOCKWISE,ED_cclockwise }, |
102 | | { XML_TOKEN_INVALID, XMLEffectDirection(0) } |
103 | | }; |
104 | | |
105 | | const SvXMLEnumMapEntry<AnimationSpeed> aXML_AnimationSpeed_EnumMap[] = |
106 | | { |
107 | | { XML_SLOW, AnimationSpeed_SLOW }, |
108 | | { XML_MEDIUM, AnimationSpeed_MEDIUM }, |
109 | | { XML_FAST, AnimationSpeed_FAST }, |
110 | | { XML_TOKEN_INVALID, AnimationSpeed(0) } |
111 | | }; |
112 | | |
113 | | AnimationEffect ImplSdXMLgetEffect( XMLEffect eKind, XMLEffectDirection eDirection, sal_Int16 nStartScale, bool /*bIn*/ ) |
114 | 0 | { |
115 | 0 | switch( eKind ) |
116 | 0 | { |
117 | 0 | case EK_fade: |
118 | 0 | switch( eDirection ) |
119 | 0 | { |
120 | 0 | case ED_from_left: return AnimationEffect_FADE_FROM_LEFT; |
121 | 0 | case ED_from_top: return AnimationEffect_FADE_FROM_TOP; |
122 | 0 | case ED_from_right: return AnimationEffect_FADE_FROM_RIGHT; |
123 | 0 | case ED_from_bottom: return AnimationEffect_FADE_FROM_BOTTOM; |
124 | 0 | case ED_from_center: return AnimationEffect_FADE_FROM_CENTER; |
125 | 0 | case ED_from_upperleft: return AnimationEffect_FADE_FROM_UPPERLEFT; |
126 | 0 | case ED_from_upperright: return AnimationEffect_FADE_FROM_UPPERRIGHT; |
127 | 0 | case ED_from_lowerleft: return AnimationEffect_FADE_FROM_LOWERLEFT; |
128 | 0 | case ED_from_lowerright: return AnimationEffect_FADE_FROM_LOWERRIGHT; |
129 | 0 | case ED_to_center: return AnimationEffect_FADE_TO_CENTER; |
130 | 0 | case ED_clockwise: return AnimationEffect_CLOCKWISE; |
131 | 0 | case ED_cclockwise: return AnimationEffect_COUNTERCLOCKWISE; |
132 | 0 | case ED_spiral_inward_left: return AnimationEffect_SPIRALIN_LEFT; |
133 | 0 | case ED_spiral_inward_right:return AnimationEffect_SPIRALIN_RIGHT; |
134 | 0 | case ED_spiral_outward_left:return AnimationEffect_SPIRALOUT_LEFT; |
135 | 0 | case ED_spiral_outward_right:return AnimationEffect_SPIRALOUT_RIGHT; |
136 | 0 | default: return AnimationEffect_FADE_FROM_LEFT; |
137 | 0 | } |
138 | 0 | case EK_move: |
139 | 0 | if( nStartScale == 200 ) |
140 | 0 | { |
141 | 0 | return AnimationEffect_ZOOM_OUT_SMALL; |
142 | 0 | } |
143 | 0 | else if( nStartScale == 50 ) |
144 | 0 | { |
145 | 0 | return AnimationEffect_ZOOM_IN_SMALL; |
146 | 0 | } |
147 | 0 | else if( nStartScale < 100 ) |
148 | 0 | { |
149 | 0 | switch( eDirection ) |
150 | 0 | { |
151 | 0 | case ED_from_left: return AnimationEffect_ZOOM_IN_FROM_LEFT; |
152 | 0 | case ED_from_top: return AnimationEffect_ZOOM_IN_FROM_TOP; |
153 | 0 | case ED_from_right: return AnimationEffect_ZOOM_IN_FROM_RIGHT; |
154 | 0 | case ED_from_bottom: return AnimationEffect_ZOOM_IN_FROM_BOTTOM; |
155 | 0 | case ED_from_upperleft: return AnimationEffect_ZOOM_IN_FROM_UPPERLEFT; |
156 | 0 | case ED_from_upperright: return AnimationEffect_ZOOM_IN_FROM_UPPERRIGHT; |
157 | 0 | case ED_from_lowerleft: return AnimationEffect_ZOOM_IN_FROM_LOWERLEFT; |
158 | 0 | case ED_from_lowerright: return AnimationEffect_ZOOM_IN_FROM_LOWERRIGHT; |
159 | 0 | case ED_from_center: return AnimationEffect_ZOOM_IN_FROM_CENTER; |
160 | 0 | case ED_spiral_inward_left: return AnimationEffect_ZOOM_IN_SPIRAL; |
161 | 0 | case ED_to_left: return AnimationEffect_MOVE_TO_LEFT; |
162 | 0 | case ED_to_top: return AnimationEffect_MOVE_TO_TOP; |
163 | 0 | case ED_to_right: return AnimationEffect_MOVE_TO_RIGHT; |
164 | 0 | case ED_to_bottom: return AnimationEffect_MOVE_TO_BOTTOM; |
165 | 0 | case ED_to_upperleft: return AnimationEffect_MOVE_TO_UPPERLEFT; |
166 | 0 | case ED_to_upperright: return AnimationEffect_MOVE_TO_UPPERRIGHT; |
167 | 0 | case ED_to_lowerright: return AnimationEffect_MOVE_TO_LOWERRIGHT; |
168 | 0 | case ED_to_lowerleft: return AnimationEffect_MOVE_TO_LOWERLEFT; |
169 | 0 | default: return AnimationEffect_ZOOM_IN; |
170 | 0 | } |
171 | 0 | } |
172 | 0 | else if( nStartScale > 100 ) |
173 | 0 | { |
174 | 0 | switch( eDirection ) |
175 | 0 | { |
176 | 0 | case ED_from_left: return AnimationEffect_ZOOM_OUT_FROM_LEFT; |
177 | 0 | case ED_from_top: return AnimationEffect_ZOOM_OUT_FROM_TOP; |
178 | 0 | case ED_from_right: return AnimationEffect_ZOOM_OUT_FROM_RIGHT; |
179 | 0 | case ED_from_bottom: return AnimationEffect_ZOOM_OUT_FROM_BOTTOM; |
180 | 0 | case ED_from_upperleft: return AnimationEffect_ZOOM_OUT_FROM_UPPERLEFT; |
181 | 0 | case ED_from_upperright: return AnimationEffect_ZOOM_OUT_FROM_UPPERRIGHT; |
182 | 0 | case ED_from_lowerleft: return AnimationEffect_ZOOM_OUT_FROM_LOWERLEFT; |
183 | 0 | case ED_from_lowerright: return AnimationEffect_ZOOM_OUT_FROM_LOWERRIGHT; |
184 | 0 | case ED_from_center: return AnimationEffect_ZOOM_OUT_FROM_CENTER; |
185 | 0 | case ED_spiral_inward_left: return AnimationEffect_ZOOM_OUT_SPIRAL; |
186 | 0 | default: return AnimationEffect_ZOOM_OUT; |
187 | 0 | } |
188 | 0 | } |
189 | 0 | else |
190 | 0 | { |
191 | 0 | switch( eDirection ) |
192 | 0 | { |
193 | 0 | case ED_from_left: return AnimationEffect_MOVE_FROM_LEFT; |
194 | 0 | case ED_from_top: return AnimationEffect_MOVE_FROM_TOP; |
195 | 0 | case ED_from_right: return AnimationEffect_MOVE_FROM_RIGHT; |
196 | 0 | case ED_from_bottom: return AnimationEffect_MOVE_FROM_BOTTOM; |
197 | 0 | case ED_from_upperleft: return AnimationEffect_MOVE_FROM_UPPERLEFT; |
198 | 0 | case ED_from_upperright: return AnimationEffect_MOVE_FROM_UPPERRIGHT; |
199 | 0 | case ED_from_lowerleft: return AnimationEffect_MOVE_FROM_LOWERLEFT; |
200 | 0 | case ED_from_lowerright: return AnimationEffect_MOVE_FROM_LOWERRIGHT; |
201 | 0 | case ED_path: return AnimationEffect_PATH; |
202 | 0 | case ED_to_top: return AnimationEffect_MOVE_TO_TOP; |
203 | 0 | case ED_to_right: return AnimationEffect_MOVE_TO_RIGHT; |
204 | 0 | case ED_to_bottom: return AnimationEffect_MOVE_TO_BOTTOM; |
205 | 0 | case ED_to_upperleft: return AnimationEffect_MOVE_TO_UPPERLEFT; |
206 | 0 | case ED_to_upperright: return AnimationEffect_MOVE_TO_UPPERRIGHT; |
207 | 0 | case ED_to_lowerright: return AnimationEffect_MOVE_TO_LOWERRIGHT; |
208 | 0 | case ED_to_lowerleft: return AnimationEffect_MOVE_TO_LOWERLEFT; |
209 | 0 | default: |
210 | 0 | break; |
211 | 0 | } |
212 | 0 | } |
213 | 0 | return AnimationEffect_MOVE_FROM_LEFT; |
214 | 0 | case EK_stripes: |
215 | 0 | if( eDirection == ED_vertical ) |
216 | 0 | return AnimationEffect_VERTICAL_STRIPES; |
217 | 0 | else |
218 | 0 | return AnimationEffect_HORIZONTAL_STRIPES; |
219 | 0 | case EK_open: |
220 | 0 | if( eDirection == ED_vertical ) |
221 | 0 | return AnimationEffect_OPEN_VERTICAL; |
222 | 0 | else |
223 | 0 | return AnimationEffect_OPEN_HORIZONTAL; |
224 | 0 | case EK_close: |
225 | 0 | if( eDirection == ED_vertical ) |
226 | 0 | return AnimationEffect_CLOSE_VERTICAL; |
227 | 0 | else |
228 | 0 | return AnimationEffect_CLOSE_HORIZONTAL; |
229 | 0 | case EK_dissolve: |
230 | 0 | return AnimationEffect_DISSOLVE; |
231 | 0 | case EK_wavyline: |
232 | 0 | switch( eDirection ) |
233 | 0 | { |
234 | 0 | case ED_from_left: return AnimationEffect_WAVYLINE_FROM_LEFT; |
235 | 0 | case ED_from_top: return AnimationEffect_WAVYLINE_FROM_TOP; |
236 | 0 | case ED_from_right: return AnimationEffect_WAVYLINE_FROM_RIGHT; |
237 | 0 | case ED_from_bottom: return AnimationEffect_WAVYLINE_FROM_BOTTOM; |
238 | 0 | default: return AnimationEffect_WAVYLINE_FROM_LEFT; |
239 | 0 | } |
240 | 0 | case EK_random: |
241 | 0 | return AnimationEffect_RANDOM; |
242 | 0 | case EK_lines: |
243 | 0 | if( eDirection == ED_vertical ) |
244 | 0 | return AnimationEffect_VERTICAL_LINES; |
245 | 0 | else |
246 | 0 | return AnimationEffect_HORIZONTAL_LINES; |
247 | 0 | case EK_laser: |
248 | 0 | switch( eDirection ) |
249 | 0 | { |
250 | 0 | case ED_from_left: return AnimationEffect_LASER_FROM_LEFT; |
251 | 0 | case ED_from_top: return AnimationEffect_LASER_FROM_TOP; |
252 | 0 | case ED_from_right: return AnimationEffect_LASER_FROM_RIGHT; |
253 | 0 | case ED_from_bottom: return AnimationEffect_LASER_FROM_BOTTOM; |
254 | 0 | case ED_from_upperleft: return AnimationEffect_LASER_FROM_UPPERLEFT; |
255 | 0 | case ED_from_upperright: return AnimationEffect_LASER_FROM_UPPERRIGHT; |
256 | 0 | case ED_from_lowerleft: return AnimationEffect_LASER_FROM_LOWERLEFT; |
257 | 0 | case ED_from_lowerright: return AnimationEffect_LASER_FROM_LOWERRIGHT; |
258 | 0 | default: return AnimationEffect_LASER_FROM_LEFT; |
259 | 0 | } |
260 | 0 | case EK_appear: |
261 | 0 | return AnimationEffect_APPEAR; |
262 | 0 | case EK_hide: |
263 | 0 | return AnimationEffect_HIDE; |
264 | 0 | case EK_move_short: |
265 | 0 | switch( eDirection ) |
266 | 0 | { |
267 | 0 | case ED_from_left: return AnimationEffect_MOVE_SHORT_FROM_LEFT; |
268 | 0 | case ED_from_top: return AnimationEffect_MOVE_SHORT_FROM_TOP; |
269 | 0 | case ED_from_right: return AnimationEffect_MOVE_SHORT_FROM_RIGHT; |
270 | 0 | case ED_from_bottom: return AnimationEffect_MOVE_SHORT_FROM_BOTTOM; |
271 | 0 | case ED_from_upperleft: return AnimationEffect_MOVE_SHORT_FROM_UPPERLEFT; |
272 | 0 | case ED_from_upperright: return AnimationEffect_MOVE_SHORT_FROM_UPPERRIGHT; |
273 | 0 | case ED_from_lowerleft: return AnimationEffect_MOVE_SHORT_FROM_LOWERLEFT; |
274 | 0 | case ED_from_lowerright: return AnimationEffect_MOVE_SHORT_FROM_LOWERRIGHT; |
275 | 0 | case ED_to_left: return AnimationEffect_MOVE_SHORT_TO_LEFT; |
276 | 0 | case ED_to_upperleft: return AnimationEffect_MOVE_SHORT_TO_UPPERLEFT; |
277 | 0 | case ED_to_top: return AnimationEffect_MOVE_SHORT_TO_TOP; |
278 | 0 | case ED_to_upperright: return AnimationEffect_MOVE_SHORT_TO_UPPERRIGHT; |
279 | 0 | case ED_to_right: return AnimationEffect_MOVE_SHORT_TO_RIGHT; |
280 | 0 | case ED_to_lowerright: return AnimationEffect_MOVE_SHORT_TO_LOWERRIGHT; |
281 | 0 | case ED_to_bottom: return AnimationEffect_MOVE_SHORT_TO_BOTTOM; |
282 | 0 | case ED_to_lowerleft: return AnimationEffect_MOVE_SHORT_TO_LOWERLEFT; |
283 | 0 | default: return AnimationEffect_MOVE_SHORT_FROM_LEFT; |
284 | 0 | } |
285 | 0 | case EK_checkerboard: |
286 | 0 | if( eDirection == ED_vertical ) |
287 | 0 | return AnimationEffect_VERTICAL_CHECKERBOARD; |
288 | 0 | else |
289 | 0 | return AnimationEffect_HORIZONTAL_CHECKERBOARD; |
290 | 0 | case EK_rotate: |
291 | 0 | if( eDirection == ED_vertical ) |
292 | 0 | return AnimationEffect_VERTICAL_ROTATE; |
293 | 0 | else |
294 | 0 | return AnimationEffect_HORIZONTAL_ROTATE; |
295 | 0 | case EK_stretch: |
296 | 0 | switch( eDirection ) |
297 | 0 | { |
298 | 0 | case ED_from_left: return AnimationEffect_STRETCH_FROM_LEFT; |
299 | 0 | case ED_from_top: return AnimationEffect_STRETCH_FROM_TOP; |
300 | 0 | case ED_from_right: return AnimationEffect_STRETCH_FROM_RIGHT; |
301 | 0 | case ED_from_bottom: return AnimationEffect_STRETCH_FROM_BOTTOM; |
302 | 0 | case ED_from_upperleft: return AnimationEffect_STRETCH_FROM_UPPERLEFT; |
303 | 0 | case ED_from_upperright: return AnimationEffect_STRETCH_FROM_UPPERRIGHT; |
304 | 0 | case ED_from_lowerleft: return AnimationEffect_STRETCH_FROM_LOWERLEFT; |
305 | 0 | case ED_from_lowerright: return AnimationEffect_STRETCH_FROM_LOWERRIGHT; |
306 | 0 | case ED_vertical: return AnimationEffect_VERTICAL_STRETCH; |
307 | 0 | case ED_horizontal: return AnimationEffect_HORIZONTAL_STRETCH; |
308 | 0 | default: |
309 | 0 | break; |
310 | 0 | } |
311 | 0 | return AnimationEffect_STRETCH_FROM_LEFT; |
312 | 0 | default: |
313 | 0 | return AnimationEffect_NONE; |
314 | 0 | } |
315 | 0 | } |
316 | | |
317 | | namespace { |
318 | | |
319 | | enum class XMLActionKind |
320 | | { |
321 | | SHOW, |
322 | | HIDE, |
323 | | DIM, |
324 | | PLAY |
325 | | }; |
326 | | |
327 | | class XMLAnimationsEffectContext : public SvXMLImportContext |
328 | | { |
329 | | public: |
330 | | rtl::Reference<XMLAnimationsContext> mxAnimationsContext; |
331 | | |
332 | | XMLActionKind meKind; |
333 | | bool mbTextEffect; |
334 | | OUString maShapeId; |
335 | | |
336 | | XMLEffect meEffect; |
337 | | XMLEffectDirection meDirection; |
338 | | sal_Int16 mnStartScale; |
339 | | |
340 | | AnimationSpeed meSpeed; |
341 | | sal_Int32 maDimColor; |
342 | | OUString maSoundURL; |
343 | | bool mbPlayFull; |
344 | | OUString maPathShapeId; |
345 | | |
346 | | public: |
347 | | |
348 | | XMLAnimationsEffectContext( SvXMLImport& rImport, |
349 | | sal_Int32 nElement, |
350 | | const Reference< XFastAttributeList >& xAttrList, |
351 | | XMLAnimationsContext& rAnimationsContext); |
352 | | |
353 | | virtual void SAL_CALL endFastElement(sal_Int32 nElement) override; |
354 | | |
355 | | virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( |
356 | | sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override; |
357 | | }; |
358 | | |
359 | | class XMLAnimationsSoundContext : public SvXMLImportContext |
360 | | { |
361 | | public: |
362 | | |
363 | | XMLAnimationsSoundContext( SvXMLImport& rImport, sal_Int32 nElement, const Reference< XFastAttributeList >& xAttrList, XMLAnimationsEffectContext* pParent ); |
364 | | }; |
365 | | |
366 | | } |
367 | | |
368 | | XMLAnimationsSoundContext::XMLAnimationsSoundContext( SvXMLImport& rImport, sal_Int32 nElement, const Reference< XFastAttributeList >& xAttrList, XMLAnimationsEffectContext* pParent ) |
369 | 0 | : SvXMLImportContext( rImport ) |
370 | 0 | { |
371 | 0 | if( !pParent || nElement != XML_ELEMENT(PRESENTATION, XML_SOUND) ) |
372 | 0 | return; |
373 | | |
374 | 0 | for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) |
375 | 0 | { |
376 | 0 | switch( aIter.getToken() ) |
377 | 0 | { |
378 | 0 | case XML_ELEMENT(XLINK, XML_HREF): |
379 | 0 | pParent->maSoundURL = rImport.GetAbsoluteReference(aIter.toString()); |
380 | 0 | break; |
381 | 0 | case XML_ELEMENT(PRESENTATION, XML_PLAY_FULL): |
382 | 0 | pParent->mbPlayFull = IsXMLToken( aIter, XML_TRUE ); |
383 | 0 | break; |
384 | 0 | default: |
385 | 0 | XMLOFF_WARN_UNKNOWN("xmloff", aIter); |
386 | 0 | } |
387 | 0 | } |
388 | 0 | } |
389 | | |
390 | | XMLAnimationsEffectContext::XMLAnimationsEffectContext( SvXMLImport& rImport, |
391 | | sal_Int32 nElement, |
392 | | const Reference< XFastAttributeList >& xAttrList, |
393 | | XMLAnimationsContext& rAnimationsContext ) |
394 | 0 | : SvXMLImportContext(rImport), |
395 | 0 | mxAnimationsContext( &rAnimationsContext ), |
396 | 0 | meKind( XMLActionKind::SHOW ), mbTextEffect( false ), |
397 | 0 | meEffect( EK_none ), meDirection( ED_none ), mnStartScale( 100 ), |
398 | 0 | meSpeed( AnimationSpeed_MEDIUM ), maDimColor(0), mbPlayFull( false ) |
399 | 0 | { |
400 | 0 | switch(nElement & TOKEN_MASK) |
401 | 0 | { |
402 | 0 | case XML_SHOW_SHAPE: |
403 | 0 | meKind = XMLActionKind::SHOW; |
404 | 0 | break; |
405 | 0 | case XML_SHOW_TEXT: |
406 | 0 | meKind = XMLActionKind::SHOW; |
407 | 0 | mbTextEffect = true; |
408 | 0 | break; |
409 | 0 | case XML_HIDE_SHAPE: |
410 | 0 | meKind = XMLActionKind::HIDE; |
411 | 0 | break; |
412 | 0 | case XML_HIDE_TEXT: |
413 | 0 | meKind = XMLActionKind::HIDE; |
414 | 0 | mbTextEffect = true; |
415 | 0 | break; |
416 | 0 | case XML_DIM: |
417 | 0 | meKind = XMLActionKind::DIM; |
418 | 0 | break; |
419 | 0 | case XML_PLAY: |
420 | 0 | meKind = XMLActionKind::PLAY; |
421 | 0 | break; |
422 | 0 | default: |
423 | 0 | XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement); |
424 | | // unknown action, overread |
425 | 0 | return; |
426 | 0 | } |
427 | | |
428 | 0 | for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) |
429 | 0 | { |
430 | 0 | switch( aIter.getToken() ) |
431 | 0 | { |
432 | 0 | case XML_ELEMENT(DRAW, XML_SHAPE_ID): |
433 | 0 | maShapeId = aIter.toString(); |
434 | 0 | break; |
435 | 0 | case XML_ELEMENT(DRAW, XML_COLOR): |
436 | 0 | ::sax::Converter::convertColor(maDimColor, aIter.toView()); |
437 | 0 | break; |
438 | | |
439 | 0 | case XML_ELEMENT(PRESENTATION, XML_EFFECT): |
440 | 0 | SvXMLUnitConverter::convertEnum( meEffect, aIter.toView(), aXML_AnimationEffect_EnumMap ); |
441 | 0 | break; |
442 | 0 | case XML_ELEMENT(PRESENTATION, XML_DIRECTION): |
443 | 0 | SvXMLUnitConverter::convertEnum( meDirection, aIter.toView(), aXML_AnimationDirection_EnumMap ); |
444 | 0 | break; |
445 | 0 | case XML_ELEMENT(PRESENTATION, XML_START_SCALE): |
446 | 0 | { |
447 | 0 | sal_Int32 nScale; |
448 | 0 | if (::sax::Converter::convertPercent( nScale, aIter.toView() )) |
449 | 0 | mnStartScale = static_cast<sal_Int16>(nScale); |
450 | 0 | break; |
451 | 0 | } |
452 | 0 | case XML_ELEMENT(PRESENTATION, XML_SPEED): |
453 | 0 | SvXMLUnitConverter::convertEnum( meSpeed, aIter.toView(), aXML_AnimationSpeed_EnumMap ); |
454 | 0 | break; |
455 | 0 | case XML_ELEMENT(PRESENTATION, XML_PATH_ID): |
456 | 0 | maPathShapeId = aIter.toString(); |
457 | 0 | break; |
458 | 0 | default: |
459 | 0 | XMLOFF_WARN_UNKNOWN("xmloff", aIter); |
460 | 0 | } |
461 | 0 | } |
462 | 0 | } |
463 | | |
464 | | css::uno::Reference< css::xml::sax::XFastContextHandler > XMLAnimationsEffectContext::createFastChildContext( |
465 | | sal_Int32 nElement, |
466 | | const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) |
467 | 0 | { |
468 | 0 | return new XMLAnimationsSoundContext( GetImport(), nElement, xAttrList, this ); |
469 | 0 | } |
470 | | |
471 | | void XMLAnimationsEffectContext::endFastElement(sal_Int32 ) |
472 | 0 | { |
473 | | // set effect on shape |
474 | |
|
475 | 0 | try |
476 | 0 | { |
477 | 0 | if( !maShapeId.isEmpty() ) |
478 | 0 | { |
479 | 0 | Reference< XPropertySet > xSet; |
480 | 0 | if( mxAnimationsContext->maLastShapeId != maShapeId ) |
481 | 0 | { |
482 | 0 | xSet.set( GetImport().getInterfaceToIdentifierMapper().getReference( maShapeId ), UNO_QUERY ); |
483 | 0 | if( xSet.is() ) |
484 | 0 | { |
485 | | // check for presentation shape service |
486 | 0 | { |
487 | 0 | Reference< XServiceInfo > xServiceInfo( xSet, UNO_QUERY ); |
488 | 0 | if( !xServiceInfo.is() || !xServiceInfo->supportsService( u"com.sun.star.presentation.Shape"_ustr ) ) |
489 | 0 | return; |
490 | 0 | } |
491 | | |
492 | 0 | mxAnimationsContext->maLastShapeId = maShapeId; |
493 | 0 | mxAnimationsContext->mxLastShape = xSet; |
494 | 0 | } |
495 | 0 | } |
496 | 0 | else |
497 | 0 | { |
498 | 0 | xSet = mxAnimationsContext->mxLastShape; |
499 | 0 | } |
500 | | |
501 | 0 | if( xSet.is() ) |
502 | 0 | { |
503 | 0 | if( meKind == XMLActionKind::DIM ) |
504 | 0 | { |
505 | 0 | xSet->setPropertyValue( u"DimPrevious"_ustr, Any(true) ); |
506 | |
|
507 | 0 | xSet->setPropertyValue( u"DimColor"_ustr, Any(maDimColor) ); |
508 | 0 | } |
509 | 0 | else if( meKind == XMLActionKind::PLAY ) |
510 | 0 | { |
511 | 0 | xSet->setPropertyValue( u"IsAnimation"_ustr, Any(true) ); |
512 | | |
513 | | // #i42894# speed is not supported for the old group animation fallback, so no need to set it |
514 | | // aAny <<= meSpeed; |
515 | | // xSet->setPropertyValue( mpImpl->msSpeed, aAny ); |
516 | 0 | } |
517 | 0 | else |
518 | 0 | { |
519 | 0 | if( meKind == XMLActionKind::HIDE && !mbTextEffect && meEffect == EK_none ) |
520 | 0 | { |
521 | 0 | xSet->setPropertyValue( u"DimHide"_ustr, Any(true) ); |
522 | 0 | } |
523 | 0 | else |
524 | 0 | { |
525 | 0 | const AnimationEffect eEffect = ImplSdXMLgetEffect( meEffect, meDirection, mnStartScale, meKind == XMLActionKind::SHOW ); |
526 | |
|
527 | 0 | if (mbTextEffect) |
528 | 0 | xSet->setPropertyValue( u"TextEffect"_ustr, Any( eEffect ) ); |
529 | 0 | else |
530 | 0 | xSet->setPropertyValue( u"Effect"_ustr, Any( eEffect ) ); |
531 | 0 | xSet->setPropertyValue( u"Speed"_ustr, Any( meSpeed ) ); |
532 | |
|
533 | 0 | if( eEffect == AnimationEffect_PATH && !maPathShapeId.isEmpty() ) |
534 | 0 | { |
535 | 0 | Reference< XShape > xPath( GetImport().getInterfaceToIdentifierMapper().getReference( maPathShapeId ), UNO_QUERY ); |
536 | 0 | if( xPath.is() ) |
537 | 0 | xSet->setPropertyValue( u"AnimationPath"_ustr, Any( xPath ) ); |
538 | 0 | } |
539 | 0 | } |
540 | 0 | } |
541 | 0 | } |
542 | 0 | if( !maSoundURL.isEmpty() ) |
543 | 0 | { |
544 | 0 | if( xSet.is() ) |
545 | 0 | { |
546 | 0 | xSet->setPropertyValue( u"Sound"_ustr, Any(maSoundURL) ); |
547 | 0 | xSet->setPropertyValue( u"PlayFull"_ustr, Any(mbPlayFull) ); |
548 | 0 | xSet->setPropertyValue( u"SoundOn"_ustr, Any(true) ); |
549 | 0 | } |
550 | 0 | else |
551 | 0 | { |
552 | 0 | OSL_FAIL("XMLAnimationsEffectContext::EndElement - Sound URL without a XPropertySet!"); |
553 | 0 | } |
554 | 0 | } |
555 | 0 | } |
556 | 0 | } |
557 | 0 | catch (const Exception&) |
558 | 0 | { |
559 | 0 | TOOLS_WARN_EXCEPTION("xmloff.draw", |
560 | 0 | "exception caught while importing animation information!"); |
561 | 0 | } |
562 | 0 | } |
563 | | |
564 | | |
565 | | XMLAnimationsContext::XMLAnimationsContext( SvXMLImport& rImport ) |
566 | 0 | : SvXMLImportContext(rImport) |
567 | 0 | { |
568 | 0 | } |
569 | | |
570 | | css::uno::Reference< css::xml::sax::XFastContextHandler > XMLAnimationsContext::createFastChildContext( |
571 | | sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) |
572 | 0 | { |
573 | 0 | return new XMLAnimationsEffectContext( GetImport(), nElement, xAttrList, *this ); |
574 | 0 | } |
575 | | |
576 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |