aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2008-01-07 14:51:37 +0000
committerNick Burch <nick@apache.org>2008-01-07 14:51:37 +0000
commit2fa190d507aaec606605382bfd5576af725e4253 (patch)
tree69c31114208a1dcbd2a9ed8427957df8cbc2aec1 /src/java/org
parenta176593fb291639964fa14843584dd15941aff2c (diff)
downloadpoi-2fa190d507aaec606605382bfd5576af725e4253.tar.gz
poi-2fa190d507aaec606605382bfd5576af725e4253.zip
Fix bug #44070 - patch from Gian Carlo Pace
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@609620 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
index b52fa1e5b2..ba9ff72a7e 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
@@ -1202,6 +1202,12 @@ public class HSSFSheet
row2Replace.createCellFromRecord( cellRecord );
sheet.addValueRecord( rowNum + n, cellRecord );
}
+
+ // move comments if exist (can exist even if cell is null)
+ HSSFComment comment = getCellComment(rowNum, col);
+ if (comment != null) {
+ comment.setRow(rowNum + n);
+ }
}
}
if ( endRow == lastrow || endRow + n > lastrow ) lastrow = Math.min( endRow + n, 65535 );
@@ -1671,7 +1677,21 @@ public class HSSFSheet
* @return cell comment or <code>null</code> if not found
*/
public HSSFComment getCellComment(int row, int column){
- return HSSFCell.findCellComment(sheet, row, column);
+ // Don't call findCellComment directly, otherwise
+ // two calls to this method will result in two
+ // new HSSFComment instances, which is bad
+ HSSFRow r = getRow(row);
+ if(r != null) {
+ HSSFCell c = r.getCell((short)column);
+ if(c != null) {
+ return c.getCellComment();
+ } else {
+ // No cell, so you will get new
+ // objects every time, sorry...
+ return HSSFCell.findCellComment(sheet, row, column);
+ }
+ }
+ return null;
}
}