Exemplo n.º 1
0
        // Token: 0x0600190D RID: 6413 RVA: 0x000C7DFC File Offset: 0x000C5FFC
        public static bool IsIncludePictureField(ref ScratchBuffer scratch, out BufferString linkUrl)
        {
            int num    = 0;
            int length = scratch.Length;

            while (num != scratch.Length && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(scratch[num])))
            {
                num++;
            }
            if (scratch.Length - num > 15 && scratch[num] == 'I' && scratch[num + 1] == 'N' && scratch[num + 2] == 'C' && scratch[num + 3] == 'L' && scratch[num + 4] == 'U' && scratch[num + 5] == 'D' && scratch[num + 6] == 'E' && scratch[num + 7] == 'P' && scratch[num + 8] == 'I' && scratch[num + 9] == 'C' && scratch[num + 10] == 'T' && scratch[num + 11] == 'U' && scratch[num + 12] == 'R' && scratch[num + 13] == 'E' && scratch[num + 14] == ' ')
            {
                num += 15;
                int offset;
                int num2;
                int offset2;
                int num3;
                int fieldArgument = RtfSupport.GetFieldArgument(ref scratch, num, out offset, out num2, out offset2, out num3);
                while (num2 == 2 && scratch[offset] == '\\')
                {
                    num          += fieldArgument;
                    fieldArgument = RtfSupport.GetFieldArgument(ref scratch, num, out offset, out num2, out offset2, out num3);
                }
                if (num3 > 2)
                {
                    linkUrl = scratch.SubString(offset2, num3);
                    return(true);
                }
            }
            linkUrl = BufferString.Null;
            return(false);
        }
Exemplo n.º 2
0
 public PropertyValue RegisterFaceName(bool isStatic, BufferString value)
 {
     if (value.Length == 0)
     {
         return(PropertyValue.Null);
     }
     return(this.RegisterFaceName(isStatic, value.ToString()));
 }
Exemplo n.º 3
0
        //public TerminalRichTextEditor TerminalRichTextEditorObj { get; set; }
        public Terminal(TelnetSession Session)
            : base()
        {
            // it should not be less than 10000

            this.Session = Session;
            InitializeComponent();
            ConsoleTextBox.Caret = this.Caret;
            consolebuffer = new BufferString();
            logfile = new LogFile(this);
            ConsoleTextBox.TextInput += ConsoleTextBox_TextInput;
            //ConsoleTextBox.KeyDownEvent += ConsoleTextBox_KeyDown;
            ConsoleTextBox.AddHandler(KeyDownEvent, new RoutedEventHandler(ConsoleTextBox_KeyDown), true);
            ConsoleTextBox.AddHandler(KeyUpEvent, new RoutedEventHandler(ConsoleTextBox_KeyUp), true);
        }
Exemplo n.º 4
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;
            }
        }
Exemplo n.º 5
0
 public StringValue RegisterStringValue(bool isStatic, BufferString value)
 {
     return(this.Store.AllocateStringValue(isStatic, value.ToString()));
 }
Exemplo n.º 6
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;
                }
            }
        }
Exemplo n.º 7
0
        // Token: 0x0600190C RID: 6412 RVA: 0x000C7C8C File Offset: 0x000C5E8C
        public static bool IsHyperlinkField(ref ScratchBuffer scratch, out bool local, out BufferString linkUrl)
        {
            int num    = 0;
            int length = scratch.Length;

            while (num != scratch.Length && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(scratch[num])))
            {
                num++;
            }
            if (scratch.Length - num > 10 && scratch[num] == 'H' && scratch[num + 1] == 'Y' && scratch[num + 2] == 'P' && scratch[num + 3] == 'E' && scratch[num + 4] == 'R' && scratch[num + 5] == 'L' && scratch[num + 6] == 'I' && scratch[num + 7] == 'N' && scratch[num + 8] == 'K' && scratch[num + 9] == ' ')
            {
                num += 10;
                int num2;
                int num3;
                int num4;
                int num5;
                int fieldArgument = RtfSupport.GetFieldArgument(ref scratch, num, out num2, out num3, out num4, out num5);
                if (num3 == 2 && scratch[num2] == '\\' && scratch[num2 + 1] == 'l')
                {
                    local         = true;
                    num          += fieldArgument;
                    fieldArgument = RtfSupport.GetFieldArgument(ref scratch, num, out num2, out num3, out num4, out num5);
                }
                else
                {
                    local = false;
                }
                if (num5 != 0)
                {
                    if (local)
                    {
                        num4--;
                        num5++;
                        scratch[num4] = '#';
                    }
                    linkUrl = scratch.SubString(num4, num5);
                    return(true);
                }
            }
            local   = false;
            linkUrl = BufferString.Null;
            return(false);
        }
Exemplo n.º 8
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;
            }
        }
Exemplo n.º 9
0
        public void SetStringProperty(PropertyId propertyId, BufferString value)
        {
            StringValue stringValue = this.converter.RegisterStringValue(false, value);

            this.converter.StyleBuildHelper.SetProperty(0, propertyId, stringValue.PropertyValue);
        }
Exemplo n.º 10
0
        // Token: 0x06001BA4 RID: 7076 RVA: 0x000D4DC8 File Offset: 0x000D2FC8
        public void SetStringProperty(PropertyPrecedence propertyPrecedence, PropertyId propertyId, BufferString value)
        {
            StringValue stringValue = this.converter.RegisterStringValue(false, value);

            this.converter.ContainerStyleBuildHelper.SetProperty((int)propertyPrecedence, propertyId, stringValue.PropertyValue);
        }
Exemplo n.º 11
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;
            }
        }
Exemplo n.º 12
0
        public static PropertyValue ParseNumber(BufferString value, NumberParseFlags parseFlags)
        {
            bool  flag   = false;
            bool  flag2  = false;
            bool  flag3  = false;
            ulong num    = 0uL;
            int   num2   = 0;
            int   num3   = 0;
            bool  flag4  = false;
            int   num4   = 0;
            int   length = value.Length;

            while (num4 < length && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(value[num4])))
            {
                num4++;
            }
            if (num4 == length)
            {
                return(PropertyValue.Null);
            }
            if (num4 < length && (value[num4] == '-' || value[num4] == '+'))
            {
                flag2 = true;
                flag3 = (value[num4] == '-');
                num4++;
            }
            while (num4 < length && ParseSupport.NumericCharacter(ParseSupport.GetCharClass(value[num4])))
            {
                flag = true;
                if (num < 1844674407370955152uL)
                {
                    num = num * 10uL + (ulong)(value[num4] - '0');
                }
                else
                {
                    num2++;
                }
                num4++;
            }
            if (num4 < length && value[num4] == '.')
            {
                flag4 = true;
                num4++;
                while (num4 < length && ParseSupport.NumericCharacter(ParseSupport.GetCharClass(value[num4])))
                {
                    flag = true;
                    if (num < 1844674407370955152uL)
                    {
                        num = num * 10uL + (ulong)(value[num4] - '0');
                        num2--;
                    }
                    num4++;
                }
                if (num2 >= 0 && (parseFlags & NumberParseFlags.Strict) != 0)
                {
                    return(PropertyValue.Null);
                }
            }
            if (!flag)
            {
                return(PropertyValue.Null);
            }
            while (num4 < length && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(value[num4])))
            {
                num4++;
            }
            if (num4 < length && (value[num4] | ' ') == 'e' && num4 + 1 < length && (value[num4 + 1] == '-' || value[num4 + 1] == '+' || ParseSupport.NumericCharacter(ParseSupport.GetCharClass(value[num4 + 1]))))
            {
                flag4 = true;
                num4++;
                bool flag5 = false;
                if (value[num4] == '-' || value[num4] == '+')
                {
                    flag5 = (value[num4] == '-');
                    num4++;
                }
                while (num4 < length && ParseSupport.NumericCharacter(ParseSupport.GetCharClass(value[num4])))
                {
                    num3 = num3 * 10 + (value[num4++] - '0');
                }
                if (flag5)
                {
                    num3 = -num3;
                }
                while (num4 < length && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(value[num4])))
                {
                    num4++;
                }
            }
            uint         num5         = flag4 ? 10000u : 1u;
            uint         num6         = 1u;
            PropertyType propertyType = flag4 ? PropertyType.Fractional : PropertyType.Integer;
            bool         flag6        = false;
            int          num7         = 0;

            if (num4 + 1 < length)
            {
                if ((value[num4] | ' ') == 'p')
                {
                    if ((value[num4 + 1] | ' ') == 'c')
                    {
                        num5         = 1920u;
                        num6         = 1u;
                        flag6        = true;
                        propertyType = PropertyType.AbsLength;
                        num7         = 2;
                    }
                    else if ((value[num4 + 1] | ' ') == 't')
                    {
                        num5         = 160u;
                        num6         = 1u;
                        flag6        = true;
                        propertyType = PropertyType.AbsLength;
                        num7         = 2;
                    }
                    else if ((value[num4 + 1] | ' ') == 'x')
                    {
                        num5         = 11520u;
                        num6         = 120u;
                        propertyType = PropertyType.Pixels;
                        flag6        = true;
                        num7         = 2;
                    }
                }
                else if ((value[num4] | ' ') == 'e')
                {
                    if ((value[num4 + 1] | ' ') == 'm')
                    {
                        num5         = 160u;
                        num6         = 1u;
                        propertyType = PropertyType.Ems;
                        flag6        = true;
                        num7         = 2;
                    }
                    else if ((value[num4 + 1] | ' ') == 'x')
                    {
                        num5         = 160u;
                        num6         = 1u;
                        propertyType = PropertyType.Exs;
                        flag6        = true;
                        num7         = 2;
                    }
                }
                else if ((value[num4] | ' ') == 'i')
                {
                    if ((value[num4 + 1] | ' ') == 'n')
                    {
                        num5         = 11520u;
                        num6         = 1u;
                        flag6        = true;
                        propertyType = PropertyType.AbsLength;
                        num7         = 2;
                    }
                }
                else if ((value[num4] | ' ') == 'c')
                {
                    if ((value[num4 + 1] | ' ') == 'm')
                    {
                        num5         = 1152000u;
                        num6         = 254u;
                        flag6        = true;
                        propertyType = PropertyType.AbsLength;
                        num7         = 2;
                    }
                }
                else if ((value[num4] | ' ') == 'm' && (value[num4 + 1] | ' ') == 'm')
                {
                    num5         = 115200u;
                    num6         = 254u;
                    flag6        = true;
                    propertyType = PropertyType.AbsLength;
                    num7         = 2;
                }
            }
            if (!flag6 && num4 < length)
            {
                if (value[num4] == '%')
                {
                    num5         = 10000u;
                    num6         = 1u;
                    propertyType = PropertyType.Percentage;
                    num7         = 1;
                }
                else if (value[num4] == '*')
                {
                    num5         = 1u;
                    num6         = 1u;
                    propertyType = PropertyType.Multiple;
                    num7         = 1;
                }
            }
            num4 += num7;
            if (num4 < length)
            {
                while (num4 < length && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(value[num4])))
                {
                    num4++;
                }
                if (num4 < length && (parseFlags & (NumberParseFlags.StyleSheetProperty | NumberParseFlags.Strict)) != 0)
                {
                    return(PropertyValue.Null);
                }
            }
            if (num != 0uL)
            {
                int num8 = num2 + num3;
                if (num8 > 0)
                {
                    if (num8 > 20)
                    {
                        num8 = 0;
                        num  = 18446744073709551615uL;
                    }
                    else
                    {
                        while (num8 != 0)
                        {
                            if (num > 1844674407370955161uL)
                            {
                                num8 = 0;
                                num  = 18446744073709551615uL;
                                break;
                            }
                            num *= 10uL;
                            num8--;
                        }
                    }
                }
                else if (num8 < -10)
                {
                    if (num8 < -21)
                    {
                        num8 = 0;
                        num  = 0uL;
                    }
                    else
                    {
                        while (num8 != -10)
                        {
                            num /= 10uL;
                            num8++;
                        }
                    }
                }
                num *= num5;
                num /= num6;
                while (num8 != 0)
                {
                    num /= 10uL;
                    num8++;
                }
                if (num > 67108863uL)
                {
                    num = 67108863uL;
                }
            }
            int num9 = (int)num;

            if (flag3)
            {
                num9 = -num9;
            }
            if (propertyType == PropertyType.Integer)
            {
                if ((parseFlags & NumberParseFlags.Integer) == 0)
                {
                    if ((parseFlags & NumberParseFlags.HtmlFontUnits) != 0)
                    {
                        if (flag2)
                        {
                            if (num9 < -7)
                            {
                                num9 = -7;
                            }
                            else if (num9 > 7)
                            {
                                num9 = 7;
                            }
                            propertyType = PropertyType.RelHtmlFontUnits;
                        }
                        else
                        {
                            if (num9 < 1)
                            {
                                num9 = 1;
                            }
                            else if (num9 > 7)
                            {
                                num9 = 7;
                            }
                            propertyType = PropertyType.HtmlFontUnits;
                        }
                    }
                    else if ((parseFlags & NumberParseFlags.AbsoluteLength) != 0)
                    {
                        num = num * 11520uL / 120uL;
                        if (num > 67108863uL)
                        {
                            num = 67108863uL;
                        }
                        num9 = (int)num;
                        if (flag3)
                        {
                            num9 = -num9;
                        }
                        propertyType = PropertyType.Pixels;
                    }
                    else
                    {
                        if ((parseFlags & NumberParseFlags.Float) == 0)
                        {
                            return(PropertyValue.Null);
                        }
                        num *= 10000uL;
                        if (num > 67108863uL)
                        {
                            num = 67108863uL;
                        }
                        num9 = (int)num;
                        if (flag3)
                        {
                            num9 = -num9;
                        }
                        propertyType = PropertyType.Fractional;
                    }
                }
            }
            else if (propertyType == PropertyType.Fractional)
            {
                if ((parseFlags & NumberParseFlags.Float) == 0)
                {
                    if ((parseFlags & NumberParseFlags.AbsoluteLength) == 0)
                    {
                        return(PropertyValue.Null);
                    }
                    num = num * 11520uL / 120uL / 10000uL;
                    if (num > 67108863uL)
                    {
                        num = 67108863uL;
                    }
                    num9 = (int)num;
                    if (flag3)
                    {
                        num9 = -num9;
                    }
                    propertyType = PropertyType.Pixels;
                }
            }
            else if (propertyType == PropertyType.AbsLength || propertyType == PropertyType.Pixels)
            {
                if ((parseFlags & NumberParseFlags.AbsoluteLength) == 0)
                {
                    return(PropertyValue.Null);
                }
            }
            else if (propertyType == PropertyType.Ems || propertyType == PropertyType.Exs)
            {
                if ((parseFlags & NumberParseFlags.EmExLength) == 0)
                {
                    return(PropertyValue.Null);
                }
            }
            else if (propertyType == PropertyType.Percentage)
            {
                if ((parseFlags & NumberParseFlags.Percentage) == 0)
                {
                    return(PropertyValue.Null);
                }
            }
            else if (propertyType == PropertyType.Multiple && (parseFlags & NumberParseFlags.Multiple) == 0)
            {
                return(PropertyValue.Null);
            }
            if (num9 < 0 && (parseFlags & NumberParseFlags.NonNegative) != 0 && propertyType != PropertyType.RelHtmlFontUnits)
            {
                return(PropertyValue.Null);
            }
            return(new PropertyValue(propertyType, num9));
        }
