]> source.dussan.org Git - poi.git/commitdiff
bug 59687: correctly delete comments from rows when removing a row and the workbook...
authorJaven O'Neal <onealj@apache.org>
Thu, 22 Sep 2016 07:50:33 +0000 (07:50 +0000)
committerJaven O'Neal <onealj@apache.org>
Thu, 22 Sep 2016 07:50:33 +0000 (07:50 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1761861 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java

index 8b9746489f55a7dee425d643b35f07cede87035a..bc2f071bea0428bf046d995a60691b74245490f2 100644 (file)
@@ -1928,15 +1928,17 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
         }
 
         // Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory
-        final Integer rownumI = new Integer(row.getRowNum()); // NOSONAR
-        int idx = _rows.headMap(rownumI).size();
-        _rows.remove(rownumI);
+        final int rowNum = row.getRowNum();
+        final Integer rowNumI = new Integer(rowNum); // NOSONAR
+        // this is not the physical row number!
+        final int idx = _rows.headMap(rowNumI).size();
+        _rows.remove(rowNumI);
         worksheet.getSheetData().removeRow(idx);
 
         // also remove any comment located in that row
         if(sheetComments != null) {
             for (CellAddress ref : getCellComments().keySet()) {
-                if (ref.getRow() == idx) {
+                if (ref.getRow() == rowNum) {
                     sheetComments.removeComment(ref);
                 }
             }
index 34ae2cfc40e390ef3159ff6e8fcfba50241f54ba..24c1d723757588b68863cc743a8f62b98559329b 100644 (file)
@@ -2022,8 +2022,7 @@ public final class TestXSSFSheet extends BaseTestXSheet {
     }
     
     // bug 59687:  XSSFSheet.RemoveRow doesn't handle row gaps properly when removing row comments
-    // This test is currently failing (thus expected AssertionError). When this bug is fixed, no error should be thrown.
-    @Test(expected=AssertionError.class)
+    @Test
     public void testRemoveRowWithCommentAndGapAbove() throws IOException {
         final Workbook wb = _testDataProvider.openSampleWorkbook("59687.xlsx");
         final Sheet sheet = wb.getSheetAt(0);