示例#1
0
        private void ProcessStartTagAttributes(HtmlDtd.TagDefinition tagDef)
        {
            switch (tagDef.tagIndex)
            {
            case HtmlTagIndex.A:


                if (this.outputAnchorLinks)
                {
                    foreach (HtmlAttribute attr in this.token.Attributes)
                    {
                        if (attr.NameIndex == HtmlNameIndex.Href)
                        {
                            if (attr.IsAttrBegin)
                            {
                                this.urlScratch.Reset();
                            }

                            this.urlScratch.AppendHtmlAttributeValue(attr, HtmlSupport.MaxAttributeSize);
                            break;
                        }
                    }

                    if (this.token.IsTagEnd)
                    {
                        BufferString url = this.urlScratch.BufferString;

                        url.TrimWhitespace();

                        if (url.Length != 0 && url[0] != '#' && url[0] != '?' && url[0] != ';')
                        {
                            if (!this.lineStarted)
                            {
                                this.StartParagraphOrLine();
                            }



                            string urlString = url.ToString();

                            if (urlString.IndexOf(' ') != -1)
                            {
                                urlString = urlString.Replace(" ", "%20");
                            }

                            this.output.AnchorUrl = urlString;
                            this.insideAnchor     = true;

                            if (this.urlCompareSink == null)
                            {
                                this.urlCompareSink = new UrlCompareSink();
                            }

                            this.urlCompareSink.Initialize(urlString);
                        }

                        this.urlScratch.Reset();
                    }
                }
                break;

            case HtmlTagIndex.Image:
            case HtmlTagIndex.Img:



                if (this.outputImageLinks)
                {
                    foreach (HtmlAttribute attr in this.token.Attributes)
                    {
                        if (attr.NameIndex == HtmlNameIndex.Src)
                        {
                            if (attr.IsAttrBegin)
                            {
                                this.urlScratch.Reset();
                            }

                            this.urlScratch.AppendHtmlAttributeValue(attr, HtmlSupport.MaxAttributeSize);
                        }
                        else if (attr.NameIndex == HtmlNameIndex.Alt)
                        {
                            if (attr.IsAttrBegin)
                            {
                                this.imageAltText.Reset();
                            }

                            this.imageAltText.AppendHtmlAttributeValue(attr, HtmlSupport.MaxAttributeSize);
                        }
                        else if (attr.NameIndex == HtmlNameIndex.Height)
                        {
                            if (!attr.Value.IsEmpty)
                            {
                                PropertyValue value;

                                if (attr.Value.IsContiguous)
                                {
                                    value = HtmlSupport.ParseNumber(attr.Value.ContiguousBufferString, HtmlSupport.NumberParseFlags.Length);
                                }
                                else
                                {
                                    this.scratch.Reset();
                                    this.scratch.AppendHtmlAttributeValue(attr, HtmlSupport.MaxAttributeSize);
                                    value = HtmlSupport.ParseNumber(this.scratch.BufferString, HtmlSupport.NumberParseFlags.Length);
                                }

                                if (value.IsAbsRelLength)
                                {
                                    this.imageHeightPixels = value.PixelsInteger;
                                    if (this.imageHeightPixels == 0)
                                    {
                                        this.imageHeightPixels = 1;
                                    }
                                }
                            }
                        }
                        else if (attr.NameIndex == HtmlNameIndex.Width)
                        {
                            if (!attr.Value.IsEmpty)
                            {
                                PropertyValue value;

                                if (attr.Value.IsContiguous)
                                {
                                    value = HtmlSupport.ParseNumber(attr.Value.ContiguousBufferString, HtmlSupport.NumberParseFlags.Length);
                                }
                                else
                                {
                                    this.scratch.Reset();
                                    this.scratch.AppendHtmlAttributeValue(attr, HtmlSupport.MaxAttributeSize);
                                    value = HtmlSupport.ParseNumber(this.scratch.BufferString, HtmlSupport.NumberParseFlags.Length);
                                }

                                if (value.IsAbsRelLength)
                                {
                                    this.imageWidthPixels = value.PixelsInteger;
                                    if (this.imageWidthPixels == 0)
                                    {
                                        this.imageWidthPixels = 1;
                                    }
                                }
                            }
                        }
                    }



                    if (this.token.IsTagEnd)
                    {
                        string urlString = null;
                        string altString = null;



                        BufferString alt = this.imageAltText.BufferString;

                        alt.TrimWhitespace();

                        if (alt.Length != 0)
                        {
                            altString = alt.ToString();
                        }

                        if (altString == null || this.output.ImageRenderingCallbackDefined)
                        {
                            BufferString url = this.urlScratch.BufferString;

                            url.TrimWhitespace();

                            if (url.Length != 0)
                            {
                                urlString = url.ToString();
                            }
                        }

                        if (!this.lineStarted)
                        {
                            this.StartParagraphOrLine();
                        }

                        this.output.OutputImage(urlString, altString, this.imageWidthPixels, this.imageHeightPixels);

                        this.urlScratch.Reset();
                        this.imageAltText.Reset();
                        this.imageHeightPixels = 0;
                        this.imageWidthPixels  = 0;
                    }
                }
                break;

            case HtmlTagIndex.P:



                if (this.token.Attributes.Find(HtmlNameIndex.Class) && this.token.Attributes.Current.Value.CaseInsensitiveCompareEqual("msonormal"))
                {
                    this.wideGap = false;
                    this.nextParagraphCloseWideGap = false;
                }
                break;

            case HtmlTagIndex.Font:

                foreach (HtmlAttribute attr in this.token.Attributes)
                {
                    if (attr.NameIndex == HtmlNameIndex.Face)
                    {
                        this.scratch.Reset();
                        this.scratch.AppendHtmlAttributeValue(attr, HtmlSupport.MaxAttributeSize);

                        RecognizeInterestingFontName fontRecognizer = new RecognizeInterestingFontName();

                        for (int i = 0; i < this.scratch.Length && !fontRecognizer.IsRejected; i++)
                        {
                            fontRecognizer.AddCharacter(this.scratch.Buffer[i]);
                        }

                        this.textMapping = fontRecognizer.TextMapping;
                        break;
                    }
                }

                break;


            case HtmlTagIndex.Span:

                foreach (HtmlAttribute attr in this.token.Attributes)
                {
                    if (attr.NameIndex == HtmlNameIndex.Style)
                    {
                        this.scratch.Reset();
                        this.scratch.AppendHtmlAttributeValue(attr, HtmlSupport.MaxAttributeSize);

                        RecognizeInterestingFontNameInInlineStyle fontRecognizer = new RecognizeInterestingFontNameInInlineStyle();

                        for (int i = 0; i < this.scratch.Length && !fontRecognizer.IsFinished; i++)
                        {
                            fontRecognizer.AddCharacter(this.scratch.Buffer[i]);
                        }

                        this.textMapping = fontRecognizer.TextMapping;
                        break;
                    }
                }

                break;
            }
        }
