PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.24
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.24
1.10.24 1.10.23 1.10.22 1.10.21 1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 All 168 releases
woocommerce-pos / vendor_prefixed / dompdf / dompdf / src / FrameReflower / TableCell.php

TableCell.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.24, at vendor_prefixed/dompdf/dompdf/src/FrameReflower/TableCell.php

124 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * @package dompdf
5 * @link https://github.com/dompdf/dompdf
6 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
7 */
8 namespace WCPOS\Vendor\Dompdf\FrameReflower;
9
10 use WCPOS\Vendor\Dompdf\Exception;
11 use WCPOS\Vendor\Dompdf\FrameDecorator\Block as BlockFrameDecorator;
12 use WCPOS\Vendor\Dompdf\FrameDecorator\Table as TableFrameDecorator;
13 use WCPOS\Vendor\Dompdf\FrameDecorator\TableCell as TableCellFrameDecorator;
14 use WCPOS\Vendor\Dompdf\Helpers;
15 /**
16 * Reflows table cells
17 *
18 * @package dompdf
19 */
20 class TableCell extends Block
21 {
22 /**
23 * TableCell constructor.
24 * @param BlockFrameDecorator $frame
25 */
26 function __construct(BlockFrameDecorator $frame)
27 {
28 parent::__construct($frame);
29 }
30 /**
31 * @param BlockFrameDecorator|null $block
32 */
33 function reflow(?BlockFrameDecorator $block = null)
34 {
35 /** @var TableCellFrameDecorator */
36 $frame = $this->_frame;
37 $table = TableFrameDecorator::find_parent_table($frame);
38 if ($table === null) {
39 throw new Exception("Parent table not found for table cell");
40 }
41 // Counters and generated content
42 $this->_set_content();
43 $style = $frame->get_style();
44 $cellmap = $table->get_cellmap();
45 [$x, $y] = $cellmap->get_frame_position($frame);
46 $frame->set_position($x, $y);
47 $cells = $cellmap->get_spanned_cells($frame);
48 $w = 0;
49 foreach ($cells["columns"] as $i) {
50 $col = $cellmap->get_column($i);
51 $w += $col["used-width"];
52 }
53 //FIXME?
54 $h = $frame->get_containing_block("h");
55 $left_space = (float) $style->length_in_pt([$style->margin_left, $style->padding_left, $style->border_left_width], $w);
56 $right_space = (float) $style->length_in_pt([$style->padding_right, $style->margin_right, $style->border_right_width], $w);
57 $top_space = (float) $style->length_in_pt([$style->margin_top, $style->padding_top, $style->border_top_width], $h);
58 $bottom_space = (float) $style->length_in_pt([$style->margin_bottom, $style->padding_bottom, $style->border_bottom_width], $h);
59 $cb_w = $w - $left_space - $right_space;
60 $style->set_used("width", $cb_w);
61 $content_x = $x + $left_space;
62 $content_y = $line_y = $y + $top_space;
63 // Adjust the first line based on the text-indent property
64 $indent = (float) $style->length_in_pt($style->text_indent, $w);
65 $frame->increase_line_width($indent);
66 $page = $frame->get_root();
67 // Set the y position of the first line in the cell
68 $line_box = $frame->get_current_line_box();
69 $line_box->y = $line_y;
70 // Set the containing blocks and reflow each child
71 foreach ($frame->get_children() as $child) {
72 $child->set_containing_block($content_x, $content_y, $cb_w, $h);
73 $this->process_clear($child);
74 $child->reflow($frame);
75 $this->process_float($child, $content_x, $cb_w);
76 if ($page->is_full()) {
77 break;
78 }
79 }
80 // Determine our height
81 $style_height = (float) $style->length_in_pt($style->height, $h);
82 $content_height = $this->_calculate_content_height();
83 $height = \max($style_height, $content_height);
84 $frame->set_content_height($content_height);
85 // Let the cellmap know our height
86 $cell_height = $height / \count($cells["rows"]);
87 if ($style_height <= $height) {
88 $cell_height += $top_space + $bottom_space;
89 }
90 foreach ($cells["rows"] as $i) {
91 $cellmap->set_row_height($i, $cell_height);
92 }
93 $style->set_used("height", $height);
94 $this->_text_align();
95 $this->vertical_align();
96 // Handle relative positioning
97 foreach ($frame->get_children() as $child) {
98 $this->position_relative($child);
99 }
100 }
101 public function get_min_max_content_width() : array
102 {
103 // Ignore percentage values for a specified width here, as they are
104 // relative to the table width, which is not determined yet
105 $style = $this->_frame->get_style();
106 $width = $style->width;
107 $fixed_width = $width !== "auto" && !Helpers::is_percent($width);
108 [$min, $max] = $this->get_min_max_child_width();
109 // For table cells: Use specified width if it is greater than the
110 // minimum defined by the content
111 if ($fixed_width) {
112 $width = (float) $style->length_in_pt($width, 0);
113 $min = \max($width, $min);
114 $max = $min;
115 }
116 // Handle min/max width style properties
117 $min_width = $this->resolve_min_width(null);
118 $max_width = $this->resolve_max_width(null);
119 $min = Helpers::clamp($min, $min_width, $max_width);
120 $max = Helpers::clamp($max, $min_width, $max_width);
121 return [$min, $max];
122 }
123 }
124