Search in sources :

Example 1 with Record

use of org.apache.poi.hslf.record.Record in project poi by apache.

the class ActiveXShape method getExControl.

/**
     * Document-level container that specifies information about an ActiveX control
     *
     * @return container that specifies information about an ActiveX control
     */
public ExControl getExControl() {
    int idx = getControlIndex();
    Document doc = getSheet().getSlideShow().getDocumentRecord();
    ExObjList lst = (ExObjList) doc.findFirstOfType(RecordTypes.ExObjList.typeID);
    if (lst == null) {
        return null;
    }
    for (Record ch : lst.getChildRecords()) {
        if (ch instanceof ExControl) {
            ExControl c = (ExControl) ch;
            if (c.getExOleObjAtom().getObjID() == idx) {
                return c;
            }
        }
    }
    return null;
}
Also used : ExObjList(org.apache.poi.hslf.record.ExObjList) ExControl(org.apache.poi.hslf.record.ExControl) HSLFEscherClientDataRecord(org.apache.poi.hslf.record.HSLFEscherClientDataRecord) Record(org.apache.poi.hslf.record.Record) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord) EscherSpRecord(org.apache.poi.ddf.EscherSpRecord) Document(org.apache.poi.hslf.record.Document)

Example 2 with Record

use of org.apache.poi.hslf.record.Record in project poi by apache.

the class SLWTListing method main.

public static void main(String[] args) throws IOException {
    if (args.length < 1) {
        System.err.println("Need to give a filename");
        System.exit(1);
    }
    HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]);
    // Find the documents, and then their SLWT
    Record[] records = ss.getRecords();
    for (int i = 0; i < records.length; i++) {
        if (records[i] instanceof Document) {
            Document doc = (Document) records[i];
            SlideListWithText[] slwts = doc.getSlideListWithTexts();
            System.out.println("Document at " + i + " had " + slwts.length + " SlideListWithTexts");
            if (slwts.length == 0) {
                System.err.println("** Warning: Should have had at least 1! **");
            }
            if (slwts.length > 3) {
                System.err.println("** Warning: Shouldn't have more than 3!");
            }
            // Check the SLWTs contain what we'd expect
            for (int j = 0; j < slwts.length; j++) {
                SlideListWithText slwt = slwts[j];
                Record[] children = slwt.getChildRecords();
                System.out.println(" - SLWT at " + j + " had " + children.length + " children:");
                // Should only have SlideAtomSets if the second one
                int numSAS = slwt.getSlideAtomsSets().length;
                if (j == 1) {
                    if (numSAS == 0) {
                        System.err.println("  ** 2nd SLWT didn't have any SlideAtomSets!");
                    } else {
                        System.out.println("  - Contains " + numSAS + " SlideAtomSets");
                    }
                } else {
                    if (numSAS > 0) {
                        System.err.println("  ** SLWT " + j + " had " + numSAS + " SlideAtomSets! (expected 0)");
                    }
                }
                // Report the first 5 children, to give a flavour
                int upTo = 5;
                if (children.length < 5) {
                    upTo = children.length;
                }
                for (int k = 0; k < upTo; k++) {
                    Record r = children[k];
                    int typeID = (int) r.getRecordType();
                    String typeName = RecordTypes.forTypeID(typeID).name();
                    System.out.println("   - " + typeID + " (" + typeName + ")");
                }
            }
        }
    }
    ss.close();
}
Also used : SlideListWithText(org.apache.poi.hslf.record.SlideListWithText) Record(org.apache.poi.hslf.record.Record) Document(org.apache.poi.hslf.record.Document) HSLFSlideShowImpl(org.apache.poi.hslf.usermodel.HSLFSlideShowImpl)

Example 3 with Record

use of org.apache.poi.hslf.record.Record in project poi by apache.

the class SlideAndNotesAtomListing method main.

public static void main(String[] args) throws IOException {
    if (args.length < 1) {
        System.err.println("Need to give a filename");
        System.exit(1);
    }
    HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]);
    System.out.println("");
    // Find either Slides or Notes
    Record[] records = ss.getRecords();
    for (int i = 0; i < records.length; i++) {
        Record r = records[i];
        // When we find them, print out their IDs
        if (r instanceof Slide) {
            Slide s = (Slide) r;
            SlideAtom sa = s.getSlideAtom();
            System.out.println("Found Slide at " + i);
            System.out.println("  Slide's master ID is " + sa.getMasterID());
            System.out.println("  Slide's notes ID is  " + sa.getNotesID());
            System.out.println("");
        }
        if (r instanceof Notes) {
            Notes n = (Notes) r;
            NotesAtom na = n.getNotesAtom();
            System.out.println("Found Notes at " + i);
            System.out.println("  Notes ID is " + na.getSlideID());
            System.out.println("");
        }
    }
    ss.close();
}
Also used : SlideAtom(org.apache.poi.hslf.record.SlideAtom) Slide(org.apache.poi.hslf.record.Slide) Record(org.apache.poi.hslf.record.Record) HSLFSlideShowImpl(org.apache.poi.hslf.usermodel.HSLFSlideShowImpl) Notes(org.apache.poi.hslf.record.Notes) NotesAtom(org.apache.poi.hslf.record.NotesAtom)

