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 "../env.hpp"
12
13#include <cstdlib>
14#include <cstdint>
15#include <iosfwd>
16#include <initializer_list>
17#include <string_view>
18
19// NB: This header should only use primitive data types and enums.
20
21namespace orcus { namespace spreadsheet {
22
23typedef int32_t row_t;
24typedef int32_t col_t;
25typedef int32_t sheet_t;
26typedef uint8_t color_elem_t;
27typedef uint16_t col_width_t;
28typedef uint16_t row_height_t;
29typedef uint32_t string_id_t;
30
31typedef uint32_t pivot_cache_id_t;
32
33ORCUS_DLLPUBLIC col_width_t get_default_column_width();
34ORCUS_DLLPUBLIC row_height_t get_default_row_height();
35
36enum class error_value_t
37{
38 unknown = 0,
39 null, // #NULL!
40 div0, // #DIV/0!
41 value, // #VALUE!
42 ref, // #REF!
43 name, // #NAME?
44 num, // #NUM!
45 na // #N/A!
46};
47
48enum class border_direction_t
49{
50 unknown = 0,
51 top,
52 bottom,
53 left,
54 right,
55 diagonal,
56 diagonal_bl_tr,
57 diagonal_tl_br
58};
59
60enum class border_style_t
61{
62 unknown = 0,
63 none,
64 solid,
65 dash_dot,
66 dash_dot_dot,
67 dashed,
68 dotted,
69 double_border,
70 hair,
71 medium,
72 medium_dash_dot,
73 medium_dash_dot_dot,
74 medium_dashed,
75 slant_dash_dot,
76 thick,
77 thin,
78 double_thin,
79 fine_dashed
80};
81
82enum class fill_pattern_t
83{
84 none = 0,
85 solid,
86 dark_down,
87 dark_gray,
88 dark_grid,
89 dark_horizontal,
90 dark_trellis,
91 dark_up,
92 dark_vertical,
93 gray_0625,
94 gray_125,
95 light_down,
96 light_gray,
97 light_grid,
98 light_horizontal,
99 light_trellis,
100 light_up,
101 light_vertical,
102 medium_gray
103};
104
105enum class strikethrough_style_t
106{
107 none = 0,
108 solid,
109 dash,
110 dot_dash,
111 dot_dot_dash,
112 dotted,
113 long_dash,
114 wave
115};
116
117enum class strikethrough_type_t
118{
119 unknown = 0,
120 none,
121 single,
122 double_type
123};
124
125enum class strikethrough_width_t
126{
127 unknown = 0,
128 width_auto,
129 thin,
130 medium,
131 thick,
132 bold
133};
134
135enum class strikethrough_text_t
136{
137 unknown = 0,
138 slash,
139 cross
140};
141
146enum class formula_grammar_t
147{
149 unknown = 0,
151 xls_xml,
153 xlsx,
155 ods,
157 gnumeric
158};
159
160enum class formula_t
161{
162 unknown = 0,
163 array,
164 data_table,
165 normal,
166 shared
167};
168
174enum class formula_ref_context_t
175{
180 global = 0,
181
183 named_expression_base,
184
189 named_range,
190};
191
196enum class formula_error_policy_t
197{
198 unknown,
200 fail,
202 skip
203};
204
205enum class underline_t
206{
207 none = 0,
208 single_line,
209 single_accounting, // unique to xlsx
210 double_line,
211 double_accounting, // unique to xlsx
212 dotted,
213 dash,
214 long_dash,
215 dot_dash,
216 dot_dot_dot_dash, // TODO:API: -> dot_dot_dash
217 wave
218};
219
220enum class underline_width_t
221{
222 none = 0,
223 normal,
224 bold,
225 thin,
226 medium,
227 thick,
228 positive_integer,
229 percent,
230 positive_length
231};
232
233enum class underline_mode_t
234{
235 continuos = 0, // TODO:API: fix this typo
236 skip_white_space
237};
238
239enum class underline_type_t
240{
241 none = 0,
242 single, // TODO:API: standardize these values
243 double_type //necessary to not call it "double", since it is a reserved word
244};
245
247{
248 underline_t underline_style;
249 underline_width_t underline_width;
250 underline_mode_t underline_mode;
251 underline_type_t underline_type;
252};
253
254enum class hor_alignment_t
255{
256 unknown = 0,
257 left,
258 center,
259 right,
260 justified,
261 distributed,
262 filled
263};
264
265enum class ver_alignment_t
266{
267 unknown = 0,
268 top,
269 middle,
270 bottom,
271 justified,
272 distributed
273};
274
280enum class data_table_type_t
281{
282 column,
283 row,
284 both
285};
286
290enum class totals_row_function_t
291{
292 none = 0,
293 sum,
294 minimum,
295 maximum,
296 average,
297 count,
298 count_numbers,
299 standard_deviation,
300 variance,
301 custom
302};
303
304enum class conditional_format_t
305{
306 unknown = 0,
307 condition,
308 date,
309 formula,
310 colorscale,
311 databar,
312 iconset
313};
314
315enum class condition_operator_t
316{
317 unknown = 0,
318 equal,
319 less,
320 greater,
321 greater_equal,
322 less_equal,
323 not_equal,
324 between,
325 not_between,
326 duplicate,
327 unique,
328 top_n,
329 bottom_n,
330 above_average,
331 below_average,
332 above_equal_average,
333 below_equal_average,
334 contains_error,
335 contains_no_error,
336 begins_with,
337 ends_with,
338 contains,
339 contains_blanks,
340 not_contains,
341 expression
342};
343
344enum class condition_type_t
345{
346 unknown = 0,
347 value,
348 automatic,
349 max,
350 min,
351 formula,
352 percent,
353 percentile
354};
355
356enum class condition_date_t
357{
358 unknown = 0,
359 today,
360 yesterday,
361 tomorrow,
362 last_7_days,
363 this_week,
364 next_week,
365 last_week,
366 this_month,
367 next_month,
368 last_month,
369 this_year,
370 next_year,
371 last_year,
372};
373
374enum class databar_axis_t
375{
376 none = 0,
377 middle,
378 automatic
379};
380
381enum class pivot_cache_group_by_t
382{
383 unknown = 0,
384 days, // grouping on "days" for date values.
385 hours, // grouping on "hours" for date values.
386 minutes, // grouping on "minutes" for date values.
387 months, // grouping on "months" for date values.
388 quarters, // grouping on "quarters" for date values.
389 range, // grouping by numeric ranges for numeric values.
390 seconds, // grouping on "seconds" for date values.
391 years // grouping on "years" for date values.
392};
393
395{
396 row_t row;
397 col_t column;
398};
399
401{
402 row_t rows;
403 col_t columns;
404};
405
407{
408 address_t first;
409 address_t last;
410};
411
417{
418 sheet_t sheet;
419 row_t row;
420 col_t column;
421};
422
428{
429 src_address_t first;
430 src_address_t last;
431};
432
433ORCUS_DLLPUBLIC address_t to_rc_address(const src_address_t& r);
434ORCUS_DLLPUBLIC range_t to_rc_range(const src_range_t& r);
435
436ORCUS_DLLPUBLIC bool operator== (const address_t& left, const address_t& right);
437ORCUS_DLLPUBLIC bool operator!= (const address_t& left, const address_t& right);
438
439ORCUS_DLLPUBLIC bool operator== (const src_address_t& left, const src_address_t& right);
440ORCUS_DLLPUBLIC bool operator!= (const src_address_t& left, const src_address_t& right);
441
442ORCUS_DLLPUBLIC bool operator== (const range_t& left, const range_t& right);
443ORCUS_DLLPUBLIC bool operator!= (const range_t& left, const range_t& right);
444
445ORCUS_DLLPUBLIC bool operator== (const src_range_t& left, const src_range_t& right);
446ORCUS_DLLPUBLIC bool operator!= (const src_range_t& left, const src_range_t& right);
447
448ORCUS_DLLPUBLIC bool operator< (const range_t& left, const range_t& right);
449ORCUS_DLLPUBLIC bool operator> (const range_t& left, const range_t& right);
450
451ORCUS_DLLPUBLIC range_t& operator+= (range_t& left, const address_t& right);
452ORCUS_DLLPUBLIC range_t& operator-= (range_t& left, const address_t& right);
453
454ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const address_t& v);
455ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const src_address_t& v);
456ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const range_t& v);
457
458struct ORCUS_DLLPUBLIC color_rgb_t
459{
460 color_elem_t red;
461 color_elem_t green;
462 color_elem_t blue;
463
464 color_rgb_t();
465 color_rgb_t(std::initializer_list<color_elem_t> vs);
466 color_rgb_t(const color_rgb_t& other);
467 color_rgb_t(color_rgb_t&& other);
468
469 color_rgb_t& operator= (const color_rgb_t& other);
470};
471
480ORCUS_DLLPUBLIC totals_row_function_t to_totals_row_function_enum(std::string_view s);
481
490ORCUS_DLLPUBLIC pivot_cache_group_by_t to_pivot_cache_group_by_enum(std::string_view s);
491
500ORCUS_DLLPUBLIC error_value_t to_error_value_enum(std::string_view s);
501
511ORCUS_DLLPUBLIC color_rgb_t to_color_rgb(std::string_view s);
512
522ORCUS_DLLPUBLIC color_rgb_t to_color_rgb_from_name(std::string_view s);
523
531ORCUS_DLLPUBLIC formula_error_policy_t to_formula_error_policy(std::string_view s);
532
533ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, error_value_t ev);
534ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, formula_grammar_t grammar);
535ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const color_rgb_t& color);
536
537}}
538
539#endif
540
541/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: sheet.hpp:34
Definition: types.hpp:395
Definition: types.hpp:459
Definition: types.hpp:401
Definition: types.hpp:407
Definition: types.hpp:417
Definition: types.hpp:428
Definition: types.hpp:247