List of usage examples for org.apache.poi.hpsf DocumentSummaryInformation DEFAULT_STREAM_NAME
String DEFAULT_STREAM_NAME
To view the source code for org.apache.poi.hpsf DocumentSummaryInformation DEFAULT_STREAM_NAME.
Click Source Link
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 a v a 2 s .com 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:edu.ku.brc.specify.tasks.subpane.wb.ConfigureXLS.java
License:Open Source License
/** * @param poifs//from w w w .j ava 2 s .c o m * @returns the DocumentSummaryInformation for poifs, or null if no DocumentSummaryInformation is found. */ protected DocumentSummaryInformation getDocSummary(final POIFSFileSystem poifs) { DirectoryEntry dir = poifs.getRoot(); DocumentSummaryInformation result = null; try { DocumentEntry dsiEntry = (DocumentEntry) dir.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME); DocumentInputStream dis = new DocumentInputStream(dsiEntry); PropertySet ps = new PropertySet(dis); dis.close(); result = new DocumentSummaryInformation(ps); } catch (FileNotFoundException ex) { // There is no document summary information. result = null; } /* * just returning null if anything weird happens. If there is a problem with the xls file, * something else will probably blow up later. */ catch (IOException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ConfigureXLS.class, ex); log.debug(ex); result = null; } catch (NoPropertySetStreamException ex) { //edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); //edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ConfigureXLS.class, ex); log.debug(ex); result = null; } catch (MarkUnsupportedException ex) { //edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); //edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ConfigureXLS.class, ex); log.debug(ex); result = null; } catch (UnexpectedPropertySetTypeException ex) { //edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); //edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ConfigureXLS.class, ex); log.debug(ex); result = null; } catch (IllegalPropertySetDataException ex) { //edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); //edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ConfigureXLS.class, ex); log.debug(ex); result = null; } return result; }
From source file:edu.ku.brc.specify.tasks.subpane.wb.XLSExport.java
License:Open Source License
public void writeData(final List<?> data) throws Exception { HSSFWorkbook workBook = new HSSFWorkbook(); HSSFSheet workSheet = workBook.createSheet(); DocumentSummaryInformation mappings = null; int rowNum = 0; if (config.getFirstRowHasHeaders() && !config.getAppendData()) { writeHeaders(workSheet);/*from ww w .jav a 2 s. c o m*/ rowNum++; String[] headers = config.getHeaders(); for (int i = 0; i < headers.length; i++) { workSheet.setColumnWidth(i, StringUtils.isNotEmpty(headers[i]) ? (256 * headers[i].length()) : 2560); } WorkbenchTemplate wbTemplate = null; if (data.get(0) instanceof WorkbenchTemplate) { wbTemplate = (WorkbenchTemplate) data.get(0); } else { wbTemplate = ((WorkbenchRow) data.get(0)).getWorkbench().getWorkbenchTemplate(); } mappings = writeMappings(wbTemplate); } //assuming data is never empty. boolean hasTemplate = data.get(0) instanceof WorkbenchTemplate; boolean hasRows = hasTemplate ? data.size() > 1 : data.size() > 0; if (hasRows) { int[] disciplinees; WorkbenchRow wbRow = (WorkbenchRow) data.get(hasTemplate ? 1 : 0); Workbench workBench = wbRow.getWorkbench(); WorkbenchTemplate template = workBench.getWorkbenchTemplate(); int numCols = template.getWorkbenchTemplateMappingItems().size(); int geoDataCol = -1; Vector<Integer> imgCols = new Vector<Integer>(); disciplinees = bldColTypes(template); for (Object rowObj : data) { if (rowObj instanceof WorkbenchTemplate) { continue; } WorkbenchRow row = (WorkbenchRow) rowObj; HSSFRow hssfRow = workSheet.createRow(rowNum++); int colNum; boolean rowHasGeoData = false; for (colNum = 0; colNum < numCols; colNum++) { HSSFCell cell = hssfRow.createCell(colNum); cell.setCellType(disciplinees[colNum]); setCellValue(cell, row.getData(colNum)); } if (row.getBioGeomancerResults() != null && !row.getBioGeomancerResults().equals("")) { geoDataCol = colNum; rowHasGeoData = true; HSSFCell cell = hssfRow.createCell(colNum++); cell.setCellType(HSSFCell.CELL_TYPE_STRING); setCellValue(cell, row.getBioGeomancerResults()); } // if (row.getCardImage() != null) if (row.getRowImage(0) != null) { if (!rowHasGeoData) { colNum++; } int imgIdx = 0; WorkbenchRowImage img = row.getRowImage(imgIdx++); while (img != null) { if (imgCols.indexOf(colNum) < 0) { imgCols.add(colNum); } HSSFCell cell = hssfRow.createCell(colNum++); cell.setCellType(HSSFCell.CELL_TYPE_STRING); String cellValue = img.getCardImageFullPath(); String attachToTbl = img.getAttachToTableName(); if (attachToTbl != null) { cellValue += "\t" + attachToTbl; } setCellValue(cell, cellValue); img = row.getRowImage(imgIdx++); } } } if (imgCols.size() > 0 || geoDataCol != -1) { writeExtraHeaders(workSheet, imgCols, geoDataCol); } } try { // Write the workbook File file = new File(getConfig().getFileName()); if (file.canWrite() || (!file.exists() && file.createNewFile())) { FileOutputStream fos = new FileOutputStream(file); workBook.write(fos); fos.close(); //Now write the mappings. //NOT (hopefully) the best way to write the mappings, but (sadly) the easiest way. //May need to do this another way if this slows performance for big wbs. if (mappings != null) { InputStream is = new FileInputStream(file); POIFSFileSystem poifs = new POIFSFileSystem(is); is.close(); mappings.write(poifs.getRoot(), DocumentSummaryInformation.DEFAULT_STREAM_NAME); fos = new FileOutputStream(file); poifs.writeFilesystem(fos); fos.close(); } } else { UIRegistry.displayErrorDlgLocalized("WB_EXPORT_PERM_ERR"); } } catch (Exception e) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(XLSExport.class, e); throw (e); } }
From source file:net.sf.mpxj.mpp.ProjectPropertiesReader.java
License:Open Source License
/** * The main entry point for processing project properties. * /*from ww w . j a v a 2s . co m*/ * @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 w w. j av a2s . c o 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; }
From source file:org.opencms.search.extractors.A_CmsTextExtractorMsOfficeBase.java
License:Open Source License
/** * @see org.apache.poi.poifs.eventfilesystem.POIFSReaderListener#processPOIFSReaderEvent(org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent) *//*from www . ja va 2s .co 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 (RuntimeException e) { // ignore } catch (Exception e) { // ignore } }
From source file:org.redpill.alfresco.module.metadatawriter.services.msoffice.impl.POIFSFacadeImpl.java
License:Open Source License
private void saveDocumentSummaryInformation() throws ContentException { try {/*from ww w. jav a 2 s.co m*/ getDocumentSummaryInformation().write(getFileSystem().getRoot(), DocumentSummaryInformation.DEFAULT_STREAM_NAME); } catch (IOException e) { throw new ContentFacade.ContentException("Could not write Document Summary Information", e); } catch (WritingNotSupportedException e) { throw new ContentFacade.ContentException("Could not write Document Summary Information", e); } }
From source file:org.redpill.alfresco.module.metadatawriter.services.msoffice.impl.POIFSFacadeImpl.java
License:Open Source License
private DocumentSummaryInformation getDocumentSummaryInformation() throws ContentFacade.ContentException { if (null == dsi) { try {//from w w w. j av a 2 s. c o m final PropertySet ps = createPropertySet(DocumentSummaryInformation.DEFAULT_STREAM_NAME); dsi = new DocumentSummaryInformation(ps); } catch (FileNotFoundException fnf) { logger.debug("Document summary information does not exist in file, createing new!"); dsi = PropertySetFactory.newDocumentSummaryInformation(); } catch (UnexpectedPropertySetTypeException e) { throw new ContentException("Document summary information property set has invalid type", e); } } return dsi; }
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 ww w .java 2 s . c o 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(); }