react-native-nitro-xlsx 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (395) hide show
  1. package/NitroXlsx.podspec +26 -27
  2. package/Package.swift +31 -10
  3. package/README.md +1 -1
  4. package/android/CMakeLists.txt +20 -27
  5. package/package.json +2 -2
  6. package/scripts/run-cpp-tests.sh +1 -1
  7. package/thirdparty/OpenXLSX/.clang-format +118 -0
  8. package/thirdparty/OpenXLSX/.clang-tidy +28 -0
  9. package/thirdparty/OpenXLSX/.gitignore +130 -0
  10. package/thirdparty/OpenXLSX/Benchmarks/2024-07-29-benchmarks_before_XMLNode_wrappers +46 -0
  11. package/thirdparty/OpenXLSX/Benchmarks/2024-07-29-benchmarks_with_XMLNode_wrappers_and_namespace_and_stripping +49 -0
  12. package/thirdparty/OpenXLSX/Benchmarks/2024-07-29-benchmarks_with_XMLNode_wrappers_and_namespace_char_support +49 -0
  13. package/thirdparty/OpenXLSX/Benchmarks/2024-07-29-benchmarks_with_XMLNode_wrappers_and_namespace_support +49 -0
  14. package/thirdparty/OpenXLSX/Benchmarks/2024-07-29-benchmarks_with_XMLNode_wrappers_and_namespaced_name_disabled +49 -0
  15. package/thirdparty/OpenXLSX/Benchmarks/2024-08-11-benchmarks_post-XLCellIterator-Rework +46 -0
  16. package/thirdparty/OpenXLSX/Benchmarks/2024-08-14-benchmarks_post-default-row-column-style-support +46 -0
  17. package/thirdparty/OpenXLSX/Benchmarks/2024-09-02-benchmarks +46 -0
  18. package/thirdparty/OpenXLSX/Benchmarks/2024-12-19-benchmarks +46 -0
  19. package/thirdparty/OpenXLSX/Benchmarks/2024-12-30-benchmarks-post-XLSharedStrings-by-ref +46 -0
  20. package/thirdparty/OpenXLSX/Benchmarks/2025-01-09-benchmarks-post-conditionalFormatsAndSheetProtection +46 -0
  21. package/thirdparty/OpenXLSX/Benchmarks/2025-01-10-benchmarks-post-XLCellValue-bugfix +46 -0
  22. package/thirdparty/OpenXLSX/Benchmarks/2025-01-31-benchmarks-post-XLComments-implementation +46 -0
  23. package/thirdparty/OpenXLSX/Benchmarks/2025-02-02-benchmarks-post-XLRowIterator-Rework +46 -0
  24. package/thirdparty/OpenXLSX/Benchmarks/2025-07-20-benchmarks-after-hiding-pugixml-internals +46 -0
  25. package/thirdparty/OpenXLSX/Benchmarks/2025-08-29-benchmarks-after-code-review-with-libzip +46 -0
  26. package/thirdparty/OpenXLSX/Benchmarks/Benchmark.cpp +249 -0
  27. package/thirdparty/OpenXLSX/Benchmarks/CMakeLists.txt +19 -0
  28. package/thirdparty/OpenXLSX/CMakeLists.txt +466 -0
  29. package/thirdparty/OpenXLSX/Documentation/CMakeLists.txt +31 -0
  30. package/thirdparty/OpenXLSX/Documentation/Doxyfile.in +2471 -0
  31. package/thirdparty/OpenXLSX/Documentation/DoxygenLayout.xml +194 -0
  32. package/thirdparty/OpenXLSX/Documentation/customdoxygen.css +1355 -0
  33. package/thirdparty/OpenXLSX/Examples/CMakeLists.txt +103 -0
  34. package/thirdparty/OpenXLSX/Examples/Demo1.cpp +279 -0
  35. package/thirdparty/OpenXLSX/Examples/Demo10.cpp +545 -0
  36. package/thirdparty/OpenXLSX/Examples/Demo1A.cpp +137 -0
  37. package/thirdparty/OpenXLSX/Examples/Demo2.cpp +65 -0
  38. package/thirdparty/OpenXLSX/Examples/Demo3.cpp +89 -0
  39. package/thirdparty/OpenXLSX/Examples/Demo4.cpp +86 -0
  40. package/thirdparty/OpenXLSX/Examples/Demo5.cpp +77 -0
  41. package/thirdparty/OpenXLSX/Examples/Demo6.cpp +103 -0
  42. package/thirdparty/OpenXLSX/Examples/Demo7.cpp +79 -0
  43. package/thirdparty/OpenXLSX/Examples/Demo8.cpp +117 -0
  44. package/thirdparty/OpenXLSX/Examples/Demo9.cpp +363 -0
  45. package/thirdparty/OpenXLSX/Examples/cmake/FindLIBZIP.cmake +61 -0
  46. package/thirdparty/OpenXLSX/Examples/external/CustomZip/CustomZip.hpp +256 -0
  47. package/thirdparty/OpenXLSX/LICENSE.md +29 -0
  48. package/thirdparty/OpenXLSX/Makefile.GNU +530 -0
  49. package/thirdparty/OpenXLSX/Notes/TBDs.txt +16 -0
  50. package/thirdparty/OpenXLSX/Notes/confirmed-TBCs.txt +8 -0
  51. package/thirdparty/OpenXLSX/Notes/styles-missing-support.xml +12 -0
  52. package/thirdparty/OpenXLSX/Notes/todo-list.txt +108 -0
  53. package/thirdparty/OpenXLSX/OpenXLSX/CMakeLists.txt +631 -0
  54. package/thirdparty/OpenXLSX/OpenXLSX/OpenXLSX.hpp +63 -0
  55. package/thirdparty/OpenXLSX/OpenXLSX/OpenXLSXConfig.cmake +11 -0
  56. package/thirdparty/OpenXLSX/OpenXLSX/cmake/bundle_static_library.cmake +198 -0
  57. package/thirdparty/OpenXLSX/OpenXLSX/cmake/patch_pkg_config.cmake +69 -0
  58. package/thirdparty/OpenXLSX/OpenXLSX/headers/IZipArchive.hpp +361 -0
  59. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX-Exports.hpp +12 -0
  60. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLCell.hpp +367 -0
  61. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLCellIterator.hpp +252 -0
  62. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLCellRange.hpp +223 -0
  63. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLCellReference.hpp +317 -0
  64. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLCellValue.hpp +793 -0
  65. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLColor.hpp +232 -0
  66. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLColumn.hpp +159 -0
  67. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLCommandQuery.hpp +228 -0
  68. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLComments.hpp +270 -0
  69. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLConstants.hpp +18 -0
  70. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLContentTypes.hpp +264 -0
  71. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLDateTime.hpp +175 -0
  72. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLDocument.hpp +505 -0
  73. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLDrawing.hpp +452 -0
  74. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLException.hpp +161 -0
  75. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLFormula.hpp +375 -0
  76. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLIterator.hpp +40 -0
  77. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLMergeCells.hpp +216 -0
  78. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLProperties.hpp +348 -0
  79. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLRelationships.hpp +348 -0
  80. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLRow.hpp +721 -0
  81. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLRowData.hpp +488 -0
  82. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLSharedStrings.hpp +204 -0
  83. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLSheet.hpp +1640 -0
  84. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLStyles.hpp +2390 -0
  85. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLTables.hpp +132 -0
  86. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLWorkbook.hpp +404 -0
  87. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLXmlData.hpp +283 -0
  88. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLXmlFile.hpp +194 -0
  89. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLXmlParser.hpp +282 -0
  90. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLXmlParserForwardDeclarations.hpp +85 -0
  91. package/thirdparty/OpenXLSX/OpenXLSX/headers/XLZipArchive.hpp +232 -0
  92. package/thirdparty/OpenXLSX/OpenXLSX/headers/detail/LibZip.hpp +447 -0
  93. package/thirdparty/OpenXLSX/OpenXLSX/headers/detail/OpenXLSXFileSystemTools.hpp +207 -0
  94. package/thirdparty/OpenXLSX/OpenXLSX/headers/detail/Zippy.hpp +1375 -0
  95. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLCell.cpp +340 -0
  96. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLCellIterator.cpp +427 -0
  97. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLCellRange.cpp +221 -0
  98. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLCellReference.cpp +408 -0
  99. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLCellValue.cpp +519 -0
  100. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLColor.cpp +202 -0
  101. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLColumn.cpp +141 -0
  102. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLComments.cpp +637 -0
  103. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLContentTypes.cpp +329 -0
  104. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLDateTime.cpp +269 -0
  105. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLDocument.cpp +1678 -0
  106. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLDrawing.cpp +784 -0
  107. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLFormula.cpp +201 -0
  108. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLMergeCells.cpp +357 -0
  109. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLProperties.cpp +810 -0
  110. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLRelationships.cpp +529 -0
  111. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLRow.cpp +918 -0
  112. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLRowData.cpp +508 -0
  113. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLSharedStrings.cpp +220 -0
  114. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLSheet.cpp +1970 -0
  115. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLStyles.cpp +3014 -0
  116. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLTables.cpp +125 -0
  117. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLWorkbook.cpp +784 -0
  118. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLXmlData.cpp +247 -0
  119. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLXmlFile.cpp +160 -0
  120. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLXmlParser.cpp +261 -0
  121. package/thirdparty/OpenXLSX/OpenXLSX/sources/XLZipArchive.cpp +266 -0
  122. package/thirdparty/OpenXLSX/OpenXLSX/sources/utilities/XLUtilities.hpp +478 -0
  123. package/thirdparty/OpenXLSX/README.md +1279 -0
  124. package/thirdparty/OpenXLSX/Scripts/cmake-cleanup.sh +102 -0
  125. package/thirdparty/OpenXLSX/Scripts/compile.sh +23 -0
  126. package/thirdparty/OpenXLSX/Scripts/demos-cleanup.sh +25 -0
  127. package/thirdparty/OpenXLSX/Scripts/demos-run-all.sh +60 -0
  128. package/thirdparty/OpenXLSX/Scripts/guarded-xml-format.sh +47 -0
  129. package/thirdparty/OpenXLSX/Scripts/make-gnu.sh +11 -0
  130. package/thirdparty/OpenXLSX/Scripts/uninstall-manifest.sh +48 -0
  131. package/thirdparty/OpenXLSX/Scripts/xml-format-all.sh +19 -0
  132. package/thirdparty/OpenXLSX/Scripts/xml-format.sh +38 -0
  133. package/thirdparty/OpenXLSX/Tests/CMakeLists.txt +37 -0
  134. package/thirdparty/OpenXLSX/Tests/catch/catch.hpp +17799 -0
  135. package/thirdparty/OpenXLSX/Tests/catch/catch_reporter_automake.hpp +68 -0
  136. package/thirdparty/OpenXLSX/Tests/catch/catch_reporter_sonarqube.hpp +182 -0
  137. package/thirdparty/OpenXLSX/Tests/catch/catch_reporter_tap.hpp +278 -0
  138. package/thirdparty/OpenXLSX/Tests/catch/catch_reporter_teamcity.hpp +212 -0
  139. package/thirdparty/OpenXLSX/Tests/main.cpp +55 -0
  140. package/thirdparty/OpenXLSX/Tests/testXLCell.cpp +176 -0
  141. package/thirdparty/OpenXLSX/Tests/testXLCellRange.cpp +180 -0
  142. package/thirdparty/OpenXLSX/Tests/testXLCellReference.cpp +160 -0
  143. package/thirdparty/OpenXLSX/Tests/testXLCellValue.cpp +366 -0
  144. package/thirdparty/OpenXLSX/Tests/testXLCellValueProxy.cpp +255 -0
  145. package/thirdparty/OpenXLSX/Tests/testXLColor.cpp +75 -0
  146. package/thirdparty/OpenXLSX/Tests/testXLDateTime.cpp +229 -0
  147. package/thirdparty/OpenXLSX/Tests/testXLDocument.cpp +197 -0
  148. package/thirdparty/OpenXLSX/Tests/testXLFormula.cpp +131 -0
  149. package/thirdparty/OpenXLSX/Tests/testXLRow.cpp +597 -0
  150. package/thirdparty/OpenXLSX/Tests/testXLSheet.cpp +77 -0
  151. package/thirdparty/OpenXLSX/Tests/ziptest-with-libs.cpp +88 -0
  152. package/thirdparty/OpenXLSX/Tests/ziptest.cpp +735 -0
  153. package/thirdparty/OpenXLSX/cmake/get-git-HEAD-ID.cmake +45 -0
  154. package/thirdparty/OpenXLSX/cmake/libopenxlsxCPackOptions.cmake.in +20 -0
  155. package/thirdparty/OpenXLSX/cmake/manage_dependency.cmake +813 -0
  156. package/thirdparty/OpenXLSX/cmake/recursive_library_type_test.cmake +52 -0
  157. package/thirdparty/OpenXLSX/gnu-make-crutch/OpenXLSX-Exports-shared.hpp +42 -0
  158. package/thirdparty/OpenXLSX/gnu-make-crutch/OpenXLSX-Exports-static.hpp +42 -0
  159. package/thirdparty/OpenXLSX/vcpkg.json +24 -0
  160. package/thirdparty/README.md +42 -0
  161. package/thirdparty/miniz/.clang-format +47 -0
  162. package/thirdparty/miniz/.travis.yml +2 -0
  163. package/thirdparty/miniz/CMakeLists.txt +333 -0
  164. package/thirdparty/miniz/CMakePresets.json +31 -0
  165. package/thirdparty/miniz/ChangeLog.md +272 -0
  166. package/thirdparty/miniz/Config.cmake.in +1 -0
  167. package/thirdparty/miniz/LICENSE +22 -0
  168. package/thirdparty/miniz/amalgamate.sh +57 -0
  169. package/thirdparty/miniz/examples/example1.c +105 -0
  170. package/thirdparty/miniz/examples/example2.c +164 -0
  171. package/thirdparty/miniz/examples/example3.c +269 -0
  172. package/thirdparty/miniz/examples/example4.c +102 -0
  173. package/thirdparty/miniz/examples/example5.c +327 -0
  174. package/thirdparty/miniz/examples/example6.c +189 -0
  175. package/thirdparty/miniz/meson.build +21 -0
  176. package/thirdparty/miniz/miniz.c +646 -0
  177. package/thirdparty/miniz/miniz.h +615 -0
  178. package/thirdparty/miniz/miniz.pc.in +13 -0
  179. package/thirdparty/miniz/miniz_common.h +89 -0
  180. package/thirdparty/miniz/miniz_export.h +20 -0
  181. package/thirdparty/miniz/miniz_tdef.c +1602 -0
  182. package/thirdparty/miniz/miniz_tdef.h +199 -0
  183. package/thirdparty/miniz/miniz_tinfl.c +778 -0
  184. package/thirdparty/miniz/miniz_tinfl.h +150 -0
  185. package/thirdparty/miniz/miniz_zip.c +4895 -0
  186. package/thirdparty/miniz/miniz_zip.h +454 -0
  187. package/thirdparty/miniz/readme.md +46 -0
  188. package/thirdparty/miniz/test.sh +36 -0
  189. package/thirdparty/miniz/tests/add_in_place_fuzzer.c +87 -0
  190. package/thirdparty/miniz/tests/catch_amalgamated.cpp +10795 -0
  191. package/thirdparty/miniz/tests/catch_amalgamated.hpp +13143 -0
  192. package/thirdparty/miniz/tests/checksum_fuzzer.c +26 -0
  193. package/thirdparty/miniz/tests/compress_fuzzer.c +91 -0
  194. package/thirdparty/miniz/tests/flush_fuzzer.c +88 -0
  195. package/thirdparty/miniz/tests/fuzz_main.c +55 -0
  196. package/thirdparty/miniz/tests/large_fuzzer.c +133 -0
  197. package/thirdparty/miniz/tests/main.cpp +185 -0
  198. package/thirdparty/miniz/tests/miniz_tdefl_fuzzer.cc +115 -0
  199. package/thirdparty/miniz/tests/miniz_tester.cpp +1881 -0
  200. package/thirdparty/miniz/tests/miniz_zip_validate_fuzzer.cc +71 -0
  201. package/thirdparty/miniz/tests/miniz_zip_writer_fuzzer.cc +96 -0
  202. package/thirdparty/miniz/tests/ossfuzz.sh +48 -0
  203. package/thirdparty/miniz/tests/small_fuzzer.c +126 -0
  204. package/thirdparty/miniz/tests/timer.cpp +152 -0
  205. package/thirdparty/miniz/tests/timer.h +40 -0
  206. package/thirdparty/miniz/tests/uncompress2_fuzzer.c +21 -0
  207. package/thirdparty/miniz/tests/uncompress_fuzzer.c +30 -0
  208. package/thirdparty/miniz/tests/zip.dict +9 -0
  209. package/thirdparty/miniz/tests/zip_fuzzer.c +63 -0
  210. package/thirdparty/pugixml/.codecov.yml +7 -0
  211. package/thirdparty/pugixml/.gitattributes +1 -0
  212. package/thirdparty/pugixml/CMakeLists.txt +330 -0
  213. package/thirdparty/pugixml/LICENSE.md +24 -0
  214. package/thirdparty/pugixml/Makefile +98 -0
  215. package/thirdparty/pugixml/README.md +81 -0
  216. package/thirdparty/pugixml/SECURITY.md +9 -0
  217. package/thirdparty/pugixml/appveyor.yml +50 -0
  218. package/thirdparty/pugixml/docs/config.adoc +7 -0
  219. package/thirdparty/pugixml/docs/images/dom_tree.png +0 -0
  220. package/thirdparty/pugixml/docs/images/vs2005_link1.png +0 -0
  221. package/thirdparty/pugixml/docs/images/vs2005_link2.png +0 -0
  222. package/thirdparty/pugixml/docs/images/vs2005_pch1.png +0 -0
  223. package/thirdparty/pugixml/docs/images/vs2005_pch2.png +0 -0
  224. package/thirdparty/pugixml/docs/images/vs2005_pch3.png +0 -0
  225. package/thirdparty/pugixml/docs/images/vs2005_pch4.png +0 -0
  226. package/thirdparty/pugixml/docs/images/vs2010_link1.png +0 -0
  227. package/thirdparty/pugixml/docs/images/vs2010_link2.png +0 -0
  228. package/thirdparty/pugixml/docs/manual.adoc +3326 -0
  229. package/thirdparty/pugixml/docs/manual.html +6395 -0
  230. package/thirdparty/pugixml/docs/quickstart.adoc +287 -0
  231. package/thirdparty/pugixml/docs/quickstart.html +1107 -0
  232. package/thirdparty/pugixml/docs/samples/character.xml +8 -0
  233. package/thirdparty/pugixml/docs/samples/custom_memory_management.cpp +27 -0
  234. package/thirdparty/pugixml/docs/samples/include.cpp +64 -0
  235. package/thirdparty/pugixml/docs/samples/load_error_handling.cpp +33 -0
  236. package/thirdparty/pugixml/docs/samples/load_file.cpp +16 -0
  237. package/thirdparty/pugixml/docs/samples/load_memory.cpp +66 -0
  238. package/thirdparty/pugixml/docs/samples/load_options.cpp +30 -0
  239. package/thirdparty/pugixml/docs/samples/load_stream.cpp +97 -0
  240. package/thirdparty/pugixml/docs/samples/modify_add.cpp +29 -0
  241. package/thirdparty/pugixml/docs/samples/modify_base.cpp +43 -0
  242. package/thirdparty/pugixml/docs/samples/modify_remove.cpp +27 -0
  243. package/thirdparty/pugixml/docs/samples/save_custom_writer.cpp +116 -0
  244. package/thirdparty/pugixml/docs/samples/save_declaration.cpp +27 -0
  245. package/thirdparty/pugixml/docs/samples/save_file.cpp +17 -0
  246. package/thirdparty/pugixml/docs/samples/save_options.cpp +48 -0
  247. package/thirdparty/pugixml/docs/samples/save_stream.cpp +18 -0
  248. package/thirdparty/pugixml/docs/samples/save_subtree.cpp +26 -0
  249. package/thirdparty/pugixml/docs/samples/text.cpp +35 -0
  250. package/thirdparty/pugixml/docs/samples/transitions.xml +7 -0
  251. package/thirdparty/pugixml/docs/samples/traverse_base.cpp +51 -0
  252. package/thirdparty/pugixml/docs/samples/traverse_iter.cpp +27 -0
  253. package/thirdparty/pugixml/docs/samples/traverse_predicate.cpp +48 -0
  254. package/thirdparty/pugixml/docs/samples/traverse_rangefor.cpp +32 -0
  255. package/thirdparty/pugixml/docs/samples/traverse_walker.cpp +35 -0
  256. package/thirdparty/pugixml/docs/samples/tree.xml +12 -0
  257. package/thirdparty/pugixml/docs/samples/weekly-shift_jis.xml +78 -0
  258. package/thirdparty/pugixml/docs/samples/weekly-utf-16.xml +0 -0
  259. package/thirdparty/pugixml/docs/samples/weekly-utf-8.xml +78 -0
  260. package/thirdparty/pugixml/docs/samples/xgconsole.xml +12 -0
  261. package/thirdparty/pugixml/docs/samples/xpath_error.cpp +43 -0
  262. package/thirdparty/pugixml/docs/samples/xpath_query.cpp +36 -0
  263. package/thirdparty/pugixml/docs/samples/xpath_select.cpp +28 -0
  264. package/thirdparty/pugixml/docs/samples/xpath_variables.cpp +38 -0
  265. package/thirdparty/pugixml/readme.txt +50 -0
  266. package/thirdparty/pugixml/scripts/archive.py +54 -0
  267. package/thirdparty/pugixml/scripts/cocoapods_push.sh +4 -0
  268. package/thirdparty/pugixml/scripts/natvis/pugixml.natvis +77 -0
  269. package/thirdparty/pugixml/scripts/natvis/pugixml_compact.natvis +506 -0
  270. package/thirdparty/pugixml/scripts/nuget/build/native/pugixml-propertiesui.xml +17 -0
  271. package/thirdparty/pugixml/scripts/nuget/build/native/pugixml.targets +28 -0
  272. package/thirdparty/pugixml/scripts/nuget/pugixml.nuspec +20 -0
  273. package/thirdparty/pugixml/scripts/nuget_build.ps1 +60 -0
  274. package/thirdparty/pugixml/scripts/premake4.lua +92 -0
  275. package/thirdparty/pugixml/scripts/pugixml-config.cmake.in +12 -0
  276. package/thirdparty/pugixml/scripts/pugixml.pc.in +11 -0
  277. package/thirdparty/pugixml/scripts/pugixml.podspec +14 -0
  278. package/thirdparty/pugixml/scripts/pugixml.xcodeproj/project.pbxproj +212 -0
  279. package/thirdparty/pugixml/scripts/pugixml_airplay.mkf +13 -0
  280. package/thirdparty/pugixml/scripts/pugixml_codeblocks.cbp +44 -0
  281. package/thirdparty/pugixml/scripts/pugixml_codelite.project +56 -0
  282. package/thirdparty/pugixml/scripts/pugixml_dll.rc +45 -0
  283. package/thirdparty/pugixml/scripts/pugixml_vs2005.vcproj +343 -0
  284. package/thirdparty/pugixml/scripts/pugixml_vs2005_static.vcproj +343 -0
  285. package/thirdparty/pugixml/scripts/pugixml_vs2008.vcproj +339 -0
  286. package/thirdparty/pugixml/scripts/pugixml_vs2008_static.vcproj +339 -0
  287. package/thirdparty/pugixml/scripts/pugixml_vs2010.vcxproj +191 -0
  288. package/thirdparty/pugixml/scripts/pugixml_vs2010_static.vcxproj +191 -0
  289. package/thirdparty/pugixml/scripts/pugixml_vs2013.vcxproj +199 -0
  290. package/thirdparty/pugixml/scripts/pugixml_vs2013_static.vcxproj +199 -0
  291. package/thirdparty/pugixml/scripts/pugixml_vs2015.vcxproj +172 -0
  292. package/thirdparty/pugixml/scripts/pugixml_vs2015_static.vcxproj +176 -0
  293. package/thirdparty/pugixml/scripts/pugixml_vs2017.vcxproj +172 -0
  294. package/thirdparty/pugixml/scripts/pugixml_vs2017_static.vcxproj +176 -0
  295. package/thirdparty/pugixml/scripts/pugixml_vs2019.vcxproj +176 -0
  296. package/thirdparty/pugixml/scripts/pugixml_vs2019_static.vcxproj +180 -0
  297. package/thirdparty/pugixml/scripts/pugixml_vs2022.vcxproj +176 -0
  298. package/thirdparty/pugixml/scripts/pugixml_vs2022_static.vcxproj +180 -0
  299. package/thirdparty/pugixml/scripts/pugixml_vs2026.vcxproj +176 -0
  300. package/thirdparty/pugixml/scripts/pugixml_vs2026_static.vcxproj +180 -0
  301. package/thirdparty/pugixml/scripts/sbom.cdx.json +47 -0
  302. package/thirdparty/pugixml/src/pugiconfig.hpp +81 -0
  303. package/thirdparty/pugixml/src/pugixml.cpp +13776 -0
  304. package/thirdparty/pugixml/src/pugixml.hpp +1604 -0
  305. package/thirdparty/pugixml/tests/allocator.cpp +175 -0
  306. package/thirdparty/pugixml/tests/allocator.hpp +10 -0
  307. package/thirdparty/pugixml/tests/autotest-appveyor.ps1 +93 -0
  308. package/thirdparty/pugixml/tests/cmake-appveyor.ps1 +57 -0
  309. package/thirdparty/pugixml/tests/data/empty.xml +0 -0
  310. package/thirdparty/pugixml/tests/data/large.xml +1 -0
  311. package/thirdparty/pugixml/tests/data/latintest_latin1.xml +1 -0
  312. package/thirdparty/pugixml/tests/data/latintest_utf8.xml +1 -0
  313. package/thirdparty/pugixml/tests/data/multiline.xml +3 -0
  314. package/thirdparty/pugixml/tests/data/small.xml +1 -0
  315. package/thirdparty/pugixml/tests/data/truncation.xml +19 -0
  316. package/thirdparty/pugixml/tests/data/utftest_utf16_be.xml +0 -0
  317. package/thirdparty/pugixml/tests/data/utftest_utf16_be_bom.xml +0 -0
  318. package/thirdparty/pugixml/tests/data/utftest_utf16_be_clean.xml +0 -0
  319. package/thirdparty/pugixml/tests/data/utftest_utf16_be_nodecl.xml +0 -0
  320. package/thirdparty/pugixml/tests/data/utftest_utf16_le.xml +0 -0
  321. package/thirdparty/pugixml/tests/data/utftest_utf16_le_bom.xml +0 -0
  322. package/thirdparty/pugixml/tests/data/utftest_utf16_le_clean.xml +0 -0
  323. package/thirdparty/pugixml/tests/data/utftest_utf16_le_nodecl.xml +0 -0
  324. package/thirdparty/pugixml/tests/data/utftest_utf32_be.xml +0 -0
  325. package/thirdparty/pugixml/tests/data/utftest_utf32_be_bom.xml +0 -0
  326. package/thirdparty/pugixml/tests/data/utftest_utf32_be_clean.xml +0 -0
  327. package/thirdparty/pugixml/tests/data/utftest_utf32_be_nodecl.xml +0 -0
  328. package/thirdparty/pugixml/tests/data/utftest_utf32_le.xml +0 -0
  329. package/thirdparty/pugixml/tests/data/utftest_utf32_le_bom.xml +0 -0
  330. package/thirdparty/pugixml/tests/data/utftest_utf32_le_clean.xml +0 -0
  331. package/thirdparty/pugixml/tests/data/utftest_utf32_le_nodecl.xml +0 -0
  332. package/thirdparty/pugixml/tests/data/utftest_utf8.xml +87 -0
  333. package/thirdparty/pugixml/tests/data/utftest_utf8_bom.xml +87 -0
  334. package/thirdparty/pugixml/tests/data/utftest_utf8_clean.xml +84 -0
  335. package/thirdparty/pugixml/tests/data/utftest_utf8_nodecl.xml +86 -0
  336. package/thirdparty/pugixml/tests/data//321/202/320/265/321/201/321/202.xml +1 -0
  337. package/thirdparty/pugixml/tests/data_fuzz_parse/basic.xml +1 -0
  338. package/thirdparty/pugixml/tests/data_fuzz_parse/doctype.xml +1 -0
  339. package/thirdparty/pugixml/tests/data_fuzz_parse/refs.xml +1 -0
  340. package/thirdparty/pugixml/tests/data_fuzz_parse/types.xml +1 -0
  341. package/thirdparty/pugixml/tests/data_fuzz_parse/utf16.xml +0 -0
  342. package/thirdparty/pugixml/tests/data_fuzz_parse/utf32.xml +0 -0
  343. package/thirdparty/pugixml/tests/data_fuzz_xpath/basic.xpath +1 -0
  344. package/thirdparty/pugixml/tests/data_fuzz_xpath/functions.xpath +1 -0
  345. package/thirdparty/pugixml/tests/data_fuzz_xpath/math.xpath +1 -0
  346. package/thirdparty/pugixml/tests/data_fuzz_xpath/path.xpath +1 -0
  347. package/thirdparty/pugixml/tests/data_fuzz_xpath/predicate.xpath +1 -0
  348. package/thirdparty/pugixml/tests/fuzz_parse.cpp +14 -0
  349. package/thirdparty/pugixml/tests/fuzz_parse.dict +72 -0
  350. package/thirdparty/pugixml/tests/fuzz_setup.sh +11 -0
  351. package/thirdparty/pugixml/tests/fuzz_xpath.cpp +46 -0
  352. package/thirdparty/pugixml/tests/fuzz_xpath.dict +72 -0
  353. package/thirdparty/pugixml/tests/helpers.hpp +114 -0
  354. package/thirdparty/pugixml/tests/main.cpp +218 -0
  355. package/thirdparty/pugixml/tests/test.cpp +220 -0
  356. package/thirdparty/pugixml/tests/test.hpp +175 -0
  357. package/thirdparty/pugixml/tests/test_compact.cpp +150 -0
  358. package/thirdparty/pugixml/tests/test_deprecated.cpp +25 -0
  359. package/thirdparty/pugixml/tests/test_document.cpp +1910 -0
  360. package/thirdparty/pugixml/tests/test_dom_modify.cpp +2122 -0
  361. package/thirdparty/pugixml/tests/test_dom_text.cpp +601 -0
  362. package/thirdparty/pugixml/tests/test_dom_traverse.cpp +1481 -0
  363. package/thirdparty/pugixml/tests/test_header_guard.cpp +3 -0
  364. package/thirdparty/pugixml/tests/test_header_iosfwd_1.cpp +3 -0
  365. package/thirdparty/pugixml/tests/test_header_iosfwd_2.cpp +3 -0
  366. package/thirdparty/pugixml/tests/test_header_iostream_1.cpp +3 -0
  367. package/thirdparty/pugixml/tests/test_header_iostream_2.cpp +3 -0
  368. package/thirdparty/pugixml/tests/test_header_only_1.cpp +21 -0
  369. package/thirdparty/pugixml/tests/test_header_only_2.cpp +21 -0
  370. package/thirdparty/pugixml/tests/test_header_string_1.cpp +3 -0
  371. package/thirdparty/pugixml/tests/test_header_string_2.cpp +3 -0
  372. package/thirdparty/pugixml/tests/test_header_string_iostream.cpp +5 -0
  373. package/thirdparty/pugixml/tests/test_memory.cpp +303 -0
  374. package/thirdparty/pugixml/tests/test_parse.cpp +1463 -0
  375. package/thirdparty/pugixml/tests/test_parse_doctype.cpp +366 -0
  376. package/thirdparty/pugixml/tests/test_unicode.cpp +152 -0
  377. package/thirdparty/pugixml/tests/test_version.cpp +5 -0
  378. package/thirdparty/pugixml/tests/test_write.cpp +757 -0
  379. package/thirdparty/pugixml/tests/test_xpath.cpp +833 -0
  380. package/thirdparty/pugixml/tests/test_xpath_api.cpp +646 -0
  381. package/thirdparty/pugixml/tests/test_xpath_functions.cpp +844 -0
  382. package/thirdparty/pugixml/tests/test_xpath_operators.cpp +566 -0
  383. package/thirdparty/pugixml/tests/test_xpath_parse.cpp +428 -0
  384. package/thirdparty/pugixml/tests/test_xpath_paths.cpp +787 -0
  385. package/thirdparty/pugixml/tests/test_xpath_paths_abbrev_w3c.cpp +219 -0
  386. package/thirdparty/pugixml/tests/test_xpath_paths_w3c.cpp +312 -0
  387. package/thirdparty/pugixml/tests/test_xpath_variables.cpp +683 -0
  388. package/thirdparty/pugixml/tests/test_xpath_xalan_1.cpp +411 -0
  389. package/thirdparty/pugixml/tests/test_xpath_xalan_2.cpp +417 -0
  390. package/thirdparty/pugixml/tests/test_xpath_xalan_3.cpp +321 -0
  391. package/thirdparty/pugixml/tests/test_xpath_xalan_4.cpp +300 -0
  392. package/thirdparty/pugixml/tests/test_xpath_xalan_5.cpp +295 -0
  393. package/thirdparty/pugixml/tests/writer_string.cpp +79 -0
  394. package/thirdparty/pugixml/tests/writer_string.hpp +27 -0
  395. package/scripts/prepare-openxlsx.js +0 -126
