TextMap.cs 9.2 KB

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