Java Code Examples for org.apache.poi.poifs.filesystem.DirectoryEntry#getEntry()

The following examples show how to use org.apache.poi.poifs.filesystem.DirectoryEntry#getEntry() . 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 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 2
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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 10
Source File: PropertySet.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes a property set to a document in a POI filesystem directory.
 *
 * @param dir The directory in the POI filesystem to write the document to.
 * @param name The document's name. If there is already a document with the
 * same name in the directory the latter will be overwritten.
 *
 * @throws WritingNotSupportedException if the filesystem doesn't support writing
 * @throws IOException if the old entry can't be deleted or the new entry be written
 */
public void write(final DirectoryEntry dir, final String name)
throws WritingNotSupportedException, IOException {
    /* If there is already an entry with the same name, remove it. */
    if (dir.hasEntry(name)) {
        final Entry e = dir.getEntry(name);
        e.delete();
    }

    /* Create the new entry. */
    dir.createDocument(name, toInputStream());
}
 
Example 11
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 12
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 13
Source File: MPP8Reader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Populate member data used by the rest of the reader.
 *
 * @param reader parent file reader
 * @param file parent MPP file
 * @param root Root of the POI file system.
 */
private void populateMemberData(MPPReader reader, ProjectFile file, DirectoryEntry root) throws IOException
{
   m_reader = reader;
   m_root = root;
   m_file = file;
   m_eventManager = file.getEventManager();

   m_calendarMap = new HashMap<>();
   m_projectDir = (DirectoryEntry) root.getEntry("   1");
   m_viewDir = (DirectoryEntry) root.getEntry("   2");

   m_file.getProjectProperties().setMppFileType(Integer.valueOf(8));
}
 
Example 14
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 15
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 16
Source File: ProjectCleanUtility.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Extract a file from within an MPP file.
 *
 * @param parentDirectory parent directory
 * @param fileName file name
 * @return file data
 */
private byte[] extractFile(DirectoryEntry parentDirectory, String fileName) throws IOException
{
   DocumentEntry targetFile = (DocumentEntry) parentDirectory.getEntry(fileName);
   DocumentInputStream dis = new DocumentInputStream(targetFile);
   int dataSize = dis.available();
   byte[] data = new byte[dataSize];
   dis.read(data);
   dis.close();
   targetFile.delete();
   return data;
}
 
Example 17
Source File: MPP9Reader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Populate member data used by the rest of the reader.
 *
 * @param reader parent file reader
 * @param file parent MPP file
 * @param root Root of the POI file system.
 */
private void populateMemberData(MPPReader reader, ProjectFile file, DirectoryEntry root) throws MPXJException, IOException
{
   m_reader = reader;
   m_file = file;
   m_eventManager = file.getEventManager();
   m_root = root;

   //
   // Retrieve the high level document properties (never encoded)
   //
   Props9 props9 = new Props9(new DocumentInputStream(((DocumentEntry) root.getEntry("Props9"))));
   //System.out.println(props9);

   file.getProjectProperties().setProjectFilePath(props9.getUnicodeString(Props.PROJECT_FILE_PATH));
   m_inputStreamFactory = new DocumentInputStreamFactory(props9);

   //
   // Test for password protection. In the single byte retrieved here:
   //
   // 0x00 = no password
   // 0x01 = protection password has been supplied
   // 0x02 = write reservation password has been supplied
   // 0x03 = both passwords have been supplied
   byte passwordProtectionFlag = props9.getByte(Props.PASSWORD_FLAG);
   boolean passwordRequiredToRead = (passwordProtectionFlag & 0x1) != 0;
   //boolean passwordRequiredToWrite = (passwordProtectionFlag & 0x2) != 0;

   if (passwordRequiredToRead && reader.getRespectPasswordProtection())
   {
      // File is password protected for reading, let's read the password
      // and see if the correct read password was given to us.
      String readPassword = MPPUtility.decodePassword(props9.getByteArray(Props.PROTECTION_PASSWORD_HASH), m_inputStreamFactory.getEncryptionCode());
      // It looks like it is possible for a project file to have the password protection flag on without a password. In
      // this case MS Project treats the file as NOT protected. We need to do the same. It is worth noting that MS Project does
      // correct the problem if the file is re-saved (at least it did for me).
      if (readPassword != null && readPassword.length() > 0)
      {
         // See if the correct read password was given
         if (reader.getReadPassword() == null || reader.getReadPassword().matches(readPassword) == false)
         {
            // Passwords don't match
            throw new MPXJException(MPXJException.PASSWORD_PROTECTED_ENTER_PASSWORD);
         }
      }
      // Passwords matched so let's allow the reading to continue.
   }

   m_resourceMap = new HashMap<>();
   m_projectDir = (DirectoryEntry) root.getEntry("   19");
   m_viewDir = (DirectoryEntry) root.getEntry("   29");
   DirectoryEntry outlineCodeDir = (DirectoryEntry) m_projectDir.getEntry("TBkndOutlCode");
   VarMeta outlineCodeVarMeta = new VarMeta9(new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("VarMeta"))));
   m_outlineCodeVarData = new Var2Data(outlineCodeVarMeta, new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("Var2Data"))));
   m_projectProps = new Props9(m_inputStreamFactory.getInstance(m_projectDir, "Props"));
   //MPPUtility.fileDump("c:\\temp\\props.txt", m_projectProps.toString().getBytes());

   m_fontBases = new HashMap<>();
   m_taskSubProjects = new HashMap<>();
   m_taskOrder = new TreeMap<>();
   m_nullTaskOrder = new TreeMap<>();

   m_file.getProjectProperties().setMppFileType(Integer.valueOf(9));
   m_file.getProjectProperties().setAutoFilter(props9.getBoolean(Props.AUTO_FILTER));
}
 
