Bug Summary

File:home/maarten/src/libreoffice/core/include/com/sun/star/uno/Any.hxx
Warning:line 577, column 17
Dereference of null pointer

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name animationexport.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D XMLOFF_DLLIMPLEMENTATION -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/xmloff/inc -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/xmloff/generated -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx

/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx

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
21#include <com/sun/star/animations/XAnimateColor.hpp>
22#include <com/sun/star/animations/XCommand.hpp>
23#include <com/sun/star/animations/Timing.hpp>
24#include <com/sun/star/animations/Event.hpp>
25#include <com/sun/star/animations/XAnimateMotion.hpp>
26#include <com/sun/star/animations/XAnimatePhysics.hpp>
27#include <com/sun/star/animations/XAnimateTransform.hpp>
28#include <com/sun/star/animations/XTransitionFilter.hpp>
29#include <com/sun/star/animations/XIterateContainer.hpp>
30#include <com/sun/star/animations/XAudio.hpp>
31#include <com/sun/star/animations/AnimationColorSpace.hpp>
32#include <com/sun/star/animations/AnimationNodeType.hpp>
33#include <com/sun/star/animations/AnimationRestart.hpp>
34#include <com/sun/star/animations/EventTrigger.hpp>
35#include <com/sun/star/animations/AnimationFill.hpp>
36#include <com/sun/star/animations/AnimationEndSync.hpp>
37#include <com/sun/star/animations/AnimationCalcMode.hpp>
38#include <com/sun/star/animations/AnimationAdditiveMode.hpp>
39#include <com/sun/star/animations/AnimationTransformType.hpp>
40#include <com/sun/star/animations/TransitionType.hpp>
41#include <com/sun/star/animations/TransitionSubType.hpp>
42#include <com/sun/star/animations/ValuePair.hpp>
43#include <com/sun/star/container/XEnumerationAccess.hpp>
44#include <com/sun/star/beans/NamedValue.hpp>
45#include <com/sun/star/beans/XPropertySet.hpp>
46#include <com/sun/star/document/XStorageBasedDocument.hpp>
47#include <com/sun/star/embed/ElementModes.hpp>
48#include <com/sun/star/embed/XTransactedObject.hpp>
49#include <com/sun/star/presentation/EffectNodeType.hpp>
50#include <com/sun/star/presentation/EffectPresetClass.hpp>
51#include <com/sun/star/presentation/ParagraphTarget.hpp>
52#include <com/sun/star/presentation/TextAnimationType.hpp>
53#include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
54#include <com/sun/star/presentation/EffectCommands.hpp>
55#include <o3tl/any.hxx>
56#include <sax/tools/converter.hxx>
57#include <sal/log.hxx>
58#include <tools/diagnose_ex.h>
59
60#include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
61#include "sdpropls.hxx"
62#include <xmlsdtypes.hxx>
63#include <xmloff/xmltoken.hxx>
64#include <xmloff/xmlnamespace.hxx>
65#include <xmloff/xmluconv.hxx>
66#include <xmloff/xmlexp.hxx>
67#include <xmloff/xmlement.hxx>
68#include <xmloff/xmlprhdl.hxx>
69
70#include <animations.hxx>
71#include <xmloff/animationexport.hxx>
72
73using namespace css;
74using namespace ::std;
75using namespace ::cppu;
76using namespace ::com::sun::star::animations;
77using namespace ::com::sun::star::presentation;
78using namespace ::com::sun::star::drawing;
79using namespace ::com::sun::star::beans;
80using namespace ::xmloff::token;
81
82using ::com::sun::star::uno::Any;
83using ::com::sun::star::uno::UNO_QUERY;
84using ::com::sun::star::uno::UNO_QUERY_THROW;
85using ::com::sun::star::uno::Reference;
86using ::com::sun::star::uno::Sequence;
87using ::com::sun::star::uno::Exception;
88using ::com::sun::star::uno::RuntimeException;
89using ::com::sun::star::uno::XInterface;
90using ::com::sun::star::beans::NamedValue;
91using ::com::sun::star::container::XEnumerationAccess;
92using ::com::sun::star::container::XEnumeration;
93
94namespace xmloff
95{
96
97const SvXMLEnumMapEntry<sal_Int16> aAnimations_EnumMap_Fill[] =
98{
99 { XML_DEFAULT, AnimationFill::DEFAULT },
100 { XML_REMOVE, AnimationFill::REMOVE },
101 { XML_FREEZE, AnimationFill::FREEZE },
102 { XML_HOLD, AnimationFill::HOLD },
103 { XML_TRANSITION, AnimationFill::TRANSITION },
104 { XML_AUTO, AnimationFill::AUTO },
105 { XML_TOKEN_INVALID, 0 }
106};
107const SvXMLEnumMapEntry<sal_Int16> aAnimations_EnumMap_FillDefault[] =
108{
109 { XML_INHERIT, AnimationFill::INHERIT },
110 { XML_REMOVE, AnimationFill::REMOVE },
111 { XML_FREEZE, AnimationFill::FREEZE },
112 { XML_HOLD, AnimationFill::HOLD },
113 { XML_TRANSITION, AnimationFill::TRANSITION },
114 { XML_AUTO, AnimationFill::AUTO },
115 { XML_TOKEN_INVALID, 0 }
116};
117const SvXMLEnumMapEntry<sal_Int16> aAnimations_EnumMap_Restart[] =
118{
119 { XML_DEFAULT, AnimationRestart::DEFAULT },
120 { XML_ALWAYS, AnimationRestart::ALWAYS },
121 { XML_WHENNOTACTIVE,AnimationRestart::WHEN_NOT_ACTIVE },
122 { XML_NEVER, AnimationRestart::NEVER },
123 { XML_TOKEN_INVALID, 0 }
124};
125const SvXMLEnumMapEntry<sal_Int16> aAnimations_EnumMap_RestartDefault[] =
126{
127 { XML_INHERIT, AnimationRestart::INHERIT },
128 { XML_ALWAYS, AnimationRestart::ALWAYS },
129 { XML_WHENNOTACTIVE,AnimationRestart::WHEN_NOT_ACTIVE },
130 { XML_NEVER, AnimationRestart::NEVER },
131 { XML_TOKEN_INVALID, 0 }
132};
133const SvXMLEnumMapEntry<sal_Int16> aAnimations_EnumMap_Endsync[] =
134{
135 { XML_FIRST, AnimationEndSync::FIRST },
136 { XML_LAST, AnimationEndSync::LAST },
137 { XML_ALL, AnimationEndSync::ALL },
138 { XML_MEDIA, AnimationEndSync::MEDIA },
139 { XML_TOKEN_INVALID, 0 }
140};
141const SvXMLEnumMapEntry<sal_Int16> aAnimations_EnumMap_CalcMode[] =
142{
143 { XML_DISCRETE, AnimationCalcMode::DISCRETE },
144 { XML_LINEAR, AnimationCalcMode::LINEAR },
145 { XML_PACED, AnimationCalcMode::PACED },
146 { XML_SPLINE, AnimationCalcMode::SPLINE },
147 { XML_TOKEN_INVALID, 0 }
148};
149const SvXMLEnumMapEntry<sal_Int16> aAnimations_EnumMap_AdditiveMode[] =
150{
151 { XML_BASE, AnimationAdditiveMode::BASE },
152 { XML_SUM, AnimationAdditiveMode::SUM },
153 { XML_REPLACE, AnimationAdditiveMode::REPLACE },
154 { XML_MULTIPLY, AnimationAdditiveMode::MULTIPLY },
155 { XML_NONE, AnimationAdditiveMode::NONE },
156 { XML_TOKEN_INVALID, 0 }
157};
158const SvXMLEnumMapEntry<sal_Int16> aAnimations_EnumMap_TransformType[] =
159{
160 { XML_TRANSLATE, AnimationTransformType::TRANSLATE },
161 { XML_SCALE, AnimationTransformType::SCALE },
162 { XML_ROTATE, AnimationTransformType::ROTATE },
163 { XML_SKEWX, AnimationTransformType::SKEWX },
164 { XML_SKEWY, AnimationTransformType::SKEWY },
165 { XML_TOKEN_INVALID, 0 }
166};
167const SvXMLEnumMapEntry<sal_Int16> aAnimations_EnumMap_TransitionType[] =
168{
169 { XML_BARWIPE, TransitionType::BARWIPE },
170 { XML_BOXWIPE, TransitionType::BOXWIPE },
171 { XML_FOURBOXWIPE, TransitionType::FOURBOXWIPE },
172 { XML_BARNDOORWIPE, TransitionType::BARNDOORWIPE },
173 { XML_DIAGONALWIPE, TransitionType::DIAGONALWIPE },
174 { XML_BOWTIEWIPE, TransitionType::BOWTIEWIPE },
175 { XML_MISCDIAGONALWIPE, TransitionType::MISCDIAGONALWIPE },
176 { XML_VEEWIPE, TransitionType::VEEWIPE },
177 { XML_BARNVEEWIPE, TransitionType::BARNVEEWIPE },
178 { XML_ZIGZAGWIPE, TransitionType::ZIGZAGWIPE },
179 { XML_BARNZIGZAGWIPE, TransitionType::BARNZIGZAGWIPE },
180 { XML_IRISWIPE, TransitionType::IRISWIPE },
181 { XML_TRIANGLEWIPE, TransitionType::TRIANGLEWIPE },
182 { XML_ARROWHEADWIPE, TransitionType::ARROWHEADWIPE },
183 { XML_PENTAGONWIPE, TransitionType::PENTAGONWIPE },
184 { XML_HEXAGONWIPE, TransitionType::HEXAGONWIPE },
185 { XML_ELLIPSEWIPE, TransitionType::ELLIPSEWIPE },
186 { XML_EYEWIPE, TransitionType::EYEWIPE },
187 { XML_ROUNDRECTWIPE, TransitionType::ROUNDRECTWIPE },
188 { XML_STARWIPE, TransitionType::STARWIPE },
189 { XML_MISCSHAPEWIPE, TransitionType::MISCSHAPEWIPE },
190 { XML_CLOCKWIPE, TransitionType::CLOCKWIPE },
191 { XML_PINWHEELWIPE, TransitionType::PINWHEELWIPE },
192 { XML_SINGLESWEEPWIPE, TransitionType::SINGLESWEEPWIPE },
193 { XML_FANWIPE, TransitionType::FANWIPE },
194 { XML_DOUBLEFANWIPE, TransitionType::DOUBLEFANWIPE },
195 { XML_DOUBLESWEEPWIPE, TransitionType::DOUBLESWEEPWIPE },
196 { XML_SALOONDOORWIPE, TransitionType::SALOONDOORWIPE },
197 { XML_WINDSHIELDWIPE, TransitionType::WINDSHIELDWIPE },
198 { XML_SNAKEWIPE, TransitionType::SNAKEWIPE },
199 { XML_SPIRALWIPE, TransitionType::SPIRALWIPE },
200 { XML_PARALLELSNAKESWIPE,TransitionType::PARALLELSNAKESWIPE },
201 { XML_BOXSNAKESWIPE, TransitionType::BOXSNAKESWIPE },
202 { XML_WATERFALLWIPE, TransitionType::WATERFALLWIPE },
203 { XML_PUSHWIPE, TransitionType::PUSHWIPE },
204 { XML_SLIDEWIPE, TransitionType::SLIDEWIPE },
205 { XML_FADE, TransitionType::FADE },
206 { XML_RANDOMBARWIPE, TransitionType::RANDOMBARWIPE },
207 { XML_CHECKERBOARDWIPE, TransitionType::CHECKERBOARDWIPE },
208 { XML_DISSOLVE, TransitionType::DISSOLVE },
209 { XML_BLINDSWIPE, TransitionType::BLINDSWIPE },
210 { XML_RANDOM, TransitionType::RANDOM },
211 { XML_ZOOM, TransitionType::ZOOM },
212 { XML_TOKEN_INVALID, 0 }
213};
214const SvXMLEnumMapEntry<sal_Int16> aAnimations_EnumMap_TransitionSubType[] =
215{
216 { XML_DEFAULT, TransitionSubType::DEFAULT },
217 { XML_LEFTTORIGHT, TransitionSubType::LEFTTORIGHT },
218 { XML_TOPTOBOTTOM, TransitionSubType::TOPTOBOTTOM },
219 { XML_TOPLEFT, TransitionSubType::TOPLEFT },
220 { XML_TOPRIGHT, TransitionSubType::TOPRIGHT },
221 { XML_BOTTOMRIGHT, TransitionSubType::BOTTOMRIGHT },
222 { XML_BOTTOMLEFT, TransitionSubType::BOTTOMLEFT },
223 { XML_TOPCENTER, TransitionSubType::TOPCENTER },
224 { XML_RIGHTCENTER, TransitionSubType::RIGHTCENTER },
225 { XML_BOTTOMCENTER, TransitionSubType::BOTTOMCENTER },
226 { XML_LEFTCENTER, TransitionSubType::LEFTCENTER },
227 { XML_CORNERSIN, TransitionSubType::CORNERSIN },
228 { XML_CORNERSOUT, TransitionSubType::CORNERSOUT },
229 { XML_VERTICAL, TransitionSubType::VERTICAL },
230 { XML_HORIZONTAL, TransitionSubType::HORIZONTAL },
231 { XML_DIAGONALBOTTOMLEFT, TransitionSubType::DIAGONALBOTTOMLEFT },
232 { XML_DIAGONALTOPLEFT, TransitionSubType::DIAGONALTOPLEFT },
233 { XML_DOUBLEBARNDOOR, TransitionSubType::DOUBLEBARNDOOR },
234 { XML_DOUBLEDIAMOND, TransitionSubType::DOUBLEDIAMOND },
235 { XML_DOWN, TransitionSubType::DOWN },
236 { XML_LEFT, TransitionSubType::LEFT },
237 { XML_UP, TransitionSubType::UP },
238 { XML_RIGHT, TransitionSubType::RIGHT },
239 { XML_RECTANGLE, TransitionSubType::RECTANGLE },
240 { XML_DIAMOND, TransitionSubType::DIAMOND },
241 { XML_CIRCLE, TransitionSubType::CIRCLE },
242 { XML_FOURPOINT, TransitionSubType::FOURPOINT },
243 { XML_FIVEPOINT, TransitionSubType::FIVEPOINT },
244 { XML_SIXPOINT, TransitionSubType::SIXPOINT },
245 { XML_HEART, TransitionSubType::HEART },
246 { XML_KEYHOLE, TransitionSubType::KEYHOLE },
247 { XML_CLOCKWISETWELVE, TransitionSubType::CLOCKWISETWELVE },
248 { XML_CLOCKWISETHREE, TransitionSubType::CLOCKWISETHREE },
249 { XML_CLOCKWISESIX, TransitionSubType::CLOCKWISESIX },
250 { XML_CLOCKWISENINE, TransitionSubType::CLOCKWISENINE },
251 { XML_TWOBLADEVERTICAL, TransitionSubType::TWOBLADEVERTICAL },
252 { XML_TWOBLADEHORIZONTAL, TransitionSubType::TWOBLADEHORIZONTAL },
253 { XML_FOURBLADE, TransitionSubType::FOURBLADE },
254 { XML_CLOCKWISETOP, TransitionSubType::CLOCKWISETOP },
255 { XML_CLOCKWISERIGHT, TransitionSubType::CLOCKWISERIGHT },
256 { XML_CLOCKWISEBOTTOM, TransitionSubType::CLOCKWISEBOTTOM },
257 { XML_CLOCKWISELEFT, TransitionSubType::CLOCKWISELEFT },
258 { XML_CLOCKWISETOPLEFT, TransitionSubType::CLOCKWISETOPLEFT },
259 { XML_COUNTERCLOCKWISEBOTTOMLEFT,TransitionSubType::COUNTERCLOCKWISEBOTTOMLEFT },
260 { XML_CLOCKWISEBOTTOMRIGHT, TransitionSubType::CLOCKWISEBOTTOMRIGHT },
261 { XML_COUNTERCLOCKWISETOPRIGHT,TransitionSubType::COUNTERCLOCKWISETOPRIGHT },
262 { XML_CENTERTOP, TransitionSubType::CENTERTOP },
263 { XML_CENTERRIGHT, TransitionSubType::CENTERRIGHT },
264 { XML_TOP, TransitionSubType::TOP },
265 { XML_BOTTOM, TransitionSubType::BOTTOM },
266 { XML_FANOUTVERTICAL, TransitionSubType::FANOUTVERTICAL },
267 { XML_FANOUTHORIZONTAL, TransitionSubType::FANOUTHORIZONTAL },
268 { XML_FANINVERTICAL, TransitionSubType::FANINVERTICAL },
269 { XML_FANINHORIZONTAL, TransitionSubType::FANINHORIZONTAL },
270 { XML_PARALLELVERTICAL, TransitionSubType::PARALLELVERTICAL },
271 { XML_PARALLELDIAGONAL, TransitionSubType::PARALLELDIAGONAL },
272 { XML_OPPOSITEVERTICAL, TransitionSubType::OPPOSITEVERTICAL },
273 { XML_OPPOSITEHORIZONTAL, TransitionSubType::OPPOSITEHORIZONTAL },
274 { XML_PARALLELDIAGONALTOPLEFT,TransitionSubType::PARALLELDIAGONALTOPLEFT },
275 { XML_PARALLELDIAGONALBOTTOMLEFT,TransitionSubType::PARALLELDIAGONALBOTTOMLEFT },
276 { XML_TOPLEFTHORIZONTAL, TransitionSubType::TOPLEFTHORIZONTAL },
277 { XML_TOPLEFTDIAGONAL, TransitionSubType::TOPLEFTDIAGONAL },
278 { XML_TOPRIGHTDIAGONAL, TransitionSubType::TOPRIGHTDIAGONAL },
279 { XML_BOTTOMRIGHTDIAGONAL, TransitionSubType::BOTTOMRIGHTDIAGONAL },
280 { XML_BOTTOMLEFTDIAGONAL, TransitionSubType::BOTTOMLEFTDIAGONAL },
281 { XML_TOPLEFTCLOCKWISE, TransitionSubType::TOPLEFTCLOCKWISE },
282 { XML_TOPRIGHTCLOCKWISE, TransitionSubType::TOPRIGHTCLOCKWISE },
283 { XML_BOTTOMRIGHTCLOCKWISE, TransitionSubType::BOTTOMRIGHTCLOCKWISE },
284 { XML_BOTTOMLEFTCLOCKWISE, TransitionSubType::BOTTOMLEFTCLOCKWISE },
285 { XML_TOPLEFTCOUNTERCLOCKWISE,TransitionSubType::TOPLEFTCOUNTERCLOCKWISE },
286 { XML_TOPRIGHTCOUNTERCLOCKWISE,TransitionSubType::TOPRIGHTCOUNTERCLOCKWISE },
287 { XML_BOTTOMRIGHTCOUNTERCLOCKWISE,TransitionSubType::BOTTOMRIGHTCOUNTERCLOCKWISE },
288 { XML_BOTTOMLEFTCOUNTERCLOCKWISE,TransitionSubType::BOTTOMLEFTCOUNTERCLOCKWISE },
289 { XML_VERTICALTOPSAME, TransitionSubType::VERTICALTOPSAME },
290 { XML_VERTICALBOTTOMSAME, TransitionSubType::VERTICALBOTTOMSAME },
291 { XML_VERTICALTOPLEFTOPPOSITE,TransitionSubType::VERTICALTOPLEFTOPPOSITE },
292 { XML_VERTICALBOTTOMLEFTOPPOSITE,TransitionSubType::VERTICALBOTTOMLEFTOPPOSITE },
293 { XML_HORIZONTALLEFTSAME, TransitionSubType::HORIZONTALLEFTSAME },
294 { XML_HORIZONTALRIGHTSAME, TransitionSubType::HORIZONTALRIGHTSAME },
295 { XML_HORIZONTALTOPLEFTOPPOSITE,TransitionSubType::HORIZONTALTOPLEFTOPPOSITE },
296 { XML_HORIZONTALTOPRIGHTOPPOSITE,TransitionSubType::HORIZONTALTOPRIGHTOPPOSITE },
297 { XML_DIAGONALBOTTOMLEFTOPPOSITE,TransitionSubType::DIAGONALBOTTOMLEFTOPPOSITE },
298 { XML_DIAGONALTOPLEFTOPPOSITE,TransitionSubType::DIAGONALTOPLEFTOPPOSITE },
299 { XML_TWOBOXTOP, TransitionSubType::TWOBOXTOP },
300 { XML_TWOBOXBOTTOM, TransitionSubType::TWOBOXBOTTOM },
301 { XML_TWOBOXLEFT, TransitionSubType::TWOBOXLEFT },
302 { XML_TWOBOXRIGHT, TransitionSubType::TWOBOXRIGHT },
303 { XML_FOURBOXVERTICAL, TransitionSubType::FOURBOXVERTICAL },
304 { XML_FOURBOXHORIZONTAL, TransitionSubType::FOURBOXHORIZONTAL },
305 { XML_VERTICALLEFT, TransitionSubType::VERTICALLEFT },
306 { XML_VERTICALRIGHT, TransitionSubType::VERTICALRIGHT },
307 { XML_HORIZONTALLEFT, TransitionSubType::HORIZONTALLEFT },
308 { XML_HORIZONTALRIGHT, TransitionSubType::HORIZONTALRIGHT },
309 { XML_FROMLEFT, TransitionSubType::FROMLEFT },
310 { XML_FROMTOP, TransitionSubType::FROMTOP },
311 { XML_FROMRIGHT, TransitionSubType::FROMRIGHT },
312 { XML_FROMBOTTOM, TransitionSubType::FROMBOTTOM },
313 { XML_CROSSFADE, TransitionSubType::CROSSFADE },
314 { XML_FADETOCOLOR, TransitionSubType::FADETOCOLOR },
315 { XML_FADEFROMCOLOR, TransitionSubType::FADEFROMCOLOR },
316 { XML_FADEOVERCOLOR, TransitionSubType::FADEOVERCOLOR },
317 { XML_THREEBLADE, TransitionSubType::THREEBLADE },
318 { XML_EIGHTBLADE, TransitionSubType::EIGHTBLADE },
319 { XML_ONEBLADE, TransitionSubType::ONEBLADE },
320 { XML_ACROSS, TransitionSubType::ACROSS },
321 { XML_TOPLEFTVERTICAL, TransitionSubType::TOPLEFTVERTICAL },
322 { XML_COMBHORIZONTAL, TransitionSubType::COMBHORIZONTAL },
323 { XML_COMBVERTICAL, TransitionSubType::COMBVERTICAL },
324 { XML_IN, TransitionSubType::IN },
325 { XML_OUT, TransitionSubType::OUT },
326 { XML_ROTATEIN, TransitionSubType::ROTATEIN },
327 { XML_ROTATEOUT, TransitionSubType::ROTATEOUT },
328 { XML_FROMTOPLEFT, TransitionSubType::FROMTOPLEFT },
329 { XML_FROMTOPRIGHT, TransitionSubType::FROMTOPRIGHT },
330 { XML_FROMBOTTOMLEFT, TransitionSubType::FROMBOTTOMLEFT },
331 { XML_FROMBOTTOMRIGHT, TransitionSubType::FROMBOTTOMRIGHT },
332
333 { XML_TOKEN_INVALID, 0 }
334};
335const SvXMLEnumMapEntry<sal_Int16> aAnimations_EnumMap_EventTrigger[] =
336{
337 { XML_ONBEGIN, EventTrigger::ON_BEGIN },
338 { XML_ONEND, EventTrigger::ON_END },
339 { XML_BEGIN, EventTrigger::BEGIN_EVENT },
340 { XML_END, EventTrigger::END_EVENT },
341 { XML_CLICK, EventTrigger::ON_CLICK },
342 { XML_DOUBLECLICK, EventTrigger::ON_DBL_CLICK },
343 { XML_MOUSEOVER, EventTrigger::ON_MOUSE_ENTER },
344 { XML_MOUSEOUT, EventTrigger::ON_MOUSE_LEAVE },
345 { XML_NEXT, EventTrigger::ON_NEXT },
346 { XML_PREVIOUS, EventTrigger::ON_PREV },
347 { XML_STOP_AUDIO, EventTrigger::ON_STOP_AUDIO },
348 { XML_REPEAT, EventTrigger::REPEAT },
349 { XML_TOKEN_INVALID, 0 }
350};
351const SvXMLEnumMapEntry<sal_Int16> aAnimations_EnumMap_EffectPresetClass[] =
352{
353 { XML_CUSTOM, EffectPresetClass::CUSTOM },
354 { XML_ENTRANCE, EffectPresetClass::ENTRANCE },
355 { XML_EXIT, EffectPresetClass::EXIT },
356 { XML_EMPHASIS, EffectPresetClass::EMPHASIS },
357 { XML_MOTION_PATH, EffectPresetClass::MOTIONPATH },
358 { XML_OLE_ACTION, EffectPresetClass::OLEACTION },
359 { XML_MEDIA_CALL, EffectPresetClass::MEDIACALL },
360 { XML_TOKEN_INVALID, 0 }
361};
362const SvXMLEnumMapEntry<sal_Int16> aAnimations_EnumMap_EffectNodeType[] =
363{
364 { XML_DEFAULT, EffectNodeType::DEFAULT },
365 { XML_ON_CLICK, EffectNodeType::ON_CLICK },
366 { XML_WITH_PREVIOUS, EffectNodeType::WITH_PREVIOUS },
367 { XML_AFTER_PREVIOUS, EffectNodeType::AFTER_PREVIOUS },
368 { XML_MAIN_SEQUENCE, EffectNodeType::MAIN_SEQUENCE },
369 { XML_TIMING_ROOT, EffectNodeType::TIMING_ROOT },
370 { XML_INTERACTIVE_SEQUENCE, EffectNodeType::INTERACTIVE_SEQUENCE },
371 { XML_TOKEN_INVALID, 0 }
372};
373const SvXMLEnumMapEntry<sal_Int16> aAnimations_EnumMap_SubItem[] =
374{
375 { XML_WHOLE, ShapeAnimationSubType::AS_WHOLE },
376 { XML_BACKGROUND, ShapeAnimationSubType::ONLY_BACKGROUND },
377 { XML_TEXT, ShapeAnimationSubType::ONLY_TEXT },
378 { XML_TOKEN_INVALID, 0 }
379};
380const SvXMLEnumMapEntry<sal_Int16> aAnimations_EnumMap_IterateType[] =
381{
382 { XML_BY_PARAGRAPH, TextAnimationType::BY_PARAGRAPH },
383 { XML_BY_WORD, TextAnimationType::BY_WORD },
384 { XML_BY_LETTER, TextAnimationType::BY_LETTER },
385 { XML_TOKEN_INVALID, 0 }
386};
387const SvXMLEnumMapEntry<sal_Int16> aAnimations_EnumMap_Command[] =
388{
389 { XML_CUSTOM, EffectCommands::CUSTOM },
390 { XML_VERB, EffectCommands::VERB },
391 { XML_PLAY, EffectCommands::PLAY },
392 { XML_TOGGLE_PAUSE, EffectCommands::TOGGLEPAUSE },
393 { XML_STOP, EffectCommands::STOP },
394 { XML_STOP_AUDIO, EffectCommands::STOPAUDIO },
395 { XML_TOKEN_INVALID, 0 }
396};
397
398const struct ImplAttributeNameConversion* getAnimationAttributeNamesConversionList()
399{
400 static const struct ImplAttributeNameConversion gImplConversionList[] =
401 {
402 { XML_X, "X" },
403 { XML_Y, "Y" },
404 { XML_WIDTH, "Width" },
405 { XML_HEIGHT, "Height" },
406 { XML_ROTATE, "Rotate" },
407 { XML_SKEWX, "SkewX" },
408 { XML_FILL_COLOR, "FillColor" },
409 { XML_FILL, "FillStyle" },
410 { XML_STROKE_COLOR, "LineColor" },
411 { XML_STROKE, "LineStyle" },
412 { XML_COLOR, "CharColor" },
413 { XML_TEXT_ROTATION_ANGLE, "CharRotation" },
414 { XML_FONT_WEIGHT, "CharWeight" },
415 { XML_TEXT_UNDERLINE, "CharUnderline" },
416 { XML_FONT_FAMILY, "CharFontName" },
417 { XML_FONT_SIZE, "CharHeight" },
418 { XML_FONT_STYLE, "CharPosture" },
419 { XML_VISIBILITY, "Visibility" },
420 { XML_OPACITY, "Opacity" },
421 { XML_DIM, "DimColor" },
422 { XML_TOKEN_INVALID, nullptr }
423 };
424
425 return gImplConversionList;
426}
427
428
429class AnimationsExporterImpl
430{
431public:
432 AnimationsExporterImpl( SvXMLExport& rExport, const Reference< XPropertySet >& xPageProps );
433
434 void prepareNode( const Reference< XAnimationNode >& xNode );
435 void exportNode( const Reference< XAnimationNode >& xNode );
436
437 void exportContainer( const Reference< XTimeContainer >& xNode, sal_Int16 nContainerNodeType );
438 void exportAnimate( const Reference< XAnimate >& xNode );
439 void exportAudio( const Reference< XAudio >& xAudio );
440 void exportCommand( const Reference< XCommand >& xCommand );
441
442 static Reference< XInterface > getParagraphTarget( const ParagraphTarget& pTarget );
443
444 static void convertPath( OUStringBuffer& sTmp, const Any& rPath );
445 void convertValue( XMLTokenEnum eAttributeName, OUStringBuffer& sTmp, const Any& rValue ) const;
446 void convertTiming( OUStringBuffer& sTmp, const Any& rTiming ) const;
447 void convertTarget( OUStringBuffer& sTmp, const Any& rTarget ) const;
448
449 void prepareValue( const Any& rValue );
450
451 void exportTransitionNode();
452 void prepareTransitionNode();
453
454 bool mbHasTransition;
455private:
456 rtl::Reference<SvXMLExport> mxExport;
457 Reference< XPropertySet > mxPageProps;
458 rtl::Reference<XMLSdPropHdlFactory> mxSdPropHdlFactory;
459};
460
461AnimationsExporterImpl::AnimationsExporterImpl( SvXMLExport& rExport, const Reference< XPropertySet >& xPageProps )
462: mbHasTransition(false)
463, mxExport( &rExport )
464, mxPageProps( xPageProps )
465, mxSdPropHdlFactory(new XMLSdPropHdlFactory( rExport.GetModel(), rExport ))
466{
467}
468
469
470/** split a uri hierarchy into first segment and rest */
471static bool splitPath(OUString const & i_rPath,
472 OUString & o_rDir, OUString& o_rRest)
473{
474 const sal_Int32 idx(i_rPath.indexOf(u'/'));
475 if (idx < 0 || idx >= i_rPath.getLength()) {
476 o_rDir = OUString();
477 o_rRest = i_rPath;
478 return true;
479 } else if (idx == 0 || idx == i_rPath.getLength() - 1) {
480 // input must not start or end with '/'
481 return false;
482 } else {
483 o_rDir = i_rPath.copy(0, idx);
484 o_rRest = i_rPath.copy(idx+1);
485 return true;
486 }
487}
488
489static void lcl_CopyStream(
490 uno::Reference<embed::XStorage> const& xSource,
491 uno::Reference<embed::XStorage> const& xTarget,
492 OUString const& rPath)
493{
494 OUString dir;
495 OUString rest;
496 if (!splitPath(rPath, dir, rest))
497 throw uno::RuntimeException();
498
499 if (dir.getLength() == 0)
500 xSource->copyElementTo(rPath, xTarget, rPath);
501 else
502 {
503 uno::Reference<embed::XStorage> const xSubSource(
504 xSource->openStorageElement(dir, embed::ElementModes::READ));
505 uno::Reference<embed::XStorage> const xSubTarget(
506 xTarget->openStorageElement(dir, embed::ElementModes::WRITE));
507 lcl_CopyStream(xSubSource, xSubTarget, rest);
508 }
509 uno::Reference<embed::XTransactedObject> const xTransaction(xTarget, uno::UNO_QUERY);
510 if (xTransaction.is())
511 xTransaction->commit();
512}
513
514char const s_PkgScheme[] = "vnd.sun.star.Package:";
515
516static OUString lcl_StoreMediaAndGetURL(SvXMLExport & rExport, OUString const& rURL)
517{
518 OUString urlPath;
519 if (rURL.startsWithIgnoreAsciiCase(s_PkgScheme, &urlPath))
520 {
521 try // video is embedded
522 {
523 // copy the media stream from document storage to target storage
524 // (not sure if this is the best way to store these?)
525 uno::Reference<document::XStorageBasedDocument> const xSBD(
526 rExport.GetModel(), uno::UNO_QUERY_THROW);
527 uno::Reference<embed::XStorage> const xSource(
528 xSBD->getDocumentStorage(), uno::UNO_SET_THROW);
529 uno::Reference<embed::XStorage> const xTarget(
530 rExport.GetTargetStorage(), uno::UNO_SET_THROW);
531
532 urlPath = rURL.copy(SAL_N_ELEMENTS(s_PkgScheme)(sizeof(sal_n_array_size(s_PkgScheme)))-1);
533
534 lcl_CopyStream(xSource, xTarget, urlPath);
535
536 return urlPath;
537 }
538 catch (uno::Exception const&)
539 {
540 TOOLS_INFO_EXCEPTION("xmloff", "exception while storing embedded media")do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "xmloff")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "exception while storing embedded media"
<< " " << exceptionToString(tools_warn_exception
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), (
"xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "540" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "exception while storing embedded media"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "exception while storing embedded media" << " "
<< exceptionToString(tools_warn_exception); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "540" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "exception while storing embedded media" <<
" " << exceptionToString(tools_warn_exception)) == 1) {
::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("xmloff"),
("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "540" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "exception while storing embedded media"
<< " " << exceptionToString(tools_warn_exception
)), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "exception while storing embedded media" << " "
<< exceptionToString(tools_warn_exception); ::sal::detail
::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("xmloff"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "540" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
541 }
542 return OUString();
543 }
544 else
545 {
546 return rExport.GetRelativeReference(rURL); // linked
547 }
548}
549
550void AnimationsExporterImpl::exportTransitionNode()
551{
552 if( !(mbHasTransition && mxPageProps.is()) )
553 return;
554
555 sal_Int16 nTransition = 0;
556 mxPageProps->getPropertyValue("TransitionType") >>= nTransition;
557
558 Any aSound( mxPageProps->getPropertyValue("Sound") );
559 OUString sSoundURL;
560 aSound >>= sSoundURL;
561 bool bStopSound = false;
562 if( !(aSound >>= bStopSound) )
563 bStopSound = false;
564
565
566 OUStringBuffer sTmp;
567 if( !((nTransition != 0) || !sSoundURL.isEmpty() || bStopSound) )
568 return;
569
570 Reference< XInterface > xSource( mxPageProps.get() );
571 Event aEvent;
572 aEvent.Source <<= xSource;
573 aEvent.Trigger = EventTrigger::BEGIN_EVENT;
574 aEvent.Repeat = 0;
575
576 convertTiming( sTmp, Any( aEvent ) );
577 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_BEGIN, sTmp.makeStringAndClear() );
578
579 SvXMLElementExport aElement( *mxExport, XML_NAMESPACE_ANIMATION, XML_PAR, true, true );
580
581 if( nTransition != 0 )
582 {
583 sal_Int16 nSubtype = 0;
584 bool bDirection = false;
585 sal_Int32 nFadeColor = 0;
586 double fDuration = 0.0;
587 mxPageProps->getPropertyValue("TransitionSubtype") >>= nSubtype;
588 mxPageProps->getPropertyValue("TransitionDirection") >>= bDirection;
589 mxPageProps->getPropertyValue("TransitionFadeColor") >>= nFadeColor;
590 mxPageProps->getPropertyValue("TransitionDuration") >>= fDuration;
591
592 ::sax::Converter::convertDouble( sTmp, fDuration );
593 sTmp.append( 's');
594 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_DUR, sTmp.makeStringAndClear() );
595
596 SvXMLUnitConverter::convertEnum( sTmp, nTransition, aAnimations_EnumMap_TransitionType );
597 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_TYPE, sTmp.makeStringAndClear() );
598
599 if( nSubtype != TransitionSubType::DEFAULT )
600 {
601 SvXMLUnitConverter::convertEnum( sTmp, nSubtype, aAnimations_EnumMap_TransitionSubType );
602 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_SUBTYPE, sTmp.makeStringAndClear() );
603 }
604
605 if( !bDirection )
606 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_DIRECTION, XML_REVERSE );
607
608 if( (nTransition == TransitionType::FADE) && ((nSubtype == TransitionSubType::FADETOCOLOR) || (nSubtype == TransitionSubType::FADEFROMCOLOR) ))
609 {
610 ::sax::Converter::convertColor( sTmp, nFadeColor );
611 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_FADECOLOR, sTmp.makeStringAndClear() );
612 }
613 SvXMLElementExport aElement2( *mxExport, XML_NAMESPACE_ANIMATION, XML_TRANSITIONFILTER, true, true );
614 }
615
616 if( bStopSound )
617 {
618 mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_COMMAND, XML_STOP_AUDIO );
619 SvXMLElementExport aElement2( *mxExport, XML_NAMESPACE_ANIMATION, XML_COMMAND, true, true );
620 }
621 else if( !sSoundURL.isEmpty())
622 {
623 sSoundURL = lcl_StoreMediaAndGetURL(*mxExport, sSoundURL);
624 mxExport->AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sSoundURL );
625
626 bool bLoopSound = false;
627 mxPageProps->getPropertyValue("LoopSound") >>= bLoopSound;
628
629 if( bLoopSound )
630 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATCOUNT, XML_INDEFINITE );
631 SvXMLElementExport aElement2( *mxExport, XML_NAMESPACE_ANIMATION, XML_AUDIO, true, true );
632 }
633}
634
635void AnimationsExporterImpl::prepareTransitionNode()
636{
637 if( !mxPageProps.is() )
638 return;
639
640 try
641 {
642 sal_Int16 nTransition = 0;
643 mxPageProps->getPropertyValue("TransitionType") >>= nTransition;
644
645 bool bStopSound = false;
646 OUString sSoundURL;
647
648 if( nTransition == 0 )
649 {
650 Any aSound( mxPageProps->getPropertyValue("Sound") );
651 aSound >>= sSoundURL;
652
653 if( !(aSound >>= bStopSound) )
654 bStopSound = false;
655 }
656
657 if( (nTransition != 0) || !sSoundURL.isEmpty() || bStopSound )
658 {
659 mbHasTransition = true;
660 Reference< XInterface > xInt( mxPageProps.get() );
661 mxExport->getInterfaceToIdentifierMapper().registerReference( xInt );
662 }
663 }
664 catch (const Exception&)
665 {
666 TOOLS_WARN_EXCEPTION("xmloff.draw", "")do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff.draw")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break;
case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "666" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "666" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "" << " " << exceptionToString(tools_warn_exception
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "666" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "666" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
667 }
668}
669
670void AnimationsExporterImpl::prepareNode( const Reference< XAnimationNode >& xNode )
671{
672 try
673 {
674 prepareValue( xNode->getBegin() );
675 prepareValue( xNode->getEnd() );
676
677 sal_Int16 nNodeType = xNode->getType();
678 switch( nNodeType )
679 {
680 case AnimationNodeType::ITERATE:
681 {
682 Reference< XIterateContainer > xIter( xNode, UNO_QUERY_THROW );
683 prepareValue( xIter->getTarget() );
684 [[fallthrough]];
685 }
686 case AnimationNodeType::PAR:
687 case AnimationNodeType::SEQ:
688 {
689 Reference< XEnumerationAccess > xEnumerationAccess( xNode, UNO_QUERY_THROW );
690 Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), css::uno::UNO_SET_THROW );
691 while( xEnumeration->hasMoreElements() )
692 {
693 Reference< XAnimationNode > xChildNode( xEnumeration->nextElement(), UNO_QUERY_THROW );
694 prepareNode( xChildNode );
695 }
696 }
697 break;
698
699 case AnimationNodeType::ANIMATE:
700 case AnimationNodeType::SET:
701 case AnimationNodeType::ANIMATEMOTION:
702 case AnimationNodeType::ANIMATEPHYSICS:
703 case AnimationNodeType::ANIMATECOLOR:
704 case AnimationNodeType::ANIMATETRANSFORM:
705 case AnimationNodeType::TRANSITIONFILTER:
706 {
707 Reference< XAnimate > xAnimate( xNode, UNO_QUERY_THROW );
708 prepareValue( xAnimate->getTarget() );
709 }
710 break;
711
712 case AnimationNodeType::COMMAND:
713 {
714 Reference< XCommand > xCommand( xNode, UNO_QUERY_THROW );
715 prepareValue( xCommand->getTarget() );
716 }
717 break;
718
719 case AnimationNodeType::AUDIO:
720 {
721 Reference< XAudio > xAudio( xNode, UNO_QUERY_THROW );
722 prepareValue( xAudio->getSource() );
723 }
724 break;
725 }
726
727 const Sequence< NamedValue > aUserData( xNode->getUserData() );
728 for( const auto& rValue : aUserData )
729 {
730 if( IsXMLToken( rValue.Name, XML_MASTER_ELEMENT ) )
731 {
732 Reference< XInterface > xMaster;
733 rValue.Value >>= xMaster;
734 if( xMaster.is() )
735 mxExport->getInterfaceToIdentifierMapper().registerReference( xMaster );
736 }
737 }
738 }
739 catch (const Exception&)
740 {
741 TOOLS_WARN_EXCEPTION("xmloff.draw", "")do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff.draw")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break;
case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "741" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "741" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "" << " " << exceptionToString(tools_warn_exception
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "741" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "741" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
742 }
743}
744
745void AnimationsExporterImpl::exportNode( const Reference< XAnimationNode >& xNode )
746{
747 try
748 {
749 OUStringBuffer sTmp;
750
751 const OUString& rExportIdentifier = mxExport->getInterfaceToIdentifierMapper().getIdentifier( xNode );
752 if( !rExportIdentifier.isEmpty() )
1
Taking false branch
753 {
754 mxExport->AddAttributeIdLegacy(
755 XML_NAMESPACE_ANIMATION, rExportIdentifier);
756 }
757
758 Any aTemp( xNode->getBegin() );
2
Value assigned to 'aTemp.pData'
759 if( aTemp.hasValue() )
3
Taking true branch
760 {
761 convertTiming( sTmp, aTemp );
4
Calling 'AnimationsExporterImpl::convertTiming'
762 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_BEGIN, sTmp.makeStringAndClear() );
763 }
764
765 double fTemp = 0;
766 sal_Int16 nTemp;
767
768 aTemp = xNode->getDuration();
769 if( aTemp.hasValue() )
770 {
771 if( aTemp >>= fTemp )
772 {
773 ::sax::Converter::convertDouble( sTmp, fTemp );
774 sTmp.append( 's');
775 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_DUR, sTmp.makeStringAndClear() );
776 }
777 else
778 {
779 Timing eTiming;
780 if( aTemp >>= eTiming )
781 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_DUR, eTiming == Timing_INDEFINITE ? XML_INDEFINITE : XML_MEDIA );
782 }
783 }
784
785 aTemp = xNode->getEnd();
786 if( aTemp.hasValue() )
787 {
788 convertTiming( sTmp, aTemp );
789 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_END, sTmp.makeStringAndClear() );
790 }
791
792 nTemp = xNode->getFill();
793 if( nTemp != AnimationFill::DEFAULT )
794 {
795 SvXMLUnitConverter::convertEnum( sTmp, nTemp, aAnimations_EnumMap_Fill );
796 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_FILL, sTmp.makeStringAndClear() );
797 }
798
799 nTemp = xNode->getFillDefault();
800 if( nTemp != AnimationFill::INHERIT )
801 {
802 SvXMLUnitConverter::convertEnum( sTmp, nTemp, aAnimations_EnumMap_FillDefault );
803 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_FILLDEFAULT, sTmp.makeStringAndClear() );
804 }
805
806 nTemp = xNode->getRestart();
807 if( nTemp != AnimationRestart::DEFAULT )
808 {
809 SvXMLUnitConverter::convertEnum( sTmp, nTemp, aAnimations_EnumMap_Restart );
810 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_RESTART, sTmp.makeStringAndClear() );
811 }
812
813 nTemp = xNode->getRestartDefault();
814 if( nTemp != AnimationRestart::INHERIT )
815 {
816 SvXMLUnitConverter::convertEnum( sTmp, nTemp, aAnimations_EnumMap_RestartDefault );
817 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_RESTARTDEFAULT, sTmp.makeStringAndClear() );
818 }
819
820 fTemp = xNode->getAcceleration();
821 if( fTemp != 0.0 )
822 {
823 ::sax::Converter::convertDouble( sTmp, fTemp );
824 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_ACCELERATE, sTmp.makeStringAndClear() );
825 }
826
827 fTemp = xNode->getDecelerate();
828 if( fTemp != 0.0 )
829 {
830 ::sax::Converter::convertDouble( sTmp, fTemp );
831 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_DECELERATE, sTmp.makeStringAndClear() );
832 }
833
834 bool bTemp = xNode->getAutoReverse();
835 if( bTemp )
836 {
837 ::sax::Converter::convertBool( sTmp, bTemp );
838 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_AUTOREVERSE, sTmp.makeStringAndClear() );
839 }
840
841 aTemp = xNode->getRepeatCount();
842 if( aTemp.hasValue() )
843 {
844 Timing eTiming;
845 if( (aTemp >>= eTiming ) && (eTiming == Timing_INDEFINITE ) )
846 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATCOUNT, XML_INDEFINITE );
847 else if( aTemp >>= fTemp )
848 {
849 ::sax::Converter::convertDouble( sTmp, fTemp );
850 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATCOUNT, sTmp.makeStringAndClear() );
851 }
852 }
853
854 aTemp = xNode->getRepeatDuration();
855 if( aTemp.hasValue() )
856 {
857 Timing eTiming;
858 if( ( aTemp >>= eTiming ) && (eTiming == Timing_INDEFINITE) )
859 {
860 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATDUR, XML_INDEFINITE );
861 }
862 else if( aTemp >>= fTemp )
863 {
864 ::sax::Converter::convertDouble( sTmp, fTemp );
865 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATDUR, sTmp.makeStringAndClear() );
866 }
867 }
868
869 aTemp = xNode->getEndSync();
870 if( aTemp.hasValue() && (aTemp >>= nTemp) )
871 {
872 SvXMLUnitConverter::convertEnum( sTmp, nTemp, aAnimations_EnumMap_Endsync );
873 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_ENDSYNC, sTmp.makeStringAndClear() );
874 }
875
876 sal_Int16 nContainerNodeType = EffectNodeType::DEFAULT;
877 OUString aPresetId;
878 const Sequence< NamedValue > aUserData( xNode->getUserData() );
879 for( const auto& rValue : aUserData )
880 {
881 if( IsXMLToken( rValue.Name, XML_NODE_TYPE ) )
882 {
883 if( (rValue.Value >>= nContainerNodeType) && (nContainerNodeType != EffectNodeType::DEFAULT) )
884 {
885 SvXMLUnitConverter::convertEnum( sTmp, nContainerNodeType, aAnimations_EnumMap_EffectNodeType );
886 mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_NODE_TYPE, sTmp.makeStringAndClear() );
887 }
888 }
889 else if( IsXMLToken( rValue.Name, XML_PRESET_ID ) )
890 {
891 if( rValue.Value >>= aPresetId )
892 {
893 mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_ID, aPresetId );
894 }
895 }
896 else if( IsXMLToken( rValue.Name, XML_PRESET_SUB_TYPE ) )
897 {
898 OUString aPresetSubType;
899 if( rValue.Value >>= aPresetSubType )
900 {
901 mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_SUB_TYPE, aPresetSubType );
902 }
903 }
904 else if( IsXMLToken( rValue.Name, XML_PRESET_CLASS ) )
905 {
906 sal_Int16 nEffectPresetClass = sal_uInt16();
907 if( rValue.Value >>= nEffectPresetClass )
908 {
909 SvXMLUnitConverter::convertEnum( sTmp, nEffectPresetClass, aAnimations_EnumMap_EffectPresetClass );
910 mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_CLASS, sTmp.makeStringAndClear() );
911 }
912 }
913 else if( IsXMLToken( rValue.Name, XML_MASTER_ELEMENT ) )
914 {
915 Reference< XInterface > xMaster;
916 rValue.Value >>= xMaster;
917 if( xMaster.is() )
918 {
919 const OUString& rIdentifier = mxExport->getInterfaceToIdentifierMapper().getIdentifier(xMaster);
920 if( !rIdentifier.isEmpty() )
921 mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_MASTER_ELEMENT, rIdentifier );
922 }
923 }
924 else if( IsXMLToken( rValue.Name, XML_GROUP_ID ) )
925 {
926 sal_Int32 nGroupId = 0;
927 if( rValue.Value >>= nGroupId )
928 mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_GROUP_ID, OUString::number( nGroupId ) );
929 }
930 else
931 {
932 OUString aTmp;
933 if( rValue.Value >>= aTmp )
934 mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, rValue.Name, aTmp );
935 }
936 }
937
938 nTemp = xNode->getType();
939 switch( nTemp )
940 {
941 case AnimationNodeType::PAR:
942 case AnimationNodeType::SEQ:
943 case AnimationNodeType::ITERATE:
944 {
945 Reference< XTimeContainer > xContainer( xNode, UNO_QUERY_THROW );
946 exportContainer( xContainer, nContainerNodeType );
947 }
948 break;
949
950 case AnimationNodeType::ANIMATE:
951 case AnimationNodeType::SET:
952 case AnimationNodeType::ANIMATEMOTION:
953 case AnimationNodeType::ANIMATEPHYSICS:
954 case AnimationNodeType::ANIMATECOLOR:
955 case AnimationNodeType::ANIMATETRANSFORM:
956 case AnimationNodeType::TRANSITIONFILTER:
957 {
958 Reference< XAnimate > xAnimate( xNode, UNO_QUERY_THROW );
959 exportAnimate( xAnimate );
960 }
961 break;
962 case AnimationNodeType::AUDIO:
963 {
964 Reference< XAudio > xAudio( xNode, UNO_QUERY_THROW );
965 exportAudio( xAudio );
966 }
967 break;
968 case AnimationNodeType::COMMAND:
969 {
970 Reference< XCommand > xCommand( xNode, UNO_QUERY_THROW );
971 exportCommand( xCommand );
972 }
973 break;
974 default:
975 OSL_FAIL( "xmloff::AnimationsExporterImpl::exportNode(), invalid AnimationNodeType!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "975" ": "), "%s", "xmloff::AnimationsExporterImpl::exportNode(), invalid AnimationNodeType!"
); } } while (false)
;
976 }
977 }
978 catch (const RuntimeException&)
979 {
980 TOOLS_WARN_EXCEPTION("xmloff.draw", "")do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff.draw")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break;
case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "980" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "980" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "" << " " << exceptionToString(tools_warn_exception
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "980" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "980" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
981 }
982
983 // if something goes wrong, its always a good idea to clear the attribute list
984 mxExport->ClearAttrList();
985}
986
987void AnimationsExporterImpl::exportContainer( const Reference< XTimeContainer >& xContainer, sal_Int16 nContainerNodeType )
988{
989 try
990 {
991 const sal_Int32 nNodeType = xContainer->getType();
992
993 if( nNodeType == AnimationNodeType::ITERATE )
994 {
995 OUStringBuffer sTmp;
996 Reference< XIterateContainer > xIter( xContainer, UNO_QUERY_THROW );
997
998 Any aTemp( xIter->getTarget() );
999 if( aTemp.hasValue() )
1000 {
1001 convertTarget( sTmp, aTemp );
1002 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_TARGETELEMENT, sTmp.makeStringAndClear() );
1003 }
1004
1005 sal_Int16 nTemp = xIter->getSubItem();
1006 if( nTemp )
1007 {
1008 SvXMLUnitConverter::convertEnum( sTmp, nTemp, aAnimations_EnumMap_SubItem );
1009 mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_SUB_ITEM, sTmp.makeStringAndClear() );
1010 }
1011
1012 nTemp = xIter->getIterateType();
1013 if( nTemp )
1014 {
1015 SvXMLUnitConverter::convertEnum( sTmp, nTemp, aAnimations_EnumMap_IterateType );
1016 mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_ITERATE_TYPE, sTmp.makeStringAndClear() );
1017 }
1018
1019 double fTemp = xIter->getIterateInterval();
1020 if( fTemp )
1021 {
1022 OUStringBuffer buf;
1023 ::sax::Converter::convertDuration(buf, fTemp / (24*60*60));
1024 mxExport->AddAttribute( XML_NAMESPACE_ANIMATION,
1025 XML_ITERATE_INTERVAL, buf.makeStringAndClear());
1026 }
1027 }
1028
1029 XMLTokenEnum eElementToken;
1030 switch( nNodeType )
1031 {
1032 case AnimationNodeType::PAR: eElementToken = XML_PAR; break;
1033 case AnimationNodeType::SEQ: eElementToken = XML_SEQ; break;
1034 case AnimationNodeType::ITERATE:eElementToken = XML_ITERATE; break;
1035 default:
1036 OSL_FAIL( "xmloff::AnimationsExporterImpl::exportContainer(), invalid TimeContainerType!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1036" ": "), "%s", "xmloff::AnimationsExporterImpl::exportContainer(), invalid TimeContainerType!"
); } } while (false)
;
1037 return;
1038 }
1039 SvXMLElementExport aElement( *mxExport, XML_NAMESPACE_ANIMATION, eElementToken, true, true );
1040
1041 if( nContainerNodeType == EffectNodeType::TIMING_ROOT )
1042 exportTransitionNode();
1043
1044 Reference< XEnumerationAccess > xEnumerationAccess( xContainer, UNO_QUERY_THROW );
1045 Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), css::uno::UNO_SET_THROW );
1046 while( xEnumeration->hasMoreElements() )
1047 {
1048 Reference< XAnimationNode > xChildNode( xEnumeration->nextElement(), UNO_QUERY_THROW );
1049 exportNode( xChildNode );
1050 }
1051 }
1052 catch (const RuntimeException&)
1053 {
1054 TOOLS_WARN_EXCEPTION("xmloff.draw", "")do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff.draw")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break;
case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1054" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1054" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "" << " " << exceptionToString(tools_warn_exception
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1054" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1054" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1055 }
1056}
1057
1058void AnimationsExporterImpl::exportAnimate( const Reference< XAnimate >& xAnimate )
1059{
1060 try
1061 {
1062 const sal_Int16 nNodeType = xAnimate->getType();
1063
1064 OUStringBuffer sTmp;
1065 sal_Int16 nTemp;
1066 bool bTemp;
1067
1068 Any aTemp( xAnimate->getTarget() );
1069 if( aTemp.hasValue() )
1070 {
1071 convertTarget( sTmp, aTemp );
1072 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_TARGETELEMENT, sTmp.makeStringAndClear() );
1073 }
1074
1075 nTemp = xAnimate->getSubItem();
1076 if( nTemp )
1077 {
1078 SvXMLUnitConverter::convertEnum( sTmp, nTemp, aAnimations_EnumMap_SubItem );
1079 mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_SUB_ITEM, sTmp.makeStringAndClear() );
1080 }
1081
1082 XMLTokenEnum eAttributeName = XML_TOKEN_INVALID;
1083
1084 if( nNodeType == AnimationNodeType::TRANSITIONFILTER )
1085 {
1086 eAttributeName = XML_TRANSITIONFILTER;
1087 }
1088 else if( nNodeType == AnimationNodeType::ANIMATETRANSFORM )
1089 {
1090 eAttributeName = XML_ANIMATETRANSFORM;
1091 }
1092 else if( nNodeType == AnimationNodeType::ANIMATEMOTION )
1093 {
1094 eAttributeName = XML_ANIMATEMOTION;
1095 }
1096 else if( nNodeType == AnimationNodeType::ANIMATEPHYSICS )
1097 {
1098 eAttributeName = XML_ANIMATEPHYSICS;
1099 }
1100 else
1101 {
1102 OUString sTemp( xAnimate->getAttributeName() );
1103 if( !sTemp.isEmpty() )
1104 {
1105 const struct ImplAttributeNameConversion* p = getAnimationAttributeNamesConversionList();
1106 while( p->mpAPIName )
1107 {
1108 if( sTemp.equalsAscii( p->mpAPIName ) )
1109 {
1110 sTemp = GetXMLToken( p->meXMLToken );
1111 eAttributeName = p->meXMLToken;
1112 break;
1113 }
1114
1115 p++;
1116 }
1117
1118 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_ATTRIBUTENAME, sTemp );
1119 }
1120 else
1121 {
1122 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_ATTRIBUTENAME, "invalid" );
1123 }
1124 }
1125
1126 Sequence< Any > aValues( xAnimate->getValues() );
1127 if( aValues.hasElements() )
1128 {
1129 aTemp <<= aValues;
1130 convertValue( eAttributeName, sTmp, aTemp );
1131 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_VALUES, sTmp.makeStringAndClear() );
1132 }
1133 else
1134 {
1135 aTemp = xAnimate->getFrom();
1136 if( aTemp.hasValue() )
1137 {
1138 convertValue( eAttributeName, sTmp, aTemp );
1139 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_FROM, sTmp.makeStringAndClear() );
1140 }
1141
1142 aTemp = xAnimate->getBy();
1143 if( aTemp.hasValue() )
1144 {
1145 convertValue( eAttributeName, sTmp, aTemp );
1146 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_BY, sTmp.makeStringAndClear() );
1147 }
1148
1149 aTemp = xAnimate->getTo();
1150 if( aTemp.hasValue() )
1151 {
1152 convertValue( eAttributeName, sTmp, aTemp );
1153 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_TO, sTmp.makeStringAndClear() );
1154 }
1155 }
1156
1157 if(nNodeType != AnimationNodeType::SET)
1158 {
1159 const Sequence< double > aKeyTimes( xAnimate->getKeyTimes() );
1160 if( aKeyTimes.hasElements() )
1161 {
1162 for( const auto& rKeyTime : aKeyTimes )
1163 {
1164 if( !sTmp.isEmpty() )
1165 sTmp.append( ';' );
1166
1167 sTmp.append( rKeyTime );
1168 }
1169 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_KEYTIMES, sTmp.makeStringAndClear() );
1170 }
1171
1172 OUString sTemp( xAnimate->getFormula() );
1173 if( !sTemp.isEmpty() )
1174 mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_FORMULA, sTemp );
1175
1176 if( (nNodeType != AnimationNodeType::TRANSITIONFILTER) &&
1177 (nNodeType != AnimationNodeType::AUDIO ) )
1178 {
1179 // calcMode = "discrete | linear | paced | spline"
1180 nTemp = xAnimate->getCalcMode();
1181 if( ((nNodeType == AnimationNodeType::ANIMATEMOTION ) && (nTemp != AnimationCalcMode::PACED)) ||
1182 ((nNodeType != AnimationNodeType::ANIMATEMOTION ) && (nTemp != AnimationCalcMode::LINEAR)) )
1183 {
1184 SvXMLUnitConverter::convertEnum( sTmp, nTemp, aAnimations_EnumMap_CalcMode );
1185 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_CALCMODE, sTmp.makeStringAndClear() );
1186 }
1187
1188 bTemp = xAnimate->getAccumulate();
1189 if( bTemp )
1190 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_ACCUMULATE, XML_SUM );
1191
1192 nTemp = xAnimate->getAdditive();
1193 if( nTemp != AnimationAdditiveMode::REPLACE )
1194 {
1195 SvXMLUnitConverter::convertEnum( sTmp, nTemp, aAnimations_EnumMap_AdditiveMode );
1196 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_ADDITIVE, sTmp.makeStringAndClear() );
1197 }
1198 }
1199
1200 const Sequence< TimeFilterPair > aTimeFilter( xAnimate->getTimeFilter() );
1201 if( aTimeFilter.hasElements() )
1202 {
1203 for( const auto& rPair : aTimeFilter )
1204 {
1205 if( !sTmp.isEmpty() )
1206 sTmp.append( ';' );
1207
1208 sTmp.append( OUString::number(rPair.Time) ).append( "," ).append( OUString::number(rPair.Progress) );
1209 }
1210
1211 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_KEYSPLINES, sTmp.makeStringAndClear() );
1212 }
1213 }
1214
1215 XMLTokenEnum eElementToken = XML_ANIMATE;
1216
1217 switch( nNodeType )
1218 {
1219 case AnimationNodeType::ANIMATE:
1220 eElementToken = XML_ANIMATE;
1221 break;
1222
1223 case AnimationNodeType::SET:
1224 eElementToken = XML_SET;
1225 break;
1226
1227 case AnimationNodeType::ANIMATEMOTION:
1228 {
1229 eElementToken = XML_ANIMATEMOTION;
1230
1231 Reference< XAnimateMotion > xAnimateMotion( xAnimate, UNO_QUERY_THROW );
1232
1233 aTemp = xAnimateMotion->getPath();
1234 if( aTemp.hasValue() )
1235 {
1236 convertPath( sTmp, aTemp );
1237 mxExport->AddAttribute( XML_NAMESPACE_SVG, XML_PATH, sTmp.makeStringAndClear() );
1238 }
1239
1240 // TODO: origin = ( parent | layout )
1241 aTemp = xAnimateMotion->getOrigin();
1242 }
1243 break;
1244
1245 case AnimationNodeType::ANIMATEPHYSICS:
1246 {
1247 eElementToken = XML_ANIMATEPHYSICS;
1248 double fTemp = 0;
1249
1250 Reference< XAnimatePhysics > xAnimatePhysics( xAnimate, UNO_QUERY_THROW );
1251 aTemp = xAnimatePhysics->getStartVelocityX();
1252 if( aTemp.hasValue() )
1253 {
1254 aTemp >>= fTemp;
1255 ::sax::Converter::convertDouble( sTmp, fTemp );
1256 mxExport->AddAttribute( XML_NAMESPACE_LO_EXT, XML_PHYSICS_ANIMATION_START_VELOCITY_X, sTmp.makeStringAndClear() );
1257 }
1258
1259 aTemp = xAnimatePhysics->getStartVelocityY();
1260 if( aTemp.hasValue() )
1261 {
1262 aTemp >>= fTemp;
1263 ::sax::Converter::convertDouble( sTmp, fTemp );
1264 mxExport->AddAttribute( XML_NAMESPACE_LO_EXT, XML_PHYSICS_ANIMATION_START_VELOCITY_Y, sTmp.makeStringAndClear() );
1265 }
1266
1267 aTemp = xAnimatePhysics->getDensity();
1268 if( aTemp.hasValue() )
1269 {
1270 aTemp >>= fTemp;
1271 ::sax::Converter::convertDouble( sTmp, fTemp );
1272 mxExport->AddAttribute( XML_NAMESPACE_LO_EXT, XML_PHYSICS_ANIMATION_DENSITY, sTmp.makeStringAndClear() );
1273 }
1274
1275 aTemp = xAnimatePhysics->getBounciness();
1276 if( aTemp.hasValue() )
1277 {
1278 aTemp >>= fTemp;
1279 ::sax::Converter::convertDouble( sTmp, fTemp );
1280 mxExport->AddAttribute( XML_NAMESPACE_LO_EXT, XML_PHYSICS_ANIMATION_BOUNCINESS, sTmp.makeStringAndClear() );
1281 }
1282 }
1283 break;
1284
1285 case AnimationNodeType::ANIMATECOLOR:
1286 {
1287 eElementToken = XML_ANIMATECOLOR;
1288
1289 Reference< XAnimateColor > xAnimateColor( xAnimate, UNO_QUERY_THROW );
1290
1291 nTemp = xAnimateColor->getColorInterpolation();
1292 mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_COLOR_INTERPOLATION, (nTemp == AnimationColorSpace::RGB) ? XML_RGB : XML_HSL );
1293
1294 bTemp = xAnimateColor->getDirection();
1295 mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_COLOR_INTERPOLATION_DIRECTION, bTemp ? XML_CLOCKWISE : XML_COUNTER_CLOCKWISE );
1296 }
1297 break;
1298
1299 case AnimationNodeType::ANIMATETRANSFORM:
1300 {
1301 eElementToken = XML_ANIMATETRANSFORM;
1302
1303 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_ATTRIBUTENAME, XML_TRANSFORM );
1304
1305 Reference< XAnimateTransform > xTransform( xAnimate, UNO_QUERY_THROW );
1306 nTemp = xTransform->getTransformType();
1307 SvXMLUnitConverter::convertEnum( sTmp, nTemp, aAnimations_EnumMap_TransformType );
1308 mxExport->AddAttribute( XML_NAMESPACE_SVG, XML_TYPE, sTmp.makeStringAndClear() );
1309 }
1310 break;
1311
1312 case AnimationNodeType::TRANSITIONFILTER:
1313 {
1314 Reference< XTransitionFilter > xTransitionFilter( xAnimate, UNO_QUERY );
1315 eElementToken = XML_TRANSITIONFILTER;
1316
1317 sal_Int16 nTransition = xTransitionFilter->getTransition();
1318 SvXMLUnitConverter::convertEnum( sTmp, nTransition, aAnimations_EnumMap_TransitionType );
1319 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_TYPE, sTmp.makeStringAndClear() );
1320
1321 sal_Int16 nSubtype = xTransitionFilter->getSubtype();
1322 if( nSubtype != TransitionSubType::DEFAULT )
1323 {
1324 SvXMLUnitConverter::convertEnum( sTmp, nSubtype, aAnimations_EnumMap_TransitionSubType );
1325 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_SUBTYPE, sTmp.makeStringAndClear() );
1326 }
1327
1328 bTemp = xTransitionFilter->getMode();
1329 if( !bTemp )
1330 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_MODE, XML_OUT );
1331
1332 bTemp = xTransitionFilter->getDirection();
1333 if( !bTemp )
1334 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_DIRECTION, XML_REVERSE );
1335
1336 if( (nTransition == TransitionType::FADE) && ((nSubtype == TransitionSubType::FADETOCOLOR) || (nSubtype == TransitionSubType::FADEFROMCOLOR) ))
1337 {
1338 nTemp = xTransitionFilter->getFadeColor();
1339 ::sax::Converter::convertColor( sTmp, nTemp );
1340 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_FADECOLOR, sTmp.makeStringAndClear() );
1341 }
1342 }
1343 break;
1344 }
1345
1346 if( eElementToken == XML_ANIMATEPHYSICS ) // not a standard should use the extension namespace
1347 {
1348 SvXMLElementExport aElement( *mxExport, XML_NAMESPACE_LO_EXT, eElementToken, true, true );
1349 }
1350 else
1351 {
1352 SvXMLElementExport aElement( *mxExport, XML_NAMESPACE_ANIMATION, eElementToken, true, true );
1353 }
1354
1355 }
1356 catch (const Exception&)
1357 {
1358 TOOLS_WARN_EXCEPTION("xmloff.draw", "")do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff.draw")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break;
case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1358" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1358" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "" << " " << exceptionToString(tools_warn_exception
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1358" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1358" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1359 }
1360}
1361
1362void AnimationsExporterImpl::exportAudio( const Reference< XAudio >& xAudio )
1363{
1364 if( !xAudio.is() )
1365 return;
1366
1367 try
1368 {
1369 OUString aSourceURL;
1370 xAudio->getSource() >>= aSourceURL;
1371 if( !aSourceURL.isEmpty() )
1372 mxExport->AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, mxExport->GetRelativeReference( aSourceURL ) );
1373
1374 const double fVolume = xAudio->getVolume();
1375 if( fVolume != 1.0 )
1376 {
1377 OUStringBuffer sTmp;
1378 ::sax::Converter::convertDouble( sTmp, fVolume );
1379 mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_AUDIO_LEVEL, sTmp.makeStringAndClear() );
1380 }
1381
1382 /* todo?
1383 sal_Int32 nEndAfterSlide = 0;
1384 xAudio->getEndAfterSlide() >>= nEndAfterSlide;
1385 if( nEndAfterSlide != 0 )
1386 mxExport->AddAttribute( );
1387 */
1388 SvXMLElementExport aElement( *mxExport, XML_NAMESPACE_ANIMATION, XML_AUDIO, true, true );
1389
1390 }
1391 catch (const Exception&)
1392 {
1393 TOOLS_WARN_EXCEPTION("xmloff.draw", "")do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff.draw")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break;
case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1393" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1393" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "" << " " << exceptionToString(tools_warn_exception
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1393" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1393" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1394 }
1395}
1396
1397void AnimationsExporterImpl::exportCommand( const Reference< XCommand >& xCommand )
1398{
1399 if( !xCommand.is() )
1400 return;
1401
1402 try
1403 {
1404 OUStringBuffer sTmp;
1405 Any aTemp( xCommand->getTarget() );
1406 if( aTemp.hasValue() )
1407 {
1408 convertTarget( sTmp, aTemp );
1409 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_TARGETELEMENT, sTmp.makeStringAndClear() );
1410 }
1411
1412 sal_Int16 nCommand = xCommand->getCommand();
1413 SvXMLUnitConverter::convertEnum( sTmp, nCommand, aAnimations_EnumMap_Command );
1414 mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_COMMAND, sTmp.makeStringAndClear() );
1415
1416 // todo virtual css::uno::Any SAL_CALL getParameter() throw (css::uno::RuntimeException) = 0;
1417
1418 SvXMLElementExport aElement( *mxExport, XML_NAMESPACE_ANIMATION, XML_COMMAND, true, true );
1419
1420 }
1421 catch (const Exception&)
1422 {
1423 TOOLS_WARN_EXCEPTION("xmloff.draw", "")do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff.draw")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break;
case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1423" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1423" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "" << " " << exceptionToString(tools_warn_exception
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1423" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1423" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1424 }
1425}
1426
1427Reference< XInterface > AnimationsExporterImpl::getParagraphTarget( const ParagraphTarget& pTarget )
1428{
1429 try
1430 {
1431 Reference< XEnumerationAccess > xParaEnumAccess( pTarget.Shape, UNO_QUERY_THROW );
1432
1433 Reference< XEnumeration > xEnumeration( xParaEnumAccess->createEnumeration(), css::uno::UNO_SET_THROW );
1434 sal_Int32 nParagraph = pTarget.Paragraph;
1435
1436 while( xEnumeration->hasMoreElements() )
1437 {
1438 Reference< XInterface > xRef( xEnumeration->nextElement(), UNO_QUERY );
1439 if( nParagraph-- == 0 )
1440 return xRef;
1441 }
1442 }
1443 catch (const RuntimeException&)
1444 {
1445 TOOLS_WARN_EXCEPTION("xmloff.draw", "")do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff.draw")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break;
case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1445" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1445" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "" << " " << exceptionToString(tools_warn_exception
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1445" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1445" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1446 }
1447
1448 Reference< XInterface > xRef;
1449 return xRef;
1450}
1451
1452void AnimationsExporterImpl::convertPath( OUStringBuffer& sTmp, const Any& rPath )
1453{
1454 OUString aStr;
1455 rPath >>= aStr;
1456
1457 sTmp = aStr;
1458}
1459
1460void AnimationsExporterImpl::convertValue( XMLTokenEnum eAttributeName, OUStringBuffer& sTmp, const Any& rValue ) const
1461{
1462 if( !rValue.hasValue() )
1463 return;
1464
1465 if( auto pValuePair = o3tl::tryAccess<ValuePair>(rValue) )
1466 {
1467 OUStringBuffer sTmp2;
1468 convertValue( eAttributeName, sTmp, pValuePair->First );
1469 sTmp.append( ',' );
1470 convertValue( eAttributeName, sTmp2, pValuePair->Second );
1471 sTmp.append( sTmp2.makeStringAndClear() );
1472 }
1473 else if( auto pSequence = o3tl::tryAccess<Sequence<Any>>(rValue) )
1474 {
1475 const sal_Int32 nLength = pSequence->getLength();
1476 sal_Int32 nElement;
1477 const Any* pAny = pSequence->getConstArray();
1478
1479 OUStringBuffer sTmp2;
1480
1481 for( nElement = 0; nElement < nLength; nElement++, pAny++ )
1482 {
1483 if( !sTmp.isEmpty() )
1484 sTmp.append( ';' );
1485 convertValue( eAttributeName, sTmp2, *pAny );
1486 sTmp.append( sTmp2.makeStringAndClear() );
1487 }
1488 }
1489 else
1490 {
1491 sal_Int32 nType;
1492
1493 switch( eAttributeName )
1494 {
1495 case XML_X:
1496 case XML_Y:
1497 case XML_WIDTH:
1498 case XML_HEIGHT:
1499 case XML_ANIMATETRANSFORM:
1500 case XML_ANIMATEMOTION:
1501 case XML_ANIMATEPHYSICS:
1502 {
1503 if( auto aString = o3tl::tryAccess<OUString>(rValue) )
1504 {
1505 sTmp.append( *aString );
1506 }
1507 else if( auto x = o3tl::tryAccess<double>(rValue) )
1508 {
1509 sTmp.append( *x );
1510 }
1511 else
1512 {
1513 OSL_FAIL( "xmloff::AnimationsExporterImpl::convertValue(), invalid value type!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1513" ": "), "%s", "xmloff::AnimationsExporterImpl::convertValue(), invalid value type!"
); } } while (false)
;
1514 }
1515 return;
1516 }
1517
1518 case XML_SKEWX:
1519 case XML_ROTATE: nType = XML_TYPE_DOUBLE0x0000200e; break;
1520 case XML_TEXT_ROTATION_ANGLE: nType = XML_TYPE_NUMBER160x0000200c; break;
1521 case XML_FILL_COLOR:
1522 case XML_STROKE_COLOR:
1523 case XML_DIM:
1524 case XML_COLOR: nType = XML_TYPE_COLOR0x00002009; break;
1525 case XML_FILL: nType = XML_SD_TYPE_FILLSTYLE((0x2 << 10) + 9 ); break;
1526 case XML_STROKE: nType = XML_SD_TYPE_STROKE((0x2 << 10) + 0); break;
1527 case XML_FONT_WEIGHT: nType = XML_TYPE_TEXT_WEIGHT((0x3 << 10) + 10); break;
1528 case XML_FONT_STYLE: nType = XML_TYPE_TEXT_POSTURE((0x3 << 10) + 7); break;
1529 case XML_TEXT_UNDERLINE: nType = XML_TYPE_TEXT_UNDERLINE_STYLE((0x3 << 10) + 9); break;
1530 case XML_FONT_SIZE: nType = XML_TYPE_DOUBLE_PERCENT0x00002024; break;
1531 case XML_VISIBILITY: nType = XML_SD_TYPE_PRESPAGE_VISIBILITY((0x2 << 10) + 5); break;
1532 case XML_OPACITY:
1533 case XML_TRANSITIONFILTER: nType = XML_TYPE_DOUBLE0x0000200e; break;
1534 default:
1535 OSL_FAIL( "xmloff::AnimationsExporterImpl::convertValue(), invalid AttributeName!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1535" ": "), "%s", "xmloff::AnimationsExporterImpl::convertValue(), invalid AttributeName!"
); } } while (false)
;
1536 nType = XML_TYPE_STRING0x00002008;
1537 }
1538
1539 //const XMLPropertyHandler* pHandler = static_cast<SdXMLExport*>(&mrExport)->GetSdPropHdlFactory()->GetPropertyHandler( nType );
1540 const XMLPropertyHandler* pHandler = mxSdPropHdlFactory->GetPropertyHandler( nType );
1541 if( pHandler )
1542 {
1543 OUString aString;
1544 pHandler->exportXML( aString, rValue, mxExport->GetMM100UnitConverter() );
1545 sTmp.append( aString );
1546 }
1547 }
1548}
1549
1550void AnimationsExporterImpl::convertTiming( OUStringBuffer& sTmp, const Any& rValue ) const
1551{
1552 if( !rValue.hasValue() )
5
Taking false branch
1553 return;
1554
1555 if( auto pSequence = o3tl::tryAccess<Sequence<Any>>(rValue) )
6
Assuming 'pSequence' is null
7
Taking false branch
1556 {
1557 const sal_Int32 nLength = pSequence->getLength();
1558 sal_Int32 nElement;
1559 const Any* pAny = pSequence->getConstArray();
1560
1561 OUStringBuffer sTmp2;
1562
1563 for( nElement = 0; nElement < nLength; nElement++, pAny++ )
1564 {
1565 if( !sTmp.isEmpty() )
1566 sTmp.append( ';' );
1567 convertTiming( sTmp2, *pAny );
1568 sTmp.append( sTmp2.makeStringAndClear() );
1569 }
1570 }
1571 else if( auto x = o3tl::tryAccess<double>(rValue) )
8
Calling 'tryAccess<double>'
1572 {
1573 sTmp.append( *x );
1574 sTmp.append( 's');
1575 }
1576 else if( auto pTiming = o3tl::tryAccess<Timing>(rValue) )
1577 {
1578 sTmp.append( GetXMLToken( (*pTiming == Timing_MEDIA) ? XML_MEDIA : XML_INDEFINITE ) );
1579 }
1580 else if( auto pEvent = o3tl::tryAccess<Event>(rValue) )
1581 {
1582 OUStringBuffer sTmp2;
1583
1584 if( pEvent->Trigger != EventTrigger::NONE )
1585 {
1586 if( pEvent->Source.hasValue() )
1587 {
1588 convertTarget( sTmp, pEvent->Source );
1589 sTmp.append( '.' );
1590 }
1591
1592 SvXMLUnitConverter::convertEnum( sTmp2, pEvent->Trigger, aAnimations_EnumMap_EventTrigger );
1593
1594 sTmp.append( sTmp2.makeStringAndClear() );
1595 }
1596
1597 if( pEvent->Offset.hasValue() )
1598 {
1599 convertTiming( sTmp2, pEvent->Offset );
1600
1601 if( !sTmp.isEmpty() )
1602 sTmp.append( '+' );
1603
1604 sTmp.append( sTmp2.makeStringAndClear() );
1605 }
1606 }
1607 else
1608 {
1609 OSL_FAIL( "xmloff::AnimationsExporterImpl::convertTiming(), invalid value type!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1609" ": "), "%s", "xmloff::AnimationsExporterImpl::convertTiming(), invalid value type!"
); } } while (false)
;
1610 }
1611}
1612
1613void AnimationsExporterImpl::convertTarget( OUStringBuffer& sTmp, const Any& rTarget ) const
1614{
1615 if( !rTarget.hasValue() )
1616 return;
1617
1618 Reference< XInterface > xRef;
1619
1620 if( !(rTarget >>= xRef) )
1621 {
1622 if( auto pt = o3tl::tryAccess<ParagraphTarget>(rTarget) )
1623 {
1624 xRef = getParagraphTarget( *pt );
1625 }
1626 }
1627
1628 SAL_WARN_IF( !xRef.is(), "xmloff", "xmloff::AnimationsExporterImpl::convertTarget(), invalid target type!" )do { if (true && (!xRef.is())) { switch (sal_detail_log_report
(::SAL_DETAIL_LOG_LEVEL_WARN, "xmloff")) { case SAL_DETAIL_LOG_ACTION_IGNORE
: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail
::getResult( ::sal::detail::StreamStart() << "xmloff::AnimationsExporterImpl::convertTarget(), invalid target type!"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"
), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1628" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "xmloff::AnimationsExporterImpl::convertTarget(), invalid target type!"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "xmloff::AnimationsExporterImpl::convertTarget(), invalid target type!"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"
), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1628" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "xmloff::AnimationsExporterImpl::convertTarget(), invalid target type!"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"
), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1628" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "xmloff::AnimationsExporterImpl::convertTarget(), invalid target type!"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "xmloff::AnimationsExporterImpl::convertTarget(), invalid target type!"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff"
), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1628" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1629 if( xRef.is() )
1630 {
1631 const OUString& rIdentifier = mxExport->getInterfaceToIdentifierMapper().getIdentifier(xRef);
1632 if( !rIdentifier.isEmpty() )
1633 sTmp.append( rIdentifier );
1634 }
1635}
1636
1637void AnimationsExporterImpl::prepareValue( const Any& rValue )
1638{
1639 if( !rValue.hasValue() )
1640 return;
1641
1642 if( auto pValuePair = o3tl::tryAccess<ValuePair>(rValue) )
1643 {
1644 prepareValue( pValuePair->First );
1645 prepareValue( pValuePair->Second );
1646 }
1647 else if( auto pSequence = o3tl::tryAccess<Sequence<Any>>(rValue) )
1648 {
1649 const sal_Int32 nLength = pSequence->getLength();
1650 sal_Int32 nElement;
1651 const Any* pAny = pSequence->getConstArray();
1652
1653 for( nElement = 0; nElement < nLength; nElement++, pAny++ )
1654 prepareValue( *pAny );
1655 }
1656 else if( rValue.getValueTypeClass() == css::uno::TypeClass_INTERFACE )
1657 {
1658 Reference< XInterface> xRef( rValue, UNO_QUERY );
1659 if( xRef.is() )
1660 mxExport->getInterfaceToIdentifierMapper().registerReference( xRef );
1661 }
1662 else if( auto pt = o3tl::tryAccess<ParagraphTarget>(rValue) )
1663 {
1664 Reference< XInterface> xRef( getParagraphTarget( *pt ) );
1665 if( xRef.is() )
1666 mxExport->getInterfaceToIdentifierMapper().registerReference( xRef );
1667 }
1668 else if( auto pEvent = o3tl::tryAccess<Event>(rValue) )
1669 {
1670 prepareValue( pEvent->Source );
1671 }
1672}
1673
1674AnimationsExporter::AnimationsExporter( SvXMLExport& rExport, const Reference< XPropertySet >& xPageProps )
1675 : mpImpl( new AnimationsExporterImpl( rExport, xPageProps ) )
1676{
1677}
1678
1679AnimationsExporter::~AnimationsExporter()
1680{
1681}
1682
1683void AnimationsExporter::prepare( const Reference< XAnimationNode >& xRootNode )
1684{
1685 try
1686 {
1687 if( xRootNode.is() )
1688 {
1689 mpImpl->prepareTransitionNode();
1690 mpImpl->prepareNode( xRootNode );
1691 }
1692 }
1693 catch (const RuntimeException&)
1694 {
1695 TOOLS_WARN_EXCEPTION("xmloff.draw", "")do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff.draw")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break;
case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1695" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1695" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "" << " " << exceptionToString(tools_warn_exception
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1695" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1695" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1696 }
1697}
1698
1699void AnimationsExporter::exportAnimations( const Reference< XAnimationNode >& xRootNode )
1700{
1701 try
1702 {
1703 if( xRootNode.is() )
1704 {
1705 bool bHasEffects = mpImpl->mbHasTransition;
1706
1707 if( !bHasEffects )
1708 {
1709 // first check if there are no animations
1710 Reference< XEnumerationAccess > xEnumerationAccess( xRootNode, UNO_QUERY_THROW );
1711 Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), css::uno::UNO_SET_THROW );
1712 if( xEnumeration->hasMoreElements() )
1713 {
1714 // first child node may be an empty main sequence, check this
1715 Reference< XAnimationNode > xMainNode( xEnumeration->nextElement(), UNO_QUERY_THROW );
1716 Reference< XEnumerationAccess > xMainEnumerationAccess( xMainNode, UNO_QUERY_THROW );
1717 Reference< XEnumeration > xMainEnumeration( xMainEnumerationAccess->createEnumeration(), css::uno::UNO_SET_THROW );
1718
1719 // only export if the main sequence is not empty or if there are additional
1720 // trigger sequences
1721 bHasEffects = xMainEnumeration->hasMoreElements() || xEnumeration->hasMoreElements();
1722 }
1723 }
1724
1725 if( bHasEffects )
1726 mpImpl->exportNode( xRootNode );
1727 }
1728 }
1729 catch (const RuntimeException&)
1730 {
1731 TOOLS_WARN_EXCEPTION("xmloff.draw", "")do { css::uno::Any tools_warn_exception( DbgGetCaughtException
() ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "xmloff.draw")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break;
case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "" << " " <<
exceptionToString(tools_warn_exception)) == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1731" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1731" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "" << " " << exceptionToString(tools_warn_exception
)) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), (
"xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1731" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "" << " " << exceptionToString
(tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "" << " " << exceptionToString
(tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("xmloff.draw"), ("/home/maarten/src/libreoffice/core/xmloff/source/draw/animationexport.cxx"
":" "1731" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false); } while (false)
;
1732 }
1733}
1734
1735}
1736
1737/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/o3tl/any.hxx

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
10#ifndef INCLUDED_O3TL_ANY_HXX
11#define INCLUDED_O3TL_ANY_HXX
12
13#include <sal/config.h>
14
15#include <cassert>
16#include <type_traits>
17#include <utility>
18
19#include <optional>
20
21#include <com/sun/star/uno/Any.hxx>
22#include <com/sun/star/uno/RuntimeException.hpp>
23#include <com/sun/star/uno/Reference.hxx>
24#include <com/sun/star/uno/XInterface.hpp>
25#include <cppu/unotype.hxx>
26#include <rtl/ustring.hxx>
27#include <sal/types.h>
28
29// Some functionality related to css::uno::Any that would ideally be part of
30// <com/sun/star/uno/Any.hxx>, but (for now) cannot be for some reason.
31
32namespace o3tl {
33
34namespace detail {
35
36struct Void {};
37
38template<typename T> struct Optional { using type = T const *; };
39template<> struct Optional<void> { using type = std::optional<Void const>; };
40template<> struct Optional<bool> { using type = std::optional<bool const>; };
41template<> struct Optional<sal_Int8> {
42 using type = std::optional<sal_Int8 const>;
43};
44template<> struct Optional<sal_Int16> {
45 using type = std::optional<sal_Int16 const>;
46};
47template<> struct Optional<sal_uInt16> {
48 using type = std::optional<sal_uInt16 const>;
49};
50template<> struct Optional<sal_Int32> {
51 using type = std::optional<sal_Int32 const>;
52};
53template<> struct Optional<sal_uInt32> {
54 using type = std::optional<sal_uInt32 const>;
55};
56template<> struct Optional<sal_Int64> {
57 using type = std::optional<sal_Int64 const>;
58};
59template<> struct Optional<sal_uInt64> {
60 using type = std::optional<sal_uInt64 const>;
61};
62template<> struct Optional<float> {
63 using type = std::optional<float const>;
64};
65template<> struct Optional<double> {
66 using type = std::optional<double const>;
67};
68template<typename T> struct Optional<css::uno::Reference<T>> {
69 using type = std::optional<css::uno::Reference<T> const>;
70};
71template<> struct Optional<css::uno::Reference<css::uno::XInterface>> {
72 using type = css::uno::Reference<css::uno::XInterface> const *;
73};
74
75template<typename> struct IsDerivedReference: std::false_type {};
76template<typename T> struct IsDerivedReference<css::uno::Reference<T>>:
77 std::true_type
78{};
79template<> struct IsDerivedReference<css::uno::Reference<css::uno::XInterface>>:
80 std::false_type
81{};
82
83template<typename> struct IsUnoSequenceType: std::false_type {};
84template<typename T> struct IsUnoSequenceType<cppu::UnoSequenceType<T>>:
85 std::true_type
86{};
87
88template<typename T> inline std::optional<T const> tryGetConverted(
89 css::uno::Any const & any)
90{
91 T v;
92 return (any >>= v)
10
Calling 'operator>>=<double>'
93 ? std::optional<T const>(std::move(v)) : std::optional<T const>();
94}
95
96}
97
98/** Try to access the value of a specific type stored in an Any.
99
100 In trying to obtain a value, the same set of conversions as supported by
101 ">>=" are considered.
102
103 The returned object is a proxy. Proxies can be either positive or negative.
104 Each proxy can be contextually converted to bool, yielding true iff the
105 proxy is positive. For a positive proxy P representing a value of requested
106 type T, for any T other than void, the expression *P yields that value of
107 type T. (Technically, the proxy is either a plain pointer or a
108 std::optional, depending on whether a plain pointer into the given Any can
109 be returned for the specified type.)
110
111 @attention A proxy returned from this function must not outlive the
112 corresponding Any passed into this function (as it may constitute a pointer
113 into the Any's internals). That is the reason why this function is
114 restricted to lvalue arguments (i.e., to non-temporary Any objects), to
115 avoid misuses like
116 @code
117 css::uno::Any f();
118
119 if (auto p = o3tl::tryAccess<css::beans::NamedValue>(f())) {
120 return p->Name;
121 }
122 @endcode
123
124 @note Ideally this would be a public member function of css::uno::Any (at
125 least conditional on LIBO_INTERNAL_ONLY, as it requires C++11). However, as
126 std::optional (which would be needed to implement the proxies) is only
127 available since C++14, we need to use std::optional for now. But To not
128 make every entity that includes <com/sun/star/uno/Any.hxx> depend on
129 boost_headers, keep this here for now.
130
131 @tparam T the C++ representation of a UNO type that can be contained in a
132 UNO ANY (i.e., any UNO type other than ANY itself). The legacy C++
133 representations sal_Bool, cppu::UnoVoidType, cppu::UnoUnsignedShortType,
134 cppu::UnoCharType, and cppu::UnoSequenceType are not supported. Must be a
135 complete type or void.
136
137 @param any an Any value.
138
139 @return a positive proxy for the value of the specified type obtained from
140 the given Any, or a negative proxy if no such value can be obtained.
141*/
142template<typename T> inline
143typename std::enable_if<
144 !(detail::IsDerivedReference<T>::value
145 || detail::IsUnoSequenceType<T>::value
146 || std::is_base_of<css::uno::XInterface, T>::value),
147 typename detail::Optional<T>::type>::type
148tryAccess(css::uno::Any const & any) {
149 // CHAR, STRING, TYPE, sequence types, enum types, struct types, exception
150 // types, and com.sun.star.uno.XInterface interface type:
151 return cppu::UnoType<T>::get().isAssignableFrom(any.getValueType())
152 ? static_cast<T const *>(any.getValue()) : nullptr;
153}
154
155template<> inline detail::Optional<void>::type tryAccess<void>(
156 css::uno::Any const & any)
157{
158 return any.hasValue()
159 ? std::optional<detail::Void const>()
160 : std::optional<detail::Void const>(detail::Void());
161}
162
163template<> inline detail::Optional<bool>::type tryAccess<bool>(
164 css::uno::Any const & any)
165{
166 return detail::tryGetConverted<bool>(any);
167}
168
169template<> inline detail::Optional<sal_Int8>::type tryAccess<sal_Int8>(
170 css::uno::Any const & any)
171{
172 return detail::tryGetConverted<sal_Int8>(any);
173}
174
175template<> inline detail::Optional<sal_Int16>::type tryAccess<sal_Int16>(
176 css::uno::Any const & any)
177{
178 return detail::tryGetConverted<sal_Int16>(any);
179}
180
181template<> inline detail::Optional<sal_uInt16>::type tryAccess<sal_uInt16>(
182 css::uno::Any const & any)
183{
184 return detail::tryGetConverted<sal_uInt16>(any);
185}
186
187template<> inline detail::Optional<sal_Int32>::type tryAccess<sal_Int32>(
188 css::uno::Any const & any)
189{
190 return detail::tryGetConverted<sal_Int32>(any);
191}
192
193template<> inline detail::Optional<sal_uInt32>::type tryAccess<sal_uInt32>(
194 css::uno::Any const & any)
195{
196 return detail::tryGetConverted<sal_uInt32>(any);
197}
198
199template<> inline detail::Optional<sal_Int64>::type tryAccess<sal_Int64>(
200 css::uno::Any const & any)
201{
202 return detail::tryGetConverted<sal_Int64>(any);
203}
204
205template<> inline detail::Optional<sal_uInt64>::type tryAccess<sal_uInt64>(
206 css::uno::Any const & any)
207{
208 return detail::tryGetConverted<sal_uInt64>(any);
209}
210
211template<> inline detail::Optional<float>::type tryAccess<float>(
212 css::uno::Any const & any)
213{
214 return detail::tryGetConverted<float>(any);
215}
216
217template<> inline detail::Optional<double>::type tryAccess<double>(
218 css::uno::Any const & any)
219{
220 return detail::tryGetConverted<double>(any);
9
Calling 'tryGetConverted<double>'
221}
222
223template<> detail::Optional<css::uno::Any>::type tryAccess<css::uno::Any>(
224 css::uno::Any const &) = delete;
225
226template<> detail::Optional<sal_Bool>::type tryAccess<sal_Bool>(
227 css::uno::Any const &) = delete;
228
229/*
230
231// Already prevented by std::is_base_of<css::uno::XInterface, T> requiring T to
232// be complete:
233
234template<> detail::Optional<cppu::UnoVoidType>::type
235tryAccess<cppu::UnoVoidType>(css::uno::Any const &) = delete;
236
237template<> detail::Optional<cppu::UnoUnsignedShortType>::type
238tryAccess<cppu::UnoUnsignedShortType>(css::uno::Any const &) = delete;
239
240template<> detail::Optional<cppu::UnoCharType>::type
241tryAccess<cppu::UnoCharType>(css::uno::Any const &) = delete;
242
243*/
244
245template<typename T> inline
246typename std::enable_if<
247 detail::IsDerivedReference<T>::value,
248 typename detail::Optional<T>::type>::type
249tryAccess(css::uno::Any const & any) {
250 return detail::tryGetConverted<T>(any);
251}
252
253template<typename T> typename detail::Optional<T>::type tryAccess(
254 css::uno::Any const volatile &&) = delete;
255
256/** Access the value of a specific type stored in an Any, throwing an exception
257 on failure.
258
259 @attention A proxy returned from this function must not outlive the
260 corresponding Any passed into this function (as it may constitute a pointer
261 into the Any's internals). However, unlike with tryAccess, the benefit of
262 allowing this function to operate on temporaries appears to outweigh its
263 dangers.
264
265 @note Ideally this would be a public member function of css::uno::Any. See
266 tryAccess for details.
267
268 @tparam T the C++ representation of a UNO type that can be contained in a
269 UNO ANY. See tryAccess for details.
270
271 @param any an Any value.
272
273 @return a positive proxy for the value of the specified type obtained from
274 the given Any. See tryAccess for details.
275
276 @throws css::uno::RuntimeException when a value of the requested type
277 cannot be obtained.
278*/
279template<typename T> inline typename detail::Optional<T>::type doAccess(
280 css::uno::Any const & any)
281{
282 auto opt = tryAccess<T>(any);
283 if (!opt) {
284 throw css::uno::RuntimeException(
285 OUString(
286 cppu_Any_extraction_failure_msg(
287 &any, cppu::UnoType<T>::get().getTypeLibType()),
288 SAL_NO_ACQUIRE));
289 }
290 return opt;
291}
292
293/** Access the value of a specific type stored in an Any, knowing the Any
294 contains a value of a matching type.
295
296 @attention A proxy returned from this function must not outlive the
297 corresponding Any passed into this function (as it may constitute a pointer
298 into the Any's internals). However, unlike with tryAccess, the benefit of
299 allowing this function to operate on temporaries appears to outweigh its
300 dangers.
301
302 @note Ideally this would be a public member function of css::uno::Any. See
303 tryAccess for details.
304
305 @tparam T the C++ representation of a UNO type that can be contained in a
306 UNO ANY. See tryAccess for details.
307
308 @param any an Any value.
309
310 @return a positive proxy for the value of the specified type obtained from
311 the given Any. See tryAccess for details.
312*/
313template<typename T> inline typename detail::Optional<T>::type forceAccess(
314 css::uno::Any const & any)
315{
316 auto opt = tryAccess<T>(any);
317 assert(opt)(static_cast <bool> (opt) ? void (0) : __assert_fail ("opt"
, "/home/maarten/src/libreoffice/core/include/o3tl/any.hxx", 317
, __extension__ __PRETTY_FUNCTION__))
;
318 return opt;
319}
320
321}
322
323#endif
324
325/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */

/home/maarten/src/libreoffice/core/include/com/sun/star/uno/Any.hxx

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#ifndef INCLUDED_COM_SUN_STAR_UNO_ANY_HXX
20#define INCLUDED_COM_SUN_STAR_UNO_ANY_HXX
21
22#include "sal/config.h"
23
24#include <algorithm>
25#include <cassert>
26#include <cstddef>
27#include <iomanip>
28#include <ostream>
29#include <utility>
30
31#include "com/sun/star/uno/Any.h"
32#include "uno/data.h"
33#include "uno/sequence2.h"
34#include "com/sun/star/uno/Type.hxx"
35#include "com/sun/star/uno/Reference.h"
36#include "com/sun/star/uno/genfunc.hxx"
37#include "com/sun/star/uno/RuntimeException.hpp"
38#include "cppu/cppudllapi.h"
39#include "cppu/unotype.hxx"
40
41extern "C" CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) rtl_uString * SAL_CALL cppu_Any_extraction_failure_msg(
42 uno_Any const * pAny, typelib_TypeDescriptionReference * pType )
43 SAL_THROW_EXTERN_C()throw ();
44
45namespace com
46{
47namespace sun
48{
49namespace star
50{
51namespace uno
52{
53
54
55inline Any::Any()
56{
57 ::uno_any_construct( this, NULL__null, NULL__null, cpp_acquire );
58}
59
60
61template <typename T>
62inline Any::Any( T const & value )
63{
64 ::uno_type_any_construct(
65 this, const_cast<T *>(&value),
66 ::cppu::getTypeFavourUnsigned(&value).getTypeLibType(),
67 cpp_acquire );
68}
69
70inline Any::Any( bool value )
71{
72 sal_Bool b = value;
73 ::uno_type_any_construct(
74 this, &b, cppu::UnoType<bool>::get().getTypeLibType(),
75 cpp_acquire );
76}
77
78#if defined LIBO_INTERNAL_ONLY1
79template<typename T1, typename T2>
80Any::Any(rtl::OUStringConcat<T1, T2> && value):
81 Any(rtl::OUString(std::move(value)))
82{}
83#endif
84
85inline Any::Any( const Any & rAny )
86{
87 ::uno_type_any_construct( this, rAny.pData, rAny.pType, cpp_acquire );
88}
89
90inline Any::Any( const void * pData_, const Type & rType )
91{
92 ::uno_type_any_construct(
93 this, const_cast< void * >( pData_ ), rType.getTypeLibType(),
94 cpp_acquire );
95}
96
97inline Any::Any( const void * pData_, typelib_TypeDescription * pTypeDescr )
98{
99 ::uno_any_construct(
100 this, const_cast< void * >( pData_ ), pTypeDescr, cpp_acquire );
101}
102
103inline Any::Any( const void * pData_, typelib_TypeDescriptionReference * pType_ )
104{
105 ::uno_type_any_construct(
106 this, const_cast< void * >( pData_ ), pType_, cpp_acquire );
107}
108
109inline Any::~Any()
110{
111 ::uno_any_destruct(
112 this, cpp_release );
113}
114
115inline Any & Any::operator = ( const Any & rAny )
116{
117 if (this != &rAny)
118 {
119 ::uno_type_any_assign(
120 this, rAny.pData, rAny.pType,
121 cpp_acquire, cpp_release );
122 }
123 return *this;
124}
125
126#if defined LIBO_INTERNAL_ONLY1
127
128namespace detail {
129
130inline void moveAnyInternals(Any & from, Any & to) noexcept {
131 uno_any_construct(&to, nullptr, nullptr, &cpp_acquire);
132 std::swap(from.pType, to.pType);
133 std::swap(from.pData, to.pData);
134 std::swap(from.pReserved, to.pReserved);
135 if (to.pData == &from.pReserved) {
136 to.pData = &to.pReserved;
137 }
138 // This leaves from.pData (where "from" is now VOID) dangling to somewhere (cf.
139 // CONSTRUCT_EMPTY_ANY, cppu/source/uno/prim.hxx), but what's relevant is
140 // only that it isn't a nullptr (as e.g. >>= -> uno_type_assignData ->
141 // _assignData takes a null pSource to mean "construct a default value").
142}
143
144}
145
146Any::Any(Any && other) noexcept {
147 detail::moveAnyInternals(other, *this);
148}
149
150Any & Any::operator =(Any && other) noexcept {
151 uno_any_destruct(this, &cpp_release);
152 detail::moveAnyInternals(other, *this);
153 return *this;
154}
155
156#endif
157
158inline ::rtl::OUString Any::getValueTypeName() const
159{
160 return ::rtl::OUString( pType->pTypeName );
161}
162
163inline void Any::setValue( const void * pData_, const Type & rType )
164{
165 ::uno_type_any_assign(
166 this, const_cast< void * >( pData_ ), rType.getTypeLibType(),
167 cpp_acquire, cpp_release );
168}
169
170inline void Any::setValue( const void * pData_, typelib_TypeDescriptionReference * pType_ )
171{
172 ::uno_type_any_assign(
173 this, const_cast< void * >( pData_ ), pType_,
174 cpp_acquire, cpp_release );
175}
176
177inline void Any::setValue( const void * pData_, typelib_TypeDescription * pTypeDescr )
178{
179 ::uno_any_assign(
180 this, const_cast< void * >( pData_ ), pTypeDescr,
181 cpp_acquire, cpp_release );
182}
183
184inline void Any::clear()
185{
186 ::uno_any_clear(
187 this, cpp_release );
188}
189
190inline bool Any::isExtractableTo( const Type & rType ) const
191{
192 return ::uno_type_isAssignableFromData(
193 rType.getTypeLibType(), pData, pType,
194 cpp_queryInterface, cpp_release );
195}
196
197
198template <typename T>
199inline bool Any::has() const
200{
201 Type const & rType = ::cppu::getTypeFavourUnsigned(static_cast< T * >(0));
202 return ::uno_type_isAssignableFromData(
203 rType.getTypeLibType(), pData, pType,
204 cpp_queryInterface,
205 cpp_release );
206}
207
208#if defined LIBO_INTERNAL_ONLY1
209template<> bool Any::has<Any>() const = delete;
210#endif
211
212inline bool Any::operator == ( const Any & rAny ) const
213{
214 return ::uno_type_equalData(
215 pData, pType, rAny.pData, rAny.pType,
216 cpp_queryInterface, cpp_release );
217}
218
219inline bool Any::operator != ( const Any & rAny ) const
220{
221 return (! ::uno_type_equalData(
222 pData, pType, rAny.pData, rAny.pType,
223 cpp_queryInterface, cpp_release ));
224}
225
226
227template< class C >
228inline Any SAL_CALL makeAny( const C & value )
229{
230 return Any(value);
231}
232
233#if !defined LIBO_INTERNAL_ONLY1
234template<> Any makeAny(sal_uInt16 const & value)
235{ return Any(&value, cppu::UnoType<cppu::UnoUnsignedShortType>::get()); }
236#endif
237
238template<typename T> Any toAny(T const & value) { return makeAny(value); }
239
240template<> Any toAny(Any const & value) { return value; }
241
242#if defined LIBO_INTERNAL_ONLY1
243
244template<typename T1, typename T2>
245Any makeAny(rtl::OUStringConcat<T1, T2> && value)
246{ return Any(std::move(value)); }
247
248template<typename T1, typename T2>
249Any toAny(rtl::OUStringConcat<T1, T2> && value)
250{ return makeAny(std::move(value)); }
251
252template<typename T>
253Any makeAny(rtl::OUStringNumber<T> && value)
254{ return Any(OUString(std::move(value))); }
255
256template<typename T>
257Any toAny(rtl::OUStringNumber<T> && value)
258{ return makeAny(std::move(value)); }
259
260template<typename T> bool fromAny(Any const & any, T * value) {
261 assert(value != nullptr)(static_cast <bool> (value != nullptr) ? void (0) : __assert_fail
("value != nullptr", "/home/maarten/src/libreoffice/core/include/com/sun/star/uno/Any.hxx"
, 261, __extension__ __PRETTY_FUNCTION__))
;
262 return any >>= *value;
263}
264
265template<> bool fromAny(Any const & any, Any * value) {
266 assert(value != nullptr)(static_cast <bool> (value != nullptr) ? void (0) : __assert_fail
("value != nullptr", "/home/maarten/src/libreoffice/core/include/com/sun/star/uno/Any.hxx"
, 266, __extension__ __PRETTY_FUNCTION__))
;
267 *value = any;
268 return true;
269}
270
271#endif
272
273template< class C >
274inline void SAL_CALL operator <<= ( Any & rAny, const C & value )
275{
276 const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
277 ::uno_type_any_assign(
278 &rAny, const_cast< C * >( &value ), rType.getTypeLibType(),
279 cpp_acquire, cpp_release );
280}
281
282// additionally for C++ bool:
283
284template<>
285inline void SAL_CALL operator <<= ( Any & rAny, bool const & value )
286{
287 sal_Bool b = value;
288 ::uno_type_any_assign(
289 &rAny, &b, cppu::UnoType<bool>::get().getTypeLibType(),
290 cpp_acquire, cpp_release );
291}
292
293
294#ifdef LIBO_INTERNAL_ONLY1 // "RTL_FAST_STRING"
295template< class C1, class C2 >
296inline void SAL_CALL operator <<= ( Any & rAny, rtl::OUStringConcat< C1, C2 >&& value )
297{
298 const rtl::OUString str( std::move(value) );
299 const Type & rType = ::cppu::getTypeFavourUnsigned(&str);
300 ::uno_type_any_assign(
301 &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(),
302 cpp_acquire, cpp_release );
303}
304template<typename T1, typename T2>
305void operator <<=(Any &, rtl::OUStringConcat<T1, T2> const &) = delete;
306template< class C >
307inline void SAL_CALL operator <<= ( Any & rAny, rtl::OUStringNumber< C >&& value )
308{
309 const rtl::OUString str( std::move(value) );
310 const Type & rType = ::cppu::getTypeFavourUnsigned(&str);
311 ::uno_type_any_assign(
312 &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(),
313 cpp_acquire, cpp_release );
314}
315template<typename T>
316void operator <<=(Any &, rtl::OUStringNumber<T> const &) = delete;
317#endif
318
319#if defined LIBO_INTERNAL_ONLY1
320template<> void SAL_CALL operator <<=(Any &, Any const &) = delete;
321#endif
322
323template< class C >
324inline bool SAL_CALL operator >>= ( const Any & rAny, C & value )
325{
326 const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
327 return ::uno_type_assignData(
328 &value, rType.getTypeLibType(),
329 rAny.pData, rAny.pType,
330 cpp_queryInterface,
331 cpp_acquire, cpp_release );
332}
333
334// bool
335
336template<>
337inline bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Bool & value )
338{
339 if (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass)
340 {
341 value = bool(* static_cast< const sal_Bool * >( rAny.pData ));
342 return true;
343 }
344 return false;
345}
346
347template<>
348inline bool SAL_CALL operator == ( const Any & rAny, const sal_Bool & value )
349{
350 return (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass &&
351 bool(value) == bool(* static_cast< const sal_Bool * >( rAny.pData )));
352}
353
354
355template<>
356inline bool SAL_CALL operator >>= ( Any const & rAny, bool & value )
357{
358 if (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN)
359 {
360 value = *static_cast< sal_Bool const * >( rAny.pData );
361 return true;
362 }
363 return false;
364}
365
366
367template<>
368inline bool SAL_CALL operator == ( Any const & rAny, bool const & value )
369{
370 return (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN &&
371 (value ==
372 bool(*static_cast< sal_Bool const * >( rAny.pData ))));
373}
374
375// byte
376
377template<>
378inline bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int8 & value )
379{
380 if (typelib_TypeClass_BYTE == rAny.pType->eTypeClass)
381 {
382 value = * static_cast< const sal_Int8 * >( rAny.pData );
383 return true;
384 }
385 return false;
386}
387// short
388
389template<>
390inline bool SAL_CALL operator >>= ( const Any & rAny, sal_Int16 & value )
391{
392 switch (rAny.pType->eTypeClass)
393 {
394 case typelib_TypeClass_BYTE:
395 value = * static_cast< const sal_Int8 * >( rAny.pData );
396 return true;
397 case typelib_TypeClass_SHORT:
398 case typelib_TypeClass_UNSIGNED_SHORT:
399 value = * static_cast< const sal_Int16 * >( rAny.pData );
400 return true;
401 default:
402 return false;
403 }
404}
405
406template<>
407inline bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt16 & value )
408{
409 switch (rAny.pType->eTypeClass)
410 {
411 case typelib_TypeClass_BYTE:
412 value = static_cast<sal_uInt16>( * static_cast< const sal_Int8 * >( rAny.pData ) );
413 return true;
414 case typelib_TypeClass_SHORT:
415 case typelib_TypeClass_UNSIGNED_SHORT:
416 value = * static_cast< const sal_uInt16 * >( rAny.pData );
417 return true;
418 default:
419 return false;
420 }
421}
422// long
423
424template<>
425inline bool SAL_CALL operator >>= ( const Any & rAny, sal_Int32 & value )
426{
427 switch (rAny.pType->eTypeClass)
428 {
429 case typelib_TypeClass_BYTE:
430 value = * static_cast< const sal_Int8 * >( rAny.pData );
431 return true;
432 case typelib_TypeClass_SHORT:
433 value = * static_cast< const sal_Int16 * >( rAny.pData );
434 return true;
435 case typelib_TypeClass_UNSIGNED_SHORT:
436 value = * static_cast< const sal_uInt16 * >( rAny.pData );
437 return true;
438 case typelib_TypeClass_LONG:
439 case typelib_TypeClass_UNSIGNED_LONG:
440 value = * static_cast< const sal_Int32 * >( rAny.pData );
441 return true;
442 default:
443 return false;
444 }
445}
446
447template<>
448inline bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt32 & value )
449{
450 switch (rAny.pType->eTypeClass)
451 {
452 case typelib_TypeClass_BYTE:
453 value = static_cast<sal_uInt32>( * static_cast< const sal_Int8 * >( rAny.pData ) );
454 return true;
455 case typelib_TypeClass_SHORT:
456 value = static_cast<sal_uInt32>( * static_cast< const sal_Int16 * >( rAny.pData ) );
457 return true;
458 case typelib_TypeClass_UNSIGNED_SHORT:
459 value = * static_cast< const sal_uInt16 * >( rAny.pData );
460 return true;
461 case typelib_TypeClass_LONG:
462 case typelib_TypeClass_UNSIGNED_LONG:
463 value = * static_cast< const sal_uInt32 * >( rAny.pData );
464 return true;
465 default:
466 return false;
467 }
468}
469// hyper
470
471template<>
472inline bool SAL_CALL operator >>= ( const Any & rAny, sal_Int64 & value )
473{
474 switch (rAny.pType->eTypeClass)
475 {
476 case typelib_TypeClass_BYTE:
477 value = * static_cast< const sal_Int8 * >( rAny.pData );
478 return true;
479 case typelib_TypeClass_SHORT:
480 value = * static_cast< const sal_Int16 * >( rAny.pData );
481 return true;
482 case typelib_TypeClass_UNSIGNED_SHORT:
483 value = * static_cast< const sal_uInt16 * >( rAny.pData );
484 return true;
485 case typelib_TypeClass_LONG:
486 value = * static_cast< const sal_Int32 * >( rAny.pData );
487 return true;
488 case typelib_TypeClass_UNSIGNED_LONG:
489 value = * static_cast< const sal_uInt32 * >( rAny.pData );
490 return true;
491 case typelib_TypeClass_HYPER:
492 case typelib_TypeClass_UNSIGNED_HYPER:
493 value = * static_cast< const sal_Int64 * >( rAny.pData );
494 return true;
495 default:
496 return false;
497 }
498}
499
500template<>
501inline bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt64 & value )
502{
503 switch (rAny.pType->eTypeClass)
504 {
505 case typelib_TypeClass_BYTE:
506 value = static_cast<sal_uInt64>( * static_cast< const sal_Int8 * >( rAny.pData ) );
507 return true;
508 case typelib_TypeClass_SHORT:
509 value = static_cast<sal_uInt64>( * static_cast< const sal_Int16 * >( rAny.pData ) );
510 return true;
511 case typelib_TypeClass_UNSIGNED_SHORT:
512 value = * static_cast< const sal_uInt16 * >( rAny.pData );
513 return true;
514 case typelib_TypeClass_LONG:
515 value = static_cast<sal_uInt64>( * static_cast< const sal_Int32 * >( rAny.pData ) );
516 return true;
517 case typelib_TypeClass_UNSIGNED_LONG:
518 value = * static_cast< const sal_uInt32 * >( rAny.pData );
519 return true;
520 case typelib_TypeClass_HYPER:
521 case typelib_TypeClass_UNSIGNED_HYPER:
522 value = * static_cast< const sal_uInt64 * >( rAny.pData );
523 return true;
524 default:
525 return false;
526 }
527}
528// float
529
530template<>
531inline bool SAL_CALL operator >>= ( const Any & rAny, float & value )
532{
533 switch (rAny.pType->eTypeClass)
534 {
535 case typelib_TypeClass_BYTE:
536 value = * static_cast< const sal_Int8 * >( rAny.pData );
537 return true;
538 case typelib_TypeClass_SHORT:
539 value = * static_cast< const sal_Int16 * >( rAny.pData );
540 return true;
541 case typelib_TypeClass_UNSIGNED_SHORT:
542 value = * static_cast< const sal_uInt16 * >( rAny.pData );
543 return true;
544 case typelib_TypeClass_FLOAT:
545 value = * static_cast< const float * >( rAny.pData );
546 return true;
547 default:
548 return false;
549 }
550}
551// double
552
553template<>
554inline bool SAL_CALL operator >>= ( const Any & rAny, double & value )
555{
556 switch (rAny.pType->eTypeClass)
11
Control jumps to 'case typelib_TypeClass_DOUBLE:' at line 576
557 {
558 case typelib_TypeClass_BYTE:
559 value = * static_cast< const sal_Int8 * >( rAny.pData );
560 return true;
561 case typelib_TypeClass_SHORT:
562 value = * static_cast< const sal_Int16 * >( rAny.pData );
563 return true;
564 case typelib_TypeClass_UNSIGNED_SHORT:
565 value = * static_cast< const sal_uInt16 * >( rAny.pData );
566 return true;
567 case typelib_TypeClass_LONG:
568 value = * static_cast< const sal_Int32 * >( rAny.pData );
569 return true;
570 case typelib_TypeClass_UNSIGNED_LONG:
571 value = * static_cast< const sal_uInt32 * >( rAny.pData );
572 return true;
573 case typelib_TypeClass_FLOAT:
574 value = * static_cast< const float * >( rAny.pData );
575 return true;
576 case typelib_TypeClass_DOUBLE:
577 value = * static_cast< const double * >( rAny.pData );
12
Dereference of null pointer
578 return true;
579 default:
580 return false;
581 }
582}
583// string
584
585template<>
586inline bool SAL_CALL operator >>= ( const Any & rAny, ::rtl::OUString & value )
587{
588 if (typelib_TypeClass_STRING == rAny.pType->eTypeClass)
589 {
590 value = * static_cast< const ::rtl::OUString * >( rAny.pData );
591 return true;
592 }
593 return false;
594}
595
596template<>
597inline bool SAL_CALL operator == ( const Any & rAny, const ::rtl::OUString & value )
598{
599 return (typelib_TypeClass_STRING == rAny.pType->eTypeClass &&
600 value == * static_cast< const ::rtl::OUString * >( rAny.pData ) );
601}
602// type
603
604template<>
605inline bool SAL_CALL operator >>= ( const Any & rAny, Type & value )
606{
607 if (typelib_TypeClass_TYPE == rAny.pType->eTypeClass)
608 {
609 value = * static_cast< const Type * >( rAny.pData );
610 return true;
611 }
612 return false;
613}
614
615template<>
616inline bool SAL_CALL operator == ( const Any & rAny, const Type & value )
617{
618 return (typelib_TypeClass_TYPE == rAny.pType->eTypeClass &&
619 value.equals( * static_cast< const Type * >( rAny.pData ) ));
620}
621// any
622
623#if defined LIBO_INTERNAL_ONLY1
624template<> bool SAL_CALL operator >>=(Any const &, Any &) = delete;
625#else
626template<>
627inline bool SAL_CALL operator >>= ( const Any & rAny, Any & value )
628{
629 if (&rAny != &value)
630 {
631 ::uno_type_any_assign(
632 &value, rAny.pData, rAny.pType,
633 cpp_acquire, cpp_release );
634 }
635 return true;
636}
637#endif
638// interface
639
640template<>
641inline bool SAL_CALL operator == ( const Any & rAny, const BaseReference & value )
642{
643 if (typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass)
644 {
645 return static_cast< const BaseReference * >( rAny.pData )->operator == ( value );
646 }
647 return false;
648}
649
650// operator to compare to an any.
651
652template< class C >
653inline bool SAL_CALL operator == ( const Any & rAny, const C & value )
654{
655 const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
656 return ::uno_type_equalData(
657 rAny.pData, rAny.pType,
658 const_cast< C * >( &value ), rType.getTypeLibType(),
659 cpp_queryInterface, cpp_release );
660}
661// operator to compare to an any. may use specialized operators ==.
662
663template< class C >
664inline bool SAL_CALL operator != ( const Any & rAny, const C & value )
665{
666 return (! operator == ( rAny, value ));
667}
668
669template <typename T>
670T Any::get() const
671{
672 T value = T();
673 if (! (*this >>= value)) {
674 throw RuntimeException(
675 ::rtl::OUString(
676 cppu_Any_extraction_failure_msg(
677 this,
678 ::cppu::getTypeFavourUnsigned(&value).getTypeLibType() ),
679 SAL_NO_ACQUIRE ) );
680 }
681 return value;
682}
683
684#if defined LIBO_INTERNAL_ONLY1
685template<> Any Any::get() const = delete;
686#endif
687
688/**
689 Support for Any in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO
690 macros, for example).
691
692 @since LibreOffice 4.2
693*/
694template<typename charT, typename traits>
695inline std::basic_ostream<charT, traits> &operator<<(std::basic_ostream<charT, traits> &o, Any const &any) {
696 o << "<Any: (" << any.getValueTypeName() << ')';
697 switch(any.pType->eTypeClass) {
698 case typelib_TypeClass_VOID:
699 break;
700 case typelib_TypeClass_BOOLEAN:
701 o << ' ' << any.get<bool>();
702 break;
703 case typelib_TypeClass_BYTE:
704 case typelib_TypeClass_SHORT:
705 case typelib_TypeClass_LONG:
706 case typelib_TypeClass_HYPER:
707 o << ' ' << any.get<sal_Int64>();
708 break;
709 case typelib_TypeClass_UNSIGNED_SHORT:
710 case typelib_TypeClass_UNSIGNED_LONG:
711 case typelib_TypeClass_UNSIGNED_HYPER:
712 o << ' ' << any.get<sal_uInt64>();
713 break;
714 case typelib_TypeClass_FLOAT:
715 case typelib_TypeClass_DOUBLE:
716 o << ' ' << any.get<double>();
717 break;
718 case typelib_TypeClass_CHAR: {
719 std::ios_base::fmtflags flgs = o.setf(
720 std::ios_base::hex, std::ios_base::basefield);
721 charT fill = o.fill('0');
722 o << " U+" << std::setw(4)
723 << unsigned(*static_cast<sal_Unicode const *>(any.getValue()));
724 o.setf(flgs);
725 o.fill(fill);
726 break;
727 }
728 case typelib_TypeClass_STRING:
729 o << ' ' << any.get<rtl::OUString>();
730 break;
731 case typelib_TypeClass_TYPE:
732 o << ' ' << any.get<css::uno::Type>().getTypeName();
733 break;
734 case typelib_TypeClass_SEQUENCE:
735 o << " len "
736 << ((*static_cast<uno_Sequence * const *>(any.getValue()))->
737 nElements);
738 break;
739 case typelib_TypeClass_ENUM:
740 o << ' ' << *static_cast<sal_Int32 const *>(any.getValue());
741 break;
742 case typelib_TypeClass_STRUCT:
743 case typelib_TypeClass_EXCEPTION:
744 o << ' ' << any.getValue();
745 break;
746 case typelib_TypeClass_INTERFACE:
747 o << ' ' << *static_cast<void * const *>(any.getValue());
748 break;
749 default:
750 assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail (
"false", "/home/maarten/src/libreoffice/core/include/com/sun/star/uno/Any.hxx"
, 750, __extension__ __PRETTY_FUNCTION__))
; // this cannot happen
751 break;
752 }
753 o << '>';
754 return o;
755}
756
757}
758}
759}
760}
761
762#endif
763
764/* vim:set shiftwidth=4 softtabstop=4 expandtab: */