public void setSectionRenderBox(final TableSectionRenderBox sectionRenderBox) { this.rowSpans.clear(); this.sectionRenderBox = sectionRenderBox; if (this.sectionRenderBox != null) { this.rowModel = sectionRenderBox.getRowModel(); this.bodySection = (sectionRenderBox.getDisplayRole() == TableSectionRenderBox.Role.BODY); } else { this.rowModel = null; this.bodySection = false; } this.rowCount = -1; }
private void assertPageValid(final List<LogicalPageBox> pages, final int page, final long offset) throws Exception { final LogicalPageBox pageBox = pages.get(page); final long pageOffset = pageBox.getPageOffset(); // ModelPrinter.INSTANCE.print(pageBox); final RenderNode[] elementsByNodeType = MatchFactory.findElementsByNodeType(pageBox, LayoutNodeTypes.TYPE_BOX_TABLE_SECTION); Assert.assertEquals(2, elementsByNodeType.length); final TableSectionRenderBox header = (TableSectionRenderBox) elementsByNodeType[0]; Assert.assertEquals(TableSectionRenderBox.Role.HEADER, header.getDisplayRole()); final TableSectionRenderBox body = (TableSectionRenderBox) elementsByNodeType[1]; Assert.assertEquals(TableSectionRenderBox.Role.BODY, body.getDisplayRole()); final RenderNode[] rows = MatchFactory.findElementsByNodeType(body, LayoutNodeTypes.TYPE_BOX_TABLE_ROW); Assert.assertTrue("Have rows on page " + page, rows.length > 0); Assert.assertEquals("Header starts at top of page " + page, pageOffset + offset, header.getY()); Assert.assertEquals( "Row starts after the header on page " + page, header.getY() + header.getHeight(), rows[0].getY()); final RenderNode[] table = MatchFactory.findElementsByNodeType(pageBox, LayoutNodeTypes.TYPE_BOX_TABLE); Assert.assertEquals(1, table.length); final RenderBox box = (RenderBox) table[0]; final RenderNode lastChild = box.getLastChild(); Assert.assertEquals( "Table height extends correctly on page " + page, box.getY() + box.getHeight(), lastChild.getY() + lastChild.getHeight()); }
protected boolean startTableSectionBox(final TableSectionRenderBox box) { if (currentTable == null) { return false; } if (currentTable.getSectionRenderBox() != null) { return true; } currentTable.setSectionRenderBox(box); box.getRowModel().initialize(currentTable.getTable()); return true; }
protected void finishTableSectionBox(final TableSectionRenderBox box) { if (currentTable == null) { return; } if (currentTable.getSectionRenderBox() != box) { return; } final IntList rowSpans = currentTable.rowSpans; int missingRows = 0; for (int i = 0; i < rowSpans.size(); i++) { final int value = rowSpans.get(i); if (missingRows < value) { missingRows = value; } } for (int i = 0; i < missingRows; i += 1) { currentTable.rowModel.addRow(); } box.getRowModel().validateSizes(box); currentTable.setSectionRenderBox(null); }