Example usage for org.apache.poi.ddf EscherRecord serialize

List of usage examples for org.apache.poi.ddf EscherRecord serialize

Introduction

In this page you can find the example usage for org.apache.poi.ddf EscherRecord serialize.

Prototype

public byte[] serialize() 

Source Link

Document

Serializes to a new byte array.

Usage

From source file:poi.hslf.examples.SoundFinder.java

License:Apache License

/**
 * Check if a given shape is associated with a sound.
 * @return 0-based reference to a sound in the sound collection
 * or -1 if the shape is not associated with a sound
 *//*w ww . j  av  a2  s  .  c  o  m*/
protected static int getSoundReference(Shape shape) {
    int soundRef = -1;
    //dive into the shape container and search for InteractiveInfoAtom
    EscherContainerRecord spContainer = shape.getSpContainer();
    List spchild = spContainer.getChildRecords();
    for (Iterator it = spchild.iterator(); it.hasNext();) {
        EscherRecord obj = (EscherRecord) it.next();
        if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID) {
            byte[] data = obj.serialize();
            Record[] records = Record.findChildRecords(data, 8, data.length - 8);
            for (int j = 0; j < records.length; j++) {
                if (records[j] instanceof InteractiveInfo) {
                    InteractiveInfoAtom info = ((InteractiveInfo) records[j]).getInteractiveInfoAtom();
                    if (info.getAction() == InteractiveInfoAtom.ACTION_MEDIA) {
                        soundRef = info.getSoundRef();
                    }
                }
            }
        }
    }
    return soundRef;
}