use of org.apache.poi.hemf.record.HemfHeader in project poi by apache.
the class HemfExtractorTest method testBasicMac.
@Test
public void testBasicMac() throws Exception {
InputStream is = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("SimpleEMF_mac.emf");
HemfExtractor ex = new HemfExtractor(is);
HemfHeader header = ex.getHeader();
int records = 0;
boolean extractedData = false;
for (HemfRecord record : ex) {
if (record.getRecordType() == HemfRecordType.comment) {
AbstractHemfComment comment = ((HemfCommentRecord) record).getComment();
if (comment instanceof HemfCommentPublic.MultiFormats) {
for (HemfCommentPublic.HemfMultiFormatsData d : ((HemfCommentPublic.MultiFormats) comment).getData()) {
byte[] data = d.getData();
//make sure header starts at 0
assertEquals('%', data[0]);
assertEquals('P', data[1]);
assertEquals('D', data[2]);
assertEquals('F', data[3]);
//make sure byte array ends at EOF\n
assertEquals('E', data[data.length - 4]);
assertEquals('O', data[data.length - 3]);
assertEquals('F', data[data.length - 2]);
assertEquals('\n', data[data.length - 1]);
extractedData = true;
}
}
}
records++;
}
assertTrue(extractedData);
assertEquals(header.getRecords() - 1, records);
}
use of org.apache.poi.hemf.record.HemfHeader in project poi by apache.
the class HemfExtractorTest method testBasicWindows.
@Test
public void testBasicWindows() throws Exception {
InputStream is = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("SimpleEMF_windows.emf");
HemfExtractor ex = new HemfExtractor(is);
HemfHeader header = ex.getHeader();
assertEquals(27864, header.getBytes());
assertEquals(31, header.getRecords());
assertEquals(3, header.getHandles());
assertEquals(346000, header.getMicrometersX());
assertEquals(194000, header.getMicrometersY());
int records = 0;
for (HemfRecord record : ex) {
records++;
}
assertEquals(header.getRecords() - 1, records);
}
Aggregations