internal bool Read() { if (m_htmlReader.Peek(out char c)) { if (c == '<') { if (m_htmlReader.Peek(1, out c)) { switch (c) { case '/': m_htmlReader.Advance(); ReadEndElement(); break; case '!': m_htmlReader.Advance(); ReadBangElement(); break; default: if (char.IsLetter(c)) { m_htmlReader.Advance(); ReadStartElement(); break; } ReadTextElement(); if (!string.IsNullOrEmpty(m_currentElement.Value)) { break; } return(Read()); } } else { ReadTextElement(); } return(true); } HtmlElement.HtmlElementType htmlElementType = HtmlElement.HtmlElementType.None; if (m_elementStack.Count > 0) { htmlElementType = m_elementStack.Peek().ElementType; if (htmlElementType == HtmlElement.HtmlElementType.STYLE || htmlElementType == HtmlElement.HtmlElementType.SCRIPT) { ReadScriptOrStyleContents(htmlElementType); return(true); } } ReadTextElement(); if (string.IsNullOrEmpty(m_currentElement.Value)) { return(Read()); } return(true); } return(false); }
private void RevertActionElement(HtmlElement.HtmlElementType elementType) { if (this.m_currentHyperlinkText != null) { this.m_currentHyperlinkText = null; base.m_currentStyle = base.m_currentStyle.RemoveStyle(elementType); } }
private ListStyle GetListStyleForElement(HtmlElement.HtmlElementType elementType) { if (elementType == HtmlElement.HtmlElementType.OL) { return(ListStyle.Numbered); } return(ListStyle.Bulleted); }
internal CompiledStyleInfo CreateChildStyle(HtmlElement.HtmlElementType elementType) { CompiledStyleInfo compiledStyleInfo = new CompiledStyleInfo(); compiledStyleInfo.m_elementType = elementType; compiledStyleInfo.m_parentStyle = this; m_childStyle = compiledStyleInfo; return(compiledStyleInfo); }
private void ReadStartElement() { int position = m_htmlReader.Position; HtmlElement.HtmlElementType type = ReadElementType(isEndElement: false); m_currentElement = new HtmlElement(HtmlElement.HtmlNodeType.Element, type, GetAttributesAsString(out bool isEmpty), isEmpty, position); m_elementStack.Push(m_currentElement); AdvanceToEndOfElement(); }
internal CompiledParagraphInfo CreateChildParagraph(HtmlElement.HtmlElementType elementType) { CompiledParagraphInfo compiledParagraphInfo = new CompiledParagraphInfo(); compiledParagraphInfo.ElementType = elementType; compiledParagraphInfo.m_parentParagraph = this; compiledParagraphInfo.m_flatStore = m_flatStore; m_childParagraph = compiledParagraphInfo; return(compiledParagraphInfo); }
private void ReadStartElement() { int position = this.m_htmlReader.Position; HtmlElement.HtmlElementType type = this.ReadElementType(false); bool isEmpty = default(bool); this.m_currentElement = new HtmlElement(HtmlElement.HtmlNodeType.Element, type, this.GetAttributesAsString(out isEmpty), isEmpty, position); this.m_elementStack.Push(this.m_currentElement); this.AdvanceToEndOfElement(); }
private void ReadEndElement() { int position = this.m_htmlReader.Position; HtmlElement.HtmlElementType elemntType = this.ReadElementType(true); this.m_currentElement = new HtmlElement(HtmlElement.HtmlNodeType.EndElement, elemntType, position); this.AdvanceToEndOfElement(); if (this.m_elementStack.Count > 0) { HtmlElement htmlElement = this.m_elementStack.Pop(); HtmlElement.HtmlElementType elementType = htmlElement.ElementType; } }
private void ReadScriptOrStyleContents(HtmlElement.HtmlElementType aElementType) { StringBuilder stringBuilder = new StringBuilder(); bool flag = true; int position = this.m_htmlReader.Position; char c = default(char); while (this.m_htmlReader.Peek(out c) && flag) { char c2 = c; if (c2 == '<') { this.m_htmlReader.Mark(); this.m_htmlReader.Advance(); char c3 = default(char); if (this.m_htmlReader.Peek(out c3)) { if (c3 == '!' && this.m_htmlReader.Peek(1, out c3) && c3 == '-' && this.m_htmlReader.Peek(2, out c3) && c3 == '-') { flag = false; this.m_htmlReader.Reset(); } else if (c3 == '/') { HtmlElement.HtmlElementType htmlElementType = this.ReadElementType(true); this.m_htmlReader.Reset(); if (htmlElementType == aElementType) { flag = false; } else { this.m_htmlReader.Advance(); stringBuilder.Append(c); } } else { stringBuilder.Append(c); } } } else { this.m_htmlReader.Advance(); stringBuilder.Append(c); } } this.m_currentElement = new HtmlElement((HtmlElement.HtmlNodeType)((aElementType == HtmlElement.HtmlElementType.SCRIPT) ? 4 : 5), HtmlElement.HtmlElementType.None, stringBuilder.ToString(), position); }
private void ReadScriptOrStyleContents(HtmlElement.HtmlElementType aElementType) { StringBuilder stringBuilder = new StringBuilder(); bool flag = true; int position = m_htmlReader.Position; char c; while (m_htmlReader.Peek(out c) && flag) { if (c == '<') { m_htmlReader.Mark(); m_htmlReader.Advance(); if (!m_htmlReader.Peek(out char c2)) { continue; } if (c2 == '!' && m_htmlReader.Peek(1, out c2) && c2 == '-' && m_htmlReader.Peek(2, out c2) && c2 == '-') { flag = false; m_htmlReader.Reset(); } else if (c2 == '/') { HtmlElement.HtmlElementType num = ReadElementType(isEndElement: true); m_htmlReader.Reset(); if (num == aElementType) { flag = false; continue; } m_htmlReader.Advance(); stringBuilder.Append(c); } else { stringBuilder.Append(c); } } else { m_htmlReader.Advance(); stringBuilder.Append(c); } } m_currentElement = new HtmlElement((aElementType == HtmlElement.HtmlElementType.SCRIPT) ? HtmlElement.HtmlNodeType.ScriptText : HtmlElement.HtmlNodeType.StyleText, HtmlElement.HtmlElementType.None, stringBuilder.ToString(), position); }
internal CompiledStyleInfo RemoveStyle(HtmlElement.HtmlElementType elementType) { if (m_elementType == elementType) { if (m_parentStyle != null) { m_parentStyle.m_childStyle = null; return(m_parentStyle); } ResetStyle(); } else if (m_parentStyle != null) { m_parentStyle.InternalRemoveStyle(elementType); } return(this); }
internal CompiledParagraphInfo RemoveParagraph(HtmlElement.HtmlElementType elementType) { if (m_elementType == elementType) { ApplySpaceAfter(); if (m_parentParagraph != null) { m_parentParagraph.m_childParagraph = null; return(m_parentParagraph); } ResetParagraph(); } else if (m_parentParagraph != null) { m_parentParagraph.InternalRemoveParagraph(elementType); } return(this); }
public void InternalRemoveStyle(HtmlElement.HtmlElementType elementType) { if (this.m_elementType == elementType) { if (this.m_parentStyle != null) { this.m_parentStyle.m_childStyle = this.m_childStyle; this.m_childStyle.m_parentStyle = this.m_parentStyle; } else if (this.m_parentStyle == null) { this.m_childStyle.m_parentStyle = null; } } else if (this.m_parentStyle != null) { this.m_parentStyle.InternalRemoveStyle(elementType); } }
internal void InternalRemoveStyle(HtmlElement.HtmlElementType elementType) { if (m_elementType == elementType) { if (m_parentStyle != null) { m_parentStyle.m_childStyle = m_childStyle; m_childStyle.m_parentStyle = m_parentStyle; } else if (m_parentStyle == null) { m_childStyle.m_parentStyle = null; } } else if (m_parentStyle != null) { m_parentStyle.InternalRemoveStyle(elementType); } }
public void InternalRemoveParagraph(HtmlElement.HtmlElementType elementType) { if (this.m_elementType == elementType) { this.ApplySpaceAfter(); if (this.m_parentParagraph != null) { this.m_parentParagraph.m_childParagraph = this.m_childParagraph; this.m_childParagraph.m_parentParagraph = this.m_parentParagraph; } else if (this.m_parentParagraph == null) { this.m_childParagraph.m_parentParagraph = null; } } else if (this.m_parentParagraph != null) { this.m_parentParagraph.InternalRemoveParagraph(elementType); } }
internal void InternalRemoveParagraph(HtmlElement.HtmlElementType elementType) { if (m_elementType == elementType) { ApplySpaceAfter(); if (m_parentParagraph != null) { m_parentParagraph.m_childParagraph = m_childParagraph; m_childParagraph.m_parentParagraph = m_parentParagraph; } else if (m_parentParagraph == null) { m_childParagraph.m_parentParagraph = null; } } else if (m_parentParagraph != null) { m_parentParagraph.InternalRemoveParagraph(elementType); } }
private void ParseParagraphElement(HtmlElement.HtmlElementType elementType, FunctionalList <ListStyle> listStyles) { this.CloseParagraph(); if (base.m_currentParagraph.ElementType == HtmlElement.HtmlElementType.P) { base.m_currentParagraph = base.m_currentParagraph.RemoveParagraph(HtmlElement.HtmlElementType.P); base.m_currentStyle = base.m_currentStyle.RemoveStyle(HtmlElement.HtmlElementType.P); } if (elementType == HtmlElement.HtmlElementType.LI) { this.FlushPendingLI(); if (listStyles.Count > 0) { base.m_currentParagraph.ListStyle = listStyles.First; } else { base.m_currentParagraph.ListStyle = ListStyle.Bulleted; } } else { base.m_currentStyle = base.m_currentStyle.CreateChildStyle(elementType); base.m_currentParagraph = base.m_currentParagraph.CreateChildParagraph(elementType); switch (elementType) { case HtmlElement.HtmlElementType.H1: base.m_currentStyle.FontSize = StyleDefaults.H1FontSize; base.m_currentStyle.FontWeight = FontWeights.Bold; this.SetMarginTopAndBottom(StyleDefaults.H1Margin); break; case HtmlElement.HtmlElementType.H2: base.m_currentStyle.FontSize = StyleDefaults.H2FontSize; base.m_currentStyle.FontWeight = FontWeights.Bold; this.SetMarginTopAndBottom(StyleDefaults.H2Margin); break; case HtmlElement.HtmlElementType.H3: base.m_currentStyle.FontSize = StyleDefaults.H3FontSize; base.m_currentStyle.FontWeight = FontWeights.Bold; this.SetMarginTopAndBottom(StyleDefaults.H3Margin); break; case HtmlElement.HtmlElementType.H4: base.m_currentStyle.FontSize = StyleDefaults.H4FontSize; base.m_currentStyle.FontWeight = FontWeights.Bold; this.SetMarginTopAndBottom(StyleDefaults.H4Margin); break; case HtmlElement.HtmlElementType.H5: base.m_currentStyle.FontSize = StyleDefaults.H5FontSize; base.m_currentStyle.FontWeight = FontWeights.Bold; this.SetMarginTopAndBottom(StyleDefaults.H5Margin); break; case HtmlElement.HtmlElementType.H6: base.m_currentStyle.FontSize = StyleDefaults.H6FontSize; base.m_currentStyle.FontWeight = FontWeights.Bold; this.SetMarginTopAndBottom(StyleDefaults.H6Margin); break; case HtmlElement.HtmlElementType.P: this.SetMarginTopAndBottom(StyleDefaults.PMargin); break; } string text = default(string); if (!this.m_currentHtmlElement.IsEmptyElement && this.m_currentHtmlElement.HasAttributes && base.m_allowMultipleParagraphs && this.m_currentHtmlElement.Attributes.TryGetValue("align", out text)) { TextAlignments textAlign = default(TextAlignments); if (RichTextStyleTranslator.TranslateTextAlign(text, out textAlign)) { base.m_currentStyle.TextAlign = textAlign; } else { base.m_richTextLogger.RegisterInvalidValueWarning("align", text, this.m_currentHtmlElement.CharacterPosition); } } } this.SetStyleValues(true); }
private void ParseTextRunElement(HtmlElement.HtmlElementType elementType) { m_currentStyle = m_currentStyle.CreateChildStyle(elementType); bool flag = false; switch (m_currentHtmlElement.ElementType) { case HtmlElement.HtmlElementType.I: case HtmlElement.HtmlElementType.EM: m_currentStyle.FontStyle = FontStyles.Italic; break; case HtmlElement.HtmlElementType.U: m_currentStyle.TextDecoration = TextDecorations.Underline; break; case HtmlElement.HtmlElementType.STRONG: case HtmlElement.HtmlElementType.B: m_currentStyle.FontWeight = FontWeights.Bold; break; case HtmlElement.HtmlElementType.STRIKE: case HtmlElement.HtmlElementType.S: m_currentStyle.TextDecoration = TextDecorations.LineThrough; break; case HtmlElement.HtmlElementType.SPAN: case HtmlElement.HtmlElementType.FONT: flag = true; break; } if (!flag || m_currentHtmlElement.IsEmptyElement || !m_currentHtmlElement.HasAttributes) { return; } if (m_currentHtmlElement.ElementType == HtmlElement.HtmlElementType.FONT) { if (m_currentHtmlElement.Attributes.TryGetValue("size", out string value)) { if (RichTextStyleTranslator.TranslateHtmlFontSize(value, out string translatedSize)) { m_currentStyle.FontSize = new ReportSize(translatedSize); } else { m_richTextLogger.RegisterInvalidSizeWarning("size", value, m_currentHtmlElement.CharacterPosition); } } if (m_currentHtmlElement.Attributes.TryGetValue("face", out value)) { m_currentStyle.FontFamily = value; } if (m_currentHtmlElement.Attributes.TryGetValue("color", out value)) { if (ReportColor.TryParse(RichTextStyleTranslator.TranslateHtmlColor(value), out ReportColor reportColor)) { m_currentStyle.Color = reportColor; } else { m_richTextLogger.RegisterInvalidColorWarning("color", value, m_currentHtmlElement.CharacterPosition); } } } else if (m_currentHtmlElement.ElementType == HtmlElement.HtmlElementType.SPAN) { SetStyleValues(isParagraph: false); } }
public bool Read() { char c = default(char); if (this.m_htmlReader.Peek(out c)) { char c2 = c; if (c2 == '<') { if (this.m_htmlReader.Peek(1, out c)) { switch (c) { case '/': this.m_htmlReader.Advance(); this.ReadEndElement(); break; case '!': this.m_htmlReader.Advance(); this.ReadBangElement(); break; default: if (char.IsLetter(c)) { this.m_htmlReader.Advance(); this.ReadStartElement(); break; } this.ReadTextElement(); if (!string.IsNullOrEmpty(this.m_currentElement.Value)) { break; } return(this.Read()); } } else { this.ReadTextElement(); } return(true); } HtmlElement.HtmlElementType htmlElementType = HtmlElement.HtmlElementType.None; if (this.m_elementStack.Count > 0) { htmlElementType = this.m_elementStack.Peek().ElementType; if (htmlElementType != HtmlElement.HtmlElementType.STYLE && htmlElementType != HtmlElement.HtmlElementType.SCRIPT) { goto IL_00c5; } this.ReadScriptOrStyleContents(htmlElementType); return(true); } goto IL_00c5; } return(false); IL_00c5: this.ReadTextElement(); if (string.IsNullOrEmpty(this.m_currentElement.Value)) { return(this.Read()); } return(true); }
protected override void InternalParse(string richText) { this.m_htmlLexer = new HtmlLexer(richText); int num = 0; FunctionalList <ListStyle> functionalList = FunctionalList <ListStyle> .Empty; HtmlElement.HtmlNodeType htmlNodeType = HtmlElement.HtmlNodeType.Element; HtmlElement.HtmlNodeType htmlNodeType2 = HtmlElement.HtmlNodeType.Element; HtmlElement.HtmlElementType htmlElementType = HtmlElement.HtmlElementType.None; HtmlElement.HtmlElementType htmlElementType2 = HtmlElement.HtmlElementType.None; while (this.m_htmlLexer.Read()) { this.m_currentHtmlElement = this.m_htmlLexer.CurrentElement; htmlElementType2 = this.m_currentHtmlElement.ElementType; htmlNodeType2 = this.m_currentHtmlElement.NodeType; switch (htmlNodeType2) { case HtmlElement.HtmlNodeType.Element: if (num != 0 && htmlElementType2 != HtmlElement.HtmlElementType.TITLE) { break; } switch (htmlElementType2) { case HtmlElement.HtmlElementType.TITLE: if (!this.m_currentHtmlElement.IsEmptyElement) { num++; } htmlElementType2 = htmlElementType; htmlNodeType2 = htmlNodeType; break; case HtmlElement.HtmlElementType.P: case HtmlElement.HtmlElementType.DIV: case HtmlElement.HtmlElementType.LI: case HtmlElement.HtmlElementType.H1: case HtmlElement.HtmlElementType.H2: case HtmlElement.HtmlElementType.H3: case HtmlElement.HtmlElementType.H4: case HtmlElement.HtmlElementType.H5: case HtmlElement.HtmlElementType.H6: this.ParseParagraphElement(htmlElementType2, functionalList); break; case HtmlElement.HtmlElementType.UL: case HtmlElement.HtmlElementType.OL: { this.FlushPendingLI(); this.CloseParagraph(); ListStyle listStyleForElement2 = this.GetListStyleForElement(htmlElementType2); functionalList = functionalList.Add(listStyleForElement2); base.m_currentParagraph.ListLevel = functionalList.Count; break; } case HtmlElement.HtmlElementType.SPAN: case HtmlElement.HtmlElementType.FONT: case HtmlElement.HtmlElementType.STRONG: case HtmlElement.HtmlElementType.STRIKE: case HtmlElement.HtmlElementType.B: case HtmlElement.HtmlElementType.I: case HtmlElement.HtmlElementType.U: case HtmlElement.HtmlElementType.S: case HtmlElement.HtmlElementType.EM: this.ParseTextRunElement(htmlElementType2); break; case HtmlElement.HtmlElementType.A: this.ParseActionElement(functionalList.Count); break; case HtmlElement.HtmlElementType.BR: if (htmlNodeType != HtmlElement.HtmlNodeType.EndElement) { this.AppendText(Environment.NewLine); } else { this.SetTextRunValue(Environment.NewLine); } break; default: htmlElementType2 = htmlElementType; htmlNodeType2 = htmlNodeType; break; } break; case HtmlElement.HtmlNodeType.Text: if (num == 0) { string text = this.m_currentHtmlElement.Value; if (htmlNodeType == HtmlElement.HtmlNodeType.Text) { this.AppendText(text); } else if (htmlElementType == HtmlElement.HtmlElementType.BR) { this.AppendText(this.HtmlTrimStart(text)); } else { if (base.m_currentParagraphInstance == null) { text = this.HtmlTrimStart(text); } if (!string.IsNullOrEmpty(text)) { this.SetTextRunValue(text); } else { htmlElementType2 = htmlElementType; htmlNodeType2 = htmlNodeType; } } } break; case HtmlElement.HtmlNodeType.EndElement: if (num != 0 && htmlElementType2 != HtmlElement.HtmlElementType.TITLE) { break; } switch (htmlElementType2) { case HtmlElement.HtmlElementType.TITLE: if (num > 0) { num--; } htmlElementType2 = htmlElementType; htmlNodeType2 = htmlNodeType; break; case HtmlElement.HtmlElementType.UL: case HtmlElement.HtmlElementType.OL: this.FlushPendingLI(); this.CloseParagraph(); if (functionalList.Count > 0) { ListStyle listStyleForElement = this.GetListStyleForElement(htmlElementType2); bool flag = false; FunctionalList <ListStyle> functionalList2 = functionalList; do { flag = (functionalList2.First == listStyleForElement); functionalList2 = functionalList2.Rest; }while (!flag && functionalList2.Count > 0); if (flag) { functionalList = functionalList2; base.m_currentParagraph.ListLevel = functionalList.Count; } } break; case HtmlElement.HtmlElementType.LI: this.CloseParagraph(); break; case HtmlElement.HtmlElementType.P: case HtmlElement.HtmlElementType.DIV: case HtmlElement.HtmlElementType.H1: case HtmlElement.HtmlElementType.H2: case HtmlElement.HtmlElementType.H3: case HtmlElement.HtmlElementType.H4: case HtmlElement.HtmlElementType.H5: case HtmlElement.HtmlElementType.H6: this.CloseParagraph(); base.m_currentParagraph = base.m_currentParagraph.RemoveParagraph(htmlElementType2); goto case HtmlElement.HtmlElementType.SPAN; case HtmlElement.HtmlElementType.SPAN: case HtmlElement.HtmlElementType.FONT: case HtmlElement.HtmlElementType.STRONG: case HtmlElement.HtmlElementType.STRIKE: case HtmlElement.HtmlElementType.B: case HtmlElement.HtmlElementType.I: case HtmlElement.HtmlElementType.U: case HtmlElement.HtmlElementType.S: case HtmlElement.HtmlElementType.EM: base.m_currentStyle = base.m_currentStyle.RemoveStyle(htmlElementType2); break; case HtmlElement.HtmlElementType.A: this.RevertActionElement(htmlElementType2); break; default: htmlElementType2 = htmlElementType; htmlNodeType2 = htmlNodeType; break; } break; } htmlNodeType = htmlNodeType2; htmlElementType = htmlElementType2; } if (base.m_paragraphInstanceCollection.Count == 0) { this.CreateTextRunInstance(); } base.m_currentParagraph = base.m_currentParagraph.RemoveAll(); }
private void ParseTextRunElement(HtmlElement.HtmlElementType elementType) { base.m_currentStyle = base.m_currentStyle.CreateChildStyle(elementType); bool flag = false; switch (this.m_currentHtmlElement.ElementType) { case HtmlElement.HtmlElementType.I: case HtmlElement.HtmlElementType.EM: base.m_currentStyle.FontStyle = FontStyles.Italic; break; case HtmlElement.HtmlElementType.U: base.m_currentStyle.TextDecoration = TextDecorations.Underline; break; case HtmlElement.HtmlElementType.STRONG: case HtmlElement.HtmlElementType.B: base.m_currentStyle.FontWeight = FontWeights.Bold; break; case HtmlElement.HtmlElementType.STRIKE: case HtmlElement.HtmlElementType.S: base.m_currentStyle.TextDecoration = TextDecorations.LineThrough; break; case HtmlElement.HtmlElementType.SPAN: case HtmlElement.HtmlElementType.FONT: flag = true; break; } if (flag && !this.m_currentHtmlElement.IsEmptyElement && this.m_currentHtmlElement.HasAttributes) { if (this.m_currentHtmlElement.ElementType == HtmlElement.HtmlElementType.FONT) { string text = default(string); if (this.m_currentHtmlElement.Attributes.TryGetValue("size", out text)) { string size = default(string); if (RichTextStyleTranslator.TranslateHtmlFontSize(text, out size)) { base.m_currentStyle.FontSize = new ReportSize(size); } else { base.m_richTextLogger.RegisterInvalidSizeWarning("size", text, this.m_currentHtmlElement.CharacterPosition); } } if (this.m_currentHtmlElement.Attributes.TryGetValue("face", out text)) { base.m_currentStyle.FontFamily = text; } if (this.m_currentHtmlElement.Attributes.TryGetValue("color", out text)) { ReportColor color = default(ReportColor); if (ReportColor.TryParse(RichTextStyleTranslator.TranslateHtmlColor(text), out color)) { base.m_currentStyle.Color = color; } else { base.m_richTextLogger.RegisterInvalidColorWarning("color", text, this.m_currentHtmlElement.CharacterPosition); } } } else if (this.m_currentHtmlElement.ElementType == HtmlElement.HtmlElementType.SPAN) { this.SetStyleValues(false); } } }
private void ParseParagraphElement(HtmlElement.HtmlElementType elementType, FunctionalList <ListStyle> listStyles) { CloseParagraph(); if (m_currentParagraph.ElementType == HtmlElement.HtmlElementType.P) { m_currentParagraph = m_currentParagraph.RemoveParagraph(HtmlElement.HtmlElementType.P); m_currentStyle = m_currentStyle.RemoveStyle(HtmlElement.HtmlElementType.P); } if (elementType == HtmlElement.HtmlElementType.LI) { FlushPendingLI(); if (listStyles.Count > 0) { m_currentParagraph.ListStyle = listStyles.First; } else { m_currentParagraph.ListStyle = ListStyle.Bulleted; } } else { m_currentStyle = m_currentStyle.CreateChildStyle(elementType); m_currentParagraph = m_currentParagraph.CreateChildParagraph(elementType); switch (elementType) { case HtmlElement.HtmlElementType.H1: m_currentStyle.FontSize = StyleDefaults.H1FontSize; m_currentStyle.FontWeight = FontWeights.Bold; SetMarginTopAndBottom(StyleDefaults.H1Margin); break; case HtmlElement.HtmlElementType.H2: m_currentStyle.FontSize = StyleDefaults.H2FontSize; m_currentStyle.FontWeight = FontWeights.Bold; SetMarginTopAndBottom(StyleDefaults.H2Margin); break; case HtmlElement.HtmlElementType.H3: m_currentStyle.FontSize = StyleDefaults.H3FontSize; m_currentStyle.FontWeight = FontWeights.Bold; SetMarginTopAndBottom(StyleDefaults.H3Margin); break; case HtmlElement.HtmlElementType.H4: m_currentStyle.FontSize = StyleDefaults.H4FontSize; m_currentStyle.FontWeight = FontWeights.Bold; SetMarginTopAndBottom(StyleDefaults.H4Margin); break; case HtmlElement.HtmlElementType.H5: m_currentStyle.FontSize = StyleDefaults.H5FontSize; m_currentStyle.FontWeight = FontWeights.Bold; SetMarginTopAndBottom(StyleDefaults.H5Margin); break; case HtmlElement.HtmlElementType.H6: m_currentStyle.FontSize = StyleDefaults.H6FontSize; m_currentStyle.FontWeight = FontWeights.Bold; SetMarginTopAndBottom(StyleDefaults.H6Margin); break; case HtmlElement.HtmlElementType.P: SetMarginTopAndBottom(StyleDefaults.PMargin); break; } if (!m_currentHtmlElement.IsEmptyElement && m_currentHtmlElement.HasAttributes && m_allowMultipleParagraphs && m_currentHtmlElement.Attributes.TryGetValue("align", out string value)) { if (RichTextStyleTranslator.TranslateTextAlign(value, out TextAlignments textAlignment)) { m_currentStyle.TextAlign = textAlignment; } else { m_richTextLogger.RegisterInvalidValueWarning("align", value, m_currentHtmlElement.CharacterPosition); } } } SetStyleValues(isParagraph: true); }