Search in sources :

Example 1 with ParagraphPropertyFetcher

use of org.apache.poi.xslf.model.ParagraphPropertyFetcher 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 2 with ParagraphPropertyFetcher

use of org.apache.poi.xslf.model.ParagraphPropertyFetcher 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 3 with ParagraphPropertyFetcher

use of org.apache.poi.xslf.model.ParagraphPropertyFetcher in project poi by apache.

the class XSLFTextParagraph method getTabStop.

public double getTabStop(final int idx) {
    ParagraphPropertyFetcher<Double> fetcher = new ParagraphPropertyFetcher<Double>(getIndentLevel()) {

        public boolean fetch(CTTextParagraphProperties props) {
            if (props.isSetTabLst()) {
                CTTextTabStopList tabStops = props.getTabLst();
                if (idx < tabStops.sizeOfTabArray()) {
                    CTTextTabStop ts = tabStops.getTabArray(idx);
                    double val = Units.toPoints(ts.getPos());
                    setValue(val);
                    return true;
                }
            }
            return false;
        }
    };
    fetchParagraphProperty(fetcher);
    return fetcher.getValue() == null ? 0. : fetcher.getValue();
}
Also used : ParagraphPropertyFetcher(org.apache.poi.xslf.model.ParagraphPropertyFetcher) CTTextTabStop(org.openxmlformats.schemas.drawingml.x2006.main.CTTextTabStop) CTTextParagraphProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties) CTTextTabStopList(org.openxmlformats.schemas.drawingml.x2006.main.CTTextTabStopList)

Example 4 with ParagraphPropertyFetcher

use of org.apache.poi.xslf.model.ParagraphPropertyFetcher in project poi by apache.

the class XSLFTextParagraph method getLineSpacing.

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

        public boolean fetch(CTTextParagraphProperties props) {
            if (props.isSetLnSpc()) {
                CTTextSpacing spc = props.getLnSpc();
                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);
    Double lnSpc = fetcher.getValue();
    if (lnSpc != null && lnSpc > 0) {
        // check if the percentage value is scaled
        CTTextNormalAutofit normAutofit = getParentShape().getTextBodyPr().getNormAutofit();
        if (normAutofit != null) {
            double scale = 1 - (double) normAutofit.getLnSpcReduction() / 100000;
            lnSpc *= scale;
        }
    }
    return lnSpc;
}
Also used : ParagraphPropertyFetcher(org.apache.poi.xslf.model.ParagraphPropertyFetcher) CTTextSpacing(org.openxmlformats.schemas.drawingml.x2006.main.CTTextSpacing) CTTextNormalAutofit(org.openxmlformats.schemas.drawingml.x2006.main.CTTextNormalAutofit) CTTextParagraphProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties)

Example 5 with ParagraphPropertyFetcher

use of org.apache.poi.xslf.model.ParagraphPropertyFetcher 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)

Aggregations

ParagraphPropertyFetcher (org.apache.poi.xslf.model.ParagraphPropertyFetcher)6 CTTextParagraphProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties)6 CTTextSpacing (org.openxmlformats.schemas.drawingml.x2006.main.CTTextSpacing)3 Color (java.awt.Color)1 AutoNumberingScheme (org.apache.poi.sl.usermodel.AutoNumberingScheme)1 CTColor (org.openxmlformats.schemas.drawingml.x2006.main.CTColor)1 CTSRgbColor (org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor)1 CTTextNormalAutofit (org.openxmlformats.schemas.drawingml.x2006.main.CTTextNormalAutofit)1 CTTextTabStop (org.openxmlformats.schemas.drawingml.x2006.main.CTTextTabStop)1 CTTextTabStopList (org.openxmlformats.schemas.drawingml.x2006.main.CTTextTabStopList)1