use of org.apache.poi.POIDataSamples in project poi by apache.
the class TestSlides method testAddSlides2to3.
/**
* Add slides to ppt which already has two slides
*/
@Test
public void testAddSlides2to3() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
HSLFSlideShow ppt = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
assertEquals(2, ppt.getSlides().size());
// First slide is 256 / 4
HSLFSlide s1 = ppt.getSlides().get(0);
assertEquals(256, s1._getSheetNumber());
assertEquals(4, s1._getSheetRefId());
// Last slide is 257 / 6
HSLFSlide s2 = ppt.getSlides().get(1);
assertEquals(257, s2._getSheetNumber());
assertEquals(6, s2._getSheetRefId());
// Add another slide, goes in at the end
HSLFSlide s3 = ppt.createSlide();
assertEquals(3, ppt.getSlides().size());
assertEquals(258, s3._getSheetNumber());
assertEquals(8, s3._getSheetRefId());
// Serialize and read again
ByteArrayOutputStream out = new ByteArrayOutputStream();
ppt.write(out);
out.close();
ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
assertEquals(3, ppt.getSlides().size());
// Check IDs are still right
s1 = ppt.getSlides().get(0);
assertEquals(256, s1._getSheetNumber());
assertEquals(4, s1._getSheetRefId());
s2 = ppt.getSlides().get(1);
assertEquals(257, s2._getSheetNumber());
assertEquals(6, s2._getSheetRefId());
s3 = ppt.getSlides().get(2);
assertEquals(3, ppt.getSlides().size());
assertEquals(258, s3._getSheetNumber());
assertEquals(8, s3._getSheetRefId());
}
use of org.apache.poi.POIDataSamples in project poi by apache.
the class TestReOrderingSlides method setUp.
/**
* Create/open the slideshows
*/
@Before
public void setUp() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
hss_one = new HSLFSlideShowImpl(slTests.openResourceAsStream("Single_Coloured_Page.ppt"));
ss_one = new HSLFSlideShow(hss_one);
hss_two = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
ss_two = new HSLFSlideShow(hss_two);
hss_three = new HSLFSlideShowImpl(slTests.openResourceAsStream("incorrect_slide_order.ppt"));
ss_three = new HSLFSlideShow(hss_three);
}
use of org.apache.poi.POIDataSamples in project poi by apache.
the class TestRecordSetup method init.
@Before
public void init() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
ss = new HSLFSlideShow(hss);
}
use of org.apache.poi.POIDataSamples in project poi by apache.
the class TestFileWithAttachmentsRead method setUp.
/**
* Initialize this test, load up the attachment_test_msg.msg mapi message.
*
* @throws Exception
*/
@BeforeClass
public static void setUp() throws IOException {
POIDataSamples samples = POIDataSamples.getHSMFInstance();
twoSimpleAttachments = new MAPIMessage(samples.openResourceAsStream("attachment_test_msg.msg"));
pdfMsgAttachments = new MAPIMessage(samples.openResourceAsStream("attachment_msg_pdf.msg"));
inlineImgMsgAttachments = new MAPIMessage(samples.openResourceAsStream("attachment_msg_inlineImg.msg"));
}
use of org.apache.poi.POIDataSamples in project poi by apache.
the class TestSound method testRealFile.
@Test
public void testRealFile() throws IOException {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
HSLFSlideShow ppt = new HSLFSlideShow(slTests.openResourceAsStream("sound.ppt"));
// Get the document
Document doc = ppt.getDocumentRecord();
SoundCollection soundCollection = null;
Record[] doc_ch = doc.getChildRecords();
for (Record rec : doc_ch) {
if (rec instanceof SoundCollection) {
soundCollection = (SoundCollection) rec;
break;
}
}
assertNotNull(soundCollection);
Sound sound = null;
Record[] sound_ch = soundCollection.getChildRecords();
int k = 0;
for (Record rec : sound_ch) {
if (rec instanceof Sound) {
sound = (Sound) rec;
k++;
}
}
assertNotNull(sound);
assertEquals(1, k);
assertEquals("ringin.wav", sound.getSoundName());
assertEquals(".WAV", sound.getSoundType());
assertNotNull(sound.getSoundData());
byte[] ref_data = slTests.readFile("ringin.wav");
assertArrayEquals(ref_data, sound.getSoundData());
ppt.close();
}
Aggregations