List of usage examples for org.apache.poi.hpsf DocumentSummaryInformation getCategory
public String getCategory()
From source file:RefDiviedMain.java
License:Creative Commons License
public static void readDocumentSummary(HWPFDocument doc) { DocumentSummaryInformation summaryInfo = doc.getDocumentSummaryInformation(); String category = summaryInfo.getCategory(); String company = summaryInfo.getCompany(); int lineCount = summaryInfo.getLineCount(); int sectionCount = summaryInfo.getSectionCount(); int slideCount = summaryInfo.getSlideCount(); ta.append("\n" + "---------------------------"); ta.append("\n" + "Category: " + category); ta.append("\n" + "Company: " + company); ta.append("\n" + "Line Count: " + lineCount); ta.append("\n" + "Section Count: " + sectionCount); ta.append("\n" + "Slide Count: " + slideCount); }
From source file:com.pnf.plugin.ole.parser.StreamReader.java
License:Apache License
private List<INode> readDocSummaryStream(ByteBuffer stream) { List<INode> roots = new LinkedList<>(); String propType = "Property"; try {/*from w w w .ja v a2s . co m*/ DocumentSummaryInformation info = (DocumentSummaryInformation) PropertySetFactory .create(new ByteArrayInputStream(stream.array())); propType = "int"; StreamEntry counts = new StreamEntry("Counts"); if (info.getLineCount() != 0) counts.addChild(new StreamEntry("Line count", propType, String.valueOf(info.getLineCount()))); if (info.getByteCount() != 0) counts.addChild(new StreamEntry("Byte count", propType, String.valueOf(info.getByteCount()))); if (info.getHiddenCount() != 0) counts.addChild(new StreamEntry("Hidden count", propType, String.valueOf(info.getHiddenCount()))); if (info.getMMClipCount() != 0) counts.addChild(new StreamEntry("MMClip count", propType, String.valueOf(info.getMMClipCount()))); if (info.getNoteCount() != 0) counts.addChild(new StreamEntry("Note count", propType, String.valueOf(info.getNoteCount()))); if (info.getParCount() != 0) counts.addChild(new StreamEntry("Par count", propType, String.valueOf(info.getParCount()))); if (info.getSlideCount() != 0) counts.addChild(new StreamEntry("Slide count", propType, String.valueOf(info.getSlideCount()))); if (counts.size() > 0) roots.add(counts); propType = "String"; StreamEntry strings = new StreamEntry("Strings"); strings.addChild(new StreamEntry("Category", propType, info.getCategory())); strings.addChild(new StreamEntry("Company", propType, info.getCompany())); strings.addChild(new StreamEntry("Manager", propType, info.getManager())); strings.addChild(new StreamEntry("Presentation Format", propType, info.getPresentationFormat())); roots.add(strings); propType = "Custom"; StreamEntry custom = new StreamEntry("User-defined properties"); CustomProperties props = info.getCustomProperties(); if (props != null) { Set<Entry<Object, CustomProperty>> entries = props.entrySet(); for (Entry<Object, CustomProperty> e : entries) { try { custom.addChild(new StreamEntry(e.getValue().getName(), propType, e.getValue().getValue().toString())); } catch (NullPointerException ex) { // ignore any errors } } } } catch (Throwable t) { addMessage("Attempted to read " + DOC_SUMM + " stream but no property sets were found.", null, Message.CORRUPT); } return roots; }
From source file:intelligentWebAlgorithms.util.parsing.msword.MSWordDocumentParser.java
License:Apache License
public String[] readDocumentSummary(HWPFDocument doc) { String[] summary = new String[5]; DocumentSummaryInformation summaryInfo = doc.getDocumentSummaryInformation(); summary[0] = summaryInfo.getCategory(); summary[1] = summaryInfo.getCompany(); summary[2] = Integer.toString(summaryInfo.getLineCount()); summary[3] = Integer.toString(summaryInfo.getSectionCount()); summary[4] = Integer.toString(summaryInfo.getSlideCount()); // P.hline(); // P.println("Category: "+category); // P.println("Company: "+company); // P.println("Line Count: "+lineCount); // P.println("Section Count: "+sectionCount); // P.println("Slide Count: "+slideCount); return summary; }
From source file:lucee.runtime.poi.Excel.java
License:Open Source License
private void info(Struct sct, DocumentSummaryInformation summary) { if (summary == null) return;/* w w w . ja v a 2s . co m*/ set(sct, "CATEGORY", summary.getCategory()); set(sct, "COMPANY", summary.getCompany()); set(sct, "MANAGER", summary.getManager()); set(sct, "PRESENTATIONFORMAT", summary.getPresentationFormat()); }
From source file:mj.ocraptor.extraction.tika.parser.microsoft.SummaryExtractor.java
License:Apache License
private void parse(DocumentSummaryInformation summary) { set(OfficeOpenXMLExtended.COMPANY, summary.getCompany()); set(OfficeOpenXMLExtended.MANAGER, summary.getManager()); set(TikaCoreProperties.LANGUAGE, getLanguage(summary)); set(OfficeOpenXMLCore.CATEGORY, summary.getCategory()); // New style counts set(Office.SLIDE_COUNT, summary.getSlideCount()); if (summary.getSlideCount() > 0) { metadata.set(PagedText.N_PAGES, summary.getSlideCount()); }/* w ww. ja va2 s.co m*/ // Old style, Tika 1.0 counts // TODO Remove these in Tika 2.0 set(Metadata.COMPANY, summary.getCompany()); set(Metadata.MANAGER, summary.getManager()); set(MSOffice.SLIDE_COUNT, summary.getSlideCount()); set(Metadata.CATEGORY, summary.getCategory()); parse(summary.getCustomProperties()); }
From source file:org.alanwilliamson.openbd.plugin.spreadsheet.functions.SpreadsheetInfo.java
License:Open Source License
public cfData execute(cfSession _session, List<cfData> parameters) throws cfmRunTimeException { cfSpreadSheetData spreadsheet = null; spreadsheet = (cfSpreadSheetData) parameters.get(0); Workbook workbook = spreadsheet.getWorkBook(); cfStructData s = new cfStructData(); /*// w ww . ja v a 2s. c om * Sheet details */ s.setData("sheets", new cfNumberData(workbook.getNumberOfSheets())); cfArrayData sheetArr = cfArrayData.createArray(1); for (int x = 0; x < workbook.getNumberOfSheets(); x++) { String name = workbook.getSheetName(x); if (name == null) name = ""; sheetArr.addElement(new cfStringData(name)); } s.setData("sheetnames", sheetArr); /* * Workbook type */ if (workbook instanceof XSSFWorkbook) { s.setData("spreadsheettype", new cfStringData("xlsx")); } else { s.setData("spreadsheettype", new cfStringData("xls")); } /* * XSSFWorkbook */ if (workbook instanceof XSSFWorkbook) { XSSFWorkbook xSSFWorkbook = (XSSFWorkbook) workbook; CoreProperties cP = xSSFWorkbook.getProperties().getCoreProperties(); s.setData("category", new cfStringData(cP.getCategory())); s.setData("subject", new cfStringData(cP.getSubject())); s.setData("title", new cfStringData(cP.getTitle())); s.setData("revision", new cfStringData(cP.getRevision())); s.setData("author", new cfStringData(cP.getCreator())); s.setData("description", new cfStringData(cP.getDescription())); if (cP.getLastPrinted() != null) s.setData("lastprinted", new cfDateData(cP.getLastPrinted())); if (cP.getModified() != null) s.setData("lastsaved", new cfDateData(cP.getModified())); if (cP.getCreated() != null) s.setData("creationdate", new cfDateData(cP.getCreated())); } else { HSSFWorkbook hSSFWorkbook = (HSSFWorkbook) workbook; DocumentSummaryInformation dSummary = hSSFWorkbook.getDocumentSummaryInformation(); if (dSummary == null) { s.setData("category", cfStringData.EMPTY_STRING); s.setData("company", cfStringData.EMPTY_STRING); s.setData("manager", cfStringData.EMPTY_STRING); } else { s.setData("category", new cfStringData(dSummary.getCategory())); s.setData("company", new cfStringData(dSummary.getCompany())); s.setData("manager", new cfStringData(dSummary.getManager())); } SummaryInformation sInformation = hSSFWorkbook.getSummaryInformation(); if (sInformation == null) { s.setData("author", cfStringData.EMPTY_STRING); s.setData("comments", cfStringData.EMPTY_STRING); s.setData("keywords", cfStringData.EMPTY_STRING); s.setData("lastauthor", cfStringData.EMPTY_STRING); s.setData("title", cfStringData.EMPTY_STRING); s.setData("subject", cfStringData.EMPTY_STRING); } else { s.setData("author", new cfStringData(sInformation.getAuthor())); s.setData("comments", new cfStringData(sInformation.getComments())); s.setData("keywords", new cfStringData(sInformation.getKeywords())); s.setData("lastauthor", new cfStringData(sInformation.getLastAuthor())); s.setData("title", new cfStringData(sInformation.getTitle())); s.setData("subject", new cfStringData(sInformation.getSubject())); if (sInformation.getCreateDateTime() != null) s.setData("creationdate", new cfDateData(sInformation.getCreateDateTime())); if (sInformation.getLastSaveDateTime() != null) s.setData("lastsaved", new cfDateData(sInformation.getLastSaveDateTime())); if (sInformation.getLastPrinted() != null) s.setData("lastprinted", new cfDateData(sInformation.getLastPrinted())); } } return s; }
From source file:org.apache.tika.parser.microsoft.SummaryExtractor.java
License:Apache License
private void parse(DocumentSummaryInformation summary) { set(OfficeOpenXMLExtended.COMPANY, summary.getCompany()); addMulti(metadata, OfficeOpenXMLExtended.MANAGER, summary.getManager()); set(TikaCoreProperties.LANGUAGE, getLanguage(summary)); set(OfficeOpenXMLCore.CATEGORY, summary.getCategory()); // New style counts set(Office.SLIDE_COUNT, summary.getSlideCount()); if (summary.getSlideCount() > 0) { metadata.set(PagedText.N_PAGES, summary.getSlideCount()); }/*from w w w . ja v a 2 s . c o m*/ // Old style, Tika 1.0 counts // TODO Remove these in Tika 2.0 set(Metadata.COMPANY, summary.getCompany()); set(Metadata.MANAGER, summary.getManager()); set(MSOffice.SLIDE_COUNT, summary.getSlideCount()); set(Metadata.CATEGORY, summary.getCategory()); parse(summary.getCustomProperties()); }
From source file:poi.hpsf.examples.ModifyDocumentSummaryInformation.java
License:Apache License
/** * <p>Main method - see class description.</p> * * @param args The command-line parameters. * @throws java.io.IOException//from w ww . j a v a2s . co m * @throws MarkUnsupportedException * @throws NoPropertySetStreamException * @throws UnexpectedPropertySetTypeException * @throws WritingNotSupportedException */ public static void main(final String[] args) throws IOException, NoPropertySetStreamException, MarkUnsupportedException, UnexpectedPropertySetTypeException, WritingNotSupportedException { /* Read the name of the POI filesystem to modify from the command line. * For brevity to boundary check is performed on the command-line * arguments. */ File poiFilesystem = new File(args[0]); /* Open the POI filesystem. */ InputStream is = new FileInputStream(poiFilesystem); POIFSFileSystem poifs = new POIFSFileSystem(is); is.close(); /* Read the summary information. */ DirectoryEntry dir = poifs.getRoot(); SummaryInformation si; try { DocumentEntry siEntry = (DocumentEntry) dir.getEntry(SummaryInformation.DEFAULT_STREAM_NAME); DocumentInputStream dis = new DocumentInputStream(siEntry); PropertySet ps = new PropertySet(dis); dis.close(); si = new SummaryInformation(ps); } catch (FileNotFoundException ex) { /* There is no summary information yet. We have to create a new * one. */ si = PropertySetFactory.newSummaryInformation(); } /* Change the author to "Rainer Klute". Any former author value will * be lost. If there has been no author yet, it will be created. */ si.setAuthor("Rainer Klute"); System.out.println("Author changed to " + si.getAuthor() + "."); /* Handling the document summary information is analogous to handling * the summary information. An additional feature, however, are the * custom properties. */ /* Read the document summary information. */ DocumentSummaryInformation dsi; try { DocumentEntry dsiEntry = (DocumentEntry) dir.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME); DocumentInputStream dis = new DocumentInputStream(dsiEntry); PropertySet ps = new PropertySet(dis); dis.close(); dsi = new DocumentSummaryInformation(ps); } catch (FileNotFoundException ex) { /* There is no document summary information yet. We have to create a * new one. */ dsi = PropertySetFactory.newDocumentSummaryInformation(); } /* Change the category to "POI example". Any former category value will * be lost. If there has been no category yet, it will be created. */ dsi.setCategory("POI example"); System.out.println("Category changed to " + dsi.getCategory() + "."); /* Read the custom properties. If there are no custom properties yet, * the application has to create a new CustomProperties object. It will * serve as a container for custom properties. */ CustomProperties customProperties = dsi.getCustomProperties(); if (customProperties == null) customProperties = new CustomProperties(); /* Insert some custom properties into the container. */ customProperties.put("Key 1", "Value 1"); customProperties.put("Schl\u00fcssel 2", "Wert 2"); customProperties.put("Sample Number", new Integer(12345)); customProperties.put("Sample Boolean", Boolean.TRUE); customProperties.put("Sample Date", new Date()); /* Read a custom property. */ Object value = customProperties.get("Sample Number"); /* Write the custom properties back to the document summary * information. */ dsi.setCustomProperties(customProperties); /* Write the summary information and the document summary information * to the POI filesystem. */ si.write(dir, SummaryInformation.DEFAULT_STREAM_NAME); dsi.write(dir, DocumentSummaryInformation.DEFAULT_STREAM_NAME); /* Write the POI filesystem back to the original file. Please note that * in production code you should never write directly to the origin * file! In case of a writing error everything would be lost. */ OutputStream out = new FileOutputStream(poiFilesystem); poifs.writeFilesystem(out); out.close(); }