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

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


        TreeMap<Integer, CTRPrElt> formats = getFormatMap(st);
        CTRPrElt fmt = CTRPrElt.Factory.newInstance();
        setRunAttributes(xssfFont.getCTFont(), fmt);
        applyFont(formats, startIndex, endIndex, fmt);

        CTRst newSt = buildCTRst(text, formats);
        st.set(newSt);
    }
View Full Code Here


    CTRst buildCTRst(String text, TreeMap<Integer, CTRPrElt> formats){
        if(text.length() != formats.lastKey()) {
            throw new IllegalArgumentException("Text length was " + text.length() +
                    " but the last format index was " + formats.lastKey());
        }
        CTRst st = CTRst.Factory.newInstance();
        int runStartIdx = 0;
        for (Iterator<Integer> it = formats.keySet().iterator(); it.hasNext();) {
            int runEndIdx = it.next();
            CTRElt run = st.addNewR();
            String fragment = text.substring(runStartIdx, runEndIdx);
            run.setT(fragment);
            preserveSpaces(run.xgetT());
            CTRPrElt fmt = formats.get(runEndIdx);
            if(fmt != null) run.setRPr(fmt);
View Full Code Here

    public void testCreate() {

        XSSFRichTextString rt = new XSSFRichTextString("Apache POI");
        assertEquals("Apache POI", rt.getString());

        CTRst st = rt.getCTRst();
        assertTrue(st.isSetT());
        assertEquals("Apache POI", st.getT());

        rt.append(" is cool stuff");
        assertEquals(2, st.sizeOfRArray());
        assertFalse(st.isSetT());

        assertEquals("Apache POI is cool stuff", rt.getString());
    }
View Full Code Here

        XSSFRichTextString rt = new XSSFRichTextString("Apache POI");
        assertEquals("Apache POI", rt.getString());

        rt.clearFormatting();

        CTRst st = rt.getCTRst();
        assertTrue(st.isSetT());
        assertEquals("Apache POI", rt.getString());
        assertEquals(0, rt.numFormattingRuns());

        XSSFFont font = new XSSFFont();
        font.setBold(true);
View Full Code Here

     * make sure we insert xml:space="preserve" attribute
     * if a string has leading or trailing white spaces
     */
    public void testPreserveSpaces() {
        XSSFRichTextString rt = new XSSFRichTextString("Apache");
        CTRst ct = rt.getCTRst();
        STXstring xs = ct.xgetT();
        assertEquals("<xml-fragment>Apache</xml-fragment>", xs.xmlText());
        rt.setString("  Apache");
        assertEquals("<xml-fragment xml:space=\"preserve\">  Apache</xml-fragment>", xs.xmlText());

    }
View Full Code Here

    /**
     * test that unicode representation_ xHHHH_ is properly processed
     */
    public void testUtfDecode() {
        CTRst st = CTRst.Factory.newInstance();
        st.setT("abc_x000D_2ef_x000D_");
        XSSFRichTextString rt = new XSSFRichTextString(st);
        //_x000D_ is converted into carriage return
        assertEquals("abc\r2ef\r", rt.getString());
       
    }
View Full Code Here

        assertEquals("abc\r2ef\r", rt.getString());
       
    }

    public void testApplyFont_lowlevel(){
        CTRst st = CTRst.Factory.newInstance();
        String text = "Apache Software Foundation";
        XSSFRichTextString str = new XSSFRichTextString(text);
        assertEquals(26, text.length());

        st.addNewR().setT(text);

        TreeMap<Integer, CTRPrElt> formats = str.getFormatMap(st);
        assertEquals(1, formats.size());
        assertEquals(26, (int)formats.firstKey());
        assertNull(formats.get( formats.firstKey() ));
View Full Code Here

    CTCommentList commentList = comments.getCommentList();

    // 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
    assertSame(comment0, sheetComments.getCTComment("A1"));
    assertSame(comment1, sheetComments.getCTComment("A2"));
View Full Code Here

    public void testCreate() {

        XSSFRichTextString rt = new XSSFRichTextString("Apache POI");
        assertEquals("Apache POI", rt.getString());

        CTRst st = rt.getCTRst();
        assertTrue(st.isSetT());
        assertEquals("Apache POI", st.getT());

        rt.append(" is cool stuff");
        assertEquals(2, st.sizeOfRArray());
        assertFalse(st.isSetT());

        assertEquals("Apache POI is cool stuff", rt.getString());
    }
View Full Code Here

        XSSFRichTextString rt = new XSSFRichTextString("Apache POI");
        assertEquals("Apache POI", rt.getString());

        rt.clearFormatting();

        CTRst st = rt.getCTRst();
        assertTrue(st.isSetT());
        assertEquals("Apache POI", rt.getString());
        assertEquals(0, rt.numFormattingRuns());

        XSSFFont font = new XSSFFont();
        font.setBold(true);
View Full Code Here

TOP

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

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.