]> source.dussan.org Git - poi.git/commitdiff
Fixed compiler warnings / simplified code
authorJosh Micich <josh@apache.org>
Thu, 30 Oct 2008 17:56:34 +0000 (17:56 +0000)
committerJosh Micich <josh@apache.org>
Thu, 30 Oct 2008 17:56:34 +0000 (17:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@709217 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java

index cfa6afc77ee43e6a109df81f1e90755d227995c8..1e5eac38c2860eb2024c43ccdfb1a8db6d552076 100644 (file)
@@ -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 <em>next<em> 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);
     }
 
     /**