Orcus
types.hpp
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 */
7
8#ifndef ORCUS_SPREADSHEET_TYPES_HPP
9#define ORCUS_SPREADSHEET_TYPES_HPP
10
11#include "orcus/env.hpp"
12#include <cstdlib>
13#include <cstdint>
14#include <iosfwd>
15#include <initializer_list>
16
17// NB: This header should only use primitive data types and enums.
18
19namespace orcus { namespace spreadsheet {
20
21typedef int32_t row_t;
22typedef int32_t col_t;
23typedef int32_t sheet_t;
24typedef uint8_t color_elem_t;
25typedef uint16_t col_width_t;
26typedef uint16_t row_height_t;
27
28typedef uint32_t pivot_cache_id_t;
29
30ORCUS_DLLPUBLIC col_width_t get_default_column_width();
31ORCUS_DLLPUBLIC row_height_t get_default_row_height();
32
33enum class error_value_t
34{
35 unknown = 0,
36 null, // #NULL!
37 div0, // #DIV/0!
38 value, // #VALUE!
39 ref, // #REF!
40 name, // #NAME?
41 num, // #NUM!
42 na // #N/A!
43};
44
45enum class border_direction_t
46{
47 unknown = 0,
48 top,
49 bottom,
50 left,
51 right,
52 diagonal,
53 diagonal_bl_tr,
54 diagonal_tl_br
55};
56
57enum class border_style_t
58{
59 unknown = 0,
60 none,
61 solid,
62 dash_dot,
63 dash_dot_dot,
64 dashed,
65 dotted,
66 double_border,
67 hair,
68 medium,
69 medium_dash_dot,
70 medium_dash_dot_dot,
71 medium_dashed,
72 slant_dash_dot,
73 thick,
74 thin,
75 double_thin,
76 fine_dashed
77};
78
79enum class fill_pattern_t
80{
81 none = 0,
82 solid,
83 dark_down,
84 dark_gray,
85 dark_grid,
86 dark_horizontal,
87 dark_trellis,
88 dark_up,
89 dark_vertical,
90 gray_0625,
91 gray_125,
92 light_down,
93 light_gray,
94 light_grid,
95 light_horizontal,
96 light_trellis,
97 light_up,
98 light_vertical,
99 medium_gray
100};
101
102enum class strikethrough_style_t
103{
104 none = 0,
105 solid,
106 dash,
107 dot_dash,
108 dot_dot_dash,
109 dotted,
110 long_dash,
111 wave
112};
113
114enum class strikethrough_type_t
115{
116 unknown = 0,
117 none,
118 single,
119 double_type
120};
121
122enum class strikethrough_width_t
123{
124 unknown = 0,
125 width_auto,
126 thin,
127 medium,
128 thick,
129 bold
130};
131
132enum class strikethrough_text_t
133{
134 unknown = 0,
135 slash,
136 cross
137};
138
143enum class formula_grammar_t
144{
146 unknown = 0,
148 xls_xml,
150 xlsx,
152 ods,
154 gnumeric
155};
156
157enum class formula_t
158{
159 unknown = 0,
160 array,
161 data_table,
162 normal,
163 shared
164};
165
166enum class underline_t
167{
168 none = 0,
169 single_line,
170 single_accounting, // unique to xlsx
171 double_line,
172 double_accounting, // unique to xlsx
173 dotted,
174 dash,
175 long_dash,
176 dot_dash,
177 dot_dot_dot_dash,
178 wave
179};
180
181enum class underline_width_t
182{
183 none = 0,
184 normal,
185 bold,
186 thin,
187 medium,
188 thick,
189 positive_integer,
190 percent,
191 positive_length
192};
193
194enum class underline_mode_t
195{
196 continuos = 0,
197 skip_white_space
198};
199
200enum class underline_type_t
201{
202 none = 0,
203 single,
204 double_type //necessary to not call it "double", since it is a reserved word
205};
206
208{
209 underline_t underline_style;
210 underline_width_t underline_width;
211 underline_mode_t underline_mode;
212 underline_type_t underline_type;
213};
214
215enum class hor_alignment_t
216{
217 unknown = 0,
218 left,
219 center,
220 right,
221 justified,
222 distributed,
223 filled
224};
225
226enum class ver_alignment_t
227{
228 unknown = 0,
229 top,
230 middle,
231 bottom,
232 justified,
233 distributed
234};
235
241enum class data_table_type_t
242{
243 column,
244 row,
245 both
246};
247
251enum class totals_row_function_t
252{
253 none = 0,
254 sum,
255 minimum,
256 maximum,
257 average,
258 count,
259 count_numbers,
260 standard_deviation,
261 variance,
262 custom
263};
264
265enum class conditional_format_t
266{
267 unknown = 0,
268 condition,
269 date,
270 formula,
271 colorscale,
272 databar,
273 iconset
274};
275
276enum class condition_operator_t
277{
278 unknown = 0,
279 equal,
280 less,
281 greater,
282 greater_equal,
283 less_equal,
284 not_equal,
285 between,
286 not_between,
287 duplicate,
288 unique,
289 top_n,
290 bottom_n,
291 above_average,
292 below_average,
293 above_equal_average,
294 below_equal_average,
295 contains_error,
296 contains_no_error,
297 begins_with,
298 ends_with,
299 contains,
300 contains_blanks,
301 not_contains,
302 expression
303};
304
305enum class condition_type_t
306{
307 unknown = 0,
308 value,
309 automatic,
310 max,
311 min,
312 formula,
313 percent,
314 percentile
315};
316
317enum class condition_date_t
318{
319 unknown = 0,
320 today,
321 yesterday,
322 tomorrow,
323 last_7_days,
324 this_week,
325 next_week,
326 last_week,
327 this_month,
328 next_month,
329 last_month,
330 this_year,
331 next_year,
332 last_year,
333};
334
335enum class databar_axis_t
336{
337 none = 0,
338 middle,
339 automatic
340};
341
342enum class pivot_cache_group_by_t
343{
344 unknown = 0,
345 days, // grouping on "days" for date values.
346 hours, // grouping on "hours" for date values.
347 minutes, // grouping on "minutes" for date values.
348 months, // grouping on "months" for date values.
349 quarters, // grouping on "quarters" for date values.
350 range, // grouping by numeric ranges for numeric values.
351 seconds, // grouping on "seconds" for date values.
352 years // grouping on "years" for date values.
353};
354
356{
357 row_t row;
358 col_t column;
359};
360
362{
363 row_t rows;
364 col_t columns;
365};
366
368{
369 address_t first;
370 address_t last;
371};
372
373ORCUS_DLLPUBLIC bool operator== (const address_t& left, const address_t& right);
374ORCUS_DLLPUBLIC bool operator!= (const address_t& left, const address_t& right);
375
376ORCUS_DLLPUBLIC bool operator== (const range_t& left, const range_t& right);
377ORCUS_DLLPUBLIC bool operator!= (const range_t& left, const range_t& right);
378ORCUS_DLLPUBLIC bool operator< (const range_t& left, const range_t& right);
379ORCUS_DLLPUBLIC bool operator> (const range_t& left, const range_t& right);
380
381ORCUS_DLLPUBLIC range_t& operator+= (range_t& left, const address_t& right);
382ORCUS_DLLPUBLIC range_t& operator-= (range_t& left, const address_t& right);
383
384ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const address_t& v);
385ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const range_t& v);
386
387struct ORCUS_DLLPUBLIC color_rgb_t
388{
389 color_elem_t red;
390 color_elem_t green;
391 color_elem_t blue;
392
393 color_rgb_t();
394 color_rgb_t(std::initializer_list<color_elem_t> vs);
395 color_rgb_t(const color_rgb_t& other);
396 color_rgb_t(color_rgb_t&& other);
397
398 color_rgb_t& operator= (const color_rgb_t& other);
399};
400
410ORCUS_DLLPUBLIC totals_row_function_t to_totals_row_function_enum(const char* p, size_t n);
411
421ORCUS_DLLPUBLIC pivot_cache_group_by_t to_pivot_cache_group_by_enum(const char* p, size_t n);
422
432ORCUS_DLLPUBLIC error_value_t to_error_value_enum(const char* p, size_t n);
433
445ORCUS_DLLPUBLIC color_rgb_t to_color_rgb(const char* p, size_t n);
446
457ORCUS_DLLPUBLIC color_rgb_t to_color_rgb_from_name(const char* p, size_t n);
458
459ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, error_value_t ev);
460ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, formula_grammar_t grammar);
461ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const color_rgb_t& color);
462
463}}
464
465#endif
466
467/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: types.hpp:356
Definition: types.hpp:388
Definition: types.hpp:362
Definition: types.hpp:368
Definition: types.hpp:208