dsi.setParCount(P_PAR_COUNT);
dsi.setPresentationFormat(P_PRESENTATION_FORMAT);
dsi.setScale(P_SCALE);
dsi.setSlideCount(P_SLIDE_COUNT);
CustomProperties customProperties = dsi.getCustomProperties();
if (customProperties == null)
customProperties = new CustomProperties();
customProperties.put("Schl�ssel �", "Wert �");
customProperties.put("Schl�ssel ��", "Wert ��");
customProperties.put("Schl�ssel ���", "Wert ���");
customProperties.put("Schl�ssel ����", "Wert ����");
customProperties.put("positive_Integer", POSITIVE_INTEGER);
customProperties.put("positive_Long", POSITIVE_LONG);
customProperties.put("positive_Double", POSITIVE_DOUBLE);
customProperties.put("negative_Integer", NEGATIVE_INTEGER);
customProperties.put("negative_Long", NEGATIVE_LONG);
customProperties.put("negative_Double", NEGATIVE_DOUBLE);
customProperties.put("Boolean", new Boolean(true));
customProperties.put("Date", now);
customProperties.put("max_Integer", MAX_INTEGER);
customProperties.put("min_Integer", MIN_INTEGER);
customProperties.put("max_Long", MAX_LONG);
customProperties.put("min_Long", MIN_LONG);
customProperties.put("max_Double", MAX_DOUBLE);
customProperties.put("min_Double", MIN_DOUBLE);
dsi.setCustomProperties(customProperties);
/* Write the summary information stream and the document summary
* information stream to the POI filesystem. */
si.write(dir, siEntry.getName());
dsi.write(dir, dsiEntry.getName());
/* Write the POI filesystem to a (temporary) file <em>doc2</em>
* and close the latter. */
final File doc2 = File.createTempFile("POI_HPSF_Test.", ".tmp");
doc2.deleteOnExit();
OutputStream out = new FileOutputStream(doc2);
poifs.writeFilesystem(out);
out.close();
/*
* Open <em>doc2</em> for reading and check summary information and
* document summary information. All properties written before must be
* found in the property streams of <em>doc2</em> and have the correct
* values.
*/
poifs = new POIFSFileSystem(new FileInputStream(doc2));
dir = poifs.getRoot();
siEntry = (DocumentEntry) dir.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
dsiEntry = (DocumentEntry) dir.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
dis = new DocumentInputStream(siEntry);
ps = new PropertySet(dis);
si = new SummaryInformation(ps);
dis = new DocumentInputStream(dsiEntry);
ps = new PropertySet(dis);
dsi = new DocumentSummaryInformation(ps);
assertEquals(P_APPLICATION_NAME, si.getApplicationName());
assertEquals(P_AUTHOR, si.getAuthor());
assertEquals(P_CHAR_COUNT, si.getCharCount());
assertEquals(P_COMMENTS, si.getComments());
assertEquals(P_CREATE_DATE_TIME, si.getCreateDateTime());
assertEquals(P_EDIT_TIME, si.getEditTime());
assertEquals(P_KEYWORDS, si.getKeywords());
assertEquals(P_LAST_AUTHOR, si.getLastAuthor());
assertEquals(P_LAST_PRINTED, si.getLastPrinted());
assertEquals(P_LAST_SAVE_DATE_TIME, si.getLastSaveDateTime());
assertEquals(P_PAGE_COUNT, si.getPageCount());
assertEquals(P_REV_NUMBER, si.getRevNumber());
assertEquals(P_SECURITY, si.getSecurity());
assertEquals(P_SUBJECT, si.getSubject());
assertEquals(P_TEMPLATE, si.getTemplate());
// FIXME (byte array properties not yet implemented): assertEquals(P_THUMBNAIL, si.getThumbnail());
assertEquals(P_TITLE, si.getTitle());
assertEquals(P_WORD_COUNT, si.getWordCount());
assertEquals(P_BYTE_COUNT, dsi.getByteCount());
assertEquals(P_CATEGORY, dsi.getCategory());
assertEquals(P_COMPANY, dsi.getCompany());
// FIXME (byte array properties not yet implemented): assertEquals(P_, dsi.getDocparts());
// FIXME (byte array properties not yet implemented): assertEquals(P_, dsi.getHeadingPair());
assertEquals(P_HIDDEN_COUNT, dsi.getHiddenCount());
assertEquals(P_LINE_COUNT, dsi.getLineCount());
assertEquals(P_LINKS_DIRTY, dsi.getLinksDirty());
assertEquals(P_MANAGER, dsi.getManager());
assertEquals(P_MM_CLIP_COUNT, dsi.getMMClipCount());
assertEquals(P_NOTE_COUNT, dsi.getNoteCount());
assertEquals(P_PAR_COUNT, dsi.getParCount());
assertEquals(P_PRESENTATION_FORMAT, dsi.getPresentationFormat());
assertEquals(P_SCALE, dsi.getScale());
assertEquals(P_SLIDE_COUNT, dsi.getSlideCount());
final CustomProperties cps = dsi.getCustomProperties();
assertEquals(customProperties, cps);
assertNull(cps.get("No value available"));
assertEquals("Wert �", cps.get("Schl�ssel �"));
assertEquals("Wert ��", cps.get("Schl�ssel ��"));
assertEquals("Wert ���", cps.get("Schl�ssel ���"));
assertEquals("Wert ����", cps.get("Schl�ssel ����"));
assertEquals(POSITIVE_INTEGER, cps.get("positive_Integer"));
assertEquals(POSITIVE_LONG, cps.get("positive_Long"));
assertEquals(POSITIVE_DOUBLE, cps.get("positive_Double"));
assertEquals(NEGATIVE_INTEGER, cps.get("negative_Integer"));
assertEquals(NEGATIVE_LONG, cps.get("negative_Long"));
assertEquals(NEGATIVE_DOUBLE, cps.get("negative_Double"));
assertEquals(new Boolean(true), cps.get("Boolean"));
assertEquals(now, cps.get("Date"));
assertEquals(MAX_INTEGER, cps.get("max_Integer"));
assertEquals(MIN_INTEGER, cps.get("min_Integer"));
assertEquals(MAX_LONG, cps.get("max_Long"));
assertEquals(MIN_LONG, cps.get("min_Long"));
assertEquals(MAX_DOUBLE, cps.get("max_Double"));
assertEquals(MIN_DOUBLE, cps.get("min_Double"));
/* Remove all properties supported by HPSF from the summary
* information (e.g. author, edit date, application name) and from the
* document summary information (e.g. company, manager). */
si.removeApplicationName();