1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <EnhancedCustomShapeToken.hxx>
21 #include <xmloff/xmlimp.hxx>
22 #include <unordered_map>
25 namespace xmloff::EnhancedCustomShapeToken
{
33 EnhancedCustomShapeTokenEnum pE
;
38 constexpr TokenTable pTokenTableArray
[] =
40 { u
"type"_ustr
, EAS_type
},
41 { u
"name"_ustr
, EAS_name
},
42 { u
"mirror-horizontal"_ustr
, EAS_mirror_horizontal
},
43 { u
"mirror-vertical"_ustr
, EAS_mirror_vertical
},
44 { u
"viewBox"_ustr
, EAS_viewBox
},
45 { u
"text-rotate-angle"_ustr
, EAS_text_rotate_angle
},
46 { u
"extrusion-allowed"_ustr
, EAS_extrusion_allowed
},
47 { u
"extrusion-text-path-allowed"_ustr
, EAS_text_path_allowed
},
48 { u
"extrusion-concentric-gradient-fill"_ustr
, EAS_concentric_gradient_fill_allowed
},
49 { u
"extrusion"_ustr
, EAS_extrusion
},
50 { u
"extrusion-brightness"_ustr
, EAS_extrusion_brightness
},
51 { u
"extrusion-depth"_ustr
, EAS_extrusion_depth
},
52 { u
"extrusion-diffusion"_ustr
, EAS_extrusion_diffusion
},
53 { u
"extrusion-number-of-line-segments"_ustr
, EAS_extrusion_number_of_line_segments
},
54 { u
"extrusion-light-face"_ustr
, EAS_extrusion_light_face
},
55 { u
"extrusion-first-light-harsh"_ustr
, EAS_extrusion_first_light_harsh
},
56 { u
"extrusion-second-light-harsh"_ustr
, EAS_extrusion_second_light_harsh
},
57 { u
"extrusion-first-light-level"_ustr
, EAS_extrusion_first_light_level
},
58 { u
"extrusion-second-light-level"_ustr
, EAS_extrusion_second_light_level
},
59 { u
"extrusion-first-light-direction"_ustr
, EAS_extrusion_first_light_direction
},
60 { u
"extrusion-second-light-direction"_ustr
, EAS_extrusion_second_light_direction
},
61 { u
"extrusion-metal"_ustr
, EAS_extrusion_metal
},
62 { u
"extrusion-metal-type"_ustr
, EAS_extrusion_metal_type
},
63 { u
"shade-mode"_ustr
, EAS_shade_mode
},
64 { u
"extrusion-rotation-angle"_ustr
, EAS_extrusion_rotation_angle
},
65 { u
"extrusion-rotation-center"_ustr
, EAS_extrusion_rotation_center
},
66 { u
"extrusion-shininess"_ustr
, EAS_extrusion_shininess
},
67 { u
"extrusion-skew"_ustr
, EAS_extrusion_skew
},
68 { u
"extrusion-specularity"_ustr
, EAS_extrusion_specularity
},
69 { u
"extrusion-specularity-loext"_ustr
, EAS_extrusion_specularity_loext
},
70 { u
"projection"_ustr
, EAS_projection
},
71 { u
"extrusion-viewpoint"_ustr
, EAS_extrusion_viewpoint
},
72 { u
"extrusion-origin"_ustr
, EAS_extrusion_origin
},
73 { u
"extrusion-color"_ustr
, EAS_extrusion_color
},
74 { u
"enhanced-path"_ustr
, EAS_enhanced_path
},
75 { u
"path-stretchpoint-x"_ustr
, EAS_path_stretchpoint_x
},
76 { u
"path-stretchpoint-y"_ustr
, EAS_path_stretchpoint_y
},
77 { u
"text-areas"_ustr
, EAS_text_areas
},
78 { u
"glue-points"_ustr
, EAS_glue_points
},
79 { u
"glue-point-type"_ustr
, EAS_glue_point_type
},
80 { u
"glue-point-leaving-directions"_ustr
, EAS_glue_point_leaving_directions
},
81 { u
"text-path"_ustr
, EAS_text_path
},
82 { u
"text-path-mode"_ustr
, EAS_text_path_mode
},
83 { u
"text-path-scale"_ustr
, EAS_text_path_scale
},
84 { u
"text-path-same-letter-heights"_ustr
, EAS_text_path_same_letter_heights
},
85 { u
"modifiers"_ustr
, EAS_modifiers
},
86 { u
"equation"_ustr
, EAS_equation
},
87 { u
"formula"_ustr
, EAS_formula
},
88 { u
"handle"_ustr
, EAS_handle
},
89 { u
"handle-mirror-horizontal"_ustr
, EAS_handle_mirror_horizontal
},
90 { u
"handle-mirror-vertical"_ustr
, EAS_handle_mirror_vertical
},
91 { u
"handle-switched"_ustr
, EAS_handle_switched
},
92 { u
"handle-position"_ustr
, EAS_handle_position
},
93 { u
"handle-position-x"_ustr
, EAS_handle_position_x
},
94 { u
"handle-position-y"_ustr
, EAS_handle_position_y
},
95 { u
"handle-range-x-minimum"_ustr
, EAS_handle_range_x_minimum
},
96 { u
"handle-range-x-maximum"_ustr
, EAS_handle_range_x_maximum
},
97 { u
"handle-range-y-minimum"_ustr
, EAS_handle_range_y_minimum
},
98 { u
"handle-range-y-maximum"_ustr
, EAS_handle_range_y_maximum
},
99 { u
"handle-polar"_ustr
, EAS_handle_polar
},
100 { u
"handle-polar-angle"_ustr
, EAS_handle_polar_angle
},
101 { u
"handle-polar-radius"_ustr
, EAS_handle_polar_radius
},
102 { u
"handle-polar-pole-x"_ustr
, EAS_handle_polar_pole_x
},
103 { u
"handle-polar-pole-y"_ustr
, EAS_handle_polar_pole_y
},
104 { u
"handle-radius-range-minimum"_ustr
, EAS_handle_radius_range_minimum
},
105 { u
"handle-radius-range-maximum"_ustr
, EAS_handle_radius_range_maximum
},
106 { u
"sub-view-size"_ustr
, EAS_sub_view_size
},
108 { u
"CustomShapeEngine"_ustr
, EAS_CustomShapeEngine
},
109 { u
"CustomShapeData"_ustr
, EAS_CustomShapeData
},
110 { u
"Type"_ustr
, EAS_Type
},
111 { u
"MirroredX"_ustr
, EAS_MirroredX
},
112 { u
"MirroredY"_ustr
, EAS_MirroredY
},
113 { u
"ViewBox"_ustr
, EAS_ViewBox
},
114 { u
"TextRotateAngle"_ustr
, EAS_TextRotateAngle
},
115 { u
"TextPreRotateAngle"_ustr
, EAS_TextPreRotateAngle
},
116 { u
"ExtrusionAllowed"_ustr
, EAS_ExtrusionAllowed
},
117 { u
"TextPathAllowed"_ustr
, EAS_TextPathAllowed
},
118 { u
"ConcentricGradientFillAllowed"_ustr
, EAS_ConcentricGradientFillAllowed
},
119 { u
"Extrusion"_ustr
, EAS_Extrusion
},
120 { u
"Equations"_ustr
, EAS_Equations
},
121 { u
"Equation"_ustr
, EAS_Equation
},
122 { u
"Path"_ustr
, EAS_Path
},
123 { u
"TextPath"_ustr
, EAS_TextPath
},
124 { u
"Handles"_ustr
, EAS_Handles
},
125 { u
"Handle"_ustr
, EAS_Handle
},
126 { u
"Brightness"_ustr
, EAS_Brightness
},
127 { u
"Depth"_ustr
, EAS_Depth
},
128 { u
"Diffusion"_ustr
, EAS_Diffusion
},
129 { u
"NumberOfLineSegments"_ustr
, EAS_NumberOfLineSegments
},
130 { u
"LightFace"_ustr
, EAS_LightFace
},
131 { u
"FirstLightHarsh"_ustr
, EAS_FirstLightHarsh
},
132 { u
"SecondLightHarsh"_ustr
, EAS_SecondLightHarsh
},
133 { u
"FirstLightLevel"_ustr
, EAS_FirstLightLevel
},
134 { u
"SecondLightLevel"_ustr
, EAS_SecondLightLevel
},
135 { u
"FirstLightDirection"_ustr
, EAS_FirstLightDirection
},
136 { u
"SecondLightDirection"_ustr
, EAS_SecondLightDirection
},
137 { u
"Metal"_ustr
, EAS_Metal
},
138 { u
"MetalType"_ustr
, EAS_MetalType
},
139 { u
"ShadeMode"_ustr
, EAS_ShadeMode
},
140 { u
"RotateAngle"_ustr
, EAS_RotateAngle
},
141 { u
"RotationCenter"_ustr
, EAS_RotationCenter
},
142 { u
"Shininess"_ustr
, EAS_Shininess
},
143 { u
"Skew"_ustr
, EAS_Skew
},
144 { u
"Specularity"_ustr
, EAS_Specularity
},
145 { u
"ProjectionMode"_ustr
, EAS_ProjectionMode
},
146 { u
"ViewPoint"_ustr
, EAS_ViewPoint
},
147 { u
"Origin"_ustr
, EAS_Origin
},
148 { u
"Color"_ustr
, EAS_Color
},
149 { u
"Switched"_ustr
, EAS_Switched
},
150 { u
"Polar"_ustr
, EAS_Polar
},
151 { u
"RangeXMinimum"_ustr
, EAS_RangeXMinimum
},
152 { u
"RangeXMaximum"_ustr
, EAS_RangeXMaximum
},
153 { u
"RangeYMinimum"_ustr
, EAS_RangeYMinimum
},
154 { u
"RangeYMaximum"_ustr
, EAS_RangeYMaximum
},
155 { u
"RadiusRangeMinimum"_ustr
, EAS_RadiusRangeMinimum
},
156 { u
"RadiusRangeMaximum"_ustr
, EAS_RadiusRangeMaximum
},
157 { u
"Coordinates"_ustr
, EAS_Coordinates
},
158 { u
"Segments"_ustr
, EAS_Segments
},
159 { u
"StretchX"_ustr
, EAS_StretchX
},
160 { u
"StretchY"_ustr
, EAS_StretchY
},
161 { u
"TextFrames"_ustr
, EAS_TextFrames
},
162 { u
"GluePoints"_ustr
, EAS_GluePoints
},
163 { u
"GluePointLeavingDirections"_ustr
, EAS_GluePointLeavingDirections
},
164 { u
"GluePointType"_ustr
, EAS_GluePointType
},
165 { u
"TextPathMode"_ustr
, EAS_TextPathMode
},
166 { u
"ScaleX"_ustr
, EAS_ScaleX
},
167 { u
"SameLetterHeights"_ustr
, EAS_SameLetterHeights
},
168 { u
"Position"_ustr
, EAS_Position
},
169 { u
"AdjustmentValues"_ustr
, EAS_AdjustmentValues
},
170 { u
"SubViewSize"_ustr
, EAS_SubViewSize
},
172 { u
"Last"_ustr
, EAS_Last
},
173 { u
"NotFound"_ustr
, EAS_NotFound
}
176 typedef std::unordered_map
< OUString
, EnhancedCustomShapeTokenEnum
> TypeNameHashMap
;
177 static const TypeNameHashMap
& GetNameHashMap()
179 static TypeNameHashMap aHashMap
= []()
182 for (auto const & pair
: pTokenTableArray
)
183 res
[pair
.aS
] = pair
.pE
;
190 EnhancedCustomShapeTokenEnum
EASGet( const OUString
& rShapeType
)
192 EnhancedCustomShapeTokenEnum eRetValue
= EAS_NotFound
;
193 auto& rHashMap
= GetNameHashMap();
194 TypeNameHashMap::const_iterator
aHashIter( rHashMap
.find( rShapeType
) );
195 if ( aHashIter
!= rHashMap
.end() )
196 eRetValue
= (*aHashIter
).second
;
200 EnhancedCustomShapeTokenEnum
EASGet( sal_Int32 nToken
)
202 return EASGet(SvXMLImport::getNameFromToken(nToken
));
205 const OUString
& EASGet( const EnhancedCustomShapeTokenEnum eToken
)
207 sal_uInt32 i
= eToken
>= EAS_Last
208 ? sal_uInt32(EAS_NotFound
)
209 : static_cast<sal_uInt32
>(eToken
);
210 return pTokenTableArray
[ i
].aS
;
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */