Package org.apache.poi.hssf.record

Examples of org.apache.poi.hssf.record.ColumnInfoRecord


    }
  }

  private int findStartOfColumnOutlineGroup(int pIdx) {
    // Find the start of the group.
    ColumnInfoRecord columnInfo = (ColumnInfoRecord) records.get(pIdx);
    int level = columnInfo.getOutlineLevel();
    int idx = pIdx;
    while (idx != 0) {
      ColumnInfoRecord prevColumnInfo = (ColumnInfoRecord) records.get(idx - 1);
      if (!prevColumnInfo.isAdjacentBefore(columnInfo)) {
        break;
      }
      if (prevColumnInfo.getOutlineLevel() < level) {
        break;
      }
      idx--;
      columnInfo = prevColumnInfo;
    }
View Full Code Here


    return idx;
  }

  private int findEndOfColumnOutlineGroup(int colInfoIndex) {
    // Find the end of the group.
    ColumnInfoRecord columnInfo = (ColumnInfoRecord) records.get(colInfoIndex);
    int level = columnInfo.getOutlineLevel();
    int idx = colInfoIndex;
    while (idx < records.size() - 1) {
      ColumnInfoRecord nextColumnInfo = (ColumnInfoRecord) records.get(idx + 1);
      if (!columnInfo.isAdjacentBefore(nextColumnInfo)) {
        break;
      }
      if (nextColumnInfo.getOutlineLevel() < level) {
        break;
      }
      idx++;
      columnInfo = nextColumnInfo;
    }
View Full Code Here

    int endOfOutlineGroupIdx = findEndOfColumnOutlineGroup(idx);
    int nextColInfoIx = endOfOutlineGroupIdx+1;
    if (nextColInfoIx >= records.size()) {
      return false;
    }
    ColumnInfoRecord nextColInfo = getColInfo(nextColInfoIx);
    if (!getColInfo(endOfOutlineGroupIdx).isAdjacentBefore(nextColInfo)) {
      return false;
    }
    return nextColInfo.getCollapsed();
  }
View Full Code Here

    // Look out outline details of end
    int endLevel = 0;
    boolean endHidden = false;
    int endOfOutlineGroupIdx = findEndOfColumnOutlineGroup( idx );
    if (endOfOutlineGroupIdx < records.size()) {
      ColumnInfoRecord nextInfo = getColInfo(endOfOutlineGroupIdx + 1);
      if (getColInfo(endOfOutlineGroupIdx).isAdjacentBefore(nextInfo)) {
        endLevel = nextInfo.getOutlineLevel();
        endHidden = nextInfo.getHidden();
      }
    }
    // Look out outline details of start
    int startLevel = 0;
    boolean startHidden = false;
    int startOfOutlineGroupIdx = findStartOfColumnOutlineGroup( idx );
    if (startOfOutlineGroupIdx > 0) {
      ColumnInfoRecord prevInfo = getColInfo(startOfOutlineGroupIdx - 1);
      if (prevInfo.isAdjacentBefore(getColInfo(startOfOutlineGroupIdx))) {
        startLevel = prevInfo.getOutlineLevel();
        startHidden = prevInfo.getHidden();
      }
    }
    if (endLevel > startLevel) {
      return endHidden;
    }
View Full Code Here

      return;
    }

    // Find the start of the group.
    int groupStartColInfoIx = findStartOfColumnOutlineGroup(colInfoIx);
    ColumnInfoRecord columnInfo = getColInfo(groupStartColInfoIx);

    // Hide all the columns until the end of the group
    int lastColIx = setGroupHidden(groupStartColInfoIx, columnInfo.getOutlineLevel(), true);

    // Write collapse field
    setColumn(lastColIx + 1, null, null, null, null, Boolean.TRUE);
  }
