kmadej_fast_excel_fork 0.2.2
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 +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,224 @@
|
|
|
1
|
+
/*****************************************************************************
|
|
2
|
+
* custom - A library for creating Excel custom property 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/custom.h"
|
|
12
|
+
#include "xlsxwriter/utility.h"
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* Forward declarations.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/*****************************************************************************
|
|
19
|
+
*
|
|
20
|
+
* Private functions.
|
|
21
|
+
*
|
|
22
|
+
****************************************************************************/
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* Create a new custom object.
|
|
26
|
+
*/
|
|
27
|
+
lxw_custom *
|
|
28
|
+
lxw_custom_new()
|
|
29
|
+
{
|
|
30
|
+
lxw_custom *custom = calloc(1, sizeof(lxw_custom));
|
|
31
|
+
GOTO_LABEL_ON_MEM_ERROR(custom, mem_error);
|
|
32
|
+
|
|
33
|
+
return custom;
|
|
34
|
+
|
|
35
|
+
mem_error:
|
|
36
|
+
lxw_custom_free(custom);
|
|
37
|
+
return NULL;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/*
|
|
41
|
+
* Free a custom object.
|
|
42
|
+
*/
|
|
43
|
+
void
|
|
44
|
+
lxw_custom_free(lxw_custom *custom)
|
|
45
|
+
{
|
|
46
|
+
if (!custom)
|
|
47
|
+
return;
|
|
48
|
+
|
|
49
|
+
free(custom);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/*****************************************************************************
|
|
53
|
+
*
|
|
54
|
+
* XML functions.
|
|
55
|
+
*
|
|
56
|
+
****************************************************************************/
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
* Write the XML declaration.
|
|
60
|
+
*/
|
|
61
|
+
STATIC void
|
|
62
|
+
_custom_xml_declaration(lxw_custom *self)
|
|
63
|
+
{
|
|
64
|
+
lxw_xml_declaration(self->file);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/*
|
|
68
|
+
* Write the <vt:lpwstr> element.
|
|
69
|
+
*/
|
|
70
|
+
STATIC void
|
|
71
|
+
_chart_write_vt_lpwstr(lxw_custom *self, char *value)
|
|
72
|
+
{
|
|
73
|
+
lxw_xml_data_element(self->file, "vt:lpwstr", value, NULL);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/*
|
|
77
|
+
* Write the <vt:r8> element.
|
|
78
|
+
*/
|
|
79
|
+
STATIC void
|
|
80
|
+
_chart_write_vt_r_8(lxw_custom *self, double value)
|
|
81
|
+
{
|
|
82
|
+
char data[LXW_ATTR_32];
|
|
83
|
+
|
|
84
|
+
lxw_snprintf(data, LXW_ATTR_32, "%.16g", value);
|
|
85
|
+
|
|
86
|
+
lxw_xml_data_element(self->file, "vt:r8", data, NULL);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/*
|
|
90
|
+
* Write the <vt:i4> element.
|
|
91
|
+
*/
|
|
92
|
+
STATIC void
|
|
93
|
+
_custom_write_vt_i_4(lxw_custom *self, int32_t value)
|
|
94
|
+
{
|
|
95
|
+
char data[LXW_ATTR_32];
|
|
96
|
+
|
|
97
|
+
lxw_snprintf(data, LXW_ATTR_32, "%d", value);
|
|
98
|
+
|
|
99
|
+
lxw_xml_data_element(self->file, "vt:i4", data, NULL);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/*
|
|
103
|
+
* Write the <vt:bool> element.
|
|
104
|
+
*/
|
|
105
|
+
STATIC void
|
|
106
|
+
_custom_write_vt_bool(lxw_custom *self, uint8_t value)
|
|
107
|
+
{
|
|
108
|
+
if (value)
|
|
109
|
+
lxw_xml_data_element(self->file, "vt:bool", "true", NULL);
|
|
110
|
+
else
|
|
111
|
+
lxw_xml_data_element(self->file, "vt:bool", "false", NULL);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/*
|
|
115
|
+
* Write the <vt:filetime> element.
|
|
116
|
+
*/
|
|
117
|
+
STATIC void
|
|
118
|
+
_custom_write_vt_filetime(lxw_custom *self, lxw_datetime *datetime)
|
|
119
|
+
{
|
|
120
|
+
char data[LXW_DATETIME_LENGTH];
|
|
121
|
+
|
|
122
|
+
lxw_snprintf(data, LXW_DATETIME_LENGTH, "%4d-%02d-%02dT%02d:%02d:%02dZ",
|
|
123
|
+
datetime->year, datetime->month, datetime->day,
|
|
124
|
+
datetime->hour, datetime->min, (int) datetime->sec);
|
|
125
|
+
|
|
126
|
+
lxw_xml_data_element(self->file, "vt:filetime", data, NULL);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/*
|
|
130
|
+
* Write the <property> element.
|
|
131
|
+
*/
|
|
132
|
+
STATIC void
|
|
133
|
+
_chart_write_custom_property(lxw_custom *self,
|
|
134
|
+
lxw_custom_property *custom_property)
|
|
135
|
+
{
|
|
136
|
+
struct xml_attribute_list attributes;
|
|
137
|
+
struct xml_attribute *attribute;
|
|
138
|
+
char fmtid[] = "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}";
|
|
139
|
+
|
|
140
|
+
self->pid++;
|
|
141
|
+
|
|
142
|
+
LXW_INIT_ATTRIBUTES();
|
|
143
|
+
LXW_PUSH_ATTRIBUTES_STR("fmtid", fmtid);
|
|
144
|
+
LXW_PUSH_ATTRIBUTES_INT("pid", self->pid + 1);
|
|
145
|
+
LXW_PUSH_ATTRIBUTES_STR("name", custom_property->name);
|
|
146
|
+
|
|
147
|
+
lxw_xml_start_tag(self->file, "property", &attributes);
|
|
148
|
+
|
|
149
|
+
if (custom_property->type == LXW_CUSTOM_STRING) {
|
|
150
|
+
/* Write the vt:lpwstr element. */
|
|
151
|
+
_chart_write_vt_lpwstr(self, custom_property->u.string);
|
|
152
|
+
}
|
|
153
|
+
else if (custom_property->type == LXW_CUSTOM_DOUBLE) {
|
|
154
|
+
/* Write the vt:r8 element. */
|
|
155
|
+
_chart_write_vt_r_8(self, custom_property->u.number);
|
|
156
|
+
}
|
|
157
|
+
else if (custom_property->type == LXW_CUSTOM_INTEGER) {
|
|
158
|
+
/* Write the vt:i4 element. */
|
|
159
|
+
_custom_write_vt_i_4(self, custom_property->u.integer);
|
|
160
|
+
}
|
|
161
|
+
else if (custom_property->type == LXW_CUSTOM_BOOLEAN) {
|
|
162
|
+
/* Write the vt:bool element. */
|
|
163
|
+
_custom_write_vt_bool(self, custom_property->u.boolean);
|
|
164
|
+
}
|
|
165
|
+
else if (custom_property->type == LXW_CUSTOM_DATETIME) {
|
|
166
|
+
/* Write the vt:filetime element. */
|
|
167
|
+
_custom_write_vt_filetime(self, &custom_property->u.datetime);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
lxw_xml_end_tag(self->file, "property");
|
|
171
|
+
|
|
172
|
+
LXW_FREE_ATTRIBUTES();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/*
|
|
176
|
+
* Write the <Properties> element.
|
|
177
|
+
*/
|
|
178
|
+
STATIC void
|
|
179
|
+
_write_custom_properties(lxw_custom *self)
|
|
180
|
+
{
|
|
181
|
+
struct xml_attribute_list attributes;
|
|
182
|
+
struct xml_attribute *attribute;
|
|
183
|
+
char xmlns[] = LXW_SCHEMA_OFFICEDOC "/custom-properties";
|
|
184
|
+
char xmlns_vt[] = LXW_SCHEMA_OFFICEDOC "/docPropsVTypes";
|
|
185
|
+
lxw_custom_property *custom_property;
|
|
186
|
+
|
|
187
|
+
LXW_INIT_ATTRIBUTES();
|
|
188
|
+
LXW_PUSH_ATTRIBUTES_STR("xmlns", xmlns);
|
|
189
|
+
LXW_PUSH_ATTRIBUTES_STR("xmlns:vt", xmlns_vt);
|
|
190
|
+
|
|
191
|
+
lxw_xml_start_tag(self->file, "Properties", &attributes);
|
|
192
|
+
|
|
193
|
+
STAILQ_FOREACH(custom_property, self->custom_properties, list_pointers) {
|
|
194
|
+
_chart_write_custom_property(self, custom_property);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
LXW_FREE_ATTRIBUTES();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/*****************************************************************************
|
|
201
|
+
*
|
|
202
|
+
* XML file assembly functions.
|
|
203
|
+
*
|
|
204
|
+
****************************************************************************/
|
|
205
|
+
|
|
206
|
+
/*
|
|
207
|
+
* Assemble and write the XML file.
|
|
208
|
+
*/
|
|
209
|
+
void
|
|
210
|
+
lxw_custom_assemble_xml_file(lxw_custom *self)
|
|
211
|
+
{
|
|
212
|
+
/* Write the XML declaration. */
|
|
213
|
+
_custom_xml_declaration(self);
|
|
214
|
+
|
|
215
|
+
_write_custom_properties(self);
|
|
216
|
+
|
|
217
|
+
lxw_xml_end_tag(self->file, "Properties");
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/*****************************************************************************
|
|
221
|
+
*
|
|
222
|
+
* Public functions.
|
|
223
|
+
*
|
|
224
|
+
****************************************************************************/
|
|
@@ -0,0 +1,746 @@
|
|
|
1
|
+
/*****************************************************************************
|
|
2
|
+
* drawing - A library for creating Excel XLSX drawing 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/common.h"
|
|
12
|
+
#include "xlsxwriter/drawing.h"
|
|
13
|
+
#include "xlsxwriter/utility.h"
|
|
14
|
+
|
|
15
|
+
#define LXW_OBJ_NAME_LENGTH 14 /* "Picture 65536", or "Chart 65536" */
|
|
16
|
+
/*
|
|
17
|
+
* Forward declarations.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/*****************************************************************************
|
|
21
|
+
*
|
|
22
|
+
* Private functions.
|
|
23
|
+
*
|
|
24
|
+
****************************************************************************/
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
* Create a new drawing collection.
|
|
28
|
+
*/
|
|
29
|
+
lxw_drawing *
|
|
30
|
+
lxw_drawing_new()
|
|
31
|
+
{
|
|
32
|
+
lxw_drawing *drawing = calloc(1, sizeof(lxw_drawing));
|
|
33
|
+
GOTO_LABEL_ON_MEM_ERROR(drawing, mem_error);
|
|
34
|
+
|
|
35
|
+
drawing->drawing_objects = calloc(1, sizeof(struct lxw_drawing_objects));
|
|
36
|
+
GOTO_LABEL_ON_MEM_ERROR(drawing->drawing_objects, mem_error);
|
|
37
|
+
|
|
38
|
+
STAILQ_INIT(drawing->drawing_objects);
|
|
39
|
+
|
|
40
|
+
return drawing;
|
|
41
|
+
|
|
42
|
+
mem_error:
|
|
43
|
+
lxw_drawing_free(drawing);
|
|
44
|
+
return NULL;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/*
|
|
48
|
+
* Free a drawing object.
|
|
49
|
+
*/
|
|
50
|
+
void
|
|
51
|
+
lxw_free_drawing_object(lxw_drawing_object *drawing_object)
|
|
52
|
+
{
|
|
53
|
+
if (!drawing_object)
|
|
54
|
+
return;
|
|
55
|
+
|
|
56
|
+
free(drawing_object->description);
|
|
57
|
+
free(drawing_object->url);
|
|
58
|
+
free(drawing_object->tip);
|
|
59
|
+
|
|
60
|
+
free(drawing_object);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/*
|
|
64
|
+
* Free a drawing collection.
|
|
65
|
+
*/
|
|
66
|
+
void
|
|
67
|
+
lxw_drawing_free(lxw_drawing *drawing)
|
|
68
|
+
{
|
|
69
|
+
lxw_drawing_object *drawing_object;
|
|
70
|
+
|
|
71
|
+
if (!drawing)
|
|
72
|
+
return;
|
|
73
|
+
|
|
74
|
+
if (drawing->drawing_objects) {
|
|
75
|
+
while (!STAILQ_EMPTY(drawing->drawing_objects)) {
|
|
76
|
+
drawing_object = STAILQ_FIRST(drawing->drawing_objects);
|
|
77
|
+
STAILQ_REMOVE_HEAD(drawing->drawing_objects, list_pointers);
|
|
78
|
+
lxw_free_drawing_object(drawing_object);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
free(drawing->drawing_objects);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
free(drawing);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/*
|
|
88
|
+
* Add a drawing object to the drawing collection.
|
|
89
|
+
*/
|
|
90
|
+
void
|
|
91
|
+
lxw_add_drawing_object(lxw_drawing *drawing,
|
|
92
|
+
lxw_drawing_object *drawing_object)
|
|
93
|
+
{
|
|
94
|
+
STAILQ_INSERT_TAIL(drawing->drawing_objects, drawing_object,
|
|
95
|
+
list_pointers);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/*****************************************************************************
|
|
99
|
+
*
|
|
100
|
+
* XML functions.
|
|
101
|
+
*
|
|
102
|
+
****************************************************************************/
|
|
103
|
+
|
|
104
|
+
/*
|
|
105
|
+
* Write the XML declaration.
|
|
106
|
+
*/
|
|
107
|
+
STATIC void
|
|
108
|
+
_drawing_xml_declaration(lxw_drawing *self)
|
|
109
|
+
{
|
|
110
|
+
lxw_xml_declaration(self->file);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/*
|
|
114
|
+
* Write the <xdr:wsDr> element.
|
|
115
|
+
*/
|
|
116
|
+
STATIC void
|
|
117
|
+
_write_drawing_workspace(lxw_drawing *self)
|
|
118
|
+
{
|
|
119
|
+
struct xml_attribute_list attributes;
|
|
120
|
+
struct xml_attribute *attribute;
|
|
121
|
+
char xmlns_xdr[] = LXW_SCHEMA_DRAWING "/spreadsheetDrawing";
|
|
122
|
+
char xmlns_a[] = LXW_SCHEMA_DRAWING "/main";
|
|
123
|
+
|
|
124
|
+
LXW_INIT_ATTRIBUTES();
|
|
125
|
+
|
|
126
|
+
LXW_PUSH_ATTRIBUTES_STR("xmlns:xdr", xmlns_xdr);
|
|
127
|
+
LXW_PUSH_ATTRIBUTES_STR("xmlns:a", xmlns_a);
|
|
128
|
+
|
|
129
|
+
lxw_xml_start_tag(self->file, "xdr:wsDr", &attributes);
|
|
130
|
+
|
|
131
|
+
LXW_FREE_ATTRIBUTES();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/*
|
|
135
|
+
* Write the <xdr:col> element.
|
|
136
|
+
*/
|
|
137
|
+
STATIC void
|
|
138
|
+
_drawing_write_col(lxw_drawing *self, char *data)
|
|
139
|
+
{
|
|
140
|
+
lxw_xml_data_element(self->file, "xdr:col", data, NULL);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/*
|
|
144
|
+
* Write the <xdr:colOff> element.
|
|
145
|
+
*/
|
|
146
|
+
STATIC void
|
|
147
|
+
_drawing_write_col_off(lxw_drawing *self, char *data)
|
|
148
|
+
{
|
|
149
|
+
lxw_xml_data_element(self->file, "xdr:colOff", data, NULL);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/*
|
|
153
|
+
* Write the <xdr:row> element.
|
|
154
|
+
*/
|
|
155
|
+
STATIC void
|
|
156
|
+
_drawing_write_row(lxw_drawing *self, char *data)
|
|
157
|
+
{
|
|
158
|
+
lxw_xml_data_element(self->file, "xdr:row", data, NULL);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/*
|
|
162
|
+
* Write the <xdr:rowOff> element.
|
|
163
|
+
*/
|
|
164
|
+
STATIC void
|
|
165
|
+
_drawing_write_row_off(lxw_drawing *self, char *data)
|
|
166
|
+
{
|
|
167
|
+
lxw_xml_data_element(self->file, "xdr:rowOff", data, NULL);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/*
|
|
171
|
+
* Write the <xdr:from> element.
|
|
172
|
+
*/
|
|
173
|
+
STATIC void
|
|
174
|
+
_drawing_write_from(lxw_drawing *self, lxw_drawing_coords *coords)
|
|
175
|
+
{
|
|
176
|
+
char data[LXW_UINT32_T_LENGTH];
|
|
177
|
+
|
|
178
|
+
lxw_xml_start_tag(self->file, "xdr:from", NULL);
|
|
179
|
+
|
|
180
|
+
lxw_snprintf(data, LXW_UINT32_T_LENGTH, "%u", coords->col);
|
|
181
|
+
_drawing_write_col(self, data);
|
|
182
|
+
|
|
183
|
+
lxw_snprintf(data, LXW_UINT32_T_LENGTH, "%u",
|
|
184
|
+
(uint32_t) coords->col_offset);
|
|
185
|
+
_drawing_write_col_off(self, data);
|
|
186
|
+
|
|
187
|
+
lxw_snprintf(data, LXW_UINT32_T_LENGTH, "%u", coords->row);
|
|
188
|
+
_drawing_write_row(self, data);
|
|
189
|
+
|
|
190
|
+
lxw_snprintf(data, LXW_UINT32_T_LENGTH, "%u",
|
|
191
|
+
(uint32_t) coords->row_offset);
|
|
192
|
+
_drawing_write_row_off(self, data);
|
|
193
|
+
|
|
194
|
+
lxw_xml_end_tag(self->file, "xdr:from");
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/*
|
|
198
|
+
* Write the <xdr:to> element.
|
|
199
|
+
*/
|
|
200
|
+
STATIC void
|
|
201
|
+
_drawing_write_to(lxw_drawing *self, lxw_drawing_coords *coords)
|
|
202
|
+
{
|
|
203
|
+
char data[LXW_UINT32_T_LENGTH];
|
|
204
|
+
|
|
205
|
+
lxw_xml_start_tag(self->file, "xdr:to", NULL);
|
|
206
|
+
|
|
207
|
+
lxw_snprintf(data, LXW_UINT32_T_LENGTH, "%u", coords->col);
|
|
208
|
+
_drawing_write_col(self, data);
|
|
209
|
+
|
|
210
|
+
lxw_snprintf(data, LXW_UINT32_T_LENGTH, "%u",
|
|
211
|
+
(uint32_t) coords->col_offset);
|
|
212
|
+
_drawing_write_col_off(self, data);
|
|
213
|
+
|
|
214
|
+
lxw_snprintf(data, LXW_UINT32_T_LENGTH, "%u", coords->row);
|
|
215
|
+
_drawing_write_row(self, data);
|
|
216
|
+
|
|
217
|
+
lxw_snprintf(data, LXW_UINT32_T_LENGTH, "%u",
|
|
218
|
+
(uint32_t) coords->row_offset);
|
|
219
|
+
_drawing_write_row_off(self, data);
|
|
220
|
+
|
|
221
|
+
lxw_xml_end_tag(self->file, "xdr:to");
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/*
|
|
225
|
+
* Write the <xdr:cNvPr> element.
|
|
226
|
+
*/
|
|
227
|
+
STATIC void
|
|
228
|
+
_drawing_write_c_nv_pr(lxw_drawing *self, char *object_name, uint16_t index,
|
|
229
|
+
lxw_drawing_object *drawing_object)
|
|
230
|
+
{
|
|
231
|
+
struct xml_attribute_list attributes;
|
|
232
|
+
struct xml_attribute *attribute;
|
|
233
|
+
|
|
234
|
+
char name[LXW_OBJ_NAME_LENGTH];
|
|
235
|
+
lxw_snprintf(name, LXW_OBJ_NAME_LENGTH, "%s %d", object_name, index);
|
|
236
|
+
|
|
237
|
+
LXW_INIT_ATTRIBUTES();
|
|
238
|
+
|
|
239
|
+
LXW_PUSH_ATTRIBUTES_INT("id", index + 1);
|
|
240
|
+
LXW_PUSH_ATTRIBUTES_STR("name", name);
|
|
241
|
+
|
|
242
|
+
if (drawing_object)
|
|
243
|
+
LXW_PUSH_ATTRIBUTES_STR("descr", drawing_object->description);
|
|
244
|
+
|
|
245
|
+
lxw_xml_empty_tag(self->file, "xdr:cNvPr", &attributes);
|
|
246
|
+
|
|
247
|
+
LXW_FREE_ATTRIBUTES();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/*
|
|
251
|
+
* Write the <a:picLocks> element.
|
|
252
|
+
*/
|
|
253
|
+
STATIC void
|
|
254
|
+
_drawing_write_a_pic_locks(lxw_drawing *self)
|
|
255
|
+
{
|
|
256
|
+
struct xml_attribute_list attributes;
|
|
257
|
+
struct xml_attribute *attribute;
|
|
258
|
+
|
|
259
|
+
LXW_INIT_ATTRIBUTES();
|
|
260
|
+
LXW_PUSH_ATTRIBUTES_STR("noChangeAspect", "1");
|
|
261
|
+
|
|
262
|
+
lxw_xml_empty_tag(self->file, "a:picLocks", &attributes);
|
|
263
|
+
|
|
264
|
+
LXW_FREE_ATTRIBUTES();
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/*
|
|
268
|
+
* Write the <xdr:cNvPicPr> element.
|
|
269
|
+
*/
|
|
270
|
+
STATIC void
|
|
271
|
+
_drawing_write_c_nv_pic_pr(lxw_drawing *self)
|
|
272
|
+
{
|
|
273
|
+
lxw_xml_start_tag(self->file, "xdr:cNvPicPr", NULL);
|
|
274
|
+
|
|
275
|
+
/* Write the a:picLocks element. */
|
|
276
|
+
_drawing_write_a_pic_locks(self);
|
|
277
|
+
|
|
278
|
+
lxw_xml_end_tag(self->file, "xdr:cNvPicPr");
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/*
|
|
282
|
+
* Write the <xdr:nvPicPr> element.
|
|
283
|
+
*/
|
|
284
|
+
STATIC void
|
|
285
|
+
_drawing_write_nv_pic_pr(lxw_drawing *self, uint16_t index,
|
|
286
|
+
lxw_drawing_object *drawing_object)
|
|
287
|
+
{
|
|
288
|
+
lxw_xml_start_tag(self->file, "xdr:nvPicPr", NULL);
|
|
289
|
+
|
|
290
|
+
/* Write the xdr:cNvPr element. */
|
|
291
|
+
_drawing_write_c_nv_pr(self, "Picture", index, drawing_object);
|
|
292
|
+
|
|
293
|
+
/* Write the xdr:cNvPicPr element. */
|
|
294
|
+
_drawing_write_c_nv_pic_pr(self);
|
|
295
|
+
|
|
296
|
+
lxw_xml_end_tag(self->file, "xdr:nvPicPr");
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/*
|
|
300
|
+
* Write the <a:blip> element.
|
|
301
|
+
*/
|
|
302
|
+
STATIC void
|
|
303
|
+
_drawing_write_a_blip(lxw_drawing *self, uint16_t index)
|
|
304
|
+
{
|
|
305
|
+
struct xml_attribute_list attributes;
|
|
306
|
+
struct xml_attribute *attribute;
|
|
307
|
+
char xmlns_r[] = LXW_SCHEMA_OFFICEDOC "/relationships";
|
|
308
|
+
char r_id[LXW_MAX_ATTRIBUTE_LENGTH];
|
|
309
|
+
|
|
310
|
+
lxw_snprintf(r_id, LXW_ATTR_32, "rId%d", index);
|
|
311
|
+
|
|
312
|
+
LXW_INIT_ATTRIBUTES();
|
|
313
|
+
LXW_PUSH_ATTRIBUTES_STR("xmlns:r", xmlns_r);
|
|
314
|
+
LXW_PUSH_ATTRIBUTES_STR("r:embed", r_id);
|
|
315
|
+
|
|
316
|
+
lxw_xml_empty_tag(self->file, "a:blip", &attributes);
|
|
317
|
+
|
|
318
|
+
LXW_FREE_ATTRIBUTES();
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/*
|
|
322
|
+
* Write the <a:fillRect> element.
|
|
323
|
+
*/
|
|
324
|
+
STATIC void
|
|
325
|
+
_drawing_write_a_fill_rect(lxw_drawing *self)
|
|
326
|
+
{
|
|
327
|
+
lxw_xml_empty_tag(self->file, "a:fillRect", NULL);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/*
|
|
331
|
+
* Write the <a:stretch> element.
|
|
332
|
+
*/
|
|
333
|
+
STATIC void
|
|
334
|
+
_drawing_write_a_stretch(lxw_drawing *self)
|
|
335
|
+
{
|
|
336
|
+
lxw_xml_start_tag(self->file, "a:stretch", NULL);
|
|
337
|
+
|
|
338
|
+
/* Write the a:fillRect element. */
|
|
339
|
+
_drawing_write_a_fill_rect(self);
|
|
340
|
+
|
|
341
|
+
lxw_xml_end_tag(self->file, "a:stretch");
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/*
|
|
345
|
+
* Write the <xdr:blipFill> element.
|
|
346
|
+
*/
|
|
347
|
+
STATIC void
|
|
348
|
+
_drawing_write_blip_fill(lxw_drawing *self, uint16_t index)
|
|
349
|
+
{
|
|
350
|
+
lxw_xml_start_tag(self->file, "xdr:blipFill", NULL);
|
|
351
|
+
|
|
352
|
+
/* Write the a:blip element. */
|
|
353
|
+
_drawing_write_a_blip(self, index);
|
|
354
|
+
|
|
355
|
+
/* Write the a:stretch element. */
|
|
356
|
+
_drawing_write_a_stretch(self);
|
|
357
|
+
|
|
358
|
+
lxw_xml_end_tag(self->file, "xdr:blipFill");
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/*
|
|
362
|
+
* Write the <a:ext> element.
|
|
363
|
+
*/
|
|
364
|
+
STATIC void
|
|
365
|
+
_drawing_write_a_ext(lxw_drawing *self, lxw_drawing_object *drawing_object)
|
|
366
|
+
{
|
|
367
|
+
struct xml_attribute_list attributes;
|
|
368
|
+
struct xml_attribute *attribute;
|
|
369
|
+
|
|
370
|
+
LXW_INIT_ATTRIBUTES();
|
|
371
|
+
LXW_PUSH_ATTRIBUTES_INT("cx", drawing_object->width);
|
|
372
|
+
LXW_PUSH_ATTRIBUTES_INT("cy", drawing_object->height);
|
|
373
|
+
|
|
374
|
+
lxw_xml_empty_tag(self->file, "a:ext", &attributes);
|
|
375
|
+
|
|
376
|
+
LXW_FREE_ATTRIBUTES();
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/*
|
|
380
|
+
* Write the <a:off> element.
|
|
381
|
+
*/
|
|
382
|
+
STATIC void
|
|
383
|
+
_drawing_write_a_off(lxw_drawing *self, lxw_drawing_object *drawing_object)
|
|
384
|
+
{
|
|
385
|
+
struct xml_attribute_list attributes;
|
|
386
|
+
struct xml_attribute *attribute;
|
|
387
|
+
|
|
388
|
+
LXW_INIT_ATTRIBUTES();
|
|
389
|
+
LXW_PUSH_ATTRIBUTES_INT("x", drawing_object->col_absolute);
|
|
390
|
+
LXW_PUSH_ATTRIBUTES_INT("y", drawing_object->row_absolute);
|
|
391
|
+
|
|
392
|
+
lxw_xml_empty_tag(self->file, "a:off", &attributes);
|
|
393
|
+
|
|
394
|
+
LXW_FREE_ATTRIBUTES();
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/*
|
|
398
|
+
* Write the <a:xfrm> element.
|
|
399
|
+
*/
|
|
400
|
+
STATIC void
|
|
401
|
+
_drawing_write_a_xfrm(lxw_drawing *self, lxw_drawing_object *drawing_object)
|
|
402
|
+
{
|
|
403
|
+
lxw_xml_start_tag(self->file, "a:xfrm", NULL);
|
|
404
|
+
|
|
405
|
+
/* Write the a:off element. */
|
|
406
|
+
_drawing_write_a_off(self, drawing_object);
|
|
407
|
+
|
|
408
|
+
/* Write the a:ext element. */
|
|
409
|
+
_drawing_write_a_ext(self, drawing_object);
|
|
410
|
+
|
|
411
|
+
lxw_xml_end_tag(self->file, "a:xfrm");
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/*
|
|
415
|
+
* Write the <a:avLst> element.
|
|
416
|
+
*/
|
|
417
|
+
STATIC void
|
|
418
|
+
_drawing_write_a_av_lst(lxw_drawing *self)
|
|
419
|
+
{
|
|
420
|
+
lxw_xml_empty_tag(self->file, "a:avLst", NULL);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/*
|
|
424
|
+
* Write the <a:prstGeom> element.
|
|
425
|
+
*/
|
|
426
|
+
STATIC void
|
|
427
|
+
_drawing_write_a_prst_geom(lxw_drawing *self)
|
|
428
|
+
{
|
|
429
|
+
struct xml_attribute_list attributes;
|
|
430
|
+
struct xml_attribute *attribute;
|
|
431
|
+
|
|
432
|
+
LXW_INIT_ATTRIBUTES();
|
|
433
|
+
LXW_PUSH_ATTRIBUTES_STR("prst", "rect");
|
|
434
|
+
|
|
435
|
+
lxw_xml_start_tag(self->file, "a:prstGeom", &attributes);
|
|
436
|
+
|
|
437
|
+
/* Write the a:avLst element. */
|
|
438
|
+
_drawing_write_a_av_lst(self);
|
|
439
|
+
|
|
440
|
+
lxw_xml_end_tag(self->file, "a:prstGeom");
|
|
441
|
+
|
|
442
|
+
LXW_FREE_ATTRIBUTES();
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/*
|
|
446
|
+
* Write the <xdr:spPr> element.
|
|
447
|
+
*/
|
|
448
|
+
STATIC void
|
|
449
|
+
_drawing_write_sp_pr(lxw_drawing *self, lxw_drawing_object *drawing_object)
|
|
450
|
+
{
|
|
451
|
+
lxw_xml_start_tag(self->file, "xdr:spPr", NULL);
|
|
452
|
+
|
|
453
|
+
/* Write the a:xfrm element. */
|
|
454
|
+
_drawing_write_a_xfrm(self, drawing_object);
|
|
455
|
+
|
|
456
|
+
/* Write the a:prstGeom element. */
|
|
457
|
+
_drawing_write_a_prst_geom(self);
|
|
458
|
+
|
|
459
|
+
lxw_xml_end_tag(self->file, "xdr:spPr");
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/*
|
|
463
|
+
* Write the <xdr:pic> element.
|
|
464
|
+
*/
|
|
465
|
+
STATIC void
|
|
466
|
+
_drawing_write_pic(lxw_drawing *self, uint16_t index,
|
|
467
|
+
lxw_drawing_object *drawing_object)
|
|
468
|
+
{
|
|
469
|
+
lxw_xml_start_tag(self->file, "xdr:pic", NULL);
|
|
470
|
+
|
|
471
|
+
/* Write the xdr:nvPicPr element. */
|
|
472
|
+
_drawing_write_nv_pic_pr(self, index, drawing_object);
|
|
473
|
+
|
|
474
|
+
/* Write the xdr:blipFill element. */
|
|
475
|
+
_drawing_write_blip_fill(self, index);
|
|
476
|
+
|
|
477
|
+
/* Write the xdr:spPr element. */
|
|
478
|
+
_drawing_write_sp_pr(self, drawing_object);
|
|
479
|
+
|
|
480
|
+
lxw_xml_end_tag(self->file, "xdr:pic");
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/*
|
|
484
|
+
* Write the <xdr:clientData> element.
|
|
485
|
+
*/
|
|
486
|
+
STATIC void
|
|
487
|
+
_drawing_write_client_data(lxw_drawing *self)
|
|
488
|
+
{
|
|
489
|
+
lxw_xml_empty_tag(self->file, "xdr:clientData", NULL);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/*
|
|
493
|
+
* Write the <xdr:cNvGraphicFramePr> element.
|
|
494
|
+
*/
|
|
495
|
+
STATIC void
|
|
496
|
+
_drawing_write_c_nv_graphic_frame_pr(lxw_drawing *self)
|
|
497
|
+
{
|
|
498
|
+
lxw_xml_empty_tag(self->file, "xdr:cNvGraphicFramePr", NULL);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/*
|
|
502
|
+
* Write the <xdr:nvGraphicFramePr> element.
|
|
503
|
+
*/
|
|
504
|
+
STATIC void
|
|
505
|
+
_drawing_write_nv_graphic_frame_pr(lxw_drawing *self, uint16_t index)
|
|
506
|
+
{
|
|
507
|
+
lxw_xml_start_tag(self->file, "xdr:nvGraphicFramePr", NULL);
|
|
508
|
+
|
|
509
|
+
/* Write the xdr:cNvPr element. */
|
|
510
|
+
_drawing_write_c_nv_pr(self, "Chart", index, NULL);
|
|
511
|
+
|
|
512
|
+
/* Write the xdr:cNvGraphicFramePr element. */
|
|
513
|
+
_drawing_write_c_nv_graphic_frame_pr(self);
|
|
514
|
+
|
|
515
|
+
lxw_xml_end_tag(self->file, "xdr:nvGraphicFramePr");
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/*
|
|
519
|
+
* Write the <a:off> element.
|
|
520
|
+
*/
|
|
521
|
+
STATIC void
|
|
522
|
+
_drawing_write_xfrm_offset(lxw_drawing *self)
|
|
523
|
+
{
|
|
524
|
+
struct xml_attribute_list attributes;
|
|
525
|
+
struct xml_attribute *attribute;
|
|
526
|
+
|
|
527
|
+
LXW_INIT_ATTRIBUTES();
|
|
528
|
+
LXW_PUSH_ATTRIBUTES_STR("x", "0");
|
|
529
|
+
LXW_PUSH_ATTRIBUTES_STR("y", "0");
|
|
530
|
+
|
|
531
|
+
lxw_xml_empty_tag(self->file, "a:off", &attributes);
|
|
532
|
+
|
|
533
|
+
LXW_FREE_ATTRIBUTES();
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/*
|
|
537
|
+
* Write the <a:ext> element.
|
|
538
|
+
*/
|
|
539
|
+
STATIC void
|
|
540
|
+
_drawing_write_xfrm_extension(lxw_drawing *self)
|
|
541
|
+
{
|
|
542
|
+
struct xml_attribute_list attributes;
|
|
543
|
+
struct xml_attribute *attribute;
|
|
544
|
+
|
|
545
|
+
LXW_INIT_ATTRIBUTES();
|
|
546
|
+
LXW_PUSH_ATTRIBUTES_STR("cx", "0");
|
|
547
|
+
LXW_PUSH_ATTRIBUTES_STR("cy", "0");
|
|
548
|
+
|
|
549
|
+
lxw_xml_empty_tag(self->file, "a:ext", &attributes);
|
|
550
|
+
|
|
551
|
+
LXW_FREE_ATTRIBUTES();
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/*
|
|
555
|
+
* Write the <xdr:xfrm> element.
|
|
556
|
+
*/
|
|
557
|
+
STATIC void
|
|
558
|
+
_drawing_write_xfrm(lxw_drawing *self)
|
|
559
|
+
{
|
|
560
|
+
lxw_xml_start_tag(self->file, "xdr:xfrm", NULL);
|
|
561
|
+
|
|
562
|
+
/* Write the a:off element. */
|
|
563
|
+
_drawing_write_xfrm_offset(self);
|
|
564
|
+
|
|
565
|
+
/* Write the a:ext element. */
|
|
566
|
+
_drawing_write_xfrm_extension(self);
|
|
567
|
+
|
|
568
|
+
lxw_xml_end_tag(self->file, "xdr:xfrm");
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/*
|
|
572
|
+
* Write the <c:chart> element.
|
|
573
|
+
*/
|
|
574
|
+
STATIC void
|
|
575
|
+
_drawing_write_chart(lxw_drawing *self, uint16_t index)
|
|
576
|
+
{
|
|
577
|
+
struct xml_attribute_list attributes;
|
|
578
|
+
struct xml_attribute *attribute;
|
|
579
|
+
char xmlns_c[] = LXW_SCHEMA_DRAWING "/chart";
|
|
580
|
+
char xmlns_r[] = LXW_SCHEMA_OFFICEDOC "/relationships";
|
|
581
|
+
char r_id[LXW_MAX_ATTRIBUTE_LENGTH];
|
|
582
|
+
|
|
583
|
+
lxw_snprintf(r_id, LXW_ATTR_32, "rId%d", index);
|
|
584
|
+
|
|
585
|
+
LXW_INIT_ATTRIBUTES();
|
|
586
|
+
LXW_PUSH_ATTRIBUTES_STR("xmlns:c", xmlns_c);
|
|
587
|
+
LXW_PUSH_ATTRIBUTES_STR("xmlns:r", xmlns_r);
|
|
588
|
+
LXW_PUSH_ATTRIBUTES_STR("r:id", r_id);
|
|
589
|
+
|
|
590
|
+
lxw_xml_empty_tag(self->file, "c:chart", &attributes);
|
|
591
|
+
|
|
592
|
+
LXW_FREE_ATTRIBUTES();
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/*
|
|
596
|
+
* Write the <a:graphicData> element.
|
|
597
|
+
*/
|
|
598
|
+
STATIC void
|
|
599
|
+
_drawing_write_a_graphic_data(lxw_drawing *self, uint16_t index)
|
|
600
|
+
{
|
|
601
|
+
struct xml_attribute_list attributes;
|
|
602
|
+
struct xml_attribute *attribute;
|
|
603
|
+
char uri[] = LXW_SCHEMA_DRAWING "/chart";
|
|
604
|
+
|
|
605
|
+
LXW_INIT_ATTRIBUTES();
|
|
606
|
+
LXW_PUSH_ATTRIBUTES_STR("uri", uri);
|
|
607
|
+
|
|
608
|
+
lxw_xml_start_tag(self->file, "a:graphicData", &attributes);
|
|
609
|
+
|
|
610
|
+
/* Write the c:chart element. */
|
|
611
|
+
_drawing_write_chart(self, index);
|
|
612
|
+
|
|
613
|
+
lxw_xml_end_tag(self->file, "a:graphicData");
|
|
614
|
+
|
|
615
|
+
LXW_FREE_ATTRIBUTES();
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/*
|
|
619
|
+
* Write the <a:graphic> element.
|
|
620
|
+
*/
|
|
621
|
+
STATIC void
|
|
622
|
+
_drawing_write_a_graphic(lxw_drawing *self, uint16_t index)
|
|
623
|
+
{
|
|
624
|
+
|
|
625
|
+
lxw_xml_start_tag(self->file, "a:graphic", NULL);
|
|
626
|
+
|
|
627
|
+
/* Write the a:graphicData element. */
|
|
628
|
+
_drawing_write_a_graphic_data(self, index);
|
|
629
|
+
|
|
630
|
+
lxw_xml_end_tag(self->file, "a:graphic");
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/*
|
|
634
|
+
* Write the <xdr:graphicFrame> element.
|
|
635
|
+
*/
|
|
636
|
+
STATIC void
|
|
637
|
+
_drawing_write_graphic_frame(lxw_drawing *self, uint16_t index)
|
|
638
|
+
{
|
|
639
|
+
struct xml_attribute_list attributes;
|
|
640
|
+
struct xml_attribute *attribute;
|
|
641
|
+
|
|
642
|
+
LXW_INIT_ATTRIBUTES();
|
|
643
|
+
LXW_PUSH_ATTRIBUTES_STR("macro", "");
|
|
644
|
+
|
|
645
|
+
lxw_xml_start_tag(self->file, "xdr:graphicFrame", &attributes);
|
|
646
|
+
|
|
647
|
+
/* Write the xdr:nvGraphicFramePr element. */
|
|
648
|
+
_drawing_write_nv_graphic_frame_pr(self, index);
|
|
649
|
+
|
|
650
|
+
/* Write the xdr:xfrm element. */
|
|
651
|
+
_drawing_write_xfrm(self);
|
|
652
|
+
|
|
653
|
+
/* Write the a:graphic element. */
|
|
654
|
+
_drawing_write_a_graphic(self, index);
|
|
655
|
+
|
|
656
|
+
lxw_xml_end_tag(self->file, "xdr:graphicFrame");
|
|
657
|
+
|
|
658
|
+
LXW_FREE_ATTRIBUTES();
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/*
|
|
662
|
+
* Write the <xdr:twoCellAnchor> element.
|
|
663
|
+
*/
|
|
664
|
+
STATIC void
|
|
665
|
+
_drawing_write_two_cell_anchor(lxw_drawing *self, uint16_t index,
|
|
666
|
+
lxw_drawing_object *drawing_object)
|
|
667
|
+
{
|
|
668
|
+
struct xml_attribute_list attributes;
|
|
669
|
+
struct xml_attribute *attribute;
|
|
670
|
+
|
|
671
|
+
LXW_INIT_ATTRIBUTES();
|
|
672
|
+
|
|
673
|
+
if (drawing_object->anchor_type == LXW_ANCHOR_TYPE_IMAGE) {
|
|
674
|
+
|
|
675
|
+
if (drawing_object->edit_as == LXW_ANCHOR_EDIT_AS_ABSOLUTE)
|
|
676
|
+
LXW_PUSH_ATTRIBUTES_STR("editAs", "absolute");
|
|
677
|
+
else if (drawing_object->edit_as != LXW_ANCHOR_EDIT_AS_RELATIVE)
|
|
678
|
+
LXW_PUSH_ATTRIBUTES_STR("editAs", "oneCell");
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
lxw_xml_start_tag(self->file, "xdr:twoCellAnchor", &attributes);
|
|
682
|
+
|
|
683
|
+
_drawing_write_from(self, &drawing_object->from);
|
|
684
|
+
_drawing_write_to(self, &drawing_object->to);
|
|
685
|
+
|
|
686
|
+
if (drawing_object->anchor_type == LXW_ANCHOR_TYPE_CHART) {
|
|
687
|
+
/* Write the xdr:graphicFrame element for charts. */
|
|
688
|
+
_drawing_write_graphic_frame(self, index);
|
|
689
|
+
}
|
|
690
|
+
else if (drawing_object->anchor_type == LXW_ANCHOR_TYPE_IMAGE) {
|
|
691
|
+
/* Write the xdr:pic element. */
|
|
692
|
+
_drawing_write_pic(self, index, drawing_object);
|
|
693
|
+
}
|
|
694
|
+
else {
|
|
695
|
+
/* Write the xdr:sp element for shapes. */
|
|
696
|
+
/* _drawing_write_sp(self, index, col_absolute, row_absolute, width,
|
|
697
|
+
height, shape); */
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/* Write the xdr:clientData element. */
|
|
701
|
+
_drawing_write_client_data(self);
|
|
702
|
+
|
|
703
|
+
lxw_xml_end_tag(self->file, "xdr:twoCellAnchor");
|
|
704
|
+
|
|
705
|
+
LXW_FREE_ATTRIBUTES();
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
/*****************************************************************************
|
|
709
|
+
*
|
|
710
|
+
* XML file assembly functions.
|
|
711
|
+
*
|
|
712
|
+
****************************************************************************/
|
|
713
|
+
|
|
714
|
+
/*
|
|
715
|
+
* Assemble and write the XML file.
|
|
716
|
+
*/
|
|
717
|
+
void
|
|
718
|
+
lxw_drawing_assemble_xml_file(lxw_drawing *self)
|
|
719
|
+
{
|
|
720
|
+
uint16_t index;
|
|
721
|
+
lxw_drawing_object *drawing_object;
|
|
722
|
+
|
|
723
|
+
/* Write the XML declaration. */
|
|
724
|
+
_drawing_xml_declaration(self);
|
|
725
|
+
|
|
726
|
+
/* Write the xdr:wsDr element. */
|
|
727
|
+
_write_drawing_workspace(self);
|
|
728
|
+
|
|
729
|
+
if (self->embedded) {
|
|
730
|
+
index = 1;
|
|
731
|
+
|
|
732
|
+
STAILQ_FOREACH(drawing_object, self->drawing_objects, list_pointers) {
|
|
733
|
+
_drawing_write_two_cell_anchor(self, index, drawing_object);
|
|
734
|
+
index++;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
lxw_xml_end_tag(self->file, "xdr:wsDr");
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/*****************************************************************************
|
|
743
|
+
*
|
|
744
|
+
* Public functions.
|
|
745
|
+
*
|
|
746
|
+
****************************************************************************/
|