Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

392 lines
12 KiB

  1. /*
  2. * tokens.cpp
  3. *
  4. * The sorted table of strings and token values
  5. *
  6. * Note: if you insert new keywords, be sure to insert the corresponding
  7. * i_keyword in the i_xxx enum in tokens.h. This enum defines the
  8. * indices used by RTFWrit to output RTF control words.
  9. *
  10. * Original RichEdit 1.0 RTF converter: Anthony Francisco
  11. * Conversion to C++ and RichEdit 2.0: Murray Sargent
  12. *
  13. * Copyright (c) 1995-2000 Microsoft Corporation. All rights reserved.
  14. */
  15. #include "_common.h"
  16. #include "tokens.h"
  17. extern const KEYWORD rgKeyword[] =
  18. {
  19. {"adeff", tokenDefaultBiDiFont},
  20. {"af", tokenAssocFontSelect},
  21. {"afs", tokenAssocFontSize},
  22. {"animtext", tokenAnimText},
  23. {"ansi", tokenCharSetAnsi},
  24. {"ansicpg", tokenAnsiCodePage},
  25. {"b", tokenBold},
  26. {"background", tokenBackground},
  27. {"bgbdiag", tokenBckgrndBckDiag},
  28. {"bgcross", tokenBckgrndCross},
  29. {"bgdcross", tokenBckgrndDiagCross},
  30. {"bgdkbdiag", tokenBckgrndDrkBckDiag},
  31. {"bgdkcross", tokenBckgrndDrkCross},
  32. {"bgdkdcross", tokenBckgrndDrkDiagCross},
  33. {"bgdkfdiag", tokenBckgrndDrkFwdDiag},
  34. {"bgdkhoriz", tokenBckgrndDrkHoriz},
  35. {"bgdkvert", tokenBckgrndDrkVert},
  36. {"bgfdiag", tokenBckgrndFwdDiag},
  37. {"bghoriz", tokenBckgrndHoriz},
  38. {"bgvert", tokenBckgrndVert},
  39. {"bin", tokenBinaryData},
  40. {"blue", tokenColorBlue},
  41. {"box", tokenBox},
  42. {"brdrb", tokenBorderBottom},
  43. {"brdrbar", tokenBorderOutside},
  44. {"brdrbtw", tokenBorderBetween},
  45. {"brdrcf", tokenBorderColor},
  46. {"brdrdash", tokenBorderDash},
  47. {"brdrdashsm", tokenBorderDashSmall},
  48. {"brdrdb", tokenBorderDouble},
  49. {"brdrdot", tokenBorderDot},
  50. {"brdrhair", tokenBorderHairline},
  51. {"brdrl", tokenBorderLeft},
  52. {"brdrr", tokenBorderRight},
  53. {"brdrs", tokenBorderSingleThick},
  54. {"brdrsh", tokenBorderShadow},
  55. {"brdrt", tokenBorderTop},
  56. {"brdrth", tokenBorderDoubleThick},
  57. {"brdrtriple", tokenBorderTriple},
  58. {"brdrw", tokenBorderWidth},
  59. {"brsp", tokenBorderSpace},
  60. {"bullet", BULLET},
  61. {"caps", tokenCaps},
  62. {"cbpat", tokenColorBckgrndPat},
  63. {"cell", tokenCell},
  64. {"cellx", tokenCellX},
  65. {"cf", tokenColorForeground},
  66. {"cfpat", tokenColorForgrndPat},
  67. {"clbrdrb", tokenCellBorderBottom},
  68. {"clbrdrl", tokenCellBorderLeft},
  69. {"clbrdrr", tokenCellBorderRight},
  70. {"clbrdrt", tokenCellBorderTop},
  71. {"clcbpat", tokenCellBackColor},
  72. {"clcfpat", tokenCellForeColor},
  73. {"clshdng", tokenCellShading},
  74. {"cltxlrtb", tokenCellLRTB},
  75. {"cltxtbrlv", tokenCellTopBotRLVert},
  76. {"clvertalb", tokenCellAlignBottom},
  77. {"clvertalc", tokenCellAlignCenter},
  78. {"clvmgf", tokenCellMergeDown},
  79. {"clvmrg", tokenCellMergeUp},
  80. {"collapsed", tokenCollapsed},
  81. {"colortbl", tokenColorTable},
  82. {"cpg", tokenCodePage},
  83. {"cs", tokenCharStyle},
  84. {"dbch", tokenDBChars},
  85. {"deff", tokenDefaultFont},
  86. {"deflang", tokenDefaultLanguage},
  87. {"deflangfe", tokenDefaultLanguageFE},
  88. {"deftab", tokenDefaultTabWidth},
  89. {"deleted", tokenDeleted},
  90. {"dibitmap", tokenPictureWindowsDIB},
  91. {"disabled", tokenDisabled},
  92. {"dn", tokenDown},
  93. {"dropcapli", tokenDropCapLines},
  94. {"embo", tokenEmboss},
  95. //FUTURE (keithcu) I enabled em-dash and did some of the work for em-space and en-space.
  96. //Remaining is that we should output em-space and en-space via their unicode equivalents
  97. //as Word doesn't understand more than 1 instance of em-dash in a file it seems. Also, our
  98. //old measurer doesn't handle whitespace other than 0x20 properly.
  99. {"emdash", EMDASH},
  100. {"emspace", ' '},
  101. {"endash", ENDASH},
  102. {"enspace", ' '},
  103. {"expndtw", tokenExpand},
  104. {"f", tokenFontSelect},
  105. {"fbidi", tokenFontFamilyBidi},
  106. {"fchars", tokenFollowingPunct},
  107. {"fcharset", tokenCharSet},
  108. {"fdecor", tokenFontFamilyDecorative},
  109. {"fi", tokenIndentFirst},
  110. {"field", tokenField},
  111. {"fldinst", tokenFieldInstruction},
  112. {"fldrslt", tokenFieldResult},
  113. {"fmodern", tokenFontFamilyModern},
  114. {"fname", tokenRealFontName},
  115. {"fnil", tokenFontFamilyDefault},
  116. {"fonttbl", tokenFontTable},
  117. {"footer", tokenNullDestination},
  118. {"footerf", tokenNullDestination},
  119. {"footerl", tokenNullDestination},
  120. {"footerr", tokenNullDestination},
  121. {"footnote", tokenNullDestination},
  122. {"fprq", tokenPitch},
  123. {"froman", tokenFontFamilyRoman},
  124. {"fs", tokenFontSize},
  125. {"fscript", tokenFontFamilyScript},
  126. {"fswiss", tokenFontFamilySwiss},
  127. {"ftech", tokenFontFamilyTechnical},
  128. {"ftncn", tokenNullDestination},
  129. {"ftnsep", tokenNullDestination},
  130. {"ftnsepc", tokenNullDestination},
  131. {"green", tokenColorGreen},
  132. {"header", tokenNullDestination},
  133. {"headerf", tokenNullDestination},
  134. {"headerl", tokenNullDestination},
  135. {"headerr", tokenNullDestination},
  136. {"hich", tokenHIChars},
  137. {"highlight", tokenColorBackground},
  138. {"horzvert", tokenHorzInVert},
  139. {"hyphpar", tokenHyphPar},
  140. {"i", tokenItalic},
  141. {"impr", tokenImprint},
  142. {"info", tokenDocumentArea},
  143. {"intbl", tokenInTable},
  144. {"itap", tokenTableLevel},
  145. {"jpegblip", tokenJpegBlip},
  146. {"keep", tokenKeep},
  147. {"keepn", tokenKeepNext},
  148. {"kerning", tokenKerning},
  149. {"lang", tokenLanguage},
  150. {"lchars", tokenLeadingPunct},
  151. {"ldblquote", LDBLQUOTE},
  152. {"li", tokenIndentLeft},
  153. {"line", tokenLineBreak},
  154. {"lnkd", tokenLink},
  155. {"loch", tokenLOChars},
  156. {"lquote", LQUOTE},
  157. {"ltrch", tokenLToRChars},
  158. {"ltrdoc", tokenLToRDocument},
  159. {"ltrmark", LTRMARK},
  160. {"ltrpar", tokenLToRPara},
  161. {"mac", tokenMac},
  162. {"macpict", tokenPictureQuickDraw},
  163. {"nestcell", tokenNestCell},
  164. {"nestrow", tokenNestRow},
  165. {"nesttableprops", tokenNestTableProps},
  166. {"noline", tokenNoLineNumber},
  167. {"nonesttables", tokenNoNestTables},
  168. {"nosupersub", tokenNoSuperSub},
  169. {"nowidctlpar", tokenNoWidCtlPar},
  170. {"objattph", tokenObjectPlaceholder},
  171. {"objautlink", tokenObjectAutoLink},
  172. {"objclass", tokenObjectClass},
  173. {"objcropb", tokenCropBottom},
  174. {"objcropl", tokenCropLeft},
  175. {"objcropr", tokenCropRight},
  176. {"objcropt", tokenCropTop},
  177. {"objdata", tokenObjectData},
  178. {"objebookimage", tokenObjectEBookImage},
  179. {"object", tokenObject},
  180. {"objemb", tokenObjectEmbedded},
  181. {"objh", tokenHeight},
  182. {"objicemb", tokenObjectMacICEmbedder},
  183. {"objlink", tokenObjectLink},
  184. {"objname", tokenObjectName},
  185. {"objpub", tokenObjectMacPublisher},
  186. {"objscalex", tokenScaleX},
  187. {"objscaley", tokenScaleY},
  188. {"objsetsize", tokenObjectSetSize},
  189. {"objsub", tokenObjectMacSubscriber},
  190. {"objw", tokenWidth},
  191. {"outl", tokenOutline},
  192. {"page", tokenPage},
  193. {"pagebb", tokenPageBreakBefore},
  194. {"par", tokenEndParagraph},
  195. {"pard", tokenParagraphDefault},
  196. {"piccropb", tokenCropBottom},
  197. {"piccropl", tokenCropLeft},
  198. {"piccropr", tokenCropRight},
  199. {"piccropt", tokenCropTop},
  200. {"pich", tokenHeight},
  201. {"pichgoal", tokenDesiredHeight},
  202. {"picscalex", tokenScaleX},
  203. {"picscaley", tokenScaleY},
  204. {"pict", tokenPicture},
  205. {"picw", tokenWidth},
  206. {"picwgoal", tokenDesiredWidth},
  207. {"plain", tokenCharacterDefault},
  208. {"pmmetafile", tokenPictureOS2Metafile},
  209. {"pn", tokenParaNum},
  210. {"pndec", tokenParaNumDecimal},
  211. {"pngblip", tokenPngBlip},
  212. {"pnindent", tokenParaNumIndent},
  213. {"pnlcltr", tokenParaNumLCLetter},
  214. {"pnlcrm", tokenParaNumLCRoman},
  215. {"pnlvlblt", tokenParaNumBullet},
  216. {"pnlvlbody", tokenParaNumBody},
  217. {"pnlvlcont", tokenParaNumCont},
  218. {"pnqc", tokenParaNumAlignCenter},
  219. {"pnqr", tokenParaNumAlignRight},
  220. {"pnstart", tokenParaNumStart},
  221. {"pntext", tokenParaNumText},
  222. {"pntxta", tokenParaNumAfter},
  223. {"pntxtb", tokenParaNumBefore},
  224. {"pnucltr", tokenParaNumUCLetter},
  225. {"pnucrm", tokenParaNumUCRoman},
  226. {"posxr", tokenPositionRight},
  227. {"protect", tokenProtect},
  228. {"pwd", tokenPocketWord},
  229. {"qc", tokenAlignCenter},
  230. {"qj", tokenAlignJustify},
  231. {"ql", tokenAlignLeft},
  232. {"qr", tokenAlignRight},
  233. {"rdblquote", RDBLQUOTE},
  234. {"red", tokenColorRed},
  235. {"result", tokenObjectResult},
  236. {"revauth", tokenRevAuthor},
  237. {"revised", tokenRevised},
  238. {"ri", tokenIndentRight},
  239. {"row", tokenRow},
  240. {"rquote", RQUOTE},
  241. {"rtf", tokenRtf},
  242. {"rtlch", tokenRToLChars},
  243. {"rtldoc", tokenRToLDocument},
  244. {"rtlmark", RTLMARK},
  245. {"rtlpar", tokenRToLPara},
  246. {"rtlrow", tokenRToLRow},
  247. {"s", tokenStyle},
  248. {"sa", tokenSpaceAfter},
  249. {"sb", tokenSpaceBefore},
  250. {"sbys", tokenSideBySide},
  251. {"scaps", tokenSmallCaps},
  252. {"sect", tokenEndSection},
  253. {"sectd", tokenSectionDefault},
  254. {"shad", tokenShadow},
  255. {"shading", tokenShading},
  256. {"shp", tokenShape},
  257. {"shpinst", tokenShapeInstructions},
  258. {"shpwr", tokenShapeWrap},
  259. {"sl", tokenLineSpacing},
  260. {"slmult", tokenLineSpacingRule},
  261. {"sn", tokenShapeName},
  262. {"stextflow", tokenSTextFlow},
  263. {"strike", tokenStrikeOut},
  264. {"stylesheet", tokenStyleSheet},
  265. {"sub", tokenSubscript},
  266. {"super", tokenSuperscript},
  267. {"sv", tokenShapeValue},
  268. {"tab", 9},
  269. {"tb", tokenTabBar},
  270. {"tc", tokenNullDestination},
  271. {"tldot", tokenTabLeaderDots},
  272. {"tleq", tokenTabLeaderEqual},
  273. {"tlhyph", tokenTabLeaderHyphen},
  274. {"tlth", tokenTabLeaderThick},
  275. {"tlul", tokenTabLeaderUnderline},
  276. {"tqc", tokenCenterTab},
  277. {"tqdec", tokenDecimalTab},
  278. {"tqr", tokenFlushRightTab},
  279. {"trbrdrb", tokenBorderBottom},
  280. {"trbrdrl", tokenBorderLeft},
  281. {"trbrdrr", tokenBorderRight},
  282. {"trbrdrt", tokenBorderTop},
  283. {"trgaph", tokenCellHalfGap},
  284. {"trleft", tokenRowLeft},
  285. {"trowd", tokenRowDefault},
  286. {"trqc", tokenRowAlignCenter},
  287. {"trqr", tokenRowAlignRight},
  288. {"trrh", tokenRowHeight},
  289. {"tx", tokenTabPosition},
  290. {"u", tokenUnicode},
  291. {"uc", tokenUnicodeCharByteCount},
  292. {"ul", tokenUnderline},
  293. {"uld", tokenUnderlineDotted},
  294. {"uldash", tokenUnderlineDash},
  295. {"uldashd", tokenUnderlineDashDotted},
  296. {"uldashdd", tokenUnderlineDashDotDotted},
  297. {"uldb", tokenUnderlineDouble},
  298. {"ulhair", tokenUnderlineHairline},
  299. {"ulhwave", tokenUnderlineHeavyWave},
  300. {"ulldash", tokenUnderlineLongDash},
  301. {"ulnone", tokenStopUnderline},
  302. {"ulth", tokenUnderlineThick},
  303. {"ulthd", tokenUnderlineThickDotted},
  304. {"ulthdash", tokenUnderlineThickDash},
  305. {"ulthdashd", tokenUnderlineThickDashDot},
  306. {"ulthdashdd", tokenUnderlineThickDashDotDot},
  307. {"ulthldash", tokenUnderlineThickLongDash},
  308. {"ululdbwave", tokenUnderlineDoubleWave},
  309. {"ulw", tokenUnderlineWord},
  310. {"ulwave", tokenUnderlineWave},
  311. {"up", tokenUp},
  312. {"urtf", tokenURtf},
  313. {"v", tokenHiddenText},
  314. {"vertdoc", tokenVerticalRender},
  315. {"viewkind", tokenViewKind},
  316. {"viewscale", tokenViewScale},
  317. {"wbitmap", tokenPictureWindowsBitmap},
  318. {"wbmbitspixel", tokenBitmapBitsPerPixel},
  319. {"wbmplanes", tokenBitmapNumPlanes},
  320. {"wbmwidthbytes", tokenBitmapWidthBytes},
  321. {"wmetafile", tokenPictureWindowsMetafile},
  322. {"xe", tokenNullDestination},
  323. {"zwj", ZWJ},
  324. {"zwnj", ZWNJ}
  325. };
  326. INT cKeywords = ARRAY_SIZE(rgKeyword);
  327. extern const KEYWORD rgShapeKeyword[] =
  328. {
  329. {"fillAngle", shapeFillAngle},
  330. {"fillBackColor", shapeFillBackColor},
  331. {"fillColor", shapeFillColor},
  332. {"fillFocus", shapeFillFocus},
  333. {"fillType", shapeFillType}
  334. };
  335. INT cShapeKeywords = ARRAY_SIZE(rgShapeKeyword);
  336. extern const char *rgszUnrecognizedRTF[] = // When get one of these, fire
  337. { // LoFiRTF notification if enabled
  338. "abs",
  339. "aftn", // Catch \aftnbj, \aftncn, etc.
  340. "animtext",
  341. "annotation",
  342. // "bkmk", // Catch \bkmkpub, \bkmkstart, etc.
  343. "cldg",
  344. "cltx",
  345. "charscalex",
  346. "chbg", // Catch \chbgbdiag, \chbgcross, etc.
  347. "chcbpat",
  348. "chcfpat",
  349. "chshdng",
  350. "do",
  351. "dropcap",
  352. "file",
  353. "fontemb",
  354. "formfield",
  355. "linkself",
  356. "obj", // Catch \objxxx not found above
  357. "pgbrdr",
  358. // "pic",
  359. "revtbl",
  360. "striked",
  361. "tdfrmt",
  362. "twoinone"
  363. // "tp"
  364. // "tr"
  365. };
  366. INT crgszUnrecognizedRTF = ARRAY_SIZE(rgszUnrecognizedRTF);
  367. extern const BYTE szSymbolKeywords[] = "*:{}\\_|\r\n-~";
  368. extern const TOKEN tokenSymbol[] = // Keep in same order as szSymbolKeywords
  369. {
  370. tokenOptionalDestination, // *
  371. tokenIndexSubentry, // :
  372. '{', // {
  373. '}', // }
  374. '\\', // BSLASH
  375. NBHYPHEN, // _ (nonbreaking hyphen)
  376. tokenFormulaCharacter, // |
  377. tokenEndParagraph, // CR
  378. tokenEndParagraph, // LF
  379. SOFTHYPHEN, // - (optional hyphen)
  380. NBSPACE // ~ (nonbreaking space)
  381. };