public ProjectFile read(POIFSFileSystem fs) throws MPXJException
{
try
{
ProjectFile projectFile = new ProjectFile();
projectFile.addProjectListeners(m_projectListeners);
projectFile.setAutoTaskID(false);
projectFile.setAutoTaskUniqueID(false);
projectFile.setAutoResourceID(false);
projectFile.setAutoResourceUniqueID(false);
projectFile.setAutoOutlineLevel(false);
projectFile.setAutoOutlineNumber(false);
projectFile.setAutoWBS(false);
projectFile.setAutoCalendarUniqueID(false);
projectFile.setAutoAssignmentUniqueID(false);
//
// Open the file system and retrieve the root directory
//
DirectoryEntry root = fs.getRoot();
//
// Retrieve the CompObj data, validate the file format and process
//
CompObj compObj = new CompObj(new DocumentInputStream((DocumentEntry) root.getEntry("\1CompObj")));
String format = compObj.getFileFormat();
Class<? extends MPPVariantReader> readerClass = FILE_CLASS_MAP.get(format);
if (readerClass == null)
{
throw new MPXJException(MPXJException.INVALID_FILE + ": " + format);
}
MPPVariantReader reader = readerClass.newInstance();
reader.process(this, projectFile, root);
//
// Update the internal structure. We'll take this opportunity to
// generate outline numbers for the tasks as they don't appear to
// be present in the MPP file.
//
projectFile.setAutoOutlineNumber(true);
projectFile.updateStructure();
projectFile.setAutoOutlineNumber(false);
//
// Perform post-processing to set the summary flag and clean
// up any instances where a task has an empty splits list.
//
for (Task task : projectFile.getAllTasks())
{
task.setSummary(task.getChildTasks().size() != 0);
List<DateRange> splits = task.getSplits();
if (splits != null && splits.isEmpty())
{
task.setSplits(null);
}
validationRelations(task);
}
//
// Ensure that the unique ID counters are correct
//
projectFile.updateUniqueCounters();
return (projectFile);
}
catch (IOException ex)