-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] GetAllComments() tests (#1163)
* GetAllComments method tests * GetAllComments method tests
- Loading branch information
Showing
6 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
builder.CreateFile("docx"); | ||
var oDocument = Api.GetDocument(); | ||
oDocument.AddComment("This is a comment.", "John", "uid-1"); | ||
Api.AddComment(oDocument, "This is another comment.", "Jane", "uid-2"); | ||
|
||
var oParagraph = oDocument.GetElement(0); | ||
oParagraph.AddText("This is just a sample paragraph."); | ||
oParagraph.AddComment("Comment for paragraph", "Jane", "uid-2"); | ||
oParagraph.AddLineBreak(); | ||
|
||
var oRun = Api.CreateRun(); | ||
oRun.AddText("This is just a sample run. Nothing special."); | ||
oParagraph.AddElement(oRun); | ||
oRun.AddComment("Comment for run", "James", "uid-3"); | ||
|
||
var oRange = oRun.GetRange(28, 44); | ||
oRange.AddComment("Comment for range", "Julia", "uid-4"); | ||
|
||
var oTableStyle = oDocument.CreateStyle("CustomTableStyle", "table"); | ||
oTableStyle.SetBasedOn(oDocument.GetStyle("Bordered")); | ||
var oTable = Api.CreateTable(3, 3); | ||
oTable.SetWidth("percent", 100); | ||
oTable.SetStyle(oTableStyle); | ||
oDocument.Push(oTable); | ||
oTable.AddComment("Comment for table", "John", "uid-1"); | ||
|
||
var oBlockLvlSdt = Api.CreateBlockLvlSdt(); | ||
oBlockLvlSdt.GetContent().GetElement(0).AddText("This is a block text content control."); | ||
oDocument.Push(oBlockLvlSdt); | ||
oBlockLvlSdt.AddComment("Comment for block content control", "James", "uid-3"); | ||
|
||
oParagraph = Api.CreateParagraph(); | ||
var oInlineLvlSdt = Api.CreateInlineLvlSdt(); | ||
oInlineLvlSdt.AddText("This is an inline text content control."); | ||
oParagraph.AddInlineLvlSdt(oInlineLvlSdt); | ||
oDocument.Push(oParagraph); | ||
oInlineLvlSdt.AddComment("Comment for inline content control", "Julia", "uid-4"); | ||
|
||
var aComments = oDocument.GetAllComments(); | ||
var commentsArray = []; | ||
for (var i=0; i<aComments.length; i++) { | ||
commentsArray.push(aComments[i].GetText()); | ||
} | ||
oParagraph = Api.CreateParagraph(); | ||
oParagraph.AddText(commentsArray.join(", ")); | ||
oDocument.Push(oParagraph); | ||
builder.SaveFile("docx", "GetAllComments.docx"); | ||
builder.CloseFile(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
builder.CreateFile("pptx"); | ||
var oPresentation = Api.GetPresentation(); | ||
Api.pluginMethod_AddComment({"UserName": "John Smith", "Text": "This is a comment."}); | ||
Api.pluginMethod_AddComment({"UserName": "Mark Potato", "Text": "This is another comment."}); | ||
|
||
var oSlide = oPresentation.GetSlideByIndex(0); | ||
oSlide.RemoveAllObjects(); | ||
var oShape = Api.CreateShape("rect", 300 * 36000, 130 * 36000); | ||
var oDocContent = oShape.GetDocContent(); | ||
var oParagraph = oDocContent.GetElement(0); | ||
|
||
var arrComments = oPresentation.GetAllComments(); | ||
var commentsArray = []; | ||
for (var i=0; i<arrComments.length; i++) { | ||
commentsArray.push(arrComments[i].GetText()); | ||
} | ||
oParagraph.AddText(commentsArray.join(", ")); | ||
oParagraph.SetHighlight("lightGray"); | ||
oSlide.AddObject(oShape); | ||
builder.SaveFile("pptx", "GetAllComments.pptx"); | ||
builder.CloseFile(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
builder.CreateFile("xlsx"); | ||
Api.AddComment("This is a comment.", "John Smith", "uid-1"); | ||
Api.AddComment("This is another comment.", "Mark Potato", "uid-2"); | ||
var oWorksheet = Api.GetActiveSheet(); | ||
var oRange = oWorksheet.GetRange("D1"); | ||
oRange.AddComment("Comment for range", "James", "uid-3"); | ||
|
||
var arrComments = Api.GetAllComments(); | ||
var commentsArray = []; | ||
for (var i=0; i<arrComments.length; i++) { | ||
oWorksheet.GetRange("A" + (i+1)).SetValue(arrComments[i].GetAuthorName() + ":" + arrComments[i].GetText()); | ||
} | ||
builder.SaveFile("xlsx", "GetAllComments.xlsx"); | ||
builder.CloseFile(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters