Search in sources :

Example 1 with CTTextParagraphProperties

use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties in project poi by apache.

the class XSLFTextParagraph method setBulletFontColor.

/**
     * Set the color to be used on bullet characters within a given paragraph.
     *
     * @param color the bullet color
     */
public void setBulletFontColor(PaintStyle color) {
    if (!(color instanceof SolidPaint)) {
        throw new IllegalArgumentException("Currently XSLF only supports SolidPaint");
    }
    // TODO: implement setting bullet color to null
    SolidPaint sp = (SolidPaint) color;
    Color col = DrawPaint.applyColorTransform(sp.getSolidColor());
    CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
    CTColor c = pr.isSetBuClr() ? pr.getBuClr() : pr.addNewBuClr();
    CTSRgbColor clr = c.isSetSrgbClr() ? c.getSrgbClr() : c.addNewSrgbClr();
    clr.setVal(new byte[] { (byte) col.getRed(), (byte) col.getGreen(), (byte) col.getBlue() });
}
Also used : SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) Color(java.awt.Color) CTColor(org.openxmlformats.schemas.drawingml.x2006.main.CTColor) CTSRgbColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor) CTTextParagraphProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties) CTSRgbColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor) CTColor(org.openxmlformats.schemas.drawingml.x2006.main.CTColor)

Example 2 with CTTextParagraphProperties

use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties in project poi by apache.

the class XSLFTextParagraph method getBulletFontColor.

/**
     *
     * @return the color of bullet characters within a given paragraph.
     * A <code>null</code> value means to use the text font color.
     */
public PaintStyle getBulletFontColor() {
    final XSLFTheme theme = getParentShape().getSheet().getTheme();
    ParagraphPropertyFetcher<Color> fetcher = new ParagraphPropertyFetcher<Color>(getIndentLevel()) {

        public boolean fetch(CTTextParagraphProperties props) {
            if (props.isSetBuClr()) {
                XSLFColor c = new XSLFColor(props.getBuClr(), theme, null);
                setValue(c.getColor());
                return true;
            }
            return false;
        }
    };
    fetchParagraphProperty(fetcher);
    Color col = fetcher.getValue();
    return (col == null) ? null : DrawPaint.createSolidPaint(col);
}
Also used : Color(java.awt.Color) CTColor(org.openxmlformats.schemas.drawingml.x2006.main.CTColor) CTSRgbColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor) ParagraphPropertyFetcher(org.apache.poi.xslf.model.ParagraphPropertyFetcher) CTTextParagraphProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties)

Example 3 with CTTextParagraphProperties

use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties in project poi by apache.

the class XSLFTextParagraph method getSpaceAfter.

@Override
public Double getSpaceAfter() {
    ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getIndentLevel()) {

        public boolean fetch(CTTextParagraphProperties props) {
            if (props.isSetSpcAft()) {
                CTTextSpacing spc = props.getSpcAft();
                if (spc.isSetSpcPct())
                    setValue(spc.getSpcPct().getVal() * 0.001);
                else if (spc.isSetSpcPts())
                    setValue(-spc.getSpcPts().getVal() * 0.01);
                return true;
            }
            return false;
        }
    };
    fetchParagraphProperty(fetcher);
    return fetcher.getValue();
}
Also used : ParagraphPropertyFetcher(org.apache.poi.xslf.model.ParagraphPropertyFetcher) CTTextSpacing(org.openxmlformats.schemas.drawingml.x2006.main.CTTextSpacing) CTTextParagraphProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties)

Example 4 with CTTextParagraphProperties

use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties in project poi by apache.

the class XSLFTextParagraph method getDefaultMasterStyle.

/**
     * @return master style text paragraph properties, or <code>null</code> if 
     * there are no master slides or the master slides do not contain a text paragraph
     */
