org.apache.poi.poifs.filesystem.DocumentInputStream Java Examples

The following examples show how to use org.apache.poi.poifs.filesystem.DocumentInputStream. 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: SummaryInformationSanitiser.java    From DocBleach with MIT License 6 votes vote down vote up
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 #2
Source File: MPP9Reader.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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: MPP12Reader.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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 #12
Source File: MPP8Reader.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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 #13
Source File: StandardDecryptor.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
@SuppressWarnings("resource")
public InputStream getDataStream(DirectoryNode dir) throws IOException {
    DocumentInputStream dis = dir.createDocumentInputStream(DEFAULT_POIFS_ENTRY);

    _length = dis.readLong();

    if(getSecretKey() == null) {
        verifyPassword(null);
    }
    // limit wrong calculated ole entries - (bug #57080)
    // standard encryption always uses aes encoding, so blockSize is always 16 
    // http://stackoverflow.com/questions/3283787/size-of-data-after-aes-encryption
    int blockSize = getEncryptionInfo().getHeader().getCipherAlgorithm().blockSize;
    long cipherLen = (_length/blockSize + 1) * blockSize;
    Cipher cipher = getCipher(getSecretKey());
    
    InputStream boundedDis = new BoundedInputStream(dis, cipherLen);
    return new BoundedInputStream(new CipherInputStream(boundedDis, cipher), _length);
}
 
Example #14
Source File: MPP12Reader.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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 #15
Source File: MPP12Reader.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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 #16
Source File: MPP12Reader.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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 #17
Source File: MPP12Reader.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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 #18
Source File: POIFSReader.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method processPOIFSReaderEvent
 *
 * @param event
 */

@Override
public void processPOIFSReaderEvent(final POIFSReaderEvent event) {
    DocumentInputStream istream = event.getStream();
    POIFSDocumentPath   path    = event.getPath();
    String              name    = event.getName();

    try {
        byte[] data = IOUtils.toByteArray(istream);
        int pathLength = path.length();

        for (int k = 0; k < pathLength; k++) {
            System.out.print("/" + path.getComponent(k));
        }
        System.out.println("/" + name + ": " + data.length + " bytes read");
    } catch (IOException ignored) {
    } finally {
        IOUtils.closeQuietly(istream);
    }
}
 
Example #19
Source File: VBAMacroReader.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private static void readModule(DocumentInputStream dis, String name, ModuleMap modules) throws IOException {
    Module module = modules.get(name);
    // TODO Refactor this to fetch dir then do the rest
    if (module == null) {
        // no DIR stream with offsets yet, so store the compressed bytes for later
        module = new Module();
        modules.put(name, module);
        module.read(dis);
    } else if (module.buf == null) { //if we haven't already read the bytes for the module keyed off this name...
        if (module.offset == null) {
            //This should not happen. bug 59858
            throw new IOException("Module offset for '" + name + "' was never read.");
        }
        // we know the offset already, so decompress immediately on-the-fly
        long skippedBytes = dis.skip(module.offset);
        if (skippedBytes != module.offset) {
            throw new IOException("tried to skip " + module.offset + " bytes, but actually skipped " + skippedBytes + " bytes");
        }
        InputStream stream = new RLEDecompressingInputStream(dis);
        module.read(stream);
        stream.close();
    }
    
}
 
Example #20
Source File: MPP8Reader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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 #21
Source File: MPP12Reader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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 #22
Source File: MPP14Reader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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 #23
Source File: MPP14Reader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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 #24
Source File: MPP12Reader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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 #25
Source File: POIFSDump.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public static void dump(DirectoryEntry root, File parent) throws IOException {
    for(Iterator<Entry> it = root.getEntries(); it.hasNext();){
        Entry entry = it.next();
        if(entry instanceof DocumentNode){
            DocumentNode node = (DocumentNode)entry;
            DocumentInputStream is = new DocumentInputStream(node);
            byte[] bytes = IOUtils.toByteArray(is);
            is.close();

            OutputStream out = new FileOutputStream(new File(parent, node.getName().trim()));
            try {
            	out.write(bytes);
            } finally {
            	out.close();
            }
        } else if (entry instanceof DirectoryEntry){
            DirectoryEntry dir = (DirectoryEntry)entry;
            File file = new File(parent, entry.getName());
            if(!file.exists() && !file.mkdirs()) {
                throw new IOException("Could not create directory " + file);
            }
            dump(dir, file);
        } else {
            System.err.println("Skipping unsupported POIFS entry: " + entry);
        }
    }
}
 
Example #26
Source File: MPP8Reader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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 #27
Source File: MPP9Reader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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"))), 10);
   FixedData fixedData = new FixedData(fixedMeta, 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"))));

   DataLinkFactory factory = new DataLinkFactory(m_file, fixedData, varData);
   factory.process();
}
 
Example #28
Source File: POIFSReaderEvent.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * package scoped constructor
 *
 * @param stream the DocumentInputStream, freshly opened
 * @param path the path of the document
 * @param documentName the name of the document
 */

POIFSReaderEvent(final DocumentInputStream stream,
                 final POIFSDocumentPath path, final String documentName)
{
    this.stream       = stream;
    this.path         = path;
    this.documentName = documentName;
}
 
Example #29
Source File: BinaryRC4Decryptor.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("resource")
public ChunkedCipherInputStream getDataStream(DirectoryNode dir) throws IOException,
        GeneralSecurityException {
    DocumentInputStream dis = dir.createDocumentInputStream(DEFAULT_POIFS_ENTRY);
    length = dis.readLong();
    return new BinaryRC4CipherInputStream(dis, length);
}
 
Example #30
Source File: MPP9Reader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * This method extracts view data from the MPP file.
 *
 * @throws IOException
 */
private void processViewData() throws IOException
{
   DirectoryEntry dir = (DirectoryEntry) m_viewDir.getEntry("CV_iew");
   VarMeta viewVarMeta = new VarMeta9(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(122, m_inputStreamFactory.getInstance(dir, "FixedData"));

   int items = fixedMeta.getAdjustedItemCount();
   View view;
   ViewFactory factory = new ViewFactory9();

   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);
            //System.out.print(view);
         }
         lastOffset = offset;
      }
   }
}