/// <summary> /// Apply all the current Html tag (Paragraph properties) to the specified paragrah. /// </summary> public override void ApplyTags(OpenXmlCompositeElement paragraph) { if (tags.Count == 0) { return; } ParagraphProperties properties = paragraph.GetFirstChild <ParagraphProperties>(); if (properties == null) { paragraph.PrependChild <ParagraphProperties>(properties = new ParagraphProperties()); } var en = tags.GetEnumerator(); while (en.MoveNext()) { TagsAtSameLevel tagsOfSameLevel = en.Current.Value.Peek(); foreach (OpenXmlElement tag in tagsOfSameLevel.Array) { SetProperties(properties, tag.CloneNode(true)); } } }
//____________________________________________________________________ // /// <summary> /// Apply all the current Html tag to the specified table cell. /// </summary> public override void ApplyTags(OpenXmlCompositeElement tableCell) { if (tags.Count > 0) { TableCellProperties properties = tableCell.GetFirstChild <TableCellProperties>(); if (properties == null) { tableCell.PrependChild <TableCellProperties>(properties = new TableCellProperties()); } var en = tags.GetEnumerator(); while (en.MoveNext()) { TagsAtSameLevel tagsOfSameLevel = en.Current.Value.Peek(); foreach (OpenXmlElement tag in tagsOfSameLevel.Array) { SetProperties(properties, tag.CloneNode(true)); } } } // Apply some style attributes on the unique Paragraph tag contained inside a table cell. Paragraph p = tableCell.GetFirstChild <Paragraph>(); paragraphStyle.ApplyTags(p); }
/// <summary> /// Apply all the current Html tag (Run properties) to the specified run. /// </summary> public override void ApplyTags(OpenXmlCompositeElement run) { if (tags.Count == 0 && DefaultRunStyle == null) { return; } RunProperties properties = run.GetFirstChild <RunProperties>(); if (properties == null) { run.PrependChild <RunProperties>(properties = new RunProperties()); } var en = tags.GetEnumerator(); while (en.MoveNext()) { TagsAtSameLevel tagsOfSameLevel = en.Current.Value.Peek(); foreach (OpenXmlElement tag in tagsOfSameLevel.Array) { SetProperties(properties, tag.CloneNode(true)); } } if (this.DefaultRunStyle != null) { properties.RunStyle = new RunStyle() { Val = this.DefaultRunStyle } } ; }