Search in sources :

Example 1 with Document

use of org.apache.poi.hslf.record.Document 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 Document

use of org.apache.poi.hslf.record.Document 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 Document

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

the class TestBugs method bug56260.

@Test
public void bug56260() throws IOException {
    HSLFSlideShow ppt = open("56260.ppt");
    List<HSLFSlide> _slides = ppt.getSlides();
    assertEquals(13, _slides.size());
    // Check the number of TextHeaderAtoms on Slide 1
    Document dr = ppt.getDocumentRecord();
    SlideListWithText slidesSLWT = dr.getSlideSlideListWithText();
    SlideAtomsSet s1 = slidesSLWT.getSlideAtomsSets()[0];
    int tha = 0;
    for (Record r : s1.getSlideRecords()) {
        if (r instanceof TextHeaderAtom) {
            tha++;
        }
    }
    assertEquals(2, tha);
    // Check to see that we have a pair next to each other
    assertEquals(TextHeaderAtom.class, s1.getSlideRecords()[0].getClass());
    assertEquals(TextHeaderAtom.class, s1.getSlideRecords()[1].getClass());
    // Check the number of text runs based on the slide (not textbox)
    // Will have skipped the empty one
    int str = 0;
    for (List<HSLFTextParagraph> tr : _slides.get(0).getTextParagraphs()) {
        if (!tr.get(0).isDrawingBased()) {
            str++;
        }
    }
    assertEquals(2, str);
    ppt.close();
}
Also used : SlideListWithText(org.apache.poi.hslf.record.SlideListWithText) SlideAtomsSet(org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord) Record(org.apache.poi.hslf.record.Record) Document(org.apache.poi.hslf.record.Document) TextHeaderAtom(org.apache.poi.hslf.record.TextHeaderAtom) DrawPaint(org.apache.poi.sl.draw.DrawPaint) SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) Test(org.junit.Test)

Example 4 with Document

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

the class HSLFPictureShape method getEscherBSERecord.

@SuppressWarnings("resource")
protected EscherBSERecord getEscherBSERecord() {
    HSLFSlideShow ppt = getSheet().getSlideShow();
    Document doc = ppt.getDocumentRecord();
    EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
    EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
    if (bstore == null) {
        LOG.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found ");
        return null;
    }
    List<EscherRecord> lst = bstore.getChildRecords();
    int idx = getPictureIndex();
    if (idx == 0) {
        LOG.log(POILogger.DEBUG, "picture index was not found, returning ");
        return null;
    }
    return (EscherBSERecord) lst.get(idx - 1);
}
Also used : EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) Document(org.apache.poi.hslf.record.Document) EscherBSERecord(org.apache.poi.ddf.EscherBSERecord)

Example 5 with Document

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

the class HSLFFill method getPictureData.

/**
     * <code>PictureData</code> object used in a texture, pattern of picture fill.
     */
@SuppressWarnings("resource")
public HSLFPictureData getPictureData() {
    AbstractEscherOptRecord opt = shape.getEscherOptRecord();
    EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
    if (p == null) {
        return null;
    }
    HSLFSlideShow ppt = shape.getSheet().getSlideShow();
    List<HSLFPictureData> pict = ppt.getPictureData();
    Document doc = ppt.getDocumentRecord();
    EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
    EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
    java.util.List<EscherRecord> lst = bstore.getChildRecords();
    int idx = p.getPropertyValue();
    if (idx == 0) {
        LOG.log(POILogger.WARN, "no reference to picture data found ");
    } else {
        EscherBSERecord bse = (EscherBSERecord) lst.get(idx - 1);
        for (HSLFPictureData pd : pict) {
            if (pd.getOffset() == bse.getOffset()) {
                return pd;
            }
        }
    }
    return null;
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) Document(org.apache.poi.hslf.record.Document) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord) DrawPaint(org.apache.poi.sl.draw.DrawPaint) GradientPaint(org.apache.poi.sl.usermodel.PaintStyle.GradientPaint) TexturePaint(org.apache.poi.sl.usermodel.PaintStyle.TexturePaint) EscherBSERecord(org.apache.poi.ddf.EscherBSERecord)

Aggregations

Document (org.apache.poi.hslf.record.Document)10 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)5 Record (org.apache.poi.hslf.record.Record)5 AbstractEscherOptRecord (org.apache.poi.ddf.AbstractEscherOptRecord)4 EscherBSERecord (org.apache.poi.ddf.EscherBSERecord)4 EscherRecord (org.apache.poi.ddf.EscherRecord)4 SlideListWithText (org.apache.poi.hslf.record.SlideListWithText)4 HSLFSlideShowImpl (org.apache.poi.hslf.usermodel.HSLFSlideShowImpl)3 EscherSimpleProperty (org.apache.poi.ddf.EscherSimpleProperty)2 SlidePersistAtom (org.apache.poi.hslf.record.SlidePersistAtom)2 HSLFSlideShow (org.apache.poi.hslf.usermodel.HSLFSlideShow)2 DrawPaint (org.apache.poi.sl.draw.DrawPaint)2 Test (org.junit.Test)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 EscherSpRecord (org.apache.poi.ddf.EscherSpRecord)1 ExControl (org.apache.poi.hslf.record.ExControl)1 ExObjList (org.apache.poi.hslf.record.ExObjList)1 HSLFEscherClientDataRecord (org.apache.poi.hslf.record.HSLFEscherClientDataRecord)1 Notes (org.apache.poi.hslf.record.Notes)1 NotesAtom (org.apache.poi.hslf.record.NotesAtom)1