1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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
49 // always starting from 256 on, greater than a char
57 // these will only be turned on
62 EMBED
, // Netscape 2.0 ignore </EMBED>
63 HORZRULE
, // ignore </HR>
64 IMAGE
, // ignore </IMG>
65 INPUT
, // ignore </INPUT>
66 LINEBREAK
, // </BR> -> <BR>
68 META
, // HTML 3.0 ignore </META>
69 OPTION
, // ignore </OPTION>
71 SPACER
, // Netscape 3.0b5 // ignore </SPACER>
73 // tokens recognised using HTML character
77 // these will be turned back off,
78 // the off value is always located behind (+1) !!
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
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
99 BLINK_OFF
, // Netscape
100 BLOCKQUOTE30_ON
, // HTML 3.0
101 BLOCKQUOTE30_OFF
, // HTML 3.0
108 CAPTION_ON
, // HTML 3.0
109 CAPTION_OFF
, // HTML 3.0
110 CENTER_ON
, // Netscape
111 CENTER_OFF
, // Netscape
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
126 DELETEDTEXT_ON
, // HTML 3.0
127 DELETEDTEXT_OFF
, // HTML 3.0
130 DIVISION_ON
, // HTML 3.0
131 DIVISION_OFF
, // HTML 3.0
136 FIGURE_ON
, // HTML 3.0
137 FIGURE_OFF
, // HTML 3.0
139 FONT_OFF
, // Netscape
140 FOOTNOTE_ON
, // HTML 3.0
141 FOOTNOTE_OFF
, // HTML 3.0
144 FRAME_ON
, // Netscape 2.0
145 FRAME_OFF
, // Netscape 2.0
146 FRAMESET_ON
, // Netscape 2.0
147 FRAMESET_OFF
, // Netscape 2.0
164 IFRAME_ON
, // IE 3.0b2
165 IFRAME_OFF
, // IE 3.0b2
166 INSERTEDTEXT_ON
, // HTML 3.0
167 INSERTEDTEXT_OFF
, // HTML 3.0
172 LANGUAGE_ON
, // HTML 3.0
173 LANGUAGE_OFF
, // HTML 3.0
174 LISTHEADER_ON
, // HTML 3.0
175 LISTHEADER_OFF
, // HTML 3.0
178 MAP_ON
, // Netscape 2.0
179 MAP_OFF
, // Netscape 2.0
182 MULTICOL_ON
, // Netscape 3.0b5
183 MULTICOL_OFF
, // Netscape 3.0b5
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
193 NOTE_OFF
, // HTML 3.0
194 OBJECT_ON
, // HotJava
195 OBJECT_OFF
, // HotJava
200 PERSON_ON
, // HTML 3.0
201 PERSON_OFF
, // HTML 3.0
202 PLAINTEXT_ON
, // HTML 3.0
203 PLAINTEXT_OFF
, // HTML 3.0
208 SCRIPT_ON
, // HTML 3.2
209 SCRIPT_OFF
, // HTML 3.2
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
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
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
270 // Microsoft features
271 COMMENT2_ON
, // HTML 2.0 ?
272 COMMENT2_OFF
, // HTML 2.0 ?
275 PLAINTEXT2_ON
, // HTML 2.0 ?
276 PLAINTEXT2_OFF
, // HTML 2.0 ?
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
303 // attributes without value
304 CHECKED
= BOOL_START
,
306 DECLARE
, // IExplorer 3.0b5
309 MAYSCRIPT
, // Netscape 3.0
312 NORESIZE
, // Netscape 2.0
319 // attributes with a string as value
320 STRING_START
= BOOL_END
,
321 ACCEPT
= STRING_START
,
325 CHAR
, // HTML3 Table Model Draft
331 COORDS
, // Netscape 2.0
333 FACE
, // IExplorer 2.0
334 FRAMEBORDER
, // IExplorer 3.0
336 LANGUAGE
, // JavaScript
341 STYLE
, // Style Sheets
344 SDVAL
, // StarDiv NumberValue
345 SDNUM
, // StarDiv NumberFormat
350 // attributes with an SGML identifier as value
351 SGMLID_START
= STRING_END
,
353 TARGET
, // Netscape 2.0
357 // attributes with a URI as value
358 URI_START
= SGMLID_END
,
368 USEMAP
, // Netscape 2.0
371 // attributes with a color as value (all Netscape)
372 COLOR_START
= URI_END
,
375 BORDERCOLOR
, // IExplorer 2.0
376 BORDERCOLORLIGHT
, // IExplorer 2.0
377 BORDERCOLORDARK
, // IExplorer 2.0
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
391 FRAMESPACING
, // IExplorer 3.0
392 GUTTER
, // Netscape 3.0b5
396 LOOP
, // IExplorer 2.0
397 MARGINWIDTH
, // Netscape 2.0
398 MARGINHEIGHT
, // Netscape 2.0
401 SCROLLAMOUNT
, // IExplorer 2.0
402 SCROLLDELAY
, // IExplorer 2.0
403 SPAN
, // HTML3 Table Model Draft
410 // attributes with Enum values
411 ENUM_START
= NUMBER_END
,
412 BEHAVIOR
= ENUM_START
, // IExplorer 2.0
415 DIRECTION
, // IExplorer 2.0
417 FRAME
, // HTML3 Table Model Draft
422 RULES
, // HTML3 Table Model Draft
423 SCROLLING
, // Netscape 2.0
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
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
473 UNKNOWN
= CONTEXT_END
,
477 #endif // INCLUDED_SVTOOLS_HTMLTOKN_H
479 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */