/** * Sets (overwrites) the current text. * Uses the properties of the first paragraph / textrun * * @param text the text string used by this object. */ public static HSLFTextRun setText(List<HSLFTextParagraph> paragraphs, String text) { // check paragraphs assert(!paragraphs.isEmpty() && !paragraphs.get(0).getTextRuns().isEmpty()); Iterator<HSLFTextParagraph> paraIter = paragraphs.iterator(); HSLFTextParagraph htp = paraIter.next(); // keep first assert (htp != null); while (paraIter.hasNext()) { paraIter.next(); paraIter.remove(); } Iterator<HSLFTextRun> runIter = htp.getTextRuns().iterator(); if (runIter.hasNext()) { HSLFTextRun htr = runIter.next(); htr.setText(""); while (runIter.hasNext()) { runIter.next(); runIter.remove(); } } else { HSLFTextRun trun = new HSLFTextRun(htp); htp.addTextRun(trun); } return appendText(paragraphs, text, false); }
trun.setText(text.substring(0, ccStyle - ccRun)); HSLFTextRun nextRun = new HSLFTextRun(para); nextRun.setText(text.substring(ccStyle - ccRun)); runs.add(runIdx + 1, nextRun); if (csIdx < charStyles.size() - 1) { HSLFTextRun nextRun = new HSLFTextRun(para); nextRun.setText(""); runs.add(nextRun);
if (startIdx > 0) { HSLFTextRun newRun = new HSLFTextRun(p); newRun.setCharacterStyle(run.getCharacterStyle()); newRun.setText(rawText.substring(startIdx)); if (endIdx < rlen) { HSLFTextRun newRun = new HSLFTextRun(p); newRun.setCharacterStyle(run.getCharacterStyle()); newRun.setText(rawText.substring(0, endIdx));
htr = new HSLFTextRun(htp); htr.getCharacterStyle().copy(tpc); htp.addTextRun(htr);
tpara.getParagraphStyle().updateTextSize(para.length()); HSLFTextRun trun = new HSLFTextRun(tpara); tpara.addTextRun(trun); trun.setText(para);
_paragraphs.add(htp); HSLFTextRun htr = new HSLFTextRun(htp); htr.setCharacterStyle(charStyle); htr.setText(text);