From: Josh Micich Date: Thu, 30 Oct 2008 17:56:34 +0000 (+0000) Subject: Fixed compiler warnings / simplified code X-Git-Tag: trunk_20081106~21 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fa430e285148a1c47667154c7da77f3727c94eed;p=poi.git Fixed compiler warnings / simplified code git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@709217 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java b/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java index cfa6afc77e..1e5eac38c2 100644 --- a/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java +++ b/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java @@ -321,39 +321,38 @@ public final class RowRecordsAggregate extends RecordAggregate { return currentRow-1; } - public int writeHidden( RowRecord rowRecord, int row, boolean hidden ) - { + /** + * Hide all rows at or below the current outline level + * @return index of the next row after the last row that gets hidden + */ + private int writeHidden(RowRecord pRowRecord, int row) { + int rowIx = row; + RowRecord rowRecord = pRowRecord; int level = rowRecord.getOutlineLevel(); - while (rowRecord != null && this.getRow(row).getOutlineLevel() >= level) - { - rowRecord.setZeroHeight( hidden ); - row++; - rowRecord = this.getRow( row ); + while (rowRecord != null && getRow(rowIx).getOutlineLevel() >= level) { + rowRecord.setZeroHeight(true); + rowIx++; + rowRecord = getRow(rowIx); } - return row - 1; + return rowIx; } - public void collapseRow( int rowNumber ) - { + public void collapseRow(int rowNumber) { // Find the start of the group. - int startRow = findStartOfRowOutlineGroup( rowNumber ); - RowRecord rowRecord = getRow( startRow ); + int startRow = findStartOfRowOutlineGroup(rowNumber); + RowRecord rowRecord = getRow(startRow); // Hide all the columns until the end of the group - int lastRow = writeHidden( rowRecord, startRow, true ); + int nextRowIx = writeHidden(rowRecord, startRow); - // Write collapse field - if (getRow(lastRow + 1) != null) - { - getRow(lastRow + 1).setColapsed( true ); - } - else - { - RowRecord row = createRow( lastRow + 1); - row.setColapsed( true ); - insertRow( row ); + RowRecord row = getRow(nextRowIx); + if (row == null) { + row = createRow(nextRowIx); + insertRow(row); } + // Write collapse field + row.setColapsed(true); } /**