react-native-nitro-xlsx 0.2.6 → 0.2.7

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 (57) hide show
  1. package/README.md +20 -8
  2. package/cpp/HybridNitroXlsx.cpp +25 -1
  3. package/cpp/HybridXlsxCellFormat.cpp +46 -146
  4. package/cpp/HybridXlsxCellFormat.hpp +9 -41
  5. package/cpp/HybridXlsxConditionalFormat.cpp +4 -1
  6. package/cpp/HybridXlsxConditionalFormats.cpp +5 -1
  7. package/cpp/HybridXlsxWorkbook.cpp +38 -8
  8. package/cpp/HybridXlsxWorkbook.hpp +10 -1
  9. package/cpp/HybridXlsxWorksheet.cpp +422 -141
  10. package/cpp/HybridXlsxWorksheet.hpp +4 -1
  11. package/cpp/XlsxCacheDir.cpp +25 -2
  12. package/cpp/XlsxCacheDir.hpp +3 -1
  13. package/cpp/XlsxCellStyle.hpp +360 -0
  14. package/cpp/XlsxJson.cpp +29 -8
  15. package/package.json +1 -1
  16. package/scripts/sync-openxlsx-headers.sh +34 -0
  17. package/src/__mocks__/react-native-nitro-modules.ts +523 -20
  18. package/src/__tests__/index.test.ts +124 -16
  19. package/src/index.ts +13 -13
  20. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/IZipArchive.hpp +361 -0
  21. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/OpenXLSX-Exports.hpp +12 -0
  22. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLCell.hpp +367 -0
  23. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLCellIterator.hpp +252 -0
  24. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLCellRange.hpp +223 -0
  25. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLCellReference.hpp +317 -0
  26. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLCellValue.hpp +793 -0
  27. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLColor.hpp +232 -0
  28. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLColumn.hpp +159 -0
  29. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLCommandQuery.hpp +228 -0
  30. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLComments.hpp +270 -0
  31. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLConstants.hpp +18 -0
  32. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLContentTypes.hpp +264 -0
  33. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLDateTime.hpp +175 -0
  34. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLDocument.hpp +505 -0
  35. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLDrawing.hpp +452 -0
  36. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLException.hpp +161 -0
  37. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLFormula.hpp +375 -0
  38. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLIterator.hpp +40 -0
  39. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLMergeCells.hpp +216 -0
  40. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLProperties.hpp +348 -0
  41. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLRelationships.hpp +348 -0
  42. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLRow.hpp +721 -0
  43. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLRowData.hpp +488 -0
  44. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLSharedStrings.hpp +204 -0
  45. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLSheet.hpp +1640 -0
  46. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLStyles.hpp +2390 -0
  47. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLTables.hpp +132 -0
  48. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLWorkbook.hpp +404 -0
  49. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLXmlData.hpp +283 -0
  50. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLXmlFile.hpp +194 -0
  51. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLXmlParser.hpp +282 -0
  52. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLXmlParserForwardDeclarations.hpp +85 -0
  53. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/XLZipArchive.hpp +232 -0
  54. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/detail/LibZip.hpp +447 -0
  55. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/detail/OpenXLSXFileSystemTools.hpp +207 -0
  56. package/thirdparty/OpenXLSX/OpenXLSX/headers/OpenXLSX/detail/Zippy.hpp +1375 -0
  57. package/thirdparty/README.md +7 -3
