xlsxwriter 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +40 -0
  3. data/ext/xlsxwriter/chart.c +105 -0
  4. data/ext/xlsxwriter/chart.h +27 -0
  5. data/ext/xlsxwriter/extconf.rb +14 -0
  6. data/ext/xlsxwriter/format.c +67 -0
  7. data/ext/xlsxwriter/format.h +9 -0
  8. data/ext/xlsxwriter/libxlsxwriter/LICENSE.txt +89 -0
  9. data/ext/xlsxwriter/libxlsxwriter/Makefile +141 -0
  10. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter.h +23 -0
  11. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/app.h +79 -0
  12. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/chart.h +1093 -0
  13. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/common.h +336 -0
  14. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/content_types.h +74 -0
  15. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/core.h +51 -0
  16. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/custom.h +52 -0
  17. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/drawing.h +111 -0
  18. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/format.h +1214 -0
  19. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/hash_table.h +76 -0
  20. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/packager.h +80 -0
  21. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/relationships.h +77 -0
  22. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/shared_strings.h +83 -0
  23. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/styles.h +77 -0
  24. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/theme.h +47 -0
  25. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +215 -0
  26. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/queue.h +694 -0
  27. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/tmpfileplus.h +53 -0
  28. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/tree.h +801 -0
  29. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/zip.h +375 -0
  30. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/utility.h +166 -0
  31. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/workbook.h +751 -0
  32. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/worksheet.h +2641 -0
  33. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/xmlwriter.h +178 -0
  34. data/ext/xlsxwriter/libxlsxwriter/lib/.gitignore +0 -0
  35. data/ext/xlsxwriter/libxlsxwriter/src/Makefile +125 -0
  36. data/ext/xlsxwriter/libxlsxwriter/src/app.c +439 -0
  37. data/ext/xlsxwriter/libxlsxwriter/src/chart.c +3420 -0
  38. data/ext/xlsxwriter/libxlsxwriter/src/content_types.c +341 -0
  39. data/ext/xlsxwriter/libxlsxwriter/src/core.c +293 -0
  40. data/ext/xlsxwriter/libxlsxwriter/src/custom.c +224 -0
  41. data/ext/xlsxwriter/libxlsxwriter/src/drawing.c +746 -0
  42. data/ext/xlsxwriter/libxlsxwriter/src/format.c +728 -0
  43. data/ext/xlsxwriter/libxlsxwriter/src/hash_table.c +223 -0
  44. data/ext/xlsxwriter/libxlsxwriter/src/packager.c +877 -0
  45. data/ext/xlsxwriter/libxlsxwriter/src/relationships.c +242 -0
  46. data/ext/xlsxwriter/libxlsxwriter/src/shared_strings.c +264 -0
  47. data/ext/xlsxwriter/libxlsxwriter/src/styles.c +1086 -0
  48. data/ext/xlsxwriter/libxlsxwriter/src/theme.c +348 -0
  49. data/ext/xlsxwriter/libxlsxwriter/src/utility.c +512 -0
  50. data/ext/xlsxwriter/libxlsxwriter/src/workbook.c +1895 -0
  51. data/ext/xlsxwriter/libxlsxwriter/src/worksheet.c +4992 -0
  52. data/ext/xlsxwriter/libxlsxwriter/src/xmlwriter.c +355 -0
  53. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/Makefile +44 -0
  54. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/crypt.h +131 -0
  55. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/ioapi.c +247 -0
  56. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/ioapi.h +209 -0
  57. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/iowin32.c +456 -0
  58. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/iowin32.h +28 -0
  59. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/miniunz.c +660 -0
  60. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/minizip.c +520 -0
  61. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/mztools.c +291 -0
  62. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/mztools.h +37 -0
  63. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/unzip.c +2125 -0
  64. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/unzip.h +437 -0
  65. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/zip.c +2007 -0
  66. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/zip.h +367 -0
  67. data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/Makefile +42 -0
  68. data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c +342 -0
  69. data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.h +53 -0
  70. data/ext/xlsxwriter/workbook.c +257 -0
  71. data/ext/xlsxwriter/workbook.h +42 -0
  72. data/ext/xlsxwriter/workbook_properties.c +103 -0
  73. data/ext/xlsxwriter/workbook_properties.h +10 -0
  74. data/ext/xlsxwriter/worksheet.c +1064 -0
  75. data/ext/xlsxwriter/worksheet.h +74 -0
  76. data/ext/xlsxwriter/xlsxwriter.c +239 -0
  77. data/lib/xlsxwriter.rb +6 -0
  78. data/lib/xlsxwriter/version.rb +3 -0
  79. data/lib/xlsxwriter/worksheet.rb +72 -0
  80. data/test/run-test.rb +11 -0
  81. data/test/support/xlsx_comparable.rb +109 -0
  82. data/test/test-array-formula.rb +33 -0
  83. data/test/test-autofilter.rb +70 -0
  84. data/test/test-chart-area.rb +25 -0
  85. data/test/test-data.rb +65 -0
  86. data/test/test-default-row.rb +25 -0
  87. data/test/test-defined-name.rb +46 -0
  88. data/test/test-escapes.rb +33 -0
  89. data/test/test-fit-to-pages.rb +21 -0
  90. data/test/test-formatting.rb +137 -0
  91. data/test/test-gridlines.rb +15 -0
  92. data/test/test-hyperlink.rb +67 -0
  93. data/test/test-image.rb +84 -0
  94. data/test/test-merge-range.rb +18 -0
  95. data/test/test-misc.rb +29 -0
  96. data/test/test-optimize.rb +32 -0
  97. data/test/test-page-breaks.rb +13 -0
  98. data/test/test-page-setup.rb +28 -0
  99. data/test/test-panes.rb +45 -0
  100. data/test/test-print-area.rb +19 -0
  101. data/test/test-print-options.rb +61 -0
  102. data/test/test-print-scale.rb +12 -0
  103. data/test/test-properties.rb +51 -0
  104. data/test/test-protect.rb +27 -0
  105. data/test/test-repeat.rb +23 -0
  106. data/test/test-row-col-format.rb +35 -0
  107. data/test/test-set-selection.rb +13 -0
  108. data/test/test-set-start-page.rb +13 -0
  109. data/test/test-simple.rb +62 -0
  110. data/test/test-types.rb +17 -0
  111. data/test/xlsx-func-testcase.rb +36 -0
  112. metadata +228 -0
