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

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


     */
    public XSSFFont getFontOfFormattingRun(int index) {
        if(st.sizeOfRArray() == 0) return null;

        for(int i = 0; i < st.sizeOfRArray(); i++){
            CTRElt r = st.getRArray(i);
            if(i == index) return new XSSFFont(toCTFont(r.getRPr()));
        }
        return null;
    }
View Full Code Here


    public XSSFFont getFontAtIndex( int index ) {
        if(st.sizeOfRArray() == 0) return null;

        int pos = 0;
        for(int i = 0; i < st.sizeOfRArray(); i++){
            CTRElt r = st.getRArray(i);
            if(index >= pos && index < pos + r.getT().length()) return new XSSFFont(toCTFont(r.getRPr()));

            pos += r.getT().length();
        }
        return null;

    }
View Full Code Here

        assertEquals(1, idx);
        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());
        assertEquals(3, sst.getUniqueCount());
View Full Code Here

            rPr.setSz(1100);
            r.setT(str.getString());

        } else {
            for (int i = 0; i < str.getCTRst().sizeOfRArray(); i++) {
                CTRElt lt = str.getCTRst().getRArray(i);
                CTRPrElt ltPr = lt.getRPr();
                if(ltPr == null) ltPr = lt.addNewRPr();

                CTRegularTextRun r = p.addNewR();
                CTTextCharacterProperties rPr = r.addNewRPr();
                rPr.setLang("en-US");

                applyAttributes(ltPr, rPr);

                r.setT(lt.getT());
            }
        }
       
        clearText();               
        ctShape.getTxBody().setPArray(new CTTextParagraph[]{p});
View Full Code Here

            rPr.setSz(1100);
            r.setT(str.getString());

        } else {
            for (int i = 0; i < str.getCTRst().sizeOfRArray(); i++) {
                CTRElt lt = str.getCTRst().getRArray(i);
                CTRPrElt ltPr = lt.getRPr();
                if(ltPr == null) ltPr = lt.addNewRPr();

                CTRegularTextRun r = p.addNewR();
                CTTextCharacterProperties rPr = r.addNewRPr();
                rPr.setLang("en-US");

                applyAttributes(ltPr, rPr);

                r.setT(lt.getT());
            }
        }
       
        // Note: the XSSFTextParagraph constructor will create its required XSSFTextRuns from the provided CTTextParagraph
        XSSFTextParagraph paragraph = new XSSFTextParagraph(p, ctShape);
View Full Code Here

    public XSSFFont getFontAtIndex( int index ) {
        if(st.sizeOfRArray() == 0) return null;

        int pos = 0;
        for(int i = 0; i < st.sizeOfRArray(); i++){
            CTRElt r = st.getRArray(i);
            if(index >= pos && index < pos + r.getT().length()) return new XSSFFont(toCTFont(r.getRPr()));

            pos += r.getT().length();
        }
        return null;

    }
View Full Code Here

            if(rEnd <= startIndex) {
                runs.add(r[i]);
                pos += r[i].getT().length();
            }
            else if (startIndex > rStart && startIndex < rEnd){
                CTRElt c = (CTRElt)r[i].copy();
                String txt = text.substring(rStart, startIndex);
                c.setT(txt);
                runs.add(c);
                pos += txt.length();
            } else {
                break;
            }
        }
        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++) {
            int rStart = pos;
            String t = r[i].getT();
            int rEnd = Math.min(rStart + t.length(), text.length());

            if (endIndex < rEnd){
                CTRElt c = (CTRElt)r[i].copy();
                txt = text.substring(rStart, rEnd);
                c.setT(txt);
                runs.add(c);
                pos += txt.length();
                preserveSpaces(c.xgetT());
            }
        }


        st.setRArray(runs.toArray(new CTRElt[runs.size()]));
View Full Code Here

     * Sets the font of the entire string.
     * @param font          The font to use.
     */
    public void applyFont(Font font) {
        if(st.sizeOfRArray() == 0 && st.isSetT()) {
            CTRElt r = st.addNewR();
            r.setT(st.getT());
            setRunAttributes(((XSSFFont)font).getCTFont(), r.addNewRPr());
            st.unsetT();
        } else {
            CTRElt r = CTRElt.Factory.newInstance();
            r.setT(getString());
            setRunAttributes(((XSSFFont)font).getCTFont(), r.addNewRPr());
            st.setRArray(new CTRElt[]{r});
        }
    }
View Full Code Here

        if(st.sizeOfRArray() == 0 && st.isSetT()) {
            //convert <t>string</t> into a text run: <r><t>string</t></r>
            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

    public int getIndexOfFormattingRun(int index) {
        if(st.sizeOfRArray() == 0) return 0;

        int pos = 0;
        for(int i = 0; i < st.sizeOfRArray(); i++){
            CTRElt r = st.getRArray(i);
            if(i == index) return pos;

            pos += r.getT().length();
        }
        return -1;
    }
View Full Code Here

TOP

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

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.