PluginProbe
MBE eShip / trunk
MBE eShip vtrunk
2.8.1 trunk 1.0.0 1.1.0 1.1.3 1.2.1 1.2.2 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.7.1 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1.0 2.1.1 2.1.2 2.2.1 All 37 releases
mail-boxes-etc / lib / dompdf / src / FrameDecorator / TableCell.php

TableCell.php in MBE eShip trunk, at lib/dompdf/src/FrameDecorator/TableCell.php

144 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 use Dompdf\FrameDecorator\Block as BlockFrameDecorator;
12
13 /**
14 * Decorates table cells for layout
15 *
16 * @package dompdf
17 */
18 class TableCell extends BlockFrameDecorator
19 {
20
21 protected $_resolved_borders;
22 protected $_content_height;
23
24 //........................................................................
25
26 /**
27 * TableCell constructor.
28 * @param Frame $frame
29 * @param Dompdf $dompdf
30 */
31 function __construct(Frame $frame, Dompdf $dompdf)
32 {
33 parent::__construct($frame, $dompdf);
34 $this->_resolved_borders = [];
35 $this->_content_height = 0;
36 }
37
38 //........................................................................
39
40 function reset()
41 {
42 parent::reset();
43 $this->_resolved_borders = [];
44 $this->_content_height = 0;
45 $this->_frame->reset();
46 }
47
48 /**
49 * @return int
50 */
51 function get_content_height()
52 {
53 return $this->_content_height;
54 }
55
56 /**
57 * @param $height
58 */
59 function set_content_height($height)
60 {
61 $this->_content_height = $height;
62 }
63
64 /**
65 * @param $height
66 */
67 function set_cell_height($height)
68 {
69 $style = $this->get_style();
70 $v_space = (float)$style->length_in_pt(
71 [
72 $style->margin_top,
73 $style->padding_top,
74 $style->border_top_width,
75 $style->border_bottom_width,
76 $style->padding_bottom,
77 $style->margin_bottom
78 ],
79 (float)$style->length_in_pt($style->height)
80 );
81
82 $new_height = $height - $v_space;
83 $style->set_used("height", $new_height);
84
85 if ($new_height > $this->_content_height) {
86 $y_offset = 0;
87
88 // Adjust our vertical alignment
89 switch ($style->vertical_align) {
90 default:
91 case "baseline":
92 // FIXME: this isn't right
93
94 case "top":
95 // Don't need to do anything
96 return;
97
98 case "middle":
99 $y_offset = ($new_height - $this->_content_height) / 2;
100 break;
101
102 case "bottom":
103 $y_offset = $new_height - $this->_content_height;
104 break;
105 }
106
107 if ($y_offset) {
108 // Move our children
109 foreach ($this->get_line_boxes() as $line) {
110 foreach ($line->get_frames() as $frame) {
111 $frame->move(0, $y_offset);
112 }
113 }
114 }
115 }
116 }
117
118 /**
119 * @param $side
120 * @param $border_spec
121 */
122 function set_resolved_border($side, $border_spec)
123 {
124 $this->_resolved_borders[$side] = $border_spec;
125 }
126
127 /**
128 * @param $side
129 * @return mixed
130 */
131 function get_resolved_border($side)
132 {
133 return $this->_resolved_borders[$side];
134 }
135
136 /**
137 * @return array
138 */
139 function get_resolved_borders()
140 {
141 return $this->_resolved_borders;
142 }
143 }
144