List of usage examples for org.apache.poi.hpsf SummaryInformation DEFAULT_STREAM_NAME
String DEFAULT_STREAM_NAME
To view the source code for org.apache.poi.hpsf SummaryInformation DEFAULT_STREAM_NAME.
Click Source Link
From source file:com.armorize.hackalert.extractor.msword.MSExtractor.java
License:Apache License
/** * Extracts properties and text from an MS Document input stream *//*w ww.ja va 2s . c o m*/ protected void extract(InputStream input) throws Exception { // First, extract properties this.reader = new POIFSReader(); this.properties = new PropertiesBroker(); this.reader.registerListener(new PropertiesReaderListener(this.properties), SummaryInformation.DEFAULT_STREAM_NAME); input.reset(); if (input.available() > 0) { reader.read(input); } // Then, extract text input.reset(); this.text = extractText(input); }
From source file:com.frameworkset.platform.cms.searchmanager.extractors.A_CmsTextExtractorMsOfficeBase.java
License:Open Source License
/** * @see org.apache.poi.poifs.eventfilesystem.POIFSReaderListener#processPOIFSReaderEvent(org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent) *//* www . j a va 2 s. c o m*/ public void processPOIFSReaderEvent(POIFSReaderEvent event) { try { if ((m_summary == null) && event.getName().startsWith(SummaryInformation.DEFAULT_STREAM_NAME)) { m_summary = (SummaryInformation) PropertySetFactory.create(event.getStream()); return; } if ((m_documentSummary == null) && event.getName().startsWith(DocumentSummaryInformation.DEFAULT_STREAM_NAME)) { m_documentSummary = (DocumentSummaryInformation) PropertySetFactory.create(event.getStream()); return; } } catch (Exception e) { // ignore } }
From source file:com.oneis.graphics.ThumbnailFinder.java
License:Mozilla Public License
/** * Try and get a thumbnail from an old Microsoft Office document *//*from w ww .j a v a 2 s . c o m*/ private void findFromOldMSOffice() { try { File poiFilesystem = new File(inFilename); // Open the POI filesystem. InputStream is = new FileInputStream(poiFilesystem); POIFSFileSystem poifs = new POIFSFileSystem(is); is.close(); // Read the summary information. DirectoryEntry dir = poifs.getRoot(); DocumentEntry siEntry = (DocumentEntry) dir.getEntry(SummaryInformation.DEFAULT_STREAM_NAME); DocumentInputStream dis = new DocumentInputStream(siEntry); PropertySet ps = new PropertySet(dis); dis.close(); SummaryInformation si = new SummaryInformation(ps); if (si != null) { byte[] thumbnailData = si.getThumbnail(); if (thumbnailData != null) { Thumbnail thumbnail = new Thumbnail(thumbnailData); byte[] wmf = thumbnail.getThumbnailAsWMF(); // Got something! thumbnailDimensions = tryWMFFormat(new ByteArrayInputStream(wmf), outFilename, outFormat, maxDimension); } } } catch (Exception e) { logIgnoredException("ThumbnailFinder Apache POI file reading failed", e); } }
From source file:gov.nih.nci.evs.app.neopl.XLSXMetadataUtils.java
License:Open Source License
public static String getSummaryData(String filename, String key) { String value = null;/*from w ww . j a v a2 s.c o m*/ FileInputStream stream = null; try { stream = new FileInputStream(new File(filename)); POIFSFileSystem poifs = null; try { poifs = new POIFSFileSystem(stream); } catch (Exception e) { stream.close(); return getPOISummaryData(filename, key); } DirectoryEntry dir = poifs.getRoot(); DocumentEntry siEntry = (DocumentEntry) dir.getEntry(SummaryInformation.DEFAULT_STREAM_NAME); if (siEntry != null) { DocumentInputStream dis = new DocumentInputStream(siEntry); PropertySet ps = new PropertySet(dis); SummaryInformation si = new SummaryInformation(ps); if (key.compareTo(SUMMARY_DATA_AUTHOR) == 0) { value = si.getAuthor(); } else if (key.compareTo(SUMMARY_DATA_KEYWORDS) == 0) { value = si.getKeywords(); } else if (key.compareTo(SUMMARY_DATA_TITLE) == 0) { value = si.getTitle(); } else if (key.compareTo(SUMMARY_DATA_SUBJECT) == 0) { value = si.getSubject(); } } } catch (Exception ex) { ex.getStackTrace(); } finally { try { stream.close(); } catch (Exception ex) { ex.printStackTrace(); } } return value; }
From source file:gov.nih.nci.evs.app.neopl.XLSXMetadataUtils.java
License:Open Source License
public static String getAuthor(File file) { String author = null;/*from w ww . j a v a 2 s.c o m*/ try { FileInputStream stream = new FileInputStream(file); POIFSFileSystem poifs = null; try { poifs = new POIFSFileSystem(stream); } catch (Exception e) { stream.close(); return getCreator(file); } DirectoryEntry dir = null; try { dir = poifs.getRoot(); } catch (Exception ex) { System.out.println("DirectoryEntry is NULL???"); return null; } DocumentEntry siEntry = (DocumentEntry) dir.getEntry(SummaryInformation.DEFAULT_STREAM_NAME); if (siEntry != null) { DocumentInputStream dis = new DocumentInputStream(siEntry); PropertySet ps = new PropertySet(dis); SummaryInformation si = new SummaryInformation(ps); author = si.getAuthor(); } stream.close(); } catch (Exception ex) { ex.getStackTrace(); } return author; }
From source file:gov.nih.nci.evs.app.neopl.XLSXMetadataUtils.java
License:Open Source License
public static void setAuthor(String filename, String author) { try {/*www. j a va2 s . com*/ FileInputStream stream = new FileInputStream(new File(filename)); POIFSFileSystem poifs = new POIFSFileSystem(stream); DirectoryEntry dir = poifs.getRoot(); System.out.println("SummaryInformation.DEFAULT_STREAM_NAME: " + SummaryInformation.DEFAULT_STREAM_NAME); DocumentEntry siEntry = (DocumentEntry) dir.getEntry(SummaryInformation.DEFAULT_STREAM_NAME); DocumentInputStream dis = new DocumentInputStream(siEntry); PropertySet ps = new PropertySet(dis); SummaryInformation si = new SummaryInformation(ps); System.out.println("SummaryInformation setAuthor: " + author); si.setAuthor(author); OutputStream outStream = null; outStream = new FileOutputStream(new File(filename)); byte[] buffer = new byte[1024]; int length; while ((length = stream.read(buffer)) > 0) { outStream.write(buffer, 0, length); } outStream.close(); stream.close(); } catch (Exception ex) { ex.getStackTrace(); } }
From source file:gov.nih.nci.evs.app.neopl.XLSXMetadataUtils.java
License:Open Source License
public static void setAuthor(File file, String author) { try {/*from w w w.j av a 2 s .c om*/ FileInputStream stream = new FileInputStream(file); POIFSFileSystem poifs = null; try { poifs = new POIFSFileSystem(stream); } catch (Exception e) { stream.close(); setCreator(file, author); return; } DirectoryEntry dir = poifs.getRoot(); DocumentEntry siEntry = (DocumentEntry) dir.getEntry(SummaryInformation.DEFAULT_STREAM_NAME); if (siEntry != null) { DocumentInputStream dis = new DocumentInputStream(siEntry); PropertySet ps = new PropertySet(dis); SummaryInformation si = new SummaryInformation(ps); si.setAuthor(author); } stream.close(); } catch (Exception ex) { ex.getStackTrace(); } }
From source file:net.sf.mmm.content.parser.impl.poi.AbstractContentParserPoi.java
License:Apache License
/** * {@inheritDoc}/* w w w . j a v a 2s . c om*/ */ @Override public void parse(InputStream inputStream, long filesize, ContentParserOptions options, MutableGenericContext context) throws Exception { POIFSFileSystem poiFs = new POIFSFileSystem(inputStream); SummaryInformation summaryInfo = (SummaryInformation) PropertySetFactory .create(poiFs.createDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME)); String title = summaryInfo.getTitle(); if (title != null) { context.setVariable(VARIABLE_NAME_TITLE, title); } String author = summaryInfo.getAuthor(); if (author != null) { context.setVariable(VARIABLE_NAME_CREATOR, author); } String keywords = summaryInfo.getKeywords(); if (keywords != null) { context.setVariable(VARIABLE_NAME_KEYWORDS, keywords); } context.setVariable(VARIABLE_NAME_TEXT, extractText(poiFs, filesize, options)); }
From source file:net.sf.mpxj.mpp.ProjectPropertiesReader.java
License:Open Source License
/** * The main entry point for processing project properties. * //from w w w .j a va2 s . c om * @param file parent project file * @param props properties data * @param rootDir Root of the POI file system. */ public void process(ProjectFile file, Props props, DirectoryEntry rootDir) throws MPXJException { try { //MPPUtility.fileDump("c:\\temp\\props.txt", props.toString().getBytes()); ProjectProperties ph = file.getProjectProperties(); ph.setStartDate(props.getTimestamp(Props.PROJECT_START_DATE)); ph.setFinishDate(props.getTimestamp(Props.PROJECT_FINISH_DATE)); ph.setScheduleFrom(ScheduleFrom.getInstance(1 - props.getShort(Props.SCHEDULE_FROM))); ph.setDefaultCalendarName(props.getUnicodeString(Props.DEFAULT_CALENDAR_NAME)); ph.setDefaultStartTime(props.getTime(Props.START_TIME)); ph.setDefaultEndTime(props.getTime(Props.END_TIME)); ph.setStatusDate(props.getTimestamp(Props.STATUS_DATE)); ph.setHyperlinkBase(props.getUnicodeString(Props.HYPERLINK_BASE)); //ph.setDefaultDurationIsFixed(); ph.setDefaultDurationUnits(MPPUtility.getDurationTimeUnits(props.getShort(Props.DURATION_UNITS))); ph.setMinutesPerDay(Integer.valueOf(props.getInt(Props.MINUTES_PER_DAY))); ph.setMinutesPerWeek(Integer.valueOf(props.getInt(Props.MINUTES_PER_WEEK))); ph.setDefaultOvertimeRate(new Rate(props.getDouble(Props.OVERTIME_RATE), TimeUnit.HOURS)); ph.setDefaultStandardRate(new Rate(props.getDouble(Props.STANDARD_RATE), TimeUnit.HOURS)); ph.setDefaultWorkUnits(MPPUtility.getWorkTimeUnits(props.getShort(Props.WORK_UNITS))); ph.setSplitInProgressTasks(props.getBoolean(Props.SPLIT_TASKS)); ph.setUpdatingTaskStatusUpdatesResourceStatus(props.getBoolean(Props.TASK_UPDATES_RESOURCE)); ph.setCurrencyDigits(Integer.valueOf(props.getShort(Props.CURRENCY_DIGITS))); ph.setCurrencySymbol(props.getUnicodeString(Props.CURRENCY_SYMBOL)); ph.setCurrencyCode(props.getUnicodeString(Props.CURRENCY_CODE)); //ph.setDecimalSeparator(); ph.setSymbolPosition(MPPUtility.getSymbolPosition(props.getShort(Props.CURRENCY_PLACEMENT))); //ph.setThousandsSeparator(); ph.setWeekStartDay(Day.getInstance(props.getShort(Props.WEEK_START_DAY) + 1)); ph.setFiscalYearStartMonth(Integer.valueOf(props.getShort(Props.FISCAL_YEAR_START_MONTH))); ph.setFiscalYearStart(props.getShort(Props.FISCAL_YEAR_START) == 1); ph.setDaysPerMonth(Integer.valueOf(props.getShort(Props.DAYS_PER_MONTH))); ph.setEditableActualCosts(props.getBoolean(Props.EDITABLE_ACTUAL_COSTS)); ph.setHonorConstraints(!props.getBoolean(Props.HONOR_CONSTRAINTS)); PropertySet ps = new PropertySet(new DocumentInputStream( ((DocumentEntry) rootDir.getEntry(SummaryInformation.DEFAULT_STREAM_NAME)))); SummaryInformation summaryInformation = new SummaryInformation(ps); ph.setProjectTitle(summaryInformation.getTitle()); ph.setSubject(summaryInformation.getSubject()); ph.setAuthor(summaryInformation.getAuthor()); ph.setKeywords(summaryInformation.getKeywords()); ph.setComments(summaryInformation.getComments()); ph.setTemplate(summaryInformation.getTemplate()); ph.setLastAuthor(summaryInformation.getLastAuthor()); ph.setRevision(NumberHelper.parseInteger(summaryInformation.getRevNumber())); ph.setCreationDate(summaryInformation.getCreateDateTime()); ph.setLastSaved(summaryInformation.getLastSaveDateTime()); ph.setShortApplicationName(summaryInformation.getApplicationName()); ph.setEditingTime(Integer.valueOf((int) summaryInformation.getEditTime())); ph.setLastPrinted(summaryInformation.getLastPrinted()); ps = new PropertySet(new DocumentInputStream( ((DocumentEntry) rootDir.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME)))); ExtendedDocumentSummaryInformation documentSummaryInformation = new ExtendedDocumentSummaryInformation( ps); ph.setCategory(documentSummaryInformation.getCategory()); ph.setPresentationFormat(documentSummaryInformation.getPresentationFormat()); ph.setManager(documentSummaryInformation.getManager()); ph.setCompany(documentSummaryInformation.getCompany()); ph.setContentType(documentSummaryInformation.getContentType()); ph.setContentStatus(documentSummaryInformation.getContentStatus()); ph.setLanguage(documentSummaryInformation.getLanguage()); ph.setDocumentVersion(documentSummaryInformation.getDocumentVersion()); Map<String, Object> customPropertiesMap = new HashMap<String, Object>(); CustomProperties customProperties = documentSummaryInformation.getCustomProperties(); if (customProperties != null) { for (CustomProperty property : customProperties.values()) { customPropertiesMap.put(property.getName(), property.getValue()); } } ph.setCustomProperties(customPropertiesMap); ph.setCalculateMultipleCriticalPaths(props.getBoolean(Props.CALCULATE_MULTIPLE_CRITICAL_PATHS)); ph.setBaselineDate(props.getTimestamp(Props.BASELINE_DATE)); ph.setBaselineDate(1, props.getTimestamp(Props.BASELINE1_DATE)); ph.setBaselineDate(2, props.getTimestamp(Props.BASELINE2_DATE)); ph.setBaselineDate(3, props.getTimestamp(Props.BASELINE3_DATE)); ph.setBaselineDate(4, props.getTimestamp(Props.BASELINE4_DATE)); ph.setBaselineDate(5, props.getTimestamp(Props.BASELINE5_DATE)); ph.setBaselineDate(6, props.getTimestamp(Props.BASELINE6_DATE)); ph.setBaselineDate(7, props.getTimestamp(Props.BASELINE7_DATE)); ph.setBaselineDate(8, props.getTimestamp(Props.BASELINE8_DATE)); ph.setBaselineDate(9, props.getTimestamp(Props.BASELINE9_DATE)); ph.setBaselineDate(10, props.getTimestamp(Props.BASELINE10_DATE)); } catch (Exception ex) { throw new MPXJException(MPXJException.READ_ERROR, ex); } }
From source file:no.trank.openpipe.parse.ms.POIUtils.java
License:Apache License
/** * Fetches the \005SummaryInformation and \005DocumentSummaryInformation streams from the poi * file system and exctracts all properties of primitive type, String or Date. * /*from w ww .j a va 2 s .co m*/ * @param fs the poi filesystem * @return the properties */ public static Map<String, String> getProperties(POIFSFileSystem fs) { Map<String, String> map = new HashMap<String, String>(); try { InputStream stream = fs.createDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME); addProperties(map, PropertySetFactory.create(stream)); } catch (Exception e) { // ignore } try { InputStream stream = fs.createDocumentInputStream(DocumentSummaryInformation.DEFAULT_STREAM_NAME); addProperties(map, PropertySetFactory.create(stream)); } catch (Exception e) { // ignore } return map; }