/// <summary> Evaluate an RTF control that needs special processing. /// /// </summary> /// <param name="ipfn"> /// </param> /// <returns> /// </returns> private ErrorRtf ParseSpecialKeyword(IPFN ipfn) { ErrorRtf ret = ErrorRtf.OK; if (!UtilStrByteMode.isLocaleDefLangDBCS()) { if (_destState == RDS.SKIP && ipfn != IPFN.BIN) { /* if we're skipping, and it's not */ return(ret); /* the \bin keyword, ignore it. */ } if (ipfn == IPFN.FONT || ipfn == IPFN.CHARSET || ipfn == IPFN.UNICODE) { return(ret); } } else { if (_destState == RDS.SKIP && ipfn != IPFN.BIN && ipfn != IPFN.FONT && ipfn != IPFN.CHARSET && ipfn != IPFN.UNICODE) { return(ret); } } if (ipfn == IPFN.BIN) { _internalState = RIS.BIN; _cbBin = _lParam; } else if (ipfn == IPFN.SKIP_DEST) { _skipDestIfUnk = true; } else if (ipfn == IPFN.HEX) { _internalState = RIS.HEX; } else if (ipfn == IPFN.FONT) { _fontNum = (int)_lParam; } else if (ipfn == IPFN.CHARSET) { _charsetTable[_fontNum] = (int)_lParam; } else if (ipfn == IPFN.UNICODE) { _internalState = RIS.UNICODE; } else { ret = ErrorRtf.BAD_TABLE; } return(ret); }
/// <summary> Step 3. Search rgsymRtf for szKeyword and evaluate it appropriately. /// /// </summary> /// <param name="szKeyword"> /// </param> /// <param name="outputTxt"> /// </param> /// <returns> /// </returns> private ErrorRtf TranslateKeyword(String szKeyword, StringBuilder outputTxt) { int isym; ErrorRtf ret = ErrorRtf.OK; /* search for szKeyword in rgsymRtf */ for (isym = 0; isym < rgsymRtf.Length; isym++) { if (String.CompareOrdinal(szKeyword, rgsymRtf[isym].szKeyword) == 0) { break; } } if (isym == rgsymRtf.Length) /* control word not found */ { if (_skipDestIfUnk) { /* if this is a new destination */ _destState = RDS.SKIP; /* skip the destination */ } /* else just discard it */ _skipDestIfUnk = false; } else { ret = ErrorRtf.BAD_TABLE; /* found it! use kwd and idxInRgprop to determine what to do with it. */ _skipDestIfUnk = false; if (rgsymRtf[isym].kwd == KWD.PROP) { ret = validateProp((IPROP)rgsymRtf[isym].idxInRgprop); } else if (rgsymRtf[isym].kwd == KWD.CHAR) { ret = ParseChar(((char)((RtfChar)rgsymRtf[isym].idxInRgprop)), outputTxt); } else if (rgsymRtf[isym].kwd == KWD.DEST) { ret = changeDestState(); } else if (rgsymRtf[isym].kwd == KWD.SPEC) { ret = ParseSpecialKeyword((IPFN)rgsymRtf[isym].idxInRgprop); } } return(ret); }
/// <summary> Validate the property identified by _iprop_ to the value _val_. /// previously called Applypropchange /// </summary> /// <param name="iprop"> /// </param> /// <returns> /// </returns> private ErrorRtf validateProp(IPROP iprop) { ErrorRtf ret = ErrorRtf.OK; if (_destState == RDS.SKIP) { /* If we're skipping text, */ return(ret); /* don't do anything. */ } /* validate prop */ if (rgprop[iprop.toInt()].prop != PROPTYPE.DOP && rgprop[iprop.toInt()].prop != PROPTYPE.SEP && rgprop[iprop.toInt()].prop != PROPTYPE.PAP && rgprop[iprop.toInt()].prop != PROPTYPE.CHP && rgprop[iprop.toInt()].actn != ACTN.SPEC) { ret = ErrorRtf.BAD_TABLE; } if (rgprop[iprop.toInt()].actn != ACTN.BYTE && rgprop[iprop.toInt()].actn != ACTN.WORD && rgprop[iprop.toInt()].actn != ACTN.SPEC) { ret = ErrorRtf.BAD_TABLE; } return(ret); }
/// <summary> Route the character to the appropriate destination stream. /// /// </summary> /// <param name="ch"> /// </param> /// <param name="outputTxt"> /// </param> /// <returns> /// </returns> private ErrorRtf ParseChar(char ch, StringBuilder outputTxt) { ErrorRtf ret = ErrorRtf.OK; if (_internalState == RIS.BIN && --_cbBin <= 0) { _internalState = RIS.NORM; } if (_destState == RDS.SKIP) { } /* Toss this character. */ else if (_destState == RDS.NORM) { /* Output a character. Properties are valid at this point. */ ret = PrintChar(ch, outputTxt); } else { } /* handle other destinations.... */ return(ret); }