public void setText(String text) { if (_body.sizeOfPArray() > 0) { // remove all but first paragraph for (int i = _body.sizeOfPArray() - 1; i > 0; i--) { _body.removeP(i); } getParagraph(0).setText(text); } else { // as there were no paragraphs yet, initialize the text body initialize().setText(text); } }
@Override public XSLFTextRun setText(String text) { // calling clearText or setting to a new Array leads to a // XmlValueDisconnectedException if (!_paragraphs.isEmpty()) { CTTextBody txBody = getTextBody(false); int cntPs = txBody.sizeOfPArray(); for (int i = cntPs; i > 1; i--) { txBody.removeP(i - 1); _paragraphs.remove(i - 1); } _paragraphs.get(0).clearButKeepProperties(); } return appendText(text, false); }
protected XSSFSimpleShape(XSSFDrawing drawing, CTShape ctShape) { this.drawing = drawing; this.ctShape = ctShape; _paragraphs = new ArrayList<>(); // initialize any existing paragraphs - this will be the default body // paragraph in a new shape, // or existing paragraphs that have been loaded from the file CTTextBody body = ctShape.getTxBody(); if (body == null) { _textBody = null; } else { _textBody = new XDDFTextBody(this, body); for (int i = 0; i < body.sizeOfPArray(); i++) { _paragraphs.add(new XSSFTextParagraph(body.getPArray(i), ctShape)); } } }
public void setText(String text) { if (_body.sizeOfPArray() > 0) { // remove all but first paragraph for (int i = _body.sizeOfPArray() - 1; i > 0; i--) { _body.removeP(i); } getParagraph(0).setText(text); } else { // as there were no paragraphs yet, initialize the text body initialize().setText(text); } }
@Override public XSLFTextRun setText(String text) { // calling clearText or setting to a new Array leads to a // XmlValueDisconnectedException if (!_paragraphs.isEmpty()) { CTTextBody txBody = getTextBody(false); int cntPs = txBody.sizeOfPArray(); for (int i = cntPs; i > 1; i--) { txBody.removeP(i - 1); _paragraphs.remove(i - 1); } _paragraphs.get(0).clearButKeepProperties(); } return appendText(text, false); }
protected XSSFSimpleShape(XSSFDrawing drawing, CTShape ctShape) { this.drawing = drawing; this.ctShape = ctShape; _paragraphs = new ArrayList<>(); // initialize any existing paragraphs - this will be the default body // paragraph in a new shape, // or existing paragraphs that have been loaded from the file CTTextBody body = ctShape.getTxBody(); if (body == null) { _textBody = null; } else { _textBody = new XDDFTextBody(this, body); for (int i = 0; i < body.sizeOfPArray(); i++) { _paragraphs.add(new XSSFTextParagraph(body.getPArray(i), ctShape)); } } }