Search in sources :

Example 1 with CTOuterShadowEffect

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

the class TestXSLFBugs method bug60662.

@Test
public void bug60662() throws IOException {
    XMLSlideShow src = new XMLSlideShow();
    XSLFSlide sl = src.createSlide();
    XSLFGroupShape gs = sl.createGroup();
    gs.setAnchor(new Rectangle2D.Double(100, 100, 100, 100));
    gs.setInteriorAnchor(new Rectangle2D.Double(0, 0, 100, 100));
    XSLFAutoShape as = gs.createAutoShape();
    as.setAnchor(new Rectangle2D.Double(0, 0, 100, 100));
    as.setShapeType(ShapeType.STAR_24);
    as.setFillColor(Color.YELLOW);
    CTShape csh = (CTShape) as.getXmlObject();
    CTOuterShadowEffect shadow = csh.getSpPr().addNewEffectLst().addNewOuterShdw();
    shadow.setDir(270000);
    shadow.setDist(100000);
    shadow.addNewSrgbClr().setVal(new byte[] { 0x00, (byte) 0xFF, 0x00 });
    XMLSlideShow dst = new XMLSlideShow();
    XSLFSlide sl2 = dst.createSlide();
    sl2.importContent(sl);
    XSLFGroupShape gs2 = (XSLFGroupShape) sl2.getShapes().get(0);
    XSLFAutoShape as2 = (XSLFAutoShape) gs2.getShapes().get(0);
    CTShape csh2 = (CTShape) as2.getXmlObject();
    assertTrue(csh2.getSpPr().isSetEffectLst());
    dst.close();
    src.close();
}
Also used : Rectangle2D(java.awt.geom.Rectangle2D) CTShape(org.openxmlformats.schemas.presentationml.x2006.main.CTShape) CTOuterShadowEffect(org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect) Test(org.junit.Test)

Example 2 with CTOuterShadowEffect

use of org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect 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)

Example 3 with CTOuterShadowEffect

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

the class TestXSLFSimpleShape method testShadowEffects.

@SuppressWarnings("unused")
@Test
public void testShadowEffects() throws IOException {
    XMLSlideShow ppt = new XMLSlideShow();
    XSLFSlide slide = ppt.createSlide();
    CTStyleMatrix styleMatrix = slide.getTheme().getXmlObject().getThemeElements().getFmtScheme();
    CTEffectStyleList lst = styleMatrix.getEffectStyleLst();
    assertNotNull(lst);
    for (CTEffectStyleItem ef : lst.getEffectStyleArray()) {
        CTOuterShadowEffect obj = ef.getEffectLst().getOuterShdw();
    }
    ppt.close();
}
Also used : CTStyleMatrix(org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrix) CTEffectStyleList(org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleList) CTEffectStyleItem(org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleItem) CTOuterShadowEffect(org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect) Test(org.junit.Test)

Example 4 with CTOuterShadowEffect

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

the class XSLFShadow method getFillStyle.

@Override
public SolidPaint getFillStyle() {
    XSLFTheme theme = getSheet().getTheme();
    CTOuterShadowEffect ct = (CTOuterShadowEffect) getXmlObject();
    if (ct == null)
        return null;
    CTSchemeColor phClr = ct.getSchemeClr();
    final XSLFColor xc = new XSLFColor(ct, theme, phClr);
    return DrawPaint.createSolidPaint(xc.getColorStyle());
}
Also used : CTSchemeColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor) CTOuterShadowEffect(org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect)

Aggregations

CTOuterShadowEffect (org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect)4 Test (org.junit.Test)2 CTEffectStyleItem (org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleItem)2 CTStyleMatrix (org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrix)2 Rectangle2D (java.awt.geom.Rectangle2D)1 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 CTEffectStyleList (org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleList)1 CTSchemeColor (org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor)1 CTShapeStyle (org.openxmlformats.schemas.drawingml.x2006.main.CTShapeStyle)1 CTShape (org.openxmlformats.schemas.presentationml.x2006.main.CTShape)1