bug 59443: exit early on setAddress if address is the same

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1742881 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-05-09 05:46:14 +00:00
parent 191726ee7b
commit 730641576a
2 changed files with 11 additions and 4 deletions

View File

@ -145,10 +145,9 @@ public class CellAddress implements Comparable<CellAddress> {
return false; return false;
} }
CellAddress cr = (CellAddress) o; CellAddress other = (CellAddress) o;
return _row == cr._row return _row == other._row &&
&& _col == cr._col _col == other._col;
;
} }
@Override @Override

View File

@ -143,6 +143,10 @@ public class XSSFComment implements Comment {
@Override @Override
public void setAddress(CellAddress address) { public void setAddress(CellAddress address) {
CellAddress oldRef = new CellAddress(_comment.getRef()); CellAddress oldRef = new CellAddress(_comment.getRef());
if (address.equals(oldRef)) {
// nothing to do
return;
}
_comment.setRef(address.formatAsString()); _comment.setRef(address.formatAsString());
_comments.referenceUpdated(oldRef, _comment); _comments.referenceUpdated(oldRef, _comment);
@ -162,6 +166,8 @@ public class XSSFComment implements Comment {
/** /**
* Set the column of the cell that contains the comment * Set the column of the cell that contains the comment
* *
* If changing both row and column, use {@link #setAddress}.
*
* @param col the 0-based column of the cell that contains the comment * @param col the 0-based column of the cell that contains the comment
*/ */
@Override @Override
@ -172,6 +178,8 @@ public class XSSFComment implements Comment {
/** /**
* Set the row of the cell that contains the comment * Set the row of the cell that contains the comment
* *
* If changing both row and column, use {@link #setAddress}.
*
* @param row the 0-based row of the cell that contains the comment * @param row the 0-based row of the cell that contains the comment
*/ */
@Override @Override