tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / include / svtools / htmltokn.h
blob89d8ee868535ad9ef83a6818e32f19c820728ee5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <svtools/svtdllapi.h>
23 #include <sal/types.h>
24 #include <stdexcept>
25 #include <string_view>
27 namespace rtl {
28 class OUString;
30 enum class HtmlOptionId;
31 enum class HtmlTokenId : sal_Int16;
33 // search the char for the CharName
34 sal_Unicode GetHTMLCharName( std::u16string_view rName );
36 // search the TokenID for the token
37 SVT_DLLPUBLIC HtmlTokenId GetHTMLToken( std::u16string_view rName );
39 // search the TokenId for an attribute token
40 HtmlOptionId GetHTMLOption( std::u16string_view rName );
42 // search the 24-bit color for a color name (not found = SAL_MAX_UINT32)
43 SVT_DLLPUBLIC sal_uInt32 GetHTMLColor( const rtl::OUString& rName );
45 enum class HtmlTokenId : sal_Int16
47 INVALID = -1,
48 NONE = 0,
49 // always starting from 256 on, greater than a char
50 TEXTTOKEN = 0x100,
51 SINGLECHAR,
52 NEWPARA,
53 TABCHAR,
54 RAWDATA,
55 LINEFEEDCHAR,
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>
75 // tokens recognised using HTML character
76 NONBREAKSPACE,
77 SOFTHYPH,
79 // these will be turned back off,
80 // the off value is always located behind (+1) !!
81 ONOFF_START,
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
86 ADDRESS_ON,
87 ADDRESS_OFF,
88 ANCHOR_ON,
89 ANCHOR_OFF,
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
104 BLOCKQUOTE_ON,
105 BLOCKQUOTE_OFF,
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
114 CITATION_ON,
115 CITATION_OFF,
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,
126 DEFLIST_ON,
127 DEFLIST_OFF,
128 DELETEDTEXT_ON, // HTML 3.0
129 DELETEDTEXT_OFF, // HTML 3.0
130 DIRLIST_ON,
131 DIRLIST_OFF,
132 DIVISION_ON, // HTML 3.0
133 DIVISION_OFF, // HTML 3.0
134 DT_ON,
135 DT_OFF,
136 EMPHASIS_ON,
137 EMPHASIS_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,
171 ITALIC_OFF,
172 KEYBOARD_ON,
173 KEYBOARD_OFF,
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
182 MENULIST_ON,
183 MENULIST_OFF,
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
198 ORDERLIST_ON,
199 ORDERLIST_OFF,
200 PARABREAK_ON,
201 PARABREAK_OFF,
202 PERSON_ON, // HTML 3.0
203 PERSON_OFF, // HTML 3.0
204 PLAINTEXT_ON, // HTML 3.0
205 PLAINTEXT_OFF, // HTML 3.0
206 PREFORMTXT_ON,
207 PREFORMTXT_OFF,
208 SAMPLE_ON,
209 SAMPLE_OFF,
210 SCRIPT_ON, // HTML 3.2
211 SCRIPT_OFF, // HTML 3.2
212 SELECT_ON,
213 SELECT_OFF,
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,
223 STRONG_OFF,
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
240 TELETYPE_ON,
241 TELETYPE_OFF,
242 TEXTAREA_ON,
243 TEXTAREA_OFF,
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,
250 UNDERLINE_ON,
251 UNDERLINE_OFF,
252 UNORDERLIST_ON,
253 UNORDERLIST_OFF,
254 VARIABLE_ON,
255 VARIABLE_OFF,
257 // obsolete features
258 XMP_ON,
259 XMP_OFF,
260 LISTING_ON,
261 LISTING_OFF,
263 // proposed features
264 DEFINSTANCE_ON,
265 DEFINSTANCE_OFF,
266 STRIKE_ON,
267 STRIKE_OFF,
269 UNKNOWNCONTROL_ON,
270 UNKNOWNCONTROL_OFF,
272 // Microsoft features
273 COMMENT2_ON, // HTML 2.0 ?
274 COMMENT2_OFF, // HTML 2.0 ?
275 MARQUEE_ON,
276 MARQUEE_OFF,
277 PLAINTEXT2_ON, // HTML 2.0 ?
278 PLAINTEXT2_OFF, // HTML 2.0 ?
280 SDFIELD_ON,
281 SDFIELD_OFF
284 constexpr bool isOffToken(HtmlTokenId nToken)
286 return (nToken == HtmlTokenId::NONE || nToken >= HtmlTokenId::ONOFF_START)
287 ? (1 & static_cast<int>(nToken))
288 : throw std::logic_error("Assertion failed!"); // C++11 does not do assert in constexpr
291 constexpr HtmlTokenId getOnToken(HtmlTokenId nToken)
293 return (nToken == HtmlTokenId::NONE || nToken >= HtmlTokenId::ONOFF_START)
294 ? HtmlTokenId(~1 & static_cast<int>(nToken))
295 : throw std::logic_error("Assertion failed!"); // C++11 does not do assert in constexpr
298 // HTML attribute token (=Options)
300 enum class HtmlOptionId
302 // always starting from 256 on, greater than a char
303 BOOL_START = 0x100,
305 // attributes without value
306 CHECKED = BOOL_START,
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,
319 BOOL_END,
321 // attributes with a string as value
322 STRING_START = BOOL_END,
323 ACCEPT = STRING_START,
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 DSVAL,
348 SDNUM, // StarDiv NumberFormat
349 DSNUM,
350 DSFORMULA,
351 SDLIBRARY,
352 SDMODULE,
353 STRING_END,
355 // attributes with an SGML identifier as value
356 SGMLID_START = STRING_END,
357 ID = SGMLID_START,
358 TARGET, // Netscape 2.0
360 SGMLID_END,
362 // attributes with a URI as value
363 URI_START = SGMLID_END,
364 ACTION = URI_START,
365 ARCHIVE,
366 BACKGROUND,
367 CLASSID,
368 CODEBASE, // HotJava
369 DATA,
370 HREF,
371 SCRIPT,
372 SRC,
373 USEMAP, // Netscape 2.0
374 URI_END,
376 // attributes with a color as value (all Netscape)
377 COLOR_START = URI_END,
378 ALINK = COLOR_START,
379 BGCOLOR,
380 BORDERCOLOR, // IExplorer 2.0
381 BORDERCOLORLIGHT, // IExplorer 2.0
382 BORDERCOLORDARK, // IExplorer 2.0
383 COLOR,
384 LINK,
385 TEXT,
386 VLINK,
387 COLOR_END,
389 // attributes with a numeric value
390 NUMBER_START = COLOR_END,
391 BORDER = NUMBER_START,
392 CELLSPACING, // HTML3 Table Model Draft
393 CELLPADDING, // HTML3 Table Model Draft
394 CHAROFF, // HTML3 Table Model Draft
395 COLSPAN,
396 FRAMESPACING, // IExplorer 3.0
397 GUTTER, // Netscape 3.0b5
398 HEIGHT,
399 HSPACE, // Netscape
400 LEFT,
401 LOOP, // IExplorer 2.0
402 MARGINWIDTH, // Netscape 2.0
403 MARGINHEIGHT, // Netscape 2.0
404 MAXLENGTH,
405 ROWSPAN,
406 SCROLLAMOUNT, // IExplorer 2.0
407 SCROLLDELAY, // IExplorer 2.0
408 SPAN, // HTML3 Table Model Draft
409 TABINDEX,
410 VSPACE, // Netscape
411 WIDTH,
412 ZINDEX,
413 NUMBER_END,
415 // attributes with Enum values
416 ENUM_START = NUMBER_END,
417 BEHAVIOR = ENUM_START, // IExplorer 2.0
418 CLEAR,
419 DIR,
420 DIRECTION, // IExplorer 2.0
421 FORMAT,
422 FRAME, // HTML3 Table Model Draft
423 LANG,
424 METHOD,
425 REL,
426 REV,
427 RULES, // HTML3 Table Model Draft
428 SCROLLING, // Netscape 2.0
429 SDREADONLY,
430 SUBTYPE,
431 TYPE,
432 VALIGN,
433 VALUETYPE,
434 WRAP,
435 XML_SPACE,
436 ENUM_END,
438 // attributes with script code as value
439 SCRIPT_START = ENUM_END,
440 ONABORT = SCRIPT_START, // JavaScript
441 ONBLUR, // JavaScript
442 ONCHANGE, // JavaScript
443 ONCLICK, // JavaScript
444 ONERROR, // JavaScript
445 ONFOCUS, // JavaScript
446 ONLOAD, // JavaScript
447 ONMOUSEOUT, // JavaScript
448 ONMOUSEOVER, // JavaScript
449 ONRESET, // JavaScript
450 ONSELECT, // JavaScript
451 ONSUBMIT, // JavaScript
452 ONUNLOAD, // JavaScript
454 SDONABORT, // StarBasic
455 SDONBLUR, // StarBasic
456 SDONCHANGE, // StarBasic
457 SDONCLICK, // StarBasic
458 SDONERROR, // StarBasic
459 SDONFOCUS, // StarBasic
460 SDONLOAD, // StarBasic
461 SDONMOUSEOUT, // StarBasic
462 SDONMOUSEOVER, // StarBasic
463 SDONRESET, // StarBasic
464 SDONSELECT, // StarBasic
465 SDONSUBMIT, // StarBasic
466 SDONUNLOAD, // StarBasic
467 SCRIPT_END,
469 // attributes with context dependent values
470 CONTEXT_START = SCRIPT_END,
471 ALIGN = CONTEXT_START,
472 COLS, // Netscape 2.0 vs HTML 2.0
473 ROWS, // Netscape 2.0 vs HTML 2.0
474 SIZE,
475 START,
476 CONTEXT_END,
478 // an unknown option
479 UNKNOWN = CONTEXT_END,
483 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */