Search in sources :

Example 6 with CTTextBody

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);
}
Also used : CTTextBody(org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody)

Example 7 with CTTextBody

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);
}
Also used : CTTextBody(org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody)

Example 8 with CTTextBody

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);
    }
}
Also used : VerticalAlignment(org.apache.poi.sl.usermodel.VerticalAlignment) CTTextBody(org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody)

Example 9 with CTTextBody

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;
}
Also used : CTTableCell(org.openxmlformats.schemas.drawingml.x2006.main.CTTableCell) CTTextBody(org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody)

Example 10 with CTTextBody

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);
    }
}
Also used : CTTextParagraph(org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph) CTTextField(org.openxmlformats.schemas.drawingml.x2006.main.CTTextField) CTTx(org.openxmlformats.schemas.drawingml.x2006.chart.CTTx) CTTextBody(org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody) CTTitle(org.openxmlformats.schemas.drawingml.x2006.chart.CTTitle) CTRegularTextRun(org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun)

Aggregations

CTTextBody (org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody)9 CTTextParagraph (org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph)3 CTTextBodyProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties)2 CTShape (org.openxmlformats.schemas.presentationml.x2006.main.CTShape)2 VerticalAlignment (org.apache.poi.sl.usermodel.VerticalAlignment)1 CTTitle (org.openxmlformats.schemas.drawingml.x2006.chart.CTTitle)1 CTTx (org.openxmlformats.schemas.drawingml.x2006.chart.CTTx)1 CTRegularTextRun (org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun)1 CTTableCell (org.openxmlformats.schemas.drawingml.x2006.main.CTTableCell)1 CTTextCharacterProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties)1 CTTextField (org.openxmlformats.schemas.drawingml.x2006.main.CTTextField)1 CTShape (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape)1 CTShapeNonVisual (org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShapeNonVisual)1 CTApplicationNonVisualDrawingProps (org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps)1