Search in sources :

Example 1 with HemfCommentEMFPlus

use of org.apache.poi.hemf.record.HemfCommentEMFPlus in project poi by apache.

the class HemfPlusExtractorTest method testBasic.

@Test
public void testBasic() throws Exception {
    //test header
    HemfCommentEMFPlus emfPlus = getCommentRecord("SimpleEMF_windows.emf", 0);
    List<HemfPlusRecord> records = emfPlus.getRecords();
    assertEquals(1, records.size());
    assertEquals(HemfPlusRecordType.header, records.get(0).getRecordType());
    HemfPlusHeader header = (HemfPlusHeader) records.get(0);
    assertEquals(240, header.getLogicalDpiX());
    assertEquals(240, header.getLogicalDpiY());
    assertEquals(1, header.getFlags());
    assertEquals(1, header.getEmfPlusFlags());
    //test that the HemfCommentEMFPlus record at offset 1
    //contains 6 HemfCommentEMFPlus records within it
    List<HemfPlusRecordType> expected = new ArrayList<HemfPlusRecordType>();
    expected.add(HemfPlusRecordType.setPixelOffsetMode);
    expected.add(HemfPlusRecordType.setAntiAliasMode);
    expected.add(HemfPlusRecordType.setCompositingQuality);
    expected.add(HemfPlusRecordType.setPageTransform);
    expected.add(HemfPlusRecordType.setInterpolationMode);
    expected.add(HemfPlusRecordType.getDC);
    emfPlus = getCommentRecord("SimpleEMF_windows.emf", 1);
    records = emfPlus.getRecords();
    assertEquals(expected.size(), records.size());
    for (int i = 0; i < expected.size(); i++) {
        assertEquals(expected.get(i), records.get(i).getRecordType());
    }
}
Also used : ArrayList(java.util.ArrayList) HemfPlusRecord(org.apache.poi.hemf.hemfplus.record.HemfPlusRecord) HemfPlusHeader(org.apache.poi.hemf.hemfplus.record.HemfPlusHeader) HemfPlusRecordType(org.apache.poi.hemf.hemfplus.record.HemfPlusRecordType) HemfCommentEMFPlus(org.apache.poi.hemf.record.HemfCommentEMFPlus) Test(org.junit.Test)

Example 2 with HemfCommentEMFPlus

use of org.apache.poi.hemf.record.HemfCommentEMFPlus in project poi by apache.

the class HemfPlusExtractorTest method getCommentRecord.

private HemfCommentEMFPlus getCommentRecord(String testFileName, int recordIndex) throws Exception {
    InputStream is = null;
    HemfCommentEMFPlus returnRecord = null;
    try {
        is = POIDataSamples.getSpreadSheetInstance().openResourceAsStream(testFileName);
        HemfExtractor ex = new HemfExtractor(is);
        int i = 0;
        for (HemfRecord record : ex) {
            if (i == recordIndex) {
                HemfCommentRecord commentRecord = ((HemfCommentRecord) record);
                returnRecord = (HemfCommentEMFPlus) commentRecord.getComment();
                break;
            }
            i++;
        }
    } finally {
        is.close();
    }
    return returnRecord;
}
Also used : InputStream(java.io.InputStream) HemfRecord(org.apache.poi.hemf.record.HemfRecord) HemfCommentRecord(org.apache.poi.hemf.record.HemfCommentRecord) HemfExtractor(org.apache.poi.hemf.extractor.HemfExtractor) HemfCommentEMFPlus(org.apache.poi.hemf.record.HemfCommentEMFPlus)

Aggregations

HemfCommentEMFPlus (org.apache.poi.hemf.record.HemfCommentEMFPlus)2 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 HemfExtractor (org.apache.poi.hemf.extractor.HemfExtractor)1 HemfPlusHeader (org.apache.poi.hemf.hemfplus.record.HemfPlusHeader)1 HemfPlusRecord (org.apache.poi.hemf.hemfplus.record.HemfPlusRecord)1 HemfPlusRecordType (org.apache.poi.hemf.hemfplus.record.HemfPlusRecordType)1 HemfCommentRecord (org.apache.poi.hemf.record.HemfCommentRecord)1 HemfRecord (org.apache.poi.hemf.record.HemfRecord)1 Test (org.junit.Test)1