From: Sergey Vladimirov Date: Tue, 5 Jul 2011 01:40:39 +0000 (+0000) Subject: allow user to check table level from Table class (not only from Paragraph), so table... X-Git-Tag: REL_3_8_BETA4~325 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=34cae0eb4e4b35e155dbbcbf6afcebc5eb1a7f39;p=poi.git allow user to check table level from Table class (not only from Paragraph), so table processing code is simplified git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1142871 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Table.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Table.java index 4fb4d1636e..f676afd1d4 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Table.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Table.java @@ -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 _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(); + _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