예제 #1
0
        public void EndComment(string commentId)
        {
            CommentRangeEnd commentRangeEnd = new CommentRangeEnd()
            {
                Id = commentId
            };

            _runList.Add(commentRangeEnd);

            Run commentRun = new Run();

            CommentReference commentReference = new CommentReference()
            {
                Id = commentId
            };

            commentRun.Append(commentReference);

            _runList.Add(commentRun);
        }
예제 #2
0
        /// <summary>
        /// Edit Comment and CommentEx
        /// </summary>
        /// <param name="filePath">Editing target file path</param>
        /// <param name="log">Logger</param>
        public void EditElements(string filePath, VerifiableLog log)
        {
            using (WordprocessingDocument package = WordprocessingDocument.Open(filePath, true))
            {
                WordprocessingCommentsPart   commentPart   = package.MainDocumentPart.WordprocessingCommentsPart;
                WordprocessingCommentsExPart commentExPart = package.MainDocumentPart.WordprocessingCommentsExPart;
                Comment       comment   = null;
                W15.CommentEx commentEx = null;

                try
                {
                    //2.1 Change comment text
                    comment = GetComment(commentPart, CommentIDs.CommentID1);
                    Text text = comment.Descendants <Text>().First();
                    text.Text = CommentStrings.CommentChangeString1;

                    log.Pass("Edited comment text. comment ID=[{0}]. comment text=[{1}].", CommentIDs.CommentID1, CommentStrings.CommentChangeString1);
                }
                catch (Exception e)
                {
                    log.Fail(e.Message);
                }

                try
                {
                    //2.2 Change commnet initials attribute
                    comment = GetComment(commentPart, CommentIDs.CommentID1);

                    comment.Initials = CommentInitials.Initial2;
                    log.Pass("Edited comment attribute of Initials. comment ID=[{0}]. Initials=[{1}].", CommentIDs.CommentID1, CommentInitials.Initial2);

                    //2.2 Change commnet date attribute
                    comment.Date = new DateTimeValue(new DateTime(2015, 12, 24, 12, 34, 56, 77));
                    log.Pass("Edited comment attribute of Date. comment ID=[{0}]. Date=[{1}/{2}/{3}-{4}:{5}:{6}-{7}].", CommentIDs.CommentID1, 12, 24, 2015, 12, 34, 56, 77);

                    //2.2 Change commnet author attribute
                    comment.Author = CommentAuthors.Author2;
                    log.Pass("Edited comment attribute of Author. comment ID=[{0}]. Author=[{1}].", CommentIDs.CommentID1, CommentAuthors.Author2);
                }
                catch (Exception e)
                {
                    log.Fail(e.Message);
                }

                try
                {
                    //2.3 Change comment parent-child relationship, Case of parent attribute deleteing.
                    commentEx = GetCommentEx(commentPart, commentExPart, CommentIDs.CommentID2);
                    commentEx.ParaIdParent = null;
                    log.Pass("Edited CommentEx parent-child relationship, Set CommentEx parent id is null. comment ID=[{0}]. CommentEx.ParaIdParent=[null].", CommentIDs.CommentID2);

                    //2.3 Change comment parent-child relationship, Case of parent attribute appending.
                    commentEx = GetCommentEx(commentPart, commentExPart, CommentIDs.CommentID3);
                    W15.CommentEx comEx = GetCommentEx(commentPart, commentExPart, CommentIDs.CommentID2);
                    commentEx.ParaIdParent = comEx.ParaId;
                    log.Pass("Edited CommentEx parent-child relationship, Set CommentEx parent id is comment(id=1) have id. comment ID=[{0}]. CommentEx.ParaIdParent=[{1}].", CommentIDs.CommentID3, comEx.ParaId.Value);
                }
                catch (Exception e)
                {
                    log.Fail(e.Message);
                }

                try
                {
                    //2.4 Change CommnetEx done attribute, Case of value "1" setting.
                    GetCommentEx(commentPart, commentExPart, CommentIDs.CommentID1).Done = true;
                    log.Pass("Edited CommentEx attribute of Done. comment ID=[{0}]. Done=[true].", CommentIDs.CommentID1);

                    //2.4 Change CommnetEx done attribute, Case of value "0" setting.
                    GetCommentEx(commentPart, commentExPart, CommentIDs.CommentID3).Done = false;
                    log.Pass("Edited CommentEx attribute of Done. comment ID=[{0}]. Done=[false].", CommentIDs.CommentID3);
                }
                catch (Exception e)
                {
                    log.Fail(e.Message);
                }

                try
                {
                    //2.5 Add comment and CommentEx.
                    CommentRangeStart commentRangeStart1 = new CommentRangeStart();
                    commentRangeStart1.Id = CommentIDs.CommentID4;
                    CommentRangeEnd CommentRangeEnd1 = new CommentRangeEnd();
                    CommentRangeEnd1.Id = CommentIDs.CommentID4;

                    Paragraph paragraph1 = package.MainDocumentPart.Document.Descendants <Paragraph>().Where(e => e.InnerText == CommentBodyStrings.Comment2).First();
                    paragraph1.Descendants <Run>().Where(e => e.InnerText == CommentBodyStrings.Comment2).First().InsertBeforeSelf <CommentRangeStart>(commentRangeStart1);
                    paragraph1.Descendants <Run>().Where(e => e.InnerText == CommentBodyStrings.Comment2).First().InsertAfterSelf <CommentRangeEnd>(CommentRangeEnd1);

                    CommentReference commentReference1 = new CommentReference();
                    commentReference1.Id = CommentIDs.CommentID4;
                    Run run1 = new Run();
                    run1.AppendChild <CommentReference>(commentReference1);

                    paragraph1.AppendChild <Run>(run1);
                    Comment comment1 = (Comment)GetComment(commentPart, CommentIDs.CommentID1).Clone();
                    comment1.Id = CommentIDs.CommentID4;
                    comment1.Descendants <Text>().First().Text             = CommentStrings.CommentAppendString1;
                    comment1.Descendants <Paragraph>().First().ParagraphId = AppendCommentExIDs.AppendCommentID1;

                    commentPart.Comments.AppendChild <Comment>(comment1);

                    W15.CommentEx commentEx1 = new W15.CommentEx();
                    commentEx1.ParaId = AppendCommentExIDs.AppendCommentID1;
                    commentExPart.CommentsEx.AppendChild <W15.CommentEx>(commentEx1);

                    log.Pass("Append new comment. comment ID=[{0}]. comment text=[{1}]. CommentEx.ParaIdParent=[null].", CommentIDs.CommentID4, CommentStrings.CommentAppendString1);

                    //2.5 Add comment and CommentEx.
                    CommentRangeStart commentRangeStart2 = new CommentRangeStart();
                    commentRangeStart2.Id = CommentIDs.CommentID5;
                    CommentRangeEnd CommentRangeEnd2 = new CommentRangeEnd();
                    CommentRangeEnd2.Id = CommentIDs.CommentID5;

                    Paragraph paragraph2 = package.MainDocumentPart.Document.Descendants <Paragraph>().Where(e => e.InnerText == CommentBodyStrings.Comment2).First();
                    paragraph2.Descendants <Run>().Where(e => e.InnerText == CommentBodyStrings.Comment2).First().InsertBeforeSelf <CommentRangeStart>(commentRangeStart2);
                    paragraph2.Descendants <Run>().Where(e => e.InnerText == CommentBodyStrings.Comment2).First().InsertAfterSelf <CommentRangeEnd>(CommentRangeEnd2);

                    CommentReference commentReference2 = new CommentReference();
                    commentReference2.Id = CommentIDs.CommentID5;
                    Run run2 = new Run();
                    run2.AppendChild <CommentReference>(commentReference2);

                    paragraph2.AppendChild <Run>(run2);
                    Comment comment2 = (Comment)GetComment(commentPart, CommentIDs.CommentID2).Clone();
                    comment2.Id = CommentIDs.CommentID5;
                    comment2.Descendants <Text>().First().Text             = CommentStrings.CommentAppendString2;
                    comment2.Descendants <Paragraph>().First().ParagraphId = AppendCommentExIDs.AppendCommentID2;

                    commentPart.Comments.AppendChild <Comment>(comment2);

                    W15.CommentEx commentEx2 = new W15.CommentEx();
                    commentEx2.ParaId       = AppendCommentExIDs.AppendCommentID2;
                    commentEx2.ParaIdParent = AppendCommentExIDs.AppendCommentID1;
                    commentExPart.CommentsEx.AppendChild <W15.CommentEx>(commentEx2);

                    log.Pass("Append new comment. comment ID=[{0}]. comment text=[{1}]. CommentEx.ParaIdParent=[{2}].", CommentIDs.CommentID5, CommentStrings.CommentAppendString2, AppendCommentExIDs.AppendCommentID1);
                }
                catch (Exception e)
                {
                    log.Fail(e.Message);
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Edit Comment and CommentEx
        /// </summary>
        /// <param name="stream">Package stream</param>
        /// <param name="log">Logger</param>
        public static void EditElements(Stream stream)
        {
            using (WordprocessingDocument package = WordprocessingDocument.Open(stream, true))
            {
                WordprocessingCommentsPart   commentPart   = package.MainDocumentPart.WordprocessingCommentsPart;
                WordprocessingCommentsExPart commentExPart = package.MainDocumentPart.WordprocessingCommentsExPart;
                Comment       comment   = null;
                W15.CommentEx commentEx = null;

                //2.1 Change comment text
                comment = GetComment(commentPart, CommentIDs.CommentID1);
                Text text = comment.Descendants <Text>().First();
                text.Text = CommentStrings.CommentChangeString1;

                //2.2 Change comment initials attribute
                comment = GetComment(commentPart, CommentIDs.CommentID1);

                comment.Initials = CommentInitials.Initial2;

                //2.2 Change comment date attribute
                comment.Date = new DateTimeValue(new DateTime(2015, 12, 24, 12, 34, 56, 77));

                //2.2 Change comment author attribute
                comment.Author = CommentAuthors.Author2;

                //2.3 Change comment parent-child relationship, Case of parent attribute deletion.
                commentEx = GetCommentEx(commentPart, commentExPart, CommentIDs.CommentID2);
                commentEx.ParaIdParent = null;

                //2.3 Change comment parent-child relationship, Case of parent attribute appending.
                commentEx = GetCommentEx(commentPart, commentExPart, CommentIDs.CommentID3);
                W15.CommentEx comEx = GetCommentEx(commentPart, commentExPart, CommentIDs.CommentID2);
                commentEx.ParaIdParent = comEx.ParaId;

                //2.4 Change commentEx done attribute, Case of value "1" setting.
                GetCommentEx(commentPart, commentExPart, CommentIDs.CommentID1).Done = true;

                //2.4 Change commentEx done attribute, Case of value "0" setting.
                GetCommentEx(commentPart, commentExPart, CommentIDs.CommentID3).Done = false;

                //2.5 Add comment and CommentEx.
                CommentRangeStart commentRangeStart1 = new CommentRangeStart();
                commentRangeStart1.Id = CommentIDs.CommentID4;
                CommentRangeEnd CommentRangeEnd1 = new CommentRangeEnd();
                CommentRangeEnd1.Id = CommentIDs.CommentID4;

                Paragraph paragraph1 = package.MainDocumentPart.Document.Descendants <Paragraph>().Where(e => e.InnerText == CommentBodyStrings.Comment2).First();
                paragraph1.Descendants <Run>().Where(e => e.InnerText == CommentBodyStrings.Comment2).First().InsertBeforeSelf <CommentRangeStart>(commentRangeStart1);
                paragraph1.Descendants <Run>().Where(e => e.InnerText == CommentBodyStrings.Comment2).First().InsertAfterSelf <CommentRangeEnd>(CommentRangeEnd1);

                CommentReference commentReference1 = new CommentReference();
                commentReference1.Id = CommentIDs.CommentID4;
                Run run1 = new Run();
                run1.AppendChild <CommentReference>(commentReference1);

                paragraph1.AppendChild <Run>(run1);
                Comment comment1 = (Comment)GetComment(commentPart, CommentIDs.CommentID1).Clone();
                comment1.Id = CommentIDs.CommentID4;
                comment1.Descendants <Text>().First().Text             = CommentStrings.CommentAppendString1;
                comment1.Descendants <Paragraph>().First().ParagraphId = AppendCommentExIDs.AppendCommentID1;

                commentPart.Comments.AppendChild <Comment>(comment1);

                W15.CommentEx commentEx1 = new W15.CommentEx();
                commentEx1.ParaId = AppendCommentExIDs.AppendCommentID1;
                commentExPart.CommentsEx.AppendChild <W15.CommentEx>(commentEx1);

                //2.5 Add comment and CommentEx.
                CommentRangeStart commentRangeStart2 = new CommentRangeStart();
                commentRangeStart2.Id = CommentIDs.CommentID5;
                CommentRangeEnd CommentRangeEnd2 = new CommentRangeEnd();
                CommentRangeEnd2.Id = CommentIDs.CommentID5;

                Paragraph paragraph2 = package.MainDocumentPart.Document.Descendants <Paragraph>().Where(e => e.InnerText == CommentBodyStrings.Comment2).First();
                paragraph2.Descendants <Run>().Where(e => e.InnerText == CommentBodyStrings.Comment2).First().InsertBeforeSelf <CommentRangeStart>(commentRangeStart2);
                paragraph2.Descendants <Run>().Where(e => e.InnerText == CommentBodyStrings.Comment2).First().InsertAfterSelf <CommentRangeEnd>(CommentRangeEnd2);

                CommentReference commentReference2 = new CommentReference();
                commentReference2.Id = CommentIDs.CommentID5;
                Run run2 = new Run();
                run2.AppendChild <CommentReference>(commentReference2);

                paragraph2.AppendChild <Run>(run2);
                Comment comment2 = (Comment)GetComment(commentPart, CommentIDs.CommentID2).Clone();
                comment2.Id = CommentIDs.CommentID5;
                comment2.Descendants <Text>().First().Text             = CommentStrings.CommentAppendString2;
                comment2.Descendants <Paragraph>().First().ParagraphId = AppendCommentExIDs.AppendCommentID2;

                commentPart.Comments.AppendChild <Comment>(comment2);

                W15.CommentEx commentEx2 = new W15.CommentEx();
                commentEx2.ParaId       = AppendCommentExIDs.AppendCommentID2;
                commentEx2.ParaIdParent = AppendCommentExIDs.AppendCommentID1;
                commentExPart.CommentsEx.AppendChild <W15.CommentEx>(commentEx2);
            }
        }
예제 #4
0
        /// <summary>
        /// Get the <see cref="CommentContent"/> for a <see cref="CommentReference"/>.
        /// </summary>
        /// <param name="commentReference">The <see cref="CommentReference"/> which identifies the comment.</param>
        /// <returns>The <see cref="CommentContent"/> for the <see cref="CommentReference"/>.</returns>
        public virtual CommentContent GetCommentContent(CommentReference commentReference)
        {
            CommentItem commentItem = Database.GetItem(commentReference.Uri);

            return(commentItem);
        }
예제 #5
0
        // Generates content of mainDocumentPart1.
        private void GenerateMainDocumentPart1Content(MainDocumentPart mainDocumentPart1)
        {
            Document document1 = new Document(){ MCAttributes = new MarkupCompatibilityAttributes(){ Ignorable = "w14 w15 wp14" }  };
            document1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
            document1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            document1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office");
            document1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            document1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math");
            document1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml");
            document1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
            document1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
            document1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word");
            document1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
            document1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml");
            document1.AddNamespaceDeclaration("w15", "http://schemas.microsoft.com/office/word/2012/wordml");
            document1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
            document1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
            document1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml");
            document1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape");

            Body body1 = new Body();

            Paragraph paragraph1 = new Paragraph(){ RsidParagraphAddition = "0008591D", RsidParagraphProperties = "009423EF", RsidRunAdditionDefault = "009423EF", ParagraphId = "0F416DF1", TextId = "77777777" };
            BookmarkStart bookmarkStart1 = new BookmarkStart(){ Name = "_GoBack", Id = "0" };
            BookmarkEnd bookmarkEnd1 = new BookmarkEnd(){ Id = "0" };
            CommentRangeStart commentRangeStart1 = new CommentRangeStart(){ Id = "1" };
            CommentRangeStart commentRangeStart2 = new CommentRangeStart(){ Id = "2" };

            Run run1 = new Run();

            RunProperties runProperties1 = new RunProperties();
            RunFonts runFonts1 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties1.Append(runFonts1);
            Text text1 = new Text();
            text1.Text = "Test1";

            run1.Append(runProperties1);
            run1.Append(text1);
            CommentRangeEnd commentRangeEnd1 = new CommentRangeEnd(){ Id = "1" };

            Run run2 = new Run();

            RunProperties runProperties2 = new RunProperties();
            RunStyle runStyle1 = new RunStyle(){ Val = "a3" };

            runProperties2.Append(runStyle1);
            CommentReference commentReference1 = new CommentReference(){ Id = "1" };

            run2.Append(runProperties2);
            run2.Append(commentReference1);
            CommentRangeEnd commentRangeEnd2 = new CommentRangeEnd(){ Id = "2" };

            Run run3 = new Run();

            RunProperties runProperties3 = new RunProperties();
            RunStyle runStyle2 = new RunStyle(){ Val = "a3" };

            runProperties3.Append(runStyle2);
            CommentReference commentReference2 = new CommentReference(){ Id = "2" };

            run3.Append(runProperties3);
            run3.Append(commentReference2);

            paragraph1.Append(bookmarkStart1);
            paragraph1.Append(bookmarkEnd1);
            paragraph1.Append(commentRangeStart1);
            paragraph1.Append(commentRangeStart2);
            paragraph1.Append(run1);
            paragraph1.Append(commentRangeEnd1);
            paragraph1.Append(run2);
            paragraph1.Append(commentRangeEnd2);
            paragraph1.Append(run3);

            Paragraph paragraph2 = new Paragraph(){ RsidParagraphMarkRevision = "009423EF", RsidParagraphAddition = "009423EF", RsidParagraphProperties = "009423EF", RsidRunAdditionDefault = "009423EF", ParagraphId = "5C236322", TextId = "77777777" };
            CommentRangeStart commentRangeStart3 = new CommentRangeStart(){ Id = "3" };

            Run run4 = new Run();

            RunProperties runProperties4 = new RunProperties();
            RunFonts runFonts2 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia };

            runProperties4.Append(runFonts2);
            Text text2 = new Text();
            text2.Text = "Test2";

            run4.Append(runProperties4);
            run4.Append(text2);
            CommentRangeEnd commentRangeEnd3 = new CommentRangeEnd(){ Id = "3" };

            Run run5 = new Run();

            RunProperties runProperties5 = new RunProperties();
            RunStyle runStyle3 = new RunStyle(){ Val = "a3" };

            runProperties5.Append(runStyle3);
            CommentReference commentReference3 = new CommentReference(){ Id = "3" };

            run5.Append(runProperties5);
            run5.Append(commentReference3);

            paragraph2.Append(commentRangeStart3);
            paragraph2.Append(run4);
            paragraph2.Append(commentRangeEnd3);
            paragraph2.Append(run5);

            SectionProperties sectionProperties1 = new SectionProperties(){ RsidRPr = "009423EF", RsidR = "009423EF" };
            PageSize pageSize1 = new PageSize(){ Width = (UInt32Value)11906U, Height = (UInt32Value)16838U };
            PageMargin pageMargin1 = new PageMargin(){ Top = 1985, Right = (UInt32Value)1701U, Bottom = 1701, Left = (UInt32Value)1701U, Header = (UInt32Value)851U, Footer = (UInt32Value)992U, Gutter = (UInt32Value)0U };
            Columns columns1 = new Columns(){ Space = "425" };
            DocGrid docGrid1 = new DocGrid(){ Type = DocGridValues.Lines, LinePitch = 360 };

            sectionProperties1.Append(pageSize1);
            sectionProperties1.Append(pageMargin1);
            sectionProperties1.Append(columns1);
            sectionProperties1.Append(docGrid1);

            body1.Append(paragraph1);
            body1.Append(paragraph2);
            body1.Append(sectionProperties1);

            document1.Append(body1);

            mainDocumentPart1.Document = document1;
        }
예제 #6
0
        /// <summary>
        /// Edit Comment and CommentEx
        /// </summary>
        /// <param name="filePath">Editing target file path</param>
        /// <param name="log">Logger</param>
        public void EditElements(string filePath, VerifiableLog log)
        {
            using (WordprocessingDocument package = WordprocessingDocument.Open(filePath, true))
            {
                WordprocessingCommentsPart commentPart = package.MainDocumentPart.WordprocessingCommentsPart;
                WordprocessingCommentsExPart commentExPart = package.MainDocumentPart.WordprocessingCommentsExPart;
                Comment comment = null;
                W15.CommentEx commentEx = null;

                try
                {
                    //2.1 Change comment text
                    comment = GetComment(commentPart, CommentIDs.CommentID1);
                    Text text = comment.Descendants<Text>().First();
                    text.Text = CommentStrings.CommentChangeString1;

                    log.Pass("Edited comment text. comment ID=[{0}]. comment text=[{1}].", CommentIDs.CommentID1, CommentStrings.CommentChangeString1);
                }
                catch (Exception e)
                {
                    log.Fail(e.Message);
                }

                try
                {
                    //2.2 Change commnet initials attribute
                    comment = GetComment(commentPart, CommentIDs.CommentID1);

                    comment.Initials = CommentInitials.Initial2;
                    log.Pass("Edited comment attribute of Initials. comment ID=[{0}]. Initials=[{1}].", CommentIDs.CommentID1, CommentInitials.Initial2);

                    //2.2 Change commnet date attribute
                    comment.Date = new DateTimeValue(new DateTime(2015, 12, 24, 12, 34, 56, 77));
                    log.Pass("Edited comment attribute of Date. comment ID=[{0}]. Date=[{1}/{2}/{3}-{4}:{5}:{6}-{7}].", CommentIDs.CommentID1, 12, 24, 2015, 12, 34, 56, 77);

                    //2.2 Change commnet author attribute
                    comment.Author = CommentAuthors.Author2;
                    log.Pass("Edited comment attribute of Author. comment ID=[{0}]. Author=[{1}].", CommentIDs.CommentID1, CommentAuthors.Author2);
                }
                catch (Exception e)
                {
                    log.Fail(e.Message);
                }

                try
                {
                    //2.3 Change comment parent-child relationship, Case of parent attribute deleteing.
                    commentEx = GetCommentEx(commentPart, commentExPart, CommentIDs.CommentID2);
                    commentEx.ParaIdParent = null;
                    log.Pass("Edited CommentEx parent-child relationship, Set CommentEx parent id is null. comment ID=[{0}]. CommentEx.ParaIdParent=[null].", CommentIDs.CommentID2);

                    //2.3 Change comment parent-child relationship, Case of parent attribute appending.
                    commentEx = GetCommentEx(commentPart, commentExPart, CommentIDs.CommentID3);
                    W15.CommentEx comEx = GetCommentEx(commentPart, commentExPart, CommentIDs.CommentID2);
                    commentEx.ParaIdParent = comEx.ParaId;
                    log.Pass("Edited CommentEx parent-child relationship, Set CommentEx parent id is comment(id=1) have id. comment ID=[{0}]. CommentEx.ParaIdParent=[{1}].", CommentIDs.CommentID3, comEx.ParaId.Value);
                }
                catch (Exception e)
                {
                    log.Fail(e.Message);
                }

                try
                {
                    //2.4 Change CommnetEx done attribute, Case of value "1" setting. 
                    GetCommentEx(commentPart, commentExPart, CommentIDs.CommentID1).Done = true;
                    log.Pass("Edited CommentEx attribute of Done. comment ID=[{0}]. Done=[true].", CommentIDs.CommentID1);

                    //2.4 Change CommnetEx done attribute, Case of value "0" setting. 
                    GetCommentEx(commentPart, commentExPart, CommentIDs.CommentID3).Done = false;
                    log.Pass("Edited CommentEx attribute of Done. comment ID=[{0}]. Done=[false].", CommentIDs.CommentID3);
                }
                catch (Exception e)
                {
                    log.Fail(e.Message);
                }

                try
                {
                    //2.5 Add comment and CommentEx.
                    CommentRangeStart commentRangeStart1 = new CommentRangeStart();
                    commentRangeStart1.Id = CommentIDs.CommentID4;
                    CommentRangeEnd CommentRangeEnd1 = new CommentRangeEnd();
                    CommentRangeEnd1.Id = CommentIDs.CommentID4;

                    Paragraph paragraph1 = package.MainDocumentPart.Document.Descendants<Paragraph>().Where(e => e.InnerText == CommentBodyStrings.Comment2).First();
                    paragraph1.Descendants<Run>().Where(e => e.InnerText == CommentBodyStrings.Comment2).First().InsertBeforeSelf<CommentRangeStart>(commentRangeStart1);
                    paragraph1.Descendants<Run>().Where(e => e.InnerText == CommentBodyStrings.Comment2).First().InsertAfterSelf<CommentRangeEnd>(CommentRangeEnd1);

                    CommentReference commentReference1 = new CommentReference();
                    commentReference1.Id = CommentIDs.CommentID4;
                    Run run1 = new Run();
                    run1.AppendChild<CommentReference>(commentReference1);

                    paragraph1.AppendChild<Run>(run1);
                    Comment comment1 = (Comment)GetComment(commentPart, CommentIDs.CommentID1).Clone();
                    comment1.Id = CommentIDs.CommentID4;
                    comment1.Descendants<Text>().First().Text = CommentStrings.CommentAppendString1;
                    comment1.Descendants<Paragraph>().First().ParagraphId = AppendCommentExIDs.AppendCommentID1;

                    commentPart.Comments.AppendChild<Comment>(comment1);

                    W15.CommentEx commentEx1 = new W15.CommentEx();
                    commentEx1.ParaId = AppendCommentExIDs.AppendCommentID1;
                    commentExPart.CommentsEx.AppendChild<W15.CommentEx>(commentEx1);

                    log.Pass("Append new comment. comment ID=[{0}]. comment text=[{1}]. CommentEx.ParaIdParent=[null].", CommentIDs.CommentID4, CommentStrings.CommentAppendString1);

                    //2.5 Add comment and CommentEx.
                    CommentRangeStart commentRangeStart2 = new CommentRangeStart();
                    commentRangeStart2.Id = CommentIDs.CommentID5;
                    CommentRangeEnd CommentRangeEnd2 = new CommentRangeEnd();
                    CommentRangeEnd2.Id = CommentIDs.CommentID5;

                    Paragraph paragraph2 = package.MainDocumentPart.Document.Descendants<Paragraph>().Where(e => e.InnerText == CommentBodyStrings.Comment2).First();
                    paragraph2.Descendants<Run>().Where(e => e.InnerText == CommentBodyStrings.Comment2).First().InsertBeforeSelf<CommentRangeStart>(commentRangeStart2);
                    paragraph2.Descendants<Run>().Where(e => e.InnerText == CommentBodyStrings.Comment2).First().InsertAfterSelf<CommentRangeEnd>(CommentRangeEnd2);

                    CommentReference commentReference2 = new CommentReference();
                    commentReference2.Id = CommentIDs.CommentID5;
                    Run run2 = new Run();
                    run2.AppendChild<CommentReference>(commentReference2);

                    paragraph2.AppendChild<Run>(run2);
                    Comment comment2 = (Comment)GetComment(commentPart, CommentIDs.CommentID2).Clone();
                    comment2.Id = CommentIDs.CommentID5;
                    comment2.Descendants<Text>().First().Text = CommentStrings.CommentAppendString2;
                    comment2.Descendants<Paragraph>().First().ParagraphId = AppendCommentExIDs.AppendCommentID2;

                    commentPart.Comments.AppendChild<Comment>(comment2);

                    W15.CommentEx commentEx2 = new W15.CommentEx();
                    commentEx2.ParaId = AppendCommentExIDs.AppendCommentID2;
                    commentEx2.ParaIdParent = AppendCommentExIDs.AppendCommentID1;
                    commentExPart.CommentsEx.AppendChild<W15.CommentEx>(commentEx2);

                    log.Pass("Append new comment. comment ID=[{0}]. comment text=[{1}]. CommentEx.ParaIdParent=[{2}].", CommentIDs.CommentID5, CommentStrings.CommentAppendString2, AppendCommentExIDs.AppendCommentID1);
                }
                catch (Exception e)
                {
                    log.Fail(e.Message);
                }
            }
        }
예제 #7
0
        public string GetAuthorWebsite(CommentReference comment)
        {
            var content = CommentManager.GetCommentContent(comment);

            return(content?.AuthorWebsite);
        }