* Initial check-in of RTF parser required for RichTextBox control
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms.RTF / TextMap.cs
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:
8 // 
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 // 
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.
19 //
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
21 //
22 // Authors:
23 //      Peter Bartok    (pbartok@novell.com)
24 //
25 //
26
27 // This map is for convencience only, any app can create/use it's own
28 // StdCharCode -> <text> table
29
30 using System.Collections;
31
32 namespace System.Windows.Forms.RTF {
33         internal class TextMap {
34                 #region Local Variables
35                 private string[]                table;
36                 #endregion      // Local Variables
37
38                 #region Public Constructors
39                 public TextMap() {
40                         table = new string[(int)StandardCharCode.MaxChar];
41
42                         for (int i = 0; i < (int)StandardCharCode.MaxChar; i++) {
43                                 table[i] = string.Empty;
44                         }
45                 }
46                 #endregion      // Public Constructors
47
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)
50                         get {
51                                 return table[(int)c];
52                         }
53
54                         set {
55                                 table[(int)c] = value;
56                         }
57                 }
58
59                 public string[] Table {
60                         get {
61                                 return table;
62                         }
63                 }
64                 #endregion      // Public Instance Properties
65
66                 #region Public Static Methods
67                 public static void SetupStandardTable(string[] table) {
68                         table[(int)StandardCharCode.space] = " ";
69                         table[(int)StandardCharCode.exclam] = "!";
70                         table[(int)StandardCharCode.quotedbl] = "\"";
71                         table[(int)StandardCharCode.numbersign] = "#";
72                         table[(int)StandardCharCode.dollar] = "$";
73                         table[(int)StandardCharCode.percent] = "%";
74                         table[(int)StandardCharCode.ampersand] = "&";
75                         table[(int)StandardCharCode.quoteright] = "'";
76                         table[(int)StandardCharCode.parenleft] = "(";
77                         table[(int)StandardCharCode.parenright] = ")";
78                         table[(int)StandardCharCode.asterisk] = "*";
79                         table[(int)StandardCharCode.plus] = "+";
80                         table[(int)StandardCharCode.comma] = ",";
81                         table[(int)StandardCharCode.hyphen] = "-";
82                         table[(int)StandardCharCode.period] = ".";
83                         table[(int)StandardCharCode.slash] = "/";
84                         table[(int)StandardCharCode.zero] = "0";
85                         table[(int)StandardCharCode.one] = "1";
86                         table[(int)StandardCharCode.two] = "2";
87                         table[(int)StandardCharCode.three] = "3";
88                         table[(int)StandardCharCode.four] = "4";
89                         table[(int)StandardCharCode.five] = "5";
90                         table[(int)StandardCharCode.six] = "6";
91                         table[(int)StandardCharCode.seven] = "7";
92                         table[(int)StandardCharCode.eight] = "8";
93                         table[(int)StandardCharCode.nine] = "9";
94                         table[(int)StandardCharCode.colon] = ":";
95                         table[(int)StandardCharCode.semicolon] = ";";
96                         table[(int)StandardCharCode.less] = "<";
97                         table[(int)StandardCharCode.equal] = "=";
98                         table[(int)StandardCharCode.greater] = ">";
99                         table[(int)StandardCharCode.question] = "?";
100                         table[(int)StandardCharCode.at] = "@";
101                         table[(int)StandardCharCode.A] = "A";
102                         table[(int)StandardCharCode.B] = "B";
103                         table[(int)StandardCharCode.C] = "C";
104                         table[(int)StandardCharCode.D] = "D";
105                         table[(int)StandardCharCode.E] = "E";
106                         table[(int)StandardCharCode.F] = "F";
107                         table[(int)StandardCharCode.G] = "G";
108                         table[(int)StandardCharCode.H] = "H";
109                         table[(int)StandardCharCode.I] = "I";
110                         table[(int)StandardCharCode.J] = "J";
111                         table[(int)StandardCharCode.K] = "K";
112                         table[(int)StandardCharCode.L] = "L";
113                         table[(int)StandardCharCode.M] = "M";
114                         table[(int)StandardCharCode.N] = "N";
115                         table[(int)StandardCharCode.O] = "O";
116                         table[(int)StandardCharCode.P] = "P";
117                         table[(int)StandardCharCode.Q] = "Q";
118                         table[(int)StandardCharCode.R] = "R";
119                         table[(int)StandardCharCode.S] = "S";
120                         table[(int)StandardCharCode.T] = "T";
121                         table[(int)StandardCharCode.U] = "U";
122                         table[(int)StandardCharCode.V] = "V";
123                         table[(int)StandardCharCode.W] = "W";
124                         table[(int)StandardCharCode.X] = "X";
125                         table[(int)StandardCharCode.Y] = "Y";
126                         table[(int)StandardCharCode.Z] = "Z";
127                         table[(int)StandardCharCode.bracketleft] = "[";
128                         table[(int)StandardCharCode.backslash] = "\\";
129                         table[(int)StandardCharCode.bracketright] = "]";
130                         table[(int)StandardCharCode.asciicircum] = "^";
131                         table[(int)StandardCharCode.underscore] = "_";
132                         table[(int)StandardCharCode.quoteleft] = "`";
133                         table[(int)StandardCharCode.a] = "a";
134                         table[(int)StandardCharCode.b] = "b";
135                         table[(int)StandardCharCode.c] = "c";
136                         table[(int)StandardCharCode.d] = "d";
137                         table[(int)StandardCharCode.e] = "e";
138                         table[(int)StandardCharCode.f] = "f";
139                         table[(int)StandardCharCode.g] = "g";
140                         table[(int)StandardCharCode.h] = "h";
141                         table[(int)StandardCharCode.i] = "i";
142                         table[(int)StandardCharCode.j] = "j";
143                         table[(int)StandardCharCode.k] = "k";
144                         table[(int)StandardCharCode.l] = "l";
145                         table[(int)StandardCharCode.m] = "m";
146                         table[(int)StandardCharCode.n] = "n";
147                         table[(int)StandardCharCode.o] = "o";
148                         table[(int)StandardCharCode.p] = "p";
149                         table[(int)StandardCharCode.q] = "q";
150                         table[(int)StandardCharCode.r] = "r";
151                         table[(int)StandardCharCode.s] = "s";
152                         table[(int)StandardCharCode.t] = "t";
153                         table[(int)StandardCharCode.u] = "u";
154                         table[(int)StandardCharCode.v] = "v";
155                         table[(int)StandardCharCode.w] = "w";
156                         table[(int)StandardCharCode.x] = "x";
157                         table[(int)StandardCharCode.y] = "y";
158                         table[(int)StandardCharCode.z] = "z";
159                         table[(int)StandardCharCode.braceleft] = "{";
160                         table[(int)StandardCharCode.bar] = "|";
161                         table[(int)StandardCharCode.braceright] = "}";
162                         table[(int)StandardCharCode.asciitilde] = "~";
163                         table[(int)StandardCharCode.AE] = "AE";
164                         table[(int)StandardCharCode.OE] = "OE";
165                         table[(int)StandardCharCode.acute] = "'";
166                         table[(int)StandardCharCode.ae] = "ae";
167                         table[(int)StandardCharCode.angleleft] = "<";
168                         table[(int)StandardCharCode.angleright] = ">";
169                         table[(int)StandardCharCode.arrowboth] = "<->";
170                         table[(int)StandardCharCode.arrowdblboth] = "<=>";
171                         table[(int)StandardCharCode.arrowdblleft] = "<=";
172                         table[(int)StandardCharCode.arrowdblright] = "=>";
173                         table[(int)StandardCharCode.arrowleft] = "<-";
174                         table[(int)StandardCharCode.arrowright] = "->";
175                         table[(int)StandardCharCode.bullet] = "o";
176                         table[(int)StandardCharCode.cent] = "cent";
177                         table[(int)StandardCharCode.circumflex] = "^";
178                         table[(int)StandardCharCode.copyright] = "(c)";
179                         table[(int)StandardCharCode.copyrightsans] = "(c)";
180                         table[(int)StandardCharCode.degree] = "deg.";
181                         table[(int)StandardCharCode.divide] = "/";
182                         table[(int)StandardCharCode.dotlessi] = "i";
183                         table[(int)StandardCharCode.ellipsis] = "...";
184                         table[(int)StandardCharCode.emdash] = "--";
185                         table[(int)StandardCharCode.endash] = "-";
186                         table[(int)StandardCharCode.fi] = "fi";
187                         table[(int)StandardCharCode.fl] = "fl";
188                         table[(int)StandardCharCode.fraction] = "/";
189                         table[(int)StandardCharCode.germandbls] = "ss";
190                         table[(int)StandardCharCode.grave] = "`";
191                         table[(int)StandardCharCode.greaterequal] = ">=";
192                         table[(int)StandardCharCode.guillemotleft] = "<<";
193                         table[(int)StandardCharCode.guillemotright] = ">>";
194                         table[(int)StandardCharCode.guilsinglleft] = "<";
195                         table[(int)StandardCharCode.guilsinglright] = ">";
196                         table[(int)StandardCharCode.lessequal] = "<=";
197                         table[(int)StandardCharCode.logicalnot] = "~";
198                         table[(int)StandardCharCode.mathasterisk] = "*";
199                         table[(int)StandardCharCode.mathequal] = "=";
200                         table[(int)StandardCharCode.mathminus] = "-";
201                         table[(int)StandardCharCode.mathnumbersign] = "#";
202                         table[(int)StandardCharCode.mathplus] = "+";
203                         table[(int)StandardCharCode.mathtilde] = "~";
204                         table[(int)StandardCharCode.minus] = "-";
205                         table[(int)StandardCharCode.mu] = "u";
206                         table[(int)StandardCharCode.multiply] = "x";
207                         table[(int)StandardCharCode.nobrkhyphen] = "-";
208                         table[(int)StandardCharCode.nobrkspace] = "";
209                         table[(int)StandardCharCode.notequal] = "!=";
210                         table[(int)StandardCharCode.oe] = "oe";
211                         table[(int)StandardCharCode.onehalf] = "1/2";
212                         table[(int)StandardCharCode.onequarter] = "1/4";
213                         table[(int)StandardCharCode.periodcentered] = ".";
214                         table[(int)StandardCharCode.plusminus] = "+/-";
215                         table[(int)StandardCharCode.quotedblbase] = ",,";
216                         table[(int)StandardCharCode.quotedblleft] = "\"";
217                         table[(int)StandardCharCode.quotedblright] = "\"";
218                         table[(int)StandardCharCode.quotesinglbase] = ",";
219                         table[(int)StandardCharCode.registered] = "reg.";
220                         table[(int)StandardCharCode.registersans] = "reg.";
221                         table[(int)StandardCharCode.threequarters] = "3/4";
222                         table[(int)StandardCharCode.tilde] = "~";
223                         table[(int)StandardCharCode.trademark] = "(TM)";
224                         table[(int)StandardCharCode.trademarksans] = "(TM)";
225                 }
226                 #endregion      // Public Static Methods
227         }
228 }