static internal XElement[] SplitRun(Run r, int index) { Text t = r.GetFirstTextEffectedByEdit(index); XElement[] splitText = Text.SplitText(t, index); XElement splitLeft = new XElement(r.xml.Name, r.xml.Attributes(), r.xml.Element(XName.Get("rPr", DocX.w.NamespaceName)), t.xml.ElementsBeforeSelf().Where(n => n.Name.LocalName != "rPr"), splitText[0]); if (Paragraph.GetElementTextLength(splitLeft) == 0) { splitLeft = null; } XElement splitRight = new XElement(r.xml.Name, r.xml.Attributes(), r.xml.Element(XName.Get("rPr", DocX.w.NamespaceName)), splitText[1], t.xml.ElementsAfterSelf().Where(n => n.Name.LocalName != "rPr")); if (Paragraph.GetElementTextLength(splitRight) == 0) { splitRight = null; } return ( new XElement[] { splitLeft, splitRight } ); }
internal static XElement[] SplitRun(Run r, int index, EditType type = EditType.ins) { index -= r.StartIndex; Text firstTextEffectedByEdit = r.GetFirstTextEffectedByEdit(index, type); XElement[] array = Text.SplitText(firstTextEffectedByEdit, index); XElement xElement = new XElement(r.Xml.Name, r.Xml.Attributes(), r.Xml.Element(XName.Get("rPr", DocX.w.NamespaceName)), from n in firstTextEffectedByEdit.Xml.ElementsBeforeSelf() where n.Name.LocalName != "rPr" select n, array[0]); if (Paragraph.GetElementTextLength(xElement) == 0) { xElement = null; } XElement xElement2 = new XElement(r.Xml.Name, r.Xml.Attributes(), r.Xml.Element(XName.Get("rPr", DocX.w.NamespaceName)), array[1], from n in firstTextEffectedByEdit.Xml.ElementsAfterSelf() where n.Name.LocalName != "rPr" select n); if (Paragraph.GetElementTextLength(xElement2) == 0) { xElement2 = null; } return(new XElement[2] { xElement, xElement2 }); }