Branch data TLA Line data Source code
1 : : // Copyright (c) 2016-2022 Thomas Fussell
2 : : // Copyright (c) 2024-2025 xlnt-community
3 : : //
4 : : // Permission is hereby granted, free of charge, to any person obtaining a copy
5 : : // of this software and associated documentation files (the "Software"), to deal
6 : : // in the Software without restriction, including without limitation the rights
7 : : // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 : : // copies of the Software, and to permit persons to whom the Software is
9 : : // furnished to do so, subject to the following conditions:
10 : : //
11 : : // The above copyright notice and this permission notice shall be included in
12 : : // all copies or substantial portions of the Software.
13 : : //
14 : : // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 : : // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 : : // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 : : // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 : : // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 : : // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 : : // THE SOFTWARE
21 : : //
22 : : // @license: http://www.opensource.org/licenses/mit-license.php
23 : : // @author: see AUTHORS file
24 : :
25 : : #include <detail/serialization/custom_value_traits.hpp>
26 : :
27 : : namespace xlnt {
28 : : namespace detail {
29 : :
30 : : /// <summary>
31 : : /// Returns the string representation of the underline style.
32 : : /// </summary>
33 :CBC 20 : std::string to_string(font::underline_style style)
34 : : {
35 [ + + - + : 20 : switch (style)
- - ]
36 : : {
37 : 4 : case font::underline_style::double_:
38 [ + ]: 8 : return "double";
39 : 12 : case font::underline_style::double_accounting:
40 [ + ]: 24 : return "doubleAccounting";
41 :UBC 0 : case font::underline_style::single:
42 [ # ]: 0 : return "single";
43 :CBC 4 : case font::underline_style::single_accounting:
44 [ + ]: 8 : return "singleAccounting";
45 :UBC 0 : case font::underline_style::none:
46 [ # ]: 0 : return "none";
47 : : }
48 : :
49 [ # ]: 0 : default_case("single");
50 : : }
51 : :
52 : : /// <summary>
53 : : /// Returns the string representation of the relationship type.
54 : : /// </summary>
55 :CBC 367 : std::string to_string(relationship_type t)
56 : : {
57 [ + + + + : 367 : switch (t)
+ + + + +
+ - + + +
+ - - - -
+ - - - -
- - - - -
- - - + +
- - ]
58 : : {
59 : 44 : case relationship_type::office_document:
60 [ + ]: 88 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument";
61 : 30 : case relationship_type::thumbnail:
62 [ + ]: 60 : return "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail";
63 : 5 : case relationship_type::calculation_chain:
64 [ + ]: 10 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain";
65 : 41 : case relationship_type::extended_properties:
66 [ + ]: 82 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties";
67 : 41 : case relationship_type::core_properties:
68 [ + ]: 82 : return "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
69 : 53 : case relationship_type::worksheet:
70 [ + ]: 106 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet";
71 : 30 : case relationship_type::shared_string_table:
72 [ + ]: 60 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings";
73 : 42 : case relationship_type::stylesheet:
74 [ + ]: 84 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles";
75 : 41 : case relationship_type::theme:
76 [ + ]: 82 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
77 : 16 : case relationship_type::hyperlink:
78 [ + ]: 32 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
79 :UBC 0 : case relationship_type::chartsheet:
80 [ # ]: 0 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet";
81 :CBC 8 : case relationship_type::comments:
82 [ + ]: 16 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments";
83 : 8 : case relationship_type::vml_drawing:
84 [ + ]: 16 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing";
85 : 2 : case relationship_type::custom_properties:
86 [ + ]: 4 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties";
87 : 1 : case relationship_type::printer_settings:
88 [ + ]: 2 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings";
89 :UBC 0 : case relationship_type::connections:
90 [ # ]: 0 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/connections";
91 : 0 : case relationship_type::custom_property:
92 [ # ]: 0 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customProperty";
93 : 0 : case relationship_type::custom_xml_mappings:
94 [ # ]: 0 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlMappings";
95 : 0 : case relationship_type::dialogsheet:
96 [ # ]: 0 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/dialogsheet";
97 :CBC 2 : case relationship_type::drawings:
98 [ + ]: 4 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing";
99 :UBC 0 : case relationship_type::external_workbook_references:
100 [ # ]: 0 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath";
101 : 0 : case relationship_type::pivot_table:
102 [ # ]: 0 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable";
103 : 0 : case relationship_type::pivot_table_cache_definition:
104 [ # ]: 0 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition";
105 : 0 : case relationship_type::pivot_table_cache_records:
106 [ # ]: 0 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords";
107 : 0 : case relationship_type::query_table:
108 [ # ]: 0 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/queryTable";
109 : 0 : case relationship_type::shared_workbook_revision_headers:
110 [ # ]: 0 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/revisionHeaders";
111 : 0 : case relationship_type::shared_workbook:
112 [ # ]: 0 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedWorkbook";
113 : 0 : case relationship_type::revision_log:
114 [ # ]: 0 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/revisionLog";
115 : 0 : case relationship_type::shared_workbook_user_data:
116 [ # ]: 0 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/usernames";
117 : 0 : case relationship_type::single_cell_table_definitions:
118 [ # ]: 0 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableSingleCells";
119 : 0 : case relationship_type::table_definition:
120 [ # ]: 0 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table";
121 : 0 : case relationship_type::volatile_dependencies:
122 [ # ]: 0 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/volatileDependencies";
123 :CBC 1 : case relationship_type::vbaproject:
124 [ + ]: 2 : return "http://schemas.microsoft.com/office/2006/relationships/vbaProject";
125 : 2 : case relationship_type::image:
126 [ + ]: 4 : return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
127 :UBC 0 : case relationship_type::unknown:
128 [ # ]: 0 : return "unknown";
129 : : }
130 : :
131 [ # ]: 0 : default_case("unknown");
132 : : }
133 : :
134 :CBC 210 : std::string to_string(pattern_fill_type fill_type)
135 : : {
136 [ - - - - : 210 : switch (fill_type)
- - - - +
- + - - -
- - - + +
- ]
137 : : {
138 :UBC 0 : case pattern_fill_type::darkdown:
139 [ # ]: 0 : return "darkdown";
140 : 0 : case pattern_fill_type::darkgray:
141 [ # ]: 0 : return "darkgray";
142 : 0 : case pattern_fill_type::darkgrid:
143 [ # ]: 0 : return "darkgrid";
144 : 0 : case pattern_fill_type::darkhorizontal:
145 [ # ]: 0 : return "darkhorizontal";
146 : 0 : case pattern_fill_type::darktrellis:
147 [ # ]: 0 : return "darkhorizontal";
148 : 0 : case pattern_fill_type::darkup:
149 [ # ]: 0 : return "darkup";
150 : 0 : case pattern_fill_type::darkvertical:
151 [ # ]: 0 : return "darkvertical";
152 : 0 : case pattern_fill_type::gray0625:
153 [ # ]: 0 : return "gray0625";
154 :CBC 41 : case pattern_fill_type::gray125:
155 [ + ]: 82 : return "gray125";
156 :UBC 0 : case pattern_fill_type::lightdown:
157 [ # ]: 0 : return "lightdown";
158 :CBC 1 : case pattern_fill_type::lightgray:
159 [ + ]: 2 : return "lightgray";
160 :UBC 0 : case pattern_fill_type::lightgrid:
161 [ # ]: 0 : return "lightgrid";
162 : 0 : case pattern_fill_type::lighthorizontal:
163 [ # ]: 0 : return "lighthorizontal";
164 : 0 : case pattern_fill_type::lighttrellis:
165 [ # ]: 0 : return "lighttrellis";
166 : 0 : case pattern_fill_type::lightup:
167 [ # ]: 0 : return "lightup";
168 : 0 : case pattern_fill_type::lightvertical:
169 [ # ]: 0 : return "lightvertical";
170 : 0 : case pattern_fill_type::mediumgray:
171 [ # ]: 0 : return "mediumgray";
172 :CBC 126 : case pattern_fill_type::solid:
173 [ + ]: 252 : return "solid";
174 : 42 : case pattern_fill_type::none:
175 [ + ]: 84 : return "none";
176 : : }
177 : :
178 [ # ]:UBC 0 : default_case("none");
179 : : }
180 : :
181 :CBC 1 : std::string to_string(gradient_fill_type fill_type)
182 : : {
183 [ + - - ]: 1 : switch (fill_type)
184 : : {
185 : 1 : case gradient_fill_type::linear:
186 [ + ]: 2 : return "linear";
187 :UBC 0 : case gradient_fill_type::path:
188 [ # ]: 0 : return "path";
189 : : }
190 : :
191 [ # ]: 0 : default_case("linear");
192 : : }
193 : :
194 :CBC 116 : std::string to_string(border_style style)
195 : : {
196 [ - - - - : 116 : switch (style)
+ - + - -
- - + + -
- ]
197 : : {
198 :UBC 0 : case border_style::dashdot:
199 [ # ]: 0 : return "dashDot";
200 : 0 : case border_style::dashdotdot:
201 [ # ]: 0 : return "dashDotDot";
202 : 0 : case border_style::dashed:
203 [ # ]: 0 : return "dashed";
204 : 0 : case border_style::dotted:
205 [ # ]: 0 : return "dotted";
206 :CBC 24 : case border_style::double_:
207 [ + ]: 48 : return "double";
208 :UBC 0 : case border_style::hair:
209 [ # ]: 0 : return "hair";
210 :CBC 4 : case border_style::medium:
211 [ + ]: 8 : return "medium";
212 :UBC 0 : case border_style::mediumdashdot:
213 [ # ]: 0 : return "mediumDashDot";
214 : 0 : case border_style::mediumdashdotdot:
215 [ # ]: 0 : return "mediumDashDotDot";
216 : 0 : case border_style::mediumdashed:
217 [ # ]: 0 : return "mediumDashed";
218 : 0 : case border_style::slantdashdot:
219 [ # ]: 0 : return "slantDashDot";
220 :CBC 8 : case border_style::thick:
221 [ + ]: 16 : return "thick";
222 : 80 : case border_style::thin:
223 [ + ]: 160 : return "thin";
224 :UBC 0 : case border_style::none:
225 [ # ]: 0 : return "none";
226 : : }
227 : :
228 [ # ]: 0 : default_case("none");
229 : : }
230 : :
231 :CBC 74 : std::string to_string(vertical_alignment alignment)
232 : : {
233 [ + + + - : 74 : switch (alignment)
+ - ]
234 : : {
235 : 15 : case vertical_alignment::top:
236 [ + ]: 30 : return "top";
237 : 52 : case vertical_alignment::center:
238 [ + ]: 104 : return "center";
239 : 3 : case vertical_alignment::bottom:
240 [ + ]: 6 : return "bottom";
241 :UBC 0 : case vertical_alignment::justify:
242 [ # ]: 0 : return "justify";
243 :CBC 4 : case vertical_alignment::distributed:
244 [ + ]: 8 : return "distributed";
245 : : }
246 : :
247 [ # ]:UBC 0 : default_case("top");
248 : : }
249 : :
250 :CBC 24 : std::string to_string(horizontal_alignment alignment)
251 : : {
252 [ + + + + : 24 : switch (alignment)
- - - -
- ]
253 : : {
254 : 2 : case horizontal_alignment::general:
255 [ + ]: 4 : return "general";
256 : 13 : case horizontal_alignment::left:
257 [ + ]: 26 : return "left";
258 : 5 : case horizontal_alignment::center:
259 [ + ]: 10 : return "center";
260 : 4 : case horizontal_alignment::right:
261 [ + ]: 8 : return "right";
262 :UBC 0 : case horizontal_alignment::fill:
263 [ # ]: 0 : return "fill";
264 : 0 : case horizontal_alignment::justify:
265 [ # ]: 0 : return "justify";
266 : 0 : case horizontal_alignment::center_continuous:
267 [ # ]: 0 : return "centerContinuous";
268 : 0 : case horizontal_alignment::distributed:
269 [ # ]: 0 : return "distributed";
270 : : }
271 : :
272 [ # ]: 0 : default_case("general");
273 : : }
274 : :
275 :CBC 420 : std::string to_string(border_side side)
276 : : {
277 [ + + + + : 420 : switch (side)
- - + - ]
278 : : {
279 : 84 : case border_side::bottom:
280 [ + ]: 168 : return "bottom";
281 : 84 : case border_side::top:
282 [ + ]: 168 : return "top";
283 : 84 : case border_side::start:
284 [ + ]: 168 : return "left";
285 : 84 : case border_side::end:
286 [ + ]: 168 : return "right";
287 :UBC 0 : case border_side::horizontal:
288 [ # ]: 0 : return "horizontal";
289 : 0 : case border_side::vertical:
290 [ # ]: 0 : return "vertical";
291 :CBC 84 : case border_side::diagonal:
292 [ + ]: 168 : return "diagonal";
293 : : }
294 : :
295 [ # ]:UBC 0 : default_case("top");
296 : : }
297 : :
298 :CBC 179 : std::string to_string(core_property prop)
299 : : {
300 [ + - + + : 179 : switch (prop)
+ - + + +
- + + + +
- - ]
301 : : {
302 : 4 : case core_property::category:
303 [ + ]: 8 : return "category";
304 :UBC 0 : case core_property::content_status:
305 [ # ]: 0 : return "contentStatus";
306 :CBC 36 : case core_property::created:
307 [ + ]: 72 : return "created";
308 : 38 : case core_property::creator:
309 [ + ]: 76 : return "creator";
310 : 5 : case core_property::description:
311 [ + ]: 10 : return "description";
312 :UBC 0 : case core_property::identifier:
313 [ # ]: 0 : return "identifier";
314 :CBC 4 : case core_property::keywords:
315 [ + ]: 8 : return "keywords";
316 : 1 : case core_property::language:
317 [ + ]: 2 : return "language";
318 : 40 : case core_property::last_modified_by:
319 [ + ]: 80 : return "lastModifiedBy";
320 :UBC 0 : case core_property::last_printed:
321 [ # ]: 0 : return "lastPrinted";
322 :CBC 40 : case core_property::modified:
323 [ + ]: 80 : return "modified";
324 : 1 : case core_property::revision:
325 [ + ]: 2 : return "revision";
326 : 5 : case core_property::subject:
327 [ + ]: 10 : return "subject";
328 : 5 : case core_property::title:
329 [ + ]: 10 : return "title";
330 :UBC 0 : case core_property::version:
331 [ # ]: 0 : return "version";
332 : : }
333 : :
334 [ # ]: 0 : default_case("category");
335 : : }
336 : :
337 :CBC 398 : std::string to_string(extended_property prop)
338 : : {
339 [ + + - - : 398 : switch (prop)
+ - + + -
+ + - - +
+ - - - -
- + + - +
+ + - - ]
340 : : {
341 : 40 : case extended_property::application:
342 [ + ]: 80 : return "Application";
343 : 39 : case extended_property::app_version:
344 [ + ]: 78 : return "AppVersion";
345 :UBC 0 : case extended_property::characters:
346 [ # ]: 0 : return "Characters";
347 : 0 : case extended_property::characters_with_spaces:
348 [ # ]: 0 : return "CharactersWithSpaces";
349 :CBC 36 : case extended_property::company:
350 [ + ]: 72 : return "Company";
351 :UBC 0 : case extended_property::dig_sig:
352 [ # ]: 0 : return "DigSig";
353 :CBC 39 : case extended_property::doc_security:
354 [ + ]: 78 : return "DocSecurity";
355 : 39 : case extended_property::heading_pairs:
356 [ + ]: 78 : return "HeadingPairs";
357 :UBC 0 : case extended_property::hidden_slides:
358 [ # ]: 0 : return "HiddenSlides";
359 :CBC 39 : case extended_property::hyperlinks_changed:
360 [ + ]: 78 : return "HyperlinksChanged";
361 : 4 : case extended_property::hyperlink_base:
362 [ + ]: 8 : return "HyperlinkBase";
363 :UBC 0 : case extended_property::h_links:
364 [ # ]: 0 : return "HLinks";
365 : 0 : case extended_property::lines:
366 [ # ]: 0 : return "Lines";
367 :CBC 39 : case extended_property::links_up_to_date:
368 [ + ]: 78 : return "LinksUpToDate";
369 : 4 : case extended_property::manager:
370 [ + ]: 8 : return "Manager";
371 :UBC 0 : case extended_property::m_m_clips:
372 [ # ]: 0 : return "MMClips";
373 : 0 : case extended_property::notes:
374 [ # ]: 0 : return "Notes";
375 : 0 : case extended_property::pages:
376 [ # ]: 0 : return "Pages";
377 : 0 : case extended_property::paragraphs:
378 [ # ]: 0 : return "Paragraphs";
379 : 0 : case extended_property::presentation_format:
380 [ # ]: 0 : return "PresentationFormat";
381 :CBC 39 : case extended_property::scale_crop:
382 [ + ]: 78 : return "ScaleCrop";
383 : 39 : case extended_property::shared_doc:
384 [ + ]: 78 : return "SharedDoc";
385 :UBC 0 : case extended_property::slides:
386 [ # ]: 0 : return "Slides";
387 :CBC 1 : case extended_property::template_:
388 [ + ]: 2 : return "Template";
389 : 39 : case extended_property::titles_of_parts:
390 [ + ]: 78 : return "TitlesOfParts";
391 : 1 : case extended_property::total_time:
392 [ + ]: 2 : return "TotalTime";
393 :UBC 0 : case extended_property::words:
394 [ # ]: 0 : return "Words";
395 : : }
396 : :
397 [ # ]: 0 : default_case("Application");
398 : : }
399 : :
400 :CBC 39 : std::string to_string(variant::type type)
401 : : {
402 [ - - - + : 39 : switch (type)
- - - ]
403 : : {
404 :UBC 0 : case variant::type::boolean:
405 [ # ]: 0 : return "bool";
406 : 0 : case variant::type::date:
407 [ # ]: 0 : return "date";
408 : 0 : case variant::type::i4:
409 [ # ]: 0 : return "i4";
410 :CBC 39 : case variant::type::lpstr:
411 [ + ]: 78 : return "lpstr";
412 :UBC 0 : case variant::type::null:
413 [ # ]: 0 : return "null";
414 : 0 : case variant::type::vector:
415 [ # ]: 0 : return "vector";
416 : : }
417 : :
418 [ # ]: 0 : default_case("null");
419 : : }
420 : :
421 :CBC 6 : std::string to_string(pane_corner corner)
422 : : {
423 [ + + - + : 6 : switch (corner)
- ]
424 : : {
425 : 1 : case pane_corner::bottom_left:
426 [ + ]: 2 : return "bottomLeft";
427 : 4 : case pane_corner::bottom_right:
428 [ + ]: 8 : return "bottomRight";
429 :UBC 0 : case pane_corner::top_left:
430 [ # ]: 0 : return "topLeft";
431 :CBC 1 : case pane_corner::top_right:
432 [ + ]: 2 : return "topRight";
433 : : }
434 : :
435 [ # ]:UBC 0 : default_case("topLeft");
436 : : }
437 : :
438 : 0 : std::string to_string(target_mode mode)
439 : : {
440 [ # # # ]: 0 : switch (mode)
441 : : {
442 : 0 : case target_mode::external:
443 [ # ]: 0 : return "External";
444 : 0 : case target_mode::internal:
445 [ # ]: 0 : return "Internal";
446 : : }
447 : :
448 [ # ]: 0 : default_case("Internal");
449 : : }
450 : :
451 :CBC 2 : std::string to_string(pane_state state)
452 : : {
453 [ + - - - ]: 2 : switch (state)
454 : : {
455 : 2 : case pane_state::frozen:
456 [ + ]: 4 : return "frozen";
457 :UBC 0 : case pane_state::frozen_split:
458 [ # ]: 0 : return "frozenSplit";
459 : 0 : case pane_state::split:
460 [ # ]: 0 : return "split";
461 : : }
462 : :
463 [ # ]: 0 : default_case("frozen");
464 : : }
465 : :
466 :CBC 8 : std::string to_string(orientation orient)
467 : : {
468 [ - - + - ]: 8 : switch (orient)
469 : : {
470 :UBC 0 : case xlnt::orientation::default_orientation:
471 [ # ]: 0 : return "default";
472 : 0 : case xlnt::orientation::landscape:
473 [ # ]: 0 : return "landscape";
474 :CBC 8 : case xlnt::orientation::portrait:
475 [ + ]: 16 : return "portrait";
476 : : }
477 [ # ]:UBC 0 : default_case("default");
478 : : }
479 : :
480 : : } // namespace detail
481 : : } // namespace xlnt
|