private List <Portion> GetPortions(A.Paragraph aParagraph, SCParagraph paragraph) { IEnumerable <A.Run> aRuns = aParagraph.Elements <A.Run>(); if (aRuns.Any()) { var runPortions = new List <Portion>(aRuns.Count()); foreach (A.Run aRun in aRuns) { runPortions.Add(new Portion(aRun.Text, paragraph)); } return(runPortions); } A.Field aField = aParagraph.GetFirstChild <A.Field>(); if (aField != null) { A.Text aText = aParagraph.GetFirstChild <A.Field>().GetFirstChild <A.Text>(); var aFieldPortions = new List <Portion>(new[] { new Portion(aText, paragraph) }); return(aFieldPortions); } return(new List <Portion>()); }
public static void GetFontDataFromPlaceholder(ref FontData phFontData, SCParagraph paragraph) { Shape fontParentShape = (Shape)paragraph.ParentTextBox.ParentTextBoxContainer; int paragraphLvl = paragraph.Level; if (fontParentShape.Placeholder == null) { return; } Placeholder placeholder = (Placeholder)fontParentShape.Placeholder; IFontDataReader phReferencedShape = (IFontDataReader)placeholder.ReferencedShape; phReferencedShape?.FillFontData(paragraphLvl, ref phFontData); }
/// <summary> /// Adds a new paragraph in collection. /// </summary> /// <returns>Added <see cref="SCParagraph" /> instance.</returns> public IParagraph Add() { // Create a new paragraph from the last paragraph and insert at the end A.Paragraph lastAParagraph = this.paragraphs.Value.Last().AParagraph; A.Paragraph newAParagraph = (A.Paragraph)lastAParagraph.CloneNode(true); lastAParagraph.InsertAfterSelf(newAParagraph); var newParagraph = new SCParagraph(newAParagraph, this.textBox) { Text = string.Empty }; this.paragraphs.Reset(); return(newParagraph); }
/// <summary> /// Initializes a new instance of the <see cref="PortionCollection"/> class. /// </summary> public PortionCollection(A.Paragraph aParagraph, SCParagraph paragraph) { this.portions = new ResettableLazy <List <Portion> >(() => this.GetPortions(aParagraph, paragraph)); }