-
Notifications
You must be signed in to change notification settings - Fork 0
/
x_theme.go
588 lines (548 loc) · 15.9 KB
/
x_theme.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
package packaging
import "encoding/xml"
// Theme Defines
const (
ThemeContentType = "application/vnd.openxmlformats-officedocument.theme+xml"
ThemeRelationshipType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"
ThemePath = "xl"
ThemeFileName = "theme/theme%d.xml"
)
// XTheme Theme XML doc
type XTheme struct {
XMLName xml.Name `xml:"a:theme"`
XmlnsA string `xml:"xmlns:a,attr"`
Name string `xml:"name,attr"`
ThemeElements *XThemeElements `xml:"a:themeElements"`
ObjectDefaults *XObjectDefaults `xml:"a:objectDefaults"`
ExtraClrSchemeLst *XExtraClrSchemeLst `xml:"a:extraClrSchemeLst"`
ExtLst *XExtLst `xml:"a:extLst"`
}
// XThemeElements ThemeElements type
type XThemeElements struct {
ClrScheme *XClrScheme `xml:"a:clrScheme"`
FontScheme *XFontScheme `xml:"a:fontScheme"`
FmtScheme *XFmtScheme `xml:"a:fmtScheme"`
}
// XClrScheme ClrScheme type
type XClrScheme struct {
Name string `xml:"name,attr"`
Dk1 *XSysClrElement `xml:"a:dk1"`
Lt1 *XSysClrElement `xml:"a:lt1"`
Dk2 *XSrgbClrElement `xml:"a:dk2"`
Lt2 *XSrgbClrElement `xml:"a:lt2"`
Accent1 *XSrgbClrElement `xml:"a:accent1"`
Accent2 *XSrgbClrElement `xml:"a:accent2"`
Accent3 *XSrgbClrElement `xml:"a:accent3"`
Accent4 *XSrgbClrElement `xml:"a:accent4"`
Accent5 *XSrgbClrElement `xml:"a:accent5"`
Accent6 *XSrgbClrElement `xml:"a:accent6"`
Hlink *XSrgbClrElement `xml:"a:hlink"`
FolHlink *XSrgbClrElement `xml:"a:folHlink"`
}
// XSysClrElement SysClrElement type
type XSysClrElement struct {
SysClr *XSysClr `xml:"a:sysClr"`
}
// XSysClr SysClr type
type XSysClr struct {
Val string `xml:"val,attr"`
LastClr string `xml:"lastClr,attr"`
}
// XSrgbClrElement SrgbClrElement type
type XSrgbClrElement struct {
SrgbClr *XSrgbClr `xml:"a:srgbClr"`
}
// XSrgbClr SrgbClr type
type XSrgbClr struct {
Val string `xml:"val,attr"`
Alpha *XValAttrElement `xml:"a:alpha,omitempty"`
}
// XFontScheme FontScheme type
type XFontScheme struct {
Name string `xml:"name,attr"`
MajorFont *XFontElement `xml:"a:majorFont"`
MinorFont *XFontElement `xml:"a:minorFont"`
}
// XFontElement FontElement type
type XFontElement struct {
Latin *XLatin `xml:"a:latin"`
Ea *XTypeface `xml:"a:ea"`
Cs *XTypeface `xml:"a:cs"`
Font []*XThemeFont `xml:"a:font"`
}
// XLatin Latin type
type XLatin struct {
Typeface string `xml:"typeface,attr"`
Panose string `xml:"panose,attr"`
}
// XTypeface Typeface type
type XTypeface struct {
Typeface string `xml:"typeface,attr"`
}
// XThemeFont ThemeFont type
type XThemeFont struct {
Script string `xml:"script,attr"`
Typeface string `xml:"typeface,attr"`
}
// XFmtScheme FmtScheme type
type XFmtScheme struct {
Name string `xml:"name,attr"`
FillStyleLst *XFillStyleLst `xml:"a:fillStyleLst"`
LnStyleLst *XLnStyleLst `xml:"a:lnStyleLst"`
EffectStyleLst *XEffectStyleLst `xml:"a:effectStyleLst"`
BgFillStyleLst *XBgFillStyleLst `xml:"a:bgFillStyleLst"`
}
// XFillStyleLst FillStyleLst type
type XFillStyleLst struct {
SolidFill *XSolidFill `xml:"a:solidFill"`
GradFill []*XGradFill `xml:"a:gradFill"`
}
// XSolidFill SolidFill type
type XSolidFill struct {
SchemeClr *XSchemeClr `xml:"a:schemeClr"`
Tint *XValAttrElement `xml:"a:tint,omitempty"`
SatMod *XValAttrElement `xml:"a:satMod,omitempty"`
}
// XSchemeClr SchemeClr type
type XSchemeClr struct {
Val string `xml:"val,attr"`
LumMod *XValAttrElement `xml:"a:lumMod,omitempty"`
SatMod *XValAttrElement `xml:"a:satMod,omitempty"`
Tint *XValAttrElement `xml:"a:tint,omitempty"`
Shade *XValAttrElement `xml:"a:shade,omitempty"`
}
// XGradFill GradFill type
type XGradFill struct {
RotWithShape string `xml:"rotWithShape,attr"`
GsLst *XGsLst `xml:"a:gsLst"`
Lin *XLin `xml:"a:lin"`
}
// XGsLst GsLst type
type XGsLst struct {
Gs []*XGs `xml:"a:gs"`
}
// XGs Gs type
type XGs struct {
Pos string `xml:"pos,attr"`
SchemeClr *XSchemeClr `xml:"a:schemeClr"`
}
// XLin Lin type
type XLin struct {
Ang string `xml:"ang,attr"`
Scaled string `xml:"scaled,attr"`
}
// XLnStyleLst LnStyleLst type
type XLnStyleLst struct {
Ln []*XLn `xml:"a:ln"`
}
// XLn Ln type
type XLn struct {
W string `xml:"w,attr"`
Cap string `xml:"cap,attr"`
Cmpd string `xml:"cmpd,attr"`
Algn string `xml:"algn,attr"`
SolidFill *XSolidFill `xml:"a:solidFill"`
PrstDash *XValAttrElement `xml:"a:prstDash"`
Miter *XMiter `xml:"a:miter"`
}
// XMiter Miter type
type XMiter struct {
Lim string `xml:"lim,attr"`
}
// XEffectStyleLst EffectStyleLst type
type XEffectStyleLst struct {
EffectStyle []*XEffectStyle `xml:"a:effectStyle"`
}
// XEffectStyle EffectStyle type
type XEffectStyle struct {
EffectLst *XEffectLst `xml:"a:effectLst"`
}
// XEffectLst EffectLst type
type XEffectLst struct {
OuterShdw *XOuterShdw `xml:"a:outerShdw"`
}
// XOuterShdw OuterShdw type
type XOuterShdw struct {
BlurRad string `xml:"blurRad,attr"`
Dist string `xml:"dist,attr"`
Dir string `xml:"dir,attr"`
Algn string `xml:"algn,attr"`
RotWithShape string `xml:"rotWithShape,attr"`
SrgbClr *XSrgbClr `xml:"a:srgbClr"`
}
// XBgFillStyleLst BgFillStyleLst type
type XBgFillStyleLst struct {
SolidFill []*XSolidFill `xml:"a:solidFill"`
GradFill *XGradFill `xml:"a:gradFill"`
}
// XObjectDefaults ObjectDefaults type
type XObjectDefaults struct {
}
// XExtraClrSchemeLst ExtraClrSchemeLst type
type XExtraClrSchemeLst struct {
}
// XExtLst ExtLst type
type XExtLst struct {
Ext *XExt `xml:"a:ext"`
}
// XExt Ext type
type XExt struct {
URI string `xml:"uri,attr"`
ThemeFamily *XThemeFamily `xml:"thm15:themeFamily"`
}
// XThemeFamily ThemeFamily type
type XThemeFamily struct {
XmlnsThm15 string `xml:"xmlns:thm15,attr"`
Name string `xml:"name,attr"`
ID string `xml:"id,attr"`
Vid string `xml:"vid,attr"`
}
// NewDefaultXTheme create *XTheme with default template
func NewDefaultXTheme() *XTheme {
return &XTheme{
XmlnsA: "http://schemas.openxmlformats.org/drawingml/2006/main",
Name: "Office Theme",
ThemeElements: &XThemeElements{
ClrScheme: &XClrScheme{
Name: "Office",
Dk1: &XSysClrElement{
SysClr: &XSysClr{
Val: "windowText",
LastClr: "000000",
},
},
Lt1: &XSysClrElement{
SysClr: &XSysClr{
Val: "window",
LastClr: "FFFFFF",
},
},
Dk2: &XSrgbClrElement{
SrgbClr: &XSrgbClr{
Val: "44546A",
},
},
Lt2: &XSrgbClrElement{
SrgbClr: &XSrgbClr{
Val: "E7E6E6",
},
},
Accent1: &XSrgbClrElement{
SrgbClr: &XSrgbClr{
Val: "5B9BD5",
},
},
Accent2: &XSrgbClrElement{
SrgbClr: &XSrgbClr{
Val: "ED7D31",
},
},
Accent3: &XSrgbClrElement{
SrgbClr: &XSrgbClr{
Val: "A5A5A5",
},
},
Accent4: &XSrgbClrElement{
SrgbClr: &XSrgbClr{
Val: "FFC000",
},
},
Accent5: &XSrgbClrElement{
SrgbClr: &XSrgbClr{
Val: "4472C4",
},
},
Accent6: &XSrgbClrElement{
SrgbClr: &XSrgbClr{
Val: "70AD47",
},
},
Hlink: &XSrgbClrElement{
SrgbClr: &XSrgbClr{
Val: "0563C1",
},
},
FolHlink: &XSrgbClrElement{
SrgbClr: &XSrgbClr{
Val: "954F72",
},
},
},
FontScheme: &XFontScheme{
Name: "Office",
MajorFont: &XFontElement{
Latin: &XLatin{Typeface: "Calibri Light", Panose: "020F0302020204030204"},
Ea: &XTypeface{Typeface: ""},
Cs: &XTypeface{Typeface: ""},
Font: []*XThemeFont{
{Script: "Jpan", Typeface: "Yu Gothic Light"},
{Script: "Hang", Typeface: "맑은 고딕"},
{Script: "Hans", Typeface: "等线 Light"},
{Script: "Hant", Typeface: "新細明體"},
{Script: "Arab", Typeface: "Times New Roman"},
{Script: "Hebr", Typeface: "Times New Roman"},
{Script: "Thai", Typeface: "Tahoma"},
{Script: "Ethi", Typeface: "Nyala"},
{Script: "Beng", Typeface: "Vrinda"},
{Script: "Gujr", Typeface: "Shruti"},
{Script: "Khmr", Typeface: "MoolBoran"},
{Script: "Knda", Typeface: "Tunga"},
{Script: "Guru", Typeface: "Raavi"},
{Script: "Cans", Typeface: "Euphemia"},
{Script: "Cher", Typeface: "Plantagenet Cherokee"},
{Script: "Yiii", Typeface: "Microsoft Yi Baiti"},
{Script: "Tibt", Typeface: "Microsoft Himalaya"},
{Script: "Thaa", Typeface: "MV Boli"},
{Script: "Deva", Typeface: "Mangal"},
{Script: "Telu", Typeface: "Gautami"},
{Script: "Taml", Typeface: "Latha"},
{Script: "Syrc", Typeface: "Estrangelo Edessa"},
{Script: "Orya", Typeface: "Kalinga"},
{Script: "Mlym", Typeface: "Kartika"},
{Script: "Laoo", Typeface: "DokChampa"},
{Script: "Sinh", Typeface: "Iskoola Pota"},
{Script: "Mong", Typeface: "Mongolian Baiti"},
{Script: "Viet", Typeface: "Times New Roman"},
{Script: "Uigh", Typeface: "Microsoft Uighur"},
{Script: "Geor", Typeface: "Sylfaen"},
},
},
MinorFont: &XFontElement{
Latin: &XLatin{Typeface: "Calibri", Panose: "020F0502020204030204"},
Ea: &XTypeface{Typeface: ""},
Cs: &XTypeface{Typeface: ""},
Font: []*XThemeFont{
{Script: "Jpan", Typeface: "Yu Gothic"},
{Script: "Hang", Typeface: "맑은 고딕"},
{Script: "Hans", Typeface: "等线"},
{Script: "Hant", Typeface: "新細明體"},
{Script: "Arab", Typeface: "Arial"},
{Script: "Hebr", Typeface: "Arial"},
{Script: "Thai", Typeface: "Tahoma"},
{Script: "Ethi", Typeface: "Nyala"},
{Script: "Beng", Typeface: "Vrinda"},
{Script: "Gujr", Typeface: "Shruti"},
{Script: "Khmr", Typeface: "DaunPenh"},
{Script: "Knda", Typeface: "Tunga"},
{Script: "Guru", Typeface: "Raavi"},
{Script: "Cans", Typeface: "Euphemia"},
{Script: "Cher", Typeface: "Plantagenet Cherokee"},
{Script: "Yiii", Typeface: "Microsoft Yi Baiti"},
{Script: "Tibt", Typeface: "Microsoft Himalaya"},
{Script: "Thaa", Typeface: "MV Boli"},
{Script: "Deva", Typeface: "Mangal"},
{Script: "Telu", Typeface: "Gautami"},
{Script: "Taml", Typeface: "Latha"},
{Script: "Syrc", Typeface: "Estrangelo Edessa"},
{Script: "Orya", Typeface: "Kalinga"},
{Script: "Mlym", Typeface: "Kartika"},
{Script: "Laoo", Typeface: "DokChampa"},
{Script: "Sinh", Typeface: "Iskoola Pota"},
{Script: "Mong", Typeface: "Mongolian Baiti"},
{Script: "Viet", Typeface: "Arial"},
{Script: "Uigh", Typeface: "Microsoft Uighur"},
{Script: "Geor", Typeface: "Sylfaen"},
},
},
},
FmtScheme: &XFmtScheme{
Name: "Office",
FillStyleLst: &XFillStyleLst{
SolidFill: &XSolidFill{
SchemeClr: &XSchemeClr{Val: "phClr"},
},
GradFill: []*XGradFill{
{
RotWithShape: "1",
GsLst: &XGsLst{
Gs: []*XGs{
{
Pos: "0",
SchemeClr: &XSchemeClr{
Val: "phClr",
LumMod: &XValAttrElement{Val: "110000"},
SatMod: &XValAttrElement{Val: "105000"},
Tint: &XValAttrElement{Val: "67000"},
},
}, {
Pos: "50000",
SchemeClr: &XSchemeClr{
Val: "phClr",
LumMod: &XValAttrElement{Val: "105000"},
SatMod: &XValAttrElement{Val: "103000"},
Tint: &XValAttrElement{Val: "73000"},
},
}, {
Pos: "100000",
SchemeClr: &XSchemeClr{
Val: "phClr",
LumMod: &XValAttrElement{Val: "105000"},
SatMod: &XValAttrElement{Val: "109000"},
Tint: &XValAttrElement{Val: "81000"},
},
},
},
},
Lin: &XLin{Ang: "5400000", Scaled: "0"},
}, {
RotWithShape: "1",
GsLst: &XGsLst{
Gs: []*XGs{
{
Pos: "0",
SchemeClr: &XSchemeClr{
Val: "phClr",
SatMod: &XValAttrElement{Val: "103000"},
LumMod: &XValAttrElement{Val: "102000"},
Tint: &XValAttrElement{Val: "94000"},
},
}, {
Pos: "50000",
SchemeClr: &XSchemeClr{
Val: "phClr",
SatMod: &XValAttrElement{Val: "110000"},
LumMod: &XValAttrElement{Val: "100000"},
Shade: &XValAttrElement{Val: "100000"},
},
}, {
Pos: "100000",
SchemeClr: &XSchemeClr{
Val: "phClr",
LumMod: &XValAttrElement{Val: "99000"},
SatMod: &XValAttrElement{Val: "120000"},
Shade: &XValAttrElement{Val: "78000"},
},
},
},
},
Lin: &XLin{Ang: "5400000", Scaled: "0"},
},
},
},
LnStyleLst: &XLnStyleLst{
Ln: []*XLn{
{
W: "6350",
Cap: "flat",
Cmpd: "sng",
Algn: "ctr",
SolidFill: &XSolidFill{
SchemeClr: &XSchemeClr{
Val: "phClr",
},
},
PrstDash: &XValAttrElement{Val: "solid"},
Miter: &XMiter{Lim: "800000"},
}, {
W: "12700",
Cap: "flat",
Cmpd: "sng",
Algn: "ctr",
SolidFill: &XSolidFill{
SchemeClr: &XSchemeClr{
Val: "phClr",
},
},
PrstDash: &XValAttrElement{Val: "solid"},
Miter: &XMiter{Lim: "800000"},
}, {
W: "19050",
Cap: "flat",
Cmpd: "sng",
Algn: "ctr",
SolidFill: &XSolidFill{
SchemeClr: &XSchemeClr{
Val: "phClr",
},
},
PrstDash: &XValAttrElement{Val: "solid"},
Miter: &XMiter{Lim: "800000"},
},
},
},
EffectStyleLst: &XEffectStyleLst{
EffectStyle: []*XEffectStyle{
{EffectLst: &XEffectLst{}},
{EffectLst: &XEffectLst{}},
{EffectLst: &XEffectLst{
OuterShdw: &XOuterShdw{
BlurRad: "57150",
Dist: "19050",
Dir: "5400000",
Algn: "ctr",
RotWithShape: "0",
SrgbClr: &XSrgbClr{
Val: "000000",
Alpha: &XValAttrElement{Val: "63000"},
},
},
}},
},
},
BgFillStyleLst: &XBgFillStyleLst{
SolidFill: []*XSolidFill{
{
SchemeClr: &XSchemeClr{
Val: "phClr",
},
},
{
SchemeClr: &XSchemeClr{
Val: "phClr",
Tint: &XValAttrElement{Val: "95000"},
SatMod: &XValAttrElement{Val: "170000"},
},
},
},
GradFill: &XGradFill{
RotWithShape: "1",
GsLst: &XGsLst{
Gs: []*XGs{
{
Pos: "0",
SchemeClr: &XSchemeClr{
Val: "phClr",
Tint: &XValAttrElement{Val: "93000"},
SatMod: &XValAttrElement{Val: "150000"},
Shade: &XValAttrElement{Val: "98000"},
LumMod: &XValAttrElement{Val: "102000"},
},
}, {
Pos: "50000",
SchemeClr: &XSchemeClr{
Val: "phClr",
Tint: &XValAttrElement{Val: "98000"},
SatMod: &XValAttrElement{Val: "130000"},
Shade: &XValAttrElement{Val: "90000"},
LumMod: &XValAttrElement{Val: "103000"},
},
}, {
Pos: "100000",
SchemeClr: &XSchemeClr{
Val: "phClr",
Shade: &XValAttrElement{Val: "63000"},
SatMod: &XValAttrElement{Val: "120000"},
},
},
},
},
Lin: &XLin{Ang: "5400000", Scaled: "0"},
},
},
},
},
ObjectDefaults: &XObjectDefaults{},
ExtraClrSchemeLst: &XExtraClrSchemeLst{},
ExtLst: &XExtLst{
Ext: &XExt{
URI: "{05A4C25C-085E-4340-85A3-A5531E510DB2}",
ThemeFamily: &XThemeFamily{
XmlnsThm15: "http://schemas.microsoft.com/office/thememl/2012/main",
Name: "Office Theme",
ID: "{62F939B6-93AF-4DB8-9C6B-D6C7DFDC589F}",
Vid: "{4A3C46E8-61CC-4603-A589-7422A47A8E4A}",
},
},
},
}
}