Example usage for org.apache.poi.hslf.record InteractiveInfoAtom getAction

List of usage examples for org.apache.poi.hslf.record InteractiveInfoAtom getAction

Introduction

In this page you can find the example usage for org.apache.poi.hslf.record InteractiveInfoAtom getAction.

Prototype

public byte getAction() 

Source Link

Document

Hyperlink Action.

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
 *///  www.  j a  v a2s .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;
}