Line data Source code
1 : /* File: document_css_writer.c; Copyright and License: see below */
2 :
3 : #include "document/document_css_writer.h"
4 : #include "utf8stringbuf/utf8string.h"
5 : #include "u8/u8_trace.h"
6 : #include "u8/u8_log.h"
7 : #include <stdbool.h>
8 : #include <assert.h>
9 :
10 : /* IO_FILE_FORMAT_CSS */
11 :
12 : static const char CSS_ALL[]
13 : ="body {\n"
14 : " background-color: rgb(255,255,255);\n"
15 : " font-family: Helvetica,Arial,sans-serif;\n"
16 : "}\n"
17 : "article {\n"
18 : " margin-left: 200px;\n"
19 : " padding-top: 8px;\n"
20 : " padding-right: 8px;\n"
21 : " padding-bottom: 8px;\n"
22 : " padding-left: 24px;\n"
23 : "}\n"
24 : "nav {\n"
25 : " background-color: rgb(240,248,255);\n"
26 : " left: 0px;\n"
27 : " top: 0px;\n"
28 : " width: 200px;\n"
29 : " height: 100%;\n"
30 : " position: fixed;\n"
31 : " overflow: auto;\n"
32 : " padding: 2px;\n"
33 : " margin: 0px;\n"
34 : "}\n"
35 : "a:hover {\n"
36 : " background-color: rgb(255,255,255);\n"
37 : "}\n"
38 : ".toc {\n"
39 : " list-style-type: none;\n"
40 : " list-style-position: inside;\n"
41 : " padding: 0px;\n"
42 : " margin: 0px;\n"
43 : "}\n"
44 : ".toc1 {\n"
45 : " padding-left: 0px;\n"
46 : " padding-top: 3px;\n"
47 : " padding-right: 0px;\n"
48 : " padding-bottom: 3px;\n"
49 : " color: rgb(192,128,0);\n"
50 : " font-size: small;\n"
51 : " counter-reset: cnt-head-two;\n"
52 : "}\n"
53 : ".toc2::before {\n"
54 : " counter-increment: cnt-head-two;\n"
55 : " content: counter(cnt-head-two) \"\\0000a0 \";\n"
56 : "}\n"
57 : ".toc2 {\n"
58 : " padding-left: 8px;\n"
59 : " padding-top: 2px;\n"
60 : " padding-right: 0px;\n"
61 : " padding-bottom: 2px;\n"
62 : " color: rgb(192,128,0);\n"
63 : " font-size: small;\n"
64 : " counter-reset: cnt-head-three;\n"
65 : "}\n"
66 : ".toc3::before {\n"
67 : " counter-increment: cnt-head-three;\n"
68 : " content: counter(cnt-head-two) \".\" counter(cnt-head-three) \"\\0000a0 \";\n"
69 : "}\n"
70 : ".toc3 {\n"
71 : " padding-left: 8px;\n"
72 : " padding-top: 2px;\n"
73 : " padding-right: 0px;\n"
74 : " padding-bottom: 1px;\n"
75 : " color: rgb(192,128,0);\n"
76 : " font-size: x-small;\n"
77 : " counter-reset: cnt-head-four;\n"
78 : "}\n"
79 : ".toc4::before {\n"
80 : " counter-increment: cnt-head-four;\n"
81 : " content: counter(cnt-head-two) \".\" counter(cnt-head-three) \".\" counter(cnt-head-four) \"\\0000a0 \";\n"
82 : "}\n"
83 : ".toc4 {\n"
84 : " padding-left: 8px;\n"
85 : " padding-top: 1px;\n"
86 : " padding-right: 0px;\n"
87 : " padding-bottom: 1px;\n"
88 : " border-left: 2px solid #FFFFFF;\n"
89 : " color: rgb(192,128,0);\n"
90 : " font-size: xx-small;\n"
91 : " counter-reset: cnt-head-five;\n"
92 : "}\n"
93 : ".toc5::before {\n"
94 : " counter-increment: cnt-head-five;\n"
95 : " content: counter(cnt-head-two) \".\" counter(cnt-head-three) \".\" counter(cnt-head-four) \".\" counter(cnt-head-five) \"\\0000a0 \";\n"
96 : "}\n"
97 : ".toc5 {\n"
98 : " padding-left: 8px;\n"
99 : " padding-top: 1px;\n"
100 : " padding-right: 0px;\n"
101 : " padding-bottom: 0px;\n"
102 : " color: rgb(192,128,0);\n"
103 : " font-size: xx-small;\n"
104 : " counter-reset: cnt-head-six;\n"
105 : "}\n"
106 : ".toc6::before {\n"
107 : " counter-increment: cnt-head-six;\n"
108 : " content: counter(cnt-head-two) \".\" counter(cnt-head-three) \".\" counter(cnt-head-four) \".\" counter(cnt-head-five) \".\" counter(cnt-head-six) \"\\0000a0 \";\n"
109 : "}\n"
110 : ".toc6 {\n"
111 : " padding-left: 8px;\n"
112 : " color: rgb(192,128,0);\n"
113 : " font-size: xx-small;\n"
114 : "}\n"
115 : ".diag-title {\n"
116 : " color: rgb(192,128,0);\n"
117 : "}\n"
118 : ".diag-stereo::before {\n"
119 : " content:\"\\0000a0 \\0000ab\";\n"
120 : "}\n"
121 : ".diag-stereo {\n"
122 : " color: rgb(80,80,80);\n"
123 : "}\n"
124 : ".diag-stereo::after {\n"
125 : " content: \"\\0000bb\";\n"
126 : "}\n"
127 : ".diag-name {\n"
128 : " color: rgb(128,128,128);\n"
129 : "}\n"
130 : ".diag-type::before {\n"
131 : " content:\"\\0000a0 \\0000a0 {type=\";\n"
132 : "}\n"
133 : ".diag-type {\n"
134 : " color: rgb(160,160,160);\n"
135 : "}\n"
136 : ".diag-type::after {\n"
137 : " content: \"}\";\n"
138 : "}\n"
139 : ".diag-id::before {\n"
140 : " content:\"\\0000a0 \\0000a0 {id=\";\n"
141 : "}\n"
142 : ".diag-id {\n"
143 : " color: rgb(160,160,160);\n"
144 : "}\n"
145 : ".diag-id::after {\n"
146 : " content: \"}\";\n"
147 : "}\n"
148 : ".diag-descr {\n"
149 : " padding: 16px 8px;\n"
150 : " margin-left: 2px;\n"
151 : " margin-right: 2px;\n"
152 : " margin-top: 2px;\n"
153 : " margin-bottom: 12px;\n"
154 : " border: 1px solid #DDAA88;\n"
155 : "}\n"
156 : ".clas {\n"
157 : " margin-top: 8px;\n"
158 : " border-top: 1px solid #CCCCCC;\n"
159 : " border-right: 1px solid #CCCCCC;\n"
160 : " border-bottom: 1px solid #CCCCCC;\n"
161 : "}\n"
162 : ".clas-stereo::before {\n"
163 : " content:\"\\0000a0 \\0000ab\";\n"
164 : "}\n"
165 : ".clas-stereo {\n"
166 : " color: rgb(80,80,80);\n"
167 : "}\n"
168 : ".clas-stereo::after {\n"
169 : " content: \"\\0000bb\";\n"
170 : "}\n"
171 : ".clas-name {\n"
172 : " color: rgb(192,128,0);\n"
173 : "}\n"
174 : ".clas-type::before {\n"
175 : " content:\"\\0000a0 \\0000a0 {type=\";\n"
176 : "}\n"
177 : ".clas-type {\n"
178 : " color: rgb(160,160,160);\n"
179 : "}\n"
180 : ".clas-type::after {\n"
181 : " content: \"}\";\n"
182 : "}\n"
183 : ".clas-id::before {\n"
184 : " content:\"\\0000a0 \\0000a0 {id=\";\n"
185 : "}\n"
186 : ".clas-id {\n"
187 : " color: rgb(160,160,160);\n"
188 : "}\n"
189 : ".clas-id::after {\n"
190 : " content: \"}\";\n"
191 : "}\n"
192 : ".clas-see::before {\n"
193 : " content:\"appears in \";\n"
194 : "}\n"
195 : ".clas-see {\n"
196 : " background-color: rgb(240,240,240);\n"
197 : " text-align: right;\n"
198 : " font-size: x-small;\n"
199 : " color: rgb(160,160,160);\n"
200 : "}\n"
201 : ".clas-descr {\n"
202 : " padding: 16px 8px;\n"
203 : " margin: 2px;\n"
204 : " border: 1px solid #CCCCCC;\n"
205 : "}\n"
206 : ".feat {\n"
207 : " font-size: small;\n"
208 : " margin-left: 32px;\n"
209 : " margin-right: 0px;\n"
210 : "}\n"
211 : ".feat-stereo::before {\n"
212 : " content:\"\\0000a0 \\0000ab\";\n"
213 : "}\n"
214 : ".feat-stereo {\n"
215 : " color: rgb(80,80,80);\n"
216 : "}\n"
217 : ".feat-stereo::after {\n"
218 : " content: \"\\0000bb\";\n"
219 : "}\n"
220 : /* ".feat-name {\n" */
221 : /* " color: rgb(0,0,0);\n" */
222 : /* "}\n" */
223 : ".feat-type::before {\n"
224 : " content:\"\\0000a0 \\0000a0 {type=\";\n"
225 : "}\n"
226 : ".feat-type {\n"
227 : " color: rgb(160,160,160);\n"
228 : "}\n"
229 : ".feat-type::after {\n"
230 : " content: \"}\";\n"
231 : "}\n"
232 : ".feat-id::before {\n"
233 : " content: \"\\0000a0 \\0000a0 {id=\";\n"
234 : "}\n"
235 : ".feat-id {\n"
236 : " color: rgb(160,160,160);\n"
237 : "}\n"
238 : ".feat-id::after {\n"
239 : " content :\"}\";\n"
240 : "}\n"
241 : ".feat-descr {\n"
242 : " padding: 8px 8px;\n"
243 : " margin: 2px;\n"
244 : " border: 1px solid #CCCCCC;\n"
245 : "}\n"
246 : ".rel {\n"
247 : " font-size: small;\n"
248 : " margin-left: 32px;\n"
249 : " margin-right: 0px;\n"
250 : "}\n"
251 : ".rel-stereo::before {\n"
252 : " content:\"\\0000a0 \\0000ab\";\n"
253 : "}\n"
254 : ".rel-stereo {\n"
255 : " color: rgb(80,80,80);\n"
256 : "}\n"
257 : ".rel-stereo::after {\n"
258 : " content: \"\\0000bb\";\n"
259 : "}\n"
260 : /* ".rel-name {\n" */
261 : /* " color: rgb(0,0,0);\n" */
262 : /* "}\n" */
263 : /* ".rel-dest {\n" */
264 : /* " color: rgb(0,0,0);\n" */
265 : /* "}\n" */
266 : ".rel-type::before {\n"
267 : " content:\"\\0000a0 \\0000a0 {type=\";\n"
268 : "}\n"
269 : ".rel-type {\n"
270 : " color: rgb(160,160,160);\n"
271 : "}\n"
272 : ".rel-type::after {\n"
273 : " content: \"}\";\n"
274 : "}\n"
275 : ".rel-id::before {\n"
276 : " content: \"\\0000a0 \\0000a0 {id=\";\n"
277 : "}\n"
278 : ".rel-id {\n"
279 : " color: rgb(160,160,160);\n"
280 : "}\n"
281 : ".rel-id::after {\n"
282 : " content: \"}\";\n"
283 : "}\n"
284 : ".rel-descr {\n"
285 : " padding: 8px 8px;\n"
286 : " margin: 2px;\n"
287 : " border: 1px solid #CCCCCC;\n"
288 : "}\n"
289 : "h1 {\n"
290 : " counter-reset: cnt-head-two;\n"
291 : "}\n"
292 : "h2::before {\n"
293 : " counter-increment: cnt-head-two;\n"
294 : " content: counter(cnt-head-two) \"\\0000a0 \";\n"
295 : "}\n"
296 : "h2 {\n"
297 : " counter-reset: cnt-head-three;\n"
298 : "}\n"
299 : "h3::before {\n"
300 : " counter-increment: cnt-head-three;\n"
301 : " content: counter(cnt-head-two) \".\" counter(cnt-head-three) \"\\0000a0 \";\n"
302 : "}\n"
303 : "h3 {\n"
304 : " counter-reset: cnt-head-four;\n"
305 : "}\n"
306 : "h4::before {\n"
307 : " counter-increment: cnt-head-four;\n"
308 : " content: counter(cnt-head-two) \".\" counter(cnt-head-three) \".\" counter(cnt-head-four) \"\\0000a0 \";\n"
309 : "}\n"
310 : "h4 {\n"
311 : " counter-reset: cnt-head-five;\n"
312 : "}\n"
313 : "h5::before {\n"
314 : " counter-increment: cnt-head-five;\n"
315 : " content: counter(cnt-head-two) \".\" counter(cnt-head-three) \".\" counter(cnt-head-four) \".\" counter(cnt-head-five) \"\\0000a0 \";\n"
316 : "}\n"
317 : "h5 {\n"
318 : " counter-reset: cnt-head-six;\n"
319 : "}\n"
320 : "h6::before {\n"
321 : " counter-increment: cnt-head-six;\n"
322 : " content: counter(cnt-head-two) \".\" counter(cnt-head-three) \".\" counter(cnt-head-four) \".\" counter(cnt-head-five) \".\" counter(cnt-head-six) \"\\0000a0 \";\n"
323 : "}\n"
324 : "p {\n"
325 : " padding: 2px;\n"
326 : " margin: 0px;\n"
327 : "}\n";
328 :
329 0 : void document_css_writer_init ( document_css_writer_t *this_,
330 : universal_output_stream_t *output )
331 : {
332 0 : U8_TRACE_BEGIN();
333 0 : assert( NULL != output );
334 :
335 0 : (*this_).output = output;
336 :
337 0 : U8_TRACE_END();
338 0 : }
339 :
340 0 : void document_css_writer_destroy( document_css_writer_t *this_ )
341 : {
342 0 : U8_TRACE_BEGIN();
343 :
344 0 : (*this_).output = NULL;
345 :
346 0 : U8_TRACE_END();
347 0 : }
348 :
349 0 : u8_error_t document_css_writer_write_stylesheet( document_css_writer_t *this_ )
350 : {
351 0 : U8_TRACE_BEGIN();
352 0 : u8_error_t export_err = U8_ERROR_NONE;
353 :
354 0 : utf8string_t *text = CSS_ALL;
355 0 : const size_t text_len = utf8string_get_length(text);
356 0 : export_err |= universal_output_stream_write( (*this_).output, text, text_len);
357 :
358 0 : U8_TRACE_END_ERR( export_err );
359 0 : return export_err;
360 : }
361 :
362 :
363 : /*
364 : Copyright 2017-2025 Andreas Warnke
365 :
366 : Licensed under the Apache License, Version 2.0 (the "License");
367 : you may not use this file except in compliance with the License.
368 : You may obtain a copy of the License at
369 :
370 : http://www.apache.org/licenses/LICENSE-2.0
371 :
372 : Unless required by applicable law or agreed to in writing, software
373 : distributed under the License is distributed on an "AS IS" BASIS,
374 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
375 : See the License for the specific language governing permissions and
376 : limitations under the License.
377 : */
|