Search in sources :

Example 1 with EscherContainerRecord

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

the class HSSFPatriarch method onCreate.

private void onCreate(HSSFShape shape) {
    EscherContainerRecord spgrContainer = _boundAggregate.getEscherContainer().getChildContainers().get(0);
    EscherContainerRecord spContainer = shape.getEscherContainer();
    int shapeId = newShapeId();
    shape.setShapeId(shapeId);
    spgrContainer.addChildRecord(spContainer);
    shape.afterInsert(this);
    setFlipFlags(shape);
}
Also used : EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord)

Example 2 with EscherContainerRecord

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

the class HSSFPicture method createSpContainer.

@Override
protected EscherContainerRecord createSpContainer() {
    EscherContainerRecord spContainer = super.createSpContainer();
    EscherOptRecord opt = spContainer.getChildById(EscherOptRecord.RECORD_ID);
    opt.removeEscherProperty(EscherProperties.LINESTYLE__LINEDASHING);
    opt.removeEscherProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH);
    spContainer.removeChildRecord(spContainer.getChildById(EscherTextboxRecord.RECORD_ID));
    return spContainer;
}
Also used : EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherOptRecord(org.apache.poi.ddf.EscherOptRecord)

Example 3 with EscherContainerRecord

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

the class PPDrawing method create.

/**
	 * Create the Escher records associated with a new PPDrawing
	 */
private void create() {
    EscherContainerRecord dgContainer = new EscherContainerRecord();
    dgContainer.setRecordId(EscherContainerRecord.DG_CONTAINER);
    dgContainer.setOptions((short) 15);
    dg = new EscherDgRecord();
    dg.setOptions((short) 16);
    dg.setNumShapes(1);
    dgContainer.addChildRecord(dg);
    EscherContainerRecord spgrContainer = new EscherContainerRecord();
    spgrContainer.setOptions((short) 15);
    spgrContainer.setRecordId(EscherContainerRecord.SPGR_CONTAINER);
    EscherContainerRecord spContainer = new EscherContainerRecord();
    spContainer.setOptions((short) 15);
    spContainer.setRecordId(EscherContainerRecord.SP_CONTAINER);
    EscherSpgrRecord spgr = new EscherSpgrRecord();
    spgr.setOptions((short) 1);
    spContainer.addChildRecord(spgr);
    EscherSpRecord sp = new EscherSpRecord();
    sp.setOptions((short) ((ShapeType.NOT_PRIMITIVE.nativeId << 4) + 2));
    sp.setFlags(EscherSpRecord.FLAG_PATRIARCH | EscherSpRecord.FLAG_GROUP);
    spContainer.addChildRecord(sp);
    spgrContainer.addChildRecord(spContainer);
    dgContainer.addChildRecord(spgrContainer);
    spContainer = new EscherContainerRecord();
    spContainer.setOptions((short) 15);
    spContainer.setRecordId(EscherContainerRecord.SP_CONTAINER);
    sp = new EscherSpRecord();
    sp.setOptions((short) ((ShapeType.RECT.nativeId << 4) + 2));
    sp.setFlags(EscherSpRecord.FLAG_BACKGROUND | EscherSpRecord.FLAG_HASSHAPETYPE);
    spContainer.addChildRecord(sp);
    EscherOptRecord opt = new EscherOptRecord();
    opt.setRecordId(EscherOptRecord.RECORD_ID);
    opt.addEscherProperty(new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, 134217728));
    opt.addEscherProperty(new EscherRGBProperty(EscherProperties.FILL__FILLBACKCOLOR, 134217733));
    opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.FILL__RECTRIGHT, 10064750));
    opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.FILL__RECTBOTTOM, 7778750));
    opt.addEscherProperty(new EscherBoolProperty(EscherProperties.FILL__NOFILLHITTEST, 1179666));
    opt.addEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 524288));
    opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.SHAPE__BLACKANDWHITESETTINGS, 9));
    opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.SHAPE__BACKGROUNDSHAPE, 65537));
    spContainer.addChildRecord(opt);
    dgContainer.addChildRecord(spContainer);
    childRecords.add(dgContainer);
}
Also used : EscherSpgrRecord(org.apache.poi.ddf.EscherSpgrRecord) EscherBoolProperty(org.apache.poi.ddf.EscherBoolProperty) EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) EscherSpRecord(org.apache.poi.ddf.EscherSpRecord) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherDgRecord(org.apache.poi.ddf.EscherDgRecord) EscherOptRecord(org.apache.poi.ddf.EscherOptRecord) EscherRGBProperty(org.apache.poi.ddf.EscherRGBProperty)

Example 4 with EscherContainerRecord

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

the class ActiveXShape method createSpContainer.

/**
     * Create a new Placeholder and initialize internal structures
     *
     * @return the created <code>EscherContainerRecord</code> which holds shape data
     */
@Override
protected EscherContainerRecord createSpContainer(int idx, boolean isChild) {
    EscherContainerRecord ecr = super.createSpContainer(idx, isChild);
    EscherSpRecord spRecord = ecr.getChildById(EscherSpRecord.RECORD_ID);
    spRecord.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE | EscherSpRecord.FLAG_OLESHAPE);
    setShapeType(ShapeType.HOST_CONTROL);
    setEscherProperty(EscherProperties.BLIP__PICTUREID, idx);
    setEscherProperty(EscherProperties.LINESTYLE__COLOR, 0x8000001);
    setEscherProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x80008);
    setEscherProperty(EscherProperties.SHADOWSTYLE__COLOR, 0x8000002);
    setEscherProperty(EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, -1);
    HSLFEscherClientDataRecord cldata = getClientData(true);
    cldata.addChild(new ExObjRefAtom());
    return ecr;
}
Also used : ExObjRefAtom(org.apache.poi.hslf.record.ExObjRefAtom) HSLFEscherClientDataRecord(org.apache.poi.hslf.record.HSLFEscherClientDataRecord) EscherSpRecord(org.apache.poi.ddf.EscherSpRecord) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord)

