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 .
22 #include <svtools/svtdllapi.h>
23 #include <sal/types.h>
25 #include <string_view>
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
49 // always starting from 256 on, greater than a char
57 // these will only be turned on
62 DUMMY
, // so ONOFF_START is even
64 EMBED
, // Netscape 2.0 ignore </EMBED>
65 HORZRULE
, // ignore </HR>
66 IMAGE
, // ignore </IMG>
67 INPUT
, // ignore </INPUT>
68 LINEBREAK
, // </BR> -> <BR>
70 META
, // HTML 3.0 ignore </META>
71 OPTION
, // ignore </OPTION>
73 SPACER
, // Netscape 3.0b5 // ignore </SPACER>
75 // tokens recognised using HTML character
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
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
110 CAPTION_ON
, // HTML 3.0
111 CAPTION_OFF
, // HTML 3.0
112 CENTER_ON
, // Netscape
113 CENTER_OFF
, // Netscape
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
128 DELETEDTEXT_ON
, // HTML 3.0
129 DELETEDTEXT_OFF
, // HTML 3.0
132 DIVISION_ON
, // HTML 3.0
133 DIVISION_OFF
, // HTML 3.0
138 FIGURE_ON
, // HTML 3.0
139 FIGURE_OFF
, // HTML 3.0
141 FONT_OFF
, // Netscape
142 FOOTNOTE_ON
, // HTML 3.0
143 FOOTNOTE_OFF
, // HTML 3.0
146 FRAME_ON
, // Netscape 2.0
147 FRAME_OFF
, // Netscape 2.0
148 FRAMESET_ON
, // Netscape 2.0
149 FRAMESET_OFF
, // Netscape 2.0
166 IFRAME_ON
, // IE 3.0b2
167 IFRAME_OFF
, // IE 3.0b2
168 INSERTEDTEXT_ON
, // HTML 3.0
169 INSERTEDTEXT_OFF
, // HTML 3.0
174 LANGUAGE_ON
, // HTML 3.0
175 LANGUAGE_OFF
, // HTML 3.0
176 LISTHEADER_ON
, // HTML 3.0
177 LISTHEADER_OFF
, // HTML 3.0
180 MAP_ON
, // Netscape 2.0
181 MAP_OFF
, // Netscape 2.0
184 MULTICOL_ON
, // Netscape 3.0b5
185 MULTICOL_OFF
, // Netscape 3.0b5
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
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
210 SCRIPT_ON
, // HTML 3.2
211 SCRIPT_OFF
, // HTML 3.2
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
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
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 ?
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
305 // attributes without value
306 CHECKED
= BOOL_START
,
308 DECLARE
, // IExplorer 3.0b5
311 MAYSCRIPT
, // Netscape 3.0
314 NORESIZE
, // Netscape 2.0
321 // attributes with a string as value
322 STRING_START
= BOOL_END
,
323 ACCEPT
= STRING_START
,
327 CHAR
, // HTML3 Table Model Draft
333 COORDS
, // Netscape 2.0
335 FACE
, // IExplorer 2.0
336 FRAMEBORDER
, // IExplorer 3.0
338 LANGUAGE
, // JavaScript
343 STYLE
, // Style Sheets
346 SDVAL
, // StarDiv NumberValue
348 SDNUM
, // StarDiv NumberFormat
355 // attributes with an SGML identifier as value
356 SGMLID_START
= STRING_END
,
358 TARGET
, // Netscape 2.0
362 // attributes with a URI as value
363 URI_START
= SGMLID_END
,
373 USEMAP
, // Netscape 2.0
376 // attributes with a color as value (all Netscape)
377 COLOR_START
= URI_END
,
380 BORDERCOLOR
, // IExplorer 2.0
381 BORDERCOLORLIGHT
, // IExplorer 2.0
382 BORDERCOLORDARK
, // IExplorer 2.0
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
396 FRAMESPACING
, // IExplorer 3.0
397 GUTTER
, // Netscape 3.0b5
401 LOOP
, // IExplorer 2.0
402 MARGINWIDTH
, // Netscape 2.0
403 MARGINHEIGHT
, // Netscape 2.0
406 SCROLLAMOUNT
, // IExplorer 2.0
407 SCROLLDELAY
, // IExplorer 2.0
408 SPAN
, // HTML3 Table Model Draft
415 // attributes with Enum values
416 ENUM_START
= NUMBER_END
,
417 BEHAVIOR
= ENUM_START
, // IExplorer 2.0
420 DIRECTION
, // IExplorer 2.0
422 FRAME
, // HTML3 Table Model Draft
427 RULES
, // HTML3 Table Model Draft
428 SCROLLING
, // Netscape 2.0
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
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
479 UNKNOWN
= CONTEXT_END
,
483 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */