示例#1
0
        private void Process(HtmlTokenId tokenId)
        {
            this.token = this.parser.Token;
            switch (tokenId)
            {
            case HtmlTokenId.EndOfFile:
                if (this.injection != null)
                {
                    bool haveHead = this.injection.HaveHead;
                }
                base.CloseAllContainersAndSetEOF();
                if (this.output != null)
                {
                    this.output.Flush();
                }
                break;

            case HtmlTokenId.Text:
                if (!this.insideParam)
                {
                    this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                    this.OutputText(this.token);
                    return;
                }
                if (this.tagPendingParameter != HtmlNameIndex._NOTANAME)
                {
                    this.scratch.AppendTokenText(this.token, 256);
                    return;
                }
                break;

            case HtmlTokenId.EncodingChange:
                if (this.output != null && this.output.OutputCodePageSameAsInput)
                {
                    this.output.OutputEncoding = this.token.TokenEncoding;
                    return;
                }
                break;

            case HtmlTokenId.Tag:
                if (this.token.IsTagBegin)
                {
                    if (this.token.IsEndTag)
                    {
                        if (this.token.NameIndex == HtmlNameIndex.Param)
                        {
                            if (this.insideParam)
                            {
                                HtmlNameIndex htmlNameIndex = this.tagPendingParameter;
                                if (htmlNameIndex <= HtmlNameIndex.ParaIndent)
                                {
                                    if (htmlNameIndex != HtmlNameIndex.Color)
                                    {
                                        if (htmlNameIndex == HtmlNameIndex.ParaIndent)
                                        {
                                            BufferString bufferString = this.scratch.BufferString;
                                            bufferString.TrimWhitespace();
                                            int num  = 0;
                                            int num2 = 0;
                                            int num3 = 0;
                                            int num4 = 0;
                                            int num6;
                                            for (int num5 = 0; num5 != bufferString.Length; num5 = num6)
                                            {
                                                int i = num5;
                                                num6 = num5;
                                                while (i < bufferString.Length)
                                                {
                                                    if (bufferString[i] == ',')
                                                    {
                                                        break;
                                                    }
                                                    i++;
                                                    num6++;
                                                }
                                                while (i > num5 && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(bufferString[i - 1])))
                                                {
                                                    i--;
                                                }
                                                if (num6 < bufferString.Length)
                                                {
                                                    do
                                                    {
                                                        num6++;
                                                    }while (num6 < bufferString.Length && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(bufferString[num6])));
                                                }
                                                BufferString bufferString2 = bufferString.SubString(num5, i - num5);
                                                if (bufferString2.EqualsToLowerCaseStringIgnoreCase("left"))
                                                {
                                                    num++;
                                                }
                                                else if (bufferString2.EqualsToLowerCaseStringIgnoreCase("right"))
                                                {
                                                    num2++;
                                                }
                                                else if (bufferString2.EqualsToLowerCaseStringIgnoreCase("in"))
                                                {
                                                    num3++;
                                                }
                                                else if (bufferString2.EqualsToLowerCaseStringIgnoreCase("out"))
                                                {
                                                    num4++;
                                                }
                                            }
                                            if (num + num4 != 0)
                                            {
                                                base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.LeftPadding, new PropertyValue(LengthUnits.Points, 30 * (num + num4) - ((this.indentLevel == 0) ? 12 : 0)));
                                            }
                                            if (num3 - num4 != 0)
                                            {
                                                if (num3 - num4 > 0)
                                                {
                                                    base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.FirstLineIndent, new PropertyValue(LengthUnits.Points, 30 * (num3 - num4) - ((this.indentLevel == 0 && num + num4 == 0) ? 12 : 0)));
                                                }
                                                else
                                                {
                                                    base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.FirstLineIndent, new PropertyValue(LengthUnits.Points, 30 * (num3 - num4) + ((this.indentLevel == 0 && num4 - num3 == num + num4) ? 12 : 0)));
                                                }
                                            }
                                            if (num2 != 0)
                                            {
                                                base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.RightPadding, new PropertyValue(LengthUnits.Points, 30 * num2));
                                            }
                                            if (num + num4 != 0 && this.indentLevel == 0)
                                            {
                                                this.indentLevel++;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        PropertyValue value = HtmlSupport.ParseColor(this.scratch.BufferString, true, false);
                                        if (value.IsColor)
                                        {
                                            if (value.Color.Red > 250U && value.Color.Green > 250U && value.Color.Blue > 250U)
                                            {
                                                value = new PropertyValue(PropertyType.Color, 14737632U);
                                            }
                                            base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.FontColor, value);
                                        }
                                    }
                                }
                                else if (htmlNameIndex != HtmlNameIndex.Excerpt)
                                {
                                    if (htmlNameIndex != HtmlNameIndex.Lang)
                                    {
                                        if (htmlNameIndex == HtmlNameIndex.FontFamily)
                                        {
                                            PropertyValue value = HtmlSupport.ParseFontFace(this.scratch.BufferString, this);
                                            if (!value.IsNull)
                                            {
                                                base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.FontFace, value);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        PropertyValue value = HtmlSupport.ParseLanguage(this.scratch.BufferString, null);
                                        if (!value.IsNull)
                                        {
                                            base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.Language, value);
                                        }
                                    }
                                }
                                this.insideParam = false;
                            }
                        }
                        else if (this.token.NameIndex != HtmlNameIndex.Unknown)
                        {
                            if (this.token.NameIndex == HtmlNameIndex.ParaIndent && this.indentLevel != 0)
                            {
                                this.indentLevel--;
                            }
                            base.CloseContainer(this.token.NameIndex);
                        }
                        this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                        return;
                    }
                    HtmlNameIndex nameIndex = this.token.NameIndex;
                    if (nameIndex <= HtmlNameIndex.ParaIndent)
                    {
                        if (nameIndex <= HtmlNameIndex.Param)
                        {
                            if (nameIndex == HtmlNameIndex.Nofill)
                            {
                                base.OpenContainer(FormatContainerType.Block, false, 2, base.GetStyle(14), this.token.NameIndex);
                                this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                                return;
                            }
                            if (nameIndex == HtmlNameIndex.FlushRight)
                            {
                                base.OpenContainer(FormatContainerType.Block, false, 2, FormatStyle.Null, this.token.NameIndex);
                                base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.TextAlignment, new PropertyValue(TextAlign.Right));
                                this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                                return;
                            }
                            if (nameIndex == HtmlNameIndex.Param)
                            {
                                this.insideParam = true;
                                this.scratch.Reset();
                                return;
                            }
                        }
                        else if (nameIndex <= HtmlNameIndex.Italic)
                        {
                            if (nameIndex == HtmlNameIndex.Color)
                            {
                                base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, FormatStyle.Null, this.token.NameIndex);
                                this.tagPendingParameter = HtmlNameIndex.Color;
                                return;
                            }
                            if (nameIndex == HtmlNameIndex.Italic)
                            {
                                base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, base.GetStyle(4), this.token.NameIndex);
                                this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                                return;
                            }
                        }
                        else
                        {
                            switch (nameIndex)
                            {
                            case HtmlNameIndex.Center:
                                base.OpenContainer(FormatContainerType.Block, false, 2, base.GetStyle(13), this.token.NameIndex);
                                this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                                return;

                            case HtmlNameIndex.Height:
                                break;

                            case HtmlNameIndex.Underline:
                                base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, base.GetStyle(5), this.token.NameIndex);
                                this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                                return;

                            case HtmlNameIndex.FlushBoth:
                                base.OpenContainer(FormatContainerType.Block, false, 2, FormatStyle.Null, this.token.NameIndex);
                                base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.TextAlignment, new PropertyValue(TextAlign.Justify));
                                this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                                return;

                            default:
                                if (nameIndex == HtmlNameIndex.ParaIndent)
                                {
                                    base.OpenContainer(FormatContainerType.Block, false, 2, FormatStyle.Null, this.token.NameIndex);
                                    this.tagPendingParameter = HtmlNameIndex.ParaIndent;
                                    if (this.indentLevel != 0)
                                    {
                                        this.indentLevel++;
                                        return;
                                    }
                                    return;
                                }
                                break;
                            }
                        }
                    }
                    else if (nameIndex <= HtmlNameIndex.FlushLeft)
                    {
                        if (nameIndex == HtmlNameIndex.Fixed)
                        {
                            base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, base.GetStyle(10), this.token.NameIndex);
                            this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                            return;
                        }
                        if (nameIndex == HtmlNameIndex.Smaller)
                        {
                            base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, FormatStyle.Null, this.token.NameIndex);
                            base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.FontSize, new PropertyValue(PropertyType.RelHtmlFontUnits, -1));
                            this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                            return;
                        }
                        switch (nameIndex)
                        {
                        case HtmlNameIndex.Bold:
                            base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, base.GetStyle(1), this.token.NameIndex);
                            this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                            return;

                        case HtmlNameIndex.FlushLeft:
                            base.OpenContainer(FormatContainerType.Block, false, 2, FormatStyle.Null, this.token.NameIndex);
                            base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.TextAlignment, new PropertyValue(TextAlign.Left));
                            this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                            return;
                        }
                    }
                    else if (nameIndex <= HtmlNameIndex.Lang)
                    {
                        if (nameIndex == HtmlNameIndex.Excerpt)
                        {
                            base.OpenContainer(FormatContainerType.Block, false, 2, FormatStyle.Null, this.token.NameIndex);
                            base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.QuotingLevelDelta, new PropertyValue(PropertyType.Integer, 1));
                            this.tagPendingParameter = HtmlNameIndex.Excerpt;
                            return;
                        }
                        if (nameIndex == HtmlNameIndex.Lang)
                        {
                            base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, base.GetStyle(6), this.token.NameIndex);
                            this.tagPendingParameter = HtmlNameIndex.Lang;
                            return;
                        }
                    }
                    else
                    {
                        if (nameIndex == HtmlNameIndex.Bigger)
                        {
                            base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, FormatStyle.Null, this.token.NameIndex);
                            base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.FontSize, new PropertyValue(PropertyType.RelHtmlFontUnits, 1));
                            this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                            return;
                        }
                        if (nameIndex == HtmlNameIndex.FontFamily)
                        {
                            base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, FormatStyle.Null, this.token.NameIndex);
                            this.tagPendingParameter = HtmlNameIndex.FontFamily;
                            return;
                        }
                    }
                    this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                    return;
                }
                break;

            case HtmlTokenId.Restart:
            case HtmlTokenId.OverlappedClose:
            case HtmlTokenId.OverlappedReopen:
                break;

            default:
                return;
            }
        }
示例#2
0
        // Token: 0x0600173D RID: 5949 RVA: 0x000B4F28 File Offset: 0x000B3128
        private void EndGroup()
        {
            RtfDestination destination = this.state.Destination;

            switch (destination)
            {
            case RtfDestination.Field:
                if (this.state.ParentDestination != RtfDestination.Field)
                {
                    this.skipFieldResult = false;
                    if (this.includePictureField)
                    {
                        PropertyValue propertyValue  = new PropertyValue(LengthUnits.Twips, this.pictureHeight);
                        PropertyValue propertyValue2 = new PropertyValue(LengthUnits.Twips, this.pictureWidth);
                        this.output.OutputImage(this.imageUrl, this.imageAltText, propertyValue2.PixelsInteger, propertyValue.PixelsInteger);
                        this.includePictureField = false;
                        this.imageUrl            = null;
                        this.imageAltText        = null;
                        return;
                    }
                    if (this.hyperLinkActive)
                    {
                        if (!this.urlCompareSink.IsMatch)
                        {
                            this.output.CloseAnchor();
                        }
                        else
                        {
                            this.output.CancelAnchor();
                        }
                        this.hyperLinkActive = false;
                    }
                }
                break;

            case RtfDestination.FieldResult:
                break;

            case RtfDestination.FieldInstruction:
                if (this.state.ParentDestination == RtfDestination.Field)
                {
                    bool         flag;
                    BufferString bufferString;
                    TextMapping  textMapping;
                    char         ucs32Literal;
                    short        num;
                    if (RtfSupport.IsHyperlinkField(ref this.scratch, out flag, out bufferString))
                    {
                        if (!flag)
                        {
                            if (this.hyperLinkActive)
                            {
                                if (!this.urlCompareSink.IsMatch)
                                {
                                    this.output.CloseAnchor();
                                }
                                else
                                {
                                    this.output.CancelAnchor();
                                }
                                this.hyperLinkActive = false;
                                this.urlCompareSink.Reset();
                            }
                            bufferString.TrimWhitespace();
                            if (bufferString.Length != 0)
                            {
                                string text = bufferString.ToString();
                                this.output.OpenAnchor(text);
                                this.hyperLinkActive = true;
                                if (this.urlCompareSink == null)
                                {
                                    this.urlCompareSink = new UrlCompareSink();
                                }
                                this.urlCompareSink.Initialize(text);
                            }
                        }
                    }
                    else if (RtfSupport.IsIncludePictureField(ref this.scratch, out bufferString))
                    {
                        bufferString.TrimWhitespace();
                        if (bufferString.Length != 0)
                        {
                            this.includePictureField = true;
                            bufferString.TrimWhitespace();
                            if (bufferString.Length != 0)
                            {
                                this.imageUrl = bufferString.ToString();
                            }
                            this.pictureWidth  = 0;
                            this.pictureHeight = 0;
                        }
                    }
                    else if (RtfSupport.IsSymbolField(ref this.scratch, out textMapping, out ucs32Literal, out num))
                    {
                        if (this.output.LineEmpty && this.lineIndent >= 120 && this.lineIndent < 7200)
                        {
                            this.output.OutputSpace(this.lineIndent / 120);
                        }
                        this.output.OutputNonspace((int)ucs32Literal, textMapping);
                        this.skipFieldResult = true;
                    }
                    this.scratch.Reset();
                    return;
                }
                break;

            default:
                switch (destination)
                {
                case RtfDestination.Picture:
                    if (this.state.ParentDestination != RtfDestination.Picture && !this.includePictureField)
                    {
                        PropertyValue propertyValue3 = new PropertyValue(LengthUnits.Twips, this.pictureHeight);
                        PropertyValue propertyValue4 = new PropertyValue(LengthUnits.Twips, this.pictureWidth);
                        this.output.OutputImage(null, null, propertyValue4.PixelsInteger, propertyValue3.PixelsInteger);
                        return;
                    }
                    break;

                case RtfDestination.PictureProperties:
                    break;

                case RtfDestination.ShapeName:
                    if (this.state.ParentDestination != RtfDestination.ShapeName)
                    {
                        BufferString bufferString2 = this.scratch.BufferString;
                        bufferString2.TrimWhitespace();
                        this.descriptionProperty = bufferString2.EqualsToLowerCaseStringIgnoreCase("wzdescription");
                        this.scratch.Reset();
                        return;
                    }
                    break;

                case RtfDestination.ShapeValue:
                    if (this.state.ParentDestination != RtfDestination.ShapeValue && this.descriptionProperty)
                    {
                        BufferString bufferString3 = this.scratch.BufferString;
                        bufferString3.TrimWhitespace();
                        if (bufferString3.Length != 0)
                        {
                            this.imageAltText = bufferString3.ToString();
                        }
                        this.scratch.Reset();
                        return;
                    }
                    break;

                default:
                    return;
                }
                break;
            }
        }