xlsxwriter 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +40 -0
  3. data/ext/xlsxwriter/chart.c +105 -0
  4. data/ext/xlsxwriter/chart.h +27 -0
  5. data/ext/xlsxwriter/extconf.rb +14 -0
  6. data/ext/xlsxwriter/format.c +67 -0
  7. data/ext/xlsxwriter/format.h +9 -0
  8. data/ext/xlsxwriter/libxlsxwriter/LICENSE.txt +89 -0
  9. data/ext/xlsxwriter/libxlsxwriter/Makefile +141 -0
  10. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter.h +23 -0
  11. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/app.h +79 -0
  12. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/chart.h +1093 -0
  13. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/common.h +336 -0
  14. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/content_types.h +74 -0
  15. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/core.h +51 -0
  16. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/custom.h +52 -0
  17. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/drawing.h +111 -0
  18. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/format.h +1214 -0
  19. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/hash_table.h +76 -0
  20. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/packager.h +80 -0
  21. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/relationships.h +77 -0
  22. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/shared_strings.h +83 -0
  23. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/styles.h +77 -0
  24. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/theme.h +47 -0
  25. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +215 -0
  26. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/queue.h +694 -0
  27. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/tmpfileplus.h +53 -0
  28. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/tree.h +801 -0
  29. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/zip.h +375 -0
  30. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/utility.h +166 -0
  31. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/workbook.h +751 -0
  32. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/worksheet.h +2641 -0
  33. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/xmlwriter.h +178 -0
  34. data/ext/xlsxwriter/libxlsxwriter/lib/.gitignore +0 -0
  35. data/ext/xlsxwriter/libxlsxwriter/src/Makefile +125 -0
  36. data/ext/xlsxwriter/libxlsxwriter/src/app.c +439 -0
  37. data/ext/xlsxwriter/libxlsxwriter/src/chart.c +3420 -0
  38. data/ext/xlsxwriter/libxlsxwriter/src/content_types.c +341 -0
  39. data/ext/xlsxwriter/libxlsxwriter/src/core.c +293 -0
  40. data/ext/xlsxwriter/libxlsxwriter/src/custom.c +224 -0
  41. data/ext/xlsxwriter/libxlsxwriter/src/drawing.c +746 -0
  42. data/ext/xlsxwriter/libxlsxwriter/src/format.c +728 -0
  43. data/ext/xlsxwriter/libxlsxwriter/src/hash_table.c +223 -0
  44. data/ext/xlsxwriter/libxlsxwriter/src/packager.c +877 -0
  45. data/ext/xlsxwriter/libxlsxwriter/src/relationships.c +242 -0
  46. data/ext/xlsxwriter/libxlsxwriter/src/shared_strings.c +264 -0
  47. data/ext/xlsxwriter/libxlsxwriter/src/styles.c +1086 -0
  48. data/ext/xlsxwriter/libxlsxwriter/src/theme.c +348 -0
  49. data/ext/xlsxwriter/libxlsxwriter/src/utility.c +512 -0
  50. data/ext/xlsxwriter/libxlsxwriter/src/workbook.c +1895 -0
  51. data/ext/xlsxwriter/libxlsxwriter/src/worksheet.c +4992 -0
  52. data/ext/xlsxwriter/libxlsxwriter/src/xmlwriter.c +355 -0
  53. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/Makefile +44 -0
  54. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/crypt.h +131 -0
  55. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/ioapi.c +247 -0
  56. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/ioapi.h +209 -0
  57. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/iowin32.c +456 -0
  58. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/iowin32.h +28 -0
  59. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/miniunz.c +660 -0
  60. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/minizip.c +520 -0
  61. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/mztools.c +291 -0
  62. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/mztools.h +37 -0
  63. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/unzip.c +2125 -0
  64. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/unzip.h +437 -0
  65. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/zip.c +2007 -0
  66. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/zip.h +367 -0
  67. data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/Makefile +42 -0
  68. data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c +342 -0
  69. data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.h +53 -0
  70. data/ext/xlsxwriter/workbook.c +257 -0
  71. data/ext/xlsxwriter/workbook.h +42 -0
  72. data/ext/xlsxwriter/workbook_properties.c +103 -0
  73. data/ext/xlsxwriter/workbook_properties.h +10 -0
  74. data/ext/xlsxwriter/worksheet.c +1064 -0
  75. data/ext/xlsxwriter/worksheet.h +74 -0
  76. data/ext/xlsxwriter/xlsxwriter.c +239 -0
  77. data/lib/xlsxwriter.rb +6 -0
  78. data/lib/xlsxwriter/version.rb +3 -0
  79. data/lib/xlsxwriter/worksheet.rb +72 -0
  80. data/test/run-test.rb +11 -0
  81. data/test/support/xlsx_comparable.rb +109 -0
  82. data/test/test-array-formula.rb +33 -0
  83. data/test/test-autofilter.rb +70 -0
  84. data/test/test-chart-area.rb +25 -0
  85. data/test/test-data.rb +65 -0
  86. data/test/test-default-row.rb +25 -0
  87. data/test/test-defined-name.rb +46 -0
  88. data/test/test-escapes.rb +33 -0
  89. data/test/test-fit-to-pages.rb +21 -0
  90. data/test/test-formatting.rb +137 -0
  91. data/test/test-gridlines.rb +15 -0
  92. data/test/test-hyperlink.rb +67 -0
  93. data/test/test-image.rb +84 -0
  94. data/test/test-merge-range.rb +18 -0
  95. data/test/test-misc.rb +29 -0
  96. data/test/test-optimize.rb +32 -0
  97. data/test/test-page-breaks.rb +13 -0
  98. data/test/test-page-setup.rb +28 -0
  99. data/test/test-panes.rb +45 -0
  100. data/test/test-print-area.rb +19 -0
  101. data/test/test-print-options.rb +61 -0
  102. data/test/test-print-scale.rb +12 -0
  103. data/test/test-properties.rb +51 -0
  104. data/test/test-protect.rb +27 -0
  105. data/test/test-repeat.rb +23 -0
  106. data/test/test-row-col-format.rb +35 -0
  107. data/test/test-set-selection.rb +13 -0
  108. data/test/test-set-start-page.rb +13 -0
  109. data/test/test-simple.rb +62 -0
  110. data/test/test-types.rb +17 -0
  111. data/test/xlsx-func-testcase.rb +36 -0
  112. metadata +228 -0
