]> source.dussan.org Git - poi.git/commitdiff
allow user to check table level from Table class (not only from Paragraph), so table...
authorSergey Vladimirov <sergey@apache.org>
Tue, 5 Jul 2011 01:40:39 +0000 (01:40 +0000)
committerSergey Vladimirov <sergey@apache.org>
Tue, 5 Jul 2011 01:40:39 +0000 (01:40 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1142871 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hwpf/usermodel/Table.java

index 4fb4d1636e54cf9a75280b23f96ed5e5e7735151..f676afd1d455e8db7bee26882a72d0a1844a0eb7 100644 (file)
@@ -19,44 +19,51 @@ package org.apache.poi.hwpf.usermodel;
 
 import java.util.ArrayList;
 
-public final class Table
-  extends Range
+public final class Table extends Range
 {
-  ArrayList _rows;
+    private ArrayList<TableRow> _rows;
 
-  Table(int startIdx, int endIdx, Range parent, int levelNum)
-  {
-    super(startIdx, endIdx, Range.TYPE_PARAGRAPH, parent);
-    _rows = new ArrayList();
-    int numParagraphs = numParagraphs();
+    private int _tableLevel;
 
-    int rowStart = 0;
-    int rowEnd = 0;
+    Table( int startIdx, int endIdx, Range parent, int levelNum )
+    {
+        super( startIdx, endIdx, Range.TYPE_PARAGRAPH, parent );
+        _rows = new ArrayList<TableRow>();
+        _tableLevel = levelNum;
+
+        int rowStart = 0;
+        int rowEnd = 0;
+
+        int numParagraphs = numParagraphs();
+        while ( rowEnd < numParagraphs )
+        {
+            Paragraph p = getParagraph( rowEnd );
+            rowEnd++;
+            if ( p.isTableRowEnd() && p.getTableLevel() == levelNum )
+            {
+                _rows.add( new TableRow( rowStart, rowEnd, this, levelNum ) );
+                rowStart = rowEnd;
+            }
+        }
+    }
+
+    public TableRow getRow( int index )
+    {
+        return _rows.get( index );
+    }
+
+    public int getTableLevel()
+    {
+        return _tableLevel;
+    }
+
+    public int numRows()
+    {
+        return _rows.size();
+    }
 
-    while (rowEnd < numParagraphs)
+    public int type()
     {
-      Paragraph p = getParagraph(rowEnd);
-      rowEnd++;
-      if (p.isTableRowEnd() && p.getTableLevel() == levelNum)
-      {
-        _rows.add(new TableRow(rowStart, rowEnd, this, levelNum));
-        rowStart = rowEnd;
-      }
+        return TYPE_TABLE;
     }
-  }
-
-  public int numRows()
-  {
-    return _rows.size();
-  }
-
-  public int type()
-  {
-    return TYPE_TABLE;
-  }
-
-  public TableRow getRow(int index)
-  {
-    return (TableRow)_rows.get(index);
-  }
-}
+}
\ No newline at end of file