LibreOffice Module svtools (master) 1
htmltokn.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <svtools/svtdllapi.h>
23#include <sal/types.h>
24#include <stdexcept>
25#include <string_view>
26
27namespace rtl {
28 class OUString;
29};
30enum class HtmlOptionId;
31enum class HtmlTokenId : sal_Int16;
32
33// search the char for the CharName
34sal_Unicode GetHTMLCharName( std::u16string_view rName );
35
36// search the TokenID for the token
37SVT_DLLPUBLIC HtmlTokenId GetHTMLToken( std::u16string_view rName );
38
39// search the TokenId for an attribute token
40HtmlOptionId GetHTMLOption( std::u16string_view rName );
41
42// search the 24-bit color for a color name (not found = SAL_MAX_UINT32)
43SVT_DLLPUBLIC sal_uInt32 GetHTMLColor( const rtl::OUString& rName );
44
45enum class HtmlTokenId : sal_Int16
46{
47 INVALID = -1,
48 NONE = 0,
49// always starting from 256 on, greater than a char
50 TEXTTOKEN = 0x100,
52 NEWPARA,
53 TABCHAR,
54 RAWDATA,
56
57 // these will only be turned on
58 AREA, // Netscape 2.0
59 BASE, // HTML 3.0
60 COMMENT,
61 CDATA,
62 DUMMY, // so ONOFF_START is even
63 DOCTYPE,
64 EMBED, // Netscape 2.0 ignore </EMBED>
65 HORZRULE, // ignore </HR>
66 IMAGE, // ignore </IMG>
67 INPUT, // ignore </INPUT>
68 LINEBREAK, // </BR> -> <BR>
69 LINK, // HTML 3.0
70 META, // HTML 3.0 ignore </META>
71 OPTION, // ignore </OPTION>
72 PARAM, // HotJava
73 SPACER, // Netscape 3.0b5 // ignore </SPACER>
74
75 // tokens recognised using HTML character
78
79 // these will be turned back off,
80 // the off value is always located behind (+1) !!
82 ABBREVIATION_ON = ONOFF_START, // HTML 3.0
83 ABBREVIATION_OFF, // HTML 3.0
84 ACRONYM_ON, // HTML 3.0
85 ACRONYM_OFF, // HTML 3.0
90 APPLET_ON, // HotJava
91 APPLET_OFF, // HotJava
92 AUTHOR_ON, // HTML 3.0
93 AUTHOR_OFF, // HTML 3.0
94 BANNER_ON, // HTML 3.0
95 BANNER_OFF, // HTML 3.0
96 BASEFONT_ON, // Netscape
97 BASEFONT_OFF, // Netscape
98 BIGPRINT_ON, // HTML 3.0
99 BIGPRINT_OFF, // HTML 3.0
100 BLINK_ON, // Netscape
101 BLINK_OFF, // Netscape
102 BLOCKQUOTE30_ON, // HTML 3.0
103 BLOCKQUOTE30_OFF, // HTML 3.0
106 BODY_ON,
107 BODY_OFF,
108 BOLD_ON,
109 BOLD_OFF,
110 CAPTION_ON, // HTML 3.0
111 CAPTION_OFF, // HTML 3.0
112 CENTER_ON, // Netscape
113 CENTER_OFF, // Netscape
116 CODE_ON,
117 CODE_OFF,
118 COL_ON, // HTML3 Table Model Draft
119 COL_OFF, // HTML3 Table Model Draft
120 COLGROUP_ON, // HTML3 Table Model Draft
121 COLGROUP_OFF, // HTML3 Table Model Draft
122 CREDIT_ON, // HTML 3.0
123 CREDIT_OFF, // HTML 3.0
124 DD_ON,
125 DD_OFF,
128 DELETEDTEXT_ON, // HTML 3.0
129 DELETEDTEXT_OFF, // HTML 3.0
132 DIVISION_ON, // HTML 3.0
133 DIVISION_OFF, // HTML 3.0
134 DT_ON,
135 DT_OFF,
138 FIGURE_ON, // HTML 3.0
139 FIGURE_OFF, // HTML 3.0
140 FONT_ON, // Netscape
141 FONT_OFF, // Netscape
142 FOOTNOTE_ON, // HTML 3.0
143 FOOTNOTE_OFF, // HTML 3.0
144 FORM_ON,
145 FORM_OFF,
146 FRAME_ON, // Netscape 2.0
147 FRAME_OFF, // Netscape 2.0
148 FRAMESET_ON, // Netscape 2.0
149 FRAMESET_OFF, // Netscape 2.0
150 HEAD1_ON,
151 HEAD1_OFF,
152 HEAD2_ON,
153 HEAD2_OFF,
154 HEAD3_ON,
155 HEAD3_OFF,
156 HEAD4_ON,
157 HEAD4_OFF,
158 HEAD5_ON,
159 HEAD5_OFF,
160 HEAD6_ON,
161 HEAD6_OFF,
162 HEAD_ON,
163 HEAD_OFF,
164 HTML_ON,
165 HTML_OFF,
166 IFRAME_ON, // IE 3.0b2
167 IFRAME_OFF, // IE 3.0b2
168 INSERTEDTEXT_ON, // HTML 3.0
169 INSERTEDTEXT_OFF, // HTML 3.0
170 ITALIC_ON,
174 LANGUAGE_ON, // HTML 3.0
175 LANGUAGE_OFF, // HTML 3.0
176 LISTHEADER_ON, // HTML 3.0
177 LISTHEADER_OFF, // HTML 3.0
178 LI_ON,
179 LI_OFF,
180 MAP_ON, // Netscape 2.0
181 MAP_OFF, // Netscape 2.0
184 MULTICOL_ON, // Netscape 3.0b5
185 MULTICOL_OFF, // Netscape 3.0b5
186 NOBR_ON, // Netscape
187 NOBR_OFF, // Netscape
188 NOEMBED_ON, // Netscape 2.0
189 NOEMBED_OFF, // Netscape 2.0
190 NOFRAMES_ON, // Netscape 2.0
191 NOFRAMES_OFF, // Netscape 2.0
192 NOSCRIPT_ON, // Netscape 2.0
193 NOSCRIPT_OFF, // Netscape 3.0
194 NOTE_ON, // HTML 3.0
195 NOTE_OFF, // HTML 3.0
196 OBJECT_ON, // HotJava
197 OBJECT_OFF, // HotJava
202 PERSON_ON, // HTML 3.0
203 PERSON_OFF, // HTML 3.0
204 PLAINTEXT_ON, // HTML 3.0
205 PLAINTEXT_OFF, // HTML 3.0
208 SAMPLE_ON,
210 SCRIPT_ON, // HTML 3.2
211 SCRIPT_OFF, // HTML 3.2
212 SELECT_ON,
214 SHORTQUOTE_ON, // HTML 3.0
215 SHORTQUOTE_OFF, // HTML 3.0
216 SMALLPRINT_ON, // HTML 3.0
217 SMALLPRINT_OFF, // HTML 3.0
218 SPAN_ON, // Style Sheets
219 SPAN_OFF, // Style Sheets
220 STRIKETHROUGH_ON, // HTML 3.0
221 STRIKETHROUGH_OFF, // HTML 3.0
222 STRONG_ON,
224 STYLE_ON, // HTML 3.0
225 STYLE_OFF, // HTML 3.0
226 SUBSCRIPT_ON, // HTML 3.0
227 SUBSCRIPT_OFF, // HTML 3.0
228 SUPERSCRIPT_ON, // HTML 3.0
229 SUPERSCRIPT_OFF, // HTML 3.0
230 TABLE_ON, // HTML 3.0
231 TABLE_OFF, // HTML 3.0
232 TABLEDATA_ON, // HTML 3.0
233 TABLEDATA_OFF, // HTML 3.0
234 TABLEHEADER_ON, // HTML 3.0
235 TABLEHEADER_OFF, // HTML 3.0
236 TABLEROW_ON, // HTML 3.0
237 TABLEROW_OFF, // HTML 3.0
238 TBODY_ON, // HTML3 Table Model Draft
239 TBODY_OFF, // HTML3 Table Model Draft
244 TFOOT_ON, // HTML3 Table Model Draft
245 TFOOT_OFF, // HTML3 Table Model Draft
246 THEAD_ON, // HTML3 Table Model Draft
247 THEAD_OFF, // HTML3 Table Model Draft
248 TITLE_ON,
249 TITLE_OFF,
256
257 // obsolete features
258 XMP_ON,
259 XMP_OFF,
262
263 // proposed features
266 STRIKE_ON,
268
271
272 // Microsoft features
273 COMMENT2_ON, // HTML 2.0 ?
274 COMMENT2_OFF, // HTML 2.0 ?
277 PLAINTEXT2_ON, // HTML 2.0 ?
278 PLAINTEXT2_OFF, // HTML 2.0 ?
279
282};
283
284constexpr bool isOffToken(HtmlTokenId nToken)
285{
287 ? (1 & static_cast<int>(nToken))
288 : throw std::logic_error("Assertion failed!"); // C++11 does not do assert in constexpr
289}
290
292{
294 ? HtmlTokenId(~1 & static_cast<int>(nToken))
295 : throw std::logic_error("Assertion failed!"); // C++11 does not do assert in constexpr
296}
297
298// HTML attribute token (=Options)
299
300enum class HtmlOptionId
301{
302// always starting from 256 on, greater than a char
303BOOL_START = 0x100,
304
305// attributes without value
307 COMPACT,
308 DECLARE, // IExplorer 3.0b5
309 DISABLED,
310 ISMAP,
311 MAYSCRIPT, // Netscape 3.0
312 MULTIPLE,
313 NOHREF, // Netscape
314 NORESIZE, // Netscape 2.0
315 NOSHADE, // Netscape
316 NOWRAP,
317 SDFIXED,
318 SELECTED,
320
321// attributes with a string as value
324 ACCESSKEY,
325 ALT,
326 AXIS,
327 CHAR, // HTML3 Table Model Draft
328 CHARSET,
329 CLASS,
330 CODE, // HotJava
331 CODETYPE,
332 CONTENT,
333 COORDS, // Netscape 2.0
334 ENCTYPE,
335 FACE, // IExplorer 2.0
336 FRAMEBORDER, // IExplorer 3.0
337 HTTPEQUIV,
338 LANGUAGE, // JavaScript
339 NAME,
340 PROMPT,
341 SHAPE,
342 STANDBY,
343 STYLE, // Style Sheets
344 TITLE,
345 VALUE,
346 SDVAL, // StarDiv NumberValue
347 SDNUM, // StarDiv NumberFormat
348 SDLIBRARY,
349 SDMODULE,
351
352// attributes with an SGML identifier as value
355 TARGET, // Netscape 2.0
356 TO,
358
359// attributes with a URI as value
362 ARCHIVE,
364 CLASSID,
365 CODEBASE, // HotJava
366 DATA,
367 HREF,
368 SCRIPT,
369 SRC,
370 USEMAP, // Netscape 2.0
371URI_END,
372
373// attributes with a color as value (all Netscape)
376 BGCOLOR,
377 BORDERCOLOR, // IExplorer 2.0
378 BORDERCOLORLIGHT, // IExplorer 2.0
379 BORDERCOLORDARK, // IExplorer 2.0
380 COLOR,
381 LINK,
382 TEXT,
383 VLINK,
385
386// attributes with a numeric value
389 CELLSPACING, // HTML3 Table Model Draft
390 CELLPADDING, // HTML3 Table Model Draft
391 CHAROFF, // HTML3 Table Model Draft
392 COLSPAN,
393 FRAMESPACING, // IExplorer 3.0
394 GUTTER, // Netscape 3.0b5
395 HEIGHT,
396 HSPACE, // Netscape
397 LEFT,
398 LOOP, // IExplorer 2.0
399 MARGINWIDTH, // Netscape 2.0
400 MARGINHEIGHT, // Netscape 2.0
401 MAXLENGTH,
402 ROWSPAN,
403 SCROLLAMOUNT, // IExplorer 2.0
404 SCROLLDELAY, // IExplorer 2.0
405 SPAN, // HTML3 Table Model Draft
406 TABINDEX,
407 VSPACE, // Netscape
408 WIDTH,
409 ZINDEX,
411
412// attributes with Enum values
414 BEHAVIOR = ENUM_START, // IExplorer 2.0
415 CLEAR,
416 DIR,
417 DIRECTION, // IExplorer 2.0
418 FORMAT,
419 FRAME, // HTML3 Table Model Draft
420 LANG,
421 METHOD,
422 REL,
423 REV,
424 RULES, // HTML3 Table Model Draft
425 SCROLLING, // Netscape 2.0
427 SUBTYPE,
428 TYPE,
429 VALIGN,
430 VALUETYPE,
431 WRAP,
433
434// attributes with script code as value
436 ONABORT = SCRIPT_START, // JavaScript
437 ONBLUR, // JavaScript
438 ONCHANGE, // JavaScript
439 ONCLICK, // JavaScript
440 ONERROR, // JavaScript
441 ONFOCUS, // JavaScript
442 ONLOAD, // JavaScript
443 ONMOUSEOUT, // JavaScript
444 ONMOUSEOVER, // JavaScript
445 ONRESET, // JavaScript
446 ONSELECT, // JavaScript
447 ONSUBMIT, // JavaScript
448 ONUNLOAD, // JavaScript
449
450 SDONABORT, // StarBasic
451 SDONBLUR, // StarBasic
452 SDONCHANGE, // StarBasic
453 SDONCLICK, // StarBasic
454 SDONERROR, // StarBasic
455 SDONFOCUS, // StarBasic
456 SDONLOAD, // StarBasic
457 SDONMOUSEOUT, // StarBasic
458 SDONMOUSEOVER, // StarBasic
459 SDONRESET, // StarBasic
460 SDONSELECT, // StarBasic
461 SDONSUBMIT, // StarBasic
462 SDONUNLOAD, // StarBasic
464
465// attributes with context dependent values
468 COLS, // Netscape 2.0 vs HTML 2.0
469 ROWS, // Netscape 2.0 vs HTML 2.0
470 SIZE,
471 START,
473
474// an unknown option
476END
477};
478
479/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr OUStringLiteral TITLE
UNKNOWN
constexpr HtmlTokenId getOnToken(HtmlTokenId nToken)
Definition: htmltokn.h:291
sal_Unicode GetHTMLCharName(std::u16string_view rName)
Definition: htmlkywd.cxx:468
HtmlOptionId
Definition: htmltokn.h:301
HtmlOptionId GetHTMLOption(std::u16string_view rName)
Definition: htmlkywd.cxx:640
SVT_DLLPUBLIC HtmlTokenId GetHTMLToken(std::u16string_view rName)
Definition: htmlkywd.cxx:182
HtmlTokenId
Definition: htmltokn.h:46
SVT_DLLPUBLIC sal_uInt32 GetHTMLColor(const rtl::OUString &rName)
constexpr bool isOffToken(HtmlTokenId nToken)
Definition: htmltokn.h:284
COMMENT
NONE
const sal_uInt32 LEFT
const sal_uInt16 WIDTH
END
constexpr tools::Long SIZE
START
FRAME
INVALID
#define HEIGHT
DefTokenId nToken
#define SVT_DLLPUBLIC
Definition: svtdllapi.h:27
LOOP
TEXT
sal_uInt16 sal_Unicode