Search in sources :

Example 1 with EscherProperty

use of org.apache.poi.ddf.EscherProperty in project poi by apache.

the class HSLFSimpleShape method getShadow.

@Override
public Shadow<HSLFShape, HSLFTextParagraph> getShadow() {
    AbstractEscherOptRecord opt = getEscherOptRecord();
    if (opt == null) {
        return null;
    }
    EscherProperty shadowType = opt.lookup(EscherProperties.SHADOWSTYLE__TYPE);
    if (shadowType == null) {
        return null;
    }
    return new Shadow<HSLFShape, HSLFTextParagraph>() {

        @Override
        public SimpleShape<HSLFShape, HSLFTextParagraph> getShadowParent() {
            return HSLFSimpleShape.this;
        }

        @Override
        public double getDistance() {
            return getShadowDistance();
        }

        @Override
        public double getAngle() {
            return getShadowAngle();
        }

        @Override
        public double getBlur() {
            // TODO Auto-generated method stub
            return 0;
        }

        @Override
        public SolidPaint getFillStyle() {
            return DrawPaint.createSolidPaint(getShadowColor());
        }
    };
}
Also used : Shadow(org.apache.poi.sl.usermodel.Shadow) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord) EscherProperty(org.apache.poi.ddf.EscherProperty)

Example 2 with EscherProperty

use of org.apache.poi.ddf.EscherProperty in project poi by apache.

the class HSLFShapeFactory method createNonPrimitive.

private static HSLFShape createNonPrimitive(EscherContainerRecord spContainer, ShapeContainer<HSLFShape, HSLFTextParagraph> parent) {
    AbstractEscherOptRecord opt = HSLFShape.getEscherChild(spContainer, EscherOptRecord.RECORD_ID);
    EscherProperty prop = HSLFShape.getEscherProperty(opt, EscherProperties.GEOMETRY__VERTICES);
    if (prop != null) {
        return new HSLFFreeformShape(spContainer, parent);
    }
    logger.log(POILogger.INFO, "Creating AutoShape for a NotPrimitive shape");
    return new HSLFAutoShape(spContainer, parent);
}
Also used : AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord) EscherProperty(org.apache.poi.ddf.EscherProperty)

Example 3 with EscherProperty

use of org.apache.poi.ddf.EscherProperty in project poi by apache.

the class HSLFShapeFactory method createShapeGroup.

public static HSLFGroupShape createShapeGroup(EscherContainerRecord spContainer, ShapeContainer<HSLFShape, HSLFTextParagraph> parent) {
    boolean isTable = false;
    EscherContainerRecord ecr = (EscherContainerRecord) spContainer.getChild(0);
    EscherRecord opt = HSLFShape.getEscherChild(ecr, RecordTypes.EscherUserDefined);
    if (opt != null) {
        EscherPropertyFactory f = new EscherPropertyFactory();
        List<EscherProperty> props = f.createProperties(opt.serialize(), 8, opt.getInstance());
        for (EscherProperty ep : props) {
            if (ep.getPropertyNumber() == EscherProperties.GROUPSHAPE__TABLEPROPERTIES && ep instanceof EscherSimpleProperty && (((EscherSimpleProperty) ep).getPropertyValue() & 1) == 1) {
                isTable = true;
                break;
            }
        }
    }
    HSLFGroupShape group;
    if (isTable) {
        group = new HSLFTable(spContainer, parent);
    } else {
        group = new HSLFGroupShape(spContainer, parent);
    }
    return group;
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) EscherPropertyFactory(org.apache.poi.ddf.EscherPropertyFactory) EscherProperty(org.apache.poi.ddf.EscherProperty)

Example 4 with EscherProperty

use of org.apache.poi.ddf.EscherProperty in project poi by apache.

the class HSLFShape method setEscherProperty.

/**
     * Set an escher property for this shape.
     *
     * @param opt       The opt record to set the properties to.
     * @param propId    The id of the property. One of the constants defined in EscherOptRecord.
     * @param value     value of the property. If value = -1 then the property is removed.
     */
public static void setEscherProperty(AbstractEscherOptRecord opt, short propId, int value) {
    java.util.List<EscherProperty> props = opt.getEscherProperties();
    for (Iterator<EscherProperty> iterator = props.iterator(); iterator.hasNext(); ) {
        if (iterator.next().getPropertyNumber() == propId) {
            iterator.remove();
            break;
        }
    }
    if (value != -1) {
        opt.addEscherProperty(new EscherSimpleProperty(propId, value));
        opt.sortProperties();
    }
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) EscherProperty(org.apache.poi.ddf.EscherProperty)

Example 5 with EscherProperty

use of org.apache.poi.ddf.EscherProperty in project poi by apache.

the class HSSFShape method getShapeName.

/**
     * @return the name of this shape
     */
public String getShapeName() {
    EscherOptRecord eor = getOptRecord();
    if (eor == null) {
        return null;
    }
    EscherProperty ep = eor.lookup(EscherProperties.GROUPSHAPE__SHAPENAME);
    if (ep instanceof EscherComplexProperty) {
        return StringUtil.getFromUnicodeLE(((EscherComplexProperty) ep).getComplexData());
    }
    return null;
}
Also used : EscherComplexProperty(org.apache.poi.ddf.EscherComplexProperty) EscherOptRecord(org.apache.poi.ddf.EscherOptRecord) EscherProperty(org.apache.poi.ddf.EscherProperty)

Aggregations

EscherProperty (org.apache.poi.ddf.EscherProperty)7 EscherOptRecord (org.apache.poi.ddf.EscherOptRecord)3 AbstractEscherOptRecord (org.apache.poi.ddf.AbstractEscherOptRecord)2 EscherComplexProperty (org.apache.poi.ddf.EscherComplexProperty)2 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)2 EscherRecord (org.apache.poi.ddf.EscherRecord)2 EscherSimpleProperty (org.apache.poi.ddf.EscherSimpleProperty)2 Map (java.util.Map)1 EscherClientDataRecord (org.apache.poi.ddf.EscherClientDataRecord)1 EscherPropertyFactory (org.apache.poi.ddf.EscherPropertyFactory)1 CommonObjectDataSubRecord (org.apache.poi.hssf.record.CommonObjectDataSubRecord)1 ObjRecord (org.apache.poi.hssf.record.ObjRecord)1 TextObjectRecord (org.apache.poi.hssf.record.TextObjectRecord)1 Shadow (org.apache.poi.sl.usermodel.Shadow)1 RecordFormatException (org.apache.poi.util.RecordFormatException)1