org.apache.poi.poifs.filesystem.DocumentEntry Java Examples
The following examples show how to use
org.apache.poi.poifs.filesystem.DocumentEntry.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MPP12Reader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * This method extracts and collates resource assignment data. * * @throws IOException */ private void processAssignmentData() throws IOException { FieldMap fieldMap = new FieldMap12(m_file.getProjectProperties(), m_file.getCustomFields()); fieldMap.createAssignmentFieldMap(m_projectProps); FieldMap enterpriseCustomFieldMap = new FieldMap12(m_file.getProjectProperties(), m_file.getCustomFields()); enterpriseCustomFieldMap.createEnterpriseCustomFieldMap(m_projectProps, AssignmentField.class); DirectoryEntry assnDir = (DirectoryEntry) m_projectDir.getEntry("TBkndAssn"); VarMeta assnVarMeta = new VarMeta12(new DocumentInputStream(((DocumentEntry) assnDir.getEntry("VarMeta")))); Var2Data assnVarData = new Var2Data(assnVarMeta, new DocumentInputStream(((DocumentEntry) assnDir.getEntry("Var2Data")))); FixedMeta assnFixedMeta = new FixedMeta(new DocumentInputStream(((DocumentEntry) assnDir.getEntry("FixedMeta"))), 34); // MSP 20007 seems to write 142 byte blocks, MSP 2010 writes 110 byte blocks // We need to identify any cases where the meta data count does not correctly identify the block size FixedData assnFixedData = new FixedData(assnFixedMeta, m_inputStreamFactory.getInstance(assnDir, "FixedData")); FixedData assnFixedData2 = new FixedData(48, m_inputStreamFactory.getInstance(assnDir, "Fixed2Data")); ResourceAssignmentFactory factory = new ResourceAssignmentFactory(); factory.process(m_file, fieldMap, enterpriseCustomFieldMap, m_reader.getUseRawTimephasedData(), m_reader.getPreserveNoteFormatting(), assnVarMeta, assnVarData, assnFixedMeta, assnFixedData, assnFixedData2, assnFixedMeta.getAdjustedItemCount()); }
Example #2
Source File: MPP9Reader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Read filter definitions. * * @todo Doesn't work correctly with MPP9 files saved by Propject 2007 and 2010 * @throws IOException */ private void processFilterData() throws IOException { DirectoryEntry dir = (DirectoryEntry) m_viewDir.getEntry("CFilter"); //FixedMeta fixedMeta = new FixedMeta(new DocumentInputStream(((DocumentEntry) dir.getEntry("FixedMeta"))), 9); //FixedData fixedData = new FixedData(fixedMeta, getEncryptableInputStream(dir, "FixedData")); InputStream stream = m_inputStreamFactory.getInstance(dir, "FixedData"); int blockSize = stream.available() % 115 == 0 ? 115 : 110; FixedData fixedData = new FixedData(blockSize, stream, true); VarMeta varMeta = new VarMeta9(new DocumentInputStream(((DocumentEntry) dir.getEntry("VarMeta")))); Var2Data varData = new Var2Data(varMeta, new DocumentInputStream(((DocumentEntry) dir.getEntry("Var2Data")))); //System.out.println(fixedMeta); //System.out.println(fixedData); //System.out.println(varMeta); //System.out.println(varData); FilterReader reader = new FilterReader9(); reader.process(m_file.getProjectProperties(), m_file.getFilters(), fixedData, varData); }
Example #3
Source File: MPP9Reader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * This method extracts table data from the MPP file. * * @todo This implementation does not deal with MPP9 files saved by later * versions of MS Project * * @throws IOException */ private void processTableData() throws IOException { DirectoryEntry dir = (DirectoryEntry) m_viewDir.getEntry("CTable"); //FixedMeta fixedMeta = new FixedMeta(getEncryptableInputStream(dir, "FixedMeta"), 9); InputStream stream = m_inputStreamFactory.getInstance(dir, "FixedData"); int blockSize = stream.available() % 115 == 0 ? 115 : 110; FixedData fixedData = new FixedData(blockSize, stream); VarMeta varMeta = new VarMeta9(new DocumentInputStream(((DocumentEntry) dir.getEntry("VarMeta")))); Var2Data varData = new Var2Data(varMeta, new DocumentInputStream(((DocumentEntry) dir.getEntry("Var2Data")))); TableContainer container = m_file.getTables(); TableFactory factory = new TableFactory(TABLE_COLUMN_DATA_STANDARD, TABLE_COLUMN_DATA_ENTERPRISE, TABLE_COLUMN_DATA_BASELINE); int items = fixedData.getItemCount(); for (int loop = 0; loop < items; loop++) { byte[] data = fixedData.getByteArrayValue(loop); Table table = factory.createTable(m_file, data, varMeta, varData); container.add(table); //System.out.println(table); } }
Example #4
Source File: MPP14Reader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * This method extracts and collates resource assignment data. * * @throws IOException */ private void processAssignmentData() throws IOException { FieldMap fieldMap = new FieldMap14(m_file.getProjectProperties(), m_file.getCustomFields()); fieldMap.createAssignmentFieldMap(m_projectProps); FieldMap enterpriseCustomFieldMap = new FieldMap14(m_file.getProjectProperties(), m_file.getCustomFields()); enterpriseCustomFieldMap.createEnterpriseCustomFieldMap(m_projectProps, AssignmentField.class); DirectoryEntry assnDir = (DirectoryEntry) m_projectDir.getEntry("TBkndAssn"); VarMeta assnVarMeta = new VarMeta12(new DocumentInputStream(((DocumentEntry) assnDir.getEntry("VarMeta")))); Var2Data assnVarData = new Var2Data(assnVarMeta, new DocumentInputStream(((DocumentEntry) assnDir.getEntry("Var2Data")))); FixedMeta assnFixedMeta = new FixedMeta(new DocumentInputStream(((DocumentEntry) assnDir.getEntry("FixedMeta"))), 34); FixedData assnFixedData = new FixedData(110, m_inputStreamFactory.getInstance(assnDir, "FixedData")); FixedData assnFixedData2 = new FixedData(48, m_inputStreamFactory.getInstance(assnDir, "Fixed2Data")); //FixedMeta assnFixedMeta2 = new FixedMeta(new DocumentInputStream(((DocumentEntry) assnDir.getEntry("Fixed2Meta"))), 53); //Props props = new Props14(new DocumentInputStream(((DocumentEntry) assnDir.getEntry("Props")))); ResourceAssignmentFactory factory = new ResourceAssignmentFactory(); factory.process(m_file, fieldMap, enterpriseCustomFieldMap, m_reader.getUseRawTimephasedData(), m_reader.getPreserveNoteFormatting(), assnVarMeta, assnVarData, assnFixedMeta, assnFixedData, assnFixedData2, assnFixedMeta.getItemCount()); }
Example #5
Source File: MPP9Reader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * This method extracts and collates resource assignment data. * * @throws IOException */ private void processAssignmentData() throws IOException { FieldMap fieldMap = new FieldMap9(m_file.getProjectProperties(), m_file.getCustomFields()); fieldMap.createAssignmentFieldMap(m_projectProps); DirectoryEntry assnDir = (DirectoryEntry) m_projectDir.getEntry("TBkndAssn"); VarMeta assnVarMeta = new VarMeta9(new DocumentInputStream(((DocumentEntry) assnDir.getEntry("VarMeta")))); Var2Data assnVarData = new Var2Data(assnVarMeta, new DocumentInputStream(((DocumentEntry) assnDir.getEntry("Var2Data")))); FixedMeta assnFixedMeta = new FixedMeta(new DocumentInputStream(((DocumentEntry) assnDir.getEntry("FixedMeta"))), 34); FixedData assnFixedData = new FixedData(142, m_inputStreamFactory.getInstance(assnDir, "FixedData")); if (assnFixedData.getItemCount() != assnFixedMeta.getAdjustedItemCount()) { assnFixedData = new FixedData(assnFixedMeta, m_inputStreamFactory.getInstance(assnDir, "FixedData")); } ResourceAssignmentFactory factory = new ResourceAssignmentFactory(); factory.process(m_file, fieldMap, null, m_reader.getUseRawTimephasedData(), m_reader.getPreserveNoteFormatting(), assnVarMeta, assnVarData, assnFixedMeta, assnFixedData, null, assnFixedMeta.getAdjustedItemCount()); }
Example #6
Source File: MPP9Reader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Read group definitions. * * @todo Doesn't work correctly with MPP9 files saved by Propject 2007 and 2010 * @throws IOException */ private void processGroupData() throws IOException { DirectoryEntry dir = (DirectoryEntry) m_viewDir.getEntry("CGrouping"); //FixedMeta fixedMeta = new FixedMeta(new DocumentInputStream(((DocumentEntry) dir.getEntry("FixedMeta"))), 9); FixedData fixedData = new FixedData(110, m_inputStreamFactory.getInstance(dir, "FixedData")); VarMeta varMeta = new VarMeta9(new DocumentInputStream(((DocumentEntry) dir.getEntry("VarMeta")))); Var2Data varData = new Var2Data(varMeta, new DocumentInputStream(((DocumentEntry) dir.getEntry("Var2Data")))); // System.out.println(fixedMeta); // System.out.println(fixedData); // System.out.println(varMeta); // System.out.println(varData); GroupReader reader = new GroupReader9(); reader.process(m_file, fixedData, varData, m_fontBases); }
Example #7
Source File: MPP14Reader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * This method extracts table data from the MPP file. * * @throws java.io.IOException */ private void processTableData() throws IOException { DirectoryEntry dir = (DirectoryEntry) m_viewDir.getEntry("CTable"); VarMeta varMeta = new VarMeta12(new DocumentInputStream(((DocumentEntry) dir.getEntry("VarMeta")))); Var2Data varData = new Var2Data(varMeta, new DocumentInputStream(((DocumentEntry) dir.getEntry("Var2Data")))); FixedData fixedData = new FixedData(230, new DocumentInputStream(((DocumentEntry) dir.getEntry("FixedData")))); //System.out.println(varMeta); //System.out.println(varData); //System.out.println(fixedData); TableContainer container = m_file.getTables(); TableFactory14 factory = new TableFactory14(TABLE_COLUMN_DATA_STANDARD, TABLE_COLUMN_DATA_ENTERPRISE, TABLE_COLUMN_DATA_BASELINE); int items = fixedData.getItemCount(); for (int loop = 0; loop < items; loop++) { byte[] data = fixedData.getByteArrayValue(loop); Table table = factory.createTable(m_file, data, varMeta, varData); container.add(table); //System.out.println(table); } }
Example #8
Source File: MPP14Reader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Read saved view state from an MPP file. * * @throws IOException */ private void processSavedViewState() throws IOException { DirectoryEntry dir = (DirectoryEntry) m_viewDir.getEntry("CEdl"); VarMeta varMeta = new VarMeta12(new DocumentInputStream(((DocumentEntry) dir.getEntry("VarMeta")))); Var2Data varData = new Var2Data(varMeta, new DocumentInputStream(((DocumentEntry) dir.getEntry("Var2Data")))); //System.out.println(varMeta); //System.out.println(varData); InputStream is = new DocumentInputStream(((DocumentEntry) dir.getEntry("FixedData"))); byte[] fixedData = new byte[is.available()]; is.read(fixedData); is.close(); //System.out.println(ByteArrayHelper.hexdump(fixedData, false, 16, "")); ViewStateReader reader = new ViewStateReader12(); reader.process(m_file, varData, fixedData); }
Example #9
Source File: MPP14Reader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Read group definitions. * * @throws IOException */ private void processGroupData() throws IOException { DirectoryEntry dir = (DirectoryEntry) m_viewDir.getEntry("CGrouping"); FixedMeta fixedMeta = new FixedMeta(new DocumentInputStream(((DocumentEntry) dir.getEntry("FixedMeta"))), 10); FixedData fixedData = new FixedData(fixedMeta, m_inputStreamFactory.getInstance(dir, "FixedData")); VarMeta varMeta = new VarMeta12(new DocumentInputStream(((DocumentEntry) dir.getEntry("VarMeta")))); Var2Data varData = new Var2Data(varMeta, new DocumentInputStream(((DocumentEntry) dir.getEntry("Var2Data")))); //System.out.println(fixedMeta); //System.out.println(fixedData); //System.out.println(varMeta); //System.out.println(varData); GroupReader14 reader = new GroupReader14(); reader.process(m_file, fixedData, varData, m_fontBases); }
Example #10
Source File: MPP9Reader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Read saved view state from an MPP file. * * @throws IOException */ private void processSavedViewState() throws IOException { DirectoryEntry dir = (DirectoryEntry) m_viewDir.getEntry("CEdl"); VarMeta varMeta = new VarMeta9(new DocumentInputStream(((DocumentEntry) dir.getEntry("VarMeta")))); Var2Data varData = new Var2Data(varMeta, new DocumentInputStream(((DocumentEntry) dir.getEntry("Var2Data")))); //System.out.println(varMeta); //System.out.println(varData); InputStream is = m_inputStreamFactory.getInstance(dir, "FixedData"); byte[] fixedData = new byte[is.available()]; is.read(fixedData); //System.out.println(ByteArrayHelper.hexdump(fixedData, false, 16, "")); ViewStateReader reader = new ViewStateReader9(); reader.process(m_file, varData, fixedData); }
Example #11
Source File: MPP8Reader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * This method extracts view data from the MPP file. * * @throws IOException */ private void processViewData() throws IOException { DirectoryEntry dir = (DirectoryEntry) m_viewDir.getEntry("CV_iew"); FixFix ff = new FixFix(138, new DocumentInputStream(((DocumentEntry) dir.getEntry("FixFix 0")))); int items = ff.getItemCount(); byte[] data; View view; for (int loop = 0; loop < items; loop++) { data = ff.getByteArrayValue(loop); view = new View8(m_file, data); m_file.getViews().add(view); } }
Example #12
Source File: MPP12Reader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * This method extracts table data from the MPP file. * * @throws java.io.IOException */ private void processTableData() throws IOException { DirectoryEntry dir = (DirectoryEntry) m_viewDir.getEntry("CTable"); VarMeta varMeta = new VarMeta12(new DocumentInputStream(((DocumentEntry) dir.getEntry("VarMeta")))); Var2Data varData = new Var2Data(varMeta, new DocumentInputStream(((DocumentEntry) dir.getEntry("Var2Data")))); FixedData fixedData = new FixedData(230, new DocumentInputStream(((DocumentEntry) dir.getEntry("FixedData")))); //System.out.println(varMeta); //System.out.println(varData); //System.out.println(fixedData); TableContainer container = m_file.getTables(); TableFactory factory = new TableFactory(TABLE_COLUMN_DATA_STANDARD, TABLE_COLUMN_DATA_ENTERPRISE, TABLE_COLUMN_DATA_BASELINE); int items = fixedData.getItemCount(); for (int loop = 0; loop < items; loop++) { byte[] data = fixedData.getByteArrayValue(loop); Table table = factory.createTable(m_file, data, varMeta, varData); container.add(table); //System.out.println(table); } }
Example #13
Source File: MPP12Reader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Read filter definitions. * * @throws IOException */ private void processFilterData() throws IOException { DirectoryEntry dir = (DirectoryEntry) m_viewDir.getEntry("CFilter"); FixedMeta fixedMeta = new FixedMeta(new DocumentInputStream(((DocumentEntry) dir.getEntry("FixedMeta"))), 10); FixedData fixedData = new FixedData(fixedMeta, m_inputStreamFactory.getInstance(dir, "FixedData")); VarMeta varMeta = new VarMeta12(new DocumentInputStream(((DocumentEntry) dir.getEntry("VarMeta")))); Var2Data varData = new Var2Data(varMeta, new DocumentInputStream(((DocumentEntry) dir.getEntry("Var2Data")))); //System.out.println(fixedMeta); //System.out.println(fixedData); //System.out.println(varMeta); //System.out.println(varData); FilterReader reader = new FilterReader12(); reader.process(m_file.getProjectProperties(), m_file.getFilters(), fixedData, varData); }
Example #14
Source File: MPP12Reader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Read saved view state from an MPP file. * * @throws IOException */ private void processSavedViewState() throws IOException { DirectoryEntry dir = (DirectoryEntry) m_viewDir.getEntry("CEdl"); VarMeta varMeta = new VarMeta12(new DocumentInputStream(((DocumentEntry) dir.getEntry("VarMeta")))); Var2Data varData = new Var2Data(varMeta, new DocumentInputStream(((DocumentEntry) dir.getEntry("Var2Data")))); //System.out.println(varMeta); //System.out.println(varData); InputStream is = new DocumentInputStream(((DocumentEntry) dir.getEntry("FixedData"))); byte[] fixedData = new byte[is.available()]; is.read(fixedData); is.close(); //System.out.println(ByteArrayHelper.hexdump(fixedData, false, 16, "")); ViewStateReader reader = new ViewStateReader12(); reader.process(m_file, varData, fixedData); }
Example #15
Source File: SummaryInformationSanitiserTest.java From DocBleach with MIT License | 6 votes |
@Test void test1() { // Test an invalid stream, should be ignored Entry entry = mock(Entry.class); doReturn("\005RandomString").when(entry).getName(); assertTrue(instance.test(entry)); verify(instance, never()).sanitizeSummaryInformation(eq(session), (DocumentEntry) any()); // Test a valid stream name, but wrong type (should be ignored) reset(entry); doReturn(SummaryInformation.DEFAULT_STREAM_NAME).when(entry).getName(); assertTrue(instance.test(entry)); verify(instance, never()).sanitizeSummaryInformation(eq(session), (DocumentEntry) any()); reset(instance, entry); // Test a valid SummaryInformation name DocumentEntry docEntry = mock(DocumentEntry.class); doReturn(SummaryInformation.DEFAULT_STREAM_NAME).when(docEntry).getName(); doNothing().when(instance).sanitizeSummaryInformation(session, docEntry); assertTrue(instance.test(docEntry)); verify(instance, atLeastOnce()).sanitizeSummaryInformation(session, docEntry); }
Example #16
Source File: MPP12Reader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Read group definitions. * * @todo Doesn't work correctly with MPP12 files saved by Project 2007 and 2010 * @throws IOException */ private void processGroupData() throws IOException { DirectoryEntry dir = (DirectoryEntry) m_viewDir.getEntry("CGrouping"); FixedMeta fixedMeta = new FixedMeta(new DocumentInputStream(((DocumentEntry) dir.getEntry("FixedMeta"))), 10); FixedData fixedData = new FixedData(fixedMeta, m_inputStreamFactory.getInstance(dir, "FixedData")); VarMeta varMeta = new VarMeta12(new DocumentInputStream(((DocumentEntry) dir.getEntry("VarMeta")))); Var2Data varData = new Var2Data(varMeta, new DocumentInputStream(((DocumentEntry) dir.getEntry("Var2Data")))); // System.out.println(fixedMeta); // System.out.println(fixedData); // System.out.println(varMeta); // System.out.println(varData); GroupReader reader = new GroupReader12(); reader.process(m_file, fixedData, varData, m_fontBases); }
Example #17
Source File: SummaryInformationSanitiser.java From DocBleach with MIT License | 6 votes |
protected void sanitizeSummaryInformation(BleachSession session, DocumentEntry dsiEntry) { if (dsiEntry.getSize() <= 0) { return; } try (DocumentInputStream dis = new DocumentInputStream(dsiEntry)) { PropertySet ps = new PropertySet(dis); // Useful for debugging purposes // LOGGER.debug("PropertySet sections: {}", ps.getSections()); SummaryInformation dsi = new SummaryInformation(ps); sanitizeSummaryInformation(session, dsi); } catch (NoPropertySetStreamException | UnexpectedPropertySetTypeException | IOException e) { LOGGER.error("An error occured while trying to sanitize the document entry", e); } }
Example #18
Source File: SummaryInformationSanitiser.java From DocBleach with MIT License | 6 votes |
@Override public boolean test(Entry entry) { String entryName = entry.getName(); if (!SummaryInformation.DEFAULT_STREAM_NAME.equals(entryName)) { return true; } if (!(entry instanceof DocumentEntry)) { return true; } DocumentEntry dsiEntry = (DocumentEntry) entry; sanitizeSummaryInformation(session, dsiEntry); return true; }
Example #19
Source File: MPP8Reader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * This method process the data held in the props file specific to the * visual appearance of the project data. */ private void processViewPropertyData() throws IOException { Props8 props = new Props8(new DocumentInputStream(((DocumentEntry) m_viewDir.getEntry("Props")))); ProjectProperties properties = m_file.getProjectProperties(); properties.setShowProjectSummaryTask(props.getBoolean(Props.SHOW_PROJECT_SUMMARY_TASK)); }
Example #20
Source File: MPP8Reader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Process the project properties data. */ private void processProjectProperties() throws MPXJException, IOException { Props8 props = new Props8(new DocumentInputStream(((DocumentEntry) m_projectDir.getEntry("Props")))); ProjectPropertiesReader reader = new ProjectPropertiesReader(); reader.process(m_file, props, m_root); }
Example #21
Source File: MPP14Reader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * This method extracts view data from the MPP file. * * @throws java.io.IOException */ private void processViewData() throws IOException { DirectoryEntry dir = (DirectoryEntry) m_viewDir.getEntry("CV_iew"); VarMeta viewVarMeta = new VarMeta12(new DocumentInputStream(((DocumentEntry) dir.getEntry("VarMeta")))); Var2Data viewVarData = new Var2Data(viewVarMeta, new DocumentInputStream(((DocumentEntry) dir.getEntry("Var2Data")))); FixedMeta fixedMeta = new FixedMeta(new DocumentInputStream(((DocumentEntry) dir.getEntry("FixedMeta"))), 10); FixedData fixedData = new FixedData(138, m_inputStreamFactory.getInstance(dir, "FixedData")); int items = fixedMeta.getAdjustedItemCount(); View view; ViewFactory factory = new ViewFactory14(); int lastOffset = -1; for (int loop = 0; loop < items; loop++) { byte[] fm = fixedMeta.getByteArrayValue(loop); int offset = MPPUtility.getShort(fm, 4); if (offset > lastOffset) { byte[] fd = fixedData.getByteArrayValue(fixedData.getIndexFromOffset(offset)); if (fd != null) { view = factory.createView(m_file, fm, fd, viewVarData, m_fontBases); m_file.getViews().add(view); } lastOffset = offset; } } }
Example #22
Source File: MPP14Reader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Read data link definitions. */ private void processDataLinks() throws IOException { DirectoryEntry dir = (DirectoryEntry) m_viewDir.getEntry("CEdl"); FixedMeta fixedMeta = new FixedMeta(new DocumentInputStream(((DocumentEntry) dir.getEntry("FixedMeta"))), 11); FixedData fixedData = new FixedData(fixedMeta, m_inputStreamFactory.getInstance(dir, "FixedData")); VarMeta varMeta = new VarMeta12(new DocumentInputStream(((DocumentEntry) dir.getEntry("VarMeta")))); Var2Data varData = new Var2Data(varMeta, new DocumentInputStream(((DocumentEntry) dir.getEntry("Var2Data")))); DataLinkFactory factory = new DataLinkFactory(m_file, fixedData, varData); factory.process(); }
Example #23
Source File: MPP12Reader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * This method extracts view data from the MPP file. * * @throws java.io.IOException */ private void processViewData() throws IOException { DirectoryEntry dir = (DirectoryEntry) m_viewDir.getEntry("CV_iew"); VarMeta viewVarMeta = new VarMeta12(new DocumentInputStream(((DocumentEntry) dir.getEntry("VarMeta")))); Var2Data viewVarData = new Var2Data(viewVarMeta, new DocumentInputStream(((DocumentEntry) dir.getEntry("Var2Data")))); FixedMeta fixedMeta = new FixedMeta(new DocumentInputStream(((DocumentEntry) dir.getEntry("FixedMeta"))), 10); FixedData fixedData = new FixedData(138, m_inputStreamFactory.getInstance(dir, "FixedData")); int items = fixedMeta.getAdjustedItemCount(); View view; ViewFactory factory = new ViewFactory12(); int lastOffset = -1; for (int loop = 0; loop < items; loop++) { byte[] fm = fixedMeta.getByteArrayValue(loop); int offset = MPPUtility.getShort(fm, 4); if (offset > lastOffset) { byte[] fd = fixedData.getByteArrayValue(fixedData.getIndexFromOffset(offset)); if (fd != null) { view = factory.createView(m_file, fm, fd, viewVarData, m_fontBases); m_file.getViews().add(view); } lastOffset = offset; } } }
Example #24
Source File: MPP12Reader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Read data link definitions. */ private void processDataLinks() throws IOException { DirectoryEntry dir = (DirectoryEntry) m_viewDir.getEntry("CEdl"); FixedMeta fixedMeta = new FixedMeta(new DocumentInputStream(((DocumentEntry) dir.getEntry("FixedMeta"))), 11); FixedData fixedData = new FixedData(fixedMeta, m_inputStreamFactory.getInstance(dir, "FixedData")); VarMeta varMeta = new VarMeta12(new DocumentInputStream(((DocumentEntry) dir.getEntry("VarMeta")))); Var2Data varData = new Var2Data(varMeta, new DocumentInputStream(((DocumentEntry) dir.getEntry("Var2Data")))); DataLinkFactory factory = new DataLinkFactory(m_file, fixedData, varData); factory.process(); }
Example #25
Source File: MPPReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * This method allows us to peek into the OLE compound document to extract the file format. * This allows the UniversalProjectReader to determine if this is an MPP file, or if * it is another type of OLE compound document. * * @param fs POIFSFileSystem instance * @return file format name * @throws IOException */ public static String getFileFormat(POIFSFileSystem fs) throws IOException { String fileFormat = ""; DirectoryEntry root = fs.getRoot(); if (root.getEntryNames().contains("\1CompObj")) { CompObj compObj = new CompObj(new DocumentInputStream((DocumentEntry) root.getEntry("\1CompObj"))); fileFormat = compObj.getFileFormat(); } return fileFormat; }
Example #26
Source File: ObjectRemover.java From DocBleach with MIT License | 5 votes |
@Override public boolean test(Entry entry) { String entryName = entry.getName(); if (!isObject(entryName)) { return true; } LOGGER.info("Found Compound Objects, removing them."); StringBuilder infos = new StringBuilder(); if (entry instanceof DirectoryEntry) { Set<String> entryNames = ((DirectoryEntry) entry).getEntryNames(); LOGGER.trace("Compound Objects' entries: {}", entryNames); infos.append("Entries: ").append(entryNames); } else if (entry instanceof DocumentEntry) { int size = ((DocumentEntry) entry).getSize(); infos.append("Size: ").append(size); } Threat threat = Threat.builder() .type(ThreatType.EXTERNAL_CONTENT) .severity(ThreatSeverity.HIGH) .action(ThreatAction.REMOVE) .location(entryName) .details(infos.toString()) .build(); session.recordThreat(threat); return false; }
Example #27
Source File: MacroRemover.java From DocBleach with MIT License | 5 votes |
@Override public boolean test(Entry entry) { String entryName = entry.getName(); // Matches _VBA_PROJECT_CUR, VBA, ... :) if (!isMacro(entryName)) { return true; } LOGGER.info("Found Macros, removing them."); StringBuilder infos = new StringBuilder(); if (entry instanceof DirectoryEntry) { Set<String> entryNames = ((DirectoryEntry) entry).getEntryNames(); LOGGER.trace("Macros' entries: {}", entryNames); infos.append("Entries: ").append(entryNames); } else if (entry instanceof DocumentEntry) { int size = ((DocumentEntry) entry).getSize(); infos.append("Size: ").append(size); } Threat threat = Threat.builder() .type(ThreatType.ACTIVE_CONTENT) .severity(ThreatSeverity.EXTREME) .action(ThreatAction.REMOVE) .location(entryName) .details(infos.toString()) .build(); session.recordThreat(threat); return false; }
Example #28
Source File: XlsReader.java From dremio-oss with Apache License 2.0 | 5 votes |
/** * returns a {@link BlockStoreInputStream} that exposes all workbook sectors in their correct order * * @param is XLS InputStream * @return {@link BlockStoreInputStream} that wraps the workbook's stream * * @throws IOException if the data doesn't contain a proper MS-CFB header * @throws OldExcelFormatException if the file is too old to be supported */ static InputStream createWorkbookInputStream(final XlsInputStream is) throws IOException { final XlsReader xlsReader = new XlsReader(is); DocumentEntry workBookEntry = xlsReader.getWorkbookEntry(); DocumentNode workbookNode = (DocumentNode) workBookEntry; // use proper blockStore final boolean useMiniStore = workbookNode.getSize() < POIFSConstants.BIG_BLOCK_MINIMUM_DOCUMENT_SIZE; final BlockStore blockStore = useMiniStore ? xlsReader.miniStore : xlsReader.difats; return new BlockStoreInputStream(is, blockStore, workbookNode.getProperty().getStartBlock()); }
Example #29
Source File: CompoundOleUtil.java From jackcess with Apache License 2.0 | 5 votes |
private List<Entry> getEntries(List<Entry> entries, DirectoryEntry dir, String prefix) { for(org.apache.poi.poifs.filesystem.Entry entry : dir) { if (entry instanceof DirectoryEntry) { // .. recurse into this directory getEntries(entries, (DirectoryEntry)entry, prefix + ENTRY_SEPARATOR); } else if(entry instanceof DocumentEntry) { // grab the entry name/detils DocumentEntry de = (DocumentEntry)entry; String entryName = prefix + encodeEntryName(entry.getName()); entries.add(new EntryImpl(entryName, de)); } } return entries; }
Example #30
Source File: OleBlobTest.java From jackcess with Apache License 2.0 | 5 votes |
private static void checkCompoundStorage(OleBlob.CompoundContent cc, Attachment attach) throws Exception { File tmpData = File.createTempFile("attach_", ".dat"); try { FileOutputStream fout = new FileOutputStream(tmpData); fout.write(attach.getFileData()); fout.close(); POIFSFileSystem attachFs = new POIFSFileSystem(tmpData, true); for(OleBlob.CompoundContent.Entry e : cc) { DocumentEntry attachE = null; try { attachE = CompoundOleUtil.getDocumentEntry(e.getName(), attachFs.getRoot()); } catch(FileNotFoundException fnfe) { // ignored, the ole data has extra entries continue; } byte[] attachEBytes = toByteArray(new DocumentInputStream(attachE), attachE.getSize()); byte[] entryBytes = toByteArray(e.getStream(), e.length()); assertTrue(Arrays.equals(attachEBytes, entryBytes)); } ByteUtil.closeQuietly(attachFs); } finally { tmpData.delete(); } }