/** * Does this string have any explicit formatting applied, or is * it just text in the default style? */ public boolean hasFormatting() { //noinspection deprecation - for performance reasons! CTRElt[] rs = st.getRArray(); if (rs == null || rs.length == 0) { return false; } for (CTRElt r : rs) { if (r.isSetRPr()) return true; } return false; }
TreeMap<Integer, CTRPrElt> getFormatMap(CTRst entry){ int length = 0; TreeMap<Integer, CTRPrElt> formats = new TreeMap<>(); //noinspection deprecation - for performance reasons! for (CTRElt r : entry.getRArray()) { String txt = r.getT(); CTRPrElt fmt = r.getRPr(); length += txt.length(); formats.put(length, fmt); } return formats; }
/** * Returns the number of characters this format run covers. * * @param index the index of the formatting run * @return the number of characters this format run covers */ public int getLengthOfFormattingRun(int index) { if(st.sizeOfRArray() == 0 || index >= st.sizeOfRArray()) { return -1; } CTRElt r = st.getRArray(index); return r.getT().length(); }
/** * The index within the string to which the specified formatting run applies. * * @param index the index of the formatting run * @return the index within the string. */ 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; }
/** * Returns the plain string representation. */ public String getString() { if(st.sizeOfRArray() == 0) { return utfDecode(st.getT()); } StringBuilder buf = new StringBuilder(); //noinspection deprecation - for performance reasons! for(CTRElt r : st.getRArray()){ buf.append(r.getT()); } return utfDecode(buf.toString()); }
protected void setStylesTableReference(StylesTable tbl){ styles = tbl; if(st.sizeOfRArray() > 0) { //noinspection deprecation - for performance reasons! for (CTRElt r : st.getRArray()) { CTRPrElt pr = r.getRPr(); if(pr != null && pr.sizeOfRFontArray() > 0){ 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); } } } } }
/** * Return a copy of the font in use at a particular index. * * @param index The index. * @return A copy of the font that's currently being applied at that * index or null if no font is being applied or the * index is out of range. */ public XSSFFont getFontAtIndex( int index ) { final ThemesTable themes = getThemesTable(); int pos = 0; //noinspection deprecation - for performance reasons! for(CTRElt r : st.getRArray()){ final int length = r.getT().length(); if(index >= pos && index < pos + length) { XSSFFont fnt = new XSSFFont(toCTFont(r.getRPr())); fnt.setThemesTable(themes); return fnt; } pos += length; } return null; }
/** * Gets a copy of the font used in a particular formatting run. * * @param index the index of the formatting run * @return A copy of the font used or null if no formatting is applied to the specified text run. */ public XSSFFont getFontOfFormattingRun(int index) { if(st.sizeOfRArray() == 0 || index >= st.sizeOfRArray()) { return null; } CTRElt r = st.getRArray(index); if(r.getRPr() != null) { XSSFFont fnt = new XSSFFont(toCTFont(r.getRPr())); fnt.setThemesTable(getThemesTable()); return fnt; } return null; }
CTRElt lt = str.getCTRst().getRArray(i); CTRPrElt ltPr = lt.getRPr(); if (ltPr == null) {
CTRElt lt = str.getCTRst().getRArray(i); CTRPrElt ltPr = lt.getRPr(); if (ltPr == null) {
/** * Does this string have any explicit formatting applied, or is * it just text in the default style? */ public boolean hasFormatting() { //noinspection deprecation - for performance reasons! CTRElt[] rs = st.getRArray(); if (rs == null || rs.length == 0) { return false; } for (CTRElt r : rs) { if (r.isSetRPr()) return true; } return false; }
TreeMap<Integer, CTRPrElt> getFormatMap(CTRst entry){ int length = 0; TreeMap<Integer, CTRPrElt> formats = new TreeMap<>(); //noinspection deprecation - for performance reasons! for (CTRElt r : entry.getRArray()) { String txt = r.getT(); CTRPrElt fmt = r.getRPr(); length += txt.length(); formats.put(length, fmt); } return formats; }
@SuppressWarnings("deprecation") TreeMap<Integer, CTRPrElt> getFormatMap(CTRst entry){ int length = 0; TreeMap<Integer, CTRPrElt> formats = new TreeMap<Integer, CTRPrElt>(); for (CTRElt r : entry.getRArray()) { String txt = r.getT(); CTRPrElt fmt = r.getRPr(); length += txt.length(); formats.put(length, fmt); } return formats; }
/** * Returns the number of characters this format run covers. * * @param index the index of the formatting run * @return the number of characters this format run covers */ public int getLengthOfFormattingRun(int index) { if(st.sizeOfRArray() == 0 || index >= st.sizeOfRArray()) { return -1; } CTRElt r = st.getRArray(index); return r.getT().length(); }
/** * The index within the string to which the specified formatting run applies. * * @param index the index of the formatting run * @return the index within the string. */ 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; }
/** * The index within the string to which the specified formatting run applies. * * @param index the index of the formatting run * @return the index within the string. */ 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; }
/** * Returns the plain string representation. */ public String getString() { if(st.sizeOfRArray() == 0) { return utfDecode(st.getT()); } StringBuilder buf = new StringBuilder(); //noinspection deprecation - for performance reasons! for(CTRElt r : st.getRArray()){ buf.append(r.getT()); } return utfDecode(buf.toString()); }
/** * Returns the plain string representation. */ @SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support public String getString() { if(st.sizeOfRArray() == 0) { return utfDecode(st.getT()); } StringBuffer buf = new StringBuffer(); for(CTRElt r : st.getRArray()){ buf.append(r.getT()); } return utfDecode(buf.toString()); }
/** * Returns the number of characters this format run covers. * * @param index the index of the formatting run * @return the number of characters this format run covers */ public int getLengthOfFormattingRun(int index) { if(st.sizeOfRArray() == 0) return length(); for(int i = 0; i < st.sizeOfRArray(); i++){ CTRElt r = st.getRArray(i); if(i == index) return r.getT().length(); } return -1; }
/** * Gets a copy of the font used in a particular formatting run. * * @param index the index of the formatting run * @return A copy of the font used or null if no formatting is applied to the specified text run. */ 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) { XSSFFont fnt = new XSSFFont(toCTFont(r.getRPr())); fnt.setThemesTable(getThemesTable()); return fnt; } } return null; }