Example 18
Source File: MPP12Reader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Populate member data used by the rest of the reader.
 *
 * @param reader parent file reader
 * @param file parent MPP file
 * @param root Root of the POI file system.
 */
private void populateMemberData(MPPReader reader, ProjectFile file, DirectoryEntry root) throws MPXJException, IOException
{
   m_reader = reader;
   m_file = file;
   m_eventManager = file.getEventManager();
   m_root = root;

   //
   // Retrieve the high level document properties
   //
   Props12 props12 = new Props12(new DocumentInputStream(((DocumentEntry) root.getEntry("Props12"))));
   //System.out.println(props12);

   file.getProjectProperties().setProjectFilePath(props12.getUnicodeString(Props.PROJECT_FILE_PATH));
   m_inputStreamFactory = new DocumentInputStreamFactory(props12);

   //
   // Test for password protection. In the single byte retrieved here:
   //
   // 0x00 = no password
   // 0x01 = protection password has been supplied
   // 0x02 = write reservation password has been supplied
   // 0x03 = both passwords have been supplied
   //
   byte passwordProtectionFlag = props12.getByte(Props.PASSWORD_FLAG);
   boolean passwordRequiredToRead = (passwordProtectionFlag & 0x1) != 0;
   //boolean passwordRequiredToWrite = (passwordProtectionFlag & 0x2) != 0;

   if (passwordRequiredToRead)
   {
      // Couldn't figure out how to get the password for MPP12 files so for now we just need to block the reading
      throw new MPXJException(MPXJException.PASSWORD_PROTECTED);
   }

   m_resourceMap = new HashMap<>();
   m_projectDir = (DirectoryEntry) root.getEntry("   112");
   m_viewDir = (DirectoryEntry) root.getEntry("   212");
   DirectoryEntry outlineCodeDir = (DirectoryEntry) m_projectDir.getEntry("TBkndOutlCode");
   m_outlineCodeVarMeta = new VarMeta12(new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("VarMeta"))));
   m_outlineCodeVarData = new Var2Data(m_outlineCodeVarMeta, new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("Var2Data"))));
   m_outlineCodeFixedMeta = new FixedMeta(new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("FixedMeta"))), 10);
   m_outlineCodeFixedData = new FixedData(m_outlineCodeFixedMeta, new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("FixedData"))));
   m_outlineCodeFixedMeta2 = new FixedMeta(new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("Fixed2Meta"))), 10);
   m_outlineCodeFixedData2 = new FixedData(m_outlineCodeFixedMeta2, new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("Fixed2Data"))));
   m_projectProps = new Props12(m_inputStreamFactory.getInstance(m_projectDir, "Props"));

   //MPPUtility.fileDump("c:\\temp\\props.txt", m_projectProps.toString().getBytes());

   m_fontBases = new HashMap<>();
   m_taskSubProjects = new HashMap<>();
   m_taskOrder = new TreeMap<>();
   m_nullTaskOrder = new TreeMap<>();

   m_file.getProjectProperties().setMppFileType(Integer.valueOf(12));
   m_file.getProjectProperties().setAutoFilter(props12.getBoolean(Props.AUTO_FILTER));
}
 
