]> source.dussan.org Git - poi.git/commitdiff
add disabled unit test for bug 59393 from stone
authorJaven O'Neal <onealj@apache.org>
Mon, 9 May 2016 03:49:16 +0000 (03:49 +0000)
committerJaven O'Neal <onealj@apache.org>
Mon, 9 May 2016 03:49:16 +0000 (03:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1742868 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java

index 0152c5db58c2fedc579daf91c07135c8265e32fd..e84c391cef27257be3a428b8afe9b578cb5f936f 100644 (file)
@@ -1496,4 +1496,48 @@ public abstract class BaseTestBugzillaIssues {
     protected double delta(long startTimeMillis) {
         return time() - startTimeMillis;
     }
+    
+    @Ignore("bug 59393")
+    @Test
+    public void bug59393_commentsCanHaveSameAnchor() throws IOException
+    {
+        Workbook wb = _testDataProvider.createWorkbook();
+        
+        Sheet sheet = wb.createSheet();
+        
+        CreationHelper helper = wb.getCreationHelper();
+        ClientAnchor anchor = helper.createClientAnchor();
+        Drawing drawing = sheet.createDrawingPatriarch();
+        
+        Row row = sheet.createRow(0);
+        
+        Cell cell1 = row.createCell(0);
+        Cell cell2 = row.createCell(1);
+        Cell cell3 = row.createCell(2);
+
+        Comment comment1 = drawing.createCellComment(anchor);
+        RichTextString richTextString1 = helper.createRichTextString("comment1");
+        comment1.setString(richTextString1);
+        cell1.setCellComment(comment1);
+         
+        // fails with IllegalArgumentException("Multiple cell comments in one cell are not allowed, cell: A1")
+        // because createCellComment tries to create a cell at A1
+        // (from CellAddress(anchor.getRow1(), anchor.getCell1())),
+        // but cell A1 already has a comment (comment1).
+        // Need to atomically create a comment and attach it to a cell.
+        // Current workaround: change anchor between each usage
+        // anchor.setCol1(1);
+        Comment comment2 = drawing.createCellComment(anchor);
+        RichTextString richTextString2 = helper.createRichTextString("comment2");
+        comment2.setString(richTextString2);
+        cell2.setCellComment(comment2);
+
+        // anchor.setCol1(2);
+        Comment comment3 = drawing.createCellComment(anchor);
+        RichTextString richTextString3 = helper.createRichTextString("comment3");
+        comment3.setString(richTextString3);
+        cell3.setCellComment(comment3);
+        
+        wb.close();
+    }
 }