You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Table.java 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* ====================================================================
  2. Copyright 2002-2004 Apache Software Foundation
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ==================================================================== */
  13. package org.apache.poi.hwpf.usermodel;
  14. import java.util.ArrayList;
  15. public class Table
  16. extends Range
  17. {
  18. ArrayList _rows;
  19. Table(int startIdx, int endIdx, Range parent, int levelNum)
  20. {
  21. super(startIdx, endIdx, Range.TYPE_PARAGRAPH, parent);
  22. _rows = new ArrayList();
  23. int numParagraphs = numParagraphs();
  24. int rowStart = 0;
  25. int rowEnd = 0;
  26. while (rowEnd < numParagraphs)
  27. {
  28. Paragraph p = getParagraph(rowEnd);
  29. rowEnd++;
  30. if (p.isTableRowEnd() && p.getTableLevel() == levelNum)
  31. {
  32. _rows.add(new TableRow(rowStart, rowEnd, this, levelNum));
  33. rowStart = rowEnd;
  34. }
  35. }
  36. }
  37. public int numRows()
  38. {
  39. return _rows.size();
  40. }
  41. public int type()
  42. {
  43. return TYPE_TABLE;
  44. }
  45. public TableRow getRow(int index)
  46. {
  47. return (TableRow)_rows.get(index);
  48. }
  49. }