diff --git a/main/HSSF/Record/EscherAggregate.cs b/main/HSSF/Record/EscherAggregate.cs index 08329cb03..7de89d498 100644 --- a/main/HSSF/Record/EscherAggregate.cs +++ b/main/HSSF/Record/EscherAggregate.cs @@ -1298,10 +1298,7 @@ public void RemoveTailRecord(NoteRecord note) internal void AddTailRecord(NoteRecord note) { - if (tailRec.ContainsKey(note.ShapeId)) - tailRec.Add(note.ShapeId, note); - else - tailRec[note.ShapeId] = note; + tailRec[note.ShapeId] = note; } /** * @return unmodifiable copy of tail records. We need to access them when building shapes. diff --git a/testcases/main/HSSF/UserModel/TestHSSFComment.cs b/testcases/main/HSSF/UserModel/TestHSSFComment.cs index 99e84ce31..a1719a00e 100644 --- a/testcases/main/HSSF/UserModel/TestHSSFComment.cs +++ b/testcases/main/HSSF/UserModel/TestHSSFComment.cs @@ -452,5 +452,20 @@ public void ShapeId() wb.Close(); } + + [Test] + public void TestBug1240() + { + using(var wb = HSSFTestDataSamples.OpenSampleWorkbook("test_FailAddingComment.xls")) + { + Assert.DoesNotThrow(() => + { + ISheet sheet = wb.GetSheetAt(0); + var drawingPatriarch2 = sheet.CreateDrawingPatriarch(); + IClientAnchor anchor2 = drawingPatriarch2.CreateAnchor(0, 0, 0, 0, 55, 71, 58, 75); + IComment comment2 = drawingPatriarch2.CreateCellComment(anchor2); + }); + } + } } } diff --git a/testcases/test-data/spreadsheet/test_FailAddingComment.xls b/testcases/test-data/spreadsheet/test_FailAddingComment.xls new file mode 100644 index 000000000..9ac716031 Binary files /dev/null and b/testcases/test-data/spreadsheet/test_FailAddingComment.xls differ