use of org.apache.poi.hslf.usermodel.HSLFSlideShowImpl 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();
}
use of org.apache.poi.hslf.usermodel.HSLFSlideShowImpl 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();
}
use of org.apache.poi.hslf.usermodel.HSLFSlideShowImpl in project poi by apache.
the class TestPOIDocumentScratchpad method setUp.
/**
* Set things up, using a PowerPoint document and
* a Word Document for our testing
*/
@Before
public void setUp() throws IOException {
doc = new HSLFSlideShowImpl(POIDataSamples.getSlideShowInstance().openResourceAsStream("basic_test_ppt_file.ppt"));
doc2 = HWPFTestDataSamples.openSampleFile("test2.doc");
}
use of org.apache.poi.hslf.usermodel.HSLFSlideShowImpl in project poi by apache.
the class TestEncryptedFile method testLoadNonEncrypted.
@Test
public void testLoadNonEncrypted() throws IOException {
InputStream is = slTests.openResourceAsStream("basic_test_ppt_file.ppt");
HSLFSlideShowImpl hss = new HSLFSlideShowImpl(is);
assertNotNull(hss);
hss.close();
is.close();
}
use of org.apache.poi.hslf.usermodel.HSLFSlideShowImpl in project poi by apache.
the class TestReWrite method assertWritesOutTheSame.
public void assertWritesOutTheSame(HSLFSlideShowImpl hss, POIFSFileSystem pfs) throws Exception {
// Write out to a byte array, and to a temp file
ByteArrayOutputStream baos = new ByteArrayOutputStream();
hss.write(baos);
final File file = TempFile.createTempFile("TestHSLF", ".ppt");
final File file2 = TempFile.createTempFile("TestHSLF", ".ppt");
hss.write(file);
hss.write(file2);
// Build an input stream of it, and read back as a POIFS from the stream
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
POIFSFileSystem npfS = new POIFSFileSystem(bais);
// And the same on the temp file
POIFSFileSystem npfF = new POIFSFileSystem(file);
// And another where we do an in-place write
POIFSFileSystem npfRF = new POIFSFileSystem(file2, false);
HSLFSlideShowImpl hssRF = new HSLFSlideShowImpl(npfRF);
hssRF.write();
hssRF.close();
npfRF = new POIFSFileSystem(file2);
// Check all of them in turn
for (POIFSFileSystem npf : new POIFSFileSystem[] { npfS, npfF, npfRF }) {
// Check that the "PowerPoint Document" sections have the same size
DocumentEntry oProps = (DocumentEntry) pfs.getRoot().getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
DocumentEntry nProps = (DocumentEntry) npf.getRoot().getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
assertEquals(oProps.getSize(), nProps.getSize());
// Check that they contain the same data
byte[] _oData = new byte[oProps.getSize()];
byte[] _nData = new byte[nProps.getSize()];
pfs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_oData);
npf.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT).read(_nData);
for (int i = 0; i < _oData.length; i++) {
//System.out.println(i + "\t" + Integer.toHexString(i));
assertEquals(_oData[i], _nData[i]);
}
npf.close();
}
}
Aggregations