Index: hwpf/usermodel/Range.java =================================================================== RCS file: /home/cvspublic/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java,v retrieving revision 1.6 diff -u -r1.6 Range.java --- hwpf/usermodel/Range.java 23 Mar 2004 05:51:54 -0000 1.6 +++ hwpf/usermodel/Range.java 25 Mar 2004 16:21:30 -0000 @@ -662,15 +662,15 @@ r.initAll(); int tableEnd = r._parEnd; - if (r._parStart != 0 && ((Paragraph)r._paragraphs.get(r._parStart - 1)).isInTable()) + if (r._parStart != 0 && getParagraph(r._parStart - 1).isInTable()) { throw new IllegalArgumentException("This paragraph is not the first one in the table"); } - int limit = r._paragraphs.size(); + int limit = _paragraphs.size(); for (; tableEnd < limit; tableEnd++) { - if (!((Paragraph)r._paragraphs.get(tableEnd)).isInTable()) + if (!getParagraph(tableEnd).isInTable()) { break; } Index: hwpf/usermodel/TableCell.java =================================================================== RCS file: /home/cvspublic/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableCell.java,v retrieving revision 1.2 diff -u -r1.2 TableCell.java --- hwpf/usermodel/TableCell.java 5 Mar 2004 13:07:55 -0000 1.2 +++ hwpf/usermodel/TableCell.java 25 Mar 2004 16:21:30 -0000 @@ -1,16 +1,90 @@ package org.apache.poi.hwpf.usermodel; - public class TableCell extends Range { - int _levelNum; + private int _levelNum; + private TableCellDescriptor _tcd; + private int _leftEdge; + private int _width; - public TableCell(int startIdx, int endIdx, TableRow parent, int levelNum, TableCellDescriptor tcd) + public TableCell(int startIdx, int endIdx, TableRow parent, int levelNum, TableCellDescriptor tcd, int leftEdge, int width) { super(startIdx, endIdx, Range.TYPE_PARAGRAPH, parent); + _tcd = tcd; + _leftEdge = leftEdge; + _width = width; _levelNum = levelNum; } + public boolean isFirstMerged() + { + return _tcd.isFFirstMerged(); + } + + public boolean isMerged() + { + return _tcd.isFMerged(); + } + + public boolean isVertical() + { + return _tcd.isFVertical(); + } + + public boolean isBackward() + { + return _tcd.isFBackward(); + } + + public boolean isRotateFont() + { + return _tcd.isFRotateFont(); + } + + public boolean isVerticallyMerged() + { + return _tcd.isFVertMerge(); + } + + public boolean isFirstVerticallyMerged() + { + return _tcd.isFVertRestart(); + } + + public byte getVertAlign() + { + return _tcd.getVertAlign(); + } + + public BorderCode getBrcTop() + { + return _tcd.getBrcTop(); + } + + public BorderCode getBrcBottom() + { + return _tcd.getBrcBottom(); + } + + public BorderCode getBrcLeft() + { + return _tcd.getBrcLeft(); + } + + public BorderCode getBrcRight() + { + return _tcd.getBrcRight(); + } + + public int getLeftEdge() // twips + { + return _leftEdge; + } + + public int getWidth() // twips + { + return _width; + } } Index: hwpf/usermodel/TableRow.java =================================================================== RCS file: /home/cvspublic/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableRow.java,v retrieving revision 1.2 diff -u -r1.2 TableRow.java --- hwpf/usermodel/TableRow.java 10 Mar 2004 04:18:56 -0000 1.2 +++ hwpf/usermodel/TableRow.java 25 Mar 2004 16:21:30 -0000 @@ -1,6 +1,5 @@ package org.apache.poi.hwpf.usermodel; - import org.apache.poi.hwpf.sprm.TableSprmUncompressor; import org.apache.poi.hwpf.sprm.SprmBuffer; @@ -16,8 +15,8 @@ private final static short SPRM_DYAROWHEIGHT = (short)0x9407; int _levelNum; - TableProperties _tprops; - TableCell[] _cells; + private TableProperties _tprops; + private TableCell[] _cells; public TableRow(int startIdx, int endIdx, Table parent, int levelNum) { @@ -28,17 +27,26 @@ _cells = new TableCell[_tprops.getItcMac()]; int start = 0; - int cellIndex = 0; - for (int x = 0; x < numParagraphs(); x++) + int end = 0; + + for (int cellIndex = 0; cellIndex < _cells.length; cellIndex++) { - Paragraph p = getParagraph(x); + Paragraph p = getParagraph(start); String s = p.text(); - if ((levelNum == 1 && s.charAt(s.length()-1) == TABLE_CELL_MARK) || - p.isEmbeddedCellMark() && p.getTableLevel() == levelNum) + while (! ( (levelNum == 1 && s.charAt(s.length() - 1) == TABLE_CELL_MARK) || + p.isEmbeddedCellMark() && p.getTableLevel() == levelNum)) { - _cells[cellIndex] = new TableCell(start, x+1, this, levelNum, _tprops.getRgtc()[cellIndex]); + end++; + p = getParagraph(end); + s = p.text(); } + _cells[cellIndex] = new TableCell(start, end, this, levelNum, + _tprops.getRgtc()[cellIndex], + _tprops.getRgdxaCenter()[cellIndex], + _tprops.getRgdxaCenter()[cellIndex+1]-_tprops.getRgdxaCenter()[cellIndex]); + end++; + start = end; } } @@ -97,4 +105,13 @@ _papx.updateSprm(SPRM_FTABLEHEADER, (byte)(tableHeader ? 1 : 0)); } + public int numCells() + { + return _cells.length; + } + + public TableCell getCell(int index) + { + return _cells[index]; + } }