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();
}
}