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; } }
// Token: 0x0600190E RID: 6414 RVA: 0x000C7F8C File Offset: 0x000C618C public static bool IsSymbolField(ref ScratchBuffer scratch, out TextMapping textMapping, out char symbol, out short points) { textMapping = TextMapping.Unicode; symbol = '\0'; points = 0; int num = 0; int length = scratch.Length; while (num != scratch.Length && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(scratch[num]))) { num++; } if (scratch.Length - num <= 7 || scratch[num] != 'S' || scratch[num + 1] != 'Y' || scratch[num + 2] != 'M' || scratch[num + 3] != 'B' || scratch[num + 4] != 'O' || scratch[num + 5] != 'L' || scratch[num + 6] != ' ') { return(false); } num += 7; int num2; int num3; int num4; int num5; int fieldArgument = RtfSupport.GetFieldArgument(ref scratch, num, out num2, out num3, out num4, out num5); int num6; char c; if (num3 > 2 && scratch.Buffer[num2] == '0' && (ushort)(scratch.Buffer[num2 + 1] | ' ') == 120) { num6 = 2; while (num6 < num3 && (c = scratch.Buffer[num2 + num6]) <= 'f') { if (('0' > c || c > '9') && ('a' > c || c > 'f')) { if ('A' > c) { break; } if (c > 'F') { break; } } symbol = (symbol << 4) + ((c <= '9') ? (c - '0') : ((c & 'O') - 'A' + '\n')); num6++; } } else { num6 = 0; while (num6 < num3 && (c = scratch.Buffer[num2 + num6]) <= '9' && '0' <= c) { symbol = '\n' * symbol + (c - '0'); num6++; } } num += fieldArgument; fieldArgument = RtfSupport.GetFieldArgument(ref scratch, num, out num2, out num3, out num4, out num5); if (num3 != 2 || scratch[num2] != '\\' || scratch[num2 + 1] != 'f') { return(false); } num += fieldArgument; fieldArgument = RtfSupport.GetFieldArgument(ref scratch, num, out num2, out num3, out num4, out num5); if (num5 == 0) { return(false); } RecognizeInterestingFontName recognizeInterestingFontName = default(RecognizeInterestingFontName); num6 = 0; while (num6 < num5 && !recognizeInterestingFontName.IsRejected) { recognizeInterestingFontName.AddCharacter(scratch.Buffer[num4 + num6]); num6++; } textMapping = recognizeInterestingFontName.TextMapping; if (textMapping == TextMapping.Unicode) { textMapping = TextMapping.OtherSymbol; } num += fieldArgument; fieldArgument = RtfSupport.GetFieldArgument(ref scratch, num, out num2, out num3, out num4, out num5); if (num3 != 2 || scratch[num2] != '\\' || scratch[num2 + 1] != 's') { return(true); } num += fieldArgument; fieldArgument = RtfSupport.GetFieldArgument(ref scratch, num, out num2, out num3, out num4, out num5); num6 = 0; while (num6 < num3 && (c = scratch.Buffer[num2 + num6]) <= '9' && '0' <= c) { points = 10 * points + (short)(c - '0'); num6++; } return(true); }
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; } } }
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; } } }