private EmfCommentDataPlus getCommentRecord(String testFileName, int recordIndex) throws Exception {
- EmfCommentDataPlus returnRecord = null;
-
try (InputStream is = POIDataSamples.getSpreadSheetInstance().openResourceAsStream(testFileName)) {
HemfPicture ex = new HemfPicture(is);
int i = 0;
for (HemfRecord record : ex) {
- if (i == recordIndex) {
- EmfComment commentRecord = ((EmfComment) record);
- returnRecord = (EmfCommentDataPlus) commentRecord.getCommentData();
- break;
+ if (record instanceof EmfComment && i++ == recordIndex) {
+ EmfComment commentRecord = (EmfComment)record;
+ return (EmfCommentDataPlus) commentRecord.getCommentData();
}
- i++;
}
}
- return returnRecord;
+ return null;
}
}
assertEquals(27864, header.getBytes());
assertEquals(31, header.getRecords());
assertEquals(3, header.getHandles());
- assertEquals(346000, header.getMicroDimension().getWidth());
- assertEquals(194000, header.getMicroDimension().getHeight());
+ assertEquals(346000, header.getMicroDimension().getWidth(), 0);
+ assertEquals(194000, header.getMicroDimension().getHeight(), 0);
List<HemfRecord> records = pic.getRecords();