View Full Code Here

   * @param pIdx the col info index of the start of the outline group
   * @return the column index of the last column in the outline group
   */
  private int setGroupHidden(int pIdx, int level, boolean hidden) {
    int idx = pIdx;
    ColumnInfoRecord columnInfo = getColInfo(idx);
    while (idx < records.size()) {
      columnInfo.setHidden(hidden);
      if (idx + 1 < records.size()) {
        ColumnInfoRecord nextColumnInfo = getColInfo(idx + 1);
        if (!columnInfo.isAdjacentBefore(nextColumnInfo)) {
          break;
        }
        if (nextColumnInfo.getOutlineLevel() < level) {
          break;
        }
        columnInfo = nextColumnInfo;
      }
      idx++;
View Full Code Here

    // hidden bit gets unset _if_ surrounding groups are expanded you can determine
    //   this by looking at the hidden bit of the enclosing group.  You will have
    //   to look at the start and the end of the current group to determine which
    //   is the enclosing group
    // hidden bit only is altered for this outline level.  ie.  don't uncollapse contained groups
    ColumnInfoRecord columnInfo = getColInfo(endIdx);
    if (!isColumnGroupHiddenByParent(idx)) {
      int outlineLevel = columnInfo.getOutlineLevel();
      for (int i = startIdx; i <= endIdx; i++) {
        ColumnInfoRecord ci = getColInfo(i);
        if (outlineLevel == ci.getOutlineLevel())
          ci.setHidden(false);
      }
    }

    // Write collapse flag (stored in a single col info record after this outline group)
    setColumn(columnInfo.getLastColumn() + 1, null, null, null, null, Boolean.FALSE);
View Full Code Here

  }


  public void setColumn(int targetColumnIx, Short xfIndex, Integer width,
          Integer level, Boolean hidden, Boolean collapsed) {
    ColumnInfoRecord ci = null;
    int k  = 0;

    for (k = 0; k < records.size(); k++) {
      ColumnInfoRecord tci = (ColumnInfoRecord) records.get(k);
      if (tci.containsColumn(targetColumnIx)) {
        ci = tci;
        break;
      }
      if (tci.getFirstColumn() > targetColumnIx) {
        // call column infos after k are for later columns
        break; // exit now so k will be the correct insert pos
      }
    }

    if (ci == null) {
      // okay so there ISN'T a column info record that covers this column so lets create one!
      ColumnInfoRecord nci = new ColumnInfoRecord();

      nci.setFirstColumn(targetColumnIx);
      nci.setLastColumn(targetColumnIx);
      setColumnInfoFields( nci, xfIndex, width, level, hidden, collapsed );
      insertColumn(k, nci);
      attemptMergeColInfoRecords(k);
      return;
    }

    boolean styleChanged = xfIndex != null && ci.getXFIndex() != xfIndex.shortValue();
    boolean widthChanged = width != null && ci.getColumnWidth() != width.shortValue();
    boolean levelChanged = level != null && ci.getOutlineLevel() != level.intValue();
    boolean hiddenChanged = hidden != null && ci.getHidden() != hidden.booleanValue();
    boolean collapsedChanged = collapsed != null && ci.getCollapsed() != collapsed.booleanValue();

    boolean columnChanged = styleChanged || widthChanged || levelChanged || hiddenChanged || collapsedChanged;
    if (!columnChanged) {
      // do nothing...nothing changed.
      return;
    }

    if (ci.getFirstColumn() == targetColumnIx && ci.getLastColumn() == targetColumnIx) {
      // ColumnInfo ci for a single column, the target column
      setColumnInfoFields(ci, xfIndex, width, level, hidden, collapsed);
      attemptMergeColInfoRecords(k);
      return;
    }

    if (ci.getFirstColumn() == targetColumnIx || ci.getLastColumn() == targetColumnIx) {
      // The target column is at either end of the multi-column ColumnInfo ci
      // we'll just divide the info and create a new one
      if (ci.getFirstColumn() == targetColumnIx) {
        ci.setFirstColumn(targetColumnIx + 1);
      } else {
        ci.setLastColumn(targetColumnIx - 1);
        k++; // adjust insert pos to insert after
      }
      ColumnInfoRecord nci = copyColInfo(ci);

      nci.setFirstColumn(targetColumnIx);
      nci.setLastColumn(targetColumnIx);
      setColumnInfoFields( nci, xfIndex, width, level, hidden, collapsed );

      insertColumn(k, nci);
      attemptMergeColInfoRecords(k);
    } else {
      //split to 3 records
      ColumnInfoRecord ciStart = ci;
      ColumnInfoRecord ciMid = copyColInfo(ci);
      ColumnInfoRecord ciEnd = copyColInfo(ci);
      int lastcolumn = ci.getLastColumn();

      ciStart.setLastColumn(targetColumnIx - 1);

      ciMid.setFirstColumn(targetColumnIx);
      ciMid.setLastColumn(targetColumnIx);
      setColumnInfoFields(ciMid, xfIndex, width, level, hidden, collapsed);
      insertColumn(++k, ciMid);

      ciEnd.setFirstColumn(targetColumnIx+1);
      ciEnd.setLastColumn(lastcolumn);
      insertColumn(++k, ciEnd);
      // no need to attemptMergeColInfoRecords because we
      // know both on each side are different
    }
  }
View Full Code Here

    if (fromColInfoIdx < 0) {
      throw new IllegalArgumentException( "fromIdx parameter out of range: " + fromColInfoIdx );
    }

    for (int k = fromColInfoIdx; k < records.size(); k++) {
      ColumnInfoRecord ci = getColInfo(k);
      if (ci.containsColumn(columnIx)) {
        return k;
      }
      if (ci.getFirstColumn() > columnIx) {
        break;
      }
    }
    return -1;
  }
View Full Code Here

    int nRecords = records.size();
    if (colInfoIx < 0 || colInfoIx >= nRecords) {
      throw new IllegalArgumentException("colInfoIx " + colInfoIx
          + " is out of range (0.." + (nRecords-1) + ")");
    }
    ColumnInfoRecord currentCol = getColInfo(colInfoIx);
    int nextIx = colInfoIx+1;
    if (nextIx < nRecords) {
      if (mergeColInfoRecords(currentCol, getColInfo(nextIx))) {
          records.remove(nextIx);
      }
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.ColumnInfoRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.