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

/*
* 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-2000 Microsoft Corporation. All rights reserved.
*/
#include "_common.h"
#include "tokens.h"
extern const KEYWORD rgKeyword[] =
{
{"adeff", tokenDefaultBiDiFont},
{"af", tokenAssocFontSelect},
{"afs", tokenAssocFontSize},
{"animtext", tokenAnimText},
{"ansi", tokenCharSetAnsi},
{"ansicpg", tokenAnsiCodePage},
{"b", tokenBold},
{"background", tokenBackground},
{"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},
{"clcbpat", tokenCellBackColor},
{"clcfpat", tokenCellForeColor},
{"clshdng", tokenCellShading},
{"cltxlrtb", tokenCellLRTB},
{"cltxtbrlv", tokenCellTopBotRLVert},
{"clvertalb", tokenCellAlignBottom},
{"clvertalc", tokenCellAlignCenter},
{"clvmgf", tokenCellMergeDown},
{"clvmrg", tokenCellMergeUp},
{"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},
//FUTURE (keithcu) I enabled em-dash and did some of the work for em-space and en-space.
//Remaining is that we should output em-space and en-space via their unicode equivalents
//as Word doesn't understand more than 1 instance of em-dash in a file it seems. Also, our
//old measurer doesn't handle whitespace other than 0x20 properly.
{"emdash", EMDASH},
{"emspace", ' '},
{"endash", ENDASH},
{"enspace", ' '},
{"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},
{"hich", tokenHIChars},
{"highlight", tokenColorBackground},
{"horzvert", tokenHorzInVert},
{"hyphpar", tokenHyphPar},
{"i", tokenItalic},
{"impr", tokenImprint},
{"info", tokenDocumentArea},
{"intbl", tokenInTable},
{"itap", tokenTableLevel},
{"jpegblip", tokenJpegBlip},
{"keep", tokenKeep},
{"keepn", tokenKeepNext},
{"kerning", tokenKerning},
{"lang", tokenLanguage},
{"lchars", tokenLeadingPunct},
{"ldblquote", LDBLQUOTE},
{"li", tokenIndentLeft},
{"line", tokenLineBreak},
{"lnkd", tokenLink},
{"loch", tokenLOChars},
{"lquote", LQUOTE},
{"ltrch", tokenLToRChars},
{"ltrdoc", tokenLToRDocument},
{"ltrmark", LTRMARK},
{"ltrpar", tokenLToRPara},
{"mac", tokenMac},
{"macpict", tokenPictureQuickDraw},
{"nestcell", tokenNestCell},
{"nestrow", tokenNestRow},
{"nesttableprops", tokenNestTableProps},
{"noline", tokenNoLineNumber},
{"nonesttables", tokenNoNestTables},
{"nosupersub", tokenNoSuperSub},
{"nowidctlpar", tokenNoWidCtlPar},
{"objattph", tokenObjectPlaceholder},
{"objautlink", tokenObjectAutoLink},
{"objclass", tokenObjectClass},
{"objcropb", tokenCropBottom},
{"objcropl", tokenCropLeft},
{"objcropr", tokenCropRight},
{"objcropt", tokenCropTop},
{"objdata", tokenObjectData},
{"objebookimage", tokenObjectEBookImage},
{"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},
{"pngblip", tokenPngBlip},
{"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},
{"posxr", tokenPositionRight},
{"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},
{"rtlrow", tokenRToLRow},
{"s", tokenStyle},
{"sa", tokenSpaceAfter},
{"sb", tokenSpaceBefore},
{"sbys", tokenSideBySide},
{"scaps", tokenSmallCaps},
{"sect", tokenEndSection},
{"sectd", tokenSectionDefault},
{"shad", tokenShadow},
{"shading", tokenShading},
{"shp", tokenShape},
{"shpinst", tokenShapeInstructions},
{"shpwr", tokenShapeWrap},
{"sl", tokenLineSpacing},
{"slmult", tokenLineSpacingRule},
{"sn", tokenShapeName},
{"stextflow", tokenSTextFlow},
{"strike", tokenStrikeOut},
{"stylesheet", tokenStyleSheet},
{"sub", tokenSubscript},
{"super", tokenSuperscript},
{"sv", tokenShapeValue},
{"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},
{"trrh", tokenRowHeight},
{"tx", tokenTabPosition},
{"u", tokenUnicode},
{"uc", tokenUnicodeCharByteCount},
{"ul", tokenUnderline},
{"uld", tokenUnderlineDotted},
{"uldash", tokenUnderlineDash},
{"uldashd", tokenUnderlineDashDotted},
{"uldashdd", tokenUnderlineDashDotDotted},
{"uldb", tokenUnderlineDouble},
{"ulhair", tokenUnderlineHairline},
{"ulhwave", tokenUnderlineHeavyWave},
{"ulldash", tokenUnderlineLongDash},
{"ulnone", tokenStopUnderline},
{"ulth", tokenUnderlineThick},
{"ulthd", tokenUnderlineThickDotted},
{"ulthdash", tokenUnderlineThickDash},
{"ulthdashd", tokenUnderlineThickDashDot},
{"ulthdashdd", tokenUnderlineThickDashDotDot},
{"ulthldash", tokenUnderlineThickLongDash},
{"ululdbwave", tokenUnderlineDoubleWave},
{"ulw", tokenUnderlineWord},
{"ulwave", tokenUnderlineWave},
{"up", tokenUp},
{"urtf", tokenURtf},
{"v", tokenHiddenText},
{"vertdoc", tokenVerticalRender},
{"viewkind", tokenViewKind},
{"viewscale", tokenViewScale},
{"wbitmap", tokenPictureWindowsBitmap},
{"wbmbitspixel", tokenBitmapBitsPerPixel},
{"wbmplanes", tokenBitmapNumPlanes},
{"wbmwidthbytes", tokenBitmapWidthBytes},
{"wmetafile", tokenPictureWindowsMetafile},
{"xe", tokenNullDestination},
{"zwj", ZWJ},
{"zwnj", ZWNJ}
};
INT cKeywords = ARRAY_SIZE(rgKeyword);
extern const KEYWORD rgShapeKeyword[] =
{
{"fillAngle", shapeFillAngle},
{"fillBackColor", shapeFillBackColor},
{"fillColor", shapeFillColor},
{"fillFocus", shapeFillFocus},
{"fillType", shapeFillType}
};
INT cShapeKeywords = ARRAY_SIZE(rgShapeKeyword);
extern const char *rgszUnrecognizedRTF[] = // When get one of these, fire
{ // LoFiRTF notification if enabled
"abs",
"aftn", // Catch \aftnbj, \aftncn, etc.
"animtext",
"annotation",
// "bkmk", // Catch \bkmkpub, \bkmkstart, etc.
"cldg",
"cltx",
"charscalex",
"chbg", // Catch \chbgbdiag, \chbgcross, etc.
"chcbpat",
"chcfpat",
"chshdng",
"do",
"dropcap",
"file",
"fontemb",
"formfield",
"linkself",
"obj", // Catch \objxxx not found above
"pgbrdr",
// "pic",
"revtbl",
"striked",
"tdfrmt",
"twoinone"
// "tp"
// "tr"
};
INT crgszUnrecognizedRTF = ARRAY_SIZE(rgszUnrecognizedRTF);
extern const BYTE szSymbolKeywords[] = "*:{}\\_|\r\n-~";
extern const TOKEN tokenSymbol[] = // Keep in same order as szSymbolKeywords
{
tokenOptionalDestination, // *
tokenIndexSubentry, // :
'{', // {
'}', // }
'\\', // BSLASH
NBHYPHEN, // _ (nonbreaking hyphen)
tokenFormulaCharacter, // |
tokenEndParagraph, // CR
tokenEndParagraph, // LF
SOFTHYPHEN, // - (optional hyphen)
NBSPACE // ~ (nonbreaking space)
};