use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody in project poi by apache.
the class XSLFTextShape method clearText.
/**
* unset text from this shape
*/
public void clearText() {
_paragraphs.clear();
CTTextBody txBody = getTextBody(true);
// remove any existing paragraphs
txBody.setPArray(null);
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody in project poi by apache.
the class XSLFTextShape method setText.
@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);
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody in project poi by apache.
the class XSLFTextShape method copy.
@Override
void copy(XSLFShape other) {
super.copy(other);
XSLFTextShape otherTS = (XSLFTextShape) other;
CTTextBody otherTB = otherTS.getTextBody(false);
CTTextBody thisTB = getTextBody(true);
if (otherTB == null) {
return;
}
thisTB.setBodyPr((CTTextBodyProperties) otherTB.getBodyPr().copy());
if (thisTB.isSetLstStyle())
thisTB.unsetLstStyle();
if (otherTB.isSetLstStyle()) {
thisTB.setLstStyle((CTTextListStyle) otherTB.getLstStyle().copy());
}
boolean srcWordWrap = otherTS.getWordWrap();
if (srcWordWrap != getWordWrap()) {
setWordWrap(srcWordWrap);
}
double leftInset = otherTS.getLeftInset();
if (leftInset != getLeftInset()) {
setLeftInset(leftInset);
}
double rightInset = otherTS.getRightInset();
if (rightInset != getRightInset()) {
setRightInset(rightInset);
}
double topInset = otherTS.getTopInset();
if (topInset != getTopInset()) {
setTopInset(topInset);
}
double bottomInset = otherTS.getBottomInset();
if (bottomInset != getBottomInset()) {
setBottomInset(bottomInset);
}
VerticalAlignment vAlign = otherTS.getVerticalAlignment();
if (vAlign != getVerticalAlignment()) {
setVerticalAlignment(vAlign);
}
clearText();
for (XSLFTextParagraph srcP : otherTS.getTextParagraphs()) {
XSLFTextParagraph tgtP = addNewTextParagraph();
tgtP.copy(srcP);
}
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody in project poi by apache.
the class XSLFTableCell method getTextBody.
@Override
protected CTTextBody getTextBody(boolean create) {
CTTableCell cell = getCell();
CTTextBody txBody = cell.getTxBody();
if (txBody == null && create) {
txBody = cell.addNewTxBody();
XSLFAutoShape.initTextBody(txBody);
}
return txBody;
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody in project poi by apache.
the class XSSFChart method setTitleText.
/**
* Sets the title text as a static string.
* @param newTitle to use
*/
public void setTitleText(String newTitle) {
CTTitle ctTitle;
if (chart.isSetTitle()) {
ctTitle = chart.getTitle();
} else {
ctTitle = chart.addNewTitle();
}
CTTx tx;
if (ctTitle.isSetTx()) {
tx = ctTitle.getTx();
} else {
tx = ctTitle.addNewTx();
}
if (tx.isSetStrRef()) {
tx.unsetStrRef();
}
CTTextBody rich;
if (tx.isSetRich()) {
rich = tx.getRich();
} else {
rich = tx.addNewRich();
// body properties must exist (but can be empty)
rich.addNewBodyPr();
}
CTTextParagraph para;
if (rich.sizeOfPArray() > 0) {
para = rich.getPArray(0);
} else {
para = rich.addNewP();
}
if (para.sizeOfRArray() > 0) {
CTRegularTextRun run = para.getRArray(0);
run.setT(newTitle);
} else if (para.sizeOfFldArray() > 0) {
CTTextField fld = para.getFldArray(0);
fld.setT(newTitle);
} else {
CTRegularTextRun run = para.addNewR();
run.setT(newTitle);
}
}
Aggregations