use of org.openxmlformats.schemas.presentationml.x2006.main.CTComment in project poi by apache.
the class CommentsTable method newComment.
/**
* Create a new comment located` at cell address
*
* @param ref the location to add the comment
* @return a new CTComment located at ref with default author
*/
@Internal
public CTComment newComment(CellAddress ref) {
CTComment ct = comments.getCommentList().addNewComment();
ct.setRef(ref.formatAsString());
ct.setAuthorId(DEFAULT_AUTHOR_ID);
if (commentRefs != null) {
commentRefs.put(ref, ct);
}
return ct;
}
use of org.openxmlformats.schemas.presentationml.x2006.main.CTComment in project poi by apache.
the class CommentsTable method removeComment.
/**
* Remove the comment at cellRef location, if one exists
*
* @param cellRef the location of the comment to remove
* @return returns true if a comment was removed
*/
public boolean removeComment(CellAddress cellRef) {
final String stringRef = cellRef.formatAsString();
CTCommentList lst = comments.getCommentList();
if (lst != null) {
CTComment[] commentArray = lst.getCommentArray();
for (int i = 0; i < commentArray.length; i++) {
CTComment comment = commentArray[i];
if (stringRef.equals(comment.getRef())) {
lst.removeComment(i);
if (commentRefs != null) {
commentRefs.remove(cellRef);
}
return true;
}
}
}
return false;
}
use of org.openxmlformats.schemas.presentationml.x2006.main.CTComment in project poi by apache.
the class CommentsTable method getCellComments.
/**
* Returns all cell comments on this sheet.
* @return A map of each Comment in this sheet, keyed on the cell address where
* the comment is located.
*/
public Map<CellAddress, XSSFComment> getCellComments() {
prepareCTCommentCache();
final TreeMap<CellAddress, XSSFComment> map = new TreeMap<CellAddress, XSSFComment>();
for (final Entry<CellAddress, CTComment> e : commentRefs.entrySet()) {
map.put(e.getKey(), new XSSFComment(this, e.getValue(), null));
}
return map;
}
use of org.openxmlformats.schemas.presentationml.x2006.main.CTComment in project poi by apache.
the class TestXSSFComment method constructor.
/**
* test properties of a newly constructed comment
*/
@Test
public void constructor() {
CommentsTable sheetComments = new CommentsTable();
assertNotNull(sheetComments.getCTComments().getCommentList());
assertNotNull(sheetComments.getCTComments().getAuthors());
assertEquals(1, sheetComments.getCTComments().getAuthors().sizeOfAuthorArray());
assertEquals(1, sheetComments.getNumberOfAuthors());
CTComment ctComment = sheetComments.newComment(CellAddress.A1);
CTShape vmlShape = CTShape.Factory.newInstance();
XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape);
assertEquals(null, comment.getString());
assertEquals(0, comment.getRow());
assertEquals(0, comment.getColumn());
assertEquals("", comment.getAuthor());
assertEquals(false, comment.isVisible());
}
use of org.openxmlformats.schemas.presentationml.x2006.main.CTComment in project poi by apache.
the class TestXSSFComment method getSetCol.
@Test
public void getSetCol() {
CommentsTable sheetComments = new CommentsTable();
XSSFVMLDrawing vml = new XSSFVMLDrawing();
CTComment ctComment = sheetComments.newComment(CellAddress.A1);
CTShape vmlShape = vml.newCommentShape();
XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape);
comment.setColumn(1);
assertEquals(1, comment.getColumn());
assertEquals(1, new CellReference(ctComment.getRef()).getCol());
assertEquals(1, vmlShape.getClientDataArray(0).getColumnArray(0).intValue());
comment.setColumn(5);
assertEquals(5, comment.getColumn());
assertEquals(5, new CellReference(ctComment.getRef()).getCol());
assertEquals(5, vmlShape.getClientDataArray(0).getColumnArray(0).intValue());
}
Aggregations