Search in sources :

Example 1 with XSLFEffectProperties

use of org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFEffectProperties in project poi by apache.

the class XSLFSimpleShape method getShadow.

/**
     * @return shadow of this shape or null if shadow is disabled
     */
@Override
public XSLFShadow getShadow() {
    PropertyFetcher<CTOuterShadowEffect> fetcher = new PropertyFetcher<CTOuterShadowEffect>() {

        @Override
        public boolean fetch(XSLFShape shape) {
            XSLFEffectProperties ep = XSLFPropertiesDelegate.getEffectDelegate(shape.getShapeProperties());
            if (ep != null && ep.isSetEffectLst()) {
                CTOuterShadowEffect obj = ep.getEffectLst().getOuterShdw();
                setValue(obj == null ? NO_SHADOW : obj);
                return true;
            }
            return false;
        }
    };
    fetchShapeProperty(fetcher);
    CTOuterShadowEffect obj = fetcher.getValue();
    if (obj == null) {
        // fill color was not found, check if it is defined in the theme
        CTShapeStyle style = getSpStyle();
        if (style != null && style.getEffectRef() != null) {
            // 1-based index of a shadow style within the style matrix
            int idx = (int) style.getEffectRef().getIdx();
            if (idx != 0) {
                CTStyleMatrix styleMatrix = getSheet().getTheme().getXmlObject().getThemeElements().getFmtScheme();
                CTEffectStyleItem ef = styleMatrix.getEffectStyleLst().getEffectStyleArray(idx - 1);
                obj = ef.getEffectLst().getOuterShdw();
            }
        }
    }
    return (obj == null || obj == NO_SHADOW) ? null : new XSLFShadow(obj, this);
}
Also used : CTStyleMatrix(org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrix) CTShapeStyle(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeStyle) XSLFEffectProperties(org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFEffectProperties) PropertyFetcher(org.apache.poi.xslf.model.PropertyFetcher) CTEffectStyleItem(org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleItem) CTOuterShadowEffect(org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect) DrawPaint(org.apache.poi.sl.draw.DrawPaint) SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)

Aggregations

DrawPaint (org.apache.poi.sl.draw.DrawPaint)1 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)1 PropertyFetcher (org.apache.poi.xslf.model.PropertyFetcher)1 XSLFEffectProperties (org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFEffectProperties)1 CTEffectStyleItem (org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleItem)1 CTOuterShadowEffect (org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect)1 CTShapeStyle (org.openxmlformats.schemas.drawingml.x2006.main.CTShapeStyle)1 CTStyleMatrix (org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrix)1