poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1142871 - /poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Table.java
Date Tue, 05 Jul 2011 01:40:40 GMT
Author: sergey
Date: Tue Jul  5 01:40:39 2011
New Revision: 1142871

URL: http://svn.apache.org/viewvc?rev=1142871&view=rev
Log:
allow user to check table level from Table class (not only from Paragraph), so table processing
code is simplified

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Table.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Table.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Table.java?rev=1142871&r1=1142870&r2=1142871&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Table.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Table.java Tue Jul  5 01:40:39
2011
@@ -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 );
+    }
 
-    while (rowEnd < numParagraphs)
+    public int getTableLevel()
     {
-      Paragraph p = getParagraph(rowEnd);
-      rowEnd++;
-      if (p.isTableRowEnd() && p.getTableLevel() == levelNum)
-      {
-        _rows.add(new TableRow(rowStart, rowEnd, this, levelNum));
-        rowStart = rowEnd;
-      }
+        return _tableLevel;
     }
-  }
 
-  public int numRows()
-  {
-    return _rows.size();
-  }
-
-  public int type()
-  {
-    return TYPE_TABLE;
-  }
-
-  public TableRow getRow(int index)
-  {
-    return (TableRow)_rows.get(index);
-  }
-}
+    public int numRows()
+    {
+        return _rows.size();
+    }
+
+    public int type()
+    {
+        return TYPE_TABLE;
+    }
+}
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message