Exemplo n.º 13
0
        public static PropertyValue ParseNumber(BufferString value, NumberParseFlags parseFlags)
        {
            bool  isValidNumber      = false;
            bool  isSigned           = false;
            bool  isNegative         = false;
            ulong result             = 0;
            int   exponent           = 0;
            int   scientificExponent = 0;
            bool  floatNumber        = false;
            int   offset             = 0;
            int   end = value.Length;

            while (offset < end && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(value[offset])))
            {
                offset++;
            }

            if (offset == end)
            {
                return(PropertyValue.Null);
            }

            if (offset < end && (value[offset] == '-' || value[offset] == '+'))
            {
                isSigned   = true;
                isNegative = (value[offset] == '-');
                offset++;
            }

            while (offset < end && ParseSupport.NumericCharacter(ParseSupport.GetCharClass(value[offset])))
            {
                isValidNumber = true;
                if (result < ulong.MaxValue / 10 - 9)
                {
                    result = unchecked (result * 10u + (uint)(value[offset] - '0'));
                }
                else
                {
                    exponent++;
                }
                offset++;
            }

            if (offset < end && value[offset] == '.')
            {
                floatNumber = true;
                offset++;

                while (offset < end && ParseSupport.NumericCharacter(ParseSupport.GetCharClass(value[offset])))
                {
                    isValidNumber = true;

                    if (result < ulong.MaxValue / 10 - 9)
                    {
                        result = unchecked (result * 10u + (uint)(value[offset] - '0'));
                        exponent--;
                    }

                    offset++;
                }

                if (exponent >= 0 && 0 != (parseFlags & NumberParseFlags.Strict))
                {
                    return(PropertyValue.Null);
                }
            }

            if (!isValidNumber)
            {
                return(PropertyValue.Null);
            }

            while (offset < end && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(value[offset])))
            {
                offset++;
            }

            if (offset < end && (value[offset] | '\x20') == 'e')
            {
                if (offset + 1 < end && (value[offset + 1] == '-' || value[offset + 1] == '+' || ParseSupport.NumericCharacter(ParseSupport.GetCharClass(value[offset + 1]))))
                {
                    floatNumber = true;
                    offset++;

                    bool isNegativeScientificExponent = false;

                    if (value[offset] == '-' || value[offset] == '+')
                    {
                        isNegativeScientificExponent = (value[offset] == '-');
                        offset++;
                    }

                    while (offset < end && ParseSupport.NumericCharacter(ParseSupport.GetCharClass(value[offset])))
                    {
                        scientificExponent = unchecked (scientificExponent * 10 + (value[offset++] - '0'));
                    }

                    if (isNegativeScientificExponent)
                    {
                        scientificExponent = -scientificExponent;
                    }

                    while (offset < end && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(value[offset])))
                    {
                        offset++;
                    }
                }
            }

            uint         mul        = floatNumber ? 10000u : 1;
            uint         div        = 1;
            PropertyType units      = floatNumber ? PropertyType.Fractional : PropertyType.Integer;
            bool         recognized = false;
            int          typeLength = 0;

            if (offset + 1 < end)
            {
                if ((value[offset] | '\x20') == 'p')
                {
                    if ((value[offset + 1] | '\x20') == 'c')
                    {
                        mul        = 8 * 20 * 12;
                        div        = 1;
                        recognized = true;
                        units      = PropertyType.AbsLength;
                        typeLength = 2;
                    }
                    else if ((value[offset + 1] | '\x20') == 't')
                    {
                        mul        = 8 * 20;
                        div        = 1;
                        recognized = true;
                        units      = PropertyType.AbsLength;
                        typeLength = 2;
                    }
                    else if ((value[offset + 1] | '\x20') == 'x')
                    {
                        mul        = 8 * 20 * 72;
                        div        = 120;
                        units      = PropertyType.Pixels;
                        recognized = true;
                        typeLength = 2;
                    }
                }
                else if ((value[offset] | '\x20') == 'e')
                {
                    if ((value[offset + 1] | '\x20') == 'm')
                    {
                        mul        = 8 * 20;
                        div        = 1;
                        units      = PropertyType.Ems;
                        recognized = true;
                        typeLength = 2;
                    }
                    else if ((value[offset + 1] | '\x20') == 'x')
                    {
                        mul        = 8 * 20;
                        div        = 1;
                        units      = PropertyType.Exs;
                        recognized = true;
                        typeLength = 2;
                    }
                }
                else if ((value[offset] | '\x20') == 'i')
                {
                    if ((value[offset + 1] | '\x20') == 'n')
                    {
                        mul        = 8 * 20 * 72;
                        div        = 1;
                        recognized = true;
                        units      = PropertyType.AbsLength;
                        typeLength = 2;
                    }
                }
                else if ((value[offset] | '\x20') == 'c')
                {
                    if ((value[offset + 1] | '\x20') == 'm')
                    {
                        mul        = 8 * 20 * 72 * 100;
                        div        = 254;
                        recognized = true;
                        units      = PropertyType.AbsLength;
                        typeLength = 2;
                    }
                }
                else if ((value[offset] | '\x20') == 'm')
                {
                    if ((value[offset + 1] | '\x20') == 'm')
                    {
                        mul        = 8 * 20 * 72 * 10;
                        div        = 254;
                        recognized = true;
                        units      = PropertyType.AbsLength;
                        typeLength = 2;
                    }
                }
            }

            if (!recognized && offset < end)
            {
                if (value[offset] == '%')
                {
                    mul        = 10000;
                    div        = 1;
                    units      = PropertyType.Percentage;
                    recognized = true;
                    typeLength = 1;
                }
                else if (value[offset] == '*')
                {
                    mul        = 1;
                    div        = 1;
                    units      = PropertyType.Multiple;
                    recognized = true;
                    typeLength = 1;
                }
            }

            offset += typeLength;

            if (offset < end)
            {
                while (offset < end && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(value[offset])))
                {
                    offset++;
                }

                if (offset < end)
                {
                    if (0 != (parseFlags & (NumberParseFlags.Strict | NumberParseFlags.StyleSheetProperty)))
                    {
                        return(PropertyValue.Null);
                    }
                }
            }

            if (result != 0)
            {
                int actualExponent = exponent + scientificExponent;

                if (actualExponent > 0)
                {
                    if (actualExponent > 20)
                    {
                        actualExponent = 0;
                        result         = ulong.MaxValue;
                    }
                    else
                    {
                        while (actualExponent != 0)
                        {
                            if (result > ulong.MaxValue / 10)
                            {
                                actualExponent = 0;
                                result         = ulong.MaxValue;
                                break;
                            }
                            else
                            {
                                result = unchecked (result * 10);
                            }
                            actualExponent--;
                        }
                    }
                }
                else if (actualExponent < -10)
                {
                    if (actualExponent < -21)
                    {
                        actualExponent = 0;
                        result         = 0;
                    }
                    else
                    {
                        while (actualExponent != -10)
                        {
                            result /= 10;
                            actualExponent++;
                        }
                    }
                }

                result *= mul;
                result /= div;

                while (actualExponent != 0)
                {
                    result /= 10;
                    actualExponent++;
                }

                if (result > PropertyValue.ValueMax)
                {
                    result = PropertyValue.ValueMax;
                }
            }

            int intValue = unchecked ((int)result);

            if (isNegative)
            {
                intValue = -intValue;
            }

            if (units == PropertyType.Integer)
            {
                if (0 != (parseFlags & NumberParseFlags.Integer))
                {
                }
                else if (0 != (parseFlags & NumberParseFlags.HtmlFontUnits))
                {
                    if (isSigned)
                    {
                        if (intValue < -7)
                        {
                            intValue = -7;
                        }
                        else if (intValue > 7)
                        {
                            intValue = 7;
                        }
                        units = PropertyType.RelHtmlFontUnits;
                    }
                    else
                    {
                        if (intValue < 1)
                        {
                            intValue = 1;
                        }
                        else if (intValue > 7)
                        {
                            intValue = 7;
                        }
                        units = PropertyType.HtmlFontUnits;
                    }
                }
                else if (0 != (parseFlags & NumberParseFlags.AbsoluteLength))
                {
                    result = result * (8 * 20 * 72) / 120;
                    if (result > PropertyValue.ValueMax)
                    {
                        result = PropertyValue.ValueMax;
                    }

                    intValue = unchecked ((int)result);
                    if (isNegative)
                    {
                        intValue = -intValue;
                    }

                    units = PropertyType.Pixels;
                }
                else if (0 != (parseFlags & NumberParseFlags.Float))
                {
                    result *= 10000;
                    if (result > PropertyValue.ValueMax)
                    {
                        result = PropertyValue.ValueMax;
                    }

                    intValue = unchecked ((int)result);
                    if (isNegative)
                    {
                        intValue = -intValue;
                    }

                    units = PropertyType.Fractional;
                }
                else
                {
                    return(PropertyValue.Null);
                }
            }
            else if (units == PropertyType.Fractional)
            {
                if (0 != (parseFlags & NumberParseFlags.Float))
                {
                }
                else if (0 != (parseFlags & NumberParseFlags.AbsoluteLength))
                {
                    result = result * (8 * 20 * 72) / 120 / 10000;
                    if (result > PropertyValue.ValueMax)
                    {
                        result = PropertyValue.ValueMax;
                    }

                    intValue = unchecked ((int)result);
                    if (isNegative)
                    {
                        intValue = -intValue;
                    }

                    units = PropertyType.Pixels;
                }
                else
                {
                    return(PropertyValue.Null);
                }
            }
            else if (units == PropertyType.AbsLength || units == PropertyType.Pixels)
            {
                if (0 == (parseFlags & NumberParseFlags.AbsoluteLength))
                {
                    return(PropertyValue.Null);
                }
            }
            else if (units == PropertyType.Ems || units == PropertyType.Exs)
            {
                if (0 == (parseFlags & NumberParseFlags.EmExLength))
                {
                    return(PropertyValue.Null);
                }
            }
            else if (units == PropertyType.Percentage)
            {
                if (0 == (parseFlags & NumberParseFlags.Percentage))
                {
                    return(PropertyValue.Null);
                }
            }
            else if (units == PropertyType.Multiple)
            {
                if (0 == (parseFlags & NumberParseFlags.Multiple))
                {
                    return(PropertyValue.Null);
                }
            }

            if (intValue < 0 && 0 != (parseFlags & NumberParseFlags.NonNegative) && units != PropertyType.RelHtmlFontUnits)
            {
                return(PropertyValue.Null);
            }

            return(new PropertyValue(units, intValue));
        }
Exemplo n.º 14
0
        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;
                }
            }
        }