Line data Source code
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 :
21 : #include <limits.h>
22 : #include <sal/types.h>
23 : #include <stdlib.h>
24 : #include <string.h>
25 : #include <rtl/ustring.hxx>
26 : #include <svtools/htmltokn.h>
27 : #include <svtools/htmlkywd.hxx>
28 :
29 : // Table has still to be sorted
30 : struct HTML_TokenEntry
31 : {
32 : union
33 : {
34 : const sal_Char *sToken;
35 : const OUString *pUToken;
36 : };
37 : int nToken;
38 : };
39 :
40 : // Flag: RTF token table has already been sorted
41 : static bool bSortKeyWords = false;
42 :
43 : static HTML_TokenEntry aHTMLTokenTab[] = {
44 : {{OOO_STRING_SVTOOLS_HTML_area}, HTML_AREA}, // Netscape 2.0
45 : {{OOO_STRING_SVTOOLS_HTML_base}, HTML_BASE}, // HTML 3.0
46 : {{OOO_STRING_SVTOOLS_HTML_comment}, HTML_COMMENT},
47 : {{OOO_STRING_SVTOOLS_HTML_doctype}, HTML_DOCTYPE},
48 : {{OOO_STRING_SVTOOLS_HTML_embed}, HTML_EMBED}, // Netscape 2.0
49 : {{OOO_STRING_SVTOOLS_HTML_horzrule}, HTML_HORZRULE},
50 : {{OOO_STRING_SVTOOLS_HTML_image}, HTML_IMAGE},
51 : {{OOO_STRING_SVTOOLS_HTML_input}, HTML_INPUT},
52 : {{OOO_STRING_SVTOOLS_HTML_linebreak}, HTML_LINEBREAK},
53 : {{OOO_STRING_SVTOOLS_HTML_link}, HTML_LINK}, // HTML 3.0
54 : {{OOO_STRING_SVTOOLS_HTML_meta}, HTML_META}, // HTML 3.0
55 : {{OOO_STRING_SVTOOLS_HTML_option}, HTML_OPTION},
56 : {{OOO_STRING_SVTOOLS_HTML_param}, HTML_PARAM}, // HotJava
57 : {{OOO_STRING_SVTOOLS_HTML_spacer}, HTML_SPACER}, // Netscape 3.0b5
58 :
59 : {{OOO_STRING_SVTOOLS_HTML_abbreviation}, HTML_ABBREVIATION_ON}, // HTML 3.0
60 : {{OOO_STRING_SVTOOLS_HTML_acronym}, HTML_ACRONYM_ON}, // HTML 3.0
61 : {{OOO_STRING_SVTOOLS_HTML_address}, HTML_ADDRESS_ON},
62 : {{OOO_STRING_SVTOOLS_HTML_anchor}, HTML_ANCHOR_ON},
63 : {{OOO_STRING_SVTOOLS_HTML_applet}, HTML_APPLET_ON}, // HotJava
64 : {{OOO_STRING_SVTOOLS_HTML_author}, HTML_AUTHOR_ON}, // HTML 3.0
65 : {{OOO_STRING_SVTOOLS_HTML_banner}, HTML_BANNER_ON}, // HTML 3.0
66 : {{OOO_STRING_SVTOOLS_HTML_basefont}, HTML_BASEFONT_ON}, // Netscape
67 : {{OOO_STRING_SVTOOLS_HTML_bigprint}, HTML_BIGPRINT_ON}, // HTML 3.0
68 : {{OOO_STRING_SVTOOLS_HTML_blink}, HTML_BLINK_ON}, // Netscape
69 : {{OOO_STRING_SVTOOLS_HTML_blockquote}, HTML_BLOCKQUOTE_ON},
70 : {{OOO_STRING_SVTOOLS_HTML_blockquote30}, HTML_BLOCKQUOTE30_ON}, // HTML 3.0
71 : {{OOO_STRING_SVTOOLS_HTML_body}, HTML_BODY_ON},
72 : {{OOO_STRING_SVTOOLS_HTML_bold}, HTML_BOLD_ON},
73 : {{OOO_STRING_SVTOOLS_HTML_caption}, HTML_CAPTION_ON}, // HTML 3.0
74 : {{OOO_STRING_SVTOOLS_HTML_center}, HTML_CENTER_ON}, // Netscape
75 : {{OOO_STRING_SVTOOLS_HTML_citiation}, HTML_CITIATION_ON},
76 : {{OOO_STRING_SVTOOLS_HTML_col}, HTML_COL_ON}, // HTML 3 Table Model Draft
77 : {{OOO_STRING_SVTOOLS_HTML_colgroup}, HTML_COLGROUP_ON}, // HTML 3 Table Model Draft
78 : {{OOO_STRING_SVTOOLS_HTML_code}, HTML_CODE_ON},
79 : {{OOO_STRING_SVTOOLS_HTML_credit}, HTML_CREDIT_ON}, // HTML 3.0
80 : {{OOO_STRING_SVTOOLS_HTML_dd}, HTML_DD_ON},
81 : {{OOO_STRING_SVTOOLS_HTML_deflist}, HTML_DEFLIST_ON},
82 : {{OOO_STRING_SVTOOLS_HTML_deletedtext}, HTML_DELETEDTEXT_ON}, // HTML 3.0
83 : {{OOO_STRING_SVTOOLS_HTML_dirlist}, HTML_DIRLIST_ON},
84 : {{OOO_STRING_SVTOOLS_HTML_division}, HTML_DIVISION_ON}, // HTML 3.0
85 : {{OOO_STRING_SVTOOLS_HTML_dt}, HTML_DT_ON},
86 : {{OOO_STRING_SVTOOLS_HTML_emphasis}, HTML_EMPHASIS_ON},
87 : {{OOO_STRING_SVTOOLS_HTML_figure}, HTML_FIGURE_ON}, // HTML 3.0
88 : {{OOO_STRING_SVTOOLS_HTML_font}, HTML_FONT_ON}, // Netscpe
89 : {{OOO_STRING_SVTOOLS_HTML_footnote}, HTML_FOOTNOTE_ON}, // HTML 3.0
90 : {{OOO_STRING_SVTOOLS_HTML_form}, HTML_FORM_ON},
91 : {{OOO_STRING_SVTOOLS_HTML_frame}, HTML_FRAME_ON}, // Netscape 2.0
92 : {{OOO_STRING_SVTOOLS_HTML_frameset}, HTML_FRAMESET_ON}, // Netscape 2.0
93 : {{OOO_STRING_SVTOOLS_HTML_head}, HTML_HEAD_ON},
94 : {{OOO_STRING_SVTOOLS_HTML_head1}, HTML_HEAD1_ON},
95 : {{OOO_STRING_SVTOOLS_HTML_head2}, HTML_HEAD2_ON},
96 : {{OOO_STRING_SVTOOLS_HTML_head3}, HTML_HEAD3_ON},
97 : {{OOO_STRING_SVTOOLS_HTML_head4}, HTML_HEAD4_ON},
98 : {{OOO_STRING_SVTOOLS_HTML_head5}, HTML_HEAD5_ON},
99 : {{OOO_STRING_SVTOOLS_HTML_head6}, HTML_HEAD6_ON},
100 : {{OOO_STRING_SVTOOLS_HTML_html}, HTML_HTML_ON},
101 : {{OOO_STRING_SVTOOLS_HTML_iframe}, HTML_IFRAME_ON}, // IE 3.0b2
102 : {{OOO_STRING_SVTOOLS_HTML_insertedtext}, HTML_INSERTEDTEXT_ON}, // HTML 3.0
103 : {{OOO_STRING_SVTOOLS_HTML_italic}, HTML_ITALIC_ON},
104 : {{OOO_STRING_SVTOOLS_HTML_keyboard}, HTML_KEYBOARD_ON},
105 : {{OOO_STRING_SVTOOLS_HTML_language}, HTML_LANGUAGE_ON}, // HTML 3.0
106 : {{OOO_STRING_SVTOOLS_HTML_li}, HTML_LI_ON},
107 : {{OOO_STRING_SVTOOLS_HTML_listheader}, HTML_LISTHEADER_ON}, // HTML 3.0
108 : {{OOO_STRING_SVTOOLS_HTML_map}, HTML_MAP_ON}, // Netscape 2.0
109 : {{OOO_STRING_SVTOOLS_HTML_menulist}, HTML_MENULIST_ON},
110 : {{OOO_STRING_SVTOOLS_HTML_multicol}, HTML_MULTICOL_ON}, // Netscape 3.0b5
111 : {{OOO_STRING_SVTOOLS_HTML_nobr}, HTML_NOBR_ON}, // Netscape
112 : {{OOO_STRING_SVTOOLS_HTML_noembed}, HTML_NOEMBED_ON}, // Netscape 2.0 ???
113 : {{OOO_STRING_SVTOOLS_HTML_noframe}, HTML_NOFRAMES_ON}, // Netscape 2.0 ???
114 : {{OOO_STRING_SVTOOLS_HTML_noframes}, HTML_NOFRAMES_ON}, // Netscape 2.0
115 : {{OOO_STRING_SVTOOLS_HTML_noscript}, HTML_NOSCRIPT_ON}, // Netscape 3.0
116 : {{OOO_STRING_SVTOOLS_HTML_note}, HTML_NOTE_ON}, // HTML 3.0
117 : {{OOO_STRING_SVTOOLS_HTML_object}, HTML_OBJECT_ON},
118 : {{OOO_STRING_SVTOOLS_HTML_orderlist}, HTML_ORDERLIST_ON},
119 : {{OOO_STRING_SVTOOLS_HTML_parabreak}, HTML_PARABREAK_ON},
120 : {{OOO_STRING_SVTOOLS_HTML_person}, HTML_PERSON_ON}, // HTML 3.0
121 : {{OOO_STRING_SVTOOLS_HTML_plaintext}, HTML_PLAINTEXT_ON}, // HTML 3.0
122 : {{OOO_STRING_SVTOOLS_HTML_preformtxt}, HTML_PREFORMTXT_ON},
123 : {{OOO_STRING_SVTOOLS_HTML_sample}, HTML_SAMPLE_ON},
124 : {{OOO_STRING_SVTOOLS_HTML_script}, HTML_SCRIPT_ON}, // HTML 3.2
125 : {{OOO_STRING_SVTOOLS_HTML_select}, HTML_SELECT_ON},
126 : {{OOO_STRING_SVTOOLS_HTML_shortquote}, HTML_SHORTQUOTE_ON}, // HTML 3.0
127 : {{OOO_STRING_SVTOOLS_HTML_smallprint}, HTML_SMALLPRINT_ON}, // HTML 3.0
128 : {{OOO_STRING_SVTOOLS_HTML_span}, HTML_SPAN_ON}, // Style Sheets
129 : {{OOO_STRING_SVTOOLS_HTML_strikethrough},HTML_STRIKETHROUGH_ON}, // HTML 3.0
130 : {{OOO_STRING_SVTOOLS_HTML_strong}, HTML_STRONG_ON},
131 : {{OOO_STRING_SVTOOLS_HTML_style}, HTML_STYLE_ON}, // HTML 3.0
132 : {{OOO_STRING_SVTOOLS_HTML_subscript}, HTML_SUBSCRIPT_ON}, // HTML 3.0
133 : {{OOO_STRING_SVTOOLS_HTML_superscript}, HTML_SUPERSCRIPT_ON}, // HTML 3.0
134 : {{OOO_STRING_SVTOOLS_HTML_table}, HTML_TABLE_ON}, // HTML 3.0
135 : {{OOO_STRING_SVTOOLS_HTML_tabledata}, HTML_TABLEDATA_ON}, // HTML 3.0
136 : {{OOO_STRING_SVTOOLS_HTML_tableheader}, HTML_TABLEHEADER_ON}, // HTML 3.0
137 : {{OOO_STRING_SVTOOLS_HTML_tablerow}, HTML_TABLEROW_ON}, // HTML 3.0
138 : {{OOO_STRING_SVTOOLS_HTML_tbody}, HTML_TBODY_ON}, // HTML 3 Table Model Draft
139 : {{OOO_STRING_SVTOOLS_HTML_teletype}, HTML_TELETYPE_ON},
140 : {{OOO_STRING_SVTOOLS_HTML_textarea}, HTML_TEXTAREA_ON},
141 : {{OOO_STRING_SVTOOLS_HTML_tfoot}, HTML_TFOOT_ON}, // HTML 3 Table Model Draft
142 : {{OOO_STRING_SVTOOLS_HTML_thead}, HTML_THEAD_ON}, // HTML 3 Table Model Draft
143 : {{OOO_STRING_SVTOOLS_HTML_title}, HTML_TITLE_ON},
144 : {{OOO_STRING_SVTOOLS_HTML_underline}, HTML_UNDERLINE_ON},
145 : {{OOO_STRING_SVTOOLS_HTML_unorderlist}, HTML_UNORDERLIST_ON},
146 : {{OOO_STRING_SVTOOLS_HTML_variable}, HTML_VARIABLE_ON},
147 :
148 : {{OOO_STRING_SVTOOLS_HTML_xmp}, HTML_XMP_ON},
149 : {{OOO_STRING_SVTOOLS_HTML_listing}, HTML_LISTING_ON},
150 :
151 : {{OOO_STRING_SVTOOLS_HTML_definstance}, HTML_DEFINSTANCE_ON},
152 : {{OOO_STRING_SVTOOLS_HTML_strike}, HTML_STRIKE_ON},
153 :
154 : {{OOO_STRING_SVTOOLS_HTML_comment2}, HTML_COMMENT2_ON},
155 : {{OOO_STRING_SVTOOLS_HTML_marquee}, HTML_MARQUEE_ON},
156 : {{OOO_STRING_SVTOOLS_HTML_plaintext2}, HTML_PLAINTEXT2_ON},
157 :
158 : {{OOO_STRING_SVTOOLS_HTML_sdfield}, HTML_SDFIELD_ON}
159 : };
160 :
161 :
162 : extern "C"
163 : {
164 :
165 45480 : static int SAL_CALL HTMLKeyCompare( const void *pFirst, const void *pSecond)
166 : {
167 45480 : HTML_TokenEntry* pFirstEntry = (HTML_TokenEntry*)pFirst;
168 45480 : HTML_TokenEntry* pSecondEntry = (HTML_TokenEntry*)pSecond;
169 45480 : int nRet = 0;
170 45480 : if( -1 == pFirstEntry->nToken )
171 : {
172 34990 : if( -1 == pSecondEntry->nToken )
173 0 : nRet = pFirstEntry->pUToken->compareTo( *pSecondEntry->pUToken );
174 : else
175 34990 : nRet = pFirstEntry->pUToken->compareToAscii( pSecondEntry->sToken );
176 : }
177 : else
178 : {
179 10490 : if( -1 == pSecondEntry->nToken )
180 0 : nRet = -1 * pSecondEntry->pUToken->compareToAscii( pFirstEntry->sToken );
181 : else
182 10490 : nRet = strcmp( pFirstEntry->sToken, pSecondEntry->sToken );
183 : }
184 :
185 45480 : return nRet;
186 : }
187 :
188 : }
189 :
190 3390 : int GetHTMLToken( const OUString& rName )
191 : {
192 3390 : if( !bSortKeyWords )
193 : {
194 : qsort( (void*) aHTMLTokenTab,
195 : sizeof( aHTMLTokenTab ) / sizeof( HTML_TokenEntry ),
196 : sizeof( HTML_TokenEntry ),
197 10 : HTMLKeyCompare );
198 10 : bSortKeyWords = true;
199 : }
200 :
201 3390 : int nRet = 0;
202 :
203 3390 : if( !rName.compareTo( OOO_STRING_SVTOOLS_HTML_comment, 3 ) )
204 0 : return HTML_COMMENT;
205 :
206 : void* pFound;
207 : HTML_TokenEntry aSrch;
208 3390 : aSrch.pUToken = &rName;
209 3390 : aSrch.nToken = -1;
210 :
211 : pFound = bsearch( (sal_Char *) &aSrch,
212 : (void*) aHTMLTokenTab,
213 : sizeof( aHTMLTokenTab ) / sizeof( HTML_TokenEntry ),
214 : sizeof( HTML_TokenEntry ),
215 3390 : HTMLKeyCompare );
216 3390 : if( 0 != pFound )
217 3370 : nRet = ((HTML_TokenEntry*)pFound)->nToken;
218 3390 : return nRet;
219 : }
220 :
221 : struct HTML_CharEntry
222 : {
223 : union
224 : {
225 : const sal_Char *sName;
226 : const OUString *pUName;
227 : };
228 : sal_Unicode cChar;
229 : };
230 :
231 : // Flag: RTF token table has already been sorted
232 : static bool bSortCharKeyWords = false;
233 :
234 : static HTML_CharEntry aHTMLCharNameTab[] = {
235 : {{OOO_STRING_SVTOOLS_HTML_C_lt}, 60},
236 : {{OOO_STRING_SVTOOLS_HTML_C_gt}, 62},
237 : {{OOO_STRING_SVTOOLS_HTML_C_amp}, 38},
238 : {{OOO_STRING_SVTOOLS_HTML_C_quot}, 34},
239 :
240 : {{OOO_STRING_SVTOOLS_HTML_C_Agrave}, 192},
241 : {{OOO_STRING_SVTOOLS_HTML_C_Aacute}, 193},
242 : {{OOO_STRING_SVTOOLS_HTML_C_Acirc}, 194},
243 : {{OOO_STRING_SVTOOLS_HTML_C_Atilde}, 195},
244 : {{OOO_STRING_SVTOOLS_HTML_C_Auml}, 196},
245 : {{OOO_STRING_SVTOOLS_HTML_C_Aring}, 197},
246 : {{OOO_STRING_SVTOOLS_HTML_C_AElig}, 198},
247 : {{OOO_STRING_SVTOOLS_HTML_C_Ccedil}, 199},
248 : {{OOO_STRING_SVTOOLS_HTML_C_Egrave}, 200},
249 : {{OOO_STRING_SVTOOLS_HTML_C_Eacute}, 201},
250 : {{OOO_STRING_SVTOOLS_HTML_C_Ecirc}, 202},
251 : {{OOO_STRING_SVTOOLS_HTML_C_Euml}, 203},
252 : {{OOO_STRING_SVTOOLS_HTML_C_Igrave}, 204},
253 : {{OOO_STRING_SVTOOLS_HTML_C_Iacute}, 205},
254 : {{OOO_STRING_SVTOOLS_HTML_C_Icirc}, 206},
255 : {{OOO_STRING_SVTOOLS_HTML_C_Iuml}, 207},
256 : {{OOO_STRING_SVTOOLS_HTML_C_ETH}, 208},
257 : {{OOO_STRING_SVTOOLS_HTML_C_Ntilde}, 209},
258 : {{OOO_STRING_SVTOOLS_HTML_C_Ograve}, 210},
259 : {{OOO_STRING_SVTOOLS_HTML_C_Oacute}, 211},
260 : {{OOO_STRING_SVTOOLS_HTML_C_Ocirc}, 212},
261 : {{OOO_STRING_SVTOOLS_HTML_C_Otilde}, 213},
262 : {{OOO_STRING_SVTOOLS_HTML_C_Ouml}, 214},
263 : {{OOO_STRING_SVTOOLS_HTML_C_Oslash}, 216},
264 : {{OOO_STRING_SVTOOLS_HTML_C_Ugrave}, 217},
265 : {{OOO_STRING_SVTOOLS_HTML_C_Uacute}, 218},
266 : {{OOO_STRING_SVTOOLS_HTML_C_Ucirc}, 219},
267 : {{OOO_STRING_SVTOOLS_HTML_C_Uuml}, 220},
268 : {{OOO_STRING_SVTOOLS_HTML_C_Yacute}, 221},
269 :
270 : {{OOO_STRING_SVTOOLS_HTML_C_THORN}, 222},
271 : {{OOO_STRING_SVTOOLS_HTML_C_szlig}, 223},
272 :
273 : {{OOO_STRING_SVTOOLS_HTML_S_agrave}, 224},
274 : {{OOO_STRING_SVTOOLS_HTML_S_aacute}, 225},
275 : {{OOO_STRING_SVTOOLS_HTML_S_acirc}, 226},
276 : {{OOO_STRING_SVTOOLS_HTML_S_atilde}, 227},
277 : {{OOO_STRING_SVTOOLS_HTML_S_auml}, 228},
278 : {{OOO_STRING_SVTOOLS_HTML_S_aring}, 229},
279 : {{OOO_STRING_SVTOOLS_HTML_S_aelig}, 230},
280 : {{OOO_STRING_SVTOOLS_HTML_S_ccedil}, 231},
281 : {{OOO_STRING_SVTOOLS_HTML_S_egrave}, 232},
282 : {{OOO_STRING_SVTOOLS_HTML_S_eacute}, 233},
283 : {{OOO_STRING_SVTOOLS_HTML_S_ecirc}, 234},
284 : {{OOO_STRING_SVTOOLS_HTML_S_euml}, 235},
285 : {{OOO_STRING_SVTOOLS_HTML_S_igrave}, 236},
286 : {{OOO_STRING_SVTOOLS_HTML_S_iacute}, 237},
287 : {{OOO_STRING_SVTOOLS_HTML_S_icirc}, 238},
288 : {{OOO_STRING_SVTOOLS_HTML_S_iuml}, 239},
289 : {{OOO_STRING_SVTOOLS_HTML_S_eth}, 240},
290 : {{OOO_STRING_SVTOOLS_HTML_S_ntilde}, 241},
291 : {{OOO_STRING_SVTOOLS_HTML_S_ograve}, 242},
292 : {{OOO_STRING_SVTOOLS_HTML_S_oacute}, 243},
293 : {{OOO_STRING_SVTOOLS_HTML_S_ocirc}, 244},
294 : {{OOO_STRING_SVTOOLS_HTML_S_otilde}, 245},
295 : {{OOO_STRING_SVTOOLS_HTML_S_ouml}, 246},
296 : {{OOO_STRING_SVTOOLS_HTML_S_oslash}, 248},
297 : {{OOO_STRING_SVTOOLS_HTML_S_ugrave}, 249},
298 : {{OOO_STRING_SVTOOLS_HTML_S_uacute}, 250},
299 : {{OOO_STRING_SVTOOLS_HTML_S_ucirc}, 251},
300 : {{OOO_STRING_SVTOOLS_HTML_S_uuml}, 252},
301 : {{OOO_STRING_SVTOOLS_HTML_S_yacute}, 253},
302 : {{OOO_STRING_SVTOOLS_HTML_S_thorn}, 254},
303 : {{OOO_STRING_SVTOOLS_HTML_S_yuml}, 255},
304 :
305 : // special characters
306 : {{OOO_STRING_SVTOOLS_HTML_S_acute}, 180},
307 : {{OOO_STRING_SVTOOLS_HTML_S_brvbar}, 166},
308 : {{OOO_STRING_SVTOOLS_HTML_S_cedil}, 184},
309 : {{OOO_STRING_SVTOOLS_HTML_S_cent}, 162},
310 : {{OOO_STRING_SVTOOLS_HTML_S_copy}, 169},
311 : {{OOO_STRING_SVTOOLS_HTML_S_curren}, 164},
312 : {{OOO_STRING_SVTOOLS_HTML_S_deg}, 176},
313 : {{OOO_STRING_SVTOOLS_HTML_S_divide}, 247},
314 : {{OOO_STRING_SVTOOLS_HTML_S_frac12}, 189},
315 : {{OOO_STRING_SVTOOLS_HTML_S_frac14}, 188},
316 : {{OOO_STRING_SVTOOLS_HTML_S_frac34}, 190},
317 : {{OOO_STRING_SVTOOLS_HTML_S_iexcl}, 161},
318 : {{OOO_STRING_SVTOOLS_HTML_S_iquest}, 191},
319 : {{OOO_STRING_SVTOOLS_HTML_S_laquo}, 171},
320 : {{OOO_STRING_SVTOOLS_HTML_S_macr}, 175},
321 : {{OOO_STRING_SVTOOLS_HTML_S_micro}, 181},
322 : {{OOO_STRING_SVTOOLS_HTML_S_middot}, 183},
323 : {{OOO_STRING_SVTOOLS_HTML_S_not}, 172},
324 : {{OOO_STRING_SVTOOLS_HTML_S_ordf}, 170},
325 : {{OOO_STRING_SVTOOLS_HTML_S_ordm}, 186},
326 : {{OOO_STRING_SVTOOLS_HTML_S_para}, 182},
327 : {{OOO_STRING_SVTOOLS_HTML_S_plusmn}, 177},
328 : {{OOO_STRING_SVTOOLS_HTML_S_pound}, 163},
329 : {{OOO_STRING_SVTOOLS_HTML_S_raquo}, 187},
330 : {{OOO_STRING_SVTOOLS_HTML_S_reg}, 174},
331 : {{OOO_STRING_SVTOOLS_HTML_S_sect}, 167},
332 : {{OOO_STRING_SVTOOLS_HTML_S_sup1}, 185},
333 : {{OOO_STRING_SVTOOLS_HTML_S_sup2}, 178},
334 : {{OOO_STRING_SVTOOLS_HTML_S_sup3}, 179},
335 : {{OOO_STRING_SVTOOLS_HTML_S_times}, 215},
336 : {{OOO_STRING_SVTOOLS_HTML_S_uml}, 168},
337 : {{OOO_STRING_SVTOOLS_HTML_S_yen}, 165},
338 :
339 : // special characters, which will be converted to tokens !!!
340 : {{OOO_STRING_SVTOOLS_HTML_S_nbsp}, 1},
341 : {{OOO_STRING_SVTOOLS_HTML_S_shy}, 2},
342 :
343 :
344 : // HTML4
345 : {{OOO_STRING_SVTOOLS_HTML_S_OElig}, 338},
346 : {{OOO_STRING_SVTOOLS_HTML_S_oelig}, 339},
347 : {{OOO_STRING_SVTOOLS_HTML_S_Scaron}, 352},
348 : {{OOO_STRING_SVTOOLS_HTML_S_scaron}, 353},
349 : {{OOO_STRING_SVTOOLS_HTML_S_Yuml}, 376},
350 : {{OOO_STRING_SVTOOLS_HTML_S_fnof}, 402},
351 : {{OOO_STRING_SVTOOLS_HTML_S_circ}, 710},
352 : {{OOO_STRING_SVTOOLS_HTML_S_tilde}, 732},
353 : {{OOO_STRING_SVTOOLS_HTML_S_Alpha}, 913},
354 : {{OOO_STRING_SVTOOLS_HTML_S_Beta}, 914},
355 : {{OOO_STRING_SVTOOLS_HTML_S_Gamma}, 915},
356 : {{OOO_STRING_SVTOOLS_HTML_S_Delta}, 916},
357 : {{OOO_STRING_SVTOOLS_HTML_S_Epsilon}, 917},
358 : {{OOO_STRING_SVTOOLS_HTML_S_Zeta}, 918},
359 : {{OOO_STRING_SVTOOLS_HTML_S_Eta}, 919},
360 : {{OOO_STRING_SVTOOLS_HTML_S_Theta}, 920},
361 : {{OOO_STRING_SVTOOLS_HTML_S_Iota}, 921},
362 : {{OOO_STRING_SVTOOLS_HTML_S_Kappa}, 922},
363 : {{OOO_STRING_SVTOOLS_HTML_S_Lambda}, 923},
364 : {{OOO_STRING_SVTOOLS_HTML_S_Mu}, 924},
365 : {{OOO_STRING_SVTOOLS_HTML_S_Nu}, 925},
366 : {{OOO_STRING_SVTOOLS_HTML_S_Xi}, 926},
367 : {{OOO_STRING_SVTOOLS_HTML_S_Omicron}, 927},
368 : {{OOO_STRING_SVTOOLS_HTML_S_Pi}, 928},
369 : {{OOO_STRING_SVTOOLS_HTML_S_Rho}, 929},
370 : {{OOO_STRING_SVTOOLS_HTML_S_Sigma}, 931},
371 : {{OOO_STRING_SVTOOLS_HTML_S_Tau}, 932},
372 : {{OOO_STRING_SVTOOLS_HTML_S_Upsilon}, 933},
373 : {{OOO_STRING_SVTOOLS_HTML_S_Phi}, 934},
374 : {{OOO_STRING_SVTOOLS_HTML_S_Chi}, 935},
375 : {{OOO_STRING_SVTOOLS_HTML_S_Psi}, 936},
376 : {{OOO_STRING_SVTOOLS_HTML_S_Omega}, 937},
377 : {{OOO_STRING_SVTOOLS_HTML_S_alpha}, 945},
378 : {{OOO_STRING_SVTOOLS_HTML_S_beta}, 946},
379 : {{OOO_STRING_SVTOOLS_HTML_S_gamma}, 947},
380 : {{OOO_STRING_SVTOOLS_HTML_S_delta}, 948},
381 : {{OOO_STRING_SVTOOLS_HTML_S_epsilon}, 949},
382 : {{OOO_STRING_SVTOOLS_HTML_S_zeta}, 950},
383 : {{OOO_STRING_SVTOOLS_HTML_S_eta}, 951},
384 : {{OOO_STRING_SVTOOLS_HTML_S_theta}, 952},
385 : {{OOO_STRING_SVTOOLS_HTML_S_iota}, 953},
386 : {{OOO_STRING_SVTOOLS_HTML_S_kappa}, 954},
387 : {{OOO_STRING_SVTOOLS_HTML_S_lambda}, 955},
388 : {{OOO_STRING_SVTOOLS_HTML_S_mu}, 956},
389 : {{OOO_STRING_SVTOOLS_HTML_S_nu}, 957},
390 : {{OOO_STRING_SVTOOLS_HTML_S_xi}, 958},
391 : {{OOO_STRING_SVTOOLS_HTML_S_omicron}, 959},
392 : {{OOO_STRING_SVTOOLS_HTML_S_pi}, 960},
393 : {{OOO_STRING_SVTOOLS_HTML_S_rho}, 961},
394 : {{OOO_STRING_SVTOOLS_HTML_S_sigmaf}, 962},
395 : {{OOO_STRING_SVTOOLS_HTML_S_sigma}, 963},
396 : {{OOO_STRING_SVTOOLS_HTML_S_tau}, 964},
397 : {{OOO_STRING_SVTOOLS_HTML_S_upsilon}, 965},
398 : {{OOO_STRING_SVTOOLS_HTML_S_phi}, 966},
399 : {{OOO_STRING_SVTOOLS_HTML_S_chi}, 967},
400 : {{OOO_STRING_SVTOOLS_HTML_S_psi}, 968},
401 : {{OOO_STRING_SVTOOLS_HTML_S_omega}, 969},
402 : {{OOO_STRING_SVTOOLS_HTML_S_thetasym}, 977},
403 : {{OOO_STRING_SVTOOLS_HTML_S_upsih}, 978},
404 : {{OOO_STRING_SVTOOLS_HTML_S_piv}, 982},
405 : {{OOO_STRING_SVTOOLS_HTML_S_ensp}, 8194},
406 : {{OOO_STRING_SVTOOLS_HTML_S_emsp}, 8195},
407 : {{OOO_STRING_SVTOOLS_HTML_S_thinsp}, 8201},
408 : {{OOO_STRING_SVTOOLS_HTML_S_zwnj}, 8204},
409 : {{OOO_STRING_SVTOOLS_HTML_S_zwj}, 8205},
410 : {{OOO_STRING_SVTOOLS_HTML_S_lrm}, 8206},
411 : {{OOO_STRING_SVTOOLS_HTML_S_rlm}, 8207},
412 : {{OOO_STRING_SVTOOLS_HTML_S_ndash}, 8211},
413 : {{OOO_STRING_SVTOOLS_HTML_S_mdash}, 8212},
414 : {{OOO_STRING_SVTOOLS_HTML_S_lsquo}, 8216},
415 : {{OOO_STRING_SVTOOLS_HTML_S_rsquo}, 8217},
416 : {{OOO_STRING_SVTOOLS_HTML_S_sbquo}, 8218},
417 : {{OOO_STRING_SVTOOLS_HTML_S_ldquo}, 8220},
418 : {{OOO_STRING_SVTOOLS_HTML_S_rdquo}, 8221},
419 : {{OOO_STRING_SVTOOLS_HTML_S_bdquo}, 8222},
420 : {{OOO_STRING_SVTOOLS_HTML_S_dagger}, 8224},
421 : {{OOO_STRING_SVTOOLS_HTML_S_Dagger}, 8225},
422 : {{OOO_STRING_SVTOOLS_HTML_S_bull}, 8226},
423 : {{OOO_STRING_SVTOOLS_HTML_S_hellip}, 8230},
424 : {{OOO_STRING_SVTOOLS_HTML_S_permil}, 8240},
425 : {{OOO_STRING_SVTOOLS_HTML_S_prime}, 8242},
426 : {{OOO_STRING_SVTOOLS_HTML_S_Prime}, 8243},
427 : {{OOO_STRING_SVTOOLS_HTML_S_lsaquo}, 8249},
428 : {{OOO_STRING_SVTOOLS_HTML_S_rsaquo}, 8250},
429 : {{OOO_STRING_SVTOOLS_HTML_S_oline}, 8254},
430 : {{OOO_STRING_SVTOOLS_HTML_S_frasl}, 8260},
431 : {{OOO_STRING_SVTOOLS_HTML_S_euro}, 8364},
432 : {{OOO_STRING_SVTOOLS_HTML_S_image}, 8465},
433 : {{OOO_STRING_SVTOOLS_HTML_S_weierp}, 8472},
434 : {{OOO_STRING_SVTOOLS_HTML_S_real}, 8476},
435 : {{OOO_STRING_SVTOOLS_HTML_S_trade}, 8482},
436 : {{OOO_STRING_SVTOOLS_HTML_S_alefsym}, 8501},
437 : {{OOO_STRING_SVTOOLS_HTML_S_larr}, 8592},
438 : {{OOO_STRING_SVTOOLS_HTML_S_uarr}, 8593},
439 : {{OOO_STRING_SVTOOLS_HTML_S_rarr}, 8594},
440 : {{OOO_STRING_SVTOOLS_HTML_S_darr}, 8595},
441 : {{OOO_STRING_SVTOOLS_HTML_S_harr}, 8596},
442 : {{OOO_STRING_SVTOOLS_HTML_S_crarr}, 8629},
443 : {{OOO_STRING_SVTOOLS_HTML_S_lArr}, 8656},
444 : {{OOO_STRING_SVTOOLS_HTML_S_uArr}, 8657},
445 : {{OOO_STRING_SVTOOLS_HTML_S_rArr}, 8658},
446 : {{OOO_STRING_SVTOOLS_HTML_S_dArr}, 8659},
447 : {{OOO_STRING_SVTOOLS_HTML_S_hArr}, 8660},
448 : {{OOO_STRING_SVTOOLS_HTML_S_forall}, 8704},
449 : {{OOO_STRING_SVTOOLS_HTML_S_part}, 8706},
450 : {{OOO_STRING_SVTOOLS_HTML_S_exist}, 8707},
451 : {{OOO_STRING_SVTOOLS_HTML_S_empty}, 8709},
452 : {{OOO_STRING_SVTOOLS_HTML_S_nabla}, 8711},
453 : {{OOO_STRING_SVTOOLS_HTML_S_isin}, 8712},
454 : {{OOO_STRING_SVTOOLS_HTML_S_notin}, 8713},
455 : {{OOO_STRING_SVTOOLS_HTML_S_ni}, 8715},
456 : {{OOO_STRING_SVTOOLS_HTML_S_prod}, 8719},
457 : {{OOO_STRING_SVTOOLS_HTML_S_sum}, 8721},
458 : {{OOO_STRING_SVTOOLS_HTML_S_minus}, 8722},
459 : {{OOO_STRING_SVTOOLS_HTML_S_lowast}, 8727},
460 : {{OOO_STRING_SVTOOLS_HTML_S_radic}, 8730},
461 : {{OOO_STRING_SVTOOLS_HTML_S_prop}, 8733},
462 : {{OOO_STRING_SVTOOLS_HTML_S_infin}, 8734},
463 : {{OOO_STRING_SVTOOLS_HTML_S_ang}, 8736},
464 : {{OOO_STRING_SVTOOLS_HTML_S_and}, 8743},
465 : {{OOO_STRING_SVTOOLS_HTML_S_or}, 8744},
466 : {{OOO_STRING_SVTOOLS_HTML_S_cap}, 8745},
467 : {{OOO_STRING_SVTOOLS_HTML_S_cup}, 8746},
468 : {{OOO_STRING_SVTOOLS_HTML_S_int}, 8747},
469 : {{OOO_STRING_SVTOOLS_HTML_S_there4}, 8756},
470 : {{OOO_STRING_SVTOOLS_HTML_S_sim}, 8764},
471 : {{OOO_STRING_SVTOOLS_HTML_S_cong}, 8773},
472 : {{OOO_STRING_SVTOOLS_HTML_S_asymp}, 8776},
473 : {{OOO_STRING_SVTOOLS_HTML_S_ne}, 8800},
474 : {{OOO_STRING_SVTOOLS_HTML_S_equiv}, 8801},
475 : {{OOO_STRING_SVTOOLS_HTML_S_le}, 8804},
476 : {{OOO_STRING_SVTOOLS_HTML_S_ge}, 8805},
477 : {{OOO_STRING_SVTOOLS_HTML_S_sub}, 8834},
478 : {{OOO_STRING_SVTOOLS_HTML_S_sup}, 8835},
479 : {{OOO_STRING_SVTOOLS_HTML_S_nsub}, 8836},
480 : {{OOO_STRING_SVTOOLS_HTML_S_sube}, 8838},
481 : {{OOO_STRING_SVTOOLS_HTML_S_supe}, 8839},
482 : {{OOO_STRING_SVTOOLS_HTML_S_oplus}, 8853},
483 : {{OOO_STRING_SVTOOLS_HTML_S_otimes}, 8855},
484 : {{OOO_STRING_SVTOOLS_HTML_S_perp}, 8869},
485 : {{OOO_STRING_SVTOOLS_HTML_S_sdot}, 8901},
486 : {{OOO_STRING_SVTOOLS_HTML_S_lceil}, 8968},
487 : {{OOO_STRING_SVTOOLS_HTML_S_rceil}, 8969},
488 : {{OOO_STRING_SVTOOLS_HTML_S_lfloor}, 8970},
489 : {{OOO_STRING_SVTOOLS_HTML_S_rfloor}, 8971},
490 : {{OOO_STRING_SVTOOLS_HTML_S_lang}, 9001},
491 : {{OOO_STRING_SVTOOLS_HTML_S_rang}, 9002},
492 : {{OOO_STRING_SVTOOLS_HTML_S_loz}, 9674},
493 : {{OOO_STRING_SVTOOLS_HTML_S_spades}, 9824},
494 : {{OOO_STRING_SVTOOLS_HTML_S_clubs}, 9827},
495 : {{OOO_STRING_SVTOOLS_HTML_S_hearts}, 9829},
496 : {{OOO_STRING_SVTOOLS_HTML_S_diams}, 9830}
497 : };
498 :
499 : extern "C"
500 : {
501 :
502 0 : static int SAL_CALL HTMLCharNameCompare( const void *pFirst, const void *pSecond)
503 : {
504 0 : HTML_CharEntry* pFirstEntry = (HTML_CharEntry*)pFirst;
505 0 : HTML_CharEntry* pSecondEntry = (HTML_CharEntry*)pSecond;
506 0 : int nRet = 0;
507 0 : if( USHRT_MAX == pFirstEntry->cChar )
508 : {
509 0 : if( USHRT_MAX == pSecondEntry->cChar )
510 0 : nRet = pFirstEntry->pUName->compareTo( *pSecondEntry->pUName );
511 : else
512 0 : nRet = pFirstEntry->pUName->compareToAscii( pSecondEntry->sName );
513 : }
514 : else
515 : {
516 0 : if( USHRT_MAX == pSecondEntry->cChar )
517 0 : nRet = -1 * pSecondEntry->pUName->compareToAscii( pFirstEntry->sName );
518 : else
519 0 : nRet = strcmp( pFirstEntry->sName, pSecondEntry->sName );
520 : }
521 :
522 0 : return nRet;
523 : }
524 :
525 : } // extern "C"
526 :
527 0 : sal_Unicode GetHTMLCharName( const OUString& rName )
528 : {
529 0 : if( !bSortCharKeyWords )
530 : {
531 : qsort( (void*) aHTMLCharNameTab,
532 : sizeof( aHTMLCharNameTab ) / sizeof( HTML_CharEntry ),
533 : sizeof( HTML_CharEntry ),
534 0 : HTMLCharNameCompare );
535 0 : bSortCharKeyWords = true;
536 : }
537 :
538 0 : sal_Unicode cRet = 0;
539 : void* pFound;
540 : HTML_CharEntry aSrch;
541 0 : aSrch.pUName = &rName;
542 0 : aSrch.cChar = USHRT_MAX;
543 :
544 0 : if( 0 != ( pFound = bsearch( (sal_Char *) &aSrch,
545 : (void*) aHTMLCharNameTab,
546 : sizeof( aHTMLCharNameTab) / sizeof( HTML_CharEntry ),
547 : sizeof( HTML_CharEntry ),
548 0 : HTMLCharNameCompare )))
549 0 : cRet = ((HTML_CharEntry*)pFound)->cChar;
550 0 : return cRet;
551 : }
552 :
553 : // Flag: Options table has already been sorted
554 : static bool bSortOptionKeyWords = false;
555 :
556 : static HTML_TokenEntry aHTMLOptionTab[] = {
557 :
558 : // Attributes without value
559 : {{OOO_STRING_SVTOOLS_HTML_O_checked}, HTML_O_CHECKED},
560 : {{OOO_STRING_SVTOOLS_HTML_O_compact}, HTML_O_COMPACT},
561 : {{OOO_STRING_SVTOOLS_HTML_O_declare}, HTML_O_DECLARE},
562 : {{OOO_STRING_SVTOOLS_HTML_O_disabled}, HTML_O_DISABLED},
563 : {{OOO_STRING_SVTOOLS_HTML_O_ismap}, HTML_O_ISMAP},
564 : {{OOO_STRING_SVTOOLS_HTML_O_mayscript}, HTML_O_MAYSCRIPT},
565 : {{OOO_STRING_SVTOOLS_HTML_O_multiple}, HTML_O_MULTIPLE},
566 : {{OOO_STRING_SVTOOLS_HTML_O_nohref}, HTML_O_NOHREF}, // Netscape 2.0
567 : {{OOO_STRING_SVTOOLS_HTML_O_noresize}, HTML_O_NORESIZE}, // Netscape 2.0
568 : {{OOO_STRING_SVTOOLS_HTML_O_noshade}, HTML_O_NOSHADE}, // Netscape 2.0
569 : {{OOO_STRING_SVTOOLS_HTML_O_nowrap}, HTML_O_NOWRAP},
570 : {{OOO_STRING_SVTOOLS_HTML_O_sdfixed}, HTML_O_SDFIXED},
571 : {{OOO_STRING_SVTOOLS_HTML_O_selected}, HTML_O_SELECTED},
572 :
573 : // Attributes with a string value
574 : {{OOO_STRING_SVTOOLS_HTML_O_accept}, HTML_O_ACCEPT},
575 : {{OOO_STRING_SVTOOLS_HTML_O_accesskey}, HTML_O_ACCESSKEY},
576 : {{OOO_STRING_SVTOOLS_HTML_O_alt}, HTML_O_ALT},
577 : {{OOO_STRING_SVTOOLS_HTML_O_axis}, HTML_O_AXIS},
578 : {{OOO_STRING_SVTOOLS_HTML_O_char}, HTML_O_CHAR}, // HTML 3 Table Model Draft
579 : {{OOO_STRING_SVTOOLS_HTML_O_class}, HTML_O_CLASS},
580 : {{OOO_STRING_SVTOOLS_HTML_O_code}, HTML_O_CODE}, // HotJava
581 : {{OOO_STRING_SVTOOLS_HTML_O_codetype}, HTML_O_CODETYPE},
582 : {{OOO_STRING_SVTOOLS_HTML_O_content}, HTML_O_CONTENT},
583 : {{OOO_STRING_SVTOOLS_HTML_O_coords}, HTML_O_COORDS}, // Netscape 2.0
584 : {{OOO_STRING_SVTOOLS_HTML_O_enctype}, HTML_O_ENCTYPE},
585 : {{OOO_STRING_SVTOOLS_HTML_O_face}, HTML_O_FACE}, // IExplorer 2.0
586 : {{OOO_STRING_SVTOOLS_HTML_O_frameborder}, HTML_O_FRAMEBORDER}, // IExplorer 3.0
587 : {{OOO_STRING_SVTOOLS_HTML_O_httpequiv}, HTML_O_HTTPEQUIV},
588 : {{OOO_STRING_SVTOOLS_HTML_O_language}, HTML_O_LANGUAGE}, // JavaScript
589 : {{OOO_STRING_SVTOOLS_HTML_O_name}, HTML_O_NAME},
590 : {{OOO_STRING_SVTOOLS_HTML_O_prompt}, HTML_O_PROMPT},
591 : {{OOO_STRING_SVTOOLS_HTML_O_shape}, HTML_O_SHAPE},
592 : {{OOO_STRING_SVTOOLS_HTML_O_standby}, HTML_O_STANDBY},
593 : {{OOO_STRING_SVTOOLS_HTML_O_style}, HTML_O_STYLE},
594 : {{OOO_STRING_SVTOOLS_HTML_O_title}, HTML_O_TITLE},
595 : {{OOO_STRING_SVTOOLS_HTML_O_value}, HTML_O_VALUE},
596 : {{OOO_STRING_SVTOOLS_HTML_O_SDval}, HTML_O_SDVAL}, // StarDiv NumberValue
597 : {{OOO_STRING_SVTOOLS_HTML_O_SDnum}, HTML_O_SDNUM}, // StarDiv NumberFormat
598 : {{OOO_STRING_SVTOOLS_HTML_O_sdlibrary}, HTML_O_SDLIBRARY},
599 : {{OOO_STRING_SVTOOLS_HTML_O_sdmodule}, HTML_O_SDMODULE},
600 :
601 : // Attributes with a SGML identifier value
602 : {{OOO_STRING_SVTOOLS_HTML_O_id}, HTML_O_ID},
603 : {{OOO_STRING_SVTOOLS_HTML_O_target}, HTML_O_TARGET}, // Netscape 2.0
604 : {{OOO_STRING_SVTOOLS_HTML_O_to}, HTML_O_TO},
605 :
606 : // Attributes with an URI value
607 : {{OOO_STRING_SVTOOLS_HTML_O_action}, HTML_O_ACTION},
608 : {{OOO_STRING_SVTOOLS_HTML_O_archive}, HTML_O_ARCHIVE},
609 : {{OOO_STRING_SVTOOLS_HTML_O_background}, HTML_O_BACKGROUND},
610 : {{OOO_STRING_SVTOOLS_HTML_O_classid}, HTML_O_CLASSID},
611 : {{OOO_STRING_SVTOOLS_HTML_O_codebase}, HTML_O_CODEBASE}, // HotJava
612 : {{OOO_STRING_SVTOOLS_HTML_O_data}, HTML_O_DATA},
613 : {{OOO_STRING_SVTOOLS_HTML_O_href}, HTML_O_HREF},
614 : {{OOO_STRING_SVTOOLS_HTML_O_script}, HTML_O_SCRIPT},
615 : {{OOO_STRING_SVTOOLS_HTML_O_src}, HTML_O_SRC},
616 : {{OOO_STRING_SVTOOLS_HTML_O_usemap}, HTML_O_USEMAP}, // Netscape 2.0
617 :
618 : // Attributes with a color value (all Netscape versions)
619 : {{OOO_STRING_SVTOOLS_HTML_O_alink}, HTML_O_ALINK},
620 : {{OOO_STRING_SVTOOLS_HTML_O_bgcolor}, HTML_O_BGCOLOR},
621 : {{OOO_STRING_SVTOOLS_HTML_O_bordercolor}, HTML_O_BORDERCOLOR}, // IExplorer 2.0
622 : {{OOO_STRING_SVTOOLS_HTML_O_bordercolorlight}, HTML_O_BORDERCOLORLIGHT}, // IExplorer 2.0
623 : {{OOO_STRING_SVTOOLS_HTML_O_bordercolordark}, HTML_O_BORDERCOLORDARK}, // IExplorer 2.0
624 : {{OOO_STRING_SVTOOLS_HTML_O_color}, HTML_O_COLOR},
625 : {{OOO_STRING_SVTOOLS_HTML_O_link}, HTML_O_LINK},
626 : {{OOO_STRING_SVTOOLS_HTML_O_text}, HTML_O_TEXT},
627 : {{OOO_STRING_SVTOOLS_HTML_O_vlink}, HTML_O_VLINK},
628 :
629 : // Attributes with a numerical value
630 : {{OOO_STRING_SVTOOLS_HTML_O_border}, HTML_O_BORDER},
631 : {{OOO_STRING_SVTOOLS_HTML_O_cellspacing},HTML_O_CELLSPACING}, // HTML 3 Table Model Draft
632 : {{OOO_STRING_SVTOOLS_HTML_O_cellpadding},HTML_O_CELLPADDING}, // HTML 3 Table Model Draft
633 : {{OOO_STRING_SVTOOLS_HTML_O_charoff}, HTML_O_CHAROFF}, // HTML 3 Table Model Draft
634 : {{OOO_STRING_SVTOOLS_HTML_O_colspan}, HTML_O_COLSPAN},
635 : {{OOO_STRING_SVTOOLS_HTML_O_framespacing}, HTML_O_FRAMESPACING}, // IExplorer 3.0
636 : {{OOO_STRING_SVTOOLS_HTML_O_gutter}, HTML_O_GUTTER}, // Netscape 3.0b5
637 : {{OOO_STRING_SVTOOLS_HTML_O_height}, HTML_O_HEIGHT},
638 : {{OOO_STRING_SVTOOLS_HTML_O_hspace}, HTML_O_HSPACE}, // Netscape
639 : {{OOO_STRING_SVTOOLS_HTML_O_left}, HTML_O_LEFT},
640 : {{OOO_STRING_SVTOOLS_HTML_O_loop}, HTML_O_LOOP}, // IExplorer 2.0
641 : {{OOO_STRING_SVTOOLS_HTML_O_marginheight},HTML_O_MARGINHEIGHT}, // Netscape 2.0
642 : {{OOO_STRING_SVTOOLS_HTML_O_marginwidth},HTML_O_MARGINWIDTH}, // Netscape 2.0
643 : {{OOO_STRING_SVTOOLS_HTML_O_maxlength}, HTML_O_MAXLENGTH},
644 : {{OOO_STRING_SVTOOLS_HTML_O_rowspan}, HTML_O_ROWSPAN},
645 : {{OOO_STRING_SVTOOLS_HTML_O_scrollamount}, HTML_O_SCROLLAMOUNT}, // IExplorer 2.0
646 : {{OOO_STRING_SVTOOLS_HTML_O_scrolldelay}, HTML_O_SCROLLDELAY}, // IExplorer 2.0
647 : {{OOO_STRING_SVTOOLS_HTML_O_span}, HTML_O_SPAN}, // HTML 3 Table Model Draft
648 : {{OOO_STRING_SVTOOLS_HTML_O_tabindex}, HTML_O_TABINDEX},
649 : {{OOO_STRING_SVTOOLS_HTML_O_vspace}, HTML_O_VSPACE}, // Netscape
650 : {{OOO_STRING_SVTOOLS_HTML_O_width}, HTML_O_WIDTH},
651 : {{OOO_STRING_SVTOOLS_HTML_O_zindex}, HTML_O_ZINDEX},
652 :
653 : // Attributes with enum values
654 : {{OOO_STRING_SVTOOLS_HTML_O_behavior}, HTML_O_BEHAVIOR}, // IExplorer 2.0
655 : {{OOO_STRING_SVTOOLS_HTML_O_clear}, HTML_O_CLEAR},
656 : {{OOO_STRING_SVTOOLS_HTML_O_dir}, HTML_O_DIR}, // HTML 3 Table Model Draft
657 : {{OOO_STRING_SVTOOLS_HTML_O_direction}, HTML_O_DIRECTION}, // IExplorer 2.0
658 : {{OOO_STRING_SVTOOLS_HTML_O_format}, HTML_O_FORMAT},
659 : {{OOO_STRING_SVTOOLS_HTML_O_frame}, HTML_O_FRAME}, // HTML 3 Table Model Draft
660 : {{OOO_STRING_SVTOOLS_HTML_O_lang}, HTML_O_LANG},
661 : {{OOO_STRING_SVTOOLS_HTML_O_method}, HTML_O_METHOD},
662 : {{OOO_STRING_SVTOOLS_HTML_O_rel}, HTML_O_REL},
663 : {{OOO_STRING_SVTOOLS_HTML_O_rev}, HTML_O_REV},
664 : {{OOO_STRING_SVTOOLS_HTML_O_rules}, HTML_O_RULES}, // HTML 3 Table Model Draft
665 : {{OOO_STRING_SVTOOLS_HTML_O_scrolling}, HTML_O_SCROLLING}, // Netscape 2.0
666 : {{OOO_STRING_SVTOOLS_HTML_O_sdreadonly}, HTML_O_SDREADONLY},
667 : {{OOO_STRING_SVTOOLS_HTML_O_subtype}, HTML_O_SUBTYPE},
668 : {{OOO_STRING_SVTOOLS_HTML_O_type}, HTML_O_TYPE},
669 : {{OOO_STRING_SVTOOLS_HTML_O_valign}, HTML_O_VALIGN},
670 : {{OOO_STRING_SVTOOLS_HTML_O_valuetype}, HTML_O_VALUETYPE},
671 : {{OOO_STRING_SVTOOLS_HTML_O_wrap}, HTML_O_WRAP},
672 :
673 : // Attributes with script code value
674 : {{OOO_STRING_SVTOOLS_HTML_O_onblur}, HTML_O_ONBLUR}, // JavaScript
675 : {{OOO_STRING_SVTOOLS_HTML_O_onchange}, HTML_O_ONCHANGE}, // JavaScript
676 : {{OOO_STRING_SVTOOLS_HTML_O_onclick}, HTML_O_ONCLICK}, // JavaScript
677 : {{OOO_STRING_SVTOOLS_HTML_O_onfocus}, HTML_O_ONFOCUS}, // JavaScript
678 : {{OOO_STRING_SVTOOLS_HTML_O_onload}, HTML_O_ONLOAD}, // JavaScript
679 : {{OOO_STRING_SVTOOLS_HTML_O_onmouseover}, HTML_O_ONMOUSEOVER}, // JavaScript
680 : {{OOO_STRING_SVTOOLS_HTML_O_onreset}, HTML_O_ONRESET}, // JavaScript
681 : {{OOO_STRING_SVTOOLS_HTML_O_onselect}, HTML_O_ONSELECT}, // JavaScript
682 : {{OOO_STRING_SVTOOLS_HTML_O_onsubmit}, HTML_O_ONSUBMIT}, // JavaScript
683 : {{OOO_STRING_SVTOOLS_HTML_O_onunload}, HTML_O_ONUNLOAD}, // JavaScript
684 : {{OOO_STRING_SVTOOLS_HTML_O_onabort}, HTML_O_ONABORT}, // JavaScript
685 : {{OOO_STRING_SVTOOLS_HTML_O_onerror}, HTML_O_ONERROR}, // JavaScript
686 : {{OOO_STRING_SVTOOLS_HTML_O_onmouseout}, HTML_O_ONMOUSEOUT}, // JavaScript
687 :
688 : {{OOO_STRING_SVTOOLS_HTML_O_SDonblur}, HTML_O_SDONBLUR}, // StarBasic
689 : {{OOO_STRING_SVTOOLS_HTML_O_SDonchange}, HTML_O_SDONCHANGE}, // StarBasic
690 : {{OOO_STRING_SVTOOLS_HTML_O_SDonclick}, HTML_O_SDONCLICK}, // StarBasic
691 : {{OOO_STRING_SVTOOLS_HTML_O_SDonfocus}, HTML_O_SDONFOCUS}, // StarBasic
692 : {{OOO_STRING_SVTOOLS_HTML_O_SDonload}, HTML_O_SDONLOAD}, // StarBasic
693 : {{OOO_STRING_SVTOOLS_HTML_O_SDonmouseover}, HTML_O_SDONMOUSEOVER}, // StarBasic
694 : {{OOO_STRING_SVTOOLS_HTML_O_SDonreset}, HTML_O_SDONRESET}, // StarBasic
695 : {{OOO_STRING_SVTOOLS_HTML_O_SDonselect}, HTML_O_SDONSELECT}, // StarBasic
696 : {{OOO_STRING_SVTOOLS_HTML_O_SDonsubmit}, HTML_O_SDONSUBMIT}, // StarBasic
697 : {{OOO_STRING_SVTOOLS_HTML_O_SDonunload}, HTML_O_SDONUNLOAD}, // StarBasic
698 : {{OOO_STRING_SVTOOLS_HTML_O_SDonabort}, HTML_O_SDONABORT}, // StarBasic
699 : {{OOO_STRING_SVTOOLS_HTML_O_SDonerror}, HTML_O_SDONERROR}, // StarBasic
700 : {{OOO_STRING_SVTOOLS_HTML_O_SDonmouseout}, HTML_O_SDONMOUSEOUT}, // StarBasic
701 :
702 : // Attributes with context sensitive values
703 : {{OOO_STRING_SVTOOLS_HTML_O_align}, HTML_O_ALIGN},
704 : {{OOO_STRING_SVTOOLS_HTML_O_cols}, HTML_O_COLS}, // Netscape 2.0 vs HTML 2.0
705 : {{OOO_STRING_SVTOOLS_HTML_O_rows}, HTML_O_ROWS}, // Netscape 2.0 vs HTML 2.0
706 : {{OOO_STRING_SVTOOLS_HTML_O_size}, HTML_O_SIZE},
707 : {{OOO_STRING_SVTOOLS_HTML_O_start}, HTML_O_START}, // Netscape 2.0 vs IExplorer 2.0
708 : };
709 :
710 2674 : int GetHTMLOption( const OUString& rName )
711 : {
712 2674 : if( !bSortOptionKeyWords )
713 : {
714 : qsort( (void*) aHTMLOptionTab,
715 : sizeof( aHTMLOptionTab ) / sizeof( HTML_TokenEntry ),
716 : sizeof( HTML_TokenEntry ),
717 8 : HTMLKeyCompare );
718 8 : bSortOptionKeyWords = true;
719 : }
720 :
721 2674 : int nRet = HTML_O_UNKNOWN;
722 : void* pFound;
723 : HTML_TokenEntry aSrch;
724 2674 : aSrch.pUToken = &rName;
725 2674 : aSrch.nToken = -1;
726 :
727 2674 : if( 0 != ( pFound = bsearch( (sal_Char *) &aSrch,
728 : (void*) aHTMLOptionTab,
729 : sizeof( aHTMLOptionTab ) / sizeof( HTML_TokenEntry ),
730 : sizeof( HTML_TokenEntry ),
731 2674 : HTMLKeyCompare )))
732 2660 : nRet = ((HTML_TokenEntry*)pFound)->nToken;
733 2674 : return nRet;
734 : }
735 :
736 :
737 : struct HTML_ColorEntry
738 : {
739 : union
740 : {
741 : const sal_Char* sName;
742 : const OUString *pUName;
743 : };
744 : sal_uInt32 nColor;
745 : };
746 :
747 : // Flag: color table has already been sorted
748 : static bool bSortColorKeyWords = false;
749 :
750 : #define HTML_NO_COLOR 0xffffffffUL
751 :
752 : // Color names are not exported (source:
753 : // "http://www.uio.no/~mnbjerke/colors_w.html")
754 : // "http://www.infi.net/wwwimages/colorindex.html" seem to be buggy.
755 : static HTML_ColorEntry aHTMLColorNameTab[] = {
756 : { { "aliceblue" }, 0x00f0f8ffUL },
757 : { { "antiquewhite" }, 0x00faebd7UL },
758 : { { "aqua" }, 0x0000ffffUL },
759 : { { "aquamarine" }, 0x007fffd4UL },
760 : { { "azure" }, 0x00f0ffffUL },
761 : { { "beige" }, 0x00f5f5dcUL },
762 : { { "bisque" }, 0x00ffe4c4UL },
763 : { { "black" }, 0x00000000UL },
764 : { { "blanchedalmond" }, 0x00ffebcdUL },
765 : { { "blue" }, 0x000000ffUL },
766 : { { "blueviolet" }, 0x008a2be2UL },
767 : { { "brown" }, 0x00a52a2aUL },
768 : { { "burlywood" }, 0x00deb887UL },
769 : { { "cadetblue" }, 0x005f9ea0UL },
770 : { { "chartreuse" }, 0x007fff00UL },
771 : { { "chocolate" }, 0x00d2691eUL },
772 : { { "coral" }, 0x00ff7f50UL },
773 : { { "cornflowerblue" }, 0x006495edUL },
774 : { { "cornsilk" }, 0x00fff8dcUL },
775 : { { "crimson" }, 0x00dc143cUL },
776 : { { "cyan" }, 0x0000ffffUL },
777 : { { "darkblue" }, 0x0000008bUL },
778 : { { "darkcyan" }, 0x00008b8bUL },
779 : { { "darkgoldenrod" }, 0x00b8860bUL },
780 : { { "darkgray" }, 0x00a9a9a9UL },
781 : { { "darkgreen" }, 0x00006400UL },
782 : { { "darkkhaki" }, 0x00bdb76bUL },
783 : { { "darkmagenta" }, 0x008b008bUL },
784 : { { "darkolivegreen" }, 0x00556b2fUL },
785 : { { "darkorange" }, 0x00ff8c00UL },
786 : { { "darkorchid" }, 0x009932ccUL },
787 : { { "darkred" }, 0x008b0000UL },
788 : { { "darksalmon" }, 0x00e9967aUL },
789 : { { "darkseagreen" }, 0x008fbc8fUL },
790 : { { "darkslateblue" }, 0x00483d8bUL },
791 : { { "darkslategray" }, 0x002f4f4fUL },
792 : { { "darkturquoise" }, 0x0000ced1UL },
793 : { { "darkviolet" }, 0x009400d3UL },
794 : { { "deeppink" }, 0x00ff1493UL },
795 : { { "deepskyblue" }, 0x0000bfffUL },
796 : { { "dimgray" }, 0x00696969UL },
797 : { { "dodgerblue" }, 0x001e90ffUL },
798 : { { "firebrick" }, 0x00b22222UL },
799 : { { "floralwhite" }, 0x00fffaf0UL },
800 : { { "forestgreen" }, 0x00228b22UL },
801 : { { "fuchsia" }, 0x00ff00ffUL },
802 : { { "gainsboro" }, 0x00dcdcdcUL },
803 : { { "ghostwhite" }, 0x00f8f8ffUL },
804 : { { "gold" }, 0x00ffd700UL },
805 : { { "goldenrod" }, 0x00daa520UL },
806 : { { "gray" }, 0x00808080UL },
807 : { { "green" }, 0x00008000UL },
808 : { { "greenyellow" }, 0x00adff2fUL },
809 : { { "honeydew" }, 0x00f0fff0UL },
810 : { { "hotpink" }, 0x00ff69b4UL },
811 : { { "indianred" }, 0x00cd5c5cUL },
812 : { { "indigo" }, 0x004b0082UL },
813 : { { "ivory" }, 0x00fffff0UL },
814 : { { "khaki" }, 0x00f0e68cUL },
815 : { { "lavender" }, 0x00e6e6faUL },
816 : { { "lavenderblush" }, 0x00fff0f5UL },
817 : { { "lawngreen" }, 0x007cfc00UL },
818 : { { "lemonchiffon" }, 0x00fffacdUL },
819 : { { "lightblue" }, 0x00add8e6UL },
820 : { { "lightcoral" }, 0x00f08080UL },
821 : { { "lightcyan" }, 0x00e0ffffUL },
822 : { { "lightgoldenrodyellow" }, 0x00fafad2UL },
823 : { { "lightgreen" }, 0x0090ee90UL },
824 : { { "lightgrey" }, 0x00d3d3d3UL },
825 : { { "lightpink" }, 0x00ffb6c1UL },
826 : { { "lightsalmon" }, 0x00ffa07aUL },
827 : { { "lightseagreen" }, 0x0020b2aaUL },
828 : { { "lightskyblue" }, 0x0087cefaUL },
829 : { { "lightslategray" }, 0x00778899UL },
830 : { { "lightsteelblue" }, 0x00b0c4deUL },
831 : { { "lightyellow" }, 0x00ffffe0UL },
832 : { { "lime" }, 0x0000ff00UL },
833 : { { "limegreen" }, 0x0032cd32UL },
834 : { { "linen" }, 0x00faf0e6UL },
835 : { { "magenta" }, 0x00ff00ffUL },
836 : { { "maroon" }, 0x00800000UL },
837 : { { "mediumaquamarine" }, 0x0066cdaaUL },
838 : { { "mediumblue" }, 0x000000cdUL },
839 : { { "mediumorchid" }, 0x00ba55d3UL },
840 : { { "mediumpurple" }, 0x009370dbUL },
841 : { { "mediumseagreen" }, 0x003cb371UL },
842 : { { "mediumslateblue" }, 0x007b68eeUL },
843 : { { "mediumspringgreen" }, 0x0000fa9aUL },
844 : { { "mediumturquoise" }, 0x0048d1ccUL },
845 : { { "mediumvioletred" }, 0x00c71585UL },
846 : { { "midnightblue" }, 0x00191970UL },
847 : { { "mintcream" }, 0x00f5fffaUL },
848 : { { "mistyrose" }, 0x00ffe4e1UL },
849 : { { "moccasin" }, 0x00ffe4b5UL },
850 : { { "navajowhite" }, 0x00ffdeadUL },
851 : { { "navy" }, 0x00000080UL },
852 : { { "oldlace" }, 0x00fdf5e6UL },
853 : { { "olive" }, 0x00808000UL },
854 : { { "olivedrab" }, 0x006b8e23UL },
855 : { { "orange" }, 0x00ffa500UL },
856 : { { "orangered" }, 0x00ff4500UL },
857 : { { "orchid" }, 0x00da70d6UL },
858 : { { "palegoldenrod" }, 0x00eee8aaUL },
859 : { { "palegreen" }, 0x0098fb98UL },
860 : { { "paleturquoise" }, 0x00afeeeeUL },
861 : { { "palevioletred" }, 0x00db7093UL },
862 : { { "papayawhip" }, 0x00ffefd5UL },
863 : { { "peachpuff" }, 0x00ffdab9UL },
864 : { { "peru" }, 0x00cd853fUL },
865 : { { "pink" }, 0x00ffc0cbUL },
866 : { { "plum" }, 0x00dda0ddUL },
867 : { { "powderblue" }, 0x00b0e0e6UL },
868 : { { "purple" }, 0x00800080UL },
869 : { { "red" }, 0x00ff0000UL },
870 : { { "rosybrown" }, 0x00bc8f8fUL },
871 : { { "royalblue" }, 0x004169e1UL },
872 : { { "saddlebrown" }, 0x008b4513UL },
873 : { { "salmon" }, 0x00fa8072UL },
874 : { { "sandybrown" }, 0x00f4a460UL },
875 : { { "seagreen" }, 0x002e8b57UL },
876 : { { "seashell" }, 0x00fff5eeUL },
877 : { { "sienna" }, 0x00a0522dUL },
878 : { { "silver" }, 0x00c0c0c0UL },
879 : { { "skyblue" }, 0x0087ceebUL },
880 : { { "slateblue" }, 0x006a5acdUL },
881 : { { "slategray" }, 0x00708090UL },
882 : { { "snow" }, 0x00fffafaUL },
883 : { { "springgreen" }, 0x0000ff7fUL },
884 : { { "steelblue" }, 0x004682b4UL },
885 : { { "tan" }, 0x00d2b48cUL },
886 : { { "teal" }, 0x00008080UL },
887 : { { "thistle" }, 0x00d8bfd8UL },
888 : { { "tomato" }, 0x00ff6347UL },
889 : { { "turquoise" }, 0x0040e0d0UL },
890 : { { "violet" }, 0x00ee82eeUL },
891 : { { "wheat" }, 0x00f5deb3UL },
892 : { { "white" }, 0x00ffffffUL },
893 : { { "whitesmoke" }, 0x00f5f5f5UL },
894 : { { "yellow" }, 0x00ffff00UL },
895 : { { "yellowgreen" }, 0x009acd32UL }
896 : };
897 :
898 : extern "C"
899 : {
900 :
901 0 : static int SAL_CALL HTMLColorNameCompare( const void *pFirst, const void *pSecond)
902 : {
903 0 : HTML_ColorEntry* pFirstEntry = (HTML_ColorEntry*)pFirst;
904 0 : HTML_ColorEntry* pSecondEntry = (HTML_ColorEntry*)pSecond;
905 0 : int nRet = 0;
906 0 : if( HTML_NO_COLOR == pFirstEntry->nColor )
907 : {
908 0 : if( HTML_NO_COLOR == pSecondEntry->nColor )
909 0 : nRet = pFirstEntry->pUName->compareTo( *pSecondEntry->pUName );
910 : else
911 0 : nRet = pFirstEntry->pUName->compareToAscii( pSecondEntry->sName );
912 : }
913 : else
914 : {
915 0 : if( HTML_NO_COLOR == pSecondEntry->nColor )
916 0 : nRet = -1 * pSecondEntry->pUName->compareToAscii( pFirstEntry->sName );
917 : else
918 0 : nRet = strcmp( pFirstEntry->sName, pSecondEntry->sName );
919 : }
920 :
921 0 : return nRet;
922 : }
923 :
924 : } // extern "C"
925 :
926 0 : sal_uInt32 GetHTMLColor( const OUString& rName )
927 : {
928 0 : if( !bSortColorKeyWords )
929 : {
930 : qsort( (void*) aHTMLColorNameTab,
931 : sizeof( aHTMLColorNameTab ) / sizeof( HTML_ColorEntry ),
932 : sizeof( HTML_ColorEntry ),
933 0 : HTMLColorNameCompare );
934 0 : bSortColorKeyWords = true;
935 : }
936 :
937 0 : sal_uInt32 nRet = HTML_NO_COLOR;
938 : void* pFound;
939 : HTML_ColorEntry aSrch;
940 0 : OUString aLowerCase(rName.toAsciiLowerCase());
941 :
942 0 : aSrch.pUName = &aLowerCase;
943 0 : aSrch.nColor = HTML_NO_COLOR;
944 :
945 0 : if( 0 != ( pFound = bsearch( (sal_Char *) &aSrch,
946 : (void*) aHTMLColorNameTab,
947 : sizeof( aHTMLColorNameTab) / sizeof( HTML_ColorEntry ),
948 : sizeof( HTML_ColorEntry ),
949 0 : HTMLColorNameCompare )))
950 0 : nRet = ((HTML_ColorEntry*)pFound)->nColor;
951 :
952 0 : return nRet;
953 : }
954 :
955 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|