android: Update app-specific/MIME type icons
[LibreOffice.git] / writerfilter / source / dmapper / TextEffectsHandler.cxx
blob2a3deb5d0e87930ef5ed26bf850990bab2bfbb82
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #include <sal/config.h>
13 #include <map>
15 #include "TextEffectsHandler.hxx"
17 #include <rtl/ustrbuf.hxx>
18 #include <comphelper/string.hxx>
19 #include <ooxml/resourceids.hxx>
20 #include <comphelper/sequenceashashmap.hxx>
21 #include <oox/drawingml/drawingmltypes.hxx>
23 namespace writerfilter::dmapper
26 using namespace com::sun::star;
28 namespace
31 OUString lclGetNameForElementId(sal_uInt32 aId)
33 static std::map<sal_uInt32, OUString> aIdMap;
34 if(aIdMap.empty())
36 aIdMap[NS_ooxml::LN_EG_ColorChoice_srgbClr] = "srgbClr";
37 aIdMap[NS_ooxml::LN_EG_ColorChoice_schemeClr] = "schemeClr";
38 aIdMap[NS_ooxml::LN_EG_ColorTransform_tint] = "tint";
39 aIdMap[NS_ooxml::LN_EG_ColorTransform_shade] = "shade";
40 aIdMap[NS_ooxml::LN_EG_ColorTransform_alpha] = "alpha";
41 aIdMap[NS_ooxml::LN_EG_ColorTransform_hueMod] = "hueMod";
42 aIdMap[NS_ooxml::LN_EG_ColorTransform_sat] = "sat";
43 aIdMap[NS_ooxml::LN_EG_ColorTransform_satOff] = "satOff";
44 aIdMap[NS_ooxml::LN_EG_ColorTransform_satMod] = "satMod";
45 aIdMap[NS_ooxml::LN_EG_ColorTransform_lum] = "lum";
46 aIdMap[NS_ooxml::LN_EG_ColorTransform_lumOff] = "lumOff";
47 aIdMap[NS_ooxml::LN_EG_ColorTransform_lumMod] = "lumMod";
48 aIdMap[NS_ooxml::LN_EG_FillProperties_noFill] = "noFill";
49 aIdMap[NS_ooxml::LN_EG_FillProperties_solidFill] = "solidFill";
50 aIdMap[NS_ooxml::LN_EG_FillProperties_gradFill] = "gradFill";
51 aIdMap[NS_ooxml::LN_CT_GradientFillProperties_gsLst] = "gsLst";
52 aIdMap[NS_ooxml::LN_CT_GradientStopList_gs] = "gs";
53 aIdMap[NS_ooxml::LN_CT_GradientStop_pos] = "pos";
54 aIdMap[NS_ooxml::LN_EG_ShadeProperties_lin] = "lin";
55 aIdMap[NS_ooxml::LN_EG_ShadeProperties_path] = "path";
56 aIdMap[NS_ooxml::LN_CT_PathShadeProperties_fillToRect] = "fillToRect";
57 aIdMap[NS_ooxml::LN_EG_LineDashProperties_prstDash] = "prstDash";
58 aIdMap[NS_ooxml::LN_EG_LineJoinProperties_round] = "round";
59 aIdMap[NS_ooxml::LN_EG_LineJoinProperties_bevel] = "bevel";
60 aIdMap[NS_ooxml::LN_EG_LineJoinProperties_miter] = "miter";
61 aIdMap[NS_ooxml::LN_CT_Scene3D_camera] = "camera";
62 aIdMap[NS_ooxml::LN_CT_Scene3D_lightRig] = "lightRig";
63 aIdMap[NS_ooxml::LN_CT_LightRig_rot] = "rot";
64 aIdMap[NS_ooxml::LN_CT_Props3D_bevelT] = "bevelT";
65 aIdMap[NS_ooxml::LN_CT_Props3D_bevelB] = "bevelB";
66 aIdMap[NS_ooxml::LN_CT_Props3D_extrusionClr] = "extrusionClr";
67 aIdMap[NS_ooxml::LN_CT_Props3D_contourClr] = "contourClr";
68 aIdMap[NS_ooxml::LN_CT_StylisticSets_styleSet] = "styleSet";
69 aIdMap[NS_ooxml::LN_cntxtAlts_cntxtAlts] = "cntxtAlts";
71 return aIdMap[aId];
74 constexpr OUStringLiteral constAttributesSequenceName = u"attributes";
78 OUString TextEffectsHandler::getSchemeColorValTypeString(sal_Int32 nType)
80 switch (nType)
82 case NS_ooxml::LN_ST_SchemeColorVal_bg1: return "bg1";
83 case NS_ooxml::LN_ST_SchemeColorVal_tx1: return "tx1";
84 case NS_ooxml::LN_ST_SchemeColorVal_bg2: return "bg2";
85 case NS_ooxml::LN_ST_SchemeColorVal_tx2: return "tx2";
86 case NS_ooxml::LN_ST_SchemeColorVal_accent1: return "accent1";
87 case NS_ooxml::LN_ST_SchemeColorVal_accent2: return "accent2";
88 case NS_ooxml::LN_ST_SchemeColorVal_accent3: return "accent3";
89 case NS_ooxml::LN_ST_SchemeColorVal_accent4: return "accent4";
90 case NS_ooxml::LN_ST_SchemeColorVal_accent5: return "accent5";
91 case NS_ooxml::LN_ST_SchemeColorVal_accent6: return "accent6";
92 case NS_ooxml::LN_ST_SchemeColorVal_hlink: return "hlink";
93 case NS_ooxml::LN_ST_SchemeColorVal_folHlink: return "folHlink";
94 case NS_ooxml::LN_ST_SchemeColorVal_dk1: return "dk1";
95 case NS_ooxml::LN_ST_SchemeColorVal_lt1: return "lt1";
96 case NS_ooxml::LN_ST_SchemeColorVal_dk2: return "dk2";
97 case NS_ooxml::LN_ST_SchemeColorVal_lt2: return "lt2";
98 case NS_ooxml::LN_ST_SchemeColorVal_phClr: return "phClr";
99 default: break;
101 return OUString();
104 OUString TextEffectsHandler::getRectAlignmentString(sal_Int32 nType)
106 switch (nType)
108 case NS_ooxml::LN_ST_RectAlignment_none: return "none";
109 case NS_ooxml::LN_ST_RectAlignment_tl: return "tl";
110 case NS_ooxml::LN_ST_RectAlignment_t: return "t";
111 case NS_ooxml::LN_ST_RectAlignment_tr: return "tr";
112 case NS_ooxml::LN_ST_RectAlignment_l: return "l";
113 case NS_ooxml::LN_ST_RectAlignment_ctr: return "ctr";
114 case NS_ooxml::LN_ST_RectAlignment_r: return "r";
115 case NS_ooxml::LN_ST_RectAlignment_bl: return "bl";
116 case NS_ooxml::LN_ST_RectAlignment_b: return "b";
117 case NS_ooxml::LN_ST_RectAlignment_br: return "br";
119 default: break;
121 return OUString();
124 OUString TextEffectsHandler::getLineCapString(sal_Int32 nType)
126 switch (nType)
128 case NS_ooxml::LN_ST_LineCap_rnd: return "rnd";
129 case NS_ooxml::LN_ST_LineCap_sq: return "sq";
130 case NS_ooxml::LN_ST_LineCap_flat: return "flat";
131 default: break;
133 return OUString();
136 OUString TextEffectsHandler::getCompoundLineString(sal_Int32 nType)
138 switch (nType)
140 case NS_ooxml::LN_ST_CompoundLine_sng: return "sng";
141 case NS_ooxml::LN_ST_CompoundLine_dbl: return "dbl";
142 case NS_ooxml::LN_ST_CompoundLine_thickThin: return "thickThin";
143 case NS_ooxml::LN_ST_CompoundLine_thinThick: return "thinThick";
144 case NS_ooxml::LN_ST_CompoundLine_tri: return "tri";
145 default: break;
147 return OUString();
150 OUString TextEffectsHandler::getPenAlignmentString(sal_Int32 nType)
152 switch (nType)
154 case NS_ooxml::LN_ST_PenAlignment_ctr: return "ctr";
155 case NS_ooxml::LN_ST_PenAlignment_in: return "in";
156 default: break;
158 return OUString();
161 OUString TextEffectsHandler::getOnOffString(sal_Int32 nType)
163 switch (nType)
165 case NS_ooxml::LN_ST_OnOff_true: return "true";
166 case NS_ooxml::LN_ST_OnOff_false: return "false";
167 case NS_ooxml::LN_ST_OnOff_1: return "1";
168 case NS_ooxml::LN_ST_OnOff_0: return "0";
169 default: break;
171 return OUString();
174 OUString TextEffectsHandler::getPathShadeTypeString(sal_Int32 nType)
176 switch (nType)
178 case NS_ooxml::LN_ST_PathShadeType_shape: return "shape";
179 case NS_ooxml::LN_ST_PathShadeType_circle: return "circle";
180 case NS_ooxml::LN_ST_PathShadeType_rect: return "rect";
181 default: break;
183 return OUString();
186 OUString TextEffectsHandler::getPresetLineDashValString(sal_Int32 nType)
188 switch (nType)
190 case NS_ooxml::LN_ST_PresetLineDashVal_solid: return "solid";
191 case NS_ooxml::LN_ST_PresetLineDashVal_dot: return "dot";
192 case NS_ooxml::LN_ST_PresetLineDashVal_sysDot: return "sysDot";
193 case NS_ooxml::LN_ST_PresetLineDashVal_dash: return "dash";
194 case NS_ooxml::LN_ST_PresetLineDashVal_sysDash: return "sysDash";
195 case NS_ooxml::LN_ST_PresetLineDashVal_lgDash: return "lgDash";
196 case NS_ooxml::LN_ST_PresetLineDashVal_dashDot: return "dashDot";
197 case NS_ooxml::LN_ST_PresetLineDashVal_sysDashDot: return "sysDashDot";
198 case NS_ooxml::LN_ST_PresetLineDashVal_lgDashDot: return "lgDashDot";
199 case NS_ooxml::LN_ST_PresetLineDashVal_lgDashDotDot: return "lgDashDotDot";
200 case NS_ooxml::LN_ST_PresetLineDashVal_sysDashDotDot: return "sysDashDotDot";
201 default: break;
203 return OUString();
206 OUString TextEffectsHandler::getPresetCameraTypeString(sal_Int32 nType)
208 switch (nType)
210 case NS_ooxml::LN_ST_PresetCameraType_legacyObliqueTopLeft: return "legacyObliqueTopLeft";
211 case NS_ooxml::LN_ST_PresetCameraType_legacyObliqueTop: return "legacyObliqueTop";
212 case NS_ooxml::LN_ST_PresetCameraType_legacyObliqueTopRight: return "legacyObliqueTopRight";
213 case NS_ooxml::LN_ST_PresetCameraType_legacyObliqueLeft: return "legacyObliqueLeft";
214 case NS_ooxml::LN_ST_PresetCameraType_legacyObliqueFront: return "legacyObliqueFront";
215 case NS_ooxml::LN_ST_PresetCameraType_legacyObliqueRight: return "legacyObliqueRight";
216 case NS_ooxml::LN_ST_PresetCameraType_legacyObliqueBottomLeft: return "legacyObliqueBottomLeft";
217 case NS_ooxml::LN_ST_PresetCameraType_legacyObliqueBottom: return "legacyObliqueBottom";
218 case NS_ooxml::LN_ST_PresetCameraType_legacyObliqueBottomRight: return "legacyObliqueBottomRight";
219 case NS_ooxml::LN_ST_PresetCameraType_legacyPerspectiveTopLeft: return "legacyPerspectiveTopLeft";
220 case NS_ooxml::LN_ST_PresetCameraType_legacyPerspectiveTop: return "legacyPerspectiveTop";
221 case NS_ooxml::LN_ST_PresetCameraType_legacyPerspectiveTopRight: return "legacyPerspectiveTopRight";
222 case NS_ooxml::LN_ST_PresetCameraType_legacyPerspectiveLeft: return "legacyPerspectiveLeft";
223 case NS_ooxml::LN_ST_PresetCameraType_legacyPerspectiveFront: return "legacyPerspectiveFront";
224 case NS_ooxml::LN_ST_PresetCameraType_legacyPerspectiveRight: return "legacyPerspectiveRight";
225 case NS_ooxml::LN_ST_PresetCameraType_legacyPerspectiveBottomLeft: return "legacyPerspectiveBottomLeft";
226 case NS_ooxml::LN_ST_PresetCameraType_legacyPerspectiveBottom: return "legacyPerspectiveBottom";
227 case NS_ooxml::LN_ST_PresetCameraType_legacyPerspectiveBottomRight: return "legacyPerspectiveBottomRight";
228 case NS_ooxml::LN_ST_PresetCameraType_orthographicFront: return "orthographicFront";
229 case NS_ooxml::LN_ST_PresetCameraType_isometricTopUp: return "isometricTopUp";
230 case NS_ooxml::LN_ST_PresetCameraType_isometricTopDown: return "isometricTopDown";
231 case NS_ooxml::LN_ST_PresetCameraType_isometricBottomUp: return "isometricBottomUp";
232 case NS_ooxml::LN_ST_PresetCameraType_isometricBottomDown: return "isometricBottomDown";
233 case NS_ooxml::LN_ST_PresetCameraType_isometricLeftUp: return "isometricLeftUp";
234 case NS_ooxml::LN_ST_PresetCameraType_isometricLeftDown: return "isometricLeftDown";
235 case NS_ooxml::LN_ST_PresetCameraType_isometricRightUp: return "isometricRightUp";
236 case NS_ooxml::LN_ST_PresetCameraType_isometricRightDown: return "isometricRightDown";
237 case NS_ooxml::LN_ST_PresetCameraType_isometricOffAxis1Left: return "isometricOffAxis1Left";
238 case NS_ooxml::LN_ST_PresetCameraType_isometricOffAxis1Right: return "isometricOffAxis1Right";
239 case NS_ooxml::LN_ST_PresetCameraType_isometricOffAxis1Top: return "isometricOffAxis1Top";
240 case NS_ooxml::LN_ST_PresetCameraType_isometricOffAxis2Left: return "isometricOffAxis2Left";
241 case NS_ooxml::LN_ST_PresetCameraType_isometricOffAxis2Right: return "isometricOffAxis2Right";
242 case NS_ooxml::LN_ST_PresetCameraType_isometricOffAxis2Top: return "isometricOffAxis2Top";
243 case NS_ooxml::LN_ST_PresetCameraType_isometricOffAxis3Left: return "isometricOffAxis3Left";
244 case NS_ooxml::LN_ST_PresetCameraType_isometricOffAxis3Right: return "isometricOffAxis3Right";
245 case NS_ooxml::LN_ST_PresetCameraType_isometricOffAxis3Bottom: return "isometricOffAxis3Bottom";
246 case NS_ooxml::LN_ST_PresetCameraType_isometricOffAxis4Left: return "isometricOffAxis4Left";
247 case NS_ooxml::LN_ST_PresetCameraType_isometricOffAxis4Right: return "isometricOffAxis4Right";
248 case NS_ooxml::LN_ST_PresetCameraType_isometricOffAxis4Bottom: return "isometricOffAxis4Bottom";
249 case NS_ooxml::LN_ST_PresetCameraType_obliqueTopLeft: return "obliqueTopLeft";
250 case NS_ooxml::LN_ST_PresetCameraType_obliqueTop: return "obliqueTop";
251 case NS_ooxml::LN_ST_PresetCameraType_obliqueTopRight: return "obliqueTopRight";
252 case NS_ooxml::LN_ST_PresetCameraType_obliqueLeft: return "obliqueLeft";
253 case NS_ooxml::LN_ST_PresetCameraType_obliqueRight: return "obliqueRight";
254 case NS_ooxml::LN_ST_PresetCameraType_obliqueBottomLeft: return "obliqueBottomLeft";
255 case NS_ooxml::LN_ST_PresetCameraType_obliqueBottom: return "obliqueBottom";
256 case NS_ooxml::LN_ST_PresetCameraType_obliqueBottomRight: return "obliqueBottomRight";
257 case NS_ooxml::LN_ST_PresetCameraType_perspectiveFront: return "perspectiveFront";
258 case NS_ooxml::LN_ST_PresetCameraType_perspectiveLeft: return "perspectiveLeft";
259 case NS_ooxml::LN_ST_PresetCameraType_perspectiveRight: return "perspectiveRight";
260 case NS_ooxml::LN_ST_PresetCameraType_perspectiveAbove: return "perspectiveAbove";
261 case NS_ooxml::LN_ST_PresetCameraType_perspectiveBelow: return "perspectiveBelow";
262 case NS_ooxml::LN_ST_PresetCameraType_perspectiveAboveLeftFacing: return "perspectiveAboveLeftFacing";
263 case NS_ooxml::LN_ST_PresetCameraType_perspectiveAboveRightFacing: return "perspectiveAboveRightFacing";
264 case NS_ooxml::LN_ST_PresetCameraType_perspectiveContrastingLeftFacing: return "perspectiveContrastingLeftFacing";
265 case NS_ooxml::LN_ST_PresetCameraType_perspectiveContrastingRightFacing: return "perspectiveContrastingRightFacing";
266 case NS_ooxml::LN_ST_PresetCameraType_perspectiveHeroicLeftFacing: return "perspectiveHeroicLeftFacing";
267 case NS_ooxml::LN_ST_PresetCameraType_perspectiveHeroicRightFacing: return "perspectiveHeroicRightFacing";
268 case NS_ooxml::LN_ST_PresetCameraType_perspectiveHeroicExtremeLeftFacing: return "perspectiveHeroicExtremeLeftFacing";
269 case NS_ooxml::LN_ST_PresetCameraType_perspectiveHeroicExtremeRightFacing: return "perspectiveHeroicExtremeRightFacing";
270 case NS_ooxml::LN_ST_PresetCameraType_perspectiveRelaxed: return "perspectiveRelaxed";
271 case NS_ooxml::LN_ST_PresetCameraType_perspectiveRelaxedModerately: return "perspectiveRelaxedModerately";
272 default: break;
274 return OUString();
278 OUString TextEffectsHandler::getLightRigTypeString(sal_Int32 nType)
280 switch (nType)
282 case NS_ooxml::LN_ST_LightRigType_legacyFlat1: return "legacyFlat1";
283 case NS_ooxml::LN_ST_LightRigType_legacyFlat2: return "legacyFlat2";
284 case NS_ooxml::LN_ST_LightRigType_legacyFlat3: return "legacyFlat3";
285 case NS_ooxml::LN_ST_LightRigType_legacyFlat4: return "legacyFlat4";
286 case NS_ooxml::LN_ST_LightRigType_legacyNormal1: return "legacyNormal1";
287 case NS_ooxml::LN_ST_LightRigType_legacyNormal2: return "legacyNormal2";
288 case NS_ooxml::LN_ST_LightRigType_legacyNormal3: return "legacyNormal3";
289 case NS_ooxml::LN_ST_LightRigType_legacyNormal4: return "legacyNormal4";
290 case NS_ooxml::LN_ST_LightRigType_legacyHarsh1: return "legacyHarsh1";
291 case NS_ooxml::LN_ST_LightRigType_legacyHarsh2: return "legacyHarsh2";
292 case NS_ooxml::LN_ST_LightRigType_legacyHarsh3: return "legacyHarsh3";
293 case NS_ooxml::LN_ST_LightRigType_legacyHarsh4: return "legacyHarsh4";
294 case NS_ooxml::LN_ST_LightRigType_threePt: return "threePt";
295 case NS_ooxml::LN_ST_LightRigType_balanced: return "balanced";
296 case NS_ooxml::LN_ST_LightRigType_soft: return "soft";
297 case NS_ooxml::LN_ST_LightRigType_harsh: return "harsh";
298 case NS_ooxml::LN_ST_LightRigType_flood: return "flood";
299 case NS_ooxml::LN_ST_LightRigType_contrasting: return "contrasting";
300 case NS_ooxml::LN_ST_LightRigType_morning: return "morning";
301 case NS_ooxml::LN_ST_LightRigType_sunrise: return "sunrise";
302 case NS_ooxml::LN_ST_LightRigType_sunset: return "sunset";
303 case NS_ooxml::LN_ST_LightRigType_chilly: return "chilly";
304 case NS_ooxml::LN_ST_LightRigType_freezing: return "freezing";
305 case NS_ooxml::LN_ST_LightRigType_flat: return "flat";
306 case NS_ooxml::LN_ST_LightRigType_twoPt: return "twoPt";
307 case NS_ooxml::LN_ST_LightRigType_glow: return "glow";
308 case NS_ooxml::LN_ST_LightRigType_brightRoom: return "brightRoom";
309 default: break;
311 return OUString();
314 OUString TextEffectsHandler::getLightRigDirectionString(sal_Int32 nType)
316 switch (nType)
318 case NS_ooxml::LN_ST_LightRigDirection_tl: return "tl";
319 case NS_ooxml::LN_ST_LightRigDirection_t: return "t";
320 case NS_ooxml::LN_ST_LightRigDirection_tr: return "tr";
321 case NS_ooxml::LN_ST_LightRigDirection_l: return "l";
322 case NS_ooxml::LN_ST_LightRigDirection_r: return "r";
323 case NS_ooxml::LN_ST_LightRigDirection_bl: return "bl";
324 case NS_ooxml::LN_ST_LightRigDirection_b: return "b";
325 case NS_ooxml::LN_ST_LightRigDirection_br: return "br";
327 default: break;
329 return OUString();
332 OUString TextEffectsHandler::getBevelPresetTypeString(sal_Int32 nType)
334 switch (nType)
336 case NS_ooxml::LN_ST_BevelPresetType_relaxedInset: return "relaxedInset";
337 case NS_ooxml::LN_ST_BevelPresetType_circle: return "circle";
338 case NS_ooxml::LN_ST_BevelPresetType_slope: return "slope";
339 case NS_ooxml::LN_ST_BevelPresetType_cross: return "cross";
340 case NS_ooxml::LN_ST_BevelPresetType_angle: return "angle";
341 case NS_ooxml::LN_ST_BevelPresetType_softRound: return "softRound";
342 case NS_ooxml::LN_ST_BevelPresetType_convex: return "convex";
343 case NS_ooxml::LN_ST_BevelPresetType_coolSlant: return "coolSlant";
344 case NS_ooxml::LN_ST_BevelPresetType_divot: return "divot";
345 case NS_ooxml::LN_ST_BevelPresetType_riblet: return "riblet";
346 case NS_ooxml::LN_ST_BevelPresetType_hardEdge: return "hardEdge";
347 case NS_ooxml::LN_ST_BevelPresetType_artDeco: return "artDeco";
348 default: break;
350 return OUString();
353 OUString TextEffectsHandler::getPresetMaterialTypeString(sal_Int32 nType)
355 switch (nType)
357 case NS_ooxml::LN_ST_PresetMaterialType_legacyMatte: return "legacyMatte";
358 case NS_ooxml::LN_ST_PresetMaterialType_legacyPlastic: return "legacyPlastic";
359 case NS_ooxml::LN_ST_PresetMaterialType_legacyMetal: return "legacyMetal";
360 case NS_ooxml::LN_ST_PresetMaterialType_legacyWireframe: return "legacyWireframe";
361 case NS_ooxml::LN_ST_PresetMaterialType_matte: return "matte";
362 case NS_ooxml::LN_ST_PresetMaterialType_plastic: return "plastic";
363 case NS_ooxml::LN_ST_PresetMaterialType_metal: return "metal";
364 case NS_ooxml::LN_ST_PresetMaterialType_warmMatte: return "warmMatte";
365 case NS_ooxml::LN_ST_PresetMaterialType_translucentPowder: return "translucentPowder";
366 case NS_ooxml::LN_ST_PresetMaterialType_powder: return "powder";
367 case NS_ooxml::LN_ST_PresetMaterialType_dkEdge: return "dkEdge";
368 case NS_ooxml::LN_ST_PresetMaterialType_softEdge: return "softEdge";
369 case NS_ooxml::LN_ST_PresetMaterialType_clear: return "clear";
370 case NS_ooxml::LN_ST_PresetMaterialType_flat: return "flat";
371 case NS_ooxml::LN_ST_PresetMaterialType_softmetal: return "softmetal";
372 case NS_ooxml::LN_ST_PresetMaterialType_none: return "none";
373 default: break;
375 return OUString();
378 OUString TextEffectsHandler::getLigaturesString(sal_Int32 nType)
380 switch (nType)
382 case NS_ooxml::LN_ST_Ligatures_none: return "none";
383 case NS_ooxml::LN_ST_Ligatures_standard: return "standard";
384 case NS_ooxml::LN_ST_Ligatures_contextual: return "contextual";
385 case NS_ooxml::LN_ST_Ligatures_historical: return "historical";
386 case NS_ooxml::LN_ST_Ligatures_discretional: return "discretional";
387 case NS_ooxml::LN_ST_Ligatures_standardContextual: return "standardContextual";
388 case NS_ooxml::LN_ST_Ligatures_standardHistorical: return "standardHistorical";
389 case NS_ooxml::LN_ST_Ligatures_contextualHistorical: return "contextualHistorical";
390 case NS_ooxml::LN_ST_Ligatures_standardDiscretional: return "standardDiscretional";
391 case NS_ooxml::LN_ST_Ligatures_contextualDiscretional: return "contextualDiscretional";
392 case NS_ooxml::LN_ST_Ligatures_historicalDiscretional: return "historicalDiscretional";
393 case NS_ooxml::LN_ST_Ligatures_standardContextualHistorical: return "standardContextualHistorical";
394 case NS_ooxml::LN_ST_Ligatures_standardContextualDiscretional: return "standardContextualDiscretional";
395 case NS_ooxml::LN_ST_Ligatures_standardHistoricalDiscretional: return "standardHistoricalDiscretional";
396 case NS_ooxml::LN_ST_Ligatures_contextualHistoricalDiscretional: return "contextualHistoricalDiscretional";
397 case NS_ooxml::LN_ST_Ligatures_all: return "all";
398 default: break;
400 return OUString();
403 OUString TextEffectsHandler::getNumFormString(sal_Int32 nType)
405 switch (nType)
407 case NS_ooxml::LN_ST_NumForm_default: return "default";
408 case NS_ooxml::LN_ST_NumForm_lining: return "lining";
409 case NS_ooxml::LN_ST_NumForm_oldStyle: return "oldStyle";
410 default: break;
412 return OUString();
415 OUString TextEffectsHandler::getNumSpacingString(sal_Int32 nType)
417 switch (nType)
419 case NS_ooxml::LN_ST_NumSpacing_default: return "default";
420 case NS_ooxml::LN_ST_NumSpacing_proportional: return "proportional";
421 case NS_ooxml::LN_ST_NumSpacing_tabular: return "tabular";
422 default: break;
424 return OUString();
427 void TextEffectsHandler::convertElementIdToPropertyId(sal_Int32 aElementId)
429 switch(aElementId)
431 case NS_ooxml::LN_glow_glow:
432 maPropertyId = PROP_CHAR_GLOW_TEXT_EFFECT;
433 maElementName = "glow";
434 break;
435 case NS_ooxml::LN_shadow_shadow:
436 maPropertyId = PROP_CHAR_SHADOW_TEXT_EFFECT;
437 maElementName = "shadow";
438 break;
439 case NS_ooxml::LN_reflection_reflection:
440 maPropertyId = PROP_CHAR_REFLECTION_TEXT_EFFECT;
441 maElementName = "reflection";
442 break;
443 case NS_ooxml::LN_textOutline_textOutline:
444 maPropertyId = PROP_CHAR_TEXTOUTLINE_TEXT_EFFECT;
445 maElementName = "textOutline";
446 break;
447 case NS_ooxml::LN_textFill_textFill:
448 maPropertyId = PROP_CHAR_TEXTFILL_TEXT_EFFECT;
449 maElementName = "textFill";
450 break;
451 case NS_ooxml::LN_scene3d_scene3d:
452 maPropertyId = PROP_CHAR_SCENE3D_TEXT_EFFECT;
453 maElementName = "scene3d";
454 break;
455 case NS_ooxml::LN_props3d_props3d:
456 maPropertyId = PROP_CHAR_PROPS3D_TEXT_EFFECT;
457 maElementName = "props3d";
458 break;
459 case NS_ooxml::LN_ligatures_ligatures:
460 maPropertyId = PROP_CHAR_LIGATURES_TEXT_EFFECT;
461 maElementName = "ligatures";
462 break;
463 case NS_ooxml::LN_numForm_numForm:
464 maPropertyId = PROP_CHAR_NUMFORM_TEXT_EFFECT;
465 maElementName = "numForm";
466 break;
467 case NS_ooxml::LN_numSpacing_numSpacing:
468 maPropertyId = PROP_CHAR_NUMSPACING_TEXT_EFFECT;
469 maElementName = "numSpacing";
470 break;
471 case NS_ooxml::LN_stylisticSets_stylisticSets:
472 maPropertyId = PROP_CHAR_STYLISTICSETS_TEXT_EFFECT;
473 maElementName = "stylisticSets";
474 break;
475 case NS_ooxml::LN_cntxtAlts_cntxtAlts:
476 maPropertyId = PROP_CHAR_CNTXTALTS_TEXT_EFFECT;
477 maElementName = "cntxtAlts";
478 break;
479 default:
480 break;
484 TextEffectsHandler::TextEffectsHandler(sal_uInt32 aElementId) :
485 LoggedProperties("TextEffectsHandler")
487 convertElementIdToPropertyId(aElementId);
488 mpGrabBagStack.reset(new oox::GrabBagStack(maElementName));
491 TextEffectsHandler::~TextEffectsHandler()
496 void TextEffectsHandler::lcl_attribute(Id aName, Value& aValue)
498 if (mpGrabBagStack->getCurrentName() != constAttributesSequenceName)
499 mpGrabBagStack->push(constAttributesSequenceName);
501 switch(aName)
503 case NS_ooxml::LN_CT_Percentage_val:
504 case NS_ooxml::LN_CT_PositiveFixedPercentage_val:
505 case NS_ooxml::LN_CT_PositivePercentage_val:
506 mpGrabBagStack->addInt32("val", sal_Int32(aValue.getInt()));
507 break;
508 case NS_ooxml::LN_CT_Glow_rad:
509 mpGrabBagStack->addInt32("rad", sal_Int32(aValue.getInt()));
510 break;
511 case NS_ooxml::LN_CT_SchemeColor_val:
513 OUString aString = getSchemeColorValTypeString(sal_Int32(aValue.getInt()));
514 mpGrabBagStack->addString("val", aString);
516 break;
517 case NS_ooxml::LN_CT_SRgbColor_val:
519 OUString aBuffer = OUString::number(aValue.getInt(), 16);
520 OUStringBuffer aString;
521 comphelper::string::padToLength(aString, 6 - aBuffer.getLength(), '0');
522 aString.append(aBuffer.getStr());
523 mpGrabBagStack->addString("val", aString.makeStringAndClear().toAsciiUpperCase());
525 break;
526 case NS_ooxml::LN_CT_Shadow_blurRad:
527 case NS_ooxml::LN_CT_Reflection_blurRad:
528 mpGrabBagStack->addInt32("blurRad", sal_Int32(aValue.getInt()));
529 break;
530 case NS_ooxml::LN_CT_Reflection_stA:
531 mpGrabBagStack->addInt32("stA", sal_Int32(aValue.getInt()));
532 break;
533 case NS_ooxml::LN_CT_Reflection_stPos:
534 mpGrabBagStack->addInt32("stPos", sal_Int32(aValue.getInt()));
535 break;
536 case NS_ooxml::LN_CT_Reflection_endA:
537 mpGrabBagStack->addInt32("endA", sal_Int32(aValue.getInt()));
538 break;
539 case NS_ooxml::LN_CT_Reflection_endPos:
540 mpGrabBagStack->addInt32("endPos", sal_Int32(aValue.getInt()));
541 break;
542 case NS_ooxml::LN_CT_Shadow_dist:
543 case NS_ooxml::LN_CT_Reflection_dist:
544 mpGrabBagStack->addInt32("dist", sal_Int32(aValue.getInt()));
545 break;
546 case NS_ooxml::LN_CT_Shadow_dir:
547 case NS_ooxml::LN_CT_Reflection_dir:
548 mpGrabBagStack->addInt32("dir", sal_Int32(aValue.getInt()));
549 break;
550 case NS_ooxml::LN_CT_Reflection_fadeDir:
551 mpGrabBagStack->addInt32("fadeDir", sal_Int32(aValue.getInt()));
552 break;
553 case NS_ooxml::LN_CT_Shadow_sx:
554 case NS_ooxml::LN_CT_Reflection_sx:
555 mpGrabBagStack->addInt32("sx", sal_Int32(aValue.getInt()));
556 break;
557 case NS_ooxml::LN_CT_Shadow_sy:
558 case NS_ooxml::LN_CT_Reflection_sy:
559 mpGrabBagStack->addInt32("sy", sal_Int32(aValue.getInt()));
560 break;
561 case NS_ooxml::LN_CT_Shadow_kx:
562 case NS_ooxml::LN_CT_Reflection_kx:
563 mpGrabBagStack->addInt32("kx", sal_Int32(aValue.getInt()));
564 break;
565 case NS_ooxml::LN_CT_Shadow_ky:
566 case NS_ooxml::LN_CT_Reflection_ky:
567 mpGrabBagStack->addInt32("ky", sal_Int32(aValue.getInt()));
568 break;
569 case NS_ooxml::LN_CT_Shadow_algn:
570 case NS_ooxml::LN_CT_Reflection_algn:
572 uno::Any aAny(getRectAlignmentString(sal_Int32(aValue.getInt())));
573 mpGrabBagStack->appendElement("algn", aAny);
575 break;
576 case NS_ooxml::LN_CT_TextOutlineEffect_w:
577 mpGrabBagStack->addInt32("w", sal_Int32(aValue.getInt()));
578 break;
579 case NS_ooxml::LN_CT_TextOutlineEffect_cap:
581 uno::Any aAny(getLineCapString(sal_Int32(aValue.getInt())));
582 mpGrabBagStack->appendElement("cap", aAny);
584 break;
585 case NS_ooxml::LN_CT_TextOutlineEffect_cmpd:
587 uno::Any aAny(getCompoundLineString(sal_Int32(aValue.getInt())));
588 mpGrabBagStack->appendElement("cmpd", aAny);
590 break;
591 case NS_ooxml::LN_CT_TextOutlineEffect_algn:
593 uno::Any aAny(getPenAlignmentString(sal_Int32(aValue.getInt())));
594 mpGrabBagStack->appendElement("algn", aAny);
596 break;
597 case NS_ooxml::LN_CT_GradientStop_pos:
598 mpGrabBagStack->addInt32("pos", sal_Int32(aValue.getInt()));
599 break;
600 case NS_ooxml::LN_CT_LinearShadeProperties_ang:
601 mpGrabBagStack->addInt32("ang", sal_Int32(aValue.getInt()));
602 break;
603 case NS_ooxml::LN_CT_LinearShadeProperties_scaled:
605 uno::Any aAny(getOnOffString(sal_Int32(aValue.getInt())));
606 mpGrabBagStack->appendElement("scaled", aAny);
608 break;
609 case NS_ooxml::LN_CT_PathShadeProperties_path:
611 uno::Any aAny(getPathShadeTypeString(sal_Int32(aValue.getInt())));
612 mpGrabBagStack->appendElement("path", aAny);
614 break;
615 case NS_ooxml::LN_CT_RelativeRect_l:
616 mpGrabBagStack->addInt32("l", sal_Int32(aValue.getInt()));
617 break;
618 case NS_ooxml::LN_CT_RelativeRect_t:
619 mpGrabBagStack->addInt32("t", sal_Int32(aValue.getInt()));
620 break;
621 case NS_ooxml::LN_CT_RelativeRect_r:
622 mpGrabBagStack->addInt32("r", sal_Int32(aValue.getInt()));
623 break;
624 case NS_ooxml::LN_CT_RelativeRect_b:
625 mpGrabBagStack->addInt32("b", sal_Int32(aValue.getInt()));
626 break;
627 case NS_ooxml::LN_CT_PresetLineDashProperties_val:
629 uno::Any aAny(getPresetLineDashValString(sal_Int32(aValue.getInt())));
630 mpGrabBagStack->appendElement("val", aAny);
632 break;
633 case NS_ooxml::LN_CT_LineJoinMiterProperties_lim:
634 mpGrabBagStack->addInt32("lim", sal_Int32(aValue.getInt()));
635 break;
636 case NS_ooxml::LN_CT_Camera_prst:
638 uno::Any aAny(getPresetCameraTypeString(sal_Int32(aValue.getInt())));
639 mpGrabBagStack->appendElement("prst", aAny);
641 break;
642 case NS_ooxml::LN_CT_LightRig_rig:
644 uno::Any aAny(getLightRigTypeString(sal_Int32(aValue.getInt())));
645 mpGrabBagStack->appendElement("rig", aAny);
647 break;
648 case NS_ooxml::LN_CT_LightRig_dir:
650 uno::Any aAny(getLightRigDirectionString(sal_Int32(aValue.getInt())));
651 mpGrabBagStack->appendElement("dir", aAny);
653 break;
654 case NS_ooxml::LN_CT_SphereCoords_lat:
655 mpGrabBagStack->addInt32("lat", sal_Int32(aValue.getInt()));
656 break;
657 case NS_ooxml::LN_CT_SphereCoords_lon:
658 mpGrabBagStack->addInt32("lon", sal_Int32(aValue.getInt()));
659 break;
660 case NS_ooxml::LN_CT_SphereCoords_rev:
661 mpGrabBagStack->addInt32("rev", sal_Int32(aValue.getInt()));
662 break;
663 case NS_ooxml::LN_CT_Props3D_extrusionH:
664 mpGrabBagStack->addInt32("extrusionH", sal_Int32(aValue.getInt()));
665 break;
666 case NS_ooxml::LN_CT_Props3D_contourW:
667 mpGrabBagStack->addInt32("contourW", sal_Int32(aValue.getInt()));
668 break;
669 case NS_ooxml::LN_CT_Props3D_prstMaterial:
671 uno::Any aAny(getPresetMaterialTypeString(sal_Int32(aValue.getInt())));
672 mpGrabBagStack->appendElement("prstMaterial", aAny);
674 break;
675 case NS_ooxml::LN_CT_Bevel_w:
676 mpGrabBagStack->addInt32("w", sal_Int32(aValue.getInt()));
677 break;
678 case NS_ooxml::LN_CT_Bevel_h:
679 mpGrabBagStack->addInt32("h", sal_Int32(aValue.getInt()));
680 break;
681 case NS_ooxml::LN_CT_Bevel_prst:
683 uno::Any aAny(getBevelPresetTypeString(sal_Int32(aValue.getInt())));
684 mpGrabBagStack->appendElement("prst", aAny);
686 break;
687 case NS_ooxml::LN_CT_Ligatures_val:
689 uno::Any aAny(getLigaturesString(sal_Int32(aValue.getInt())));
690 mpGrabBagStack->appendElement("val", aAny);
692 break;
693 case NS_ooxml::LN_CT_NumForm_val:
695 uno::Any aAny(getNumFormString(sal_Int32(aValue.getInt())));
696 mpGrabBagStack->appendElement("val", aAny);
698 break;
699 case NS_ooxml::LN_CT_NumSpacing_val:
701 uno::Any aAny(getNumSpacingString(sal_Int32(aValue.getInt())));
702 mpGrabBagStack->appendElement("val", aAny);
704 break;
705 case NS_ooxml::LN_CT_StyleSet_id:
706 mpGrabBagStack->addInt32("id", sal_Int32(aValue.getInt()));
707 break;
708 case NS_ooxml::LN_CT_StyleSet_val:
709 case NS_ooxml::LN_CT_OnOff_val:
711 uno::Any aAny(getOnOffString(sal_Int32(aValue.getInt())));
712 mpGrabBagStack->appendElement("val", aAny);
714 break;
715 default:
716 break;
720 void TextEffectsHandler::lcl_sprm(Sprm& rSprm)
722 if (mpGrabBagStack->getCurrentName() == constAttributesSequenceName)
723 mpGrabBagStack->pop();
725 sal_uInt32 nSprmId = rSprm.getId();
726 OUString aElementName = lclGetNameForElementId(nSprmId);
727 if(aElementName.isEmpty())
729 // Element is unknown -> leave.
730 return;
733 mpGrabBagStack->push(aElementName);
735 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
736 if( !pProperties )
737 return;
739 pProperties->resolve( *this );
741 if (mpGrabBagStack->getCurrentName() == constAttributesSequenceName)
742 mpGrabBagStack->pop();
744 mpGrabBagStack->pop();
747 beans::PropertyValue TextEffectsHandler::getInteropGrabBag()
749 beans::PropertyValue aReturn = mpGrabBagStack->getRootProperty();
750 mpGrabBagStack.reset();
751 return aReturn;
754 sal_uInt8 TextEffectsHandler::GetTextFillSolidFillAlpha(const css::beans::PropertyValue& rValue)
756 if (rValue.Name != "textFill")
758 return 0;
761 uno::Sequence<beans::PropertyValue> aPropertyValues;
762 rValue.Value >>= aPropertyValues;
763 comphelper::SequenceAsHashMap aMap(aPropertyValues);
764 auto it = aMap.find("solidFill");
765 if (it == aMap.end())
767 return 0;
770 comphelper::SequenceAsHashMap aSolidFillMap(it->second);
771 it = aSolidFillMap.find("srgbClr");
772 if (it == aSolidFillMap.end())
774 it = aSolidFillMap.find("schemeClr");
775 if (it == aSolidFillMap.end())
776 return 0;
779 comphelper::SequenceAsHashMap aSrgbClrMap(it->second);
780 it = aSrgbClrMap.find("alpha");
781 if (it == aSrgbClrMap.end())
783 return 0;
786 comphelper::SequenceAsHashMap aAlphaMap(it->second);
787 it = aAlphaMap.find("attributes");
788 if (it == aAlphaMap.end())
790 return 0;
793 comphelper::SequenceAsHashMap aAttributesMap(it->second);
794 it = aAttributesMap.find("val");
795 if (it == aAttributesMap.end())
797 return 0;
799 sal_Int32 nVal = 0;
800 it->second >>= nVal;
801 return nVal / oox::drawingml::PER_PERCENT;
804 } // namespace
806 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */