windows-nt/Source/XPSP1/NT/windows/richedit/re30/tokens.cpp
2020-09-26 16:20:57 +08:00

328 lines
9.9 KiB
C++

/*
* tokens.cpp
*
* The sorted table of strings and token values
*
* Note: if you insert new keywords, be sure to insert the corresponding
* i_keyword in the i_xxx enum in tokens.h. This enum defines the
* indices used by RTFWrit to output RTF control words.
*
* Original RichEdit 1.0 RTF converter: Anthony Francisco
* Conversion to C++ and RichEdit 2.0: Murray Sargent
*
* Copyright (c) 1995-1998 Microsoft Corporation. All rights reserved.
*/
#include "_common.h"
#include "tokens.h"
extern const KEYWORD rgKeyword[] =
{
{"adeff", tokenDefaultBiDiFont},
{"af", tokenAssocFontSelect},
{"animtext", tokenAnimText},
{"ansi", tokenCharSetAnsi},
{"ansicpg", tokenAnsiCodePage},
{"b", tokenBold},
{"bgbdiag", tokenBckgrndBckDiag},
{"bgcross", tokenBckgrndCross},
{"bgdcross", tokenBckgrndDiagCross},
{"bgdkbdiag", tokenBckgrndDrkBckDiag},
{"bgdkcross", tokenBckgrndDrkCross},
{"bgdkdcross", tokenBckgrndDrkDiagCross},
{"bgdkfdiag", tokenBckgrndDrkFwdDiag},
{"bgdkhoriz", tokenBckgrndDrkHoriz},
{"bgdkvert", tokenBckgrndDrkVert},
{"bgfdiag", tokenBckgrndFwdDiag},
{"bghoriz", tokenBckgrndHoriz},
{"bgvert", tokenBckgrndVert},
{"bin", tokenBinaryData},
{"blue", tokenColorBlue},
{"box", tokenBox},
{"brdrb", tokenBorderBottom},
{"brdrbar", tokenBorderOutside},
{"brdrbtw", tokenBorderBetween},
{"brdrcf", tokenBorderColor},
{"brdrdash", tokenBorderDash},
{"brdrdashsm", tokenBorderDashSmall},
{"brdrdb", tokenBorderDouble},
{"brdrdot", tokenBorderDot},
{"brdrhair", tokenBorderHairline},
{"brdrl", tokenBorderLeft},
{"brdrr", tokenBorderRight},
{"brdrs", tokenBorderSingleThick},
{"brdrsh", tokenBorderShadow},
{"brdrt", tokenBorderTop},
{"brdrth", tokenBorderDoubleThick},
{"brdrtriple", tokenBorderTriple},
{"brdrw", tokenBorderWidth},
{"brsp", tokenBorderSpace},
{"bullet", BULLET},
{"caps", tokenCaps},
{"cbpat", tokenColorBckgrndPat},
{"cell", tokenCell},
{"cellx", tokenCellX},
{"cf", tokenColorForeground},
{"cfpat", tokenColorForgrndPat},
{"clbrdrb", tokenCellBorderBottom},
{"clbrdrl", tokenCellBorderLeft},
{"clbrdrr", tokenCellBorderRight},
{"clbrdrt", tokenCellBorderTop},
{"collapsed", tokenCollapsed},
{"colortbl", tokenColorTable},
{"cpg", tokenCodePage},
{"cs", tokenCharStyle},
{"dbch", tokenDBChars},
{"deff", tokenDefaultFont},
{"deflang", tokenDefaultLanguage},
{"deflangfe", tokenDefaultLanguageFE},
{"deftab", tokenDefaultTabWidth},
{"deleted", tokenDeleted},
{"dibitmap", tokenPictureWindowsDIB},
{"disabled", tokenDisabled},
{"dn", tokenDown},
{"dropcapli", tokenDropCapLines},
{"embo", tokenEmboss},
#if 1
{"emdash", '-'},
{"emspace", ' '},
{"endash", '-'},
{"enspace", ' '},
#else
// FUTURE(BradO): It turns out that we can't reliably
// display these Unicode characters for any particular
// font applied to them. If we choose to do something
// more intelligent to ensure that these special chars
// are displayed regardless of the font applied, then
// we should re-enable this code (see Bug #3179).
{"emdash", EMDASH},
{"emspace", EMSPACE},
{"endash", ENDASH},
{"enspace", ENSPACE},
#endif
{"expndtw", tokenExpand},
{"f", tokenFontSelect},
{"fbidi", tokenFontFamilyBidi},
{"fchars", tokenFollowingPunct},
{"fcharset", tokenCharSet},
{"fdecor", tokenFontFamilyDecorative},
{"fi", tokenIndentFirst},
{"field", tokenField},
{"fldinst", tokenFieldInstruction},
{"fldrslt", tokenFieldResult},
{"fmodern", tokenFontFamilyModern},
{"fname", tokenRealFontName},
{"fnil", tokenFontFamilyDefault},
{"fonttbl", tokenFontTable},
{"footer", tokenNullDestination},
{"footerf", tokenNullDestination},
{"footerl", tokenNullDestination},
{"footerr", tokenNullDestination},
{"footnote", tokenNullDestination},
{"fprq", tokenPitch},
{"froman", tokenFontFamilyRoman},
{"fs", tokenFontSize},
{"fscript", tokenFontFamilyScript},
{"fswiss", tokenFontFamilySwiss},
{"ftech", tokenFontFamilyTechnical},
{"ftncn", tokenNullDestination},
{"ftnsep", tokenNullDestination},
{"ftnsepc", tokenNullDestination},
{"green", tokenColorGreen},
{"header", tokenNullDestination},
{"headerf", tokenNullDestination},
{"headerl", tokenNullDestination},
{"headerr", tokenNullDestination},
{"highlight", tokenColorBackground},
{"hyphpar", tokenHyphPar},
{"i", tokenItalic},
{"impr", tokenImprint},
{"info", tokenDocumentArea},
{"intbl", tokenInTable},
{"keep", tokenKeep},
{"keepn", tokenKeepNext},
{"kerning", tokenKerning},
{"lang", tokenLanguage},
{"lchars", tokenLeadingPunct},
{"ldblquote", LDBLQUOTE},
{"li", tokenIndentLeft},
{"line", tokenLineBreak},
{"lnkd", tokenLink},
{"lquote", LQUOTE},
{"ltrch", tokenLToRChars},
{"ltrdoc", tokenLToRDocument},
{"ltrmark", LTRMARK},
{"ltrpar", tokenLToRPara},
{"macpict", tokenPictureQuickDraw},
{"noline", tokenNoLineNumber},
{"nosupersub", tokenNoSuperSub},
{"nowidctlpar", tokenNoWidCtlPar},
{"objattph", tokenObjectPlaceholder},
{"objautlink", tokenObjectAutoLink},
{"objclass", tokenObjectClass},
{"objcropb", tokenCropBottom},
{"objcropl", tokenCropLeft},
{"objcropr", tokenCropRight},
{"objcropt", tokenCropTop},
{"objdata", tokenObjectData},
{"object", tokenObject},
{"objemb", tokenObjectEmbedded},
{"objh", tokenHeight},
{"objicemb", tokenObjectMacICEmbedder},
{"objlink", tokenObjectLink},
{"objname", tokenObjectName},
{"objpub", tokenObjectMacPublisher},
{"objscalex", tokenScaleX},
{"objscaley", tokenScaleY},
{"objsetsize", tokenObjectSetSize},
{"objsub", tokenObjectMacSubscriber},
{"objw", tokenWidth},
{"outl", tokenOutline},
{"page", tokenPage},
{"pagebb", tokenPageBreakBefore},
{"par", tokenEndParagraph},
{"pard", tokenParagraphDefault},
{"piccropb", tokenCropBottom},
{"piccropl", tokenCropLeft},
{"piccropr", tokenCropRight},
{"piccropt", tokenCropTop},
{"pich", tokenHeight},
{"pichgoal", tokenDesiredHeight},
{"picscalex", tokenScaleX},
{"picscaley", tokenScaleY},
{"pict", tokenPicture},
{"picw", tokenWidth},
{"picwgoal", tokenDesiredWidth},
{"plain", tokenCharacterDefault},
{"pmmetafile", tokenPictureOS2Metafile},
{"pn", tokenParaNum},
{"pndec", tokenParaNumDecimal},
{"pnindent", tokenParaNumIndent},
{"pnlcltr", tokenParaNumLCLetter},
{"pnlcrm", tokenParaNumLCRoman},
{"pnlvlblt", tokenParaNumBullet},
{"pnlvlbody", tokenParaNumBody},
{"pnlvlcont", tokenParaNumCont},
{"pnqc", tokenParaNumAlignCenter},
{"pnqr", tokenParaNumAlignRight},
{"pnstart", tokenParaNumStart},
{"pntext", tokenParaNumText},
{"pntxta", tokenParaNumAfter},
{"pntxtb", tokenParaNumBefore},
{"pnucltr", tokenParaNumUCLetter},
{"pnucrm", tokenParaNumUCRoman},
{"protect", tokenProtect},
{"pwd", tokenPocketWord},
{"qc", tokenAlignCenter},
{"qj", tokenAlignJustify},
{"ql", tokenAlignLeft},
{"qr", tokenAlignRight},
{"rdblquote", RDBLQUOTE},
{"red", tokenColorRed},
{"result", tokenObjectResult},
{"revauth", tokenRevAuthor},
{"revised", tokenRevised},
{"ri", tokenIndentRight},
{"row", tokenRow},
{"rquote", RQUOTE},
{"rtf", tokenRtf},
{"rtlch", tokenRToLChars},
{"rtldoc", tokenRToLDocument},
{"rtlmark", RTLMARK},
{"rtlpar", tokenRToLPara},
{"s", tokenStyle},
{"sa", tokenSpaceAfter},
{"sb", tokenSpaceBefore},
{"sbys", tokenSideBySide},
{"scaps", tokenSmallCaps},
{"sect", tokenEndSection},
{"sectd", tokenSectionDefault},
{"shad", tokenShadow},
{"shading", tokenShading},
{"sl", tokenLineSpacing},
{"slmult", tokenLineSpacingRule},
{"strike", tokenStrikeOut},
{"stylesheet", tokenStyleSheet},
{"sub", tokenSubscript},
{"super", tokenSuperscript},
{"tab", 9},
{"tb", tokenTabBar},
{"tc", tokenNullDestination},
{"tldot", tokenTabLeaderDots},
{"tleq", tokenTabLeaderEqual},
{"tlhyph", tokenTabLeaderHyphen},
{"tlth", tokenTabLeaderThick},
{"tlul", tokenTabLeaderUnderline},
{"tqc", tokenCenterTab},
{"tqdec", tokenDecimalTab},
{"tqr", tokenFlushRightTab},
{"trbrdrb", tokenBorderBottom},
{"trbrdrl", tokenBorderLeft},
{"trbrdrr", tokenBorderRight},
{"trbrdrt", tokenBorderTop},
{"trgaph", tokenCellHalfGap},
{"trleft", tokenRowLeft},
{"trowd", tokenRowDefault},
{"trqc", tokenRowAlignCenter},
{"trqr", tokenRowAlignRight},
{"tx", tokenTabPosition},
{"u", tokenUnicode},
{"uc", tokenUnicodeCharByteCount},
{"ul", tokenUnderline},
{"uld", tokenUnderlineDotted},
{"uldash", tokenUnderlineDash},
{"uldashd", tokenUnderlineDashDotted},
{"uldashdd", tokenUnderlineDashDotDotted},
{"uldb", tokenUnderlineDouble},
{"ulhair", tokenUnderlineHairline},
{"ulnone", tokenStopUnderline},
{"ulth", tokenUnderlineThick},
{"ulw", tokenUnderlineWord},
{"ulwave", tokenUnderlineWave},
{"up", tokenUp},
{"urtf", tokenURtf},
{"v", tokenHiddenText},
{"viewkind", tokenViewKind},
{"viewscale", tokenViewScale},
{"wbitmap", tokenPictureWindowsBitmap},
{"wbmbitspixel",tokenBitmapBitsPerPixel},
{"wbmplanes", tokenBitmapNumPlanes},
{"wbmwidthbytes",tokenBitmapWidthBytes},
{"wmetafile", tokenPictureWindowsMetafile},
{"xe", tokenNullDestination},
{"zwj", ZWJ},
{"zwnj", ZWNJ}
};
INT cKeywords = sizeof(rgKeyword) / sizeof(rgKeyword[0]);
extern const BYTE szSymbolKeywords[] = "*:{}\\_|\r\n-~";
extern const TOKEN tokenSymbol[] = // Keep in same order as szSymbolKeywords
{
tokenOptionalDestination, // *
tokenIndexSubentry, // :
'{', // {
'}', // }
'\\', // BSLASH
'-', // _ (nonbreaking hyphen; should be 0x2011)
tokenFormulaCharacter, // |
tokenEndParagraph, // CR
tokenEndParagraph, // LF
0xAD, // - (optional hyphen)
#if 1
' ' // ~ (nonbreaking space)
#else
// FUTURE(BradO): It turns out that we can't reliably
// display these Unicode characters for any particular
// font applied to them. If we choose to do something
// more intelligent to ensure that these special chars
// are displayed regardless of the font applied, then
// we should re-enable this code (see Bug #3179).
0xa0 // ~ (nonbreaking space)
#endif
};