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

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


            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);
            runStartIdx = runEndIdx;
        }
        return st;
    }
View Full Code Here


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

        CTRPrElt fmt1 = CTRPrElt.Factory.newInstance();
        str.applyFont(formats, 0, 6, fmt1);
        assertEquals(2, formats.size());
        assertEquals("[6, 26]", formats.keySet().toString());
        Object[] runs1 = formats.values().toArray();
        assertSame(fmt1, runs1[0]);
        assertSame(null, runs1[1]);

        CTRPrElt fmt2 = CTRPrElt.Factory.newInstance();
        str.applyFont(formats, 7, 15, fmt2);
        assertEquals(4, formats.size());
        assertEquals("[6, 7, 15, 26]", formats.keySet().toString());
        Object[] runs2 = formats.values().toArray();
        assertSame(fmt1, runs2[0]);
        assertSame(null, runs2[1]);
        assertSame(fmt2, runs2[2]);
        assertSame(null, runs2[3]);

        CTRPrElt fmt3 = CTRPrElt.Factory.newInstance();
        str.applyFont(formats, 6, 7, fmt3);
        assertEquals(4, formats.size());
        assertEquals("[6, 7, 15, 26]", formats.keySet().toString());
        Object[] runs3 = formats.values().toArray();
        assertSame(fmt1, runs3[0]);
        assertSame(fmt3, runs3[1]);
        assertSame(fmt2, runs3[2]);
        assertSame(null, runs3[3]);

        CTRPrElt fmt4 = CTRPrElt.Factory.newInstance();
        str.applyFont(formats, 0, 7, fmt4);
        assertEquals(3, formats.size());
        assertEquals("[7, 15, 26]", formats.keySet().toString());
        Object[] runs4 = formats.values().toArray();
        assertSame(fmt4, runs4[0]);
        assertSame(fmt2, runs4[1]);
        assertSame(null, runs4[2]);

        CTRPrElt fmt5 = CTRPrElt.Factory.newInstance();
        str.applyFont(formats, 0, 26, fmt5);
        assertEquals(1, formats.size());
        assertEquals("[26]", formats.keySet().toString());
        Object[] runs5 = formats.values().toArray();
        assertSame(fmt5, runs5[0]);

        CTRPrElt fmt6 = CTRPrElt.Factory.newInstance();
        str.applyFont(formats, 15, 26, fmt6);
        assertEquals(2, formats.size());
        assertEquals("[15, 26]", formats.keySet().toString());
        Object[] runs6 = formats.values().toArray();
        assertSame(fmt5, runs6[0]);
View Full Code Here

        assertEquals(5, sst.getCount());
        assertEquals(2, sst.getUniqueCount());

        st = CTRst.Factory.newInstance();
        CTRElt r = st.addNewR();
        CTRPrElt pr = r.addNewRPr();
        pr.addNewColor().setRgb(new byte[]{(byte)0xFF, 0, 0}); //red
        pr.addNewI().setVal(true)//bold
        pr.addNewB().setVal(true)//italic
        r.setT("Second string");

        idx = sst.addEntry(st);
        assertEquals(2, idx);
        assertEquals(6, sst.getCount());
View Full Code Here

        assertEquals(5, sst.getCount());
        assertEquals(2, sst.getUniqueCount());

        st = CTRst.Factory.newInstance();
        CTRElt r = st.addNewR();
        CTRPrElt pr = r.addNewRPr();
        pr.addNewColor().setRgb(new byte[]{(byte)0xFF, 0, 0}); //red
        pr.addNewI().setVal(true)//bold
        pr.addNewB().setVal(true)//italic
        r.setT("Second string");

        idx = sst.addEntry(st);
        assertEquals(2, idx);
        assertEquals(6, sst.getCount());
View Full Code Here

   
    // Now get all the formatting
    // TODO: implement Rst/RpR to RichTextString conversion
    for(CTRElt r : ctText.getRArray()) {
      // Formatting info comes from rPr
      CTRPrElt rPr = r.getRPr();
      rPr.getRFontArray();
    }
    return rtxt;
  }
View Full Code Here

        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();
        assertEquals(true, rPr.getIArray()[0].getVal());
        assertEquals(8.5, rPr.getSzArray()[0].getVal());
        assertEquals(IndexedColors.BLUE_GREY.getIndex(), rPr.getColorArray()[0].getIndexed());
        assertEquals("Tahoma", rPr.getRFontArray()[0].getVal());
    }
View Full Code Here

        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();
        assertEquals(true, rPr.getIArray(0).getVal());
        assertEquals(8.5, rPr.getSzArray(0).getVal());
        assertEquals(IndexedColors.BLUE_GREY.getIndex(), rPr.getColorArray(0).getIndexed());
        assertEquals("Tahoma", rPr.getRFontArray(0).getVal());
    }
View Full Code Here

            }
        }
        CTRElt rt = CTRElt.Factory.newInstance();
        String txt = text.substring(startIndex, endIndex);
        rt.setT(txt);
        CTRPrElt pr = rt.addNewRPr();
        setRunAttributes(xssfFont.getCTFont(), pr);
        runs.add(rt);
        pos += txt.length();

        for (int i = 0; i < r.length; i++) {
View Full Code Here

            st.addNewR().setT(st.getT());
            st.unsetT();
        }
        CTRElt lt = st.addNewR();
        lt.setT(text);
        CTRPrElt pr = lt.addNewRPr();
        if(font != null) setRunAttributes(font.getCTFont(), pr);
    }
View Full Code Here

    @SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
    protected void setStylesTableReference(StylesTable tbl){
        styles = tbl;
        if(st.sizeOfRArray() > 0) {
            for (CTRElt r : st.getRArray()) {
                CTRPrElt pr = r.getRPr();
                if(pr != null){
                    String fontName = pr.getRFontArray(0).getVal();
                    if(fontName.startsWith("#")){
                        int idx = Integer.parseInt(fontName.substring(1));
                        XSSFFont font = styles.getFontAt(idx);
                        pr.removeRFont(0);
                        setRunAttributes(font.getCTFont(), pr);
                    }
                }
            }
        }
View Full Code Here

TOP

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

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.