@@ -0,0 +1,728 @@
1
+ /*****************************************************************************
2
+ * format - A library for creating Excel XLSX format files.
3
+ *
4
+ * Used in conjunction with the libxlsxwriter library.
5
+ *
6
+ * Copyright 2014-2017, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
7
+ *
8
+ */
9
+
10
+ #include "xlsxwriter/xmlwriter.h"
11
+ #include "xlsxwriter/format.h"
12
+ #include "xlsxwriter/utility.h"
13
+
14
+ /*****************************************************************************
15
+ *
16
+ * Private functions.
17
+ *
18
+ ****************************************************************************/
19
+
20
+ /*
21
+ * Create a new format object.
22
+ */
23
+ lxw_format *
24
+ lxw_format_new()
25
+ {
26
+ lxw_format *format = calloc(1, sizeof(lxw_format));
27
+ GOTO_LABEL_ON_MEM_ERROR(format, mem_error);
28
+
29
+ format->xf_format_indices = NULL;
30
+
31
+ format->xf_index = LXW_PROPERTY_UNSET;
32
+ format->dxf_index = LXW_PROPERTY_UNSET;
33
+
34
+ format->font_name[0] = '\0';
35
+ format->font_scheme[0] = '\0';
36
+ format->num_format[0] = '\0';
37
+ format->num_format_index = 0;
38
+ format->font_index = 0;
39
+ format->has_font = LXW_FALSE;
40
+ format->has_dxf_font = LXW_FALSE;
41
+ format->font_size = 11;
42
+ format->bold = LXW_FALSE;
43
+ format->italic = LXW_FALSE;
44
+ format->font_color = LXW_COLOR_UNSET;
45
+ format->underline = LXW_FALSE;
46
+ format->font_strikeout = LXW_FALSE;
47
+ format->font_outline = LXW_FALSE;
48
+ format->font_shadow = LXW_FALSE;
49
+ format->font_script = LXW_FALSE;
50
+ format->font_family = LXW_DEFAULT_FONT_FAMILY;
51
+ format->font_charset = LXW_FALSE;
52
+ format->font_condense = LXW_FALSE;
53
+ format->font_extend = LXW_FALSE;
54
+ format->theme = LXW_FALSE;
55
+ format->hyperlink = LXW_FALSE;
56
+
57
+ format->hidden = LXW_FALSE;
58
+ format->locked = LXW_TRUE;
59
+
60
+ format->text_h_align = LXW_ALIGN_NONE;
61
+ format->text_wrap = LXW_FALSE;
62
+ format->text_v_align = LXW_ALIGN_NONE;
63
+ format->text_justlast = LXW_FALSE;
64
+ format->rotation = 0;
65
+
66
+ format->fg_color = LXW_COLOR_UNSET;
67
+ format->bg_color = LXW_COLOR_UNSET;
68
+ format->pattern = LXW_PATTERN_NONE;
69
+ format->has_fill = LXW_FALSE;
70
+ format->has_dxf_fill = LXW_FALSE;
71
+ format->fill_index = 0;
72
+ format->fill_count = 0;
73
+
74
+ format->border_index = 0;
75
+ format->has_border = LXW_FALSE;
76
+ format->has_dxf_border = LXW_FALSE;
77
+ format->border_count = 0;
78
+
79
+ format->bottom = LXW_BORDER_NONE;
80
+ format->left = LXW_BORDER_NONE;
81
+ format->right = LXW_BORDER_NONE;
82
+ format->top = LXW_BORDER_NONE;
83
+ format->diag_border = LXW_BORDER_NONE;
84
+ format->diag_type = LXW_BORDER_NONE;
85
+ format->bottom_color = LXW_COLOR_UNSET;
86
+ format->left_color = LXW_COLOR_UNSET;
87
+ format->right_color = LXW_COLOR_UNSET;
88
+ format->top_color = LXW_COLOR_UNSET;
89
+ format->diag_color = LXW_COLOR_UNSET;
90
+
91
+ format->indent = 0;
92
+ format->shrink = LXW_FALSE;
93
+ format->merge_range = LXW_FALSE;
94
+ format->reading_order = 0;
95
+ format->just_distrib = LXW_FALSE;
96
+ format->color_indexed = LXW_FALSE;
97
+ format->font_only = LXW_FALSE;
98
+
99
+ return format;
100
+
101
+ mem_error:
102
+ lxw_format_free(format);
103
+ return NULL;
104
+ }
105
+
106
+ /*
107
+ * Free a format object.
108
+ */
109
+ void
110
+ lxw_format_free(lxw_format *format)
111
+ {
112
+ if (!format)
113
+ return;
114
+
115
+ free(format);
116
+ format = NULL;
117
+ }
118
+
119
+ /*
120
+ * Check a user input color.
121
+ */
122
+ lxw_color_t
123
+ lxw_format_check_color(lxw_color_t color)
124
+ {
125
+ if (color == LXW_COLOR_UNSET)
126
+ return color;
127
+ else
128
+ return color & LXW_COLOR_MASK;
129
+ }
130
+
131
+ /*
132
+ * Check a user input border.
133
+ */
134
+ STATIC uint8_t
135
+ _check_border(uint8_t border)
136
+ {
137
+ if (border >= LXW_BORDER_THIN && border <= LXW_BORDER_SLANT_DASH_DOT)
138
+ return border;
139
+ else
140
+ return LXW_BORDER_NONE;
141
+ }
142
+
143
+ /*****************************************************************************
144
+ *
145
+ * Public functions.
146
+ *
147
+ ****************************************************************************/
148
+
149
+ /*
150
+ * Returns a format struct suitable for hashing as a lookup key. This is
151
+ * mainly a memcpy with any pointer members set to NULL.
152
+ */
153
+ STATIC lxw_format *
154
+ _get_format_key(lxw_format *self)
155
+ {
156
+ lxw_format *key = calloc(1, sizeof(lxw_format));
157
+ GOTO_LABEL_ON_MEM_ERROR(key, mem_error);
158
+
159
+ memcpy(key, self, sizeof(lxw_format));
160
+
161
+ /* Set pointer members to NULL since they aren't part of the comparison. */
162
+ key->xf_format_indices = NULL;
163
+ key->num_xf_formats = NULL;
164
+ key->list_pointers.stqe_next = NULL;
165
+
166
+ return key;
167
+
168
+ mem_error:
169
+ return NULL;
170
+ }
171
+
172
+ /*
173
+ * Returns a font struct suitable for hashing as a lookup key.
174
+ */
175
+ lxw_font *
176
+ lxw_format_get_font_key(lxw_format *self)
177
+ {
178
+ lxw_font *key = calloc(1, sizeof(lxw_font));
179
+ GOTO_LABEL_ON_MEM_ERROR(key, mem_error);
180
+
181
+ LXW_FORMAT_FIELD_COPY(key->font_name, self->font_name);
182
+ key->font_size = self->font_size;
183
+ key->bold = self->bold;
184
+ key->italic = self->italic;
185
+ key->font_color = self->font_color;
186
+ key->underline = self->underline;
187
+ key->font_strikeout = self->font_strikeout;
188
+ key->font_outline = self->font_outline;
189
+ key->font_shadow = self->font_shadow;
190
+ key->font_script = self->font_script;
191
+ key->font_family = self->font_family;
192
+ key->font_charset = self->font_charset;
193
+ key->font_condense = self->font_condense;
194
+ key->font_extend = self->font_extend;
195
+
196
+ return key;
197
+
198
+ mem_error:
199
+ return NULL;
200
+ }
201
+
202
+ /*
203
+ * Returns a border struct suitable for hashing as a lookup key.
204
+ */
205
+ lxw_border *
206
+ lxw_format_get_border_key(lxw_format *self)
207
+ {
208
+ lxw_border *key = calloc(1, sizeof(lxw_border));
209
+ GOTO_LABEL_ON_MEM_ERROR(key, mem_error);
210
+
211
+ key->bottom = self->bottom;
212
+ key->left = self->left;
213
+ key->right = self->right;
214
+ key->top = self->top;
215
+ key->diag_border = self->diag_border;
216
+ key->diag_type = self->diag_type;
217
+ key->bottom_color = self->bottom_color;
218
+ key->left_color = self->left_color;
219
+ key->right_color = self->right_color;
220
+ key->top_color = self->top_color;
221
+ key->diag_color = self->diag_color;
222
+
223
+ return key;
224
+
225
+ mem_error:
226
+ return NULL;
227
+ }
228
+
229
+ /*
230
+ * Returns a pattern fill struct suitable for hashing as a lookup key.
231
+ */
232
+ lxw_fill *
233
+ lxw_format_get_fill_key(lxw_format *self)
234
+ {
235
+ lxw_fill *key = calloc(1, sizeof(lxw_fill));
236
+ GOTO_LABEL_ON_MEM_ERROR(key, mem_error);
237
+
238
+ key->fg_color = self->fg_color;
239
+ key->bg_color = self->bg_color;
240
+ key->pattern = self->pattern;
241
+
242
+ return key;
243
+
244
+ mem_error:
245
+ return NULL;
246
+ }
247
+
248
+ /*
249
+ * Returns the XF index number used by Excel to identify a format.
250
+ */
251
+ int32_t
252
+ lxw_format_get_xf_index(lxw_format *self)
253
+ {
254
+ lxw_format *format_key;
255
+ lxw_format *existing_format;
256
+ lxw_hash_element *hash_element;
257
+ lxw_hash_table *formats_hash_table = self->xf_format_indices;
258
+ int32_t index;
259
+
260
+ /* Note: The formats_hash_table/xf_format_indices contains the unique and
261
+ * more importantly the *used* formats in the workbook.
262
+ */
263
+
264
+ /* Format already has an index number so return it. */
265
+ if (self->xf_index != LXW_PROPERTY_UNSET) {
266
+ return self->xf_index;
267
+ }
268
+
269
+ /* Otherwise, the format doesn't have an index number so we assign one.
270
+ * First generate a unique key to identify the format in the hash table.
271
+ */
272
+ format_key = _get_format_key(self);
273
+
274
+ /* Return the default format index if the key generation failed. */
275
+ if (!format_key)
276
+ return 0;
277
+
278
+ /* Look up the format in the hash table. */
279
+ hash_element =
280
+ lxw_hash_key_exists(formats_hash_table, format_key,
281
+ sizeof(lxw_format));
282
+
283
+ if (hash_element) {
284
+ /* Format matches existing format with an index. */
285
+ free(format_key);
286
+ existing_format = hash_element->value;
287
+ return existing_format->xf_index;
288
+ }
289
+ else {
290
+ /* New format requiring an index. */
291
+ index = formats_hash_table->unique_count;
292
+ self->xf_index = index;
293
+ lxw_insert_hash_element(formats_hash_table, format_key, self,
294
+ sizeof(lxw_format));
295
+ return index;
296
+ }
297
+ }
298
+
299
+ /*
300
+ * Set the font_name property.
301
+ */
302
+ void
303
+ format_set_font_name(lxw_format *self, const char *font_name)
304
+ {
305
+ LXW_FORMAT_FIELD_COPY(self->font_name, font_name);
306
+ }
307
+
308
+ /*
309
+ * Set the font_size property.
310
+ */
311
+ void
312
+ format_set_font_size(lxw_format *self, uint16_t size)
313
+ {
314
+
315
+ if (size >= LXW_MIN_FONT_SIZE && size <= LXW_MAX_FONT_SIZE)
316
+ self->font_size = size;
317
+ }
318
+
319
+ /*
320
+ * Set the font_color property.
321
+ */
322
+ void
323
+ format_set_font_color(lxw_format *self, lxw_color_t color)
324
+ {
325
+ self->font_color = lxw_format_check_color(color);
326
+ }
327
+
328
+ /*
329
+ * Set the bold property.
330
+ */
331
+ void
332
+ format_set_bold(lxw_format *self)
333
+ {
334
+ self->bold = LXW_TRUE;
335
+ }
336
+
337
+ /*
338
+ * Set the italic property.
339
+ */
340
+
341
+ void
342
+ format_set_italic(lxw_format *self)
343
+ {
344
+ self->italic = LXW_TRUE;
345
+ }
346
+
347
+ /*
348
+ * Set the underline property.
349
+ */
350
+ void
351
+ format_set_underline(lxw_format *self, uint8_t style)
352
+ {
353
+ if (style >= LXW_UNDERLINE_SINGLE
354
+ && style <= LXW_UNDERLINE_DOUBLE_ACCOUNTING)
355
+ self->underline = style;
356
+ }
357
+
358
+ /*
359
+ * Set the font_strikeout property.
360
+ */
361
+ void
362
+ format_set_font_strikeout(lxw_format *self)
363
+ {
364
+ self->font_strikeout = LXW_TRUE;
365
+ }
366
+
367
+ /*
368
+ * Set the font_script property.
369
+ */
370
+ void
371
+ format_set_font_script(lxw_format *self, uint8_t style)
372
+ {
373
+ if (style >= LXW_FONT_SUPERSCRIPT && style <= LXW_FONT_SUBSCRIPT)
374
+ self->font_script = style;
375
+ }
376
+
377
+ /*
378
+ * Set the font_outline property.
379
+ */
380
+ void
381
+ format_set_font_outline(lxw_format *self)
382
+ {
383
+ self->font_outline = LXW_TRUE;
384
+ }
385
+
386
+ /*
387
+ * Set the font_shadow property.
388
+ */
389
+ void
390
+ format_set_font_shadow(lxw_format *self)
391
+ {
392
+ self->font_shadow = LXW_TRUE;
393
+ }
394
+
395
+ /*
396
+ * Set the num_format property.
397
+ */
398
+ void
399
+ format_set_num_format(lxw_format *self, const char *num_format)
400
+ {
401
+ LXW_FORMAT_FIELD_COPY(self->num_format, num_format);
402
+ }
403
+
404
+ /*
405
+ * Set the unlocked property.
406
+ */
407
+ void
408
+ format_set_unlocked(lxw_format *self)
409
+ {
410
+ self->locked = LXW_FALSE;
411
+ }
412
+
413
+ /*
414
+ * Set the hidden property.
415
+ */
416
+ void
417
+ format_set_hidden(lxw_format *self)
418
+ {
419
+ self->hidden = LXW_TRUE;
420
+ }
421
+
422
+ /*
423
+ * Set the align property.
424
+ */
425
+ void
426
+ format_set_align(lxw_format *self, uint8_t value)
427
+ {
428
+ if (value >= LXW_ALIGN_LEFT && value <= LXW_ALIGN_DISTRIBUTED) {
429
+ self->text_h_align = value;
430
+ }
431
+
432
+ if (value >= LXW_ALIGN_VERTICAL_TOP
433
+ && value <= LXW_ALIGN_VERTICAL_DISTRIBUTED) {
434
+ self->text_v_align = value;
435
+ }
436
+ }
437
+
438
+ /*
439
+ * Set the text_wrap property.
440
+ */
441
+ void
442
+ format_set_text_wrap(lxw_format *self)
443
+ {
444
+ self->text_wrap = LXW_TRUE;
445
+ }
446
+
447
+ /*
448
+ * Set the rotation property.
449
+ */
450
+ void
451
+ format_set_rotation(lxw_format *self, int16_t angle)
452
+ {
453
+ /* Convert user angle to Excel angle. */
454
+ if (angle == 270) {
455
+ self->rotation = 255;
456
+ }
457
+ else if (angle >= -90 || angle <= 90) {
458
+ if (angle < 0)
459
+ angle = -angle + 90;
460
+
461
+ self->rotation = angle;
462
+ }
463
+ else {
464
+ LXW_WARN("Rotation rotation outside range: -90 <= angle <= 90.");
465
+ self->rotation = 0;
466
+ }
467
+ }
468
+
469
+ /*
470
+ * Set the indent property.
471
+ */
472
+ void
473
+ format_set_indent(lxw_format *self, uint8_t value)
474
+ {
475
+ self->indent = value;
476
+ }
477
+
478
+ /*
479
+ * Set the shrink property.
480
+ */
481
+ void
482
+ format_set_shrink(lxw_format *self)
483
+ {
484
+ self->shrink = LXW_TRUE;
485
+ }
486
+
487
+ /*
488
+ * Set the text_justlast property.
489
+ */
490
+ void
491
+ format_set_text_justlast(lxw_format *self)
492
+ {
493
+ self->text_justlast = LXW_TRUE;
494
+ }
495
+
496
+ /*
497
+ * Set the pattern property.
498
+ */
499
+ void
500
+ format_set_pattern(lxw_format *self, uint8_t value)
501
+ {
502
+ self->pattern = value;
503
+ }
504
+
505
+ /*
506
+ * Set the bg_color property.
507
+ */
508
+ void
509
+ format_set_bg_color(lxw_format *self, lxw_color_t color)
510
+ {
511
+ self->bg_color = lxw_format_check_color(color);
512
+ }
513
+
514
+ /*
515
+ * Set the fg_color property.
516
+ */
517
+ void
518
+ format_set_fg_color(lxw_format *self, lxw_color_t color)
519
+ {
520
+ self->fg_color = lxw_format_check_color(color);
521
+ }
522
+
523
+ /*
524
+ * Set the border property.
525
+ */
526
+ void
527
+ format_set_border(lxw_format *self, uint8_t style)
528
+ {
529
+ style = _check_border(style);
530
+ self->bottom = style;
531
+ self->top = style;
532
+ self->left = style;
533
+ self->right = style;
534
+ }
535
+
536
+ /*
537
+ * Set the border_color property.
538
+ */
539
+ void
540
+ format_set_border_color(lxw_format *self, lxw_color_t color)
541
+ {
542
+ color = lxw_format_check_color(color);
543
+ self->bottom_color = color;
544
+ self->top_color = color;
545
+ self->left_color = color;
546
+ self->right_color = color;
547
+ }
548
+
549
+ /*
550
+ * Set the bottom property.
551
+ */
552
+ void
553
+ format_set_bottom(lxw_format *self, uint8_t style)
554
+ {
555
+ self->bottom = _check_border(style);
556
+ }
557
+
558
+ /*
559
+ * Set the bottom_color property.
560
+ */
561
+ void
562
+ format_set_bottom_color(lxw_format *self, lxw_color_t color)
563
+ {
564
+ self->bottom_color = lxw_format_check_color(color);
565
+ }
566
+
567
+ /*
568
+ * Set the left property.
569
+ */
570
+ void
571
+ format_set_left(lxw_format *self, uint8_t style)
572
+ {
573
+ self->left = _check_border(style);
574
+ }
575
+
576
+ /*
577
+ * Set the left_color property.
578
+ */
579
+ void
580
+ format_set_left_color(lxw_format *self, lxw_color_t color)
581
+ {
582
+ self->left_color = lxw_format_check_color(color);
583
+ }
584
+
585
+ /*
586
+ * Set the right property.
587
+ */
588
+ void
589
+ format_set_right(lxw_format *self, uint8_t style)
590
+ {
591
+ self->right = _check_border(style);
592
+ }
593
+
594
+ /*
595
+ * Set the right_color property.
596
+ */
597
+ void
598
+ format_set_right_color(lxw_format *self, lxw_color_t color)
599
+ {
600
+ self->right_color = lxw_format_check_color(color);
601
+ }
602
+
603
+ /*
604
+ * Set the top property.
605
+ */
606
+ void
607
+ format_set_top(lxw_format *self, uint8_t style)
608
+ {
609
+ self->top = _check_border(style);
610
+ }
611
+
612
+ /*
613
+ * Set the top_color property.
614
+ */
615
+ void
616
+ format_set_top_color(lxw_format *self, lxw_color_t color)
617
+ {
618
+ self->top_color = lxw_format_check_color(color);
619
+ }
620
+
621
+ /*
622
+ * Set the diag_type property.
623
+ */
624
+ void
625
+ format_set_diag_type(lxw_format *self, uint8_t type)
626
+ {
627
+ if (type >= LXW_DIAGONAL_BORDER_UP && type <= LXW_DIAGONAL_BORDER_UP_DOWN)
628
+ self->diag_type = type;
629
+ }
630
+
631
+ /*
632
+ * Set the diag_color property.
633
+ */
634
+ void
635
+ format_set_diag_color(lxw_format *self, lxw_color_t color)
636
+ {
637
+ self->diag_color = lxw_format_check_color(color);
638
+ }
639
+
640
+ /*
641
+ * Set the diag_border property.
642
+ */
643
+ void
644
+ format_set_diag_border(lxw_format *self, uint8_t style)
645
+ {
646
+ self->diag_border = style;
647
+ }
648
+
649
+ /*
650
+ * Set the num_format_index property.
651
+ */
652
+ void
653
+ format_set_num_format_index(lxw_format *self, uint8_t value)
654
+ {
655
+ self->num_format_index = value;
656
+ }
657
+
658
+ /*
659
+ * Set the valign property.
660
+ */
661
+ void
662
+ format_set_valign(lxw_format *self, uint8_t value)
663
+ {
664
+ self->text_v_align = value;
665
+ }
666
+
667
+ /*
668
+ * Set the reading_order property.
669
+ */
670
+ void
671
+ format_set_reading_order(lxw_format *self, uint8_t value)
672
+ {
673
+ self->reading_order = value;
674
+ }
675
+
676
+ /*
677
+ * Set the font_family property.
678
+ */
679
+ void
680
+ format_set_font_family(lxw_format *self, uint8_t value)
681
+ {
682
+ self->font_family = value;
683
+ }
684
+
685
+ /*
686
+ * Set the font_charset property.
687
+ */
688
+ void
689
+ format_set_font_charset(lxw_format *self, uint8_t value)
690
+ {
691
+ self->font_charset = value;
692
+ }
693
+
694
+ /*
695
+ * Set the font_scheme property.
696
+ */
697
+ void
698
+ format_set_font_scheme(lxw_format *self, const char *font_scheme)
699
+ {
700
+ LXW_FORMAT_FIELD_COPY(self->font_scheme, font_scheme);
701
+ }
702
+
703
+ /*
704
+ * Set the font_condense property.
705
+ */
706
+ void
707
+ format_set_font_condense(lxw_format *self)
708
+ {
709
+ self->font_condense = LXW_TRUE;
710
+ }
711
+
712
+ /*
713
+ * Set the font_extend property.
714
+ */
715
+ void
716
+ format_set_font_extend(lxw_format *self)
717
+ {
718
+ self->font_extend = LXW_TRUE;
719
+ }
720
+
721
+ /*
722
+ * Set the theme property.
723
+ */
724
+ void
725
+ format_set_theme(lxw_format *self, uint8_t value)
726
+ {
727
+ self->theme = value;
728
+ }