Package org.openxmlformats.schemas.spreadsheetml.x2006.main

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment


        assertEquals(13, comment.getColumn());
    }

    public void testSetRow() {
        CommentsTable sheetComments = new CommentsTable();
        CTComment ctComment = CTComment.Factory.newInstance();
        XSSFComment comment = new XSSFComment(sheetComments, ctComment);
        comment.setRow(20);
        assertEquals(20, comment.getRow());
        assertEquals(20, (new CellReference(ctComment.getRef()).getRow()));
        assertEquals("A21", ctComment.getRef());

        comment.setRow(19);
        assertEquals(19, comment.getRow());
    }
View Full Code Here


        assertEquals(19, comment.getRow());
    }

    public void testSetAuthor() {
        CommentsTable sheetComments = new CommentsTable();
        CTComment ctComment = CTComment.Factory.newInstance();
        XSSFComment comment = new XSSFComment(sheetComments, ctComment);
        comment.setAuthor(TEST_AUTHOR);
        assertEquals(TEST_AUTHOR, comment.getAuthor());
    }
View Full Code Here

        assertEquals(TEST_AUTHOR, comment.getAuthor());
    }

    public void testSetString() {
        CommentsTable sheetComments = new CommentsTable();
        CTComment ctComment = CTComment.Factory.newInstance();
        XSSFComment comment = new XSSFComment(sheetComments, ctComment);
        RichTextString richTextString = new HSSFRichTextString(TEST_RICHTEXTSTRING);
        comment.setString(richTextString);
        assertEquals(TEST_RICHTEXTSTRING, ctComment.getText().getT());
    }
View Full Code Here

    CTComments comments = sheetComments.getCTComments();
    CTCommentList commentList = comments.addNewCommentList();

    // Create 2 comments for A1 and A" cells
    CTComment comment0 = commentList.insertNewComment(0);
    comment0.setRef("A1");
    CTRst ctrst0 = CTRst.Factory.newInstance();
    ctrst0.setT(TEST_A1_TEXT);
    comment0.setText(ctrst0);
    CTComment comment1 = commentList.insertNewComment(0);
    comment1.setRef("A2");
    CTRst ctrst1 = CTRst.Factory.newInstance();
    ctrst1.setT(TEST_A2_TEXT);
    comment1.setText(ctrst1);

    // test finding the right comment for a cell
    assertEquals(TEST_A1_TEXT, sheetComments.findCellComment("A1").getString().getString());
    assertEquals(TEST_A1_TEXT, sheetComments.findCellComment(0, 0).getString().getString());
    assertEquals(TEST_A2_TEXT, sheetComments.findCellComment("A2").getString().getString());
View Full Code Here

        assertNotNull(sheetComments.getCTComments().getCommentList());
        assertNotNull(sheetComments.getCTComments().getAuthors());
        assertEquals(1, sheetComments.getCTComments().getAuthors().sizeOfAuthorArray());
        assertEquals(1, sheetComments.getNumberOfAuthors());

        CTComment ctComment = sheetComments.newComment();
        CTShape vmlShape = CTShape.Factory.newInstance();

        XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape);
        assertEquals(null, comment.getString());
        assertEquals(0, comment.getRow());
View Full Code Here

    }

    public void testGetSetCol() {
        CommentsTable sheetComments = new CommentsTable();
        XSSFVMLDrawing vml = new XSSFVMLDrawing();
        CTComment ctComment = sheetComments.newComment();
        CTShape vmlShape = vml.newCommentShape();

        XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape);
        comment.setColumn(1);
        assertEquals(1, comment.getColumn());
        assertEquals(1, new CellReference(ctComment.getRef()).getCol());
        assertEquals(1, vmlShape.getClientDataArray(0).getColumnArray(0).intValue());

        comment.setColumn(5);
        assertEquals(5, comment.getColumn());
        assertEquals(5, new CellReference(ctComment.getRef()).getCol());
        assertEquals(5, vmlShape.getClientDataArray(0).getColumnArray(0).intValue());
    }
View Full Code Here

    }

    public void testGetSetRow() {
        CommentsTable sheetComments = new CommentsTable();
        XSSFVMLDrawing vml = new XSSFVMLDrawing();
        CTComment ctComment = sheetComments.newComment();
        CTShape vmlShape = vml.newCommentShape();

        XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape);
        comment.setRow(1);
        assertEquals(1, comment.getRow());
        assertEquals(1, new CellReference(ctComment.getRef()).getRow());
        assertEquals(1, vmlShape.getClientDataArray(0).getRowArray(0).intValue());

        comment.setRow(5);
        assertEquals(5, comment.getRow());
        assertEquals(5, new CellReference(ctComment.getRef()).getRow());
        assertEquals(5, vmlShape.getClientDataArray(0).getRowArray(0).intValue());
    }
View Full Code Here

        assertEquals(TEST_RICHTEXTSTRING, comment.getString().getString());

        //if the text is already set, it should be overridden, not added twice!
        comment.setString(TEST_RICHTEXTSTRING);

        CTComment ctComment = comment.getCTComment();
        XmlObject[] obj = ctComment.selectPath(
                "declare namespace w='http://schemas.openxmlformats.org/spreadsheetml/2006/main' .//w:text");
        assertEquals(1, obj.length);
        assertEquals(TEST_RICHTEXTSTRING, comment.getString().getString());

        //sequential call of comment.getString() should return the same XSSFRichTextString object
        assertSame(comment.getString(), comment.getString());

        XSSFRichTextString richText = new XSSFRichTextString(TEST_RICHTEXTSTRING);
        XSSFFont font1 = wb.createFont();
        font1.setFontName("Tahoma");
        font1.setFontHeight(8.5);
        font1.setItalic(true);
        font1.setColor(IndexedColors.BLUE_GREY.getIndex());
        richText.applyFont(0, 5, font1);

        //check the low-level stuff
        comment.setString(richText);
        obj = ctComment.selectPath(
                "declare namespace w='http://schemas.openxmlformats.org/spreadsheetml/2006/main' .//w:text");
        assertEquals(1, obj.length);
        assertSame(comment.getString(), richText);
        //check that the rich text is set in the comment
        CTRPrElt rPr = richText.getCTRst().getRArray(0).getRPr();
View Full Code Here

        assertEquals("Tahoma", rPr.getRFontArray()[0].getVal());
    }

    public void testAuthor() {
        CommentsTable sheetComments = new CommentsTable();
        CTComment ctComment = sheetComments.newComment();

        assertEquals(1, sheetComments.getNumberOfAuthors());
        XSSFComment comment = new XSSFComment(sheetComments, ctComment, null);
        assertEquals("", comment.getAuthor());
        comment.setAuthor("Apache POI");
View Full Code Here

        }
        return addNewAuthor(author);
    }

    public XSSFComment findCellComment(String cellRef) {
        CTComment ct = getCTComment(cellRef);
        return ct == null ? null : new XSSFComment(this, ct, null);
    }
View Full Code Here

TOP

Related Classes of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.