Search in sources :

Example 6 with PropertyFetcher

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

the class XSLFSimpleShape method getLineWidth.

/**
     * @return line width in points. <code>0</code> means no line.
     */
public double getLineWidth() {
    PropertyFetcher<Double> fetcher = new PropertyFetcher<Double>() {

        @Override
        public boolean fetch(XSLFShape shape) {
            CTLineProperties ln = getLn(shape, false);
            if (ln != null) {
                if (ln.isSetNoFill()) {
                    setValue(0.);
                    return true;
                }
                if (ln.isSetW()) {
                    setValue(Units.toPoints(ln.getW()));
                    return true;
                }
            }
            return false;
        }
    };
    fetchShapeProperty(fetcher);
    double lineWidth = 0;
    if (fetcher.getValue() == null) {
        CTLineProperties defaultLn = getDefaultLineProperties();
        if (defaultLn != null) {
            if (defaultLn.isSetW()) {
                lineWidth = Units.toPoints(defaultLn.getW());
            }
        }
    } else {
        lineWidth = fetcher.getValue();
    }
    return lineWidth;
}
Also used : CTLineProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties) PropertyFetcher(org.apache.poi.xslf.model.PropertyFetcher)

Example 7 with PropertyFetcher

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

the class XSLFShape method getFillPaint.

protected PaintStyle getFillPaint() {
    final XSLFTheme theme = getSheet().getTheme();
    final boolean hasPlaceholder = getPlaceholder() != null;
    PropertyFetcher<PaintStyle> fetcher = new PropertyFetcher<PaintStyle>() {

        public boolean fetch(XSLFShape shape) {
            XSLFFillProperties fp = XSLFPropertiesDelegate.getFillDelegate(shape.getShapeProperties());
            if (fp == null) {
                return false;
            }
            if (fp.isSetNoFill()) {
                setValue(null);
                return true;
            }
            PackagePart pp = shape.getSheet().getPackagePart();
            PaintStyle paint = selectPaint(fp, null, pp, theme, hasPlaceholder);
            if (paint != null) {
                setValue(paint);
                return true;
            }
            CTShapeStyle style = shape.getSpStyle();
            if (style != null) {
                fp = XSLFPropertiesDelegate.getFillDelegate(style.getFillRef());
                paint = selectPaint(fp, null, pp, theme, hasPlaceholder);
            }
            if (paint != null) {
                setValue(paint);
                return true;
            }
            return false;
        }
    };
    fetchShapeProperty(fetcher);
    return fetcher.getValue();
}
Also used : CTShapeStyle(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeStyle) PaintStyle(org.apache.poi.sl.usermodel.PaintStyle) PropertyFetcher(org.apache.poi.xslf.model.PropertyFetcher) PackagePart(org.apache.poi.openxml4j.opc.PackagePart) XSLFFillProperties(org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties)

Example 8 with PropertyFetcher

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

the class XSLFSimpleShape method getLineCompound.

/**
     * @return the line compound
     */
public LineCompound getLineCompound() {
    PropertyFetcher<Integer> fetcher = new PropertyFetcher<Integer>() {

        @Override
        public boolean fetch(XSLFShape shape) {
            CTLineProperties ln = getLn(shape, false);
            if (ln != null) {
                STCompoundLine.Enum stCmpd = ln.getCmpd();
                if (stCmpd != null) {
                    setValue(stCmpd.intValue());
                    return true;
                }
            }
            return false;
        }
    };
    fetchShapeProperty(fetcher);
    Integer cmpd = fetcher.getValue();
    if (cmpd == null) {
        CTLineProperties defaultLn = getDefaultLineProperties();
        if (defaultLn != null && defaultLn.isSetCmpd()) {
            switch(defaultLn.getCmpd().intValue()) {
                default:
                case STCompoundLine.INT_SNG:
                    return LineCompound.SINGLE;
                case STCompoundLine.INT_DBL:
                    return LineCompound.DOUBLE;
                case STCompoundLine.INT_THICK_THIN:
                    return LineCompound.THICK_THIN;
                case STCompoundLine.INT_THIN_THICK:
                    return LineCompound.THIN_THICK;
                case STCompoundLine.INT_TRI:
                    return LineCompound.TRIPLE;
            }
        }
    }
    return null;
}
Also used : CTLineProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties) PropertyFetcher(org.apache.poi.xslf.model.PropertyFetcher) STCompoundLine(org.openxmlformats.schemas.drawingml.x2006.main.STCompoundLine)

Aggregations

PropertyFetcher (org.apache.poi.xslf.model.PropertyFetcher)8 CTLineProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties)5 CTShapeStyle (org.openxmlformats.schemas.drawingml.x2006.main.CTShapeStyle)3 PackagePart (org.apache.poi.openxml4j.opc.PackagePart)2 DrawPaint (org.apache.poi.sl.draw.DrawPaint)2 PaintStyle (org.apache.poi.sl.usermodel.PaintStyle)2 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)2 XSLFFillProperties (org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties)2 LineCap (org.apache.poi.sl.usermodel.StrokeStyle.LineCap)1 LineDash (org.apache.poi.sl.usermodel.StrokeStyle.LineDash)1 XSLFEffectProperties (org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFEffectProperties)1 XmlObject (org.apache.xmlbeans.XmlObject)1 CTEffectStyleItem (org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleItem)1 CTOuterShadowEffect (org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect)1 CTSchemeColor (org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor)1 CTShapeProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties)1 CTStyleMatrix (org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrix)1 CTStyleMatrixReference (org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrixReference)1 CTTransform2D (org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D)1 STCompoundLine (org.openxmlformats.schemas.drawingml.x2006.main.STCompoundLine)1