Example 19
Source File: MPP14CalendarFactory.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override protected VarMeta getCalendarVarMeta(DirectoryEntry directory) throws IOException
{
   return new VarMeta12(new DocumentInputStream(((DocumentEntry) directory.getEntry("VarMeta"))));
}
 
Example 20
Source File: MPP14Reader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Populate member data used by the rest of the reader.
 *
 * @param reader parent file reader
 * @param file parent MPP file
 * @param root Root of the POI file system.
 */
private void populateMemberData(MPPReader reader, ProjectFile file, DirectoryEntry root) throws FileNotFoundException, IOException, MPXJException
{
   m_reader = reader;
   m_file = file;
   m_eventManager = file.getEventManager();
   m_root = root;

   //
   // Retrieve the high level document properties
   //
   Props14 props14 = new Props14(new DocumentInputStream(((DocumentEntry) root.getEntry("Props14"))));
   //System.out.println(props14);

   file.getProjectProperties().setProjectFilePath(props14.getUnicodeString(Props.PROJECT_FILE_PATH));
   m_inputStreamFactory = new DocumentInputStreamFactory(props14);

   //
   // Test for password protection. In the single byte retrieved here:
   //
   // 0x00 = no password
   // 0x01 = protection password has been supplied
   // 0x02 = write reservation password has been supplied
   // 0x03 = both passwords have been supplied
   //
   byte passwordProtectionFlag = props14.getByte(Props.PASSWORD_FLAG);
   boolean passwordRequiredToRead = (passwordProtectionFlag & 0x1) != 0;
   //boolean passwordRequiredToWrite = (passwordProtectionFlag & 0x2) != 0;

   if (passwordRequiredToRead)
   {
      // Couldn't figure out how to get the password for MPP14 files so for now we just need to block the reading
      throw new MPXJException(MPXJException.PASSWORD_PROTECTED);
   }

   m_resourceMap = new HashMap<>();
   m_projectDir = (DirectoryEntry) root.getEntry("   114");
   m_viewDir = (DirectoryEntry) root.getEntry("   214");
   DirectoryEntry outlineCodeDir = (DirectoryEntry) m_projectDir.getEntry("TBkndOutlCode");
   m_outlineCodeVarMeta = new VarMeta12(new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("VarMeta"))));
   m_outlineCodeVarData = new Var2Data(m_outlineCodeVarMeta, new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("Var2Data"))));
   m_outlineCodeFixedMeta = new FixedMeta(new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("FixedMeta"))), 10);
   m_outlineCodeFixedData = new FixedData(m_outlineCodeFixedMeta, new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("FixedData"))));
   m_outlineCodeFixedMeta2 = new FixedMeta(new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("Fixed2Meta"))), 10);
   m_outlineCodeFixedData2 = new FixedData(m_outlineCodeFixedMeta2, new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("Fixed2Data"))));
   m_projectProps = new Props14(m_inputStreamFactory.getInstance(m_projectDir, "Props"));
   //MPPUtility.fileDump("c:\\temp\\props.txt", m_projectProps.toString().getBytes());
   //FieldMap fm = new FieldMap14(m_file);
   //fm.dumpKnownFieldMaps(m_projectProps);

   m_fontBases = new HashMap<>();
   m_taskSubProjects = new HashMap<>();
   m_parentTasks = new HashMap<>();
   m_taskOrder = new TreeMap<>();
   m_nullTaskOrder = new TreeMap<>();

   m_file.getProjectProperties().setMppFileType(Integer.valueOf(14));
   m_file.getProjectProperties().setAutoFilter(props14.getBoolean(Props.AUTO_FILTER));
}