custom_value_traits.cpp 16 KB

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