rust_xlsxwriter/
theme.rs

1// theme - A module for creating the Excel Theme.xml file.
2//
3// SPDX-License-Identifier: MIT OR Apache-2.0
4//
5// Copyright 2022-2025, John McNamara, jmcnamara@cpan.org
6
7mod tests;
8
9use std::io::Cursor;
10
11use crate::xmlwriter::xml_theme;
12
13pub struct Theme {
14    pub(crate) writer: Cursor<Vec<u8>>,
15}
16
17impl Theme {
18    // Create a new Theme struct.
19    pub(crate) fn new() -> Theme {
20        let writer = Cursor::new(Vec::with_capacity(2048));
21
22        Theme { writer }
23    }
24
25    // Assemble and generate the XML file.
26    #[allow(clippy::too_many_lines)]
27    pub(crate) fn assemble_xml_file(&mut self) {
28        xml_theme(&mut self.writer,
29            "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n\
30             <a:theme xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" name=\"Office Theme\">\
31             <a:themeElements>\
32             <a:clrScheme name=\"Office\"><a:dk1>\
33             <a:sysClr val=\"windowText\" lastClr=\"000000\"/>\
34             </a:dk1><a:lt1>\
35             <a:sysClr val=\"window\" lastClr=\"FFFFFF\"/></a:lt1><a:dk2>\
36             <a:srgbClr val=\"1F497D\"/></a:dk2><a:lt2>\
37             <a:srgbClr val=\"EEECE1\"/></a:lt2><a:accent1>\
38             <a:srgbClr val=\"4F81BD\"/></a:accent1><a:accent2>\
39             <a:srgbClr val=\"C0504D\"/></a:accent2><a:accent3>\
40             <a:srgbClr val=\"9BBB59\"/></a:accent3><a:accent4>\
41             <a:srgbClr val=\"8064A2\"/></a:accent4><a:accent5>\
42             <a:srgbClr val=\"4BACC6\"/></a:accent5><a:accent6>\
43             <a:srgbClr val=\"F79646\"/></a:accent6><a:hlink>\
44             <a:srgbClr val=\"0000FF\"/></a:hlink><a:folHlink>\
45             <a:srgbClr val=\"800080\"/></a:folHlink></a:clrScheme>\
46             <a:fontScheme name=\"Office\"><a:majorFont>\
47             <a:latin typeface=\"Cambria\"/><a:ea typeface=\"\"/>\
48             <a:cs typeface=\"\"/>\
49             <a:font script=\"Jpan\" typeface=\"MS Pゴシック\"/>\
50             <a:font script=\"Hang\" typeface=\"맑은 고딕\"/>\
51             <a:font script=\"Hans\" typeface=\"宋体\"/>\
52             <a:font script=\"Hant\" typeface=\"新細明體\"/>\
53             <a:font script=\"Arab\" typeface=\"Times New Roman\"/>\
54             <a:font script=\"Hebr\" typeface=\"Times New Roman\"/>\
55             <a:font script=\"Thai\" typeface=\"Tahoma\"/>\
56             <a:font script=\"Ethi\" typeface=\"Nyala\"/>\
57             <a:font script=\"Beng\" typeface=\"Vrinda\"/>\
58             <a:font script=\"Gujr\" typeface=\"Shruti\"/>\
59             <a:font script=\"Khmr\" typeface=\"MoolBoran\"/>\
60             <a:font script=\"Knda\" typeface=\"Tunga\"/>\
61             <a:font script=\"Guru\" typeface=\"Raavi\"/>\
62             <a:font script=\"Cans\" typeface=\"Euphemia\"/>\
63             <a:font script=\"Cher\" typeface=\"Plantagenet Cherokee\"/>\
64             <a:font script=\"Yiii\" typeface=\"Microsoft Yi Baiti\"/>\
65             <a:font script=\"Tibt\" typeface=\"Microsoft Himalaya\"/>\
66             <a:font script=\"Thaa\" typeface=\"MV Boli\"/>\
67             <a:font script=\"Deva\" typeface=\"Mangal\"/>\
68             <a:font script=\"Telu\" typeface=\"Gautami\"/>\
69             <a:font script=\"Taml\" typeface=\"Latha\"/>\
70             <a:font script=\"Syrc\" typeface=\"Estrangelo Edessa\"/>\
71             <a:font script=\"Orya\" typeface=\"Kalinga\"/>\
72             <a:font script=\"Mlym\" typeface=\"Kartika\"/>\
73             <a:font script=\"Laoo\" typeface=\"DokChampa\"/>\
74             <a:font script=\"Sinh\" typeface=\"Iskoola Pota\"/>\
75             <a:font script=\"Mong\" typeface=\"Mongolian Baiti\"/>\
76             <a:font script=\"Viet\" typeface=\"Times New Roman\"/>\
77             <a:font script=\"Uigh\" typeface=\"Microsoft Uighur\"/>\
78             </a:majorFont>\
79             <a:minorFont>\
80             <a:latin typeface=\"Calibri\"/>\
81             <a:ea typeface=\"\"/>\
82             <a:cs typeface=\"\"/>\
83             <a:font script=\"Jpan\" typeface=\"MS Pゴシック\"/>\
84             <a:font script=\"Hang\" typeface=\"맑은 고딕\"/>\
85             <a:font script=\"Hans\" typeface=\"宋体\"/>\
86             <a:font script=\"Hant\" typeface=\"新細明體\"/>\
87             <a:font script=\"Arab\" typeface=\"Arial\"/>\
88             <a:font script=\"Hebr\" typeface=\"Arial\"/>\
89             <a:font script=\"Thai\" typeface=\"Tahoma\"/>\
90             <a:font script=\"Ethi\" typeface=\"Nyala\"/>\
91             <a:font script=\"Beng\" typeface=\"Vrinda\"/>\
92             <a:font script=\"Gujr\" typeface=\"Shruti\"/>\
93             <a:font script=\"Khmr\" typeface=\"DaunPenh\"/>\
94             <a:font script=\"Knda\" typeface=\"Tunga\"/>\
95             <a:font script=\"Guru\" typeface=\"Raavi\"/>\
96             <a:font script=\"Cans\" typeface=\"Euphemia\"/>\
97             <a:font script=\"Cher\" typeface=\"Plantagenet Cherokee\"/>\
98             <a:font script=\"Yiii\" typeface=\"Microsoft Yi Baiti\"/>\
99             <a:font script=\"Tibt\" typeface=\"Microsoft Himalaya\"/>\
100             <a:font script=\"Thaa\" typeface=\"MV Boli\"/>\
101             <a:font script=\"Deva\" typeface=\"Mangal\"/>\
102             <a:font script=\"Telu\" typeface=\"Gautami\"/>\
103             <a:font script=\"Taml\" typeface=\"Latha\"/>\
104             <a:font script=\"Syrc\" typeface=\"Estrangelo Edessa\"/>\
105             <a:font script=\"Orya\" typeface=\"Kalinga\"/>\
106             <a:font script=\"Mlym\" typeface=\"Kartika\"/>\
107             <a:font script=\"Laoo\" typeface=\"DokChampa\"/>\
108             <a:font script=\"Sinh\" typeface=\"Iskoola Pota\"/>\
109             <a:font script=\"Mong\" typeface=\"Mongolian Baiti\"/>\
110             <a:font script=\"Viet\" typeface=\"Arial\"/>\
111             <a:font script=\"Uigh\" typeface=\"Microsoft Uighur\"/>\
112             </a:minorFont>\
113             </a:fontScheme><a:fmtScheme name=\"Office\">\
114             <a:fillStyleLst>\
115             <a:solidFill>\
116             <a:schemeClr val=\"phClr\"/>\
117             </a:solidFill>\
118             <a:gradFill rotWithShape=\"1\">\
119             <a:gsLst>\
120             <a:gs pos=\"0\">\
121             <a:schemeClr val=\"phClr\">\
122             <a:tint val=\"50000\"/>\
123             <a:satMod val=\"300000\"/>\
124             </a:schemeClr>\
125             </a:gs>\
126             <a:gs pos=\"35000\">\
127             <a:schemeClr val=\"phClr\">\
128             <a:tint val=\"37000\"/>\
129             <a:satMod val=\"300000\"/>\
130             </a:schemeClr>\
131             </a:gs>\
132             <a:gs pos=\"100000\">\
133             <a:schemeClr val=\"phClr\">\
134             <a:tint val=\"15000\"/>\
135             <a:satMod val=\"350000\"/>\
136             </a:schemeClr>\
137             </a:gs>\
138             </a:gsLst>\
139             <a:lin ang=\"16200000\" scaled=\"1\"/>\
140             </a:gradFill>\
141             <a:gradFill rotWithShape=\"1\">\
142             <a:gsLst>\
143             <a:gs pos=\"0\">\
144             <a:schemeClr val=\"phClr\">\
145             <a:shade val=\"51000\"/>\
146             <a:satMod val=\"130000\"/>\
147             </a:schemeClr>\
148             </a:gs>\
149             <a:gs pos=\"80000\">\
150             <a:schemeClr val=\"phClr\">\
151             <a:shade val=\"93000\"/>\
152             <a:satMod val=\"130000\"/>\
153             </a:schemeClr>\
154             </a:gs>\
155             <a:gs pos=\"100000\">\
156             <a:schemeClr val=\"phClr\">\
157             <a:shade val=\"94000\"/>\
158             <a:satMod val=\"135000\"/>\
159             </a:schemeClr>\
160             </a:gs>\
161             </a:gsLst>\
162             <a:lin ang=\"16200000\" scaled=\"0\"/>\
163             </a:gradFill>\
164             </a:fillStyleLst>\
165             <a:lnStyleLst>\
166             <a:ln w=\"9525\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">\
167             <a:solidFill>\
168             <a:schemeClr val=\"phClr\">\
169             <a:shade val=\"95000\"/>\
170             <a:satMod val=\"105000\"/>\
171             </a:schemeClr>\
172             </a:solidFill>\
173             <a:prstDash val=\"solid\"/>\
174             </a:ln>\
175             <a:ln w=\"25400\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">\
176             <a:solidFill>\
177             <a:schemeClr val=\"phClr\"/>\
178             </a:solidFill>\
179             <a:prstDash val=\"solid\"/>\
180             </a:ln>\
181             <a:ln w=\"38100\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">\
182             <a:solidFill>\
183             <a:schemeClr val=\"phClr\"/>\
184             </a:solidFill>\
185             <a:prstDash val=\"solid\"/>\
186             </a:ln>\
187             </a:lnStyleLst>\
188             <a:effectStyleLst>\
189             <a:effectStyle>\
190             <a:effectLst>\
191             <a:outerShdw blurRad=\"40000\" dist=\"20000\" \
192             dir=\"5400000\" rotWithShape=\"0\">\
193             <a:srgbClr val=\"000000\">\
194             <a:alpha val=\"38000\"/>\
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:effectStyle>\
209             <a:effectStyle>\
210             <a:effectLst>\
211             <a:outerShdw blurRad=\"40000\" dist=\"23000\" \
212             dir=\"5400000\" rotWithShape=\"0\">\
213             <a:srgbClr val=\"000000\">\
214             <a:alpha val=\"35000\"/>\
215             </a:srgbClr>\
216             </a:outerShdw>\
217             </a:effectLst>\
218             <a:scene3d>\
219             <a:camera prst=\"orthographicFront\">\
220             <a:rot lat=\"0\" lon=\"0\" rev=\"0\"/>\
221             </a:camera>\
222             <a:lightRig rig=\"threePt\" dir=\"t\">\
223             <a:rot lat=\"0\" lon=\"0\" rev=\"1200000\"/>\
224             </a:lightRig>\
225             </a:scene3d>\
226             <a:sp3d>\
227             <a:bevelT w=\"63500\" h=\"25400\"/>\
228             </a:sp3d>\
229             </a:effectStyle>\
230             </a:effectStyleLst>\
231             <a:bgFillStyleLst>\
232             <a:solidFill>\
233             <a:schemeClr val=\"phClr\"/>\
234             </a:solidFill>\
235             <a:gradFill rotWithShape=\"1\">\
236             <a:gsLst>\
237             <a:gs pos=\"0\">\
238             <a:schemeClr val=\"phClr\">\
239             <a:tint val=\"40000\"/>\
240             <a:satMod val=\"350000\"/>\
241             </a:schemeClr>\
242             </a:gs>\
243             <a:gs pos=\"40000\">\
244             <a:schemeClr val=\"phClr\">\
245             <a:tint val=\"45000\"/>\
246             <a:shade val=\"99000\"/>\
247             <a:satMod val=\"350000\"/>\
248             </a:schemeClr>\
249             </a:gs>\
250             <a:gs pos=\"100000\">\
251             <a:schemeClr val=\"phClr\">\
252             <a:shade val=\"20000\"/>\
253             <a:satMod val=\"255000\"/>\
254             </a:schemeClr>\
255             </a:gs>\
256             </a:gsLst>\
257             <a:path path=\"circle\">\
258             <a:fillToRect l=\"50000\" t=\"-80000\" r=\"50000\" b=\"180000\"/>\
259             </a:path>\
260             </a:gradFill>\
261             <a:gradFill rotWithShape=\"1\">\
262             <a:gsLst>\
263             <a:gs pos=\"0\">\
264             <a:schemeClr val=\"phClr\">\
265             <a:tint val=\"80000\"/>\
266             <a:satMod val=\"300000\"/>\
267             </a:schemeClr>\
268             </a:gs>\
269             <a:gs pos=\"100000\">\
270             <a:schemeClr val=\"phClr\">\
271             <a:shade val=\"30000\"/>\
272             <a:satMod val=\"200000\"/>\
273             </a:schemeClr>\
274             </a:gs>\
275             </a:gsLst>\
276             <a:path path=\"circle\">\
277             <a:fillToRect l=\"50000\" t=\"50000\" r=\"50000\" b=\"50000\"/>\
278             </a:path>\
279             </a:gradFill>\
280             </a:bgFillStyleLst>\
281             </a:fmtScheme>\
282             </a:themeElements>\
283             <a:objectDefaults/>\
284             <a:extraClrSchemeLst/>\
285             </a:theme>"
286        );
287    }
288}