@@ -0,0 +1,232 @@
1
+ /*
2
+
3
+ ____ ____ ___ ____ ____ ____ ___
4
+ 6MMMMb `MM( )M' `MM' 6MMMMb\`MM( )M'
5
+ 8P Y8 `MM. d' MM 6M' ` `MM. d'
6
+ 6M Mb __ ____ ____ ___ __ `MM. d' MM MM `MM. d'
7
+ MM MM `M6MMMMb 6MMMMb `MM 6MMb `MM. d' MM YM. `MM. d'
8
+ MM MM MM' `Mb 6M' `Mb MMM9 `Mb `MMd MM YMMMMb `MMd
9
+ MM MM MM MM MM MM MM' MM dMM. MM `Mb dMM.
10
+ MM MM MM MM MMMMMMMM MM MM d'`MM. MM MM d'`MM.
11
+ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM.
12
+ 8b d8 MM. ,M9 YM d9 MM MM d' `MM. MM / L ,M9 d' `MM.
13
+ YMMMM9 MMYMMM9 YMMMM9 _MM_ _MM_M(_ _)MM_ _MMMMMMM MYMMMM9 _M(_ _)MM_
14
+ MM
15
+ MM
16
+ _MM_
17
+
18
+ Copyright (c) 2018, Kenneth Troldal Balslev
19
+
20
+ All rights reserved.
21
+
22
+ Redistribution and use in source and binary forms, with or without
23
+ modification, are permitted provided that the following conditions are met:
24
+ - Redistributions of source code must retain the above copyright
25
+ notice, this list of conditions and the following disclaimer.
26
+ - Redistributions in binary form must reproduce the above copyright
27
+ notice, this list of conditions and the following disclaimer in the
28
+ documentation and/or other materials provided with the distribution.
29
+ - Neither the name of the author nor the
30
+ names of any contributors may be used to endorse or promote products
31
+ derived from this software without specific prior written permission.
32
+
33
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
34
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
35
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
37
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
39
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
40
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
41
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43
+
44
+ */
45
+
46
+ #ifndef OPENXLSX_XLCOLOR_HPP
47
+ #define OPENXLSX_XLCOLOR_HPP
48
+
49
+ #ifdef _MSC_VER // conditionally enable MSVC specific pragmas to avoid other compilers warning about unknown pragmas
50
+ # pragma warning(push)
51
+ # pragma warning(disable : 4251)
52
+ # pragma warning(disable : 4275)
53
+ #endif // _MSC_VER
54
+
55
+ // ===== External Includes ===== //
56
+ #include <cstdint> // Pull request #276
57
+ #include <string>
58
+
59
+ // ===== OpenXLSX Includes ===== //
60
+ #include "OpenXLSX-Exports.hpp"
61
+
62
+ namespace OpenXLSX
63
+ {
64
+ /**
65
+ * @brief
66
+ */
67
+ class OPENXLSX_EXPORT XLColor
68
+ {
69
+ //----------------------------------------------------------------------------------------------------------------------
70
+ // Public Member Functions
71
+ //----------------------------------------------------------------------------------------------------------------------
72
+
73
+ friend bool operator==(const XLColor& lhs, const XLColor& rhs);
74
+ friend bool operator!=(const XLColor& lhs, const XLColor& rhs);
75
+
76
+ public:
77
+ /**
78
+ * @brief
79
+ */
80
+ XLColor();
81
+
82
+ /**
83
+ * @brief
84
+ * @param alpha
85
+ * @param red
86
+ * @param green
87
+ * @param blue
88
+ */
89
+ XLColor(uint8_t alpha, uint8_t red, uint8_t green, uint8_t blue);
90
+
91
+ /**
92
+ * @brief
93
+ * @param red
94
+ * @param green
95
+ * @param blue
96
+ */
97
+ XLColor(uint8_t red, uint8_t green, uint8_t blue);
98
+
99
+ /**
100
+ * @brief
101
+ * @param hexCode
102
+ */
103
+ explicit XLColor(const std::string& hexCode);
104
+
105
+ /**
106
+ * @brief
107
+ * @param other
108
+ */
109
+ XLColor(const XLColor& other);
110
+
111
+ /**
112
+ * @brief
113
+ * @param other
114
+ */
115
+ XLColor(XLColor&& other) noexcept;
116
+
117
+ /**
118
+ * @brief
119
+ */
120
+ ~XLColor();
121
+
122
+ /**
123
+ * @brief
124
+ * @param other
125
+ * @return
126
+ */
127
+ XLColor& operator=(const XLColor& other);
128
+
129
+ /**
130
+ * @brief
131
+ * @param other
132
+ * @return
133
+ */
134
+ XLColor& operator=(XLColor&& other) noexcept;
135
+
136
+ /**
137
+ * @brief
138
+ * @param alpha
139
+ * @param red
140
+ * @param green
141
+ * @param blue
142
+ */
143
+ void set(uint8_t alpha, uint8_t red, uint8_t green, uint8_t blue);
144
+
145
+ /**
146
+ * @brief
147
+ * @param red
148
+ * @param green
149
+ * @param blue
150
+ */
151
+ void set(uint8_t red = 0, uint8_t green = 0, uint8_t blue = 0);
152
+
153
+ /**
154
+ * @brief
155
+ * @param hexCode
156
+ */
157
+ void set(const std::string& hexCode);
158
+
159
+ /**
160
+ * @brief
161
+ * @return
162
+ */
163
+ uint8_t alpha() const;
164
+
165
+ /**
166
+ * @brief
167
+ * @return
168
+ */
169
+ uint8_t red() const;
170
+
171
+ /**
172
+ * @brief
173
+ * @return
174
+ */
175
+ uint8_t green() const;
176
+
177
+ /**
178
+ * @brief
179
+ * @return
180
+ */
181
+ uint8_t blue() const;
182
+
183
+ /**
184
+ * @brief
185
+ * @return
186
+ */
187
+ std::string hex() const;
188
+
189
+ //----------------------------------------------------------------------------------------------------------------------
190
+ // Private Member Variables
191
+ //----------------------------------------------------------------------------------------------------------------------
192
+
193
+ private:
194
+ uint8_t m_alpha { 255 };
195
+
196
+ uint8_t m_red { 0 };
197
+
198
+ uint8_t m_green { 0 };
199
+
200
+ uint8_t m_blue { 0 };
201
+ };
202
+
203
+ } // namespace OpenXLSX
204
+
205
+ namespace OpenXLSX
206
+ {
207
+ /**
208
+ * @brief
209
+ * @param lhs
210
+ * @param rhs
211
+ * @return
212
+ */
213
+ inline bool operator==(const XLColor& lhs, const XLColor& rhs)
214
+ {
215
+ return lhs.alpha() == rhs.alpha() && lhs.red() == rhs.red() && lhs.green() == rhs.green() && lhs.blue() == rhs.blue();
216
+ }
217
+
218
+ /**
219
+ * @brief
220
+ * @param lhs
221
+ * @param rhs
222
+ * @return
223
+ */
224
+ inline bool operator!=(const XLColor& lhs, const XLColor& rhs) { return !(lhs == rhs); }
225
+
226
+ } // namespace OpenXLSX
227
+
228
+ #ifdef _MSC_VER // conditionally enable MSVC specific pragmas to avoid other compilers warning about unknown pragmas
229
+ # pragma warning(pop)
230
+ #endif // _MSC_VER
231
+
232
+ #endif // OPENXLSX_XLCOLOR_HPP
@@ -0,0 +1,159 @@
1
+ /*
2
+
3
+ ____ ____ ___ ____ ____ ____ ___
4
+ 6MMMMb `MM( )M' `MM' 6MMMMb\`MM( )M'
5
+ 8P Y8 `MM. d' MM 6M' ` `MM. d'
6
+ 6M Mb __ ____ ____ ___ __ `MM. d' MM MM `MM. d'
7
+ MM MM `M6MMMMb 6MMMMb `MM 6MMb `MM. d' MM YM. `MM. d'
8
+ MM MM MM' `Mb 6M' `Mb MMM9 `Mb `MMd MM YMMMMb `MMd
9
+ MM MM MM MM MM MM MM' MM dMM. MM `Mb dMM.
10
+ MM MM MM MM MMMMMMMM MM MM d'`MM. MM MM d'`MM.
11
+ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM.
12
+ 8b d8 MM. ,M9 YM d9 MM MM d' `MM. MM / L ,M9 d' `MM.
13
+ YMMMM9 MMYMMM9 YMMMM9 _MM_ _MM_M(_ _)MM_ _MMMMMMM MYMMMM9 _M(_ _)MM_
14
+ MM
15
+ MM
16
+ _MM_
17
+
18
+ Copyright (c) 2018, Kenneth Troldal Balslev
19
+
20
+ All rights reserved.
21
+
22
+ Redistribution and use in source and binary forms, with or without
23
+ modification, are permitted provided that the following conditions are met:
24
+ - Redistributions of source code must retain the above copyright
25
+ notice, this list of conditions and the following disclaimer.
26
+ - Redistributions in binary form must reproduce the above copyright
27
+ notice, this list of conditions and the following disclaimer in the
28
+ documentation and/or other materials provided with the distribution.
29
+ - Neither the name of the author nor the
30
+ names of any contributors may be used to endorse or promote products
31
+ derived from this software without specific prior written permission.
32
+
33
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
34
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
35
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
37
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
39
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
40
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
41
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43
+
44
+ */
45
+
46
+ #ifndef OPENXLSX_XLCOLUMN_HPP
47
+ #define OPENXLSX_XLCOLUMN_HPP
48
+
49
+ #ifdef _MSC_VER // conditionally enable MSVC specific pragmas to avoid other compilers warning about unknown pragmas
50
+ # pragma warning(push)
51
+ # pragma warning(disable : 4251)
52
+ # pragma warning(disable : 4275)
53
+ #endif // _MSC_VER
54
+
55
+ // ===== External Includes ===== //
56
+ #include <memory>
57
+
58
+ // ===== OpenXLSX Includes ===== //
59
+ #include "OpenXLSX-Exports.hpp"
60
+ #include "XLStyles.hpp" // XLStyleIndex
61
+ #include "XLXmlParserForwardDeclarations.hpp"
62
+
63
+ namespace OpenXLSX
64
+ {
65
+ /**
66
+ * @brief
67
+ */
68
+ class OPENXLSX_EXPORT XLColumn
69
+ {
70
+ public:
71
+ /**
72
+ * @brief Constructor
73
+ * @param columnNode A pointer to the XMLNode for the column.
74
+ */
75
+ explicit XLColumn(const XMLNode& columnNode);
76
+
77
+ /**
78
+ * @brief Copy Constructor
79
+ */
80
+ XLColumn(const XLColumn& other);
81
+
82
+ /**
83
+ * @brief Move Constructor
84
+ * @note The move constructor has been explicitly deleted.
85
+ */
86
+ XLColumn(XLColumn&& other) noexcept;
87
+
88
+ /**
89
+ * @brief Destructor
90
+ */
91
+ ~XLColumn();
92
+
93
+ /**
94
+ * @brief Copy assignment operator
95
+ */
96
+ XLColumn& operator=(const XLColumn& other);
97
+
98
+ /**
99
+ * @brief Move assignment operator
100
+ * @param other
101
+ * @return
102
+ */
103
+ XLColumn& operator=(XLColumn&& other) noexcept;
104
+
105
+ /**
106
+ * @brief Get the width of the column.
107
+ * @return The width of the column.
108
+ */
109
+ float width() const;
110
+
111
+ /**
112
+ * @brief Set the width of the column
113
+ * @param width The width of the column
114
+ */
115
+ void setWidth(float width);
116
+
117
+ /**
118
+ * @brief Is the column hidden?
119
+ * @return The state of the column.
120
+ */
121
+ bool isHidden() const;
122
+
123
+ /**
124
+ * @brief Set the column to be shown or hidden.
125
+ * @param state The state of the column.
126
+ */
127
+ void setHidden(bool state);
128
+
129
+ /**
130
+ * @brief Get the XMLNode object for the column.
131
+ * @return The XMLNode for the column
132
+ */
133
+ XMLNode& columnNode() const;
134
+
135
+ /**
136
+ * @brief Get the array index of xl/styles.xml:<styleSheet>:<cellXfs> for the style assigned to the column.
137
+ * This value is stored in the col attributes like so: style="2"
138
+ * @returns The index of the applicable format style
139
+ */
140
+ XLStyleIndex format() const;
141
+
142
+ /**
143
+ * @brief Set the column style as a reference to the array index of xl/styles.xml:<styleSheet>:<cellXfs>
144
+ * @param cellFormatIndex The style to set, corresponding to the index of XLStyles::cellStyles()
145
+ * @returns true on success, false on failure
146
+ */
147
+ bool setFormat(XLStyleIndex cellFormatIndex);
148
+
149
+ private:
150
+ std::unique_ptr<XMLNode> m_columnNode; /**< A pointer to the XMLNode object for the column. */
151
+ };
152
+
153
+ } // namespace OpenXLSX
154
+
155
+ #ifdef _MSC_VER // conditionally enable MSVC specific pragmas to avoid other compilers warning about unknown pragmas
156
+ # pragma warning(pop)
157
+ #endif // _MSC_VER
158
+
159
+ #endif // OPENXLSX_XLCOLUMN_HPP
@@ -0,0 +1,228 @@
1
+ /*
2
+
3
+ ____ ____ ___ ____ ____ ____ ___
4
+ 6MMMMb `MM( )M' `MM' 6MMMMb\`MM( )M'
5
+ 8P Y8 `MM. d' MM 6M' ` `MM. d'
6
+ 6M Mb __ ____ ____ ___ __ `MM. d' MM MM `MM. d'
7
+ MM MM `M6MMMMb 6MMMMb `MM 6MMb `MM. d' MM YM. `MM. d'
8
+ MM MM MM' `Mb 6M' `Mb MMM9 `Mb `MMd MM YMMMMb `MMd
9
+ MM MM MM MM MM MM MM' MM dMM. MM `Mb dMM.
10
+ MM MM MM MM MMMMMMMM MM MM d'`MM. MM MM d'`MM.
11
+ YM M9 MM MM MM MM MM d' `MM. MM MM d' `MM.
12
+ 8b d8 MM. ,M9 YM d9 MM MM d' `MM. MM / L ,M9 d' `MM.
13
+ YMMMM9 MMYMMM9 YMMMM9 _MM_ _MM_M(_ _)MM_ _MMMMMMM MYMMMM9 _M(_ _)MM_
14
+ MM
15
+ MM
16
+ _MM_
17
+
18
+ Copyright (c) 2018, Kenneth Troldal Balslev
19
+
20
+ All rights reserved.
21
+
22
+ Redistribution and use in source and binary forms, with or without
23
+ modification, are permitted provided that the following conditions are met:
24
+ - Redistributions of source code must retain the above copyright
25
+ notice, this list of conditions and the following disclaimer.
26
+ - Redistributions in binary form must reproduce the above copyright
27
+ notice, this list of conditions and the following disclaimer in the
28
+ documentation and/or other materials provided with the distribution.
29
+ - Neither the name of the author nor the
30
+ names of any contributors may be used to endorse or promote products
31
+ derived from this software without specific prior written permission.
32
+
33
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
34
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
35
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
37
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
39
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
40
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
41
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43
+
44
+ */
45
+
46
+ #ifndef OPENXLSX_XLCOMMANDQUERY_HPP
47
+ #define OPENXLSX_XLCOMMANDQUERY_HPP
48
+
49
+ #ifdef _MSC_VER // conditionally enable MSVC specific pragmas to avoid other compilers warning about unknown pragmas
50
+ # pragma warning(push)
51
+ # pragma warning(disable : 4251)
52
+ # pragma warning(disable : 4275)
53
+ #endif // _MSC_VER
54
+
55
+ // ===== External Includes ===== //
56
+ #include <any>
57
+ #include <cstdint> // uint8_t
58
+ #include <map>
59
+ #include <string>
60
+
61
+ namespace OpenXLSX
62
+ {
63
+ /**
64
+ * @brief
65
+ */
66
+ enum class XLCommandType : uint8_t {
67
+ SetSheetName,
68
+ SetSheetColor,
69
+ SetSheetVisibility,
70
+ SetSheetIndex,
71
+ SetSheetActive,
72
+ ResetCalcChain,
73
+ CheckAndFixCoreProperties,
74
+ CheckAndFixExtendedProperties,
75
+ AddSharedStrings,
76
+ AddWorksheet,
77
+ AddChartsheet,
78
+ DeleteSheet,
79
+ CloneSheet,
80
+ AddStyles
81
+ };
82
+
83
+ /**
84
+ * @brief
85
+ */
86
+ class XLCommand
87
+ {
88
+ public:
89
+ /**
90
+ * @brief
91
+ * @param type
92
+ */
93
+ explicit XLCommand(XLCommandType type) : m_type(type) {}
94
+
95
+ /**
96
+ * @brief
97
+ * @tparam T
98
+ * @param param
99
+ * @param value
100
+ * @return
101
+ */
102
+ template<typename T>
103
+ XLCommand& setParam(const std::string& param, T value)
104
+ {
105
+ m_params[param] = value;
106
+ return *this;
107
+ }
108
+
109
+ /**
110
+ * @brief
111
+ * @tparam T
112
+ * @param param
113
+ * @return
114
+ */
115
+ template<typename T>
116
+ T getParam(const std::string& param) const
117
+ {
118
+ return std::any_cast<T>(m_params.at(param));
119
+ }
120
+
121
+ /**
122
+ * @brief
123
+ * @return
124
+ */
125
+ XLCommandType type() const { return m_type; }
126
+
127
+ private:
128
+ XLCommandType m_type; /*< */
129
+ std::map<std::string, std::any> m_params; /*< */
130
+ };
131
+
132
+ /**
133
+ * @brief
134
+ */
135
+ enum class XLQueryType : uint8_t {
136
+ QuerySheetName,
137
+ QuerySheetIndex,
138
+ QuerySheetVisibility,
139
+ QuerySheetIsActive,
140
+ QuerySheetType,
141
+ QuerySheetID,
142
+ QuerySheetRelsID,
143
+ QuerySheetRelsTarget,
144
+ QuerySharedStrings,
145
+ QueryXmlData
146
+ };
147
+
148
+ /**
149
+ * @brief
150
+ */
151
+ class XLQuery
152
+ {
153
+ public:
154
+ /**
155
+ * @brief
156
+ * @param type
157
+ */
158
+ explicit XLQuery(XLQueryType type) : m_type(type) {}
159
+
160
+ /**
161
+ * @brief
162
+ * @tparam T
163
+ * @param param
164
+ * @param value
165
+ * @return
166
+ */
167
+ template<typename T>
168
+ XLQuery& setParam(const std::string& param, T value)
169
+ {
170
+ m_params[param] = value;
171
+ return *this;
172
+ }
173
+
174
+ /**
175
+ * @brief
176
+ * @tparam T
177
+ * @param param
178
+ * @return
179
+ */
180
+ template<typename T>
181
+ T getParam(const std::string& param) const
182
+ {
183
+ return std::any_cast<T>(m_params.at(param));
184
+ }
185
+
186
+ /**
187
+ * @brief
188
+ * @tparam T
189
+ * @param value
190
+ * @return
191
+ */
192
+ template<typename T>
193
+ XLQuery& setResult(T value)
194
+ {
195
+ m_result = value;
196
+ return *this;
197
+ }
198
+
199
+ /**
200
+ * @brief
201
+ * @tparam T
202
+ * @return
203
+ */
204
+ template<typename T>
205
+ T result() const
206
+ {
207
+ return std::any_cast<T>(m_result);
208
+ }
209
+
210
+ /**
211
+ * @brief
212
+ * @return
213
+ */
214
+ XLQueryType type() const { return m_type; }
215
+
216
+ private:
217
+ XLQueryType m_type; /*< */
218
+ std::any m_result; /*< */
219
+ std::map<std::string, std::any> m_params; /*< */
220
+ };
221
+
222
+ } // namespace OpenXLSX
223
+
224
+ #ifdef _MSC_VER // conditionally enable MSVC specific pragmas to avoid other compilers warning about unknown pragmas
225
+ # pragma warning(pop)
226
+ #endif // _MSC_VER
227
+
228
+ #endif // OPENXLSX_XLCOMMANDQUERY_HPP