Represents a range of nodes in a document.
예제 #1
0
 /// <summary>
 /// Wraps a range of nodes in a comment.
 /// </summary>
 /// <param name="nodeRange">The range of nodes to wrap in a comment.</param>
 /// <param name="text">The text of the comment.</param>
 /// <param name="author">The author's name.</param>
 /// <param name="initials">The author's initials.</param>
 /// <param name="date">The date of the comment.</param>
 /// <returns>The new comment.</returns>
 public static Comment WrapInComment(NodeRange nodeRange, string text, string author, string initials, DateTime date)
 {
     // http://www.aspose.com/community/forums/permalink/49509/224604/showthread.aspx#224604
     var comment = new Comment(nodeRange.Document, author, initials, date);
     SetCommentText(comment, text);
     InsertComment(nodeRange, comment);
     return comment;
 }
예제 #2
0
        /// <summary>
        /// Inserts a comment into a document.
        /// </summary>
        /// <param name="nodeRange">The range of nodes to insert the comment around.</param>
        /// <param name="comment">The comment to insert.</param>
        private static void InsertComment(NodeRange nodeRange, Comment comment)
        {
            // Create CommentRangeStart and CommentRangeEnd.
            var commentStart = new CommentRangeStart(nodeRange.Document, comment.Id);
            var commentEnd = new CommentRangeEnd(nodeRange.Document, comment.Id);

            // Insert the comment and range nodes at the appropriate locations.
            nodeRange.Start.ParentNode.InsertBefore(comment, nodeRange.Start);
            nodeRange.Start.ParentNode.InsertBefore(commentStart, nodeRange.Start);
            nodeRange.End.ParentNode.InsertAfter(commentEnd, nodeRange.End);
        }