]> source.dussan.org Git - poi.git/commitdiff
bug 59443: exit early on setAddress if address is the same
authorJaven O'Neal <onealj@apache.org>
Mon, 9 May 2016 05:46:14 +0000 (05:46 +0000)
committerJaven O'Neal <onealj@apache.org>
Mon, 9 May 2016 05:46:14 +0000 (05:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1742881 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/ss/util/CellAddress.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFComment.java

index 76c0bb4934cc0842914ad9af78cf50038711b73b..b6307556f8c5430004dce7628ad6d0018ccbbd6c 100644 (file)
@@ -145,10 +145,9 @@ public class CellAddress implements Comparable<CellAddress> {
             return false;
         }
         
-        CellAddress cr = (CellAddress) o;
-        return _row == cr._row
-                && _col == cr._col
-        ;
+        CellAddress other = (CellAddress) o;
+        return _row == other._row &&
+               _col == other._col;
     }
 
     @Override
index f71cbcb955d762f62c39bbd67e6df86dda1d3b65..4449757a7684333474e5bf9af1dee0fcc7db54cb 100644 (file)
@@ -143,6 +143,10 @@ public class XSSFComment implements Comment {
     @Override
     public void setAddress(CellAddress address) {
         CellAddress oldRef = new CellAddress(_comment.getRef());
+        if (address.equals(oldRef)) {
+            // nothing to do
+            return;
+        }
         
         _comment.setRef(address.formatAsString());
         _comments.referenceUpdated(oldRef, _comment);
@@ -161,6 +165,8 @@ public class XSSFComment implements 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
      */
@@ -171,6 +177,8 @@ public class XSSFComment implements 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
      */