Example #1
0
  /**
   * Extract the view data from the view data block.
   *
   * @param parent parent file
   * @param data view data
   */
  public View8(ProjectFile parent, byte[] data) {
    super(parent);

    m_id = Integer.valueOf(MPPUtility.getInt(data, 0));
    m_name = removeAmpersand(MPPUtility.getUnicodeString(data, 4));
    m_type = ViewType.getInstance(MPPUtility.getShort(data, 116));
  }
Example #2
0
  /**
   * Entry point for processing saved view state.
   *
   * @param file project file
   * @param varData view state var data
   * @param fixedData view state fixed data
   * @throws IOException
   */
  public void process(ProjectFile file, Var2Data varData, byte[] fixedData) throws IOException {
    Props props = getProps(varData);
    // System.out.println(props);
    if (props != null) {
      String viewName = MPPUtility.removeAmpersands(props.getUnicodeString(VIEW_NAME));
      byte[] listData = props.getByteArray(VIEW_CONTENTS);
      List<Integer> uniqueIdList = new LinkedList<Integer>();
      if (listData != null) {
        for (int index = 0; index < listData.length; index += 4) {
          Integer uniqueID = Integer.valueOf(MPPUtility.getInt(listData, index));

          //
          // Ensure that we have a valid task, and that if we have and
          // ID of zero, this is the first task shown.
          //
          if (file.getTaskByUniqueID(uniqueID) != null
              && (uniqueID.intValue() != 0 || index == 0)) {
            uniqueIdList.add(uniqueID);
          }
        }
      }

      int filterID = MPPUtility.getShort(fixedData, 128);

      ViewState state = new ViewState(file, viewName, uniqueIdList, filterID);
      file.getViews().setViewState(state);
    }
  }
  /**
   * The main entry point for processing project header data.
   *
   * @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 {
    // MPPUtility.fileDump("c:\\temp\\props.txt", props.toString().getBytes());
    ProjectHeader ph = file.getProjectHeader();
    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.setCalendarName(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));

    SummaryInformation summary = new SummaryInformation(rootDir);
    ph.setProjectTitle(summary.getProjectTitle());
    ph.setSubject(summary.getSubject());
    ph.setAuthor(summary.getAuthor());
    ph.setKeywords(summary.getKeywords());
    ph.setComments(summary.getComments());
    ph.setCompany(summary.getCompany());
    ph.setManager(summary.getManager());
    ph.setCategory(summary.getCategory());
    ph.setRevision(summary.getRevision());
    ph.setCreationDate(summary.getCreationDate());
    ph.setLastSaved(summary.getLastSaved());
    ph.setDocumentSummaryInformation(summary.getDocumentSummaryInformation());

    ph.setCalculateMultipleCriticalPaths(props.getBoolean(Props.CALCULATE_MULTIPLE_CRITICAL_PATHS));
  }
 /**
  * Converts an integer into a time format.
  *
  * @param format integer format value
  * @return TimeUnit instance
  */
 private TimeUnit getFormat(int format) {
   TimeUnit result;
   if (format == 0xFFFF) {
     result = TimeUnit.HOURS;
   } else {
     result = MPPUtility.getWorkTimeUnits(format);
   }
   return result;
 }
  /**
   * Creates a CostRateTable instance from a block of data.
   *
   * @param resource parent resource
   * @param index cost rate table index
   * @param data data block
   */
  public void process(Resource resource, int index, byte[] data) {
    CostRateTable result = new CostRateTable();

    if (data != null) {
      for (int i = 16; i + 44 <= data.length; i += 44) {
        Rate standardRate = new Rate(MPPUtility.getDouble(data, i), TimeUnit.HOURS);
        TimeUnit standardRateFormat = getFormat(MPPUtility.getShort(data, i + 8));
        Rate overtimeRate = new Rate(MPPUtility.getDouble(data, i + 16), TimeUnit.HOURS);
        TimeUnit overtimeRateFormat = getFormat(MPPUtility.getShort(data, i + 24));
        Double costPerUse = NumberUtility.getDouble(MPPUtility.getDouble(data, i + 32) / 100.0);
        Date endDate = MPPUtility.getTimestampFromTenths(data, i + 40);
        CostRateTableEntry entry =
            new CostRateTableEntry(
                standardRate,
                standardRateFormat,
                overtimeRate,
                overtimeRateFormat,
                costPerUse,
                endDate);
        result.add(entry);
      }
      Collections.sort(result);
    } else {
      //
      // MS Project economises by not actually storing the first cost rate
      // table if it doesn't need to, so we take this into account here.
      //
      if (index == 0) {
        Rate standardRate = resource.getStandardRate();
        Rate overtimeRate = resource.getOvertimeRate();
        Number costPerUse = resource.getCostPerUse();
        CostRateTableEntry entry =
            new CostRateTableEntry(
                standardRate,
                standardRate.getUnits(),
                overtimeRate,
                overtimeRate.getUnits(),
                costPerUse,
                CostRateTableEntry.DEFAULT_ENTRY.getEndDate());
        result.add(entry);
      } else {
        result.add(CostRateTableEntry.DEFAULT_ENTRY);
      }
    }

    resource.setCostRateTable(index, result);
  }