Search in sources :

Example 1 with ColumnInfoRecord

use of org.apache.poi.hssf.record.ColumnInfoRecord in project poi by apache.

the class ColumnInfoRecordsAggregate method getMaxOutlineLevel.

public int getMaxOutlineLevel() {
    int result = 0;
    int count = records.size();
    for (int i = 0; i < count; i++) {
        ColumnInfoRecord columnInfoRecord = getColInfo(i);
        result = Math.max(columnInfoRecord.getOutlineLevel(), result);
    }
    return result;
}
Also used : ColumnInfoRecord(org.apache.poi.hssf.record.ColumnInfoRecord)

Example 2 with ColumnInfoRecord

use of org.apache.poi.hssf.record.ColumnInfoRecord in project poi by apache.

the class ColumnInfoRecordsAggregate method visitContainedRecords.

public void visitContainedRecords(RecordVisitor rv) {
    int nItems = records.size();
    if (nItems < 1) {
        return;
    }
    ColumnInfoRecord cirPrev = null;
    for (int i = 0; i < nItems; i++) {
        ColumnInfoRecord cir = records.get(i);
        rv.visitRecord(cir);
        if (cirPrev != null && CIRComparator.compareColInfos(cirPrev, cir) > 0) {
            // that assumes the column info records are kept in order
            throw new RuntimeException("Column info records are out of order");
        }
        cirPrev = cir;
    }
}
Also used : ColumnInfoRecord(org.apache.poi.hssf.record.ColumnInfoRecord)

Example 3 with ColumnInfoRecord

use of org.apache.poi.hssf.record.ColumnInfoRecord in project poi by apache.

the class ColumnInfoRecordsAggregate method findEndOfColumnOutlineGroup.

private int findEndOfColumnOutlineGroup(int colInfoIndex) {
    // Find the end of the group.
    ColumnInfoRecord columnInfo = records.get(colInfoIndex);
    int level = columnInfo.getOutlineLevel();
    int idx = colInfoIndex;
    while (idx < records.size() - 1) {
        ColumnInfoRecord nextColumnInfo = records.get(idx + 1);
        if (!columnInfo.isAdjacentBefore(nextColumnInfo)) {
            break;
        }
        if (nextColumnInfo.getOutlineLevel() < level) {
            break;
        }
        idx++;
        columnInfo = nextColumnInfo;
    }
    return idx;
}
Also used : ColumnInfoRecord(org.apache.poi.hssf.record.ColumnInfoRecord)

Example 4 with ColumnInfoRecord

use of org.apache.poi.hssf.record.ColumnInfoRecord in project poi by apache.

the class ColumnInfoRecordsAggregate method isColumnGroupCollapsed.

/**
	 * 'Collapsed' state is stored in a single column col info record immediately after the outline group
	 * @param idx
	 * @return true, if the column is collapsed, false otherwise.
	 */
private boolean isColumnGroupCollapsed(int idx) {
    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();
}
Also used : ColumnInfoRecord(org.apache.poi.hssf.record.ColumnInfoRecord)

Example 5 with ColumnInfoRecord

use of org.apache.poi.hssf.record.ColumnInfoRecord in project poi by apache.

the class ColumnInfoRecordsAggregate method isColumnGroupHiddenByParent.

private boolean isColumnGroupHiddenByParent(int idx) {
    // 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;
    }
    return startHidden;
}
Also used : ColumnInfoRecord(org.apache.poi.hssf.record.ColumnInfoRecord)

Aggregations

ColumnInfoRecord (org.apache.poi.hssf.record.ColumnInfoRecord)16 Test (org.junit.Test)2 AssertionFailedError (junit.framework.AssertionFailedError)1