Exemplo n.º 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));
  }
Exemplo n.º 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);
    }
  }
  /**
   * 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);
  }