private XElement ProcessStaticCells(TableElement tableElement, XElement previous) { var currentElement = tableElement.HasCell() ? tableElement.StartTag : this.CurrentCell(tableElement); return(ProcessStaticCells(currentElement, previous)); }
private XElement ProcessCell(TableElement tableElement, XElement previous, string text) { var isInnerCell = tableElement.HasCell(); var currentCell = this.CurrentCell(tableElement); previous = this.ProcessStaticCells(tableElement, previous); var parent = isInnerCell ? currentCell: tableElement.StartTag.Parent; var result = DocxHelper.CreateTextElement( tableElement.StartTag, parent, text); if (!isInnerCell) { tableElement.StartTag.AddAfterSelf(result); } else { if (currentCell.Elements(WordMl.ParagraphName).Any()) { currentCell.Elements(WordMl.ParagraphName).Remove(); } currentCell.Add(result); } if (previous != null && !previous.Equals(currentCell)) { currentCell.Remove(); previous.AddAfterSelf(currentCell); } else if (previous == null) { var parentRow = isInnerCell ? tableElement.StartTag.Parent : currentCell.Parent; currentCell.Remove(); parentRow.Add(currentCell); } return(currentCell); }
private XElement ProcessStaticCells(TableElement tableElement, XElement previous) { var currentElement = tableElement.HasCell() ? tableElement.StartTag : this.CurrentCell(tableElement); return ProcessStaticCells(currentElement, previous); }
private XElement ProcessCell(TableElement tableElement, XElement previous, string text) { var isInnerCell = tableElement.HasCell(); var currentCell = this.CurrentCell(tableElement); previous = this.ProcessStaticCells(tableElement, previous); var parent = isInnerCell ? currentCell: tableElement.StartTag.Parent; var result = DocxHelper.CreateTextElement( tableElement.StartTag, parent, text); if (!isInnerCell) { tableElement.StartTag.AddAfterSelf(result); } else { if (currentCell.Elements(WordMl.ParagraphName).Any()) { currentCell.Elements(WordMl.ParagraphName).Remove(); } currentCell.Add(result); } if (previous != null && !previous.Equals(currentCell)) { currentCell.Remove(); previous.AddAfterSelf(currentCell); } else if (previous == null) { var parentRow = isInnerCell ? tableElement.StartTag.Parent : currentCell.Parent; currentCell.Remove(); parentRow.Add(currentCell); } return currentCell; }