private Instruction ProcessRowsInstruction(ReaderContext context, DataSource dataSource) { // Find the paragraph that contains the run OpenXmlElement paragraph = context.FieldData.SourceStart.SourceNode.Parent as Paragraph; // Find the row that contains the paragraph OpenXmlElement row = paragraph?.Parent?.Parent as TableRow; if (row == null) { return(null); } // Capture the row int i = _tokenBuffer.FindTokenInBuffer(row); var newBuffer = _tokenBuffer.SnipFromBuffer(i); // Create an instruction for boring data encountered so far FlushTokenBufferToDataInstruction(); // Update the token buffer with the snipped portion _tokenBuffer = newBuffer; var rel = new ForEachInstruction { DataSource = dataSource }; rel.ImplicitlyEndAfter = new Token(row, true); return(rel); }
private Instruction ProcessForEachInstruction(ReaderContext context, DataSource dataSource) { // Create an instruction for boring data encountered so far FlushTokenBufferToDataInstruction(); var rel = new ForEachInstruction { DataSource = dataSource }; // Find the paragraph that contains the run OpenXmlElement paragraph = context.FieldData.SourceStart.SourceNode.Parent as Paragraph; if (paragraph != null) { // implicitly end at the end of the container that contains the current paragraph rel.ImplicitlyEndBefore = new Token(paragraph.Parent, true); } return(rel); }