kmadej_fast_excel_fork 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.travis.yml +28 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +70 -0
- data/Makefile +14 -0
- data/README.md +95 -0
- data/Rakefile +24 -0
- data/appveyor.yml +25 -0
- data/benchmarks/1k_rows.rb +59 -0
- data/benchmarks/20k_rows.rb +26 -0
- data/benchmarks/init.rb +59 -0
- data/benchmarks/memory.rb +49 -0
- data/examples/example.rb +42 -0
- data/examples/example_align.rb +23 -0
- data/examples/example_chart.rb +21 -0
- data/examples/example_colors.rb +37 -0
- data/examples/example_formula.rb +18 -0
- data/examples/example_image.rb +13 -0
- data/examples/example_styles.rb +27 -0
- data/examples/logo.png +0 -0
- data/extconf.rb +0 -0
- data/fast_excel.gemspec +20 -0
- data/lib/fast_excel.rb +600 -0
- data/lib/fast_excel/binding.rb +2819 -0
- data/lib/fast_excel/binding/chart.rb +2666 -0
- data/lib/fast_excel/binding/format.rb +1177 -0
- data/lib/fast_excel/binding/workbook.rb +338 -0
- data/lib/fast_excel/binding/worksheet.rb +1555 -0
- data/libxlsxwriter/.gitignore +49 -0
- data/libxlsxwriter/.indent.pro +125 -0
- data/libxlsxwriter/.travis.yml +25 -0
- data/libxlsxwriter/CONTRIBUTING.md +226 -0
- data/libxlsxwriter/Changes.txt +557 -0
- data/libxlsxwriter/LICENSE.txt +89 -0
- data/libxlsxwriter/Makefile +156 -0
- data/libxlsxwriter/Readme.md +78 -0
- data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +30 -0
- data/libxlsxwriter/cocoapods/libxlsxwriter.modulemap +7 -0
- data/libxlsxwriter/include/xlsxwriter.h +23 -0
- data/libxlsxwriter/include/xlsxwriter/app.h +79 -0
- data/libxlsxwriter/include/xlsxwriter/chart.h +3476 -0
- data/libxlsxwriter/include/xlsxwriter/common.h +372 -0
- data/libxlsxwriter/include/xlsxwriter/content_types.h +74 -0
- data/libxlsxwriter/include/xlsxwriter/core.h +51 -0
- data/libxlsxwriter/include/xlsxwriter/custom.h +52 -0
- data/libxlsxwriter/include/xlsxwriter/drawing.h +111 -0
- data/libxlsxwriter/include/xlsxwriter/format.h +1214 -0
- data/libxlsxwriter/include/xlsxwriter/hash_table.h +76 -0
- data/libxlsxwriter/include/xlsxwriter/packager.h +80 -0
- data/libxlsxwriter/include/xlsxwriter/relationships.h +77 -0
- data/libxlsxwriter/include/xlsxwriter/shared_strings.h +83 -0
- data/libxlsxwriter/include/xlsxwriter/styles.h +77 -0
- data/libxlsxwriter/include/xlsxwriter/theme.h +47 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +214 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/queue.h +694 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/tmpfileplus.h +53 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/tree.h +801 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/zip.h +375 -0
- data/libxlsxwriter/include/xlsxwriter/utility.h +166 -0
- data/libxlsxwriter/include/xlsxwriter/workbook.h +757 -0
- data/libxlsxwriter/include/xlsxwriter/worksheet.h +2641 -0
- data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +178 -0
- data/libxlsxwriter/lib/.gitignore +0 -0
- data/libxlsxwriter/libxlsxwriter.podspec +47 -0
- data/libxlsxwriter/src/Makefile +130 -0
- data/libxlsxwriter/src/app.c +443 -0
- data/libxlsxwriter/src/chart.c +6346 -0
- data/libxlsxwriter/src/content_types.c +345 -0
- data/libxlsxwriter/src/core.c +293 -0
- data/libxlsxwriter/src/custom.c +224 -0
- data/libxlsxwriter/src/drawing.c +746 -0
- data/libxlsxwriter/src/format.c +729 -0
- data/libxlsxwriter/src/hash_table.c +223 -0
- data/libxlsxwriter/src/packager.c +948 -0
- data/libxlsxwriter/src/relationships.c +245 -0
- data/libxlsxwriter/src/shared_strings.c +266 -0
- data/libxlsxwriter/src/styles.c +1088 -0
- data/libxlsxwriter/src/theme.c +348 -0
- data/libxlsxwriter/src/utility.c +515 -0
- data/libxlsxwriter/src/workbook.c +1930 -0
- data/libxlsxwriter/src/worksheet.c +5022 -0
- data/libxlsxwriter/src/xmlwriter.c +355 -0
- data/libxlsxwriter/third_party/minizip/Makefile +44 -0
- data/libxlsxwriter/third_party/minizip/Makefile.am +45 -0
- data/libxlsxwriter/third_party/minizip/Makefile.orig +25 -0
- data/libxlsxwriter/third_party/minizip/MiniZip64_Changes.txt +6 -0
- data/libxlsxwriter/third_party/minizip/MiniZip64_info.txt +74 -0
- data/libxlsxwriter/third_party/minizip/README.txt +5 -0
- data/libxlsxwriter/third_party/minizip/configure.ac +32 -0
- data/libxlsxwriter/third_party/minizip/crypt.h +131 -0
- data/libxlsxwriter/third_party/minizip/ioapi.c +247 -0
- data/libxlsxwriter/third_party/minizip/ioapi.h +208 -0
- data/libxlsxwriter/third_party/minizip/iowin32.c +456 -0
- data/libxlsxwriter/third_party/minizip/iowin32.h +28 -0
- data/libxlsxwriter/third_party/minizip/make_vms.com +25 -0
- data/libxlsxwriter/third_party/minizip/miniunz.c +660 -0
- data/libxlsxwriter/third_party/minizip/miniunzip.1 +63 -0
- data/libxlsxwriter/third_party/minizip/minizip.1 +46 -0
- data/libxlsxwriter/third_party/minizip/minizip.c +520 -0
- data/libxlsxwriter/third_party/minizip/minizip.pc.in +12 -0
- data/libxlsxwriter/third_party/minizip/mztools.c +291 -0
- data/libxlsxwriter/third_party/minizip/mztools.h +37 -0
- data/libxlsxwriter/third_party/minizip/unzip.c +2125 -0
- data/libxlsxwriter/third_party/minizip/unzip.h +437 -0
- data/libxlsxwriter/third_party/minizip/zip.c +2007 -0
- data/libxlsxwriter/third_party/minizip/zip.h +367 -0
- data/libxlsxwriter/third_party/tmpfileplus/Makefile +42 -0
- data/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c +342 -0
- data/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.h +53 -0
- data/libxlsxwriter/version.txt +1 -0
- data/test/date_test.rb +22 -0
- data/test/default_format_test.rb +19 -0
- data/test/format_test.rb +171 -0
- data/test/test_helper.rb +52 -0
- data/test/tmpfile_test.rb +23 -0
- data/test/worksheet_test.rb +86 -0
- metadata +182 -0
@@ -0,0 +1,729 @@
|
|
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
|
+
if (size < LXW_MIN_FONT_SIZE) self->font_size = 0;
|
318
|
+
}
|
319
|
+
|
320
|
+
/*
|
321
|
+
* Set the font_color property.
|
322
|
+
*/
|
323
|
+
void
|
324
|
+
format_set_font_color(lxw_format *self, lxw_color_t color)
|
325
|
+
{
|
326
|
+
self->font_color = lxw_format_check_color(color);
|
327
|
+
}
|
328
|
+
|
329
|
+
/*
|
330
|
+
* Set the bold property.
|
331
|
+
*/
|
332
|
+
void
|
333
|
+
format_set_bold(lxw_format *self)
|
334
|
+
{
|
335
|
+
self->bold = LXW_TRUE;
|
336
|
+
}
|
337
|
+
|
338
|
+
/*
|
339
|
+
* Set the italic property.
|
340
|
+
*/
|
341
|
+
|
342
|
+
void
|
343
|
+
format_set_italic(lxw_format *self)
|
344
|
+
{
|
345
|
+
self->italic = LXW_TRUE;
|
346
|
+
}
|
347
|
+
|
348
|
+
/*
|
349
|
+
* Set the underline property.
|
350
|
+
*/
|
351
|
+
void
|
352
|
+
format_set_underline(lxw_format *self, uint8_t style)
|
353
|
+
{
|
354
|
+
if (style >= LXW_UNDERLINE_SINGLE
|
355
|
+
&& style <= LXW_UNDERLINE_DOUBLE_ACCOUNTING)
|
356
|
+
self->underline = style;
|
357
|
+
}
|
358
|
+
|
359
|
+
/*
|
360
|
+
* Set the font_strikeout property.
|
361
|
+
*/
|
362
|
+
void
|
363
|
+
format_set_font_strikeout(lxw_format *self)
|
364
|
+
{
|
365
|
+
self->font_strikeout = LXW_TRUE;
|
366
|
+
}
|
367
|
+
|
368
|
+
/*
|
369
|
+
* Set the font_script property.
|
370
|
+
*/
|
371
|
+
void
|
372
|
+
format_set_font_script(lxw_format *self, uint8_t style)
|
373
|
+
{
|
374
|
+
if (style >= LXW_FONT_SUPERSCRIPT && style <= LXW_FONT_SUBSCRIPT)
|
375
|
+
self->font_script = style;
|
376
|
+
}
|
377
|
+
|
378
|
+
/*
|
379
|
+
* Set the font_outline property.
|
380
|
+
*/
|
381
|
+
void
|
382
|
+
format_set_font_outline(lxw_format *self)
|
383
|
+
{
|
384
|
+
self->font_outline = LXW_TRUE;
|
385
|
+
}
|
386
|
+
|
387
|
+
/*
|
388
|
+
* Set the font_shadow property.
|
389
|
+
*/
|
390
|
+
void
|
391
|
+
format_set_font_shadow(lxw_format *self)
|
392
|
+
{
|
393
|
+
self->font_shadow = LXW_TRUE;
|
394
|
+
}
|
395
|
+
|
396
|
+
/*
|
397
|
+
* Set the num_format property.
|
398
|
+
*/
|
399
|
+
void
|
400
|
+
format_set_num_format(lxw_format *self, const char *num_format)
|
401
|
+
{
|
402
|
+
LXW_FORMAT_FIELD_COPY(self->num_format, num_format);
|
403
|
+
}
|
404
|
+
|
405
|
+
/*
|
406
|
+
* Set the unlocked property.
|
407
|
+
*/
|
408
|
+
void
|
409
|
+
format_set_unlocked(lxw_format *self)
|
410
|
+
{
|
411
|
+
self->locked = LXW_FALSE;
|
412
|
+
}
|
413
|
+
|
414
|
+
/*
|
415
|
+
* Set the hidden property.
|
416
|
+
*/
|
417
|
+
void
|
418
|
+
format_set_hidden(lxw_format *self)
|
419
|
+
{
|
420
|
+
self->hidden = LXW_TRUE;
|
421
|
+
}
|
422
|
+
|
423
|
+
/*
|
424
|
+
* Set the align property.
|
425
|
+
*/
|
426
|
+
void
|
427
|
+
format_set_align(lxw_format *self, uint8_t value)
|
428
|
+
{
|
429
|
+
if (value >= LXW_ALIGN_LEFT && value <= LXW_ALIGN_DISTRIBUTED) {
|
430
|
+
self->text_h_align = value;
|
431
|
+
}
|
432
|
+
|
433
|
+
if (value >= LXW_ALIGN_VERTICAL_TOP
|
434
|
+
&& value <= LXW_ALIGN_VERTICAL_DISTRIBUTED) {
|
435
|
+
self->text_v_align = value;
|
436
|
+
}
|
437
|
+
}
|
438
|
+
|
439
|
+
/*
|
440
|
+
* Set the text_wrap property.
|
441
|
+
*/
|
442
|
+
void
|
443
|
+
format_set_text_wrap(lxw_format *self)
|
444
|
+
{
|
445
|
+
self->text_wrap = LXW_TRUE;
|
446
|
+
}
|
447
|
+
|
448
|
+
/*
|
449
|
+
* Set the rotation property.
|
450
|
+
*/
|
451
|
+
void
|
452
|
+
format_set_rotation(lxw_format *self, int16_t angle)
|
453
|
+
{
|
454
|
+
/* Convert user angle to Excel angle. */
|
455
|
+
if (angle == 270) {
|
456
|
+
self->rotation = 255;
|
457
|
+
}
|
458
|
+
else if (angle >= -90 || angle <= 90) {
|
459
|
+
if (angle < 0)
|
460
|
+
angle = -angle + 90;
|
461
|
+
|
462
|
+
self->rotation = angle;
|
463
|
+
}
|
464
|
+
else {
|
465
|
+
LXW_WARN("Rotation rotation outside range: -90 <= angle <= 90.");
|
466
|
+
self->rotation = 0;
|
467
|
+
}
|
468
|
+
}
|
469
|
+
|
470
|
+
/*
|
471
|
+
* Set the indent property.
|
472
|
+
*/
|
473
|
+
void
|
474
|
+
format_set_indent(lxw_format *self, uint8_t value)
|
475
|
+
{
|
476
|
+
self->indent = value;
|
477
|
+
}
|
478
|
+
|
479
|
+
/*
|
480
|
+
* Set the shrink property.
|
481
|
+
*/
|
482
|
+
void
|
483
|
+
format_set_shrink(lxw_format *self)
|
484
|
+
{
|
485
|
+
self->shrink = LXW_TRUE;
|
486
|
+
}
|
487
|
+
|
488
|
+
/*
|
489
|
+
* Set the text_justlast property.
|
490
|
+
*/
|
491
|
+
void
|
492
|
+
format_set_text_justlast(lxw_format *self)
|
493
|
+
{
|
494
|
+
self->text_justlast = LXW_TRUE;
|
495
|
+
}
|
496
|
+
|
497
|
+
/*
|
498
|
+
* Set the pattern property.
|
499
|
+
*/
|
500
|
+
void
|
501
|
+
format_set_pattern(lxw_format *self, uint8_t value)
|
502
|
+
{
|
503
|
+
self->pattern = value;
|
504
|
+
}
|
505
|
+
|
506
|
+
/*
|
507
|
+
* Set the bg_color property.
|
508
|
+
*/
|
509
|
+
void
|
510
|
+
format_set_bg_color(lxw_format *self, lxw_color_t color)
|
511
|
+
{
|
512
|
+
self->bg_color = lxw_format_check_color(color);
|
513
|
+
}
|
514
|
+
|
515
|
+
/*
|
516
|
+
* Set the fg_color property.
|
517
|
+
*/
|
518
|
+
void
|
519
|
+
format_set_fg_color(lxw_format *self, lxw_color_t color)
|
520
|
+
{
|
521
|
+
self->fg_color = lxw_format_check_color(color);
|
522
|
+
}
|
523
|
+
|
524
|
+
/*
|
525
|
+
* Set the border property.
|
526
|
+
*/
|
527
|
+
void
|
528
|
+
format_set_border(lxw_format *self, uint8_t style)
|
529
|
+
{
|
530
|
+
style = _check_border(style);
|
531
|
+
self->bottom = style;
|
532
|
+
self->top = style;
|
533
|
+
self->left = style;
|
534
|
+
self->right = style;
|
535
|
+
}
|
536
|
+
|
537
|
+
/*
|
538
|
+
* Set the border_color property.
|
539
|
+
*/
|
540
|
+
void
|
541
|
+
format_set_border_color(lxw_format *self, lxw_color_t color)
|
542
|
+
{
|
543
|
+
color = lxw_format_check_color(color);
|
544
|
+
self->bottom_color = color;
|
545
|
+
self->top_color = color;
|
546
|
+
self->left_color = color;
|
547
|
+
self->right_color = color;
|
548
|
+
}
|
549
|
+
|
550
|
+
/*
|
551
|
+
* Set the bottom property.
|
552
|
+
*/
|
553
|
+
void
|
554
|
+
format_set_bottom(lxw_format *self, uint8_t style)
|
555
|
+
{
|
556
|
+
self->bottom = _check_border(style);
|
557
|
+
}
|
558
|
+
|
559
|
+
/*
|
560
|
+
* Set the bottom_color property.
|
561
|
+
*/
|
562
|
+
void
|
563
|
+
format_set_bottom_color(lxw_format *self, lxw_color_t color)
|
564
|
+
{
|
565
|
+
self->bottom_color = lxw_format_check_color(color);
|
566
|
+
}
|
567
|
+
|
568
|
+
/*
|
569
|
+
* Set the left property.
|
570
|
+
*/
|
571
|
+
void
|
572
|
+
format_set_left(lxw_format *self, uint8_t style)
|
573
|
+
{
|
574
|
+
self->left = _check_border(style);
|
575
|
+
}
|
576
|
+
|
577
|
+
/*
|
578
|
+
* Set the left_color property.
|
579
|
+
*/
|
580
|
+
void
|
581
|
+
format_set_left_color(lxw_format *self, lxw_color_t color)
|
582
|
+
{
|
583
|
+
self->left_color = lxw_format_check_color(color);
|
584
|
+
}
|
585
|
+
|
586
|
+
/*
|
587
|
+
* Set the right property.
|
588
|
+
*/
|
589
|
+
void
|
590
|
+
format_set_right(lxw_format *self, uint8_t style)
|
591
|
+
{
|
592
|
+
self->right = _check_border(style);
|
593
|
+
}
|
594
|
+
|
595
|
+
/*
|
596
|
+
* Set the right_color property.
|
597
|
+
*/
|
598
|
+
void
|
599
|
+
format_set_right_color(lxw_format *self, lxw_color_t color)
|
600
|
+
{
|
601
|
+
self->right_color = lxw_format_check_color(color);
|
602
|
+
}
|
603
|
+
|
604
|
+
/*
|
605
|
+
* Set the top property.
|
606
|
+
*/
|
607
|
+
void
|
608
|
+
format_set_top(lxw_format *self, uint8_t style)
|
609
|
+
{
|
610
|
+
self->top = _check_border(style);
|
611
|
+
}
|
612
|
+
|
613
|
+
/*
|
614
|
+
* Set the top_color property.
|
615
|
+
*/
|
616
|
+
void
|
617
|
+
format_set_top_color(lxw_format *self, lxw_color_t color)
|
618
|
+
{
|
619
|
+
self->top_color = lxw_format_check_color(color);
|
620
|
+
}
|
621
|
+
|
622
|
+
/*
|
623
|
+
* Set the diag_type property.
|
624
|
+
*/
|
625
|
+
void
|
626
|
+
format_set_diag_type(lxw_format *self, uint8_t type)
|
627
|
+
{
|
628
|
+
if (type >= LXW_DIAGONAL_BORDER_UP && type <= LXW_DIAGONAL_BORDER_UP_DOWN)
|
629
|
+
self->diag_type = type;
|
630
|
+
}
|
631
|
+
|
632
|
+
/*
|
633
|
+
* Set the diag_color property.
|
634
|
+
*/
|
635
|
+
void
|
636
|
+
format_set_diag_color(lxw_format *self, lxw_color_t color)
|
637
|
+
{
|
638
|
+
self->diag_color = lxw_format_check_color(color);
|
639
|
+
}
|
640
|
+
|
641
|
+
/*
|
642
|
+
* Set the diag_border property.
|
643
|
+
*/
|
644
|
+
void
|
645
|
+
format_set_diag_border(lxw_format *self, uint8_t style)
|
646
|
+
{
|
647
|
+
self->diag_border = style;
|
648
|
+
}
|
649
|
+
|
650
|
+
/*
|
651
|
+
* Set the num_format_index property.
|
652
|
+
*/
|
653
|
+
void
|
654
|
+
format_set_num_format_index(lxw_format *self, uint8_t value)
|
655
|
+
{
|
656
|
+
self->num_format_index = value;
|
657
|
+
}
|
658
|
+
|
659
|
+
/*
|
660
|
+
* Set the valign property.
|
661
|
+
*/
|
662
|
+
void
|
663
|
+
format_set_valign(lxw_format *self, uint8_t value)
|
664
|
+
{
|
665
|
+
self->text_v_align = value;
|
666
|
+
}
|
667
|
+
|
668
|
+
/*
|
669
|
+
* Set the reading_order property.
|
670
|
+
*/
|
671
|
+
void
|
672
|
+
format_set_reading_order(lxw_format *self, uint8_t value)
|
673
|
+
{
|
674
|
+
self->reading_order = value;
|
675
|
+
}
|
676
|
+
|
677
|
+
/*
|
678
|
+
* Set the font_family property.
|
679
|
+
*/
|
680
|
+
void
|
681
|
+
format_set_font_family(lxw_format *self, uint8_t value)
|
682
|
+
{
|
683
|
+
self->font_family = value;
|
684
|
+
}
|
685
|
+
|
686
|
+
/*
|
687
|
+
* Set the font_charset property.
|
688
|
+
*/
|
689
|
+
void
|
690
|
+
format_set_font_charset(lxw_format *self, uint8_t value)
|
691
|
+
{
|
692
|
+
self->font_charset = value;
|
693
|
+
}
|
694
|
+
|
695
|
+
/*
|
696
|
+
* Set the font_scheme property.
|
697
|
+
*/
|
698
|
+
void
|
699
|
+
format_set_font_scheme(lxw_format *self, const char *font_scheme)
|
700
|
+
{
|
701
|
+
LXW_FORMAT_FIELD_COPY(self->font_scheme, font_scheme);
|
702
|
+
}
|
703
|
+
|
704
|
+
/*
|
705
|
+
* Set the font_condense property.
|
706
|
+
*/
|
707
|
+
void
|
708
|
+
format_set_font_condense(lxw_format *self)
|
709
|
+
{
|
710
|
+
self->font_condense = LXW_TRUE;
|
711
|
+
}
|
712
|
+
|
713
|
+
/*
|
714
|
+
* Set the font_extend property.
|
715
|
+
*/
|
716
|
+
void
|
717
|
+
format_set_font_extend(lxw_format *self)
|
718
|
+
{
|
719
|
+
self->font_extend = LXW_TRUE;
|
720
|
+
}
|
721
|
+
|
722
|
+
/*
|
723
|
+
* Set the theme property.
|
724
|
+
*/
|
725
|
+
void
|
726
|
+
format_set_theme(lxw_format *self, uint8_t value)
|
727
|
+
{
|
728
|
+
self->theme = value;
|
729
|
+
}
|