From 260c6ed57fb2b255d82c9a12ab757c3ef6b93d23 Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Mon, 9 May 2016 03:49:16 +0000 Subject: [PATCH] add disabled unit test for bug 59393 from stone git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1742868 13f79535-47bb-0310-9956-ffa450edef68 --- .../ss/usermodel/BaseTestBugzillaIssues.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java index 0152c5db58..e84c391cef 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java @@ -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(); + } } -- 2.39.5