/* package */
CTTextParagraphProperties getDefaultMasterStyle() {
    CTPlaceholder ph = _shape.getCTPlaceholder();
    String defaultStyleSelector;
    switch(ph == null ? -1 : ph.getType().intValue()) {
        case STPlaceholderType.INT_TITLE:
        case STPlaceholderType.INT_CTR_TITLE:
            defaultStyleSelector = "titleStyle";
            break;
        // no placeholder means plain text box
        case -1:
        case STPlaceholderType.INT_FTR:
        case STPlaceholderType.INT_SLD_NUM:
        case STPlaceholderType.INT_DT:
            defaultStyleSelector = "otherStyle";
            break;
        default:
            defaultStyleSelector = "bodyStyle";
            break;
    }
    int level = getIndentLevel();
    // wind up and find the root master sheet which must be slide master
    final String nsPML = "http://schemas.openxmlformats.org/presentationml/2006/main";
    final String nsDML = "http://schemas.openxmlformats.org/drawingml/2006/main";
    XSLFSheet masterSheet = _shape.getSheet();
    for (XSLFSheet m = masterSheet; m != null; m = (XSLFSheet) m.getMasterSheet()) {
        masterSheet = m;
        XmlObject xo = masterSheet.getXmlObject();
        XmlCursor cur = xo.newCursor();
        try {
            cur.push();
            if ((cur.toChild(nsPML, "txStyles") && cur.toChild(nsPML, defaultStyleSelector)) || (cur.pop() && cur.toChild(nsPML, "notesStyle"))) {
                while (level >= 0) {
                    cur.push();
                    if (cur.toChild(nsDML, "lvl" + (level + 1) + "pPr")) {
                        return (CTTextParagraphProperties) cur.getObject();
                    }
                    cur.pop();
                    level--;
                }
            }
        } finally {
            cur.dispose();
        }
    }
    return null;
}
Also used : CTPlaceholder(org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder) XmlObject(org.apache.xmlbeans.XmlObject) CTTextParagraphProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties) DrawPaint(org.apache.poi.sl.draw.DrawPaint) SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) CTTextBulletSizePoint(org.openxmlformats.schemas.drawingml.x2006.main.CTTextBulletSizePoint) XmlCursor(org.apache.xmlbeans.XmlCursor)

Example 5 with CTTextParagraphProperties

use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties in project poi by apache.

the class XSLFTextParagraph method setSpaceAfter.

@Override
public void setSpaceAfter(Double spaceAfter) {
    if (spaceAfter == null && !_p.isSetPPr()) {
        return;
    }
    // unset the space before on null input
    if (spaceAfter == null) {
        if (_p.getPPr().isSetSpcAft()) {
            _p.getPPr().unsetSpcAft();
        }
        return;
    }
    CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
    CTTextSpacing spc = CTTextSpacing.Factory.newInstance();
    if (spaceAfter >= 0) {
        spc.addNewSpcPct().setVal((int) (spaceAfter * 1000));
    } else {
        spc.addNewSpcPts().setVal((int) (-spaceAfter * 100));
    }
    pr.setSpcAft(spc);
}
Also used : CTTextSpacing(org.openxmlformats.schemas.drawingml.x2006.main.CTTextSpacing) CTTextParagraphProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties)

Aggregations

CTTextParagraphProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties)22 ParagraphPropertyFetcher (org.apache.poi.xslf.model.ParagraphPropertyFetcher)6 CTTextSpacing (org.openxmlformats.schemas.drawingml.x2006.main.CTTextSpacing)5 CTTextCharacterProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties)4 CTPlaceholder (org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder)3 Color (java.awt.Color)2 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)2 Test (org.junit.Test)2 CTColor (org.openxmlformats.schemas.drawingml.x2006.main.CTColor)2 CTSRgbColor (org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor)2 CTTextBulletSizePoint (org.openxmlformats.schemas.drawingml.x2006.main.CTTextBulletSizePoint)2 CTTextTabStopList (org.openxmlformats.schemas.drawingml.x2006.main.CTTextTabStopList)2 DrawPaint (org.apache.poi.sl.draw.DrawPaint)1 AutoNumberingScheme (org.apache.poi.sl.usermodel.AutoNumberingScheme)1 XmlCursor (org.apache.xmlbeans.XmlCursor)1 XmlObject (org.apache.xmlbeans.XmlObject)1 CTTextAutonumberBullet (org.openxmlformats.schemas.drawingml.x2006.main.CTTextAutonumberBullet)1 CTTextBulletSizePercent (org.openxmlformats.schemas.drawingml.x2006.main.CTTextBulletSizePercent)1 CTTextCharBullet (org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharBullet)1 CTTextFont (org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont)1