fast_excel 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +1 -7
- data/CHANGELOG.md +9 -0
- data/Gemfile +1 -1
- data/examples/example.rb +2 -0
- data/examples/example_date_time.rb +38 -0
- data/fast_excel.gemspec +2 -2
- data/lib/fast_excel/binding/format.rb +17 -0
- data/lib/fast_excel/binding/workbook.rb +39 -17
- data/lib/fast_excel/binding/worksheet.rb +57 -13
- data/lib/fast_excel/binding.rb +7 -7
- data/lib/fast_excel.rb +27 -20
- data/libxlsxwriter/.github/FUNDING.yml +1 -0
- data/libxlsxwriter/.github/ISSUE_TEMPLATE.md +85 -0
- data/libxlsxwriter/.github/PULL_REQUEST_TEMPLATE.md +130 -0
- data/libxlsxwriter/.github/workflows/cmake_actions.yml +48 -0
- data/libxlsxwriter/.github/workflows/code_style.yml +23 -0
- data/libxlsxwriter/.github/workflows/coverity.yml +22 -0
- data/libxlsxwriter/.github/workflows/make_actions.yml +52 -0
- data/libxlsxwriter/.github/workflows/valgrind.yml +23 -0
- data/libxlsxwriter/.github/workflows/windows_build.yml +54 -0
- data/libxlsxwriter/.github/workflows/zig_build.yml +22 -0
- data/libxlsxwriter/.gitignore +16 -1
- data/libxlsxwriter/.indent.pro +24 -0
- data/libxlsxwriter/CMakeLists.txt +156 -56
- data/libxlsxwriter/CONTRIBUTING.md +2 -2
- data/libxlsxwriter/Changes.txt +344 -2
- data/libxlsxwriter/LICENSE.txt +66 -8
- data/libxlsxwriter/Makefile +151 -54
- data/libxlsxwriter/Package.swift +42 -0
- data/libxlsxwriter/Readme.md +4 -2
- data/libxlsxwriter/build.zig +324 -0
- data/libxlsxwriter/build.zig.zon +11 -0
- data/libxlsxwriter/cmake/FindMINIZIP.cmake +3 -3
- data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +6 -0
- data/libxlsxwriter/include/xlsxwriter/app.h +2 -1
- data/libxlsxwriter/include/xlsxwriter/chart.h +236 -32
- data/libxlsxwriter/include/xlsxwriter/chartsheet.h +7 -7
- data/libxlsxwriter/include/xlsxwriter/comment.h +76 -0
- data/libxlsxwriter/include/xlsxwriter/common.h +111 -50
- data/libxlsxwriter/include/xlsxwriter/content_types.h +8 -1
- data/libxlsxwriter/include/xlsxwriter/core.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/custom.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/drawing.h +11 -20
- data/libxlsxwriter/include/xlsxwriter/format.h +121 -8
- data/libxlsxwriter/include/xlsxwriter/hash_table.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/metadata.h +49 -0
- data/libxlsxwriter/include/xlsxwriter/packager.h +27 -16
- data/libxlsxwriter/include/xlsxwriter/relationships.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/shared_strings.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/styles.h +13 -7
- data/libxlsxwriter/include/xlsxwriter/table.h +51 -0
- data/libxlsxwriter/include/xlsxwriter/theme.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/third_party/emyg_dtoa.h +26 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +27 -25
- data/libxlsxwriter/include/xlsxwriter/third_party/md5.h +45 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/zip.h +155 -153
- data/libxlsxwriter/include/xlsxwriter/utility.h +70 -8
- data/libxlsxwriter/include/xlsxwriter/vml.h +55 -0
- data/libxlsxwriter/include/xlsxwriter/workbook.h +218 -47
- data/libxlsxwriter/include/xlsxwriter/worksheet.h +2770 -241
- data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +12 -8
- data/libxlsxwriter/include/xlsxwriter.h +4 -2
- data/libxlsxwriter/libxlsxwriter.podspec +8 -5
- data/libxlsxwriter/src/Makefile +58 -21
- data/libxlsxwriter/src/app.c +5 -2
- data/libxlsxwriter/src/chart.c +396 -81
- data/libxlsxwriter/src/chartsheet.c +22 -22
- data/libxlsxwriter/src/comment.c +443 -0
- data/libxlsxwriter/src/content_types.c +40 -1
- data/libxlsxwriter/src/core.c +2 -2
- data/libxlsxwriter/src/custom.c +1 -1
- data/libxlsxwriter/src/drawing.c +160 -40
- data/libxlsxwriter/src/format.c +109 -25
- data/libxlsxwriter/src/hash_table.c +1 -1
- data/libxlsxwriter/src/metadata.c +283 -0
- data/libxlsxwriter/src/packager.c +794 -94
- data/libxlsxwriter/src/relationships.c +1 -1
- data/libxlsxwriter/src/shared_strings.c +2 -4
- data/libxlsxwriter/src/styles.c +353 -58
- data/libxlsxwriter/src/table.c +304 -0
- data/libxlsxwriter/src/theme.c +1 -1
- data/libxlsxwriter/src/utility.c +143 -43
- data/libxlsxwriter/src/vml.c +1062 -0
- data/libxlsxwriter/src/workbook.c +567 -77
- data/libxlsxwriter/src/worksheet.c +6668 -1462
- data/libxlsxwriter/src/xmlwriter.c +95 -5
- data/libxlsxwriter/third_party/dtoa/Makefile +42 -0
- data/libxlsxwriter/third_party/dtoa/emyg_dtoa.c +461 -0
- data/libxlsxwriter/third_party/dtoa/emyg_dtoa.h +26 -0
- data/libxlsxwriter/third_party/md5/Makefile +42 -0
- data/libxlsxwriter/third_party/md5/md5.c +291 -0
- data/libxlsxwriter/third_party/md5/md5.h +45 -0
- data/libxlsxwriter/third_party/minizip/Makefile +3 -8
- data/libxlsxwriter/third_party/minizip/Makefile.orig +8 -4
- data/libxlsxwriter/third_party/minizip/MiniZip64_Changes.txt +1 -1
- data/libxlsxwriter/third_party/minizip/configure.ac +1 -1
- data/libxlsxwriter/third_party/minizip/crypt.h +13 -16
- data/libxlsxwriter/third_party/minizip/ioapi.c +31 -57
- data/libxlsxwriter/third_party/minizip/ioapi.h +31 -23
- data/libxlsxwriter/third_party/minizip/iowin32.c +29 -45
- data/libxlsxwriter/third_party/minizip/iowin32.h +4 -4
- data/libxlsxwriter/third_party/minizip/miniunz.c +29 -56
- data/libxlsxwriter/third_party/minizip/minizip.c +38 -49
- data/libxlsxwriter/third_party/minizip/mztools.c +1 -7
- data/libxlsxwriter/third_party/minizip/unzip.c +202 -342
- data/libxlsxwriter/third_party/minizip/unzip.h +74 -74
- data/libxlsxwriter/third_party/minizip/zip.c +165 -218
- data/libxlsxwriter/third_party/minizip/zip.h +164 -154
- data/libxlsxwriter/third_party/tmpfileplus/Makefile +3 -3
- data/libxlsxwriter/version.txt +1 -1
- data/test/auto_width_test.rb +20 -0
- data/test/default_format_test.rb +1 -1
- data/test/validations_test.rb +3 -3
- data/test/worksheet_test.rb +6 -1
- metadata +33 -7
- data/libxlsxwriter/.travis.yml +0 -37
data/libxlsxwriter/src/drawing.c
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Used in conjunction with the libxlsxwriter library.
|
|
5
5
|
*
|
|
6
|
-
* Copyright 2014-
|
|
6
|
+
* Copyright 2014-2022, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
#include "xlsxwriter/xmlwriter.h"
|
|
11
11
|
#include "xlsxwriter/common.h"
|
|
12
12
|
#include "xlsxwriter/drawing.h"
|
|
13
|
+
#include "xlsxwriter/worksheet.h"
|
|
13
14
|
#include "xlsxwriter/utility.h"
|
|
14
15
|
|
|
15
16
|
#define LXW_OBJ_NAME_LENGTH 14 /* "Picture 65536", or "Chart 65536" */
|
|
@@ -54,7 +55,6 @@ lxw_free_drawing_object(lxw_drawing_object *drawing_object)
|
|
|
54
55
|
return;
|
|
55
56
|
|
|
56
57
|
free(drawing_object->description);
|
|
57
|
-
free(drawing_object->url);
|
|
58
58
|
free(drawing_object->tip);
|
|
59
59
|
|
|
60
60
|
free(drawing_object);
|
|
@@ -168,15 +168,13 @@ _drawing_write_row_off(lxw_drawing *self, char *data)
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
/*
|
|
171
|
-
* Write the <xdr:from>
|
|
171
|
+
* Write the main part of the <xdr:from> and <xdr:to> elements.
|
|
172
172
|
*/
|
|
173
173
|
STATIC void
|
|
174
|
-
|
|
174
|
+
_drawing_write_coords(lxw_drawing *self, lxw_drawing_coords *coords)
|
|
175
175
|
{
|
|
176
176
|
char data[LXW_UINT32_T_LENGTH];
|
|
177
177
|
|
|
178
|
-
lxw_xml_start_tag(self->file, "xdr:from", NULL);
|
|
179
|
-
|
|
180
178
|
lxw_snprintf(data, LXW_UINT32_T_LENGTH, "%u", coords->col);
|
|
181
179
|
_drawing_write_col(self, data);
|
|
182
180
|
|
|
@@ -190,6 +188,17 @@ _drawing_write_from(lxw_drawing *self, lxw_drawing_coords *coords)
|
|
|
190
188
|
lxw_snprintf(data, LXW_UINT32_T_LENGTH, "%u",
|
|
191
189
|
(uint32_t) coords->row_offset);
|
|
192
190
|
_drawing_write_row_off(self, data);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/*
|
|
194
|
+
* Write the <xdr:from> element.
|
|
195
|
+
*/
|
|
196
|
+
STATIC void
|
|
197
|
+
_drawing_write_from(lxw_drawing *self, lxw_drawing_coords *coords)
|
|
198
|
+
{
|
|
199
|
+
lxw_xml_start_tag(self->file, "xdr:from", NULL);
|
|
200
|
+
|
|
201
|
+
_drawing_write_coords(self, coords);
|
|
193
202
|
|
|
194
203
|
lxw_xml_end_tag(self->file, "xdr:from");
|
|
195
204
|
}
|
|
@@ -200,25 +209,112 @@ _drawing_write_from(lxw_drawing *self, lxw_drawing_coords *coords)
|
|
|
200
209
|
STATIC void
|
|
201
210
|
_drawing_write_to(lxw_drawing *self, lxw_drawing_coords *coords)
|
|
202
211
|
{
|
|
203
|
-
char data[LXW_UINT32_T_LENGTH];
|
|
204
|
-
|
|
205
212
|
lxw_xml_start_tag(self->file, "xdr:to", NULL);
|
|
206
213
|
|
|
207
|
-
|
|
208
|
-
_drawing_write_col(self, data);
|
|
214
|
+
_drawing_write_coords(self, coords);
|
|
209
215
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
_drawing_write_col_off(self, data);
|
|
216
|
+
lxw_xml_end_tag(self->file, "xdr:to");
|
|
217
|
+
}
|
|
213
218
|
|
|
214
|
-
|
|
215
|
-
|
|
219
|
+
/*
|
|
220
|
+
* Write the <a:hlinkClick> element.
|
|
221
|
+
*/
|
|
222
|
+
STATIC void
|
|
223
|
+
_drawing_write_a_hlink_click(lxw_drawing *self, uint32_t rel_index, char *tip)
|
|
224
|
+
{
|
|
225
|
+
struct xml_attribute_list attributes;
|
|
226
|
+
struct xml_attribute *attribute;
|
|
227
|
+
char xmlns_r[] = "http://schemas.openxmlformats.org/"
|
|
228
|
+
"officeDocument/2006/relationships";
|
|
229
|
+
char r_id[LXW_MAX_ATTRIBUTE_LENGTH];
|
|
216
230
|
|
|
217
|
-
lxw_snprintf(
|
|
218
|
-
(uint32_t) coords->row_offset);
|
|
219
|
-
_drawing_write_row_off(self, data);
|
|
231
|
+
lxw_snprintf(r_id, LXW_ATTR_32, "rId%d", rel_index);
|
|
220
232
|
|
|
221
|
-
|
|
233
|
+
LXW_INIT_ATTRIBUTES();
|
|
234
|
+
LXW_PUSH_ATTRIBUTES_STR("xmlns:r", xmlns_r);
|
|
235
|
+
LXW_PUSH_ATTRIBUTES_STR("r:id", r_id);
|
|
236
|
+
|
|
237
|
+
if (tip)
|
|
238
|
+
LXW_PUSH_ATTRIBUTES_STR("tooltip", tip);
|
|
239
|
+
|
|
240
|
+
lxw_xml_empty_tag(self->file, "a:hlinkClick", &attributes);
|
|
241
|
+
|
|
242
|
+
LXW_FREE_ATTRIBUTES();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/*
|
|
246
|
+
* Write the <a16:creationId> element.
|
|
247
|
+
*/
|
|
248
|
+
STATIC void
|
|
249
|
+
_drawing_write_a16_creation_id(lxw_drawing *self)
|
|
250
|
+
{
|
|
251
|
+
struct xml_attribute_list attributes;
|
|
252
|
+
struct xml_attribute *attribute;
|
|
253
|
+
char xmlns[] = "http://schemas.microsoft.com/office/drawing/2014/main";
|
|
254
|
+
|
|
255
|
+
LXW_INIT_ATTRIBUTES();
|
|
256
|
+
LXW_PUSH_ATTRIBUTES_STR("xmlns:a16", xmlns);
|
|
257
|
+
LXW_PUSH_ATTRIBUTES_STR("id", "{00000000-0008-0000-0000-000002000000}");
|
|
258
|
+
|
|
259
|
+
lxw_xml_empty_tag(self->file, "a16:creationId", &attributes);
|
|
260
|
+
|
|
261
|
+
LXW_FREE_ATTRIBUTES();
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/*
|
|
265
|
+
* Write the <adec:decorative> element.
|
|
266
|
+
*/
|
|
267
|
+
STATIC void
|
|
268
|
+
_workbook_write_adec_decorative(lxw_drawing *self)
|
|
269
|
+
{
|
|
270
|
+
struct xml_attribute_list attributes;
|
|
271
|
+
struct xml_attribute *attribute;
|
|
272
|
+
char xmlns[] =
|
|
273
|
+
"http://schemas.microsoft.com/office/drawing/2017/decorative";
|
|
274
|
+
|
|
275
|
+
LXW_INIT_ATTRIBUTES();
|
|
276
|
+
LXW_PUSH_ATTRIBUTES_STR("xmlns:adec", xmlns);
|
|
277
|
+
LXW_PUSH_ATTRIBUTES_STR("val", "1");
|
|
278
|
+
|
|
279
|
+
lxw_xml_empty_tag(self->file, "adec:decorative", &attributes);
|
|
280
|
+
|
|
281
|
+
LXW_FREE_ATTRIBUTES();
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/*
|
|
285
|
+
* Write the <a:ext> element.
|
|
286
|
+
*/
|
|
287
|
+
STATIC void
|
|
288
|
+
_drawing_write_uri_ext(lxw_drawing *self, char *uri)
|
|
289
|
+
{
|
|
290
|
+
struct xml_attribute_list attributes;
|
|
291
|
+
struct xml_attribute *attribute;
|
|
292
|
+
|
|
293
|
+
LXW_INIT_ATTRIBUTES();
|
|
294
|
+
LXW_PUSH_ATTRIBUTES_STR("uri", uri);
|
|
295
|
+
|
|
296
|
+
lxw_xml_start_tag(self->file, "a:ext", &attributes);
|
|
297
|
+
|
|
298
|
+
LXW_FREE_ATTRIBUTES();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/*
|
|
302
|
+
* Write the decorative elements.
|
|
303
|
+
*/
|
|
304
|
+
STATIC void
|
|
305
|
+
_workbook_write_decorative(lxw_drawing *self)
|
|
306
|
+
{
|
|
307
|
+
lxw_xml_start_tag(self->file, "a:extLst", NULL);
|
|
308
|
+
|
|
309
|
+
_drawing_write_uri_ext(self, "{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}");
|
|
310
|
+
_drawing_write_a16_creation_id(self);
|
|
311
|
+
lxw_xml_end_tag(self->file, "a:ext");
|
|
312
|
+
|
|
313
|
+
_drawing_write_uri_ext(self, "{C183D7F6-B498-43B3-948B-1728B52AA6E4}");
|
|
314
|
+
_workbook_write_adec_decorative(self);
|
|
315
|
+
lxw_xml_end_tag(self->file, "a:ext");
|
|
316
|
+
|
|
317
|
+
lxw_xml_end_tag(self->file, "a:extLst");
|
|
222
318
|
}
|
|
223
319
|
|
|
224
320
|
/*
|
|
@@ -239,10 +335,33 @@ _drawing_write_c_nv_pr(lxw_drawing *self, char *object_name, uint32_t index,
|
|
|
239
335
|
LXW_PUSH_ATTRIBUTES_INT("id", index + 1);
|
|
240
336
|
LXW_PUSH_ATTRIBUTES_STR("name", name);
|
|
241
337
|
|
|
242
|
-
if (drawing_object && drawing_object->description
|
|
338
|
+
if (drawing_object && drawing_object->description
|
|
339
|
+
&& strlen(drawing_object->description)
|
|
340
|
+
&& !drawing_object->decorative) {
|
|
341
|
+
|
|
243
342
|
LXW_PUSH_ATTRIBUTES_STR("descr", drawing_object->description);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (drawing_object
|
|
346
|
+
&& (drawing_object->url_rel_index || drawing_object->decorative)) {
|
|
347
|
+
lxw_xml_start_tag(self->file, "xdr:cNvPr", &attributes);
|
|
244
348
|
|
|
245
|
-
|
|
349
|
+
if (drawing_object->url_rel_index) {
|
|
350
|
+
/* Write the a:hlinkClick element. */
|
|
351
|
+
_drawing_write_a_hlink_click(self,
|
|
352
|
+
drawing_object->url_rel_index,
|
|
353
|
+
drawing_object->tip);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (drawing_object->decorative) {
|
|
357
|
+
_workbook_write_decorative(self);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
lxw_xml_end_tag(self->file, "xdr:cNvPr");
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
lxw_xml_empty_tag(self->file, "xdr:cNvPr", &attributes);
|
|
364
|
+
}
|
|
246
365
|
|
|
247
366
|
LXW_FREE_ATTRIBUTES();
|
|
248
367
|
}
|
|
@@ -472,7 +591,7 @@ _drawing_write_pic(lxw_drawing *self, uint32_t index,
|
|
|
472
591
|
_drawing_write_nv_pic_pr(self, index, drawing_object);
|
|
473
592
|
|
|
474
593
|
/* Write the xdr:blipFill element. */
|
|
475
|
-
_drawing_write_blip_fill(self,
|
|
594
|
+
_drawing_write_blip_fill(self, drawing_object->rel_index);
|
|
476
595
|
|
|
477
596
|
/* Write the xdr:spPr element. */
|
|
478
597
|
_drawing_write_sp_pr(self, drawing_object);
|
|
@@ -529,12 +648,13 @@ _drawing_write_c_nv_graphic_frame_pr(lxw_drawing *self)
|
|
|
529
648
|
* Write the <xdr:nvGraphicFramePr> element.
|
|
530
649
|
*/
|
|
531
650
|
STATIC void
|
|
532
|
-
_drawing_write_nv_graphic_frame_pr(lxw_drawing *self, uint32_t index
|
|
651
|
+
_drawing_write_nv_graphic_frame_pr(lxw_drawing *self, uint32_t index,
|
|
652
|
+
lxw_drawing_object *drawing_object)
|
|
533
653
|
{
|
|
534
654
|
lxw_xml_start_tag(self->file, "xdr:nvGraphicFramePr", NULL);
|
|
535
655
|
|
|
536
656
|
/* Write the xdr:cNvPr element. */
|
|
537
|
-
_drawing_write_c_nv_pr(self, "Chart", index,
|
|
657
|
+
_drawing_write_c_nv_pr(self, "Chart", index, drawing_object);
|
|
538
658
|
|
|
539
659
|
/* Write the xdr:cNvGraphicFramePr element. */
|
|
540
660
|
_drawing_write_c_nv_graphic_frame_pr(self);
|
|
@@ -661,7 +781,9 @@ _drawing_write_a_graphic(lxw_drawing *self, uint32_t index)
|
|
|
661
781
|
* Write the <xdr:graphicFrame> element.
|
|
662
782
|
*/
|
|
663
783
|
STATIC void
|
|
664
|
-
_drawing_write_graphic_frame(lxw_drawing *self, uint32_t index
|
|
784
|
+
_drawing_write_graphic_frame(lxw_drawing *self, uint32_t index,
|
|
785
|
+
uint32_t rel_index,
|
|
786
|
+
lxw_drawing_object *drawing_object)
|
|
665
787
|
{
|
|
666
788
|
struct xml_attribute_list attributes;
|
|
667
789
|
struct xml_attribute *attribute;
|
|
@@ -672,13 +794,13 @@ _drawing_write_graphic_frame(lxw_drawing *self, uint32_t index)
|
|
|
672
794
|
lxw_xml_start_tag(self->file, "xdr:graphicFrame", &attributes);
|
|
673
795
|
|
|
674
796
|
/* Write the xdr:nvGraphicFramePr element. */
|
|
675
|
-
_drawing_write_nv_graphic_frame_pr(self, index);
|
|
797
|
+
_drawing_write_nv_graphic_frame_pr(self, index, drawing_object);
|
|
676
798
|
|
|
677
799
|
/* Write the xdr:xfrm element. */
|
|
678
800
|
_drawing_write_xfrm(self);
|
|
679
801
|
|
|
680
802
|
/* Write the a:graphic element. */
|
|
681
|
-
_drawing_write_a_graphic(self,
|
|
803
|
+
_drawing_write_a_graphic(self, rel_index);
|
|
682
804
|
|
|
683
805
|
lxw_xml_end_tag(self->file, "xdr:graphicFrame");
|
|
684
806
|
|
|
@@ -697,24 +819,22 @@ _drawing_write_two_cell_anchor(lxw_drawing *self, uint32_t index,
|
|
|
697
819
|
|
|
698
820
|
LXW_INIT_ATTRIBUTES();
|
|
699
821
|
|
|
700
|
-
if (drawing_object->
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
else if (drawing_object->edit_as != LXW_ANCHOR_EDIT_AS_RELATIVE)
|
|
705
|
-
LXW_PUSH_ATTRIBUTES_STR("editAs", "oneCell");
|
|
706
|
-
}
|
|
822
|
+
if (drawing_object->anchor == LXW_OBJECT_MOVE_DONT_SIZE)
|
|
823
|
+
LXW_PUSH_ATTRIBUTES_STR("editAs", "oneCell");
|
|
824
|
+
else if (drawing_object->anchor == LXW_OBJECT_DONT_MOVE_DONT_SIZE)
|
|
825
|
+
LXW_PUSH_ATTRIBUTES_STR("editAs", "absolute");
|
|
707
826
|
|
|
708
827
|
lxw_xml_start_tag(self->file, "xdr:twoCellAnchor", &attributes);
|
|
709
828
|
|
|
710
829
|
_drawing_write_from(self, &drawing_object->from);
|
|
711
830
|
_drawing_write_to(self, &drawing_object->to);
|
|
712
831
|
|
|
713
|
-
if (drawing_object->
|
|
832
|
+
if (drawing_object->type == LXW_DRAWING_CHART) {
|
|
714
833
|
/* Write the xdr:graphicFrame element for charts. */
|
|
715
|
-
_drawing_write_graphic_frame(self, index
|
|
834
|
+
_drawing_write_graphic_frame(self, index, drawing_object->rel_index,
|
|
835
|
+
drawing_object);
|
|
716
836
|
}
|
|
717
|
-
else if (drawing_object->
|
|
837
|
+
else if (drawing_object->type == LXW_DRAWING_IMAGE) {
|
|
718
838
|
/* Write the xdr:pic element. */
|
|
719
839
|
_drawing_write_pic(self, index, drawing_object);
|
|
720
840
|
}
|
|
@@ -772,7 +892,7 @@ _drawing_write_pos(lxw_drawing *self, int32_t x, int32_t y)
|
|
|
772
892
|
* Write the <xdr:absoluteAnchor> element.
|
|
773
893
|
*/
|
|
774
894
|
STATIC void
|
|
775
|
-
_drawing_write_absolute_anchor(lxw_drawing *self)
|
|
895
|
+
_drawing_write_absolute_anchor(lxw_drawing *self, uint32_t frame_index)
|
|
776
896
|
{
|
|
777
897
|
lxw_xml_start_tag(self->file, "xdr:absoluteAnchor", NULL);
|
|
778
898
|
|
|
@@ -791,7 +911,7 @@ _drawing_write_absolute_anchor(lxw_drawing *self)
|
|
|
791
911
|
_drawing_write_ext(self, 6162675, 6124575);
|
|
792
912
|
}
|
|
793
913
|
|
|
794
|
-
_drawing_write_graphic_frame(self,
|
|
914
|
+
_drawing_write_graphic_frame(self, frame_index, frame_index, NULL);
|
|
795
915
|
|
|
796
916
|
/* Write the xdr:clientData element. */
|
|
797
917
|
_drawing_write_client_data(self);
|
|
@@ -830,7 +950,7 @@ lxw_drawing_assemble_xml_file(lxw_drawing *self)
|
|
|
830
950
|
}
|
|
831
951
|
else {
|
|
832
952
|
/* Write the xdr:absoluteAnchor element. Mainly for chartsheets. */
|
|
833
|
-
_drawing_write_absolute_anchor(self);
|
|
953
|
+
_drawing_write_absolute_anchor(self, 1);
|
|
834
954
|
}
|
|
835
955
|
|
|
836
956
|
lxw_xml_end_tag(self->file, "xdr:wsDr");
|
data/libxlsxwriter/src/format.c
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Used in conjunction with the libxlsxwriter library.
|
|
5
5
|
*
|
|
6
|
-
* Copyright 2014-
|
|
6
|
+
* Copyright 2014-2022, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -27,9 +27,11 @@ lxw_format_new(void)
|
|
|
27
27
|
GOTO_LABEL_ON_MEM_ERROR(format, mem_error);
|
|
28
28
|
|
|
29
29
|
format->xf_format_indices = NULL;
|
|
30
|
+
format->dxf_format_indices = NULL;
|
|
30
31
|
|
|
31
32
|
format->xf_index = LXW_PROPERTY_UNSET;
|
|
32
33
|
format->dxf_index = LXW_PROPERTY_UNSET;
|
|
34
|
+
format->xf_id = 0;
|
|
33
35
|
|
|
34
36
|
format->font_name[0] = '\0';
|
|
35
37
|
format->font_scheme[0] = '\0';
|
|
@@ -42,7 +44,7 @@ lxw_format_new(void)
|
|
|
42
44
|
format->bold = LXW_FALSE;
|
|
43
45
|
format->italic = LXW_FALSE;
|
|
44
46
|
format->font_color = LXW_COLOR_UNSET;
|
|
45
|
-
format->underline =
|
|
47
|
+
format->underline = LXW_UNDERLINE_NONE;
|
|
46
48
|
format->font_strikeout = LXW_FALSE;
|
|
47
49
|
format->font_outline = LXW_FALSE;
|
|
48
50
|
format->font_shadow = LXW_FALSE;
|
|
@@ -51,7 +53,7 @@ lxw_format_new(void)
|
|
|
51
53
|
format->font_charset = LXW_FALSE;
|
|
52
54
|
format->font_condense = LXW_FALSE;
|
|
53
55
|
format->font_extend = LXW_FALSE;
|
|
54
|
-
format->theme =
|
|
56
|
+
format->theme = 0;
|
|
55
57
|
format->hyperlink = LXW_FALSE;
|
|
56
58
|
|
|
57
59
|
format->hidden = LXW_FALSE;
|
|
@@ -96,6 +98,8 @@ lxw_format_new(void)
|
|
|
96
98
|
format->color_indexed = LXW_FALSE;
|
|
97
99
|
format->font_only = LXW_FALSE;
|
|
98
100
|
|
|
101
|
+
format->quote_prefix = LXW_FALSE;
|
|
102
|
+
|
|
99
103
|
return format;
|
|
100
104
|
|
|
101
105
|
mem_error:
|
|
@@ -116,18 +120,6 @@ lxw_format_free(lxw_format *format)
|
|
|
116
120
|
format = NULL;
|
|
117
121
|
}
|
|
118
122
|
|
|
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
123
|
/*
|
|
132
124
|
* Check a user input border.
|
|
133
125
|
*/
|
|
@@ -160,7 +152,9 @@ _get_format_key(lxw_format *self)
|
|
|
160
152
|
|
|
161
153
|
/* Set pointer members to NULL since they aren't part of the comparison. */
|
|
162
154
|
key->xf_format_indices = NULL;
|
|
155
|
+
key->dxf_format_indices = NULL;
|
|
163
156
|
key->num_xf_formats = NULL;
|
|
157
|
+
key->num_dxf_formats = NULL;
|
|
164
158
|
key->list_pointers.stqe_next = NULL;
|
|
165
159
|
|
|
166
160
|
return key;
|
|
@@ -182,8 +176,9 @@ lxw_format_get_font_key(lxw_format *self)
|
|
|
182
176
|
key->font_size = self->font_size;
|
|
183
177
|
key->bold = self->bold;
|
|
184
178
|
key->italic = self->italic;
|
|
185
|
-
key->font_color = self->font_color;
|
|
186
179
|
key->underline = self->underline;
|
|
180
|
+
key->theme = self->theme;
|
|
181
|
+
key->font_color = self->font_color;
|
|
187
182
|
key->font_strikeout = self->font_strikeout;
|
|
188
183
|
key->font_outline = self->font_outline;
|
|
189
184
|
key->font_shadow = self->font_shadow;
|
|
@@ -296,6 +291,57 @@ lxw_format_get_xf_index(lxw_format *self)
|
|
|
296
291
|
}
|
|
297
292
|
}
|
|
298
293
|
|
|
294
|
+
/*
|
|
295
|
+
* Returns the DXF index number used by Excel to identify a format.
|
|
296
|
+
*/
|
|
297
|
+
int32_t
|
|
298
|
+
lxw_format_get_dxf_index(lxw_format *self)
|
|
299
|
+
{
|
|
300
|
+
lxw_format *format_key;
|
|
301
|
+
lxw_format *existing_format;
|
|
302
|
+
lxw_hash_element *hash_element;
|
|
303
|
+
lxw_hash_table *formats_hash_table = self->dxf_format_indices;
|
|
304
|
+
int32_t index;
|
|
305
|
+
|
|
306
|
+
/* Note: The formats_hash_table/dxf_format_indices contains the unique and
|
|
307
|
+
* more importantly the *used* formats in the workbook.
|
|
308
|
+
*/
|
|
309
|
+
|
|
310
|
+
/* Format already has an index number so return it. */
|
|
311
|
+
if (self->dxf_index != LXW_PROPERTY_UNSET) {
|
|
312
|
+
return self->dxf_index;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/* Otherwise, the format doesn't have an index number so we assign one.
|
|
316
|
+
* First generate a unique key to identify the format in the hash table.
|
|
317
|
+
*/
|
|
318
|
+
format_key = _get_format_key(self);
|
|
319
|
+
|
|
320
|
+
/* Return the default format index if the key generation failed. */
|
|
321
|
+
if (!format_key)
|
|
322
|
+
return 0;
|
|
323
|
+
|
|
324
|
+
/* Look up the format in the hash table. */
|
|
325
|
+
hash_element =
|
|
326
|
+
lxw_hash_key_exists(formats_hash_table, format_key,
|
|
327
|
+
sizeof(lxw_format));
|
|
328
|
+
|
|
329
|
+
if (hash_element) {
|
|
330
|
+
/* Format matches existing format with an index. */
|
|
331
|
+
free(format_key);
|
|
332
|
+
existing_format = hash_element->value;
|
|
333
|
+
return existing_format->dxf_index;
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
/* New format requiring an index. */
|
|
337
|
+
index = formats_hash_table->unique_count;
|
|
338
|
+
self->dxf_index = index;
|
|
339
|
+
lxw_insert_hash_element(formats_hash_table, format_key, self,
|
|
340
|
+
sizeof(lxw_format));
|
|
341
|
+
return index;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
299
345
|
/*
|
|
300
346
|
* Set the font_name property.
|
|
301
347
|
*/
|
|
@@ -323,7 +369,7 @@ format_set_font_size(lxw_format *self, double size)
|
|
|
323
369
|
void
|
|
324
370
|
format_set_font_color(lxw_format *self, lxw_color_t color)
|
|
325
371
|
{
|
|
326
|
-
self->font_color =
|
|
372
|
+
self->font_color = color;
|
|
327
373
|
}
|
|
328
374
|
|
|
329
375
|
/*
|
|
@@ -509,7 +555,7 @@ format_set_pattern(lxw_format *self, uint8_t value)
|
|
|
509
555
|
void
|
|
510
556
|
format_set_bg_color(lxw_format *self, lxw_color_t color)
|
|
511
557
|
{
|
|
512
|
-
self->bg_color =
|
|
558
|
+
self->bg_color = color;
|
|
513
559
|
}
|
|
514
560
|
|
|
515
561
|
/*
|
|
@@ -518,7 +564,7 @@ format_set_bg_color(lxw_format *self, lxw_color_t color)
|
|
|
518
564
|
void
|
|
519
565
|
format_set_fg_color(lxw_format *self, lxw_color_t color)
|
|
520
566
|
{
|
|
521
|
-
self->fg_color =
|
|
567
|
+
self->fg_color = color;
|
|
522
568
|
}
|
|
523
569
|
|
|
524
570
|
/*
|
|
@@ -540,7 +586,6 @@ format_set_border(lxw_format *self, uint8_t style)
|
|
|
540
586
|
void
|
|
541
587
|
format_set_border_color(lxw_format *self, lxw_color_t color)
|
|
542
588
|
{
|
|
543
|
-
color = lxw_format_check_color(color);
|
|
544
589
|
self->bottom_color = color;
|
|
545
590
|
self->top_color = color;
|
|
546
591
|
self->left_color = color;
|
|
@@ -562,7 +607,7 @@ format_set_bottom(lxw_format *self, uint8_t style)
|
|
|
562
607
|
void
|
|
563
608
|
format_set_bottom_color(lxw_format *self, lxw_color_t color)
|
|
564
609
|
{
|
|
565
|
-
self->bottom_color =
|
|
610
|
+
self->bottom_color = color;
|
|
566
611
|
}
|
|
567
612
|
|
|
568
613
|
/*
|
|
@@ -580,7 +625,7 @@ format_set_left(lxw_format *self, uint8_t style)
|
|
|
580
625
|
void
|
|
581
626
|
format_set_left_color(lxw_format *self, lxw_color_t color)
|
|
582
627
|
{
|
|
583
|
-
self->left_color =
|
|
628
|
+
self->left_color = color;
|
|
584
629
|
}
|
|
585
630
|
|
|
586
631
|
/*
|
|
@@ -598,7 +643,7 @@ format_set_right(lxw_format *self, uint8_t style)
|
|
|
598
643
|
void
|
|
599
644
|
format_set_right_color(lxw_format *self, lxw_color_t color)
|
|
600
645
|
{
|
|
601
|
-
self->right_color =
|
|
646
|
+
self->right_color = color;
|
|
602
647
|
}
|
|
603
648
|
|
|
604
649
|
/*
|
|
@@ -616,7 +661,7 @@ format_set_top(lxw_format *self, uint8_t style)
|
|
|
616
661
|
void
|
|
617
662
|
format_set_top_color(lxw_format *self, lxw_color_t color)
|
|
618
663
|
{
|
|
619
|
-
self->top_color =
|
|
664
|
+
self->top_color = color;
|
|
620
665
|
}
|
|
621
666
|
|
|
622
667
|
/*
|
|
@@ -635,7 +680,7 @@ format_set_diag_type(lxw_format *self, uint8_t type)
|
|
|
635
680
|
void
|
|
636
681
|
format_set_diag_color(lxw_format *self, lxw_color_t color)
|
|
637
682
|
{
|
|
638
|
-
self->diag_color =
|
|
683
|
+
self->diag_color = color;
|
|
639
684
|
}
|
|
640
685
|
|
|
641
686
|
/*
|
|
@@ -727,3 +772,42 @@ format_set_theme(lxw_format *self, uint8_t value)
|
|
|
727
772
|
{
|
|
728
773
|
self->theme = value;
|
|
729
774
|
}
|
|
775
|
+
|
|
776
|
+
/*
|
|
777
|
+
* Set the color_indexed property.
|
|
778
|
+
*/
|
|
779
|
+
void
|
|
780
|
+
format_set_color_indexed(lxw_format *self, uint8_t value)
|
|
781
|
+
{
|
|
782
|
+
self->color_indexed = value;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
/*
|
|
786
|
+
* Set the font_only property.
|
|
787
|
+
*/
|
|
788
|
+
void
|
|
789
|
+
format_set_font_only(lxw_format *self)
|
|
790
|
+
{
|
|
791
|
+
self->font_only = LXW_TRUE;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/*
|
|
795
|
+
* Set the theme property.
|
|
796
|
+
*/
|
|
797
|
+
void
|
|
798
|
+
format_set_hyperlink(lxw_format *self)
|
|
799
|
+
{
|
|
800
|
+
self->hyperlink = LXW_TRUE;
|
|
801
|
+
self->xf_id = 1;
|
|
802
|
+
self->underline = LXW_UNDERLINE_SINGLE;
|
|
803
|
+
self->theme = 10;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/*
|
|
807
|
+
* Set the quote_prefix property.
|
|
808
|
+
*/
|
|
809
|
+
void
|
|
810
|
+
format_set_quote_prefix(lxw_format *self)
|
|
811
|
+
{
|
|
812
|
+
self->quote_prefix = LXW_TRUE;
|
|
813
|
+
}
|