@@ -0,0 +1,478 @@
1
+ //
2
+ // Created by Kenneth Balslev on 24/08/2020.
3
+ //
4
+
5
+ #ifndef OPENXLSX_XLUTILITIES_HPP
6
+ #define OPENXLSX_XLUTILITIES_HPP
7
+
8
+ #include <fstream>
9
+ #include <string> // 2024-04-25 needed for xml_node_type_string
10
+ #include <string_view> // std::string_view
11
+ #include <vector> // std::vector< std::string_view >
12
+
13
+ #include "XLConstants.hpp" // 2024-05-28 OpenXLSX::MAX_ROWS
14
+ #include "XLCellReference.hpp"
15
+ #include "XLCellValue.hpp" // OpenXLSX::XLValueType
16
+ #include "XLContentTypes.hpp" // OpenXLSX::XLContentType
17
+ #include "XLRelationships.hpp" // OpenXLSX::XLRelationshipType
18
+ #include "XLStyles.hpp" // OpenXLSX::XLStyleIndex
19
+ #include "XLXmlParser.hpp" // pugixml wrapper
20
+
21
+ namespace OpenXLSX
22
+ {
23
+ constexpr const bool XLRemoveAttributes = true; // helper variables for appendAndSetNodeAttribute, parameter removeAttributes
24
+ constexpr const bool XLKeepAttributes = false; //
25
+
26
+ /**
27
+ * @brief Get rid of compiler warnings about unused variables (-Wunused-variable) or unused parameters (-Wunusued-parameter)
28
+ * @param (unnamed) the variable / parameter which is intentionally unused (e.g. for function stubs)
29
+ */
30
+ template<class T> void ignore( const T& ) {}
31
+
32
+ /**
33
+ * @brief Get a string representation of pugi::xml_node_type
34
+ * @param t the pugi::xml_node_type of a node
35
+ * @return a std::string containing the descriptive name of the node type
36
+ */
37
+ inline std::string XLValueTypeString( XLValueType t )
38
+ {
39
+ using namespace std::literals::string_literals;
40
+ switch( t ) {
41
+ case XLValueType::Empty : return "Empty"s;
42
+ case XLValueType::Boolean : return "Boolean"s;
43
+ case XLValueType::Integer : return "Integer"s;
44
+ case XLValueType::Float : return "Float"s;
45
+ case XLValueType::Error : return "Error"s;
46
+ case XLValueType::String : return "String"s;
47
+ }
48
+ throw XLInternalError(__func__ + "Invalid XLValueType."s);
49
+ }
50
+
51
+ /**
52
+ * @brief Get a string representation of pugi::xml_node_type
53
+ * @param t the pugi::xml_node_type of a node
54
+ * @return a std::string containing the descriptive name of the node type
55
+ */
56
+ inline std::string xml_node_type_string( pugi::xml_node_type t )
57
+ {
58
+ using namespace std::literals::string_literals;
59
+ switch( t ) {
60
+ case pugi::node_null : return "node_null"s;
61
+ case pugi::node_document : return "node_document"s;
62
+ case pugi::node_element : return "node_element"s;
63
+ case pugi::node_pcdata : return "node_pcdata"s;
64
+ case pugi::node_cdata : return "node_cdata"s;
65
+ case pugi::node_comment : return "node_comment"s;
66
+ case pugi::node_pi : return "node_pi"s;
67
+ case pugi::node_declaration : return "node_declaration"s;
68
+ case pugi::node_doctype : return "node_doctype"s;
69
+ }
70
+ throw XLInternalError("Invalid XML node type.");
71
+ }
72
+
73
+ /**
74
+ * @brief Get a string representation of OpenXLSX::XLContentType
75
+ * @param t an OpenXLSX::XLContentType value
76
+ * @return a std::string containing the descriptive name of the content type
77
+ */
78
+ inline std::string XLContentTypeString( OpenXLSX::XLContentType const & t )
79
+ {
80
+ using namespace OpenXLSX;
81
+ switch (t) {
82
+ case XLContentType::Workbook: return "Workbook";
83
+ case XLContentType::Relationships: return "Relationships";
84
+ case XLContentType::WorkbookMacroEnabled: return "WorkbookMacroEnabled";
85
+ case XLContentType::Worksheet: return "Worksheet";
86
+ case XLContentType::Chartsheet: return "Chartsheet";
87
+ case XLContentType::ExternalLink: return "ExternalLink";
88
+ case XLContentType::Theme: return "Theme";
89
+ case XLContentType::Styles: return "Styles";
90
+ case XLContentType::SharedStrings: return "SharedStrings";
91
+ case XLContentType::Drawing: return "Drawing";
92
+ case XLContentType::Chart: return "Chart";
93
+ case XLContentType::ChartStyle: return "ChartStyle";
94
+ case XLContentType::ChartColorStyle: return "ChartColorStyle";
95
+ case XLContentType::ControlProperties: return "ControlProperties";
96
+ case XLContentType::CalculationChain: return "CalculationChain";
97
+ case XLContentType::VBAProject: return "VBAProject";
98
+ case XLContentType::CoreProperties: return "CoreProperties";
99
+ case XLContentType::ExtendedProperties: return "ExtendedProperties";
100
+ case XLContentType::CustomProperties: return "CustomProperties";
101
+ case XLContentType::VMLDrawing: return "VMLDrawing";
102
+ case XLContentType::Comments: return "Comments";
103
+ case XLContentType::Table: return "Table";
104
+ case XLContentType::Unknown: return "Unknown";
105
+ }
106
+ return "invalid";
107
+ }
108
+
109
+ /**
110
+ * @brief Get a string representation of OpenXLSX::XLRelationshipType
111
+ * @param t an OpenXLSX::XLRelationshipType value
112
+ * @return std::string containing the descriptive name of the relationship type
113
+ */
114
+ inline std::string XLRelationshipTypeString( OpenXLSX::XLRelationshipType const & t )
115
+ {
116
+ using namespace OpenXLSX;
117
+ switch (t) {
118
+ case XLRelationshipType::CoreProperties: return "CoreProperties";
119
+ case XLRelationshipType::ExtendedProperties: return "ExtendedProperties";
120
+ case XLRelationshipType::CustomProperties: return "CustomProperties";
121
+ case XLRelationshipType::Workbook: return "Workbook";
122
+ case XLRelationshipType::Worksheet: return "Worksheet";
123
+ case XLRelationshipType::Chartsheet: return "Chartsheet";
124
+ case XLRelationshipType::Dialogsheet: return "Dialogsheet";
125
+ case XLRelationshipType::Macrosheet: return "Macrosheet";
126
+ case XLRelationshipType::CalculationChain: return "CalculationChain";
127
+ case XLRelationshipType::ExternalLink: return "ExternalLink";
128
+ case XLRelationshipType::ExternalLinkPath: return "ExternalLinkPath";
129
+ case XLRelationshipType::Theme: return "Theme";
130
+ case XLRelationshipType::Styles: return "Styles";
131
+ case XLRelationshipType::Chart: return "Chart";
132
+ case XLRelationshipType::ChartStyle: return "ChartStyle";
133
+ case XLRelationshipType::ChartColorStyle: return "ChartColorStyle";
134
+ case XLRelationshipType::Image: return "Image";
135
+ case XLRelationshipType::Drawing: return "Drawing";
136
+ case XLRelationshipType::VMLDrawing: return "VMLDrawing";
137
+ case XLRelationshipType::SharedStrings: return "SharedStrings";
138
+ case XLRelationshipType::PrinterSettings: return "PrinterSettings";
139
+ case XLRelationshipType::VBAProject: return "VBAProject";
140
+ case XLRelationshipType::ControlProperties: return "ControlProperties";
141
+ case XLRelationshipType::Comments: return "Comments";
142
+ case XLRelationshipType::Table: return "Table";
143
+ case XLRelationshipType::Unknown: return "Unknown";
144
+ }
145
+ return "invalid";
146
+ }
147
+
148
+ /**
149
+ * @details
150
+ */
151
+ inline XMLNode getRowNode(XMLNode sheetDataNode, uint32_t rowNumber)
152
+ {
153
+ if (rowNumber < 1 || rowNumber > OpenXLSX::MAX_ROWS) { // 2024-05-28: added range check
154
+ using namespace std::literals::string_literals;
155
+ throw XLCellAddressError("rowNumber "s + std::to_string( rowNumber ) + " is outside valid range [1;"s + std::to_string(OpenXLSX::MAX_ROWS) + "]"s);
156
+ }
157
+
158
+ // ===== Get the last child of sheetDataNode that is of type node_element.
159
+ XMLNode result = sheetDataNode.last_child_of_type(pugi::node_element);
160
+
161
+ // ===== If there are now rows in the worksheet, or the requested row is beyond the current max row, append a new row to the end.
162
+ if (result.empty() || (rowNumber > result.attribute("r").as_ullong())) {
163
+ result = sheetDataNode.append_child("row");
164
+ result.append_attribute("r") = rowNumber;
165
+ // result.append_attribute("x14ac:dyDescent") = "0.2";
166
+ // result.append_attribute("spans") = "1:1";
167
+ }
168
+
169
+ // ===== If the requested node is closest to the end, start from the end and search backwards.
170
+ else if (result.attribute("r").as_ullong() - rowNumber < rowNumber) {
171
+ while (not result.empty() && (result.attribute("r").as_ullong() > rowNumber)) result = result.previous_sibling_of_type(pugi::node_element);
172
+ // ===== If the backwards search failed to locate the requested row
173
+ if (result.empty() || (result.attribute("r").as_ullong() != rowNumber)) {
174
+ if (result.empty())
175
+ result = sheetDataNode.prepend_child("row"); // insert a new row node at datasheet begin. When saving, this will keep whitespace formatting towards next row node
176
+ else
177
+ result = sheetDataNode.insert_child_after("row", result);
178
+ result.append_attribute("r") = rowNumber;
179
+ // result.append_attribute("x14ac:dyDescent") = "0.2";
180
+ // result.append_attribute("spans") = "1:1";
181
+ }
182
+ }
183
+
184
+ // ===== Otherwise, start from the beginning
185
+ else {
186
+ // ===== At this point, it is guaranteed that there is at least one node_element in the row that is not empty.
187
+ result = sheetDataNode.first_child_of_type(pugi::node_element);
188
+
189
+ // ===== It has been verified above that the requested rowNumber is <= the row number of the last node_element, therefore this loop will halt.
190
+ while (result.attribute("r").as_ullong() < rowNumber) result = result.next_sibling_of_type(pugi::node_element);
191
+ // ===== If the forwards search failed to locate the requested row
192
+ if (result.attribute("r").as_ullong() > rowNumber) {
193
+ result = sheetDataNode.insert_child_before("row", result);
194
+
195
+ result.append_attribute("r") = rowNumber;
196
+ // result.append_attribute("x14ac:dyDescent") = "0.2";
197
+ // result.append_attribute("spans") = "1:1";
198
+ }
199
+ }
200
+
201
+ return result;
202
+ }
203
+
204
+ /**
205
+ * @brief get the style attribute s for the indicated column, if any is set
206
+ * @param rowNode the row node from which to obtain the parent that should hold the <cols> node
207
+ * @param colNo the column for which to obtain the style
208
+ * @return the XLStyleIndex stored for the column, or XLDefaultCellFormat if none
209
+ */
210
+ inline XLStyleIndex getColumnStyle(XMLNode rowNode, uint16_t colNo)
211
+ {
212
+ XMLNode cols = rowNode.parent().parent().child("cols");
213
+ if (not cols.empty()) {
214
+ XMLNode col = cols.first_child_of_type(pugi::node_element);
215
+ while (not col.empty()) {
216
+ if (col.attribute("min").as_int(MAX_COLS+1) <= colNo && col.attribute("max").as_int(0) >= colNo) // found
217
+ return col.attribute("style").as_uint(XLDefaultCellFormat);
218
+ col = col.next_sibling_of_type(pugi::node_element);
219
+ }
220
+ }
221
+ return XLDefaultCellFormat; // if no col style was found
222
+ }
223
+
224
+ /**
225
+ * @brief set the cell reference, and a default cell style attribute if and only if row or column style is != XLDefaultCellFormat
226
+ * @note row style takes precedence over column style
227
+ * @param cellNode the cell XML node
228
+ * @param cellRef the cell reference (attribute r) to set
229
+ * @param rowNode the row node for the cell
230
+ * @param colNo the column number for this cell (to try and fetch a column style)
231
+ * @param colStyles an optional std::vector<XLStyleIndex> that contains all pre-evaluated column styles,
232
+ * and can be used to avoid performance impact from lookup
233
+ */
234
+ inline void setDefaultCellAttributes(XMLNode cellNode, const std::string & cellRef, XMLNode rowNode, uint16_t colNo,
235
+ /**/ std::vector<XLStyleIndex> const & colStyles = {})
236
+ {
237
+ cellNode.append_attribute("r").set_value(cellRef.c_str());
238
+ XMLAttribute rowStyle = rowNode.attribute("s");
239
+ XLStyleIndex cellStyle; // scope declaration
240
+ if (rowStyle.empty()) { // if no explicit row style is set
241
+ if (colStyles.size() > 0) // if colStyles were provided
242
+ cellStyle = (colNo > colStyles.size() ? XLDefaultCellFormat : colStyles[ colNo - 1 ]); // determine cellStyle from colStyles
243
+ else // else: no colStyles provided
244
+ cellStyle = getColumnStyle(rowNode, colNo); // so perform a lookup
245
+ }
246
+ else // else: an explicit row style is set
247
+ cellStyle = rowStyle.as_uint(XLDefaultCellFormat); // use the row style
248
+
249
+ if (cellStyle != XLDefaultCellFormat) // if cellStyle was determined as not the default style (no point in setting that)
250
+ cellNode.append_attribute("s").set_value(cellStyle);
251
+ }
252
+
253
+ /**
254
+ * @brief Retrieve the xml node representing the cell at the given row and column. If the node doesn't
255
+ * exist, it will be created.
256
+ * @param rowNode The row node under which to find the cell.
257
+ * @param columnNumber The column at which to find the cell.
258
+ * @param rowNumber (optional) row number of the row node, if already known, defaults to 0
259
+ * @param colStyles an optional std::vector<XLStyleIndex> that contains all pre-evaluated column styles,
260
+ * and can be used to avoid performance impact from lookup
261
+ * @return The xml node representing the requested cell.
262
+ */
263
+ inline XMLNode getCellNode(XMLNode rowNode, uint16_t columnNumber, uint32_t rowNumber = 0,
264
+ /**/ std::vector<XLStyleIndex> const & colStyles = {})
265
+ {
266
+ if (columnNumber < 1 || columnNumber > OpenXLSX::MAX_COLS) { // 2024-08-05: added range check
267
+ using namespace std::literals::string_literals;
268
+ throw XLException("XLWorksheet::column: columnNumber "s + std::to_string(columnNumber) + " is outside allowed range [1;"s + std::to_string(MAX_COLS) + "]"s);
269
+ }
270
+ if (rowNode.empty()) return XMLNode{}; // 2024-05-28: return an empty node in case of empty rowNode
271
+
272
+ XMLNode cellNode = rowNode.last_child_of_type(pugi::node_element);
273
+ if (!rowNumber) rowNumber = rowNode.attribute("r").as_uint(); // if not provided, determine from rowNode
274
+ auto cellRef = XLCellReference(rowNumber, columnNumber);
275
+
276
+ // ===== If there are no cells in the current row, or the requested cell is beyond the last cell in the row...
277
+ if (cellNode.empty() || (XLCellReference(cellNode.attribute("r").value()).column() < columnNumber)) {
278
+ // ===== append a new node to the end.
279
+ cellNode = rowNode.append_child("c");
280
+ setDefaultCellAttributes(cellNode, cellRef.address(), rowNode, columnNumber, colStyles);
281
+ }
282
+ // ===== If the requested node is closest to the end, start from the end and search backwards...
283
+ else if (XLCellReference(cellNode.attribute("r").value()).column() - columnNumber < columnNumber) {
284
+ while (not cellNode.empty() && (XLCellReference(cellNode.attribute("r").value()).column() > columnNumber))
285
+ cellNode = cellNode.previous_sibling_of_type(pugi::node_element);
286
+ // ===== If the backwards search failed to locate the requested cell
287
+ if (cellNode.empty() || (XLCellReference(cellNode.attribute("r").value()).column() < columnNumber)) {
288
+ if (cellNode.empty()) // If between row begin and higher column number, only non-element nodes exist
289
+ cellNode = rowNode.prepend_child("c"); // insert a new cell node at row begin. When saving, this will keep whitespace formatting towards next cell node
290
+ else
291
+ cellNode = rowNode.insert_child_after("c", cellNode);
292
+ setDefaultCellAttributes(cellNode, cellRef.address(), rowNode, columnNumber, colStyles);
293
+ }
294
+ }
295
+ // ===== Otherwise, start from the beginning
296
+ else {
297
+ // ===== At this point, it is guaranteed that there is at least one node_element in the row that is not empty.
298
+ cellNode = rowNode.first_child_of_type(pugi::node_element);
299
+
300
+ // ===== It has been verified above that the requested columnNumber is <= the column number of the last node_element, therefore this loop will halt:
301
+ while (XLCellReference(cellNode.attribute("r").value()).column() < columnNumber)
302
+ cellNode = cellNode.next_sibling_of_type(pugi::node_element);
303
+ // ===== If the forwards search failed to locate the requested cell
304
+ if (XLCellReference(cellNode.attribute("r").value()).column() > columnNumber) {
305
+ cellNode = rowNode.insert_child_before("c", cellNode);
306
+ setDefaultCellAttributes(cellNode, cellRef.address(), rowNode, columnNumber, colStyles);
307
+ }
308
+ }
309
+ return cellNode;
310
+ }
311
+
312
+
313
+ /**
314
+ * @brief find the index of nodeName in nodeOrder
315
+ * @param nodeName search this
316
+ * @param nodeOrder in this
317
+ * @return index of nodeName in nodeOrder
318
+ * @return -1 if nodeName is not an element of nodeOrder
319
+ * @note this function uses a vector of std::string_view because std::string is not constexpr-capable, and in
320
+ * a future c++20 build, a std::span could be used to have the node order in any OpenXLSX class be a constexpr
321
+ */
322
+ constexpr const int SORT_INDEX_NOT_FOUND = -1;
323
+ inline int findStringInVector( std::string const & nodeName, std::vector< std::string_view > const & nodeOrder )
324
+ {
325
+ for (int i = 0; static_cast< size_t >( i ) < nodeOrder.size(); ++i)
326
+ if (nodeName == nodeOrder[ i ]) return i;
327
+ return SORT_INDEX_NOT_FOUND;
328
+ }
329
+
330
+ /**
331
+ * @brief copy all leading pc_data nodes from fromNode to toNode
332
+ * @param parent parent node that can perform sibling insertions
333
+ * @param fromNode node whose preceeding whitespaces shall be duplicated
334
+ * @param toNode node before which the duplicated whitespaces shall be inserted
335
+ * @return N/A
336
+ */
337
+ inline void copyLeadingWhitespaces( XMLNode & parent, XMLNode fromNode, XMLNode toNode )
338
+ {
339
+ fromNode = fromNode.previous_sibling(); // move to preceeding whitespace node, if any
340
+ // loop from back to front, inserting in the same order before toNode
341
+ while (fromNode.type() == pugi::node_pcdata) { // loop ends on pugi::node_element or node_null
342
+ toNode = parent.insert_child_before(pugi::node_pcdata, toNode); // prepend as toNode a new pcdata node
343
+ toNode.set_value(fromNode.value()); // with the value of fromNode
344
+ fromNode = fromNode.previous_sibling();
345
+ }
346
+ }
347
+
348
+ /**
349
+ * @brief ensure that node with nodeName exists in parent and return it
350
+ * @param parent parent node that can perform sibling insertions
351
+ * @param nodename name of the node to be (created &) returned
352
+ * @param nodeOrder optional vector of a predefined element node sequence required by MS Office
353
+ * @param force_ns optional force nodeName namespace
354
+ * @return the requested XMLNode or an empty node if the insert operation failed
355
+ * @note 2024-12-19: appendAndGetNode will attempt to perform an ordered insert per nodeOrder if provided
356
+ * Once sufficiently tested, this functionality might be generalized (e.g. in XLXmlParser OpenXLSX_xml_node)
357
+ */
358
+ inline XMLNode appendAndGetNode(XMLNode & parent, std::string const & nodeName, std::vector< std::string_view > const & nodeOrder = {}, bool force_ns = false )
359
+ {
360
+ if (parent.empty()) return XMLNode{};
361
+
362
+ XMLNode nextNode = parent.first_child_of_type(pugi::node_element);
363
+ if (nextNode.empty()) return parent.prepend_child(nodeName.c_str(), force_ns); // nothing to sort, whitespaces "belong" to parent closing tag
364
+
365
+ XMLNode node{}; // empty until successfully created;
366
+
367
+ int nodeSortIndex = (nodeOrder.size() > 1 ? findStringInVector(nodeName, nodeOrder) : SORT_INDEX_NOT_FOUND);
368
+ if (nodeSortIndex != SORT_INDEX_NOT_FOUND) { // can't sort anything if nodeOrder contains less than 2 entries or does not contain nodeName
369
+ // ===== Find first node to follow nodeName per nodeOrder
370
+ while (not nextNode.empty() && findStringInVector(nextNode.name(), nodeOrder) < nodeSortIndex)
371
+ nextNode = nextNode.next_sibling_of_type(pugi::node_element);
372
+ // ===== Evaluate search result
373
+ if (not nextNode.empty()) { // found nodeName or a node before which nodeName should be inserted
374
+ if( nextNode.name() == nodeName ) // if nodeName was found
375
+ node = nextNode; // use existing node
376
+ else { // else: a node was found before which nodeName must be inserted
377
+ node = parent.insert_child_before(nodeName.c_str(), nextNode, force_ns); // insert before nextNode without whitespaces
378
+ copyLeadingWhitespaces(parent, node, nextNode);
379
+ }
380
+ }
381
+ // else: no node was found before which nodeName should be inserted: proceed as usual
382
+ }
383
+ else // no possibility to perform ordered insert - attempt to locate existing node:
384
+ node = parent.child(nodeName.c_str());
385
+
386
+ if( node.empty() ) { // neither nodeName, nor a node following per nodeOrder was found
387
+ // ===== There is no reference to perform an ordered insert for nodeName
388
+ nextNode = parent.last_child_of_type(pugi::node_element); // at least one element node must exist, tested at begin of function
389
+ node = parent.insert_child_after(nodeName.c_str(), nextNode, force_ns); // append as the last element node, but before final whitespaces
390
+ copyLeadingWhitespaces( parent, nextNode, node ); // duplicate the prefix whitespaces of nextNode to node
391
+ }
392
+
393
+ return node;
394
+ }
395
+
396
+ inline XMLAttribute appendAndGetAttribute(XMLNode & node, std::string const & attrName, std::string const & attrDefaultVal)
397
+ {
398
+ if (node.empty()) return XMLAttribute{};
399
+ XMLAttribute attr = node.attribute(attrName.c_str());
400
+ if (attr.empty()) {
401
+ attr = node.append_attribute(attrName.c_str());
402
+ attr.set_value(attrDefaultVal.c_str());
403
+ }
404
+ return attr;
405
+ }
406
+
407
+ inline XMLAttribute appendAndSetAttribute(XMLNode & node, std::string const & attrName, std::string const & attrVal)
408
+ {
409
+ if (node.empty()) return XMLAttribute{};
410
+ XMLAttribute attr = node.attribute(attrName.c_str());
411
+ if (attr.empty())
412
+ attr = node.append_attribute(attrName.c_str());
413
+ attr.set_value(attrVal.c_str()); // silently fails on empty attribute, which is intended here
414
+ return attr;
415
+ }
416
+
417
+ /**
418
+ * @brief ensure that node with nodeName exists in parent, has an attribute with attrName and return that attribute
419
+ * @param parent parent node that can perform sibling insertions
420
+ * @param nodename name of the node under which attribute attrName shall exist
421
+ * @param attrName name of the attribute to get for node nodeName
422
+ * @param attrDefaultVal value to assign to the attribute if it has to be created
423
+ * @param nodeOrder optional vector of a predefined element node sequence required by MS Office, passed through to appendAndGetNode
424
+ * @returns the requested XMLAttribute or an empty node if the operation failed
425
+ */
426
+ inline XMLAttribute appendAndGetNodeAttribute(XMLNode & parent, std::string const & nodeName, std::string const & attrName, std::string const & attrDefaultVal,
427
+ /**/ std::vector< std::string_view > const & nodeOrder = {})
428
+ {
429
+ if (parent.empty()) return XMLAttribute{};
430
+ XMLNode node = appendAndGetNode(parent, nodeName, nodeOrder);
431
+ return appendAndGetAttribute(node, attrName, attrDefaultVal);
432
+ }
433
+
434
+ /**
435
+ * @brief ensure that node with nodeName exists in parent, has an attribute with attrName, set attribute value and return that attribute
436
+ * @param parent parent node that can perform sibling insertions
437
+ * @param nodename name of the node under which attribute attrName shall exist
438
+ * @param attrName name of the attribute to set for node nodeName
439
+ * @param attrVal value to assign to the attribute
440
+ * @param removeAttributes if true, all other attributes of the node with nodeName will be deleted
441
+ * @param nodeOrder optional vector of a predefined element node sequence required by MS Office, passed through to appendAndGetNode
442
+ * @returns the XMLAttribute that was modified or an empty node if the operation failed
443
+ */
444
+ inline XMLAttribute appendAndSetNodeAttribute(XMLNode & parent, std::string const & nodeName, std::string const & attrName, std::string const & attrVal,
445
+ /**/ bool removeAttributes = XLKeepAttributes, std::vector< std::string_view > const & nodeOrder = {})
446
+ {
447
+ if (parent.empty()) return XMLAttribute{};
448
+ XMLNode node = appendAndGetNode(parent, nodeName, nodeOrder);
449
+ if (removeAttributes) node.remove_attributes();
450
+ return appendAndSetAttribute(node, attrName, attrVal);
451
+ }
452
+
453
+ /**
454
+ * @brief special bool attribute getter function for tags that should have a val="true" or val="false" attribute,
455
+ * but when omitted shall default to "true"
456
+ * @param parent node under which tagName shall be found
457
+ * @param tagName name of the boolean tag to evaluate
458
+ * @param attrName (default: "val") name of boolean attribute that shall default to true
459
+ * @returns true if parent & tagName exist, and attribute with attrName is either omitted or as_bool() returns true. Otherwise return false
460
+ * @note this will create and explicitly set attrName if omitted
461
+ */
462
+ inline bool getBoolAttributeWhenOmittedMeansTrue( XMLNode & parent, std::string const & tagName, std::string const & attrName = "val" )
463
+ {
464
+ if (parent.empty()) return false; // can't do anything
465
+ XMLNode tagNode = parent.child(tagName.c_str());
466
+ if( tagNode.empty() ) return false; // if tag does not exist: return false
467
+ XMLAttribute valAttr = tagNode.attribute(attrName.c_str());
468
+ if( valAttr.empty() ) { // if no attribute with attrName exists: default to true
469
+ appendAndSetAttribute(tagNode, attrName, "true" ); // explicitly create & set attribute
470
+ return true;
471
+ }
472
+ // if execution gets here: attribute with attrName exists
473
+ return valAttr.as_bool(); // return attribute value
474
+ }
475
+
476
+ } // namespace OpenXLSX
477
+
478
+ #endif // OPENXLSX_XLUTILITIES_HPP