public override void Process() { base.Process(); var element = TextTag.TagNode; var text = DataReader.ReadText(TextTag.Expression); XElement parent = element.Parent; if (parent.Name == WordMl.TableRowName) { parent = element.Element(WordMl.SdtContentName).Element(WordMl.TableCellName); } var textElement = DocxHelper.CreateTextElement(element, parent, text); var result = this.CreateDynamicContentTags ? DocxHelper.CreateDynamicContentElement(new[] { textElement }, this.TextTag.TagNode, this.DynamicContentLockingType) : textElement; if (element.Parent.Name != WordMl.TableRowName) { element.AddBeforeSelf(result); } else { var cell = new XElement(WordMl.TableCellName, result); cell.AddFirst(element.Descendants(WordMl.TableCellPropertiesName)); element.AddBeforeSelf(cell); } element.Remove(); }
public override void Process() { base.Process(); ProcessDynamicContent(); if (TableTag == null) { throw new NullReferenceException(); } var tableRows = TableTag.Table.Elements(WordMl.TableRowName); var dynamicRow = TableTag.DynamicRow.HasValue ? tableRows.ElementAt(TableTag.DynamicRow.Value - 1) : tableRows.Last(); ReplaceValues(dynamicRow); if (this.CreateDynamicContentTags) { var innerElements = TraverseUtils.ElementsBetween(this.TableTag.TagTable, this.TableTag.TagEndTable).ToList(); innerElements.Remove(); this.TableTag.TagTable.AddBeforeSelf(DocxHelper.CreateDynamicContentElement(innerElements, this.TableTag.TagTable, this.DynamicContentLockingType)); this.CleanUp(this.TableTag.TagTable, this.TableTag.TagEndTable); } else { RemoveTags(); } }
public override void Process() { base.Process(); this.ProcessDynamicContent(); bool truthful; try { truthful = bool.Parse(this.DataReader.ReadText(this.Tag.Conidition)); } catch (System.FormatException) { truthful = false; } catch (System.Xml.XPath.XPathException) { truthful = false; } if (!truthful) { if (this.CreateDynamicContentTags) { this.Tag.StartIf.AddBeforeSelf(DocxHelper.CreateDynamicContentElement(Enumerable.Empty <XElement>(), this.Tag.StartIf, this.DynamicContentLockingType)); } this.CleanUp(this.Tag.StartIf, this.Tag.EndIf); } else { if (this.CreateDynamicContentTags) { var innerElements = TraverseUtils.ElementsBetween(this.Tag.StartIf, this.Tag.EndIf).ToList(); innerElements.Remove(); this.Tag.StartIf.AddBeforeSelf(DocxHelper.CreateDynamicContentElement(innerElements, this.Tag.StartIf, this.DynamicContentLockingType)); this.CleanUp(this.Tag.StartIf, this.Tag.EndIf); } else { this.Tag.StartIf.Remove(); this.Tag.EndIf.Remove(); } } }
public override void Process() { base.Process(); this.ProcessDynamicContent(); var current = RepeaterTag.StartRepeater; var dataReaders = DataReader.GetReaders(RepeaterTag.Source).ToList(); var repeaterElements = TraverseUtils.SecondElementsBetween(RepeaterTag.StartRepeater, RepeaterTag.EndRepeater) .Select(RepeaterTag.MakeElementCallback).ToList(); for (var index = 0; index < dataReaders.Count; index++) { XElement endIfElementTmp = null; XElement endRepeaterElementTmp = null; XElement endItemTableElement = null; current = this.ProcessElements(repeaterElements, dataReaders[index], current, null, index + 1, ref endIfElementTmp, ref endRepeaterElementTmp, ref endItemTableElement); } foreach (var repeaterElement in repeaterElements) { repeaterElement.XElement.Remove(); } if (this.CreateDynamicContentTags) { var innerElements = TraverseUtils.ElementsBetween(this.RepeaterTag.StartRepeater, this.RepeaterTag.EndRepeater).ToList(); innerElements.Remove(); this.RepeaterTag.StartRepeater.AddBeforeSelf( DocxHelper.CreateDynamicContentElement( innerElements, this.RepeaterTag.StartRepeater, this.DynamicContentLockingType)); this.CleanUp(this.RepeaterTag.StartRepeater, this.RepeaterTag.EndRepeater); } else { this.RepeaterTag.StartRepeater.Remove(); this.RepeaterTag.EndRepeater.Remove(); } }