@@ -0,0 +1,341 @@
1
+ /*****************************************************************************
2
+ * content_types - A library for creating Excel XLSX content_types 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/content_types.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 content_types object.
26
+ */
27
+ lxw_content_types *
28
+ lxw_content_types_new()
29
+ {
30
+ lxw_content_types *content_types = calloc(1, sizeof(lxw_content_types));
31
+ GOTO_LABEL_ON_MEM_ERROR(content_types, mem_error);
32
+
33
+ content_types->default_types = calloc(1, sizeof(struct lxw_tuples));
34
+ GOTO_LABEL_ON_MEM_ERROR(content_types->default_types, mem_error);
35
+ STAILQ_INIT(content_types->default_types);
36
+
37
+ content_types->overrides = calloc(1, sizeof(struct lxw_tuples));
38
+ GOTO_LABEL_ON_MEM_ERROR(content_types->overrides, mem_error);
39
+ STAILQ_INIT(content_types->overrides);
40
+
41
+ lxw_ct_add_default(content_types, "rels",
42
+ LXW_APP_PACKAGE "relationships+xml");
43
+ lxw_ct_add_default(content_types, "xml", "application/xml");
44
+
45
+ lxw_ct_add_override(content_types, "/docProps/app.xml",
46
+ LXW_APP_DOCUMENT "extended-properties+xml");
47
+ lxw_ct_add_override(content_types, "/docProps/core.xml",
48
+ LXW_APP_PACKAGE "core-properties+xml");
49
+ lxw_ct_add_override(content_types, "/xl/styles.xml",
50
+ LXW_APP_DOCUMENT "spreadsheetml.styles+xml");
51
+ lxw_ct_add_override(content_types, "/xl/theme/theme1.xml",
52
+ LXW_APP_DOCUMENT "theme+xml");
53
+ lxw_ct_add_override(content_types, "/xl/workbook.xml",
54
+ LXW_APP_DOCUMENT "spreadsheetml.sheet.main+xml");
55
+
56
+ return content_types;
57
+
58
+ mem_error:
59
+ lxw_content_types_free(content_types);
60
+ return NULL;
61
+ }
62
+
63
+ /*
64
+ * Free a content_types object.
65
+ */
66
+ void
67
+ lxw_content_types_free(lxw_content_types *content_types)
68
+ {
69
+ lxw_tuple *default_type;
70
+ lxw_tuple *override;
71
+
72
+ if (!content_types)
73
+ return;
74
+
75
+ while (!STAILQ_EMPTY(content_types->default_types)) {
76
+ default_type = STAILQ_FIRST(content_types->default_types);
77
+ STAILQ_REMOVE_HEAD(content_types->default_types, list_pointers);
78
+ free(default_type->key);
79
+ free(default_type->value);
80
+ free(default_type);
81
+ }
82
+
83
+ while (!STAILQ_EMPTY(content_types->overrides)) {
84
+ override = STAILQ_FIRST(content_types->overrides);
85
+ STAILQ_REMOVE_HEAD(content_types->overrides, list_pointers);
86
+ free(override->key);
87
+ free(override->value);
88
+ free(override);
89
+ }
90
+
91
+ free(content_types->default_types);
92
+ free(content_types->overrides);
93
+ free(content_types);
94
+ }
95
+
96
+ /*****************************************************************************
97
+ *
98
+ * XML functions.
99
+ *
100
+ ****************************************************************************/
101
+
102
+ /*
103
+ * Write the XML declaration.
104
+ */
105
+ STATIC void
106
+ _content_types_xml_declaration(lxw_content_types *self)
107
+ {
108
+ lxw_xml_declaration(self->file);
109
+ }
110
+
111
+ /*
112
+ * Write the <Types> element.
113
+ */
114
+ STATIC void
115
+ _write_types(lxw_content_types *self)
116
+ {
117
+ struct xml_attribute_list attributes;
118
+ struct xml_attribute *attribute;
119
+
120
+ LXW_INIT_ATTRIBUTES();
121
+ LXW_PUSH_ATTRIBUTES_STR("xmlns", LXW_SCHEMA_CONTENT);
122
+
123
+ lxw_xml_start_tag(self->file, "Types", &attributes);
124
+
125
+ LXW_FREE_ATTRIBUTES();
126
+ }
127
+
128
+ /*
129
+ * Write the <Default> element.
130
+ */
131
+ STATIC void
132
+ _write_default(lxw_content_types *self, const char *ext, const char *type)
133
+ {
134
+ struct xml_attribute_list attributes;
135
+ struct xml_attribute *attribute;
136
+
137
+ LXW_INIT_ATTRIBUTES();
138
+ LXW_PUSH_ATTRIBUTES_STR("Extension", ext);
139
+ LXW_PUSH_ATTRIBUTES_STR("ContentType", type);
140
+
141
+ lxw_xml_empty_tag(self->file, "Default", &attributes);
142
+
143
+ LXW_FREE_ATTRIBUTES();
144
+ }
145
+
146
+ /*
147
+ * Write the <Override> element.
148
+ */
149
+ STATIC void
150
+ _write_override(lxw_content_types *self, const char *part_name,
151
+ const char *type)
152
+ {
153
+ struct xml_attribute_list attributes;
154
+ struct xml_attribute *attribute;
155
+
156
+ LXW_INIT_ATTRIBUTES();
157
+ LXW_PUSH_ATTRIBUTES_STR("PartName", part_name);
158
+ LXW_PUSH_ATTRIBUTES_STR("ContentType", type);
159
+
160
+ lxw_xml_empty_tag(self->file, "Override", &attributes);
161
+
162
+ LXW_FREE_ATTRIBUTES();
163
+ }
164
+
165
+ /*****************************************************************************
166
+ *
167
+ * XML file assembly functions.
168
+ *
169
+ ****************************************************************************/
170
+
171
+ /*
172
+ * Write out all of the <Default> types.
173
+ */
174
+ STATIC void
175
+ _write_defaults(lxw_content_types *self)
176
+ {
177
+ lxw_tuple *tuple;
178
+
179
+ STAILQ_FOREACH(tuple, self->default_types, list_pointers) {
180
+ _write_default(self, tuple->key, tuple->value);
181
+ }
182
+ }
183
+
184
+ /*
185
+ * Write out all of the <Override> types.
186
+ */
187
+ STATIC void
188
+ _write_overrides(lxw_content_types *self)
189
+ {
190
+ lxw_tuple *tuple;
191
+
192
+ STAILQ_FOREACH(tuple, self->overrides, list_pointers) {
193
+ _write_override(self, tuple->key, tuple->value);
194
+ }
195
+ }
196
+
197
+ /*
198
+ * Assemble and write the XML file.
199
+ */
200
+ void
201
+ lxw_content_types_assemble_xml_file(lxw_content_types *self)
202
+ {
203
+ /* Write the XML declaration. */
204
+ _content_types_xml_declaration(self);
205
+
206
+ _write_types(self);
207
+ _write_defaults(self);
208
+ _write_overrides(self);
209
+
210
+ /* Close the content_types tag. */
211
+ lxw_xml_end_tag(self->file, "Types");
212
+ }
213
+
214
+ /*****************************************************************************
215
+ *
216
+ * Public functions.
217
+ *
218
+ ****************************************************************************/
219
+ /*
220
+ * Add elements to the ContentTypes defaults.
221
+ */
222
+ void
223
+ lxw_ct_add_default(lxw_content_types *self, const char *key,
224
+ const char *value)
225
+ {
226
+ lxw_tuple *tuple;
227
+
228
+ if (!key || !value)
229
+ return;
230
+
231
+ tuple = calloc(1, sizeof(lxw_tuple));
232
+ GOTO_LABEL_ON_MEM_ERROR(tuple, mem_error);
233
+
234
+ tuple->key = lxw_strdup(key);
235
+ GOTO_LABEL_ON_MEM_ERROR(tuple->key, mem_error);
236
+
237
+ tuple->value = lxw_strdup(value);
238
+ GOTO_LABEL_ON_MEM_ERROR(tuple->value, mem_error);
239
+
240
+ STAILQ_INSERT_TAIL(self->default_types, tuple, list_pointers);
241
+
242
+ return;
243
+
244
+ mem_error:
245
+ if (tuple) {
246
+ free(tuple->key);
247
+ free(tuple->value);
248
+ free(tuple);
249
+ }
250
+ }
251
+
252
+ /*
253
+ * Add elements to the ContentTypes overrides.
254
+ */
255
+ void
256
+ lxw_ct_add_override(lxw_content_types *self, const char *key,
257
+ const char *value)
258
+ {
259
+ lxw_tuple *tuple;
260
+
261
+ if (!key || !value)
262
+ return;
263
+
264
+ tuple = calloc(1, sizeof(lxw_tuple));
265
+ GOTO_LABEL_ON_MEM_ERROR(tuple, mem_error);
266
+
267
+ tuple->key = lxw_strdup(key);
268
+ GOTO_LABEL_ON_MEM_ERROR(tuple->key, mem_error);
269
+
270
+ tuple->value = lxw_strdup(value);
271
+ GOTO_LABEL_ON_MEM_ERROR(tuple->value, mem_error);
272
+
273
+ STAILQ_INSERT_TAIL(self->overrides, tuple, list_pointers);
274
+
275
+ return;
276
+
277
+ mem_error:
278
+ if (tuple) {
279
+ free(tuple->key);
280
+ free(tuple->value);
281
+ free(tuple);
282
+ }
283
+ }
284
+
285
+ /*
286
+ * Add the name of a worksheet to the ContentTypes overrides.
287
+ */
288
+ void
289
+ lxw_ct_add_worksheet_name(lxw_content_types *self, const char *name)
290
+ {
291
+ lxw_ct_add_override(self, name,
292
+ LXW_APP_DOCUMENT "spreadsheetml.worksheet+xml");
293
+ }
294
+
295
+ /*
296
+ * Add the name of a chart to the ContentTypes overrides.
297
+ */
298
+ void
299
+ lxw_ct_add_chart_name(lxw_content_types *self, const char *name)
300
+ {
301
+ lxw_ct_add_override(self, name, LXW_APP_DOCUMENT "drawingml.chart+xml");
302
+ }
303
+
304
+ /*
305
+ * Add the name of a drawing to the ContentTypes overrides.
306
+ */
307
+ void
308
+ lxw_ct_add_drawing_name(lxw_content_types *self, const char *name)
309
+ {
310
+ lxw_ct_add_override(self, name, LXW_APP_DOCUMENT "drawing+xml");
311
+ }
312
+
313
+ /*
314
+ * Add the sharedStrings link to the ContentTypes overrides.
315
+ */
316
+ void
317
+ lxw_ct_add_shared_strings(lxw_content_types *self)
318
+ {
319
+ lxw_ct_add_override(self, "/xl/sharedStrings.xml",
320
+ LXW_APP_DOCUMENT "spreadsheetml.sharedStrings+xml");
321
+ }
322
+
323
+ /*
324
+ * Add the calcChain link to the ContentTypes overrides.
325
+ */
326
+ void
327
+ lxw_ct_add_calc_chain(lxw_content_types *self)
328
+ {
329
+ lxw_ct_add_override(self, "/xl/calcChain.xml",
330
+ LXW_APP_DOCUMENT "spreadsheetml.calcChain+xml");
331
+ }
332
+
333
+ /*
334
+ * Add the custom properties to the ContentTypes overrides.
335
+ */
336
+ void
337
+ lxw_ct_add_custom_properties(lxw_content_types *self)
338
+ {
339
+ lxw_ct_add_override(self, "/docProps/custom.xml",
340
+ LXW_APP_DOCUMENT "custom-properties+xml");
341
+ }
@@ -0,0 +1,293 @@
1
+ /*****************************************************************************
2
+ * core - A library for creating Excel XLSX core 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/core.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 core object.
26
+ */
27
+ lxw_core *
28
+ lxw_core_new()
29
+ {
30
+ lxw_core *core = calloc(1, sizeof(lxw_core));
31
+ GOTO_LABEL_ON_MEM_ERROR(core, mem_error);
32
+
33
+ return core;
34
+
35
+ mem_error:
36
+ lxw_core_free(core);
37
+ return NULL;
38
+ }
39
+
40
+ /*
41
+ * Free a core object.
42
+ */
43
+ void
44
+ lxw_core_free(lxw_core *core)
45
+ {
46
+ if (!core)
47
+ return;
48
+
49
+ free(core);
50
+ }
51
+
52
+ /*
53
+ * Convert a time_t struct to a ISO 8601 style "2010-01-01T00:00:00Z" date.
54
+ */
55
+ static void
56
+ _localtime_to_iso8601_date(time_t *timer, char *str, size_t size)
57
+ {
58
+ struct tm *tmp_localtime;
59
+ time_t current_time = time(NULL);
60
+
61
+ if (*timer)
62
+ tmp_localtime = localtime(timer);
63
+ else
64
+ tmp_localtime = localtime(&current_time);
65
+
66
+ strftime(str, size - 1, "%Y-%m-%dT%H:%M:%SZ", tmp_localtime);
67
+ }
68
+
69
+ /*****************************************************************************
70
+ *
71
+ * XML functions.
72
+ *
73
+ ****************************************************************************/
74
+
75
+ /*
76
+ * Write the XML declaration.
77
+ */
78
+ STATIC void
79
+ _core_xml_declaration(lxw_core *self)
80
+ {
81
+ lxw_xml_declaration(self->file);
82
+ }
83
+
84
+ /*
85
+ * Write the <cp:coreProperties> element.
86
+ */
87
+ STATIC void
88
+ _write_cp_core_properties(lxw_core *self)
89
+ {
90
+ struct xml_attribute_list attributes;
91
+ struct xml_attribute *attribute;
92
+
93
+ LXW_INIT_ATTRIBUTES();
94
+ LXW_PUSH_ATTRIBUTES_STR("xmlns:cp",
95
+ "http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
96
+ LXW_PUSH_ATTRIBUTES_STR("xmlns:dc", "http://purl.org/dc/elements/1.1/");
97
+ LXW_PUSH_ATTRIBUTES_STR("xmlns:dcterms", "http://purl.org/dc/terms/");
98
+ LXW_PUSH_ATTRIBUTES_STR("xmlns:dcmitype", "http://purl.org/dc/dcmitype/");
99
+ LXW_PUSH_ATTRIBUTES_STR("xmlns:xsi",
100
+ "http://www.w3.org/2001/XMLSchema-instance");
101
+
102
+ lxw_xml_start_tag(self->file, "cp:coreProperties", &attributes);
103
+
104
+ LXW_FREE_ATTRIBUTES();
105
+ }
106
+
107
+ /*
108
+ * Write the <dc:creator> element.
109
+ */
110
+ STATIC void
111
+ _write_dc_creator(lxw_core *self)
112
+ {
113
+ if (self->properties->author) {
114
+ lxw_xml_data_element(self->file, "dc:creator",
115
+ self->properties->author, NULL);
116
+ }
117
+ else {
118
+ lxw_xml_data_element(self->file, "dc:creator", "", NULL);
119
+ }
120
+ }
121
+
122
+ /*
123
+ * Write the <cp:lastModifiedBy> element.
124
+ */
125
+ STATIC void
126
+ _write_cp_last_modified_by(lxw_core *self)
127
+ {
128
+ if (self->properties->author) {
129
+ lxw_xml_data_element(self->file, "cp:lastModifiedBy",
130
+ self->properties->author, NULL);
131
+ }
132
+ else {
133
+ lxw_xml_data_element(self->file, "cp:lastModifiedBy", "", NULL);
134
+ }
135
+ }
136
+
137
+ /*
138
+ * Write the <dcterms:created> element.
139
+ */
140
+ STATIC void
141
+ _write_dcterms_created(lxw_core *self)
142
+ {
143
+ struct xml_attribute_list attributes;
144
+ struct xml_attribute *attribute;
145
+ char datetime[LXW_ATTR_32];
146
+
147
+ _localtime_to_iso8601_date(&self->properties->created, datetime,
148
+ LXW_ATTR_32);
149
+
150
+ LXW_INIT_ATTRIBUTES();
151
+ LXW_PUSH_ATTRIBUTES_STR("xsi:type", "dcterms:W3CDTF");
152
+
153
+ lxw_xml_data_element(self->file, "dcterms:created", datetime,
154
+ &attributes);
155
+
156
+ LXW_FREE_ATTRIBUTES();
157
+ }
158
+
159
+ /*
160
+ * Write the <dcterms:modified> element.
161
+ */
162
+ STATIC void
163
+ _write_dcterms_modified(lxw_core *self)
164
+ {
165
+ struct xml_attribute_list attributes;
166
+ struct xml_attribute *attribute;
167
+ char datetime[LXW_ATTR_32];
168
+
169
+ _localtime_to_iso8601_date(&self->properties->created, datetime,
170
+ LXW_ATTR_32);
171
+
172
+ LXW_INIT_ATTRIBUTES();
173
+ LXW_PUSH_ATTRIBUTES_STR("xsi:type", "dcterms:W3CDTF");
174
+
175
+ lxw_xml_data_element(self->file, "dcterms:modified", datetime,
176
+ &attributes);
177
+
178
+ LXW_FREE_ATTRIBUTES();
179
+ }
180
+
181
+ /*
182
+ * Write the <dc:title> element.
183
+ */
184
+ STATIC void
185
+ _write_dc_title(lxw_core *self)
186
+ {
187
+ if (!self->properties->title)
188
+ return;
189
+
190
+ lxw_xml_data_element(self->file, "dc:title", self->properties->title,
191
+ NULL);
192
+ }
193
+
194
+ /*
195
+ * Write the <dc:subject> element.
196
+ */
197
+ STATIC void
198
+ _write_dc_subject(lxw_core *self)
199
+ {
200
+ if (!self->properties->subject)
201
+ return;
202
+
203
+ lxw_xml_data_element(self->file, "dc:subject", self->properties->subject,
204
+ NULL);
205
+ }
206
+
207
+ /*
208
+ * Write the <cp:keywords> element.
209
+ */
210
+ STATIC void
211
+ _write_cp_keywords(lxw_core *self)
212
+ {
213
+ if (!self->properties->keywords)
214
+ return;
215
+
216
+ lxw_xml_data_element(self->file, "cp:keywords",
217
+ self->properties->keywords, NULL);
218
+ }
219
+
220
+ /*
221
+ * Write the <dc:description> element.
222
+ */
223
+ STATIC void
224
+ _write_dc_description(lxw_core *self)
225
+ {
226
+ if (!self->properties->comments)
227
+ return;
228
+
229
+ lxw_xml_data_element(self->file, "dc:description",
230
+ self->properties->comments, NULL);
231
+ }
232
+
233
+ /*
234
+ * Write the <cp:category> element.
235
+ */
236
+ STATIC void
237
+ _write_cp_category(lxw_core *self)
238
+ {
239
+ if (!self->properties->category)
240
+ return;
241
+
242
+ lxw_xml_data_element(self->file, "cp:category",
243
+ self->properties->category, NULL);
244
+ }
245
+
246
+ /*
247
+ * Write the <cp:contentStatus> element.
248
+ */
249
+ STATIC void
250
+ _write_cp_content_status(lxw_core *self)
251
+ {
252
+ if (!self->properties->status)
253
+ return;
254
+
255
+ lxw_xml_data_element(self->file, "cp:contentStatus",
256
+ self->properties->status, NULL);
257
+ }
258
+
259
+ /*****************************************************************************
260
+ *
261
+ * XML file assembly functions.
262
+ *
263
+ ****************************************************************************/
264
+
265
+ /*
266
+ * Assemble and write the XML file.
267
+ */
268
+ void
269
+ lxw_core_assemble_xml_file(lxw_core *self)
270
+ {
271
+ /* Write the XML declaration. */
272
+ _core_xml_declaration(self);
273
+
274
+ _write_cp_core_properties(self);
275
+ _write_dc_title(self);
276
+ _write_dc_subject(self);
277
+ _write_dc_creator(self);
278
+ _write_cp_keywords(self);
279
+ _write_dc_description(self);
280
+ _write_cp_last_modified_by(self);
281
+ _write_dcterms_created(self);
282
+ _write_dcterms_modified(self);
283
+ _write_cp_category(self);
284
+ _write_cp_content_status(self);
285
+
286
+ lxw_xml_end_tag(self->file, "cp:coreProperties");
287
+ }
288
+
289
+ /*****************************************************************************
290
+ *
291
+ * Public functions.
292
+ *
293
+ ****************************************************************************/