use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRPrElt in project poi by apache.
the class XSSFRichTextString method setStylesTableReference.
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);
}
}
}
}
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRPrElt in project poi by apache.
the class XSSFRichTextString method buildCTRst.
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 stf = CTRst.Factory.newInstance();
int runStartIdx = 0;
for (Map.Entry<Integer, CTRPrElt> me : formats.entrySet()) {
int runEndIdx = me.getKey();
CTRElt run = stf.addNewR();
String fragment = text.substring(runStartIdx, runEndIdx);
run.setT(fragment);
preserveSpaces(run.xgetT());
CTRPrElt fmt = me.getValue();
if (fmt != null) {
run.setRPr(fmt);
}
runStartIdx = runEndIdx;
}
return stf;
}
Aggregations