Example 5 with EscherContainerRecord

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

the class SlideShowDumper method walkEscherDDF.

/**
   * Use the DDF code to walk the Escher records
   */
public void walkEscherDDF(int indent, int pos, int len) {
    if (len < 8) {
        return;
    }
    final String ind = (indent == 0) ? "%1$s" : "%1$" + indent + "s";
    byte[] contents = new byte[len];
    System.arraycopy(docstream, pos, contents, 0, len);
    DefaultEscherRecordFactory erf = new HSLFEscherRecordFactory();
    EscherRecord record = erf.createRecord(contents, 0);
    // For now, try filling in the fields
    record.fillFields(contents, 0, erf);
    long atomType = LittleEndian.getUShort(contents, 2);
    // This lacks the 8 byte header size
    long atomLen = LittleEndian.getUShort(contents, 4);
    // This (should) include the 8 byte header size
    int recordLen = record.getRecordSize();
    String fmt = ind + "At position %2$d (%2$04x): type is %3$d (%3$04x), len is %4$d (%4$04x) (%5$d) - record claims %6$d";
    out.println(String.format(Locale.ROOT, fmt, "", pos, atomType, atomLen, atomLen + 8, recordLen));
    // Check for corrupt / lying ones
    if (recordLen != 8 && (recordLen != (atomLen + 8))) {
        out.println(String.format(Locale.ROOT, ind + "** Atom length of $2d ($3d) doesn't match record length of %4d", "", atomLen, atomLen + 8, recordLen));
    }
    // Print the record's details
    String recordStr = record.toString().replace("\n", String.format(Locale.ROOT, "\n" + ind, ""));
    out.println(String.format(Locale.ROOT, ind + "%2$s", "", recordStr));
    if (record instanceof EscherContainerRecord) {
        walkEscherDDF((indent + 3), pos + 8, (int) atomLen);
    }
    // Handle records that seem to lie
    if (atomType == 61451L) {
        // Normally claims a size of 8
        recordLen = (int) atomLen + 8;
    }
    if (atomType == 61453L) {
        // Returns EscherContainerRecord, but really msofbtClientTextbox
        recordLen = (int) atomLen + 8;
        record.fillFields(contents, 0, erf);
        if (!(record instanceof EscherTextboxRecord)) {
            out.println(String.format(Locale.ROOT, ind + "%2$s", "", "** Really a msofbtClientTextbox !"));
        }
    }
    // Decide on what to do, based on how the lengths match up
    if (recordLen == 8 && atomLen > 8) {
        // Assume it has children, rather than being corrupted
        walkEscherDDF((indent + 3), pos + 8, (int) atomLen);
        // Wind on our length + our header
        pos += atomLen;
        pos += 8;
        len -= atomLen;
        len -= 8;
    } else {
        // No children, wind on our real length
        pos += atomLen;
        pos += 8;
        len -= atomLen;
        len -= 8;
    }
    // Move on to the next one, if we're not at the end yet
    if (len >= 8) {
        walkEscherDDF(indent, pos, len);
    }
}
Also used : EscherTextboxRecord(org.apache.poi.ddf.EscherTextboxRecord) HSLFEscherRecordFactory(org.apache.poi.hslf.record.HSLFEscherRecordFactory) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) DefaultEscherRecordFactory(org.apache.poi.ddf.DefaultEscherRecordFactory)

Aggregations

EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)53 EscherRecord (org.apache.poi.ddf.EscherRecord)17 EscherSpRecord (org.apache.poi.ddf.EscherSpRecord)17 EscherOptRecord (org.apache.poi.ddf.EscherOptRecord)11 EscherBSERecord (org.apache.poi.ddf.EscherBSERecord)8 EscherSimpleProperty (org.apache.poi.ddf.EscherSimpleProperty)8 AbstractEscherOptRecord (org.apache.poi.ddf.AbstractEscherOptRecord)6 EscherDgRecord (org.apache.poi.ddf.EscherDgRecord)6 DefaultEscherRecordFactory (org.apache.poi.ddf.DefaultEscherRecordFactory)5 ObjRecord (org.apache.poi.hssf.record.ObjRecord)5 EscherDggRecord (org.apache.poi.ddf.EscherDggRecord)4 EscherSpgrRecord (org.apache.poi.ddf.EscherSpgrRecord)4 EscherTextboxRecord (org.apache.poi.ddf.EscherTextboxRecord)4 Document (org.apache.poi.hslf.record.Document)4 PPDrawing (org.apache.poi.hslf.record.PPDrawing)4 LinkedList (java.util.LinkedList)3 EscherBoolProperty (org.apache.poi.ddf.EscherBoolProperty)3 EscherClientDataRecord (org.apache.poi.ddf.EscherClientDataRecord)3 EscherRGBProperty (org.apache.poi.ddf.EscherRGBProperty)3 ExObjRefAtom (org.apache.poi.hslf.record.ExObjRefAtom)3