Search in sources :

Example 6 with XSLFFillProperties

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

the class XSLFTextRun method getFontColor.

@Override
public PaintStyle getFontColor() {
    final boolean hasPlaceholder = getParentParagraph().getParentShape().getPlaceholder() != null;
    CharacterPropertyFetcher<PaintStyle> fetcher = new CharacterPropertyFetcher<PaintStyle>(_p.getIndentLevel()) {

        public boolean fetch(CTTextCharacterProperties props) {
            if (props == null) {
                return false;
            }
            XSLFShape shape = _p.getParentShape();
            CTShapeStyle style = shape.getSpStyle();
            CTSchemeColor phClr = null;
            if (style != null && style.getFontRef() != null) {
                phClr = style.getFontRef().getSchemeClr();
            }
            XSLFFillProperties fp = XSLFPropertiesDelegate.getFillDelegate(props);
            XSLFSheet sheet = shape.getSheet();
            PackagePart pp = sheet.getPackagePart();
            XSLFTheme theme = sheet.getTheme();
            PaintStyle ps = XSLFShape.selectPaint(fp, phClr, pp, theme, hasPlaceholder);
            if (ps != null) {
                setValue(ps);
                return true;
            }
            return false;
        }
    };
    fetchCharacterProperty(fetcher);
    return fetcher.getValue();
}
Also used : CTShapeStyle(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeStyle) CharacterPropertyFetcher(org.apache.poi.xslf.model.CharacterPropertyFetcher) CTTextCharacterProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties) CTSchemeColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor) PaintStyle(org.apache.poi.sl.usermodel.PaintStyle) PackagePart(org.apache.poi.openxml4j.opc.PackagePart) XSLFFillProperties(org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties)

Example 7 with XSLFFillProperties

use of org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties 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)

Aggregations

XSLFFillProperties (org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties)7 PaintStyle (org.apache.poi.sl.usermodel.PaintStyle)5 CTSchemeColor (org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor)4 PackagePart (org.apache.poi.openxml4j.opc.PackagePart)3 CTShapeStyle (org.openxmlformats.schemas.drawingml.x2006.main.CTShapeStyle)3 DrawPaint (org.apache.poi.sl.draw.DrawPaint)2 PropertyFetcher (org.apache.poi.xslf.model.PropertyFetcher)2 XmlObject (org.apache.xmlbeans.XmlObject)2 Color (java.awt.Color)1 GradientPaint (org.apache.poi.sl.usermodel.PaintStyle.GradientPaint)1 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)1 TexturePaint (org.apache.poi.sl.usermodel.PaintStyle.TexturePaint)1 LineCap (org.apache.poi.sl.usermodel.StrokeStyle.LineCap)1 LineDash (org.apache.poi.sl.usermodel.StrokeStyle.LineDash)1 CharacterPropertyFetcher (org.apache.poi.xslf.model.CharacterPropertyFetcher)1 XmlCursor (org.apache.xmlbeans.XmlCursor)1 CTBlip (org.openxmlformats.schemas.drawingml.x2006.main.CTBlip)1 CTLineProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties)1 CTSolidColorFillProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties)1 CTStyleMatrix (org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrix)1