View | Details | Raw Unified | Return to bug 54920
Collapse All | Expand All

(-)a/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java (-2 / +2 lines)
Lines 126-134 public class CommentsTable extends POIXMLDocumentPart { Link Here
126
        return commentRefs.get(cellRef);
126
        return commentRefs.get(cellRef);
127
    }
127
    }
128
128
129
    public CTComment newComment() {
129
    public CTComment newComment(String ref) {
130
        CTComment ct = comments.getCommentList().addNewComment();
130
        CTComment ct = comments.getCommentList().addNewComment();
131
        ct.setRef("A1");
131
        ct.setRef(ref);
132
        ct.setAuthorId(0);
132
        ct.setAuthorId(0);
133
        
133
        
134
        if(commentRefs != null) {
134
        if(commentRefs != null) {
(-)a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDrawing.java (-3 / +5 lines)
Lines 33-38 import org.apache.poi.openxml4j.opc.PackageRelationship; Link Here
33
import org.apache.poi.openxml4j.opc.TargetMode;
33
import org.apache.poi.openxml4j.opc.TargetMode;
34
import org.apache.poi.ss.usermodel.ClientAnchor;
34
import org.apache.poi.ss.usermodel.ClientAnchor;
35
import org.apache.poi.ss.usermodel.Drawing;
35
import org.apache.poi.ss.usermodel.Drawing;
36
import org.apache.poi.ss.util.CellReference;
36
import org.apache.poi.util.Internal;
37
import org.apache.poi.util.Internal;
37
import org.apache.poi.xssf.model.CommentsTable;
38
import org.apache.poi.xssf.model.CommentsTable;
38
import org.apache.xmlbeans.XmlCursor;
39
import org.apache.xmlbeans.XmlCursor;
Lines 298-306 public final class XSSFDrawing extends POIXMLDocumentPart implements Drawing { Link Here
298
                    ca.getCol2() + ", 0, " + ca.getRow2() + ", 0";
299
                    ca.getCol2() + ", 0, " + ca.getRow2() + ", 0";
299
            vmlShape.getClientDataArray(0).setAnchorArray(0, position);
300
            vmlShape.getClientDataArray(0).setAnchorArray(0, position);
300
        }
301
        }
301
        XSSFComment shape = new XSSFComment(comments, comments.newComment(), vmlShape);
302
        String ref = new CellReference(ca.getRow1(), ca.getCol1()).formatAsString();
302
        shape.setColumn(ca.getCol1());
303
		XSSFComment shape = new XSSFComment(comments, comments.newComment(ref), vmlShape);
303
        shape.setRow(ca.getRow1());
304
//        shape.setColumn(ca.getCol1());
305
//        shape.setRow(ca.getRow1());
304
        return shape;
306
        return shape;
305
    }
307
    }
306
308
(-)a/src/ooxml/testcases/org/apache/poi/xssf/model/TestCommentsTable.java (-6 / +6 lines)
Lines 187-198 public class TestCommentsTable extends TestCase { Link Here
187
187
188
    public void testRemoveComment() throws Exception {
188
    public void testRemoveComment() throws Exception {
189
        CommentsTable sheetComments = new CommentsTable();
189
        CommentsTable sheetComments = new CommentsTable();
190
        CTComment a1 = sheetComments.newComment();
190
        CTComment a1 = sheetComments.newComment("A1");
191
        a1.setRef("A1");
191
//        a1.setRef("A1");
192
        CTComment a2 = sheetComments.newComment();
192
        CTComment a2 = sheetComments.newComment("A2");
193
        a2.setRef("A2");
193
//        a2.setRef("A2");
194
        CTComment a3 = sheetComments.newComment();
194
        CTComment a3 = sheetComments.newComment("A3");
195
        a3.setRef("A3");
195
//        a3.setRef("A3");
196
196
197
        assertSame(a1, sheetComments.getCTComment("A1"));
197
        assertSame(a1, sheetComments.getCTComment("A1"));
198
        assertSame(a2, sheetComments.getCTComment("A2"));
198
        assertSame(a2, sheetComments.getCTComment("A2"));
(-)a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java (-4 / +4 lines)
Lines 50-56 public final class TestXSSFComment extends BaseTestCellComment { Link Here
50
        assertEquals(1, sheetComments.getCTComments().getAuthors().sizeOfAuthorArray());
50
        assertEquals(1, sheetComments.getCTComments().getAuthors().sizeOfAuthorArray());
51
        assertEquals(1, sheetComments.getNumberOfAuthors());
51
        assertEquals(1, sheetComments.getNumberOfAuthors());
52
52
53
        CTComment ctComment = sheetComments.newComment();
53
        CTComment ctComment = sheetComments.newComment("A1");
54
        CTShape vmlShape = CTShape.Factory.newInstance();
54
        CTShape vmlShape = CTShape.Factory.newInstance();
55
55
56
        XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape);
56
        XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape);
Lines 64-70 public final class TestXSSFComment extends BaseTestCellComment { Link Here
64
    public void testGetSetCol() {
64
    public void testGetSetCol() {
65
        CommentsTable sheetComments = new CommentsTable();
65
        CommentsTable sheetComments = new CommentsTable();
66
        XSSFVMLDrawing vml = new XSSFVMLDrawing();
66
        XSSFVMLDrawing vml = new XSSFVMLDrawing();
67
        CTComment ctComment = sheetComments.newComment();
67
        CTComment ctComment = sheetComments.newComment("A1");
68
        CTShape vmlShape = vml.newCommentShape();
68
        CTShape vmlShape = vml.newCommentShape();
69
69
70
        XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape);
70
        XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape);
Lines 82-88 public final class TestXSSFComment extends BaseTestCellComment { Link Here
82
    public void testGetSetRow() {
82
    public void testGetSetRow() {
83
        CommentsTable sheetComments = new CommentsTable();
83
        CommentsTable sheetComments = new CommentsTable();
84
        XSSFVMLDrawing vml = new XSSFVMLDrawing();
84
        XSSFVMLDrawing vml = new XSSFVMLDrawing();
85
        CTComment ctComment = sheetComments.newComment();
85
        CTComment ctComment = sheetComments.newComment("A1");
86
        CTShape vmlShape = vml.newCommentShape();
86
        CTShape vmlShape = vml.newCommentShape();
87
87
88
        XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape);
88
        XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape);
Lines 150-156 public final class TestXSSFComment extends BaseTestCellComment { Link Here
150
150
151
    public void testAuthor() {
151
    public void testAuthor() {
152
        CommentsTable sheetComments = new CommentsTable();
152
        CommentsTable sheetComments = new CommentsTable();
153
        CTComment ctComment = sheetComments.newComment();
153
        CTComment ctComment = sheetComments.newComment("A1");
154
154
155
        assertEquals(1, sheetComments.getNumberOfAuthors());
155
        assertEquals(1, sheetComments.getNumberOfAuthors());
156
        XSSFComment comment = new XSSFComment(sheetComments, ctComment, null);
156
        XSSFComment comment = new XSSFComment(sheetComments, ctComment, null);

Return to bug 54920