Example 4 with Record

use of org.apache.poi.hslf.record.Record in project poi by apache.

the class OLEShape method setObjectID.

/**
     * Set the unique identifier for the OLE object and
     * register it in the necessary structures
     * 
     * @param objectId the unique identifier for the OLE object
     */
public void setObjectID(int objectId) {
    setEscherProperty(EscherProperties.BLIP__PICTUREID, objectId);
    EscherContainerRecord ecr = getSpContainer();
    EscherSpRecord spRecord = ecr.getChildById(EscherSpRecord.RECORD_ID);
    spRecord.setFlags(spRecord.getFlags() | EscherSpRecord.FLAG_OLESHAPE);
    HSLFEscherClientDataRecord cldata = getClientData(true);
    ExObjRefAtom uer = null;
    for (Record r : cldata.getHSLFChildRecords()) {
        if (r.getRecordType() == RecordTypes.ExObjRefAtom.typeID) {
            uer = (ExObjRefAtom) r;
            break;
        }
    }
    if (uer == null) {
        uer = new ExObjRefAtom();
        cldata.addChild(uer);
    }
    uer.setExObjIdRef(objectId);
}
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) HSLFEscherClientDataRecord(org.apache.poi.hslf.record.HSLFEscherClientDataRecord) Record(org.apache.poi.hslf.record.Record) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherSpRecord(org.apache.poi.ddf.EscherSpRecord)

Example 5 with Record

use of org.apache.poi.hslf.record.Record in project poi by apache.

the class SlideShowRecordDumper method printEscherTextBox.

private void printEscherTextBox(EscherTextboxRecord tbRecord, int indent) {
    String ind = tabs.substring(0, indent);
    ps.println(ind + "EscherTextboxRecord:");
    EscherTextboxWrapper etw = new EscherTextboxWrapper(tbRecord);
    Record prevChild = null;
    for (Record child : etw.getChildRecords()) {
        if (child instanceof StyleTextPropAtom) {
            // need preceding Text[Chars|Bytes]Atom to initialize the data structure
            String text = null;
            if (prevChild instanceof TextCharsAtom) {
                text = ((TextCharsAtom) prevChild).getText();
            } else if (prevChild instanceof TextBytesAtom) {
                text = ((TextBytesAtom) prevChild).getText();
            } else {
                ps.println(ind + "Error! Couldn't find preceding TextAtom for style");
                continue;
            }
            StyleTextPropAtom tsp = (StyleTextPropAtom) child;
            tsp.setParentTextSize(text.length());
        }
        ps.println(ind + child);
        prevChild = child;
    }
}
Also used : EscherTextboxWrapper(org.apache.poi.hslf.record.EscherTextboxWrapper) Record(org.apache.poi.hslf.record.Record) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherTextboxRecord(org.apache.poi.ddf.EscherTextboxRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) TextCharsAtom(org.apache.poi.hslf.record.TextCharsAtom) StyleTextPropAtom(org.apache.poi.hslf.record.StyleTextPropAtom) TextBytesAtom(org.apache.poi.hslf.record.TextBytesAtom)

Aggregations

Record (org.apache.poi.hslf.record.Record)39 PositionDependentRecord (org.apache.poi.hslf.record.PositionDependentRecord)10 HSLFSlideShowImpl (org.apache.poi.hslf.usermodel.HSLFSlideShowImpl)9 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)8 HSLFEscherClientDataRecord (org.apache.poi.hslf.record.HSLFEscherClientDataRecord)8 SlideListWithText (org.apache.poi.hslf.record.SlideListWithText)7 TextBytesAtom (org.apache.poi.hslf.record.TextBytesAtom)7 TextCharsAtom (org.apache.poi.hslf.record.TextCharsAtom)7 UserEditAtom (org.apache.poi.hslf.record.UserEditAtom)7 DrawPaint (org.apache.poi.sl.draw.DrawPaint)7 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)7 PersistPtrHolder (org.apache.poi.hslf.record.PersistPtrHolder)6 TextHeaderAtom (org.apache.poi.hslf.record.TextHeaderAtom)6 ArrayList (java.util.ArrayList)5 EscherSpRecord (org.apache.poi.ddf.EscherSpRecord)5 Document (org.apache.poi.hslf.record.Document)5 StyleTextPropAtom (org.apache.poi.hslf.record.StyleTextPropAtom)5 Test (org.junit.Test)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 Map (java.util.Map)4