1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
23 // Peter Bartok (pbartok@novell.com)
27 // This map is for convencience only, any app can create/use it's own
28 // StdCharCode -> <text> table
30 using System.Collections;
32 namespace System.Windows.Forms.RTF {
40 #region Local Variables
41 private string[] table;
42 #endregion // Local Variables
44 #region Public Constructors
46 table = new string[(int)StandardCharCode.MaxChar];
48 for (int i = 0; i < (int)StandardCharCode.MaxChar; i++) {
49 table[i] = string.Empty;
52 #endregion // Public Constructors
54 #region Public Instance Properties
55 internal string this[StandardCharCode c] { // FIXME - this should be public, if the whole namespace was public (ie standalone RTF parser)
61 table[(int)c] = value;
65 public string[] Table {
70 #endregion // Public Instance Properties
72 #region Public Static Methods
73 public static void SetupStandardTable(string[] table)
76 table[(int)StandardCharCode.space] = " ";
77 table[(int)StandardCharCode.exclam] = "!";
78 table[(int)StandardCharCode.quotedbl] = "\"";
79 table[(int)StandardCharCode.numbersign] = "#";
80 table[(int)StandardCharCode.dollar] = "$";
81 table[(int)StandardCharCode.percent] = "%";
82 table[(int)StandardCharCode.ampersand] = "&";
83 table[(int)StandardCharCode.quoteright] = "'";
84 table[(int)StandardCharCode.parenleft] = "(";
85 table[(int)StandardCharCode.parenright] = ")";
86 table[(int)StandardCharCode.asterisk] = "*";
87 table[(int)StandardCharCode.plus] = "+";
88 table[(int)StandardCharCode.comma] = ",";
89 table[(int)StandardCharCode.hyphen] = "-";
90 table[(int)StandardCharCode.period] = ".";
91 table[(int)StandardCharCode.slash] = "/";
92 table[(int)StandardCharCode.zero] = "0";
93 table[(int)StandardCharCode.one] = "1";
94 table[(int)StandardCharCode.two] = "2";
95 table[(int)StandardCharCode.three] = "3";
96 table[(int)StandardCharCode.four] = "4";
97 table[(int)StandardCharCode.five] = "5";
98 table[(int)StandardCharCode.six] = "6";
99 table[(int)StandardCharCode.seven] = "7";
100 table[(int)StandardCharCode.eight] = "8";
101 table[(int)StandardCharCode.nine] = "9";
102 table[(int)StandardCharCode.colon] = ":";
103 table[(int)StandardCharCode.semicolon] = ";";
104 table[(int)StandardCharCode.less] = "<";
105 table[(int)StandardCharCode.equal] = "=";
106 table[(int)StandardCharCode.greater] = ">";
107 table[(int)StandardCharCode.question] = "?";
108 table[(int)StandardCharCode.at] = "@";
109 table[(int)StandardCharCode.A] = "A";
110 table[(int)StandardCharCode.B] = "B";
111 table[(int)StandardCharCode.C] = "C";
112 table[(int)StandardCharCode.D] = "D";
113 table[(int)StandardCharCode.E] = "E";
114 table[(int)StandardCharCode.F] = "F";
115 table[(int)StandardCharCode.G] = "G";
116 table[(int)StandardCharCode.H] = "H";
117 table[(int)StandardCharCode.I] = "I";
118 table[(int)StandardCharCode.J] = "J";
119 table[(int)StandardCharCode.K] = "K";
120 table[(int)StandardCharCode.L] = "L";
121 table[(int)StandardCharCode.M] = "M";
122 table[(int)StandardCharCode.N] = "N";
123 table[(int)StandardCharCode.O] = "O";
124 table[(int)StandardCharCode.P] = "P";
125 table[(int)StandardCharCode.Q] = "Q";
126 table[(int)StandardCharCode.R] = "R";
127 table[(int)StandardCharCode.S] = "S";
128 table[(int)StandardCharCode.T] = "T";
129 table[(int)StandardCharCode.U] = "U";
130 table[(int)StandardCharCode.V] = "V";
131 table[(int)StandardCharCode.W] = "W";
132 table[(int)StandardCharCode.X] = "X";
133 table[(int)StandardCharCode.Y] = "Y";
134 table[(int)StandardCharCode.Z] = "Z";
135 table[(int)StandardCharCode.bracketleft] = "[";
136 table[(int)StandardCharCode.backslash] = "\\";
137 table[(int)StandardCharCode.bracketright] = "]";
138 table[(int)StandardCharCode.asciicircum] = "^";
139 table[(int)StandardCharCode.underscore] = "_";
140 table[(int)StandardCharCode.quoteleft] = "`";
141 table[(int)StandardCharCode.a] = "a";
142 table[(int)StandardCharCode.b] = "b";
143 table[(int)StandardCharCode.c] = "c";
144 table[(int)StandardCharCode.d] = "d";
145 table[(int)StandardCharCode.e] = "e";
146 table[(int)StandardCharCode.f] = "f";
147 table[(int)StandardCharCode.g] = "g";
148 table[(int)StandardCharCode.h] = "h";
149 table[(int)StandardCharCode.i] = "i";
150 table[(int)StandardCharCode.j] = "j";
151 table[(int)StandardCharCode.k] = "k";
152 table[(int)StandardCharCode.l] = "l";
153 table[(int)StandardCharCode.m] = "m";
154 table[(int)StandardCharCode.n] = "n";
155 table[(int)StandardCharCode.o] = "o";
156 table[(int)StandardCharCode.p] = "p";
157 table[(int)StandardCharCode.q] = "q";
158 table[(int)StandardCharCode.r] = "r";
159 table[(int)StandardCharCode.s] = "s";
160 table[(int)StandardCharCode.t] = "t";
161 table[(int)StandardCharCode.u] = "u";
162 table[(int)StandardCharCode.v] = "v";
163 table[(int)StandardCharCode.w] = "w";
164 table[(int)StandardCharCode.x] = "x";
165 table[(int)StandardCharCode.y] = "y";
166 table[(int)StandardCharCode.z] = "z";
167 table[(int)StandardCharCode.braceleft] = "{";
168 table[(int)StandardCharCode.bar] = "|";
169 table[(int)StandardCharCode.braceright] = "}";
170 table[(int)StandardCharCode.asciitilde] = "~";
171 table[(int)StandardCharCode.AE] = "AE";
172 table[(int)StandardCharCode.OE] = "OE";
173 table[(int)StandardCharCode.acute] = "'";
174 table[(int)StandardCharCode.ae] = "ae";
175 table[(int)StandardCharCode.angleleft] = "<";
176 table[(int)StandardCharCode.angleright] = ">";
177 table[(int)StandardCharCode.arrowboth] = "<->";
178 table[(int)StandardCharCode.arrowdblboth] = "<=>";
179 table[(int)StandardCharCode.arrowdblleft] = "<=";
180 table[(int)StandardCharCode.arrowdblright] = "=>";
181 table[(int)StandardCharCode.arrowleft] = "<-";
182 table[(int)StandardCharCode.arrowright] = "->";
183 table[(int)StandardCharCode.bullet] = "o";
184 table[(int)StandardCharCode.cent] = "cent";
185 table[(int)StandardCharCode.circumflex] = "^";
186 table[(int)StandardCharCode.copyright] = "(c)";
187 table[(int)StandardCharCode.copyrightsans] = "(c)";
188 table[(int)StandardCharCode.degree] = "deg.";
189 table[(int)StandardCharCode.divide] = "/";
190 table[(int)StandardCharCode.dotlessi] = "i";
191 table[(int)StandardCharCode.ellipsis] = "...";
192 table[(int)StandardCharCode.emdash] = "--";
193 table[(int)StandardCharCode.endash] = "-";
194 table[(int)StandardCharCode.fi] = "fi";
195 table[(int)StandardCharCode.fl] = "fl";
196 table[(int)StandardCharCode.fraction] = "/";
197 table[(int)StandardCharCode.germandbls] = "ss";
198 table[(int)StandardCharCode.grave] = "`";
199 table[(int)StandardCharCode.greaterequal] = ">=";
200 table[(int)StandardCharCode.guillemotleft] = "<<";
201 table[(int)StandardCharCode.guillemotright] = ">>";
202 table[(int)StandardCharCode.guilsinglleft] = "<";
203 table[(int)StandardCharCode.guilsinglright] = ">";
204 table[(int)StandardCharCode.lessequal] = "<=";
205 table[(int)StandardCharCode.logicalnot] = "~";
206 table[(int)StandardCharCode.mathasterisk] = "*";
207 table[(int)StandardCharCode.mathequal] = "=";
208 table[(int)StandardCharCode.mathminus] = "-";
209 table[(int)StandardCharCode.mathnumbersign] = "#";
210 table[(int)StandardCharCode.mathplus] = "+";
211 table[(int)StandardCharCode.mathtilde] = "~";
212 table[(int)StandardCharCode.minus] = "-";
213 table[(int)StandardCharCode.mu] = "u";
214 table[(int)StandardCharCode.multiply] = "x";
215 table[(int)StandardCharCode.nobrkhyphen] = "-";
216 table[(int)StandardCharCode.nobrkspace] = "";
217 table[(int)StandardCharCode.notequal] = "!=";
218 table[(int)StandardCharCode.oe] = "oe";
219 table[(int)StandardCharCode.onehalf] = "1/2";
220 table[(int)StandardCharCode.onequarter] = "1/4";
221 table[(int)StandardCharCode.periodcentered] = ".";
222 table[(int)StandardCharCode.plusminus] = "+/-";
223 table[(int)StandardCharCode.quotedblbase] = ",,";
224 table[(int)StandardCharCode.quotedblleft] = "\"";
225 table[(int)StandardCharCode.quotedblright] = "\"";
226 table[(int)StandardCharCode.quotesinglbase] = ",";
227 table[(int)StandardCharCode.registered] = "reg.";
228 table[(int)StandardCharCode.registersans] = "reg.";
229 table[(int)StandardCharCode.threequarters] = "3/4";
230 table[(int)StandardCharCode.tilde] = "~";
231 table[(int)StandardCharCode.trademark] = "(TM)";
232 table[(int)StandardCharCode.trademarksans] = "(TM)";
234 table[(int)StandardCharCode.aacute] = "\xE0";
235 table[(int)StandardCharCode.questiondown] = "\xBF";
237 table[(int)StandardCharCode.udieresis] = "\xFC";
238 table[(int)StandardCharCode.Udieresis] = "\xDC";
239 table[(int)StandardCharCode.odieresis] = "\xF6";
240 table[(int)StandardCharCode.Odieresis] = "\xD6";
243 table [(int) StandardCharCode.formula] = "\x6";
244 table [(int) StandardCharCode.nobrkhyphen] = "\x1e";
245 table [(int) StandardCharCode.opthyphen] = "\x1f";
246 table [(int) StandardCharCode.space] = " ";
247 table [(int) StandardCharCode.exclam] = "!";
248 table [(int) StandardCharCode.quotedbl] = "\"";
249 table [(int) StandardCharCode.numbersign] = "#";
250 table [(int) StandardCharCode.dollar] = "$";
251 table [(int) StandardCharCode.percent] = "%";
252 table [(int) StandardCharCode.ampersand] = "&";
253 table [(int) StandardCharCode.parenleft] = "(";
254 table [(int) StandardCharCode.parenright] = ")";
255 table [(int) StandardCharCode.asterisk] = "*";
256 table [(int) StandardCharCode.plus] = "+";
257 table [(int) StandardCharCode.comma] = ",";
258 table [(int) StandardCharCode.hyphen] = "-";
259 table [(int) StandardCharCode.period] = ".";
260 table [(int) StandardCharCode.slash] = "/";
261 table [(int) StandardCharCode.zero] = "0";
262 table [(int) StandardCharCode.one] = "1";
263 table [(int) StandardCharCode.two] = "2";
264 table [(int) StandardCharCode.three] = "3";
265 table [(int) StandardCharCode.four] = "4";
266 table [(int) StandardCharCode.five] = "5";
267 table [(int) StandardCharCode.six] = "6";
268 table [(int) StandardCharCode.seven] = "7";
269 table [(int) StandardCharCode.eight] = "8";
270 table [(int) StandardCharCode.nine] = "9";
271 table [(int) StandardCharCode.colon] = ":";
272 table [(int) StandardCharCode.semicolon] = ";";
273 table [(int) StandardCharCode.less] = "<";
274 table [(int) StandardCharCode.equal] = "=";
275 table [(int) StandardCharCode.greater] = ">";
276 table [(int) StandardCharCode.question] = "?";
277 table [(int) StandardCharCode.at] = "@";
278 table [(int) StandardCharCode.A] = "A";
279 table [(int) StandardCharCode.B] = "B";
280 table [(int) StandardCharCode.C] = "C";
281 table [(int) StandardCharCode.D] = "D";
282 table [(int) StandardCharCode.E] = "E";
283 table [(int) StandardCharCode.F] = "F";
284 table [(int) StandardCharCode.G] = "G";
285 table [(int) StandardCharCode.H] = "H";
286 table [(int) StandardCharCode.I] = "I";
287 table [(int) StandardCharCode.J] = "J";
288 table [(int) StandardCharCode.K] = "K";
289 table [(int) StandardCharCode.L] = "L";
290 table [(int) StandardCharCode.M] = "M";
291 table [(int) StandardCharCode.N] = "N";
292 table [(int) StandardCharCode.O] = "O";
293 table [(int) StandardCharCode.P] = "P";
294 table [(int) StandardCharCode.Q] = "Q";
295 table [(int) StandardCharCode.R] = "R";
296 table [(int) StandardCharCode.S] = "S";
297 table [(int) StandardCharCode.T] = "T";
298 table [(int) StandardCharCode.U] = "U";
299 table [(int) StandardCharCode.V] = "V";
300 table [(int) StandardCharCode.W] = "W";
301 table [(int) StandardCharCode.X] = "X";
302 table [(int) StandardCharCode.Y] = "Y";
303 table [(int) StandardCharCode.Z] = "Z";
304 table [(int) StandardCharCode.bracketleft] = "[";
305 table [(int) StandardCharCode.backslash] = "\\";
306 table [(int) StandardCharCode.bracketright] = "]";
307 table [(int) StandardCharCode.asciicircum] = "^";
308 table [(int) StandardCharCode.underscore] = "_";
309 table [(int) StandardCharCode.quoteleft] = "`";
310 table [(int) StandardCharCode.a] = "a";
311 table [(int) StandardCharCode.b] = "b";
312 table [(int) StandardCharCode.c] = "c";
313 table [(int) StandardCharCode.d] = "d";
314 table [(int) StandardCharCode.e] = "e";
315 table [(int) StandardCharCode.f] = "f";
316 table [(int) StandardCharCode.g] = "g";
317 table [(int) StandardCharCode.h] = "h";
318 table [(int) StandardCharCode.i] = "i";
319 table [(int) StandardCharCode.j] = "j";
320 table [(int) StandardCharCode.k] = "k";
321 table [(int) StandardCharCode.l] = "l";
322 table [(int) StandardCharCode.m] = "m";
323 table [(int) StandardCharCode.n] = "n";
324 table [(int) StandardCharCode.o] = "o";
325 table [(int) StandardCharCode.p] = "p";
326 table [(int) StandardCharCode.q] = "q";
327 table [(int) StandardCharCode.r] = "r";
328 table [(int) StandardCharCode.s] = "s";
329 table [(int) StandardCharCode.t] = "t";
330 table [(int) StandardCharCode.u] = "u";
331 table [(int) StandardCharCode.v] = "v";
332 table [(int) StandardCharCode.w] = "w";
333 table [(int) StandardCharCode.x] = "x";
334 table [(int) StandardCharCode.y] = "y";
335 table [(int) StandardCharCode.z] = "z";
336 table [(int) StandardCharCode.braceleft] = "{";
337 table [(int) StandardCharCode.bar] = "|";
338 table [(int) StandardCharCode.braceright] = "}";
339 table [(int) StandardCharCode.asciitilde] = "~";
340 table [(int) StandardCharCode.nobrkspace] = "\xa0";
341 table [(int) StandardCharCode.exclamdown] = "\xa1";
342 table [(int) StandardCharCode.cent] = "\xa2";
343 table [(int) StandardCharCode.sterling] = "\xa3";
344 table [(int) StandardCharCode.currency] = "\xa4";
345 table [(int) StandardCharCode.yen] = "\xa5";
346 table [(int) StandardCharCode.brokenbar] = "\xa6";
347 table [(int) StandardCharCode.section] = "\xa7";
348 table [(int) StandardCharCode.dieresis] = "\xa8";
349 table [(int) StandardCharCode.copyright] = "\xa9";
350 table [(int) StandardCharCode.ordfeminine] = "\xaa";
351 table [(int) StandardCharCode.guillemotleft] = "\xab";
352 table [(int) StandardCharCode.logicalnot] = "\xac";
353 table [(int) StandardCharCode.opthyphen] = "\xad";
354 table [(int) StandardCharCode.registered] = "\xae";
355 table [(int) StandardCharCode.macron] = "\xaf";
356 table [(int) StandardCharCode.degree] = "\xb0";
357 table [(int) StandardCharCode.plusminus] = "\xb1";
358 table [(int) StandardCharCode.twosuperior] = "\xb2";
359 table [(int) StandardCharCode.threesuperior] = "\xb3";
360 table [(int) StandardCharCode.acute] = "\xb4";
361 table [(int) StandardCharCode.mu] = "\xb5";
362 table [(int) StandardCharCode.paragraph] = "\xb6";
363 table [(int) StandardCharCode.periodcentered] = "\xb7";
364 table [(int) StandardCharCode.cedilla] = "\xb8";
365 table [(int) StandardCharCode.onesuperior] = "\xb9";
366 table [(int) StandardCharCode.ordmasculine] = "\xba";
367 table [(int) StandardCharCode.guillemotright] = "\xbb";
368 table [(int) StandardCharCode.onequarter] = "\xbc";
369 table [(int) StandardCharCode.onehalf] = "\xbd";
370 table [(int) StandardCharCode.threequarters] = "\xbe";
371 table [(int) StandardCharCode.questiondown] = "\xbf";
372 table [(int) StandardCharCode.Agrave] = "\xc0";
373 table [(int) StandardCharCode.Aacute] = "\xc1";
374 table [(int) StandardCharCode.Acircumflex] = "\xc2";
375 table [(int) StandardCharCode.Atilde] = "\xc3";
376 table [(int) StandardCharCode.Adieresis] = "\xc4";
377 table [(int) StandardCharCode.Aring] = "\xc5";
378 table [(int) StandardCharCode.AE] = "\xc6";
379 table [(int) StandardCharCode.Ccedilla] = "\xc7";
380 table [(int) StandardCharCode.Egrave] = "\xc8";
381 table [(int) StandardCharCode.Eacute] = "\xc9";
382 table [(int) StandardCharCode.Ecircumflex] = "\xca";
383 table [(int) StandardCharCode.Edieresis] = "\xcb";
384 table [(int) StandardCharCode.Igrave] = "\xcc";
385 table [(int) StandardCharCode.Iacute] = "\xcd";
386 table [(int) StandardCharCode.Icircumflex] = "\xce";
387 table [(int) StandardCharCode.Idieresis] = "\xcf";
388 table [(int) StandardCharCode.Eth] = "\xd0";
389 table [(int) StandardCharCode.Ntilde] = "\xd1";
390 table [(int) StandardCharCode.Ograve] = "\xd2";
391 table [(int) StandardCharCode.Oacute] = "\xd3";
392 table [(int) StandardCharCode.Ocircumflex] = "\xd4";
393 table [(int) StandardCharCode.Otilde] = "\xd5";
394 table [(int) StandardCharCode.Odieresis] = "\xd6";
395 table [(int) StandardCharCode.multiply] = "\xd7";
396 table [(int) StandardCharCode.Oslash] = "\xd8";
397 table [(int) StandardCharCode.Ugrave] = "\xd9";
398 table [(int) StandardCharCode.Uacute] = "\xda";
399 table [(int) StandardCharCode.Ucircumflex] = "\xdb";
400 table [(int) StandardCharCode.Udieresis] = "\xdc";
401 table [(int) StandardCharCode.Yacute] = "\xdd";
402 table [(int) StandardCharCode.Thorn] = "\xde";
403 table [(int) StandardCharCode.germandbls] = "\xdf";
404 table [(int) StandardCharCode.agrave] = "\xe0";
405 table [(int) StandardCharCode.aacute] = "\xe1";
406 table [(int) StandardCharCode.acircumflex] = "\xe2";
407 table [(int) StandardCharCode.atilde] = "\xe3";
408 table [(int) StandardCharCode.adieresis] = "\xe4";
409 table [(int) StandardCharCode.aring] = "\xe5";
410 table [(int) StandardCharCode.ae] = "\xe6";
411 table [(int) StandardCharCode.ccedilla] = "\xe7";
412 table [(int) StandardCharCode.egrave] = "\xe8";
413 table [(int) StandardCharCode.eacute] = "\xe9";
414 table [(int) StandardCharCode.ecircumflex] = "\xea";
415 table [(int) StandardCharCode.edieresis] = "\xeb";
416 table [(int) StandardCharCode.igrave] = "\xec";
417 table [(int) StandardCharCode.iacute] = "\xed";
418 table [(int) StandardCharCode.icircumflex] = "\xee";
419 table [(int) StandardCharCode.idieresis] = "\xef";
420 table [(int) StandardCharCode.eth] = "\xf0";
421 table [(int) StandardCharCode.ntilde] = "\xf1";
422 table [(int) StandardCharCode.ograve] = "\xf2";
423 table [(int) StandardCharCode.oacute] = "\xf3";
424 table [(int) StandardCharCode.ocircumflex] = "\xf4";
425 table [(int) StandardCharCode.otilde] = "\xf5";
426 table [(int) StandardCharCode.odieresis] = "\xf6";
427 table [(int) StandardCharCode.divide] = "\xf7";
428 table [(int) StandardCharCode.oslash] = "\xf8";
429 table [(int) StandardCharCode.ugrave] = "\xf9";
430 table [(int) StandardCharCode.uacute] = "\xfa";
431 table [(int) StandardCharCode.ucircumflex] = "\xfb";
432 table [(int) StandardCharCode.udieresis] = "\xfc";
433 table [(int) StandardCharCode.yacute] = "\xfd";
434 table [(int) StandardCharCode.thorn] = "\xfe";
435 table [(int) StandardCharCode.ydieresis] = "\xff";
438 #endregion // Public Static Methods