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 
19 namespace orcus { namespace spreadsheet {
20 
21 typedef int32_t row_t;
22 typedef int32_t col_t;
23 typedef int32_t sheet_t;
24 typedef uint8_t color_elem_t;
25 typedef uint16_t col_width_t;
26 typedef uint16_t row_height_t;
27 
28 typedef uint32_t pivot_cache_id_t;
29 
30 ORCUS_DLLPUBLIC col_width_t get_default_column_width();
31 ORCUS_DLLPUBLIC row_height_t get_default_row_height();
32 
33 enum 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 
45 enum 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 
57 enum 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 
79 enum 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 
102 enum 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 
114 enum class strikethrough_type_t
115 {
116  unknown = 0,
117  none,
118  single,
119  double_type
120 };
121 
122 enum class strikethrough_width_t
123 {
124  unknown = 0,
125  width_auto,
126  thin,
127  medium,
128  thick,
129  bold
130 };
131 
132 enum class strikethrough_text_t
133 {
134  unknown = 0,
135  slash,
136  cross
137 };
138 
143 enum class formula_grammar_t
144 {
146  unknown = 0,
148  xls_xml,
150  xlsx,
152  ods,
154  gnumeric
155 };
156 
157 enum class formula_t
158 {
159  unknown = 0,
160  array,
161  data_table,
162  normal,
163  shared
164 };
165 
171 enum class formula_ref_context_t
172 {
177  global = 0,
178 
180  named_expression_base,
181 
186  named_range,
187 };
188 
193 enum class formula_error_policy_t
194 {
195  unknown,
197  fail,
199  skip
200 };
201 
202 enum class underline_t
203 {
204  none = 0,
205  single_line,
206  single_accounting, // unique to xlsx
207  double_line,
208  double_accounting, // unique to xlsx
209  dotted,
210  dash,
211  long_dash,
212  dot_dash,
213  dot_dot_dot_dash,
214  wave
215 };
216 
217 enum class underline_width_t
218 {
219  none = 0,
220  normal,
221  bold,
222  thin,
223  medium,
224  thick,
225  positive_integer,
226  percent,
227  positive_length
228 };
229 
230 enum class underline_mode_t
231 {
232  continuos = 0,
233  skip_white_space
234 };
235 
236 enum class underline_type_t
237 {
238  none = 0,
239  single,
240  double_type //necessary to not call it "double", since it is a reserved word
241 };
242 
244 {
245  underline_t underline_style;
246  underline_width_t underline_width;
247  underline_mode_t underline_mode;
248  underline_type_t underline_type;
249 };
250 
251 enum class hor_alignment_t
252 {
253  unknown = 0,
254  left,
255  center,
256  right,
257  justified,
258  distributed,
259  filled
260 };
261 
262 enum class ver_alignment_t
263 {
264  unknown = 0,
265  top,
266  middle,
267  bottom,
268  justified,
269  distributed
270 };
271 
277 enum class data_table_type_t
278 {
279  column,
280  row,
281  both
282 };
283 
287 enum class totals_row_function_t
288 {
289  none = 0,
290  sum,
291  minimum,
292  maximum,
293  average,
294  count,
295  count_numbers,
296  standard_deviation,
297  variance,
298  custom
299 };
300 
301 enum class conditional_format_t
302 {
303  unknown = 0,
304  condition,
305  date,
306  formula,
307  colorscale,
308  databar,
309  iconset
310 };
311 
312 enum class condition_operator_t
313 {
314  unknown = 0,
315  equal,
316  less,
317  greater,
318  greater_equal,
319  less_equal,
320  not_equal,
321  between,
322  not_between,
323  duplicate,
324  unique,
325  top_n,
326  bottom_n,
327  above_average,
328  below_average,
329  above_equal_average,
330  below_equal_average,
331  contains_error,
332  contains_no_error,
333  begins_with,
334  ends_with,
335  contains,
336  contains_blanks,
337  not_contains,
338  expression
339 };
340 
341 enum class condition_type_t
342 {
343  unknown = 0,
344  value,
345  automatic,
346  max,
347  min,
348  formula,
349  percent,
350  percentile
351 };
352 
353 enum class condition_date_t
354 {
355  unknown = 0,
356  today,
357  yesterday,
358  tomorrow,
359  last_7_days,
360  this_week,
361  next_week,
362  last_week,
363  this_month,
364  next_month,
365  last_month,
366  this_year,
367  next_year,
368  last_year,
369 };
370 
371 enum class databar_axis_t
372 {
373  none = 0,
374  middle,
375  automatic
376 };
377 
378 enum class pivot_cache_group_by_t
379 {
380  unknown = 0,
381  days, // grouping on "days" for date values.
382  hours, // grouping on "hours" for date values.
383  minutes, // grouping on "minutes" for date values.
384  months, // grouping on "months" for date values.
385  quarters, // grouping on "quarters" for date values.
386  range, // grouping by numeric ranges for numeric values.
387  seconds, // grouping on "seconds" for date values.
388  years // grouping on "years" for date values.
389 };
390 
391 struct address_t
392 {
393  row_t row;
394  col_t column;
395 };
396 
398 {
399  row_t rows;
400  col_t columns;
401 };
402 
403 struct range_t
404 {
405  address_t first;
406  address_t last;
407 };
408 
414 {
415  sheet_t sheet;
416  row_t row;
417  col_t column;
418 };
419 
425 {
426  src_address_t first;
427  src_address_t last;
428 };
429 
430 ORCUS_DLLPUBLIC address_t to_rc_address(const src_address_t& r);
431 ORCUS_DLLPUBLIC range_t to_rc_range(const src_range_t& r);
432 
433 ORCUS_DLLPUBLIC bool operator== (const address_t& left, const address_t& right);
434 ORCUS_DLLPUBLIC bool operator!= (const address_t& left, const address_t& right);
435 
436 ORCUS_DLLPUBLIC bool operator== (const src_address_t& left, const src_address_t& right);
437 ORCUS_DLLPUBLIC bool operator!= (const src_address_t& left, const src_address_t& right);
438 
439 ORCUS_DLLPUBLIC bool operator== (const range_t& left, const range_t& right);
440 ORCUS_DLLPUBLIC bool operator!= (const range_t& left, const range_t& right);
441 
442 ORCUS_DLLPUBLIC bool operator== (const src_range_t& left, const src_range_t& right);
443 ORCUS_DLLPUBLIC bool operator!= (const src_range_t& left, const src_range_t& right);
444 
445 ORCUS_DLLPUBLIC bool operator< (const range_t& left, const range_t& right);
446 ORCUS_DLLPUBLIC bool operator> (const range_t& left, const range_t& right);
447 
448 ORCUS_DLLPUBLIC range_t& operator+= (range_t& left, const address_t& right);
449 ORCUS_DLLPUBLIC range_t& operator-= (range_t& left, const address_t& right);
450 
451 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const address_t& v);
452 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const src_address_t& v);
453 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const range_t& v);
454 
455 struct ORCUS_DLLPUBLIC color_rgb_t
456 {
457  color_elem_t red;
458  color_elem_t green;
459  color_elem_t blue;
460 
461  color_rgb_t();
462  color_rgb_t(std::initializer_list<color_elem_t> vs);
463  color_rgb_t(const color_rgb_t& other);
464  color_rgb_t(color_rgb_t&& other);
465 
466  color_rgb_t& operator= (const color_rgb_t& other);
467 };
468 
478 ORCUS_DLLPUBLIC totals_row_function_t to_totals_row_function_enum(const char* p, size_t n);
479 
489 ORCUS_DLLPUBLIC pivot_cache_group_by_t to_pivot_cache_group_by_enum(const char* p, size_t n);
490 
500 ORCUS_DLLPUBLIC error_value_t to_error_value_enum(const char* p, size_t n);
501 
513 ORCUS_DLLPUBLIC color_rgb_t to_color_rgb(const char* p, size_t n);
514 
525 ORCUS_DLLPUBLIC color_rgb_t to_color_rgb_from_name(const char* p, size_t n);
526 
535 ORCUS_DLLPUBLIC formula_error_policy_t to_formula_error_policy(const char* p, size_t n);
536 
537 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, error_value_t ev);
538 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, formula_grammar_t grammar);
539 ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const color_rgb_t& color);
540 
541 }}
542 
543 #endif
544 
545 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: sheet.hpp:36
Definition: types.hpp:392
Definition: types.hpp:456
Definition: types.hpp:398
Definition: types.hpp:404
Definition: types.hpp:414
Definition: types.hpp:425
Definition: types.hpp:244