1<?php 2// $Header: /cvsroot/html2ps/box.table.section.php,v 1.14 2006/10/28 12:24:16 Konstantin Exp $ 3 4class TableSectionBox extends GenericContainerBox { 5 function &create(&$root, &$pipeline) { 6 $state =& $pipeline->get_current_css_state(); 7 $box =& new TableSectionBox(); 8 $box->readCSS($state); 9 10 // Automatically create at least one table row 11 $row = new TableRowBox(); 12 $row->readCSS($state); 13 $box->add_child($row); 14 15 // Parse table contents 16 $child = $root->first_child(); 17 while ($child) { 18 $child_box =& create_pdf_box($child, $pipeline); 19 $box->add_child($child_box); 20 $child = $child->next_sibling(); 21 }; 22 23 return $box; 24 } 25 26 function TableSectionBox() { 27 $this->GenericContainerBox(); 28 } 29 30 // Overrides default 'add_child' in GenericFormattedBox 31 function add_child(&$item) { 32 // Check if we're trying to add table cell to current table directly, without any table-rows 33 if ($item->isCell()) { 34 // Add cell to the last row 35 $last_row =& $this->content[count($this->content)-1]; 36 $last_row->add_child($item); 37 38 } elseif ($item->isTableRow()) { 39 // If previous row is empty, remove it (get rid of automatically generated table row in constructor) 40 if (count($this->content) > 0) { 41 if (count($this->content[count($this->content)-1]->content) == 0) { 42 array_pop($this->content); 43 } 44 }; 45 46 // Just add passed row 47 $this->content[] =& $item; 48 }; 49 } 50 51 function isTableSection() { 52 return true; 53 } 54} 55?>