Aspose.Words.Examples.CSharp.Programming_Documents.Working_with_Fields.FieldsHelper.VisitParagraphEnd C# (CSharp) Method

VisitParagraphEnd() public method

public VisitParagraphEnd ( Paragraph paragraph ) : VisitorAction
paragraph Paragraph
return VisitorAction
        public override VisitorAction VisitParagraphEnd(Paragraph paragraph)
        {
            if (mFieldDepth > 0)
            {
                // The field code that is being converted continues onto another paragraph. We 
                // Need to copy the remaining content from this paragraph onto the next paragraph.
                Node nextParagraph = paragraph.NextSibling;

                // Skip ahead to the next available paragraph.
                while (nextParagraph != null && nextParagraph.NodeType != NodeType.Paragraph)
                    nextParagraph = nextParagraph.NextSibling;

                // Copy all of the nodes over. Keep a list of these nodes so we know not to remove them.
                while (paragraph.HasChildNodes)
                {
                    mNodesToSkip.Add(paragraph.LastChild);
                    ((Paragraph)nextParagraph).PrependChild(paragraph.LastChild);
                }

                paragraph.Remove();
            }

            return VisitorAction.Continue;
        }