try to make comments table more extensible

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895129 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2021-11-17 23:35:16 +00:00
parent df7fccb3d0
commit e65f235198
2 changed files with 12 additions and 12 deletions

View File

@ -97,7 +97,7 @@ public class CommentsTable extends POIXMLDocumentPart implements Comments {
}
/**
* @return iterator of comments
* @return iterator of comments (without their VML Shapes set)
* @since POI 5.2.0
*/
public Iterator<XSSFComment> commentIterator() {

View File

@ -3115,14 +3115,14 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
// is there a change necessary for the current row?
if(newrownum != rownum) {
CTCommentList lst = sheetComments.getCTComments().getCommentList();
for (CTComment comment : lst.getCommentArray()) {
String oldRef = comment.getRef();
CellReference ref = new CellReference(oldRef);
Iterator<XSSFComment> commentIterator = sheetComments.commentIterator();
while (commentIterator.hasNext()) {
XSSFComment oldComment = commentIterator.next();
CellReference ref = new CellReference(oldComment.getRow(), oldComment.getColumn());
// is this comment part of the current row?
if(ref.getRow() == rownum) {
XSSFComment xssfComment = new XSSFComment(sheetComments, comment,
XSSFComment xssfComment = new XSSFComment(sheetComments, oldComment.getCTComment(),
vml == null ? null : vml.findCommentShape(rownum, ref.getCol()));
// we should not perform the shifting right here as we would then find
@ -3199,16 +3199,16 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
});
if(sheetComments != null){
CTCommentList lst = sheetComments.getCTComments().getCommentList();
for (CTComment comment : lst.getCommentArray()) {
String oldRef = comment.getRef();
CellReference ref = new CellReference(oldRef);
if (sheetComments != null) {
Iterator<XSSFComment> commentIterator = sheetComments.commentIterator();
while (commentIterator.hasNext()) {
XSSFComment oldComment = commentIterator.next();
CellReference ref = new CellReference(oldComment.getRow(), oldComment.getColumn());
int columnIndex =ref.getCol();
int newColumnIndex = shiftedRowNum(startColumnIndex, endColumnIndex, n, columnIndex);
if(newColumnIndex != columnIndex){
XSSFComment xssfComment = new XSSFComment(sheetComments, comment,
XSSFComment xssfComment = new XSSFComment(sheetComments, oldComment.getCTComment(),
vml == null ? null : vml.findCommentShape(ref.getRow(), columnIndex));
commentsToShift.put(xssfComment, newColumnIndex);
}