示例#2
0
        private void ProcessStartTagAttributes(HtmlDtd.TagDefinition tagDef)
        {
            HtmlTagIndex tagIndex = tagDef.tagIndex;

            if (tagIndex <= HtmlTagIndex.Font)
            {
                if (tagIndex != HtmlTagIndex.A)
                {
                    if (tagIndex != HtmlTagIndex.Font)
                    {
                        return;
                    }
                    HtmlToken.AttributeEnumerator enumerator = token.Attributes.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        HtmlAttribute current = enumerator.Current;
                        if (current.NameIndex == HtmlNameIndex.Face)
                        {
                            scratch.Reset();
                            scratch.AppendHtmlAttributeValue(current, 4096);
                            RecognizeInterestingFontName recognizeInterestingFontName = default(RecognizeInterestingFontName);
                            int num = 0;
                            while (num < scratch.Length && !recognizeInterestingFontName.IsRejected)
                            {
                                recognizeInterestingFontName.AddCharacter(scratch.Buffer[num]);
                                num++;
                            }
                            textMapping = recognizeInterestingFontName.TextMapping;
                            return;
                        }
                    }
                    return;
                }
                else if (outputAnchorLinks)
                {
                    HtmlToken.AttributeEnumerator enumerator2 = token.Attributes.GetEnumerator();
                    while (enumerator2.MoveNext())
                    {
                        HtmlAttribute current2 = enumerator2.Current;
                        if (current2.NameIndex == HtmlNameIndex.Href)
                        {
                            if (current2.IsAttrBegin)
                            {
                                urlScratch.Reset();
                            }
                            urlScratch.AppendHtmlAttributeValue(current2, 4096);
                            break;
                        }
                    }
                    if (token.IsTagEnd)
                    {
                        BufferString bufferString = urlScratch.BufferString;
                        bufferString.TrimWhitespace();
                        if (bufferString.Length != 0 && bufferString[0] != '#' && bufferString[0] != '?' && bufferString[0] != ';')
                        {
                            if (!lineStarted)
                            {
                                StartParagraphOrLine();
                            }
                            string text = bufferString.ToString();
                            if (text.IndexOf(' ') != -1)
                            {
                                text = text.Replace(" ", "%20");
                            }
                            output.AnchorUrl = text;
                            insideAnchor     = true;
                            if (urlCompareSink == null)
                            {
                                urlCompareSink = new UrlCompareSink();
                            }
                            urlCompareSink.Initialize(text);
                        }
                        urlScratch.Reset();
                        return;
                    }
                }
            }
            else
            {
                switch (tagIndex)
                {
                case HtmlTagIndex.Image:
                case HtmlTagIndex.Img:
                    if (outputImageLinks)
                    {
                        HtmlToken.AttributeEnumerator enumerator3 = token.Attributes.GetEnumerator();
                        while (enumerator3.MoveNext())
                        {
                            HtmlAttribute current3 = enumerator3.Current;
                            if (current3.NameIndex == HtmlNameIndex.Src)
                            {
                                if (current3.IsAttrBegin)
                                {
                                    urlScratch.Reset();
                                }
                                urlScratch.AppendHtmlAttributeValue(current3, 4096);
                            }
                            else if (current3.NameIndex == HtmlNameIndex.Alt)
                            {
                                if (current3.IsAttrBegin)
                                {
                                    imageAltText.Reset();
                                }
                                imageAltText.AppendHtmlAttributeValue(current3, 4096);
                            }
                            else if (current3.NameIndex == HtmlNameIndex.Height)
                            {
                                if (!current3.Value.IsEmpty)
                                {
                                    PropertyValue propertyValue;
                                    if (current3.Value.IsContiguous)
                                    {
                                        propertyValue = HtmlSupport.ParseNumber(current3.Value.ContiguousBufferString, HtmlSupport.NumberParseFlags.Length);
                                    }
                                    else
                                    {
                                        scratch.Reset();
                                        scratch.AppendHtmlAttributeValue(current3, 4096);
                                        propertyValue = HtmlSupport.ParseNumber(scratch.BufferString, HtmlSupport.NumberParseFlags.Length);
                                    }
                                    if (propertyValue.IsAbsRelLength)
                                    {
                                        imageHeightPixels = propertyValue.PixelsInteger;
                                        if (imageHeightPixels == 0)
                                        {
                                            imageHeightPixels = 1;
                                        }
                                    }
                                }
                            }
                            else if (current3.NameIndex == HtmlNameIndex.Width && !current3.Value.IsEmpty)
                            {
                                PropertyValue propertyValue2;
                                if (current3.Value.IsContiguous)
                                {
                                    propertyValue2 = HtmlSupport.ParseNumber(current3.Value.ContiguousBufferString, HtmlSupport.NumberParseFlags.Length);
                                }
                                else
                                {
                                    scratch.Reset();
                                    scratch.AppendHtmlAttributeValue(current3, 4096);
                                    propertyValue2 = HtmlSupport.ParseNumber(scratch.BufferString, HtmlSupport.NumberParseFlags.Length);
                                }
                                if (propertyValue2.IsAbsRelLength)
                                {
                                    imageWidthPixels = propertyValue2.PixelsInteger;
                                    if (imageWidthPixels == 0)
                                    {
                                        imageWidthPixels = 1;
                                    }
                                }
                            }
                        }
                        if (token.IsTagEnd)
                        {
                            string       imageUrl      = null;
                            string       text2         = null;
                            BufferString bufferString2 = imageAltText.BufferString;
                            bufferString2.TrimWhitespace();
                            if (bufferString2.Length != 0)
                            {
                                text2 = bufferString2.ToString();
                            }
                            if (text2 == null || output.ImageRenderingCallbackDefined)
                            {
                                BufferString bufferString3 = urlScratch.BufferString;
                                bufferString3.TrimWhitespace();
                                if (bufferString3.Length != 0)
                                {
                                    imageUrl = bufferString3.ToString();
                                }
                            }
                            if (!lineStarted)
                            {
                                StartParagraphOrLine();
                            }
                            output.OutputImage(imageUrl, text2, imageWidthPixels, imageHeightPixels);
                            urlScratch.Reset();
                            imageAltText.Reset();
                            imageHeightPixels = 0;
                            imageWidthPixels  = 0;
                            return;
                        }
                    }
                    break;

                default:
                    if (tagIndex != HtmlTagIndex.P)
                    {
                        if (tagIndex != HtmlTagIndex.Span)
                        {
                            return;
                        }
                        HtmlToken.AttributeEnumerator enumerator4 = token.Attributes.GetEnumerator();
                        while (enumerator4.MoveNext())
                        {
                            HtmlAttribute current4 = enumerator4.Current;
                            if (current4.NameIndex == HtmlNameIndex.Style)
                            {
                                scratch.Reset();
                                scratch.AppendHtmlAttributeValue(current4, 4096);
                                RecognizeInterestingFontNameInInlineStyle recognizeInterestingFontNameInInlineStyle = default(RecognizeInterestingFontNameInInlineStyle);
                                int num2 = 0;
                                while (num2 < scratch.Length && !recognizeInterestingFontNameInInlineStyle.IsFinished)
                                {
                                    recognizeInterestingFontNameInInlineStyle.AddCharacter(scratch.Buffer[num2]);
                                    num2++;
                                }
                                textMapping = recognizeInterestingFontNameInInlineStyle.TextMapping;
                                return;
                            }
                        }
                    }
                    else if (token.Attributes.Find(HtmlNameIndex.Class))
                    {
                        HtmlAttribute current5 = token.Attributes.Current;
                        if (current5.Value.CaseInsensitiveCompareEqual("msonormal"))
                        {
                            wideGap = false;
                            nextParagraphCloseWideGap = false;
                            return;
                        }
                    }
                    break;
                }
            }
        }
示例#3
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;
            }
        }
示例#4
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;
            }
        }
        private void ProcessStartTagAttributes(HtmlDtd.TagDefinition tagDef)
        {
            HtmlTagIndex tagIndex = tagDef.TagIndex;

            if (tagIndex <= HtmlTagIndex.Font)
            {
                if (tagIndex != HtmlTagIndex.A)
                {
                    if (tagIndex != HtmlTagIndex.Font)
                    {
                        return;
                    }
                    foreach (HtmlAttribute attr in this.token.Attributes)
                    {
                        if (attr.NameIndex == HtmlNameIndex.Face)
                        {
                            this.scratch.Reset();
                            this.scratch.AppendHtmlAttributeValue(attr, 4096);
                            RecognizeInterestingFontName recognizeInterestingFontName = default(RecognizeInterestingFontName);
                            int num = 0;
                            while (num < this.scratch.Length && !recognizeInterestingFontName.IsRejected)
                            {
                                recognizeInterestingFontName.AddCharacter(this.scratch.Buffer[num]);
                                num++;
                            }
                            this.textMapping = recognizeInterestingFontName.TextMapping;
                            return;
                        }
                    }
                    return;
                }
                else if (this.outputAnchorLinks)
                {
                    foreach (HtmlAttribute attr2 in this.token.Attributes)
                    {
                        if (attr2.NameIndex == HtmlNameIndex.Href)
                        {
                            if (attr2.IsAttrBegin)
                            {
                                this.urlScratch.Reset();
                            }
                            this.urlScratch.AppendHtmlAttributeValue(attr2, 4096);
                            break;
                        }
                    }
                    if (this.token.IsTagEnd)
                    {
                        BufferString bufferString = this.urlScratch.BufferString;
                        bufferString.TrimWhitespace();
                        if (bufferString.Length != 0 && bufferString[0] != '#' && bufferString[0] != '?' && bufferString[0] != ';')
                        {
                            if (!this.lineStarted)
                            {
                                this.StartParagraphOrLine();
                            }
                            string text = bufferString.ToString();
                            if (text.IndexOf(' ') != -1)
                            {
                                text = text.Replace(" ", "%20");
                            }
                            this.output.OpenAnchor(text);
                            this.insideAnchor = true;
                            if (this.urlCompareSink == null)
                            {
                                this.urlCompareSink = new UrlCompareSink();
                            }
                            this.urlCompareSink.Initialize(text);
                        }
                        this.urlScratch.Reset();
                        return;
                    }
                }
            }
            else
            {
                switch (tagIndex)
                {
                case HtmlTagIndex.Image:
                case HtmlTagIndex.Img:
                    if (this.outputImageLinks)
                    {
                        foreach (HtmlAttribute attr3 in this.token.Attributes)
                        {
                            if (attr3.NameIndex == HtmlNameIndex.Src)
                            {
                                if (attr3.IsAttrBegin)
                                {
                                    this.urlScratch.Reset();
                                }
                                this.urlScratch.AppendHtmlAttributeValue(attr3, 4096);
                            }
                            else if (attr3.NameIndex == HtmlNameIndex.Alt)
                            {
                                if (attr3.IsAttrBegin)
                                {
                                    this.imageAltText.Reset();
                                }
                                this.imageAltText.AppendHtmlAttributeValue(attr3, 4096);
                            }
                            else if (attr3.NameIndex == HtmlNameIndex.Height)
                            {
                                if (!attr3.Value.IsEmpty)
                                {
                                    PropertyValue propertyValue;
                                    if (attr3.Value.IsContiguous)
                                    {
                                        propertyValue = HtmlSupport.ParseNumber(attr3.Value.ContiguousBufferString, HtmlSupport.NumberParseFlags.Length);
                                    }
                                    else
                                    {
                                        this.scratch.Reset();
                                        this.scratch.AppendHtmlAttributeValue(attr3, 4096);
                                        propertyValue = HtmlSupport.ParseNumber(this.scratch.BufferString, HtmlSupport.NumberParseFlags.Length);
                                    }
                                    if (propertyValue.IsAbsRelLength)
                                    {
                                        this.imageHeightPixels = propertyValue.PixelsInteger;
                                        if (this.imageHeightPixels == 0)
                                        {
                                            this.imageHeightPixels = 1;
                                        }
                                    }
                                }
                            }
                            else if (attr3.NameIndex == HtmlNameIndex.Width && !attr3.Value.IsEmpty)
                            {
                                PropertyValue propertyValue2;
                                if (attr3.Value.IsContiguous)
                                {
                                    propertyValue2 = HtmlSupport.ParseNumber(attr3.Value.ContiguousBufferString, HtmlSupport.NumberParseFlags.Length);
                                }
                                else
                                {
                                    this.scratch.Reset();
                                    this.scratch.AppendHtmlAttributeValue(attr3, 4096);
                                    propertyValue2 = HtmlSupport.ParseNumber(this.scratch.BufferString, HtmlSupport.NumberParseFlags.Length);
                                }
                                if (propertyValue2.IsAbsRelLength)
                                {
                                    this.imageWidthPixels = propertyValue2.PixelsInteger;
                                    if (this.imageWidthPixels == 0)
                                    {
                                        this.imageWidthPixels = 1;
                                    }
                                }
                            }
                        }
                        if (this.token.IsTagEnd)
                        {
                            string       imageUrl      = null;
                            string       text2         = null;
                            BufferString bufferString2 = this.imageAltText.BufferString;
                            bufferString2.TrimWhitespace();
                            if (bufferString2.Length != 0)
                            {
                                text2 = bufferString2.ToString();
                            }
                            if (text2 == null || this.output.ImageRenderingCallbackDefined)
                            {
                                BufferString bufferString3 = this.urlScratch.BufferString;
                                bufferString3.TrimWhitespace();
                                if (bufferString3.Length != 0)
                                {
                                    imageUrl = bufferString3.ToString();
                                }
                            }
                            if (!this.lineStarted)
                            {
                                this.StartParagraphOrLine();
                            }
                            this.output.OutputImage(imageUrl, text2, this.imageWidthPixels, this.imageHeightPixels);
                            this.urlScratch.Reset();
                            this.imageAltText.Reset();
                            this.imageHeightPixels = 0;
                            this.imageWidthPixels  = 0;
                            return;
                        }
                    }
                    break;

                default:
                    if (tagIndex == HtmlTagIndex.P)
                    {
                        if (!this.shouldUseNarrowGapForPTagHtmlToTextConversion)
                        {
                            if (!this.token.Attributes.Find(HtmlNameIndex.Class))
                            {
                                break;
                            }
                            HtmlAttribute htmlAttribute = this.token.Attributes.Current;
                            if (!htmlAttribute.Value.CaseInsensitiveCompareEqual("msonormal"))
                            {
                                break;
                            }
                        }
                        this.wideGap = false;
                        this.nextParagraphCloseWideGap = false;
                        return;
                    }
                    if (tagIndex != HtmlTagIndex.Span)
                    {
                        return;
                    }
                    foreach (HtmlAttribute attr4 in this.token.Attributes)
                    {
                        if (attr4.NameIndex == HtmlNameIndex.Style)
                        {
                            this.scratch.Reset();
                            this.scratch.AppendHtmlAttributeValue(attr4, 4096);
                            RecognizeInterestingFontNameInInlineStyle recognizeInterestingFontNameInInlineStyle = default(RecognizeInterestingFontNameInInlineStyle);
                            int num2 = 0;
                            while (num2 < this.scratch.Length && !recognizeInterestingFontNameInInlineStyle.IsFinished)
                            {
                                recognizeInterestingFontNameInInlineStyle.AddCharacter(this.scratch.Buffer[num2]);
                                num2++;
                            }
                            this.textMapping = recognizeInterestingFontNameInInlineStyle.TextMapping;
                            return;
                        }
                    }
                    break;
                }
            }
        }