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