Coverage Report

Created: 2025-11-11 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libxlsxwriter/src/theme.c
Line
Count
Source
1
/*****************************************************************************
2
 * theme - A library for creating Excel XLSX theme files.
3
 *
4
 * Used in conjunction with the libxlsxwriter library.
5
 *
6
 * SPDX-License-Identifier: BSD-2-Clause
7
 * Copyright 2014-2025, John McNamara, jmcnamara@cpan.org.
8
 *
9
 */
10
11
#include <string.h>
12
13
#include "xlsxwriter/xmlwriter.h"
14
#include "xlsxwriter/theme.h"
15
#include "xlsxwriter/utility.h"
16
17
const char *theme_strs[] = {
18
    "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n",
19
    "<a:theme xmlns:a=\"http://schemas.openxmlformats.org/",
20
    "drawingml/2006/main\" name=\"Office Theme\">",
21
    "<a:themeElements>",
22
    "<a:clrScheme name=\"Office\"><a:dk1>",
23
    "<a:sysClr val=\"windowText\" lastClr=\"000000\"/>",
24
    "</a:dk1><a:lt1>",
25
    "<a:sysClr val=\"window\" lastClr=\"FFFFFF\"/></a:lt1><a:dk2>",
26
    "<a:srgbClr val=\"1F497D\"/></a:dk2><a:lt2>",
27
    "<a:srgbClr val=\"EEECE1\"/></a:lt2><a:accent1>",
28
    "<a:srgbClr val=\"4F81BD\"/></a:accent1><a:accent2>",
29
    "<a:srgbClr val=\"C0504D\"/></a:accent2><a:accent3>",
30
    "<a:srgbClr val=\"9BBB59\"/></a:accent3><a:accent4>",
31
    "<a:srgbClr val=\"8064A2\"/></a:accent4><a:accent5>",
32
    "<a:srgbClr val=\"4BACC6\"/></a:accent5><a:accent6>",
33
    "<a:srgbClr val=\"F79646\"/></a:accent6><a:hlink>",
34
    "<a:srgbClr val=\"0000FF\"/></a:hlink><a:folHlink>",
35
    "<a:srgbClr val=\"800080\"/></a:folHlink></a:clrScheme>",
36
    "<a:fontScheme name=\"Office\"><a:majorFont>",
37
    "<a:latin typeface=\"Cambria\"/><a:ea typeface=\"\"/>",
38
    "<a:cs typeface=\"\"/>",
39
    "<a:font script=\"Jpan\" typeface=\"MS Pゴシック\"/>",
40
    "<a:font script=\"Hang\" typeface=\"맑은 고딕\"/>",
41
    "<a:font script=\"Hans\" typeface=\"宋体\"/>",
42
    "<a:font script=\"Hant\" typeface=\"新細明體\"/>",
43
    "<a:font script=\"Arab\" typeface=\"Times New Roman\"/>",
44
    "<a:font script=\"Hebr\" typeface=\"Times New Roman\"/>",
45
    "<a:font script=\"Thai\" typeface=\"Tahoma\"/>",
46
    "<a:font script=\"Ethi\" typeface=\"Nyala\"/>",
47
    "<a:font script=\"Beng\" typeface=\"Vrinda\"/>",
48
    "<a:font script=\"Gujr\" typeface=\"Shruti\"/>",
49
    "<a:font script=\"Khmr\" typeface=\"MoolBoran\"/>",
50
    "<a:font script=\"Knda\" typeface=\"Tunga\"/>",
51
    "<a:font script=\"Guru\" typeface=\"Raavi\"/>",
52
    "<a:font script=\"Cans\" typeface=\"Euphemia\"/>",
53
    "<a:font script=\"Cher\" typeface=\"Plantagenet Cherokee\"/>",
54
    "<a:font script=\"Yiii\" typeface=\"Microsoft Yi Baiti\"/>",
55
    "<a:font script=\"Tibt\" typeface=\"Microsoft Himalaya\"/>",
56
    "<a:font script=\"Thaa\" typeface=\"MV Boli\"/>",
57
    "<a:font script=\"Deva\" typeface=\"Mangal\"/>",
58
    "<a:font script=\"Telu\" typeface=\"Gautami\"/>",
59
    "<a:font script=\"Taml\" typeface=\"Latha\"/>",
60
    "<a:font script=\"Syrc\" typeface=\"Estrangelo Edessa\"/>",
61
    "<a:font script=\"Orya\" typeface=\"Kalinga\"/>",
62
    "<a:font script=\"Mlym\" typeface=\"Kartika\"/>",
63
    "<a:font script=\"Laoo\" typeface=\"DokChampa\"/>",
64
    "<a:font script=\"Sinh\" typeface=\"Iskoola Pota\"/>",
65
    "<a:font script=\"Mong\" typeface=\"Mongolian Baiti\"/>",
66
    "<a:font script=\"Viet\" typeface=\"Times New Roman\"/>",
67
    "<a:font script=\"Uigh\" typeface=\"Microsoft Uighur\"/>",
68
    "</a:majorFont>",
69
    "<a:minorFont>",
70
    "<a:latin typeface=\"Calibri\"/>",
71
    "<a:ea typeface=\"\"/>",
72
    "<a:cs typeface=\"\"/>",
73
    "<a:font script=\"Jpan\" typeface=\"MS Pゴシック\"/>",
74
    "<a:font script=\"Hang\" typeface=\"맑은 고딕\"/>",
75
    "<a:font script=\"Hans\" typeface=\"宋体\"/>",
76
    "<a:font script=\"Hant\" typeface=\"新細明體\"/>",
77
    "<a:font script=\"Arab\" typeface=\"Arial\"/>",
78
    "<a:font script=\"Hebr\" typeface=\"Arial\"/>",
79
    "<a:font script=\"Thai\" typeface=\"Tahoma\"/>",
80
    "<a:font script=\"Ethi\" typeface=\"Nyala\"/>",
81
    "<a:font script=\"Beng\" typeface=\"Vrinda\"/>",
82
    "<a:font script=\"Gujr\" typeface=\"Shruti\"/>",
83
    "<a:font script=\"Khmr\" typeface=\"DaunPenh\"/>",
84
    "<a:font script=\"Knda\" typeface=\"Tunga\"/>",
85
    "<a:font script=\"Guru\" typeface=\"Raavi\"/>",
86
    "<a:font script=\"Cans\" typeface=\"Euphemia\"/>",
87
    "<a:font script=\"Cher\" typeface=\"Plantagenet Cherokee\"/>",
88
    "<a:font script=\"Yiii\" typeface=\"Microsoft Yi Baiti\"/>",
89
    "<a:font script=\"Tibt\" typeface=\"Microsoft Himalaya\"/>",
90
    "<a:font script=\"Thaa\" typeface=\"MV Boli\"/>",
91
    "<a:font script=\"Deva\" typeface=\"Mangal\"/>",
92
    "<a:font script=\"Telu\" typeface=\"Gautami\"/>",
93
    "<a:font script=\"Taml\" typeface=\"Latha\"/>",
94
    "<a:font script=\"Syrc\" typeface=\"Estrangelo Edessa\"/>",
95
    "<a:font script=\"Orya\" typeface=\"Kalinga\"/>",
96
    "<a:font script=\"Mlym\" typeface=\"Kartika\"/>",
97
    "<a:font script=\"Laoo\" typeface=\"DokChampa\"/>",
98
    "<a:font script=\"Sinh\" typeface=\"Iskoola Pota\"/>",
99
    "<a:font script=\"Mong\" typeface=\"Mongolian Baiti\"/>",
100
    "<a:font script=\"Viet\" typeface=\"Arial\"/>",
101
    "<a:font script=\"Uigh\" typeface=\"Microsoft Uighur\"/>",
102
    "</a:minorFont>",
103
    "</a:fontScheme><a:fmtScheme name=\"Office\">",
104
    "<a:fillStyleLst>",
105
    "<a:solidFill>",
106
    "<a:schemeClr val=\"phClr\"/>",
107
    "</a:solidFill>",
108
    "<a:gradFill rotWithShape=\"1\">",
109
    "<a:gsLst>",
110
    "<a:gs pos=\"0\">",
111
    "<a:schemeClr val=\"phClr\">",
112
    "<a:tint val=\"50000\"/>",
113
    "<a:satMod val=\"300000\"/>",
114
    "</a:schemeClr>",
115
    "</a:gs>",
116
    "<a:gs pos=\"35000\">",
117
    "<a:schemeClr val=\"phClr\">",
118
    "<a:tint val=\"37000\"/>",
119
    "<a:satMod val=\"300000\"/>",
120
    "</a:schemeClr>",
121
    "</a:gs>",
122
    "<a:gs pos=\"100000\">",
123
    "<a:schemeClr val=\"phClr\">",
124
    "<a:tint val=\"15000\"/>",
125
    "<a:satMod val=\"350000\"/>",
126
    "</a:schemeClr>",
127
    "</a:gs>",
128
    "</a:gsLst>",
129
    "<a:lin ang=\"16200000\" scaled=\"1\"/>",
130
    "</a:gradFill>",
131
    "<a:gradFill rotWithShape=\"1\">",
132
    "<a:gsLst>",
133
    "<a:gs pos=\"0\">",
134
    "<a:schemeClr val=\"phClr\">",
135
    "<a:shade val=\"51000\"/>",
136
    "<a:satMod val=\"130000\"/>",
137
    "</a:schemeClr>",
138
    "</a:gs>",
139
    "<a:gs pos=\"80000\">",
140
    "<a:schemeClr val=\"phClr\">",
141
    "<a:shade val=\"93000\"/>",
142
    "<a:satMod val=\"130000\"/>",
143
    "</a:schemeClr>",
144
    "</a:gs>",
145
    "<a:gs pos=\"100000\">",
146
    "<a:schemeClr val=\"phClr\">",
147
    "<a:shade val=\"94000\"/>",
148
    "<a:satMod val=\"135000\"/>",
149
    "</a:schemeClr>",
150
    "</a:gs>",
151
    "</a:gsLst>",
152
    "<a:lin ang=\"16200000\" scaled=\"0\"/>",
153
    "</a:gradFill>",
154
    "</a:fillStyleLst>",
155
    "<a:lnStyleLst>",
156
    "<a:ln w=\"9525\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">",
157
    "<a:solidFill>",
158
    "<a:schemeClr val=\"phClr\">",
159
    "<a:shade val=\"95000\"/>",
160
    "<a:satMod val=\"105000\"/>",
161
    "</a:schemeClr>",
162
    "</a:solidFill>",
163
    "<a:prstDash val=\"solid\"/>",
164
    "</a:ln>",
165
    "<a:ln w=\"25400\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">",
166
    "<a:solidFill>",
167
    "<a:schemeClr val=\"phClr\"/>",
168
    "</a:solidFill>",
169
    "<a:prstDash val=\"solid\"/>",
170
    "</a:ln>",
171
    "<a:ln w=\"38100\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">",
172
    "<a:solidFill>",
173
    "<a:schemeClr val=\"phClr\"/>",
174
    "</a:solidFill>",
175
    "<a:prstDash val=\"solid\"/>",
176
    "</a:ln>",
177
    "</a:lnStyleLst>",
178
    "<a:effectStyleLst>",
179
    "<a:effectStyle>",
180
    "<a:effectLst>",
181
    "<a:outerShdw blurRad=\"40000\" dist=\"20000\" ",
182
    "dir=\"5400000\" rotWithShape=\"0\">",
183
    "<a:srgbClr val=\"000000\">",
184
    "<a:alpha val=\"38000\"/>",
185
    "</a:srgbClr>",
186
    "</a:outerShdw>",
187
    "</a:effectLst>",
188
    "</a:effectStyle>",
189
    "<a:effectStyle>",
190
    "<a:effectLst>",
191
    "<a:outerShdw blurRad=\"40000\" dist=\"23000\" ",
192
    "dir=\"5400000\" rotWithShape=\"0\">",
193
    "<a:srgbClr val=\"000000\">",
194
    "<a:alpha val=\"35000\"/>",
195
    "</a:srgbClr>",
196
    "</a:outerShdw>",
197
    "</a:effectLst>",
198
    "</a:effectStyle>",
199
    "<a:effectStyle>",
200
    "<a:effectLst>",
201
    "<a:outerShdw blurRad=\"40000\" dist=\"23000\" ",
202
    "dir=\"5400000\" rotWithShape=\"0\">",
203
    "<a:srgbClr val=\"000000\">",
204
    "<a:alpha val=\"35000\"/>",
205
    "</a:srgbClr>",
206
    "</a:outerShdw>",
207
    "</a:effectLst>",
208
    "<a:scene3d>",
209
    "<a:camera prst=\"orthographicFront\">",
210
    "<a:rot lat=\"0\" lon=\"0\" rev=\"0\"/>",
211
    "</a:camera>",
212
    "<a:lightRig rig=\"threePt\" dir=\"t\">",
213
    "<a:rot lat=\"0\" lon=\"0\" rev=\"1200000\"/>",
214
    "</a:lightRig>",
215
    "</a:scene3d>",
216
    "<a:sp3d>",
217
    "<a:bevelT w=\"63500\" h=\"25400\"/>",
218
    "</a:sp3d>",
219
    "</a:effectStyle>",
220
    "</a:effectStyleLst>",
221
    "<a:bgFillStyleLst>",
222
    "<a:solidFill>",
223
    "<a:schemeClr val=\"phClr\"/>",
224
    "</a:solidFill>",
225
    "<a:gradFill rotWithShape=\"1\">",
226
    "<a:gsLst>",
227
    "<a:gs pos=\"0\">",
228
    "<a:schemeClr val=\"phClr\">",
229
    "<a:tint val=\"40000\"/>",
230
    "<a:satMod val=\"350000\"/>",
231
    "</a:schemeClr>",
232
    "</a:gs>",
233
    "<a:gs pos=\"40000\">",
234
    "<a:schemeClr val=\"phClr\">",
235
    "<a:tint val=\"45000\"/>",
236
    "<a:shade val=\"99000\"/>",
237
    "<a:satMod val=\"350000\"/>",
238
    "</a:schemeClr>",
239
    "</a:gs>",
240
    "<a:gs pos=\"100000\">",
241
    "<a:schemeClr val=\"phClr\">",
242
    "<a:shade val=\"20000\"/>",
243
    "<a:satMod val=\"255000\"/>",
244
    "</a:schemeClr>",
245
    "</a:gs>",
246
    "</a:gsLst>",
247
    "<a:path path=\"circle\">",
248
    "<a:fillToRect l=\"50000\" t=\"-80000\" r=\"50000\" b=\"180000\"/>",
249
    "</a:path>",
250
    "</a:gradFill>",
251
    "<a:gradFill rotWithShape=\"1\">",
252
    "<a:gsLst>",
253
    "<a:gs pos=\"0\">",
254
    "<a:schemeClr val=\"phClr\">",
255
    "<a:tint val=\"80000\"/>",
256
    "<a:satMod val=\"300000\"/>",
257
    "</a:schemeClr>",
258
    "</a:gs>",
259
    "<a:gs pos=\"100000\">",
260
    "<a:schemeClr val=\"phClr\">",
261
    "<a:shade val=\"30000\"/>",
262
    "<a:satMod val=\"200000\"/>",
263
    "</a:schemeClr>",
264
    "</a:gs>",
265
    "</a:gsLst>",
266
    "<a:path path=\"circle\">",
267
    "<a:fillToRect l=\"50000\" t=\"50000\" r=\"50000\" b=\"50000\"/>",
268
    "</a:path>",
269
    "</a:gradFill>",
270
    "</a:bgFillStyleLst>",
271
    "</a:fmtScheme>",
272
    "</a:themeElements>",
273
    "<a:objectDefaults/>",
274
    "<a:extraClrSchemeLst/>",
275
    "</a:theme>\n",
276
    ""
277
};
278
279
/*
280
 * Forward declarations.
281
 */
282
283
/*****************************************************************************
284
 *
285
 * Private functions.
286
 *
287
 ****************************************************************************/
288
289
/*
290
 * Create a new theme object.
291
 */
292
lxw_theme *
293
lxw_theme_new(void)
294
1.31k
{
295
1.31k
    lxw_theme *theme = calloc(1, sizeof(lxw_theme));
296
1.31k
    GOTO_LABEL_ON_MEM_ERROR(theme, mem_error);
297
298
1.31k
    return theme;
299
300
0
mem_error:
301
0
    lxw_theme_free(theme);
302
0
    return NULL;
303
1.31k
}
304
305
/*
306
 * Free a theme object.
307
 */
308
void
309
lxw_theme_free(lxw_theme *theme)
310
1.31k
{
311
1.31k
    if (!theme)
312
0
        return;
313
314
1.31k
    free(theme);
315
1.31k
}
316
317
/*****************************************************************************
318
 *
319
 * XML functions.
320
 *
321
 ****************************************************************************/
322
323
/* This library isn't a xmlwriter. */
324
325
/*****************************************************************************
326
 *
327
 * XML file assembly functions.
328
 *
329
 ****************************************************************************/
330
331
/*
332
 * Assemble and write the XML file.
333
 */
334
void
335
lxw_theme_assemble_xml_file(lxw_theme *self)
336
1.31k
{
337
1.31k
    int i = 0;
338
339
340k
    while (strlen(theme_strs[i])) {
340
339k
        fprintf(self->file, "%s", theme_strs[i]);
341
339k
        i++;
342
339k
    }
343
1.31k
}
344
345
/*****************************************************************************
346
 *
347
 * Public functions.
348
 *
349
 ****************************************************************************/