bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / svtools / htmltokn.h
bloba3374a37e87749e396b804c74173726690aec258
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 #ifndef INCLUDED_SVTOOLS_HTMLTOKN_H
21 #define INCLUDED_SVTOOLS_HTMLTOKN_H
23 #include <svtools/svtdllapi.h>
24 #include <sal/types.h>
25 #include <stdexcept>
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( const rtl::OUString& rName );
36 // search the TokenID for the token
37 SVT_DLLPUBLIC HtmlTokenId GetHTMLToken( const rtl::OUString& rName );
39 // search the TokenId for an attribute token
40 HtmlOptionId GetHTMLOption( const rtl::OUString& rName );
42 // search the 24-bit color for a color name (not found = ULONG_MAX)
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 DOCTYPE,
62 EMBED, // Netscape 2.0 ignore </EMBED>
63 HORZRULE, // ignore </HR>
64 IMAGE, // ignore </IMG>
65 INPUT, // ignore </INPUT>
66 LINEBREAK, // </BR> -> <BR>
67 LINK, // HTML 3.0
68 META, // HTML 3.0 ignore </META>
69 OPTION, // ignore </OPTION>
70 PARAM, // HotJava
71 SPACER, // Netscape 3.0b5 // ignore </SPACER>
73 // tokens recognised using HTML character
74 NONBREAKSPACE,
75 SOFTHYPH,
77 // these will be turned back off,
78 // the off value is always located behind (+1) !!
79 ONOFF_START,
80 ABBREVIATION_ON = ONOFF_START, // HTML 3.0
81 ABBREVIATION_OFF, // HTML 3.0
82 ACRONYM_ON, // HTML 3.0
83 ACRONYM_OFF, // HTML 3.0
84 ADDRESS_ON,
85 ADDRESS_OFF,
86 ANCHOR_ON,
87 ANCHOR_OFF,
88 APPLET_ON, // HotJava
89 APPLET_OFF, // HotJava
90 AUTHOR_ON, // HTML 3.0
91 AUTHOR_OFF, // HTML 3.0
92 BANNER_ON, // HTML 3.0
93 BANNER_OFF, // HTML 3.0
94 BASEFONT_ON, // Netscape
95 BASEFONT_OFF, // Netscape
96 BIGPRINT_ON, // HTML 3.0
97 BIGPRINT_OFF, // HTML 3.0
98 BLINK_ON, // Netscape
99 BLINK_OFF, // Netscape
100 BLOCKQUOTE30_ON, // HTML 3.0
101 BLOCKQUOTE30_OFF, // HTML 3.0
102 BLOCKQUOTE_ON,
103 BLOCKQUOTE_OFF,
104 BODY_ON,
105 BODY_OFF,
106 BOLD_ON,
107 BOLD_OFF,
108 CAPTION_ON, // HTML 3.0
109 CAPTION_OFF, // HTML 3.0
110 CENTER_ON, // Netscape
111 CENTER_OFF, // Netscape
112 CITIATION_ON,
113 CITIATION_OFF,
114 CODE_ON,
115 CODE_OFF,
116 COL_ON, // HTML3 Table Model Draft
117 COL_OFF, // HTML3 Table Model Draft
118 COLGROUP_ON, // HTML3 Table Model Draft
119 COLGROUP_OFF, // HTML3 Table Model Draft
120 CREDIT_ON, // HTML 3.0
121 CREDIT_OFF, // HTML 3.0
122 DD_ON,
123 DD_OFF,
124 DEFLIST_ON,
125 DEFLIST_OFF,
126 DELETEDTEXT_ON, // HTML 3.0
127 DELETEDTEXT_OFF, // HTML 3.0
128 DIRLIST_ON,
129 DIRLIST_OFF,
130 DIVISION_ON, // HTML 3.0
131 DIVISION_OFF, // HTML 3.0
132 DT_ON,
133 DT_OFF,
134 EMPHASIS_ON,
135 EMPHASIS_OFF,
136 FIGURE_ON, // HTML 3.0
137 FIGURE_OFF, // HTML 3.0
138 FONT_ON, // Netscape
139 FONT_OFF, // Netscape
140 FOOTNOTE_ON, // HTML 3.0
141 FOOTNOTE_OFF, // HTML 3.0
142 FORM_ON,
143 FORM_OFF,
144 FRAME_ON, // Netscape 2.0
145 FRAME_OFF, // Netscape 2.0
146 FRAMESET_ON, // Netscape 2.0
147 FRAMESET_OFF, // Netscape 2.0
148 HEAD1_ON,
149 HEAD1_OFF,
150 HEAD2_ON,
151 HEAD2_OFF,
152 HEAD3_ON,
153 HEAD3_OFF,
154 HEAD4_ON,
155 HEAD4_OFF,
156 HEAD5_ON,
157 HEAD5_OFF,
158 HEAD6_ON,
159 HEAD6_OFF,
160 HEAD_ON,
161 HEAD_OFF,
162 HTML_ON,
163 HTML_OFF,
164 IFRAME_ON, // IE 3.0b2
165 IFRAME_OFF, // IE 3.0b2
166 INSERTEDTEXT_ON, // HTML 3.0
167 INSERTEDTEXT_OFF, // HTML 3.0
168 ITALIC_ON,
169 ITALIC_OFF,
170 KEYBOARD_ON,
171 KEYBOARD_OFF,
172 LANGUAGE_ON, // HTML 3.0
173 LANGUAGE_OFF, // HTML 3.0
174 LISTHEADER_ON, // HTML 3.0
175 LISTHEADER_OFF, // HTML 3.0
176 LI_ON,
177 LI_OFF,
178 MAP_ON, // Netscape 2.0
179 MAP_OFF, // Netscape 2.0
180 MENULIST_ON,
181 MENULIST_OFF,
182 MULTICOL_ON, // Netscape 3.0b5
183 MULTICOL_OFF, // Netscape 3.0b5
184 NOBR_ON, // Netscape
185 NOBR_OFF, // Netscape
186 NOEMBED_ON, // Netscape 2.0
187 NOEMBED_OFF, // Netscape 2.0
188 NOFRAMES_ON, // Netscape 2.0
189 NOFRAMES_OFF, // Netscape 2.0
190 NOSCRIPT_ON, // Netscape 2.0
191 NOSCRIPT_OFF, // Netscape 3.0
192 NOTE_ON, // HTML 3.0
193 NOTE_OFF, // HTML 3.0
194 OBJECT_ON, // HotJava
195 OBJECT_OFF, // HotJava
196 ORDERLIST_ON,
197 ORDERLIST_OFF,
198 PARABREAK_ON,
199 PARABREAK_OFF,
200 PERSON_ON, // HTML 3.0
201 PERSON_OFF, // HTML 3.0
202 PLAINTEXT_ON, // HTML 3.0
203 PLAINTEXT_OFF, // HTML 3.0
204 PREFORMTXT_ON,
205 PREFORMTXT_OFF,
206 SAMPLE_ON,
207 SAMPLE_OFF,
208 SCRIPT_ON, // HTML 3.2
209 SCRIPT_OFF, // HTML 3.2
210 SELECT_ON,
211 SELECT_OFF,
212 SHORTQUOTE_ON, // HTML 3.0
213 SHORTQUOTE_OFF, // HTML 3.0
214 SMALLPRINT_ON, // HTML 3.0
215 SMALLPRINT_OFF, // HTML 3.0
216 SPAN_ON, // Style Sheets
217 SPAN_OFF, // Style Sheets
218 STRIKETHROUGH_ON, // HTML 3.0
219 STRIKETHROUGH_OFF, // HTML 3.0
220 STRONG_ON,
221 STRONG_OFF,
222 STYLE_ON, // HTML 3.0
223 STYLE_OFF, // HTML 3.0
224 SUBSCRIPT_ON, // HTML 3.0
225 SUBSCRIPT_OFF, // HTML 3.0
226 SUPERSCRIPT_ON, // HTML 3.0
227 SUPERSCRIPT_OFF, // HTML 3.0
228 TABLE_ON, // HTML 3.0
229 TABLE_OFF, // HTML 3.0
230 TABLEDATA_ON, // HTML 3.0
231 TABLEDATA_OFF, // HTML 3.0
232 TABLEHEADER_ON, // HTML 3.0
233 TABLEHEADER_OFF, // HTML 3.0
234 TABLEROW_ON, // HTML 3.0
235 TABLEROW_OFF, // HTML 3.0
236 TBODY_ON, // HTML3 Table Model Draft
237 TBODY_OFF, // HTML3 Table Model Draft
238 TELETYPE_ON,
239 TELETYPE_OFF,
240 TEXTAREA_ON,
241 TEXTAREA_OFF,
242 TFOOT_ON, // HTML3 Table Model Draft
243 TFOOT_OFF, // HTML3 Table Model Draft
244 THEAD_ON, // HTML3 Table Model Draft
245 THEAD_OFF, // HTML3 Table Model Draft
246 TITLE_ON,
247 TITLE_OFF,
248 UNDERLINE_ON,
249 UNDERLINE_OFF,
250 UNORDERLIST_ON,
251 UNORDERLIST_OFF,
252 VARIABLE_ON,
253 VARIABLE_OFF,
255 // obsolete features
256 XMP_ON,
257 XMP_OFF,
258 LISTING_ON,
259 LISTING_OFF,
261 // proposed features
262 DEFINSTANCE_ON,
263 DEFINSTANCE_OFF,
264 STRIKE_ON,
265 STRIKE_OFF,
267 UNKNOWNCONTROL_ON,
268 UNKNOWNCONTROL_OFF,
270 // Microsoft features
271 COMMENT2_ON, // HTML 2.0 ?
272 COMMENT2_OFF, // HTML 2.0 ?
273 MARQUEE_ON,
274 MARQUEE_OFF,
275 PLAINTEXT2_ON, // HTML 2.0 ?
276 PLAINTEXT2_OFF, // HTML 2.0 ?
278 SDFIELD_ON,
279 SDFIELD_OFF
282 constexpr bool isOffToken(HtmlTokenId nToken)
284 return (nToken == HtmlTokenId::NONE || nToken >= HtmlTokenId::ONOFF_START)
285 ? (1 & static_cast<int>(nToken))
286 : throw std::logic_error("Assertion failed!"); // C++11 does not do assert in constexpr
289 constexpr HtmlTokenId getOnToken(HtmlTokenId nToken)
291 return (nToken == HtmlTokenId::NONE || nToken >= HtmlTokenId::ONOFF_START)
292 ? HtmlTokenId(~1 & static_cast<int>(nToken))
293 : throw std::logic_error("Assertion failed!"); // C++11 does not do assert in constexpr
296 // HTML attribute token (=Options)
298 enum class HtmlOptionId
300 // always starting from 256 on, greater than a char
301 BOOL_START = 0x100,
303 // attributes without value
304 CHECKED = BOOL_START,
305 COMPACT,
306 DECLARE, // IExplorer 3.0b5
307 DISABLED,
308 ISMAP,
309 MAYSCRIPT, // Netscape 3.0
310 MULTIPLE,
311 NOHREF, // Netscape
312 NORESIZE, // Netscape 2.0
313 NOSHADE, // Netscape
314 NOWRAP,
315 SDFIXED,
316 SELECTED,
317 BOOL_END,
319 // attributes with a string as value
320 STRING_START = BOOL_END,
321 ACCEPT = STRING_START,
322 ACCESSKEY,
323 ALT,
324 AXIS,
325 CHAR, // HTML3 Table Model Draft
326 CHARSET,
327 CLASS,
328 CODE, // HotJava
329 CODETYPE,
330 CONTENT,
331 COORDS, // Netscape 2.0
332 ENCTYPE,
333 FACE, // IExplorer 2.0
334 FRAMEBORDER, // IExplorer 3.0
335 HTTPEQUIV,
336 LANGUAGE, // JavaScript
337 NAME,
338 PROMPT,
339 SHAPE,
340 STANDBY,
341 STYLE, // Style Sheets
342 TITLE,
343 VALUE,
344 SDVAL, // StarDiv NumberValue
345 SDNUM, // StarDiv NumberFormat
346 SDLIBRARY,
347 SDMODULE,
348 STRING_END,
350 // attributes with an SGML identifier as value
351 SGMLID_START = STRING_END,
352 ID = SGMLID_START,
353 TARGET, // Netscape 2.0
355 SGMLID_END,
357 // attributes with a URI as value
358 URI_START = SGMLID_END,
359 ACTION = URI_START,
360 ARCHIVE,
361 BACKGROUND,
362 CLASSID,
363 CODEBASE, // HotJava
364 DATA,
365 HREF,
366 SCRIPT,
367 SRC,
368 USEMAP, // Netscape 2.0
369 URI_END,
371 // attributes with a color as value (all Netscape)
372 COLOR_START = URI_END,
373 ALINK = COLOR_START,
374 BGCOLOR,
375 BORDERCOLOR, // IExplorer 2.0
376 BORDERCOLORLIGHT, // IExplorer 2.0
377 BORDERCOLORDARK, // IExplorer 2.0
378 COLOR,
379 LINK,
380 TEXT,
381 VLINK,
382 COLOR_END,
384 // attributes with a numeric value
385 NUMBER_START = COLOR_END,
386 BORDER = NUMBER_START,
387 CELLSPACING, // HTML3 Table Model Draft
388 CELLPADDING, // HTML3 Table Model Draft
389 CHAROFF, // HTML3 Table Model Draft
390 COLSPAN,
391 FRAMESPACING, // IExplorer 3.0
392 GUTTER, // Netscape 3.0b5
393 HEIGHT,
394 HSPACE, // Netscape
395 LEFT,
396 LOOP, // IExplorer 2.0
397 MARGINWIDTH, // Netscape 2.0
398 MARGINHEIGHT, // Netscape 2.0
399 MAXLENGTH,
400 ROWSPAN,
401 SCROLLAMOUNT, // IExplorer 2.0
402 SCROLLDELAY, // IExplorer 2.0
403 SPAN, // HTML3 Table Model Draft
404 TABINDEX,
405 VSPACE, // Netscape
406 WIDTH,
407 ZINDEX,
408 NUMBER_END,
410 // attributes with Enum values
411 ENUM_START = NUMBER_END,
412 BEHAVIOR = ENUM_START, // IExplorer 2.0
413 CLEAR,
414 DIR,
415 DIRECTION, // IExplorer 2.0
416 FORMAT,
417 FRAME, // HTML3 Table Model Draft
418 LANG,
419 METHOD,
420 REL,
421 REV,
422 RULES, // HTML3 Table Model Draft
423 SCROLLING, // Netscape 2.0
424 SDREADONLY,
425 SUBTYPE,
426 TYPE,
427 VALIGN,
428 VALUETYPE,
429 WRAP,
430 ENUM_END,
432 // attributes with script code as value
433 SCRIPT_START = ENUM_END,
434 ONABORT = SCRIPT_START, // JavaScript
435 ONBLUR, // JavaScript
436 ONCHANGE, // JavaScript
437 ONCLICK, // JavaScript
438 ONERROR, // JavaScript
439 ONFOCUS, // JavaScript
440 ONLOAD, // JavaScript
441 ONMOUSEOUT, // JavaScript
442 ONMOUSEOVER, // JavaScript
443 ONRESET, // JavaScript
444 ONSELECT, // JavaScript
445 ONSUBMIT, // JavaScript
446 ONUNLOAD, // JavaScript
448 SDONABORT, // StarBasic
449 SDONBLUR, // StarBasic
450 SDONCHANGE, // StarBasic
451 SDONCLICK, // StarBasic
452 SDONERROR, // StarBasic
453 SDONFOCUS, // StarBasic
454 SDONLOAD, // StarBasic
455 SDONMOUSEOUT, // StarBasic
456 SDONMOUSEOVER, // StarBasic
457 SDONRESET, // StarBasic
458 SDONSELECT, // StarBasic
459 SDONSUBMIT, // StarBasic
460 SDONUNLOAD, // StarBasic
461 SCRIPT_END,
463 // attributes with context dependent values
464 CONTEXT_START = SCRIPT_END,
465 ALIGN = CONTEXT_START,
466 COLS, // Netscape 2.0 vs HTML 2.0
467 ROWS, // Netscape 2.0 vs HTML 2.0
468 SIZE,
469 START,
470 CONTEXT_END,
472 // an unknown option
473 UNKNOWN = CONTEXT_END,
477 #endif // INCLUDED_SVTOOLS_HTMLTOKN_H
479 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */