List of usage examples for org.apache.poi.poifs.eventfilesystem POIFSReaderEvent getStream
public DocumentInputStream getStream()
From source file:com.duroty.lucene.parser.MSPowerPointParser.java
License:Open Source License
/** * DOCUMENT ME!//from www . j a v a 2s . c o m * * @param event DOCUMENT ME! */ public void processPOIFSReaderEvent(POIFSReaderEvent event) { try { if (!event.getName().equalsIgnoreCase("PowerPoint Document")) { return; } DocumentInputStream input = event.getStream(); byte[] buffer = new byte[input.available()]; input.read(buffer, 0, input.available()); byte[] espace = new String("\n\n").getBytes(); for (int i = 0; i < (buffer.length - 20); i++) { long type = LittleEndian.getUShort(buffer, i + 2); long size = LittleEndian.getUInt(buffer, i + 4); if (type == 4008) { writer.write(buffer, i + 4 + 1, (int) size + 3); writer.write(espace); i = (i + 4 + 1 + (int) size) - 1; } /*if (sleep > 0) { try { Thread.sleep(sleep); } catch (Exception ex) { } }*/ } } catch (Exception ex) { } }
From source file:com.duroty.lucene.parser.utils.POIFSListener.java
License:Apache License
/** * DOCUMENT ME!/*from ww w. ja va 2 s . co m*/ * * @param arg0 DOCUMENT ME! */ public void processPOIFSReaderEvent(POIFSReaderEvent readerEvent) { org.apache.poi.hpsf.PropertySet propertySet; try { propertySet = PropertySetFactory.create(readerEvent.getStream()); SummaryInformation info = (SummaryInformation) propertySet; this.author = info.getAuthor(); this.title = info.getTitle(); this.keywords = info.getKeywords(); this.subject = info.getSubject(); } catch (NoPropertySetStreamException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MarkUnsupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnexpectedPropertySetTypeException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.flexive.extractor.ExcelExtractor.java
License:Open Source License
/** * Proccesses the Summary section.//from w w w. ja va 2 s. c o m * * @param event the summary section event. */ @Override public void processPOIFSReaderEvent(POIFSReaderEvent event) { try { SummaryInformation si = (SummaryInformation) PropertySetFactory.create(event.getStream()); fxsi = new FxSummaryInformation(si); } catch (Exception ex) { // } }
From source file:com.flexive.extractor.FxSummaryInformation.java
License:Open Source License
/** * Reads the summary information from a document. * * @param input the input stream to read from, will not be closed at the end * @return the summary information//w ww . j a v a2s .c o m */ public static FxSummaryInformation getSummaryInformation(InputStream input) { class SummaryStore implements POIFSReaderListener { private FxSummaryInformation fxsi = null; /** * Processes the Summary section. * * @param event the summary section event. */ @Override public void processPOIFSReaderEvent(POIFSReaderEvent event) { try { SummaryInformation si = (SummaryInformation) PropertySetFactory.create(event.getStream()); fxsi = new FxSummaryInformation(si); } catch (Exception ex) { /* ignore */ } } protected FxSummaryInformation getFxSummaryInformation() { return fxsi; } } try { POIFSReader reader = new POIFSReader(); SummaryStore st = new SummaryStore(); reader.registerListener(st, "\005SummaryInformation"); reader.read(input); return st.getFxSummaryInformation(); } catch (Exception ex) { return null; } }
From source file:com.flexive.extractor.PowerpointExtractor.java
License:Open Source License
@Override public void processPOIFSReaderEvent(POIFSReaderEvent event) { try {//w ww . ja v a 2s .com if (event.getName().equalsIgnoreCase("PowerPoint Document")) { DocumentInputStream input = event.getStream(); byte[] buffer = new byte[input.available()]; //noinspection ResultOfMethodCallIgnored input.read(buffer, 0, input.available()); processContent(buffer, 0, buffer.length); } else if (event.getName().equals("\005SummaryInformation")) { SummaryInformation si = (SummaryInformation) PropertySetFactory.create(event.getStream()); fxsi = new FxSummaryInformation(si); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.flexive.extractor.WordExtractor.java
License:Open Source License
/** * Proccesses the Summary section./*from www . j av a 2 s . c o m*/ * * @param event the summary section event. */ @Override public void processPOIFSReaderEvent(POIFSReaderEvent event) { try { SummaryInformation si = (SummaryInformation) PropertySetFactory.create(event.getStream()); fxsi = new FxSummaryInformation(si); } catch (Exception ex) { // } }
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) *//*w w w . j av a 2 s. c om*/ 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.knowgate.ole.OLEListener.java
License:Open Source License
public void processPOIFSReaderEvent(POIFSReaderEvent event) { try {/*from w w w. j a v a 2 s. co m*/ si = (SummaryInformation) PropertySetFactory.create(event.getStream()); } catch (MarkUnsupportedException ex) { if (DebugFile.trace) DebugFile.writeln("com.knowgate.ole.OLEListener MarkUnsupportedException " + event.getPath() + event.getName() + " " + ex.getMessage()); } catch (NoPropertySetStreamException ex) { if (DebugFile.trace) DebugFile.writeln("com.knowgate.ole.OLEListener NoPropertySetStreamException " + event.getPath() + event.getName() + " " + ex.getMessage()); } catch (IOException ex) { if (DebugFile.trace) DebugFile.writeln("com.knowgate.ole.OLEListener IOException " + event.getPath() + event.getName() + " " + ex.getMessage()); } }
From source file:com.villemos.ispace.aperture.enricher.MicrosoftPropertyReader.java
License:Open Source License
public void processPOIFSReaderEvent(final POIFSReaderEvent event) { PropertySet ps = null;/*from w w w. j av a2s . c o m*/ try { ps = PropertySetFactory.create(event.getStream()); } catch (NoPropertySetStreamException ex) { LOG.debug("No property set stream: \"" + event.getPath() + event.getName() + "\""); return; } catch (Exception ex) { LOG.error("Exception while processing microsoft property set " + ex); } /* Print the name of the property set stream: */ LOG.debug("Property set stream \"" + event.getPath() + event.getName() + "\":"); /* Print the list of sections: */ List<Section> sections = ps.getSections(); int nr = 0; for (Section sec : sections) { String s = HexDump.dump(sec.getFormatID().getBytes(), 0L, 0); s = s.substring(0, s.length() - 1); /* Print the number of properties in this section. */ int propertyCount = sec.getPropertyCount(); /* Print the properties: */ Property[] properties = sec.getProperties(); for (int i2 = 0; i2 < properties.length; i2++) { /* Print a single property: */ Property p = properties[i2]; long id = p.getID(); long type = p.getType(); Object value = p.getValue(); String propertyName = sec.getPIDString(id); if (msProperties.containsKey(propertyName) == false) { String valueStr = value.toString(); if (valueStr.equals("") == false) { msProperties.put(propertyName, valueStr); } } } } }
From source file:lius.index.powerpoint.PPTIndexer.java
License:Apache License
public void processPOIFSReaderEvent(POIFSReaderEvent event) { try {/*from www. j a v a 2 s . c o m*/ if (!event.getName().equalsIgnoreCase("PowerPoint Document")) return; DocumentInputStream input = event.getStream(); byte[] buffer = new byte[input.available()]; input.read(buffer, 0, input.available()); for (int i = 0; i < buffer.length - 20; i++) { long type = LittleEndian.getUShort(buffer, i + 2); long size = LittleEndian.getUInt(buffer, i + 4); if (type == 4008L) { writer.write(buffer, i + 4 + 1, (int) size + 3); i = i + 4 + 1 + (int) size - 1; } } } catch (Exception ex) { logger.error(ex.getMessage()); } }