Search in sources :

Example 16 with CTTextParagraphProperties

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

the class XSLFTextParagraph method getAutoNumberingScheme.

/**
     * @return the auto numbering scheme, or null if not defined
     */
public AutoNumberingScheme getAutoNumberingScheme() {
    ParagraphPropertyFetcher<AutoNumberingScheme> fetcher = new ParagraphPropertyFetcher<AutoNumberingScheme>(getIndentLevel()) {

        public boolean fetch(CTTextParagraphProperties props) {
            if (props.isSetBuAutoNum()) {
                AutoNumberingScheme ans = AutoNumberingScheme.forOoxmlID(props.getBuAutoNum().getType().intValue());
                if (ans != null) {
                    setValue(ans);
                    return true;
                }
            }
            return false;
        }
    };
    fetchParagraphProperty(fetcher);
    return fetcher.getValue();
}
Also used : ParagraphPropertyFetcher(org.apache.poi.xslf.model.ParagraphPropertyFetcher) CTTextParagraphProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties) AutoNumberingScheme(org.apache.poi.sl.usermodel.AutoNumberingScheme)

Example 17 with CTTextParagraphProperties

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

the class XSLFTextParagraph method addTabStop.

public void addTabStop(double value) {
    CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
    CTTextTabStopList tabStops = pr.isSetTabLst() ? pr.getTabLst() : pr.addNewTabLst();
    tabStops.addNewTab().setPos(Units.toEMU(value));
}
Also used : CTTextParagraphProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties) CTTextTabStopList(org.openxmlformats.schemas.drawingml.x2006.main.CTTextTabStopList)

Example 18 with CTTextParagraphProperties

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

the class XSLFTextParagraph method getSpaceBefore.

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

        public boolean fetch(CTTextParagraphProperties props) {
            if (props.isSetSpcBef()) {
                CTTextSpacing spc = props.getSpcBef();
                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 19 with CTTextParagraphProperties

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

the class XSLFTextParagraph method setBulletAutoNumber.

/**
     * Specifies that automatic numbered bullet points should be applied to this paragraph
     *
     * @param scheme type of auto-numbering
     * @param startAt the number that will start number for a given sequence of automatically
    numbered bullets (1-based).
     */
public void setBulletAutoNumber(AutoNumberingScheme scheme, int startAt) {
    if (startAt < 1)
        throw new IllegalArgumentException("Start Number must be greater or equal that 1");
    CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
    CTTextAutonumberBullet lst = pr.isSetBuAutoNum() ? pr.getBuAutoNum() : pr.addNewBuAutoNum();
    lst.setType(STTextAutonumberScheme.Enum.forInt(scheme.ooxmlId));
    lst.setStartAt(startAt);
}
Also used : CTTextAutonumberBullet(org.openxmlformats.schemas.drawingml.x2006.main.CTTextAutonumberBullet) CTTextParagraphProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties)

Example 20 with CTTextParagraphProperties

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

the class XSLFTextRun method fetchCharacterProperty.

private boolean fetchCharacterProperty(CharacterPropertyFetcher<?> fetcher) {
    XSLFTextShape shape = _p.getParentShape();
    XSLFSheet sheet = shape.getSheet();
    CTTextCharacterProperties rPr = getRPr(false);
    if (rPr != null && fetcher.fetch(rPr)) {
        return true;
    }
    if (shape.fetchShapeProperty(fetcher)) {
        return true;
    }
    CTPlaceholder ph = shape.getCTPlaceholder();
    if (ph == null) {
        // if it is a plain text box then take defaults from presentation.xml
        @SuppressWarnings("resource") XMLSlideShow ppt = sheet.getSlideShow();
        // TODO: determine master shape
        CTTextParagraphProperties themeProps = ppt.getDefaultParagraphStyle(_p.getIndentLevel());
        if (themeProps != null && fetcher.fetch(themeProps)) {
            return true;
        }
    }
    // TODO: determine master shape
    CTTextParagraphProperties defaultProps = _p.getDefaultMasterStyle();
    if (defaultProps != null && fetcher.fetch(defaultProps)) {
        return true;
    }
    return false;
}
Also used : CTPlaceholder(org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder) CTTextCharacterProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties) 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