| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package dompdf |
| 4 |
* @link https://github.com/dompdf/dompdf |
| 5 |
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License |
| 6 |
*/ |
| 7 |
namespace Dompdf\FrameDecorator; |
| 8 |
|
| 9 |
use Dompdf\Dompdf; |
| 10 |
use Dompdf\Frame; |
| 11 |
|
| 12 |
/** |
| 13 |
* Table row group decorator |
| 14 |
* |
| 15 |
* Overrides split() method for tbody, thead & tfoot elements |
| 16 |
* |
| 17 |
* @package dompdf |
| 18 |
*/ |
| 19 |
class TableRowGroup extends AbstractFrameDecorator |
| 20 |
{ |
| 21 |
|
| 22 |
/** |
| 23 |
* Class constructor |
| 24 |
* |
| 25 |
* @param Frame $frame Frame to decorate |
| 26 |
* @param Dompdf $dompdf Current dompdf instance |
| 27 |
*/ |
| 28 |
function __construct(Frame $frame, Dompdf $dompdf) |
| 29 |
{ |
| 30 |
parent::__construct($frame, $dompdf); |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Split the row group at the given child and remove all subsequent child |
| 35 |
* rows and all subsequent row groups from the cellmap. |
| 36 |
*/ |
| 37 |
public function split(?Frame $child = null, bool $page_break = false, bool $forced = false): void |
| 38 |
{ |
| 39 |
if (is_null($child)) { |
| 40 |
parent::split($child, $page_break, $forced); |
| 41 |
return; |
| 42 |
} |
| 43 |
|
| 44 |
// Remove child & all subsequent rows from the cellmap |
| 45 |
/** @var Table $parent */ |
| 46 |
$parent = $this->get_parent(); |
| 47 |
$cellmap = $parent->get_cellmap(); |
| 48 |
$iter = $child; |
| 49 |
|
| 50 |
while ($iter) { |
| 51 |
$cellmap->remove_row($iter); |
| 52 |
$iter = $iter->get_next_sibling(); |
| 53 |
} |
| 54 |
|
| 55 |
// Remove all subsequent row groups from the cellmap |
| 56 |
$iter = $this->get_next_sibling(); |
| 57 |
|
| 58 |
while ($iter) { |
| 59 |
$cellmap->remove_row_group($iter); |
| 60 |
$iter = $iter->get_next_sibling(); |
| 61 |
} |
| 62 |
|
| 63 |
// If we are splitting at the first child remove the |
| 64 |
// table-row-group from the cellmap as well |
| 65 |
if ($child === $this->get_first_child()) { |
| 66 |
$cellmap->remove_row_group($this); |
| 67 |
parent::split(null, $page_break, $forced); |
| 68 |
return; |
| 69 |
} |
| 70 |
|
| 71 |
$cellmap->update_row_group($this, $child->get_prev_sibling()); |
| 72 |
parent::split($child, $page_break, $forced); |
| 73 |
} |
| 74 |
} |
| 75 |
|