@@ -1,41 +1,40 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: cellmap.cls.php,v $ |
|
6 | - * Created on: 2004-07-28 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @package dompdf |
|
37 | - |
|
38 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: cellmap.cls.php,v $ |
|
6 | + * Created on: 2004-07-28 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @package dompdf |
|
37 | + */ |
|
39 | 38 | |
40 | 39 | /* $Id: cellmap.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
41 | 40 | |
@@ -50,12 +49,12 @@ discard block |
||
50 | 49 | */ |
51 | 50 | class Cellmap { |
52 | 51 | |
53 | - /** |
|
54 | - * Border style weight lookup for collapsed border resolution. |
|
55 | - * |
|
56 | - * @var array |
|
57 | - */ |
|
58 | - static protected $_BORDER_STYLE_SCORE = array("inset" => 1, |
|
52 | + /** |
|
53 | + * Border style weight lookup for collapsed border resolution. |
|
54 | + * |
|
55 | + * @var array |
|
56 | + */ |
|
57 | + static protected $_BORDER_STYLE_SCORE = array("inset" => 1, |
|
59 | 58 | "groove" => 2, |
60 | 59 | "outset" => 3, |
61 | 60 | "ridge" => 4, |
@@ -65,87 +64,87 @@ discard block |
||
65 | 64 | "double" => 8, |
66 | 65 | "none" => 0); |
67 | 66 | |
68 | - /** |
|
69 | - * The table object this cellmap is attached to. |
|
70 | - * |
|
71 | - * @var Table_Frame_Decorator |
|
72 | - */ |
|
73 | - protected $_table; |
|
74 | - |
|
75 | - /** |
|
76 | - * The total number of rows in the table |
|
77 | - * |
|
78 | - * @var int |
|
79 | - */ |
|
80 | - protected $_num_rows; |
|
81 | - |
|
82 | - /** |
|
83 | - * The total number of columns in the table |
|
84 | - * |
|
85 | - * @var int |
|
86 | - */ |
|
87 | - protected $_num_cols; |
|
88 | - |
|
89 | - /** |
|
90 | - * 2D array mapping <row,column> to frames |
|
91 | - * |
|
92 | - * @var array |
|
93 | - */ |
|
94 | - protected $_cells; |
|
95 | - |
|
96 | - /** |
|
97 | - * 1D array of column dimensions |
|
98 | - * |
|
99 | - * @var array |
|
100 | - */ |
|
101 | - protected $_columns; |
|
102 | - |
|
103 | - /** |
|
104 | - * 1D array of row dimensions |
|
105 | - * |
|
106 | - * @var array |
|
107 | - */ |
|
108 | - protected $_rows; |
|
109 | - |
|
110 | - /** |
|
111 | - * 2D array of border specs |
|
112 | - * |
|
113 | - * @var array |
|
114 | - */ |
|
115 | - protected $_borders; |
|
116 | - |
|
117 | - /** |
|
118 | - * 1D Array mapping frames to (multiple) <row, col> pairs, keyed on |
|
119 | - * frame_id. |
|
120 | - * |
|
121 | - * @var array |
|
122 | - */ |
|
123 | - protected $_frames; |
|
124 | - |
|
125 | - /** |
|
126 | - * Current column when adding cells, 0-based |
|
127 | - * |
|
128 | - * @var int |
|
129 | - */ |
|
130 | - private $__col; |
|
131 | - |
|
132 | - /** |
|
133 | - * Current row when adding cells, 0-based |
|
134 | - * |
|
135 | - * @var int |
|
136 | - */ |
|
137 | - private $__row; |
|
138 | - |
|
139 | - //........................................................................ |
|
140 | - |
|
141 | - function __construct(Table_Frame_Decorator $table) { |
|
67 | + /** |
|
68 | + * The table object this cellmap is attached to. |
|
69 | + * |
|
70 | + * @var Table_Frame_Decorator |
|
71 | + */ |
|
72 | + protected $_table; |
|
73 | + |
|
74 | + /** |
|
75 | + * The total number of rows in the table |
|
76 | + * |
|
77 | + * @var int |
|
78 | + */ |
|
79 | + protected $_num_rows; |
|
80 | + |
|
81 | + /** |
|
82 | + * The total number of columns in the table |
|
83 | + * |
|
84 | + * @var int |
|
85 | + */ |
|
86 | + protected $_num_cols; |
|
87 | + |
|
88 | + /** |
|
89 | + * 2D array mapping <row,column> to frames |
|
90 | + * |
|
91 | + * @var array |
|
92 | + */ |
|
93 | + protected $_cells; |
|
94 | + |
|
95 | + /** |
|
96 | + * 1D array of column dimensions |
|
97 | + * |
|
98 | + * @var array |
|
99 | + */ |
|
100 | + protected $_columns; |
|
101 | + |
|
102 | + /** |
|
103 | + * 1D array of row dimensions |
|
104 | + * |
|
105 | + * @var array |
|
106 | + */ |
|
107 | + protected $_rows; |
|
108 | + |
|
109 | + /** |
|
110 | + * 2D array of border specs |
|
111 | + * |
|
112 | + * @var array |
|
113 | + */ |
|
114 | + protected $_borders; |
|
115 | + |
|
116 | + /** |
|
117 | + * 1D Array mapping frames to (multiple) <row, col> pairs, keyed on |
|
118 | + * frame_id. |
|
119 | + * |
|
120 | + * @var array |
|
121 | + */ |
|
122 | + protected $_frames; |
|
123 | + |
|
124 | + /** |
|
125 | + * Current column when adding cells, 0-based |
|
126 | + * |
|
127 | + * @var int |
|
128 | + */ |
|
129 | + private $__col; |
|
130 | + |
|
131 | + /** |
|
132 | + * Current row when adding cells, 0-based |
|
133 | + * |
|
134 | + * @var int |
|
135 | + */ |
|
136 | + private $__row; |
|
137 | + |
|
138 | + //........................................................................ |
|
139 | + |
|
140 | + function __construct(Table_Frame_Decorator $table) { |
|
142 | 141 | $this->_table = $table; |
143 | 142 | $this->reset(); |
144 | - } |
|
143 | + } |
|
145 | 144 | |
146 | - //........................................................................ |
|
145 | + //........................................................................ |
|
147 | 146 | |
148 | - function reset() { |
|
147 | + function reset() { |
|
149 | 148 | $this->_num_rows = 0; |
150 | 149 | $this->_num_cols = 0; |
151 | 150 | |
@@ -158,54 +157,54 @@ discard block |
||
158 | 157 | $this->_borders = array(); |
159 | 158 | |
160 | 159 | $this->__col = $this->__row = 0; |
161 | - } |
|
160 | + } |
|
162 | 161 | |
163 | - //........................................................................ |
|
162 | + //........................................................................ |
|
164 | 163 | |
165 | - function get_num_rows() { return $this->_num_rows; } |
|
166 | - function get_num_cols() { return $this->_num_cols; } |
|
164 | + function get_num_rows() { return $this->_num_rows; } |
|
165 | + function get_num_cols() { return $this->_num_cols; } |
|
167 | 166 | |
168 | - function &get_columns() { |
|
167 | + function &get_columns() { |
|
169 | 168 | return $this->_columns; |
170 | - } |
|
169 | + } |
|
171 | 170 | |
172 | - function &get_column($i) { |
|
171 | + function &get_column($i) { |
|
173 | 172 | if ( !isset($this->_columns[$i]) ) |
174 | - $this->_columns[$i] = array("x" => 0, |
|
175 | - "min-width" => 0, |
|
176 | - "max-width" => 0, |
|
177 | - "used-width" => null, |
|
178 | - "absolute" => 0, |
|
179 | - "percent" => 0, |
|
180 | - "auto" => true); |
|
173 | + $this->_columns[$i] = array("x" => 0, |
|
174 | + "min-width" => 0, |
|
175 | + "max-width" => 0, |
|
176 | + "used-width" => null, |
|
177 | + "absolute" => 0, |
|
178 | + "percent" => 0, |
|
179 | + "auto" => true); |
|
181 | 180 | |
182 | 181 | return $this->_columns[$i]; |
183 | - } |
|
182 | + } |
|
184 | 183 | |
185 | - function &get_rows() { |
|
184 | + function &get_rows() { |
|
186 | 185 | return $this->_rows; |
187 | - } |
|
186 | + } |
|
188 | 187 | |
189 | - function &get_row($j) { |
|
188 | + function &get_row($j) { |
|
190 | 189 | if ( !isset($this->_rows[$j]) ) |
191 | - $this->_rows[$j] = array("y" => 0, |
|
192 | - "first-column" => 0, |
|
193 | - "height" => null); |
|
190 | + $this->_rows[$j] = array("y" => 0, |
|
191 | + "first-column" => 0, |
|
192 | + "height" => null); |
|
194 | 193 | return $this->_rows[$j]; |
195 | - } |
|
194 | + } |
|
196 | 195 | |
197 | - function get_border($i, $j, $h_v, $prop = null) { |
|
196 | + function get_border($i, $j, $h_v, $prop = null) { |
|
198 | 197 | if ( !isset($this->_borders[$i][$j][$h_v]) ) |
199 | - $this->_borders[$i][$j][$h_v] = array("width" => 0, |
|
200 | - "style" => "solid", |
|
201 | - "color" => "black"); |
|
198 | + $this->_borders[$i][$j][$h_v] = array("width" => 0, |
|
199 | + "style" => "solid", |
|
200 | + "color" => "black"); |
|
202 | 201 | if ( isset($prop) ) |
203 | - return $this->_borders[$i][$j][$h_v][$prop]; |
|
202 | + return $this->_borders[$i][$j][$h_v][$prop]; |
|
204 | 203 | |
205 | 204 | return $this->_borders[$i][$j][$h_v]; |
206 | - } |
|
205 | + } |
|
207 | 206 | |
208 | - function get_border_properties($i, $j) { |
|
207 | + function get_border_properties($i, $j) { |
|
209 | 208 | |
210 | 209 | $left = $this->get_border($i, $j, "vertical"); |
211 | 210 | $right = $this->get_border($i, $j+1, "vertical"); |
@@ -213,119 +212,119 @@ discard block |
||
213 | 212 | $bottom = $this->get_border($i+1, $j, "horizontal"); |
214 | 213 | |
215 | 214 | return compact("top", "bottom", "left", "right"); |
216 | - } |
|
215 | + } |
|
217 | 216 | |
218 | - //........................................................................ |
|
217 | + //........................................................................ |
|
219 | 218 | |
220 | - function get_spanned_cells($frame) { |
|
219 | + function get_spanned_cells($frame) { |
|
221 | 220 | $key = $frame->get_id(); |
222 | 221 | |
223 | 222 | if ( !isset($this->_frames[$key]) ) { |
224 | - throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
223 | + throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
225 | 224 | } |
226 | 225 | |
227 | 226 | return $this->_frames[$key]; |
228 | 227 | |
229 | - } |
|
228 | + } |
|
230 | 229 | |
231 | - function frame_exists_in_cellmap($frame) { |
|
230 | + function frame_exists_in_cellmap($frame) { |
|
232 | 231 | $key = $frame->get_id(); |
233 | 232 | return isset($this->_frames[$key]); |
234 | - } |
|
233 | + } |
|
235 | 234 | |
236 | - function get_frame_position($frame) { |
|
235 | + function get_frame_position($frame) { |
|
237 | 236 | global $_dompdf_warnings; |
238 | 237 | |
239 | 238 | $key = $frame->get_id(); |
240 | 239 | |
241 | 240 | if ( !isset($this->_frames[$key]) ) { |
242 | - throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
241 | + throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
243 | 242 | } |
244 | 243 | |
245 | 244 | $col = $this->_frames[$key]["columns"][0]; |
246 | 245 | $row = $this->_frames[$key]["rows"][0]; |
247 | 246 | |
248 | 247 | if ( !isset($this->_columns[$col])) { |
249 | - $_dompdf_warnings[] = "Frame not found in columns array. Check your table layout for missing or extra TDs."; |
|
250 | - $x = 0; |
|
248 | + $_dompdf_warnings[] = "Frame not found in columns array. Check your table layout for missing or extra TDs."; |
|
249 | + $x = 0; |
|
251 | 250 | } else |
252 | - $x = $this->_columns[$col]["x"]; |
|
251 | + $x = $this->_columns[$col]["x"]; |
|
253 | 252 | |
254 | 253 | if ( !isset($this->_rows[$row])) { |
255 | - $_dompdf_warnings[] = "Frame not found in row array. Check your table layout for missing or extra TDs."; |
|
256 | - $y = 0; |
|
254 | + $_dompdf_warnings[] = "Frame not found in row array. Check your table layout for missing or extra TDs."; |
|
255 | + $y = 0; |
|
257 | 256 | } else |
258 | - $y = $this->_rows[$row]["y"]; |
|
257 | + $y = $this->_rows[$row]["y"]; |
|
259 | 258 | |
260 | 259 | return array($x, $y, "x" => $x, "y" => $y); |
261 | - } |
|
260 | + } |
|
262 | 261 | |
263 | - function get_frame_width($frame) { |
|
262 | + function get_frame_width($frame) { |
|
264 | 263 | $key = $frame->get_id(); |
265 | 264 | |
266 | 265 | if ( !isset($this->_frames[$key]) ) { |
267 | - throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
266 | + throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
268 | 267 | } |
269 | 268 | |
270 | 269 | $cols = $this->_frames[$key]["columns"]; |
271 | 270 | $w = 0; |
272 | 271 | foreach ($cols as $i) |
273 | - $w += $this->_columns[$i]["used-width"]; |
|
272 | + $w += $this->_columns[$i]["used-width"]; |
|
274 | 273 | |
275 | 274 | return $w; |
276 | 275 | |
277 | - } |
|
276 | + } |
|
278 | 277 | |
279 | - function get_frame_height($frame) { |
|
278 | + function get_frame_height($frame) { |
|
280 | 279 | $key = $frame->get_id(); |
281 | 280 | |
282 | 281 | if ( !isset($this->_frames[$key]) ) |
283 | - throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
282 | + throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
284 | 283 | |
285 | 284 | $rows = $this->_frames[$key]["rows"]; |
286 | 285 | $h = 0; |
287 | 286 | foreach ($rows as $i) { |
288 | - if ( !isset($this->_rows[$i]) ) { |
|
287 | + if ( !isset($this->_rows[$i]) ) { |
|
289 | 288 | throw new Exception("foo"); |
290 | - } |
|
291 | - $h += $this->_rows[$i]["height"]; |
|
289 | + } |
|
290 | + $h += $this->_rows[$i]["height"]; |
|
292 | 291 | } |
293 | 292 | return $h; |
294 | 293 | |
295 | - } |
|
294 | + } |
|
296 | 295 | |
297 | 296 | |
298 | - //........................................................................ |
|
297 | + //........................................................................ |
|
299 | 298 | |
300 | - function set_column_width($j, $width) { |
|
299 | + function set_column_width($j, $width) { |
|
301 | 300 | $col =& $this->get_column($j); |
302 | 301 | $col["used-width"] = $width; |
303 | 302 | $next_col =& $this->get_column($j+1); |
304 | 303 | $next_col["x"] = $next_col["x"] + $width; |
305 | - } |
|
304 | + } |
|
306 | 305 | |
307 | - function set_row_height($i, $height) { |
|
306 | + function set_row_height($i, $height) { |
|
308 | 307 | $row =& $this->get_row($i); |
309 | 308 | if ( $height <= $row["height"] ) |
310 | - return; |
|
309 | + return; |
|
311 | 310 | |
312 | 311 | $row["height"] = $height; |
313 | 312 | $next_row =& $this->get_row($i+1); |
314 | 313 | $next_row["y"] = $row["y"] + $height; |
315 | 314 | |
316 | - } |
|
315 | + } |
|
317 | 316 | |
318 | - //........................................................................ |
|
317 | + //........................................................................ |
|
319 | 318 | |
320 | 319 | |
321 | - protected function _resolve_border($i, $j, $h_v, $border_spec) { |
|
320 | + protected function _resolve_border($i, $j, $h_v, $border_spec) { |
|
322 | 321 | $n_width = $border_spec["width"]; |
323 | 322 | $n_style = $border_spec["style"]; |
324 | 323 | $n_color = $border_spec["color"]; |
325 | 324 | |
326 | 325 | if ( !isset($this->_borders[$i][$j][$h_v]) ) { |
327 | - $this->_borders[$i][$j][$h_v] = $border_spec; |
|
328 | - return $this->_borders[$i][$j][$h_v]["width"]; |
|
326 | + $this->_borders[$i][$j][$h_v] = $border_spec; |
|
327 | + return $this->_borders[$i][$j][$h_v]["width"]; |
|
329 | 328 | } |
330 | 329 | |
331 | 330 | $o_width = $this->_borders[$i][$j][$h_v]["width"]; |
@@ -341,14 +340,14 @@ discard block |
||
341 | 340 | ($o_width == $n_width && |
342 | 341 | in_array($n_style, self::$_BORDER_STYLE_SCORE) && |
343 | 342 | self::$_BORDER_STYLE_SCORE[ $n_style ] > self::$_BORDER_STYLE_SCORE[ $o_style ]) ) |
344 | - $this->_borders[$i][$j][$h_v] = $border_spec; |
|
343 | + $this->_borders[$i][$j][$h_v] = $border_spec; |
|
345 | 344 | |
346 | 345 | return $this->_borders[$i][$j][$h_v]["width"]; |
347 | - } |
|
346 | + } |
|
348 | 347 | |
349 | - //........................................................................ |
|
348 | + //........................................................................ |
|
350 | 349 | |
351 | - function add_frame(Frame $frame) { |
|
350 | + function add_frame(Frame $frame) { |
|
352 | 351 | |
353 | 352 | $style = $frame->get_style(); |
354 | 353 | $display = $style->display; |
@@ -361,39 +360,39 @@ discard block |
||
361 | 360 | $display == "inline-table" || |
362 | 361 | in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) { |
363 | 362 | |
364 | - $start_row = $this->__row; |
|
365 | - foreach ( $frame->get_children() as $child ) |
|
363 | + $start_row = $this->__row; |
|
364 | + foreach ( $frame->get_children() as $child ) |
|
366 | 365 | $this->add_frame( $child ); |
367 | 366 | |
368 | - if ( $display == "table-row" ) |
|
367 | + if ( $display == "table-row" ) |
|
369 | 368 | $this->add_row(); |
370 | 369 | |
371 | - $num_rows = $this->__row - $start_row - 1; |
|
372 | - $key = $frame->get_id(); |
|
370 | + $num_rows = $this->__row - $start_row - 1; |
|
371 | + $key = $frame->get_id(); |
|
373 | 372 | |
374 | - // Row groups always span across the entire table |
|
375 | - $this->_frames[ $key ]["columns"] = range(0,max(0,$this->_num_cols-1)); |
|
376 | - $this->_frames[ $key ]["rows"] = range($start_row, max(0, $this->__row - 1)); |
|
377 | - $this->_frames[ $key ]["frame"] = $frame; |
|
373 | + // Row groups always span across the entire table |
|
374 | + $this->_frames[ $key ]["columns"] = range(0,max(0,$this->_num_cols-1)); |
|
375 | + $this->_frames[ $key ]["rows"] = range($start_row, max(0, $this->__row - 1)); |
|
376 | + $this->_frames[ $key ]["frame"] = $frame; |
|
378 | 377 | |
379 | - if ( $display != "table-row" && $collapse ) { |
|
378 | + if ( $display != "table-row" && $collapse ) { |
|
380 | 379 | |
381 | 380 | $bp = $style->get_border_properties(); |
382 | 381 | |
383 | 382 | // Resolve the borders |
384 | 383 | for ( $i = 0; $i < $num_rows+1; $i++) { |
385 | - $this->_resolve_border($start_row + $i, 0, "vertical", $bp["left"]); |
|
386 | - $this->_resolve_border($start_row + $i, $this->_num_cols, "vertical", $bp["right"]); |
|
384 | + $this->_resolve_border($start_row + $i, 0, "vertical", $bp["left"]); |
|
385 | + $this->_resolve_border($start_row + $i, $this->_num_cols, "vertical", $bp["right"]); |
|
387 | 386 | } |
388 | 387 | |
389 | 388 | for ( $j = 0; $j < $this->_num_cols; $j++) { |
390 | - $this->_resolve_border($start_row, $j, "horizontal", $bp["top"]); |
|
391 | - $this->_resolve_border($this->__row, $j, "horizontal", $bp["bottom"]); |
|
389 | + $this->_resolve_border($start_row, $j, "horizontal", $bp["top"]); |
|
390 | + $this->_resolve_border($this->__row, $j, "horizontal", $bp["bottom"]); |
|
391 | + } |
|
392 | 392 | } |
393 | - } |
|
394 | 393 | |
395 | 394 | |
396 | - return; |
|
395 | + return; |
|
397 | 396 | } |
398 | 397 | |
399 | 398 | // Determine where this cell is going |
@@ -401,13 +400,13 @@ discard block |
||
401 | 400 | $rowspan = $frame->get_node()->getAttribute("rowspan"); |
402 | 401 | |
403 | 402 | if ( !$colspan ) { |
404 | - $colspan = 1; |
|
405 | - $frame->get_node()->setAttribute("colspan",1); |
|
403 | + $colspan = 1; |
|
404 | + $frame->get_node()->setAttribute("colspan",1); |
|
406 | 405 | } |
407 | 406 | |
408 | 407 | if ( !$rowspan ) { |
409 | - $rowspan = 1; |
|
410 | - $frame->get_node()->setAttribute("rowspan",1); |
|
408 | + $rowspan = 1; |
|
409 | + $frame->get_node()->setAttribute("rowspan",1); |
|
411 | 410 | } |
412 | 411 | $key = $frame->get_id(); |
413 | 412 | |
@@ -420,60 +419,60 @@ discard block |
||
420 | 419 | // Find the next available column (fix by Ciro Mondueri) |
421 | 420 | $ac = $this->__col; |
422 | 421 | while ( isset($this->_cells[$this->__row][$ac]) ) |
423 | - $ac++; |
|
422 | + $ac++; |
|
424 | 423 | $this->__col = $ac; |
425 | 424 | |
426 | 425 | // Rows: |
427 | 426 | for ( $i = 0; $i < $rowspan; $i++ ) { |
428 | - $row = $this->__row + $i; |
|
427 | + $row = $this->__row + $i; |
|
429 | 428 | |
430 | - $this->_frames[ $key ]["rows"][] = $row; |
|
429 | + $this->_frames[ $key ]["rows"][] = $row; |
|
431 | 430 | |
432 | - for ( $j = 0; $j < $colspan; $j++) |
|
431 | + for ( $j = 0; $j < $colspan; $j++) |
|
433 | 432 | $this->_cells[$row][$this->__col + $j] = $frame; |
434 | 433 | |
435 | - if ( $collapse ) { |
|
434 | + if ( $collapse ) { |
|
436 | 435 | // Resolve vertical borders |
437 | 436 | $max_left = max($max_left, $this->_resolve_border($row, $this->__col, "vertical", $bp["left"])); |
438 | 437 | $max_right = max($max_right, $this->_resolve_border($row, $this->__col + $colspan, "vertical", $bp["right"])); |
439 | - } |
|
438 | + } |
|
440 | 439 | } |
441 | 440 | |
442 | 441 | $max_top = $max_bottom = 0; |
443 | 442 | |
444 | 443 | // Columns: |
445 | 444 | for ( $j = 0; $j < $colspan; $j++ ) { |
446 | - $col = $this->__col + $j; |
|
447 | - $this->_frames[ $key ]["columns"][] = $col; |
|
445 | + $col = $this->__col + $j; |
|
446 | + $this->_frames[ $key ]["columns"][] = $col; |
|
448 | 447 | |
449 | - if ( $collapse ) { |
|
448 | + if ( $collapse ) { |
|
450 | 449 | // Resolve horizontal borders |
451 | 450 | $max_top = max($max_top, $this->_resolve_border($this->__row, $col, "horizontal", $bp["top"])); |
452 | 451 | $max_bottom = max($max_bottom, $this->_resolve_border($this->__row + $rowspan, $col, "horizontal", $bp["bottom"])); |
453 | - } |
|
452 | + } |
|
454 | 453 | } |
455 | 454 | |
456 | 455 | $this->_frames[ $key ]["frame"] = $frame; |
457 | 456 | |
458 | 457 | // Handle seperated border model |
459 | 458 | if ( !$collapse ) { |
460 | - list($h, $v) = $this->_table->get_style()->border_spacing; |
|
459 | + list($h, $v) = $this->_table->get_style()->border_spacing; |
|
461 | 460 | |
462 | - // Border spacing is effectively a margin between cells |
|
463 | - $v = $style->length_in_pt($v) / 2; |
|
464 | - $h = $style->length_in_pt($h) / 2; |
|
465 | - $style->margin = "$v $h"; |
|
461 | + // Border spacing is effectively a margin between cells |
|
462 | + $v = $style->length_in_pt($v) / 2; |
|
463 | + $h = $style->length_in_pt($h) / 2; |
|
464 | + $style->margin = "$v $h"; |
|
466 | 465 | |
467 | - // The additional 1/2 width gets added to the table proper |
|
466 | + // The additional 1/2 width gets added to the table proper |
|
468 | 467 | |
469 | 468 | } else { |
470 | 469 | |
471 | - // Drop the frame's actual border |
|
472 | - $style->border_left_width = $max_left / 2; |
|
473 | - $style->border_right_width = $max_right / 2; |
|
474 | - $style->border_top_width = $max_top / 2; |
|
475 | - $style->border_bottom_width = $max_bottom / 2; |
|
476 | - $style->margin = "none"; |
|
470 | + // Drop the frame's actual border |
|
471 | + $style->border_left_width = $max_left / 2; |
|
472 | + $style->border_right_width = $max_right / 2; |
|
473 | + $style->border_top_width = $max_top / 2; |
|
474 | + $style->border_bottom_width = $max_bottom / 2; |
|
475 | + $style->margin = "none"; |
|
477 | 476 | } |
478 | 477 | |
479 | 478 | // Resolve the frame's width |
@@ -482,60 +481,60 @@ discard block |
||
482 | 481 | $width = $style->width; |
483 | 482 | |
484 | 483 | if ( is_percent($width) ) { |
485 | - $var = "percent"; |
|
486 | - $val = (float)rtrim($width, "% ") / $colspan; |
|
484 | + $var = "percent"; |
|
485 | + $val = (float)rtrim($width, "% ") / $colspan; |
|
487 | 486 | |
488 | 487 | } else if ( $width !== "auto" ) { |
489 | - $var = "absolute"; |
|
490 | - $val = $style->length_in_pt($frame_min) / $colspan; |
|
488 | + $var = "absolute"; |
|
489 | + $val = $style->length_in_pt($frame_min) / $colspan; |
|
491 | 490 | } |
492 | 491 | |
493 | 492 | $min = 0; |
494 | 493 | $max = 0; |
495 | 494 | for ( $cs = 0; $cs < $colspan; $cs++ ) { |
496 | 495 | |
497 | - // Resolve the frame's width(s) with other cells |
|
498 | - $col =& $this->get_column( $this->__col + $cs ); |
|
496 | + // Resolve the frame's width(s) with other cells |
|
497 | + $col =& $this->get_column( $this->__col + $cs ); |
|
499 | 498 | |
500 | - // Note: $var is either 'percent' or 'absolute'. We compare the |
|
501 | - // requested percentage or absolute values with the existing widths |
|
502 | - // and adjust accordingly. |
|
503 | - if ( isset($var) && $val > $col[$var] ) { |
|
499 | + // Note: $var is either 'percent' or 'absolute'. We compare the |
|
500 | + // requested percentage or absolute values with the existing widths |
|
501 | + // and adjust accordingly. |
|
502 | + if ( isset($var) && $val > $col[$var] ) { |
|
504 | 503 | $col[$var] = $val; |
505 | 504 | $col["auto"] = false; |
506 | - } |
|
505 | + } |
|
507 | 506 | |
508 | - $min += $col["min-width"]; |
|
509 | - $max += $col["max-width"]; |
|
507 | + $min += $col["min-width"]; |
|
508 | + $max += $col["max-width"]; |
|
510 | 509 | } |
511 | 510 | |
512 | 511 | |
513 | 512 | if ( $frame_min > $min ) { |
514 | - // The frame needs more space. Expand each sub-column |
|
515 | - $inc = ($frame_min - $min) / $colspan; |
|
516 | - for ($c = 0; $c < $colspan; $c++) { |
|
513 | + // The frame needs more space. Expand each sub-column |
|
514 | + $inc = ($frame_min - $min) / $colspan; |
|
515 | + for ($c = 0; $c < $colspan; $c++) { |
|
517 | 516 | $col =& $this->get_column($this->__col + $c); |
518 | 517 | $col["min-width"] += $inc; |
519 | - } |
|
518 | + } |
|
520 | 519 | } |
521 | 520 | |
522 | 521 | if ( $frame_max > $max ) { |
523 | - $inc = ($frame_max - $max) / $colspan; |
|
524 | - for ($c = 0; $c < $colspan; $c++) { |
|
522 | + $inc = ($frame_max - $max) / $colspan; |
|
523 | + for ($c = 0; $c < $colspan; $c++) { |
|
525 | 524 | $col =& $this->get_column($this->__col + $c); |
526 | 525 | $col["max-width"] += $inc; |
527 | - } |
|
526 | + } |
|
528 | 527 | } |
529 | 528 | |
530 | 529 | $this->__col += $colspan; |
531 | 530 | if ( $this->__col > $this->_num_cols ) |
532 | - $this->_num_cols = $this->__col; |
|
531 | + $this->_num_cols = $this->__col; |
|
533 | 532 | |
534 | - } |
|
533 | + } |
|
535 | 534 | |
536 | - //........................................................................ |
|
535 | + //........................................................................ |
|
537 | 536 | |
538 | - function add_row() { |
|
537 | + function add_row() { |
|
539 | 538 | |
540 | 539 | $this->__row++; |
541 | 540 | $this->_num_rows++; |
@@ -543,24 +542,24 @@ discard block |
||
543 | 542 | // Find the next available column |
544 | 543 | $i = 0; |
545 | 544 | while ( isset($this->_cells[$this->__row][$i]) ) |
546 | - $i++; |
|
545 | + $i++; |
|
547 | 546 | |
548 | 547 | $this->__col = $i; |
549 | 548 | |
550 | - } |
|
549 | + } |
|
551 | 550 | |
552 | - //........................................................................ |
|
551 | + //........................................................................ |
|
553 | 552 | |
554 | - /** |
|
555 | - * Remove a row from the cellmap. |
|
556 | - * |
|
557 | - * @param Frame |
|
558 | - */ |
|
559 | - function remove_row(Frame $row) { |
|
553 | + /** |
|
554 | + * Remove a row from the cellmap. |
|
555 | + * |
|
556 | + * @param Frame |
|
557 | + */ |
|
558 | + function remove_row(Frame $row) { |
|
560 | 559 | |
561 | 560 | $key = $row->get_id(); |
562 | 561 | if ( !isset($this->_frames[$key]) ) |
563 | - return; // Presumably this row has alredy been removed |
|
562 | + return; // Presumably this row has alredy been removed |
|
564 | 563 | |
565 | 564 | $this->_row = $this->_num_rows--; |
566 | 565 | |
@@ -569,47 +568,47 @@ discard block |
||
569 | 568 | |
570 | 569 | // Remove all frames from this row |
571 | 570 | foreach ( $rows as $r ) { |
572 | - foreach ( $columns as $c ) { |
|
571 | + foreach ( $columns as $c ) { |
|
573 | 572 | if ( isset($this->_cells[$r][$c]) ) { |
574 | - $frame = $this->_cells[$r][$c]; |
|
575 | - unset($this->_frames[ $frame->get_id() ]); |
|
576 | - unset($this->_cells[$r][$c]); |
|
573 | + $frame = $this->_cells[$r][$c]; |
|
574 | + unset($this->_frames[ $frame->get_id() ]); |
|
575 | + unset($this->_cells[$r][$c]); |
|
576 | + } |
|
577 | 577 | } |
578 | - } |
|
579 | - unset($this->_rows[$r]); |
|
578 | + unset($this->_rows[$r]); |
|
580 | 579 | } |
581 | 580 | |
582 | 581 | unset($this->_frames[$key]); |
583 | 582 | |
584 | - } |
|
583 | + } |
|
585 | 584 | |
586 | - /** |
|
587 | - * Remove a row group from the cellmap. |
|
588 | - * |
|
589 | - * @param Frame $group The group to remove |
|
590 | - */ |
|
591 | - function remove_row_group(Frame $group) { |
|
585 | + /** |
|
586 | + * Remove a row group from the cellmap. |
|
587 | + * |
|
588 | + * @param Frame $group The group to remove |
|
589 | + */ |
|
590 | + function remove_row_group(Frame $group) { |
|
592 | 591 | |
593 | 592 | $key = $group->get_id(); |
594 | 593 | if ( !isset($this->_frames[$key]) ) |
595 | - return; // Presumably this row has alredy been removed |
|
594 | + return; // Presumably this row has alredy been removed |
|
596 | 595 | |
597 | 596 | $iter = $group->get_first_child(); |
598 | 597 | while ($iter) { |
599 | - $this->remove_row($iter); |
|
600 | - $iter = $iter->get_next_sibling(); |
|
598 | + $this->remove_row($iter); |
|
599 | + $iter = $iter->get_next_sibling(); |
|
601 | 600 | } |
602 | 601 | |
603 | 602 | unset($this->_frames[$key]); |
604 | - } |
|
603 | + } |
|
605 | 604 | |
606 | - /** |
|
607 | - * Update a row group after rows have been removed |
|
608 | - * |
|
609 | - * @param Frame $group The group to update |
|
610 | - * @param Frame $last_row The last row in the row group |
|
611 | - */ |
|
612 | - function update_row_group(Frame $group, Frame $last_row) { |
|
605 | + /** |
|
606 | + * Update a row group after rows have been removed |
|
607 | + * |
|
608 | + * @param Frame $group The group to update |
|
609 | + * @param Frame $last_row The last row in the row group |
|
610 | + */ |
|
611 | + function update_row_group(Frame $group, Frame $last_row) { |
|
613 | 612 | |
614 | 613 | $g_key = $group->get_id(); |
615 | 614 | $r_key = $last_row->get_id(); |
@@ -617,80 +616,80 @@ discard block |
||
617 | 616 | $r_rows = $this->_frames[$r_key]["rows"]; |
618 | 617 | $this->_frames[$g_key]["rows"] = range( $this->_frames[$g_key]["rows"][0], end($r_rows) ); |
619 | 618 | |
620 | - } |
|
619 | + } |
|
621 | 620 | |
622 | - //........................................................................ |
|
621 | + //........................................................................ |
|
623 | 622 | |
624 | - function assign_x_positions() { |
|
623 | + function assign_x_positions() { |
|
625 | 624 | // Pre-condition: widths must be resolved and assigned to columns and |
626 | 625 | // column[0]["x"] must be set. |
627 | 626 | |
628 | 627 | $x = $this->_columns[0]["x"]; |
629 | 628 | foreach ( array_keys($this->_columns) as $j ) { |
630 | - $this->_columns[$j]["x"] = $x; |
|
631 | - $x += $this->_columns[$j]["used-width"]; |
|
629 | + $this->_columns[$j]["x"] = $x; |
|
630 | + $x += $this->_columns[$j]["used-width"]; |
|
632 | 631 | |
633 | 632 | } |
634 | 633 | |
635 | - } |
|
634 | + } |
|
636 | 635 | |
637 | - function assign_frame_heights() { |
|
636 | + function assign_frame_heights() { |
|
638 | 637 | // Pre-condition: widths and heights of each column & row must be |
639 | 638 | // calcluated |
640 | 639 | |
641 | 640 | foreach ( $this->_frames as $arr ) { |
642 | - $frame = $arr["frame"]; |
|
641 | + $frame = $arr["frame"]; |
|
643 | 642 | |
644 | - $h = 0; |
|
645 | - foreach( $arr["rows"] as $row ) { |
|
643 | + $h = 0; |
|
644 | + foreach( $arr["rows"] as $row ) { |
|
646 | 645 | if ( !isset($this->_rows[$row]) ) |
647 | - // The row has been removed because of a page split, so skip it. |
|
648 | - continue; |
|
646 | + // The row has been removed because of a page split, so skip it. |
|
647 | + continue; |
|
649 | 648 | $h += $this->_rows[$row]["height"]; |
650 | - } |
|
649 | + } |
|
651 | 650 | |
652 | - if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
651 | + if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
653 | 652 | $frame->set_cell_height($h); |
654 | - else |
|
653 | + else |
|
655 | 654 | $frame->get_style()->height = $h; |
656 | 655 | } |
657 | 656 | |
658 | - } |
|
657 | + } |
|
659 | 658 | |
660 | - //........................................................................ |
|
659 | + //........................................................................ |
|
661 | 660 | |
662 | - /** |
|
663 | - * Re-adjust frame height if the table height is larger than its content |
|
664 | - */ |
|
665 | - function set_frame_heights($table_height, $content_height) { |
|
661 | + /** |
|
662 | + * Re-adjust frame height if the table height is larger than its content |
|
663 | + */ |
|
664 | + function set_frame_heights($table_height, $content_height) { |
|
666 | 665 | |
667 | 666 | |
668 | 667 | // Distribute the increased height proportionally amongst each row |
669 | 668 | foreach ( $this->_frames as $arr ) { |
670 | - $frame = $arr["frame"]; |
|
669 | + $frame = $arr["frame"]; |
|
671 | 670 | |
672 | - $h = 0; |
|
673 | - foreach ($arr["rows"] as $row ) { |
|
671 | + $h = 0; |
|
672 | + foreach ($arr["rows"] as $row ) { |
|
674 | 673 | if ( !isset($this->_rows[$row]) ) |
675 | - continue; |
|
674 | + continue; |
|
676 | 675 | |
677 | 676 | $h += $this->_rows[$row]["height"]; |
678 | - } |
|
677 | + } |
|
679 | 678 | |
680 | - $new_height = ($h / $content_height) * $table_height; |
|
679 | + $new_height = ($h / $content_height) * $table_height; |
|
681 | 680 | |
682 | - if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
681 | + if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
683 | 682 | $frame->set_cell_height($new_height); |
684 | - else |
|
683 | + else |
|
685 | 684 | $frame->get_style()->height = $new_height; |
686 | 685 | } |
687 | 686 | |
688 | - } |
|
687 | + } |
|
689 | 688 | |
690 | - //........................................................................ |
|
689 | + //........................................................................ |
|
691 | 690 | |
692 | - // Used for debugging: |
|
693 | - function __toString() { |
|
691 | + // Used for debugging: |
|
692 | + function __toString() { |
|
694 | 693 | $str = ""; |
695 | 694 | $str .= "Columns:<br/>"; |
696 | 695 | $str .= pre_r($this->_columns, true); |
@@ -700,14 +699,14 @@ discard block |
||
700 | 699 | $str .= "Frames:<br/>"; |
701 | 700 | $arr = array(); |
702 | 701 | foreach ( $this->_frames as $key => $val ) |
703 | - $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]); |
|
702 | + $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]); |
|
704 | 703 | |
705 | 704 | $str .= pre_r($arr, true); |
706 | 705 | |
707 | 706 | if ( php_sapi_name() == "cli" ) |
708 | - $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
707 | + $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
709 | 708 | array("\n",chr(27)."[01;33m", chr(27)."[0m"), |
710 | 709 | $str)); |
711 | 710 | return $str; |
712 | - } |
|
711 | + } |
|
713 | 712 | } |
@@ -1,47 +1,46 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: list_bullet_frame_decorator.cls.php,v $ |
|
6 | - * Created on: 2004-06-23 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @contributor Helmut Tischer <[email protected]> |
|
37 | - * @package dompdf |
|
38 | - |
|
39 | - * |
|
40 | - * Changes |
|
41 | - * @contributor Helmut Tischer <[email protected]> |
|
42 | - * @version 20090622 |
|
43 | - * - bullet size proportional to font size, center position |
|
44 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: list_bullet_frame_decorator.cls.php,v $ |
|
6 | + * Created on: 2004-06-23 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @contributor Helmut Tischer <[email protected]> |
|
37 | + * @package dompdf |
|
38 | + * |
|
39 | + * Changes |
|
40 | + * @contributor Helmut Tischer <[email protected]> |
|
41 | + * @version 20090622 |
|
42 | + * - bullet size proportional to font size, center position |
|
43 | + */ |
|
45 | 44 | |
46 | 45 | /* $Id: list_bullet_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
47 | 46 | |
@@ -53,42 +52,42 @@ discard block |
||
53 | 52 | */ |
54 | 53 | class List_Bullet_Frame_Decorator extends Frame_Decorator { |
55 | 54 | |
56 | - const BULLET_PADDING = 1; // Distance from bullet to text in pt |
|
57 | - // As fraction of font size (including descent). See also DECO_THICKNESS. |
|
58 | - const BULLET_THICKNESS = 0.04; // Thickness of bullet outline. Screen: 0.08, print: better less, e.g. 0.04 |
|
59 | - const BULLET_DESCENT = 0.3; //descent of font below baseline. Todo: Guessed for now. |
|
60 | - const BULLET_SIZE = 0.35; // bullet diameter. For now 0.5 of font_size without descent. |
|
55 | + const BULLET_PADDING = 1; // Distance from bullet to text in pt |
|
56 | + // As fraction of font size (including descent). See also DECO_THICKNESS. |
|
57 | + const BULLET_THICKNESS = 0.04; // Thickness of bullet outline. Screen: 0.08, print: better less, e.g. 0.04 |
|
58 | + const BULLET_DESCENT = 0.3; //descent of font below baseline. Todo: Guessed for now. |
|
59 | + const BULLET_SIZE = 0.35; // bullet diameter. For now 0.5 of font_size without descent. |
|
61 | 60 | |
62 | - static $BULLET_TYPES = array("disc", "circle", "square"); |
|
61 | + static $BULLET_TYPES = array("disc", "circle", "square"); |
|
63 | 62 | |
64 | - //........................................................................ |
|
63 | + //........................................................................ |
|
65 | 64 | |
66 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
65 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
67 | 66 | parent::__construct($frame, $dompdf); |
68 | - } |
|
67 | + } |
|
69 | 68 | |
70 | - function get_margin_width() { |
|
69 | + function get_margin_width() { |
|
71 | 70 | $style = $this->_frame->get_style(); |
72 | 71 | // Small hack to prevent extra indenting of list text on list_style_position === "inside" |
73 | 72 | // and on suppressed bullet |
74 | 73 | if ( $style->list_style_position === "outside" || |
75 | 74 | $style->list_style_type === "none" ) |
76 | - return 0; |
|
75 | + return 0; |
|
77 | 76 | return $style->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
78 | - } |
|
77 | + } |
|
79 | 78 | |
80 | - //hits only on "inset" lists items, to increase height of box |
|
81 | - function get_margin_height() { |
|
79 | + //hits only on "inset" lists items, to increase height of box |
|
80 | + function get_margin_height() { |
|
82 | 81 | return $this->_frame->get_style()->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
83 | - } |
|
82 | + } |
|
84 | 83 | |
85 | - function get_width() { |
|
84 | + function get_width() { |
|
86 | 85 | return $this->_frame->get_style()->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
87 | - } |
|
86 | + } |
|
88 | 87 | |
89 | - function get_height() { |
|
88 | + function get_height() { |
|
90 | 89 | return $this->_frame->get_style()->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
91 | - } |
|
90 | + } |
|
92 | 91 | |
93 | - //........................................................................ |
|
92 | + //........................................................................ |
|
94 | 93 | } |
@@ -1,41 +1,40 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: null_frame_reflower.cls.php,v $ |
|
6 | - * Created on: 2004-07-12 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @package dompdf |
|
37 | - |
|
38 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: null_frame_reflower.cls.php,v $ |
|
6 | + * Created on: 2004-07-12 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @package dompdf |
|
37 | + */ |
|
39 | 38 | |
40 | 39 | /* $Id: null_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
41 | 40 | |
@@ -47,8 +46,8 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Null_Frame_Reflower extends Frame_Reflower { |
49 | 48 | |
50 | - function __construct(Frame $frame) { parent::__construct($frame); } |
|
49 | + function __construct(Frame $frame) { parent::__construct($frame); } |
|
51 | 50 | |
52 | - function reflow() { return; } |
|
51 | + function reflow() { return; } |
|
53 | 52 | |
54 | 53 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: dompdf_internal_exception.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -46,14 +45,14 @@ discard block |
||
46 | 45 | */ |
47 | 46 | class DOMPDF_Internal_Exception extends Exception { |
48 | 47 | |
49 | - /** |
|
50 | - * Class constructor |
|
51 | - * |
|
52 | - * @param string $message Error message |
|
53 | - * @param int $code Error code |
|
54 | - */ |
|
55 | - function __construct($message = NULL, $code = 0) { |
|
48 | + /** |
|
49 | + * Class constructor |
|
50 | + * |
|
51 | + * @param string $message Error message |
|
52 | + * @param int $code Error code |
|
53 | + */ |
|
54 | + function __construct($message = NULL, $code = 0) { |
|
56 | 55 | parent::__construct($message, $code); |
57 | - } |
|
56 | + } |
|
58 | 57 | |
59 | 58 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: block_positioner.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -48,24 +47,24 @@ discard block |
||
48 | 47 | class Block_Positioner extends Positioner { |
49 | 48 | |
50 | 49 | |
51 | - function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
50 | + function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
52 | 51 | |
53 | - //........................................................................ |
|
52 | + //........................................................................ |
|
54 | 53 | |
55 | - function position() { |
|
54 | + function position() { |
|
56 | 55 | $cb = $this->_frame->get_containing_block(); |
57 | 56 | |
58 | 57 | $p = $this->_frame->find_block_parent(); |
59 | 58 | |
60 | 59 | if ( $p ) { |
61 | - $p->add_line(); |
|
62 | - $y = $p->get_current_line("y"); |
|
60 | + $p->add_line(); |
|
61 | + $y = $p->get_current_line("y"); |
|
63 | 62 | |
64 | 63 | } else |
65 | - $y = $cb["y"]; |
|
64 | + $y = $cb["y"]; |
|
66 | 65 | |
67 | 66 | $x = $cb["x"]; |
68 | 67 | |
69 | 68 | $this->_frame->set_position($x, $y); |
70 | - } |
|
69 | + } |
|
71 | 70 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: list_bullet_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,20 +46,20 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class List_Bullet_Frame_Reflower extends Frame_Reflower { |
49 | 48 | |
50 | - function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
49 | + function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
51 | 50 | |
52 | - //........................................................................ |
|
51 | + //........................................................................ |
|
53 | 52 | |
54 | - function reflow() { |
|
53 | + function reflow() { |
|
55 | 54 | $style = $this->_frame->get_style(); |
56 | 55 | |
57 | 56 | $style->width = $this->_frame->get_width(); |
58 | 57 | $this->_frame->position(); |
59 | 58 | |
60 | 59 | if ( $style->list_style_position === "inside" ) { |
61 | - $p = $this->_frame->find_block_parent(); |
|
62 | - $p->add_frame_to_line($this->_frame); |
|
60 | + $p = $this->_frame->find_block_parent(); |
|
61 | + $p->add_frame_to_line($this->_frame); |
|
63 | 62 | } |
64 | 63 | |
65 | - } |
|
64 | + } |
|
66 | 65 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: table_cell_renderer.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,25 +46,25 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Table_Cell_Renderer extends Block_Renderer { |
49 | 48 | |
50 | - //........................................................................ |
|
49 | + //........................................................................ |
|
51 | 50 | |
52 | - function render(Frame $frame) { |
|
51 | + function render(Frame $frame) { |
|
53 | 52 | $style = $frame->get_style(); |
54 | 53 | list($x, $y, $w, $h) = $frame->get_padding_box(); |
55 | 54 | |
56 | 55 | // Draw our background, border and content |
57 | 56 | if ( ($bg = $style->background_color) !== "transparent" ) { |
58 | - list($x, $y, $w, $h) = $frame->get_padding_box(); |
|
59 | - $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color ); |
|
57 | + list($x, $y, $w, $h) = $frame->get_padding_box(); |
|
58 | + $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color ); |
|
60 | 59 | } |
61 | 60 | |
62 | 61 | if ( ($url = $style->background_image) && $url !== "none" ) { |
63 | - $this->_background_image($url, $x, $y, $w, $h, $style); |
|
62 | + $this->_background_image($url, $x, $y, $w, $h, $style); |
|
64 | 63 | } |
65 | 64 | |
66 | 65 | if ( $style->border_collapse !== "collapse" ) { |
67 | - $this->_render_border($frame, "bevel"); |
|
68 | - return; |
|
66 | + $this->_render_border($frame, "bevel"); |
|
67 | + return; |
|
69 | 68 | } |
70 | 69 | |
71 | 70 | // The collapsed case is slightly complicated... |
@@ -83,35 +82,35 @@ discard block |
||
83 | 82 | // then we draw its bottom border. Otherwise the next row down will |
84 | 83 | // draw its top border instead. |
85 | 84 | if (in_array( $num_rows - 1, $cells["rows"])) { |
86 | - $draw_bottom = true; |
|
87 | - $bottom_row = $cellmap->get_row($num_rows - 1); |
|
85 | + $draw_bottom = true; |
|
86 | + $bottom_row = $cellmap->get_row($num_rows - 1); |
|
88 | 87 | } else |
89 | - $draw_bottom = false; |
|
88 | + $draw_bottom = false; |
|
90 | 89 | |
91 | 90 | |
92 | 91 | // Draw the horizontal borders |
93 | 92 | foreach ( $cells["columns"] as $j ) { |
94 | - $bp = $cellmap->get_border_properties($i, $j); |
|
93 | + $bp = $cellmap->get_border_properties($i, $j); |
|
95 | 94 | |
96 | - $y = $top_row["y"] - $bp["top"]["width"] / 2; |
|
95 | + $y = $top_row["y"] - $bp["top"]["width"] / 2; |
|
97 | 96 | |
98 | - $col = $cellmap->get_column($j); |
|
99 | - $x = $col["x"] - $bp["left"]["width"] / 2; |
|
100 | - $w = $col["used-width"] + ($bp["left"]["width"] + $bp["right"]["width"] ) / 2; |
|
97 | + $col = $cellmap->get_column($j); |
|
98 | + $x = $col["x"] - $bp["left"]["width"] / 2; |
|
99 | + $w = $col["used-width"] + ($bp["left"]["width"] + $bp["right"]["width"] ) / 2; |
|
101 | 100 | |
102 | - if ( $bp["top"]["style"] !== "none" && $bp["top"]["width"] > 0 ) { |
|
101 | + if ( $bp["top"]["style"] !== "none" && $bp["top"]["width"] > 0 ) { |
|
103 | 102 | $widths = array($bp["top"]["width"], |
104 | 103 | $bp["right"]["width"], |
105 | 104 | $bp["bottom"]["width"], |
106 | 105 | $bp["left"]["width"]); |
107 | 106 | $method = "_border_". $bp["top"]["style"]; |
108 | 107 | $this->$method($x, $y, $w, $bp["top"]["color"], $widths, "top", "square"); |
109 | - } |
|
108 | + } |
|
110 | 109 | |
111 | - if ( $draw_bottom ) { |
|
110 | + if ( $draw_bottom ) { |
|
112 | 111 | $bp = $cellmap->get_border_properties($num_rows - 1, $j); |
113 | 112 | if ( $bp["bottom"]["style"] === "none" || $bp["bottom"]["width"] <= 0 ) |
114 | - continue; |
|
113 | + continue; |
|
115 | 114 | |
116 | 115 | $y = $bottom_row["y"] + $bottom_row["height"] + $bp["bottom"]["width"] / 2; |
117 | 116 | |
@@ -122,7 +121,7 @@ discard block |
||
122 | 121 | $method = "_border_". $bp["bottom"]["style"]; |
123 | 122 | $this->$method($x, $y, $w, $bp["bottom"]["color"], $widths, "bottom", "square"); |
124 | 123 | |
125 | - } |
|
124 | + } |
|
126 | 125 | } |
127 | 126 | |
128 | 127 | $j = $cells["columns"][0]; |
@@ -130,23 +129,23 @@ discard block |
||
130 | 129 | $left_col = $cellmap->get_column($j); |
131 | 130 | |
132 | 131 | if (in_array($num_cols - 1, $cells["columns"])) { |
133 | - $draw_right = true; |
|
134 | - $right_col = $cellmap->get_column($num_cols - 1); |
|
132 | + $draw_right = true; |
|
133 | + $right_col = $cellmap->get_column($num_cols - 1); |
|
135 | 134 | } else |
136 | - $draw_right = false; |
|
135 | + $draw_right = false; |
|
137 | 136 | |
138 | 137 | // Draw the vertical borders |
139 | 138 | foreach ( $cells["rows"] as $i ) { |
140 | - $bp = $cellmap->get_border_properties($i, $j); |
|
139 | + $bp = $cellmap->get_border_properties($i, $j); |
|
141 | 140 | |
142 | - $x = $left_col["x"] - $bp["left"]["width"] / 2; |
|
141 | + $x = $left_col["x"] - $bp["left"]["width"] / 2; |
|
143 | 142 | |
144 | - $row = $cellmap->get_row($i); |
|
143 | + $row = $cellmap->get_row($i); |
|
145 | 144 | |
146 | - $y = $row["y"] - $bp["top"]["width"] / 2; |
|
147 | - $h = $row["height"] + ($bp["top"]["width"] + $bp["bottom"]["width"])/ 2; |
|
145 | + $y = $row["y"] - $bp["top"]["width"] / 2; |
|
146 | + $h = $row["height"] + ($bp["top"]["width"] + $bp["bottom"]["width"])/ 2; |
|
148 | 147 | |
149 | - if ( $bp["left"]["style"] !== "none" && $bp["left"]["width"] > 0 ) { |
|
148 | + if ( $bp["left"]["style"] !== "none" && $bp["left"]["width"] > 0 ) { |
|
150 | 149 | |
151 | 150 | $widths = array($bp["top"]["width"], |
152 | 151 | $bp["right"]["width"], |
@@ -155,12 +154,12 @@ discard block |
||
155 | 154 | |
156 | 155 | $method = "_border_" . $bp["left"]["style"]; |
157 | 156 | $this->$method($x, $y, $h, $bp["left"]["color"], $widths, "left", "square"); |
158 | - } |
|
157 | + } |
|
159 | 158 | |
160 | - if ( $draw_right ) { |
|
159 | + if ( $draw_right ) { |
|
161 | 160 | $bp = $cellmap->get_border_properties($i, $num_cols - 1); |
162 | 161 | if ( $bp["right"]["style"] === "none" || $bp["right"]["width"] <= 0 ) |
163 | - continue; |
|
162 | + continue; |
|
164 | 163 | |
165 | 164 | $x = $right_col["x"] + $right_col["used-width"] + $bp["right"]["width"] / 2; |
166 | 165 | |
@@ -172,8 +171,8 @@ discard block |
||
172 | 171 | $method = "_border_" . $bp["right"]["style"]; |
173 | 172 | $this->$method($x, $y, $h, $bp["right"]["color"], $widths, "right", "square"); |
174 | 173 | |
175 | - } |
|
174 | + } |
|
176 | 175 | } |
177 | 176 | |
178 | - } |
|
177 | + } |
|
179 | 178 | } |
@@ -1,41 +1,40 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: frame_tree.cls.php,v $ |
|
6 | - * Created on: 2004-06-02 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @package dompdf |
|
37 | - |
|
38 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: frame_tree.cls.php,v $ |
|
6 | + * Created on: 2004-06-02 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @package dompdf |
|
37 | + */ |
|
39 | 38 | |
40 | 39 | /* $Id: frame_tree.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
41 | 40 | |
@@ -52,118 +51,118 @@ discard block |
||
52 | 51 | */ |
53 | 52 | class Frame_Tree { |
54 | 53 | |
55 | - /** |
|
56 | - * Tags to ignore while parsing the tree |
|
57 | - * |
|
58 | - * @var array |
|
59 | - */ |
|
60 | - static protected $_HIDDEN_TAGS = array("area", "base", "basefont", "head", "style", |
|
61 | - "meta", "title", "colgroup", |
|
62 | - "noembed", "noscript", "param", "#comment"); |
|
63 | - /** |
|
64 | - * The main DomDocument |
|
65 | - * |
|
66 | - * @see http://ca2.php.net/manual/en/ref.dom.php |
|
67 | - * @var DomDocument |
|
68 | - */ |
|
69 | - protected $_dom; |
|
70 | - |
|
71 | - /** |
|
72 | - * The root node of the FrameTree. |
|
73 | - * |
|
74 | - * @var Frame |
|
75 | - */ |
|
76 | - protected $_root; |
|
77 | - |
|
78 | - /** |
|
79 | - * Subtrees of absolutely positioned elements |
|
80 | - * |
|
81 | - * @var array of Frames |
|
82 | - */ |
|
83 | - protected $_absolute_frames; |
|
84 | - |
|
85 | - /** |
|
86 | - * A mapping of {@link Frame} objects to DomNode objects |
|
87 | - * |
|
88 | - * @var array |
|
89 | - */ |
|
90 | - protected $_registry; |
|
54 | + /** |
|
55 | + * Tags to ignore while parsing the tree |
|
56 | + * |
|
57 | + * @var array |
|
58 | + */ |
|
59 | + static protected $_HIDDEN_TAGS = array("area", "base", "basefont", "head", "style", |
|
60 | + "meta", "title", "colgroup", |
|
61 | + "noembed", "noscript", "param", "#comment"); |
|
62 | + /** |
|
63 | + * The main DomDocument |
|
64 | + * |
|
65 | + * @see http://ca2.php.net/manual/en/ref.dom.php |
|
66 | + * @var DomDocument |
|
67 | + */ |
|
68 | + protected $_dom; |
|
69 | + |
|
70 | + /** |
|
71 | + * The root node of the FrameTree. |
|
72 | + * |
|
73 | + * @var Frame |
|
74 | + */ |
|
75 | + protected $_root; |
|
76 | + |
|
77 | + /** |
|
78 | + * Subtrees of absolutely positioned elements |
|
79 | + * |
|
80 | + * @var array of Frames |
|
81 | + */ |
|
82 | + protected $_absolute_frames; |
|
83 | + |
|
84 | + /** |
|
85 | + * A mapping of {@link Frame} objects to DomNode objects |
|
86 | + * |
|
87 | + * @var array |
|
88 | + */ |
|
89 | + protected $_registry; |
|
91 | 90 | |
92 | 91 | |
93 | - /** |
|
94 | - * Class constructor |
|
95 | - * |
|
96 | - * @param DomDocument $dom the main DomDocument object representing the current html document |
|
97 | - */ |
|
98 | - function __construct(DomDocument $dom) { |
|
92 | + /** |
|
93 | + * Class constructor |
|
94 | + * |
|
95 | + * @param DomDocument $dom the main DomDocument object representing the current html document |
|
96 | + */ |
|
97 | + function __construct(DomDocument $dom) { |
|
99 | 98 | $this->_dom = $dom; |
100 | 99 | $this->_root = null; |
101 | 100 | $this->_registry = array(); |
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Returns the DomDocument object representing the curent html document |
|
106 | - * |
|
107 | - * @return DomDocument |
|
108 | - */ |
|
109 | - function get_dom() { return $this->_dom; } |
|
110 | - |
|
111 | - /** |
|
112 | - * Returns the root frame of the tree |
|
113 | - * |
|
114 | - * @return Frame |
|
115 | - */ |
|
116 | - function get_root() { return $this->_root; } |
|
117 | - |
|
118 | - /** |
|
119 | - * Returns a specific frame given its id |
|
120 | - * |
|
121 | - * @param string $id |
|
122 | - * @return Frame |
|
123 | - */ |
|
124 | - function get_frame($id) { return isset($this->_registry[$id]) ? $this->_registry[$id] : null; } |
|
125 | - |
|
126 | - /** |
|
127 | - * Returns a post-order iterator for all frames in the tree |
|
128 | - * |
|
129 | - * @return FrameTreeList |
|
130 | - */ |
|
131 | - function get_frames() { return new FrameTreeList($this->_root); } |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * Returns the DomDocument object representing the curent html document |
|
105 | + * |
|
106 | + * @return DomDocument |
|
107 | + */ |
|
108 | + function get_dom() { return $this->_dom; } |
|
109 | + |
|
110 | + /** |
|
111 | + * Returns the root frame of the tree |
|
112 | + * |
|
113 | + * @return Frame |
|
114 | + */ |
|
115 | + function get_root() { return $this->_root; } |
|
116 | + |
|
117 | + /** |
|
118 | + * Returns a specific frame given its id |
|
119 | + * |
|
120 | + * @param string $id |
|
121 | + * @return Frame |
|
122 | + */ |
|
123 | + function get_frame($id) { return isset($this->_registry[$id]) ? $this->_registry[$id] : null; } |
|
124 | + |
|
125 | + /** |
|
126 | + * Returns a post-order iterator for all frames in the tree |
|
127 | + * |
|
128 | + * @return FrameTreeList |
|
129 | + */ |
|
130 | + function get_frames() { return new FrameTreeList($this->_root); } |
|
132 | 131 | |
133 | - /** |
|
134 | - * Builds the tree |
|
135 | - */ |
|
136 | - function build_tree() { |
|
132 | + /** |
|
133 | + * Builds the tree |
|
134 | + */ |
|
135 | + function build_tree() { |
|
137 | 136 | $html = $this->_dom->getElementsByTagName("html")->item(0); |
138 | 137 | if ( is_null($html) ) |
139 | - $html = $this->_dom->firstChild; |
|
138 | + $html = $this->_dom->firstChild; |
|
140 | 139 | |
141 | 140 | if ( is_null($html) ) |
142 | - throw new DOMPDF_Exception("Requested HTML document contains no data."); |
|
141 | + throw new DOMPDF_Exception("Requested HTML document contains no data."); |
|
143 | 142 | |
144 | 143 | $this->_root = $this->_build_tree_r($html); |
145 | 144 | |
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * Recursively adds {@link Frame} objects to the tree |
|
150 | - * |
|
151 | - * Recursively build a tree of Frame objects based on a dom tree. |
|
152 | - * No layout information is calculated at this time, although the |
|
153 | - * tree may be adjusted (i.e. nodes and frames for generated content |
|
154 | - * and images may be created). |
|
155 | - * |
|
156 | - * @param DomNode $node the current DomNode being considered |
|
157 | - * @return Frame |
|
158 | - */ |
|
159 | - protected function _build_tree_r(DomNode $node) { |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * Recursively adds {@link Frame} objects to the tree |
|
149 | + * |
|
150 | + * Recursively build a tree of Frame objects based on a dom tree. |
|
151 | + * No layout information is calculated at this time, although the |
|
152 | + * tree may be adjusted (i.e. nodes and frames for generated content |
|
153 | + * and images may be created). |
|
154 | + * |
|
155 | + * @param DomNode $node the current DomNode being considered |
|
156 | + * @return Frame |
|
157 | + */ |
|
158 | + protected function _build_tree_r(DomNode $node) { |
|
160 | 159 | |
161 | 160 | $frame = new Frame($node); |
162 | 161 | $id = $frame->get_id(); |
163 | 162 | $this->_registry[ $id ] = $frame; |
164 | 163 | |
165 | 164 | if ( !$node->hasChildNodes() ) |
166 | - return $frame; |
|
165 | + return $frame; |
|
167 | 166 | |
168 | 167 | // Fixes 'cannot access undefined property for object with |
169 | 168 | // overloaded access', fix by Stefan radulian |
@@ -173,55 +172,55 @@ discard block |
||
173 | 172 | // Store the children in an array so that the tree can be modified |
174 | 173 | $children = array(); |
175 | 174 | for ($i = 0; $i < $node->childNodes->length; $i++) |
176 | - $children[] = $node->childNodes->item($i); |
|
175 | + $children[] = $node->childNodes->item($i); |
|
177 | 176 | |
178 | 177 | foreach ($children as $child) { |
179 | - // Skip non-displaying nodes |
|
180 | - if ( in_array( mb_strtolower($child->nodeName), self::$_HIDDEN_TAGS) ) { |
|
178 | + // Skip non-displaying nodes |
|
179 | + if ( in_array( mb_strtolower($child->nodeName), self::$_HIDDEN_TAGS) ) { |
|
181 | 180 | if ( mb_strtolower($child->nodeName) !== "head" && |
182 | 181 | mb_strtolower($child->nodeName) !== "style" ) |
183 | - $child->parentNode->removeChild($child); |
|
182 | + $child->parentNode->removeChild($child); |
|
184 | 183 | continue; |
185 | - } |
|
184 | + } |
|
186 | 185 | |
187 | - // Skip empty text nodes |
|
188 | - if ( $child->nodeName === "#text" && $child->nodeValue == "" ) { |
|
186 | + // Skip empty text nodes |
|
187 | + if ( $child->nodeName === "#text" && $child->nodeValue == "" ) { |
|
189 | 188 | $child->parentNode->removeChild($child); |
190 | 189 | continue; |
191 | - } |
|
190 | + } |
|
192 | 191 | |
193 | - // Skip empty image nodes |
|
194 | - if ( $child->nodeName === "img" && $child->getAttribute("src") == "" ) { |
|
192 | + // Skip empty image nodes |
|
193 | + if ( $child->nodeName === "img" && $child->getAttribute("src") == "" ) { |
|
195 | 194 | $child->parentNode->removeChild($child); |
196 | 195 | continue; |
197 | - } |
|
196 | + } |
|
198 | 197 | |
199 | - // Add a container frame for images |
|
200 | - if ( $child->nodeName === "img" ) { |
|
198 | + // Add a container frame for images |
|
199 | + if ( $child->nodeName === "img" ) { |
|
201 | 200 | $img_node = $child->ownerDocument->createElement("img_inner"); |
202 | 201 | |
203 | 202 | // Move attributes to inner node |
204 | 203 | foreach ( $child->attributes as $attr => $attr_node ) { |
205 | - // Skip style, but move all other attributes |
|
206 | - if ( $attr === "style" ) |
|
204 | + // Skip style, but move all other attributes |
|
205 | + if ( $attr === "style" ) |
|
207 | 206 | continue; |
208 | 207 | |
209 | - $img_node->setAttribute($attr, $attr_node->value); |
|
208 | + $img_node->setAttribute($attr, $attr_node->value); |
|
210 | 209 | } |
211 | 210 | |
212 | 211 | foreach ( $child->attributes as $attr => $node ) { |
213 | - if ( $attr === "style" ) |
|
212 | + if ( $attr === "style" ) |
|
214 | 213 | continue; |
215 | - $child->removeAttribute($attr); |
|
214 | + $child->removeAttribute($attr); |
|
216 | 215 | } |
217 | 216 | |
218 | 217 | $child->appendChild($img_node); |
219 | - } |
|
218 | + } |
|
220 | 219 | |
221 | - $frame->append_child($this->_build_tree_r($child), false); |
|
220 | + $frame->append_child($this->_build_tree_r($child), false); |
|
222 | 221 | |
223 | 222 | } |
224 | 223 | |
225 | 224 | return $frame; |
226 | - } |
|
225 | + } |
|
227 | 226 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: table_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -46,73 +45,73 @@ discard block |
||
46 | 45 | * @package dompdf |
47 | 46 | */ |
48 | 47 | class Table_Frame_Decorator extends Frame_Decorator { |
49 | - static $VALID_CHILDREN = array("table-row-group", |
|
50 | - "table-row", |
|
51 | - "table-header-group", |
|
52 | - "table-footer-group", |
|
53 | - "table-column", |
|
54 | - "table-column-group", |
|
55 | - "table-caption", |
|
56 | - "table-cell"); |
|
57 | - |
|
58 | - static $ROW_GROUPS = array('table-row-group', |
|
59 | - 'table-header-group', |
|
60 | - 'table-footer-group'); |
|
61 | - |
|
62 | - /** |
|
63 | - * The Cellmap object for this table. The cellmap maps table cells |
|
64 | - * to rows and columns, and aids in calculating column widths. |
|
65 | - * |
|
66 | - * @var Cellmap |
|
67 | - */ |
|
68 | - protected $_cellmap; |
|
69 | - |
|
70 | - /** |
|
71 | - * The minimum width of the table, in pt |
|
72 | - * |
|
73 | - * @var float |
|
74 | - */ |
|
75 | - protected $_min_width; |
|
76 | - |
|
77 | - /** |
|
78 | - * The maximum width of the table, in pt |
|
79 | - * |
|
80 | - * @var float |
|
81 | - */ |
|
82 | - protected $_max_width; |
|
83 | - |
|
84 | - /** |
|
85 | - * Table header rows. Each table header is duplicated when a table |
|
86 | - * spans pages. |
|
87 | - * |
|
88 | - * @var array |
|
89 | - */ |
|
90 | - protected $_headers; |
|
91 | - |
|
92 | - /** |
|
93 | - * Table footer rows. Each table footer is duplicated when a table |
|
94 | - * spans pages. |
|
95 | - * |
|
96 | - * @var array |
|
97 | - */ |
|
98 | - protected $_footers; |
|
99 | - |
|
100 | - /** |
|
101 | - * Class constructor |
|
102 | - * |
|
103 | - * @param Frame $frame the frame to decorate |
|
104 | - */ |
|
105 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
48 | + static $VALID_CHILDREN = array("table-row-group", |
|
49 | + "table-row", |
|
50 | + "table-header-group", |
|
51 | + "table-footer-group", |
|
52 | + "table-column", |
|
53 | + "table-column-group", |
|
54 | + "table-caption", |
|
55 | + "table-cell"); |
|
56 | + |
|
57 | + static $ROW_GROUPS = array('table-row-group', |
|
58 | + 'table-header-group', |
|
59 | + 'table-footer-group'); |
|
60 | + |
|
61 | + /** |
|
62 | + * The Cellmap object for this table. The cellmap maps table cells |
|
63 | + * to rows and columns, and aids in calculating column widths. |
|
64 | + * |
|
65 | + * @var Cellmap |
|
66 | + */ |
|
67 | + protected $_cellmap; |
|
68 | + |
|
69 | + /** |
|
70 | + * The minimum width of the table, in pt |
|
71 | + * |
|
72 | + * @var float |
|
73 | + */ |
|
74 | + protected $_min_width; |
|
75 | + |
|
76 | + /** |
|
77 | + * The maximum width of the table, in pt |
|
78 | + * |
|
79 | + * @var float |
|
80 | + */ |
|
81 | + protected $_max_width; |
|
82 | + |
|
83 | + /** |
|
84 | + * Table header rows. Each table header is duplicated when a table |
|
85 | + * spans pages. |
|
86 | + * |
|
87 | + * @var array |
|
88 | + */ |
|
89 | + protected $_headers; |
|
90 | + |
|
91 | + /** |
|
92 | + * Table footer rows. Each table footer is duplicated when a table |
|
93 | + * spans pages. |
|
94 | + * |
|
95 | + * @var array |
|
96 | + */ |
|
97 | + protected $_footers; |
|
98 | + |
|
99 | + /** |
|
100 | + * Class constructor |
|
101 | + * |
|
102 | + * @param Frame $frame the frame to decorate |
|
103 | + */ |
|
104 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
106 | 105 | parent::__construct($frame, $dompdf); |
107 | 106 | $this->_cellmap = new Cellmap($this); |
108 | 107 | $this->_min_width = null; |
109 | 108 | $this->_max_width = null; |
110 | 109 | $this->_headers = array(); |
111 | 110 | $this->_footers = array(); |
112 | - } |
|
111 | + } |
|
113 | 112 | |
114 | 113 | |
115 | - function reset() { |
|
114 | + function reset() { |
|
116 | 115 | parent::reset(); |
117 | 116 | $this->_cellmap->reset(); |
118 | 117 | $this->_min_width = null; |
@@ -120,22 +119,22 @@ discard block |
||
120 | 119 | $this->_headers = array(); |
121 | 120 | $this->_footers = array(); |
122 | 121 | $this->_reflower->reset(); |
123 | - } |
|
122 | + } |
|
124 | 123 | |
125 | - //........................................................................ |
|
124 | + //........................................................................ |
|
126 | 125 | |
127 | - /** |
|
128 | - * split the table at $row. $row and all subsequent rows will be |
|
129 | - * added to the clone. This method is overidden in order to remove |
|
130 | - * frames from the cellmap properly. |
|
131 | - * |
|
132 | - * @param Frame $row |
|
133 | - */ |
|
134 | - function split($child = null) { |
|
126 | + /** |
|
127 | + * split the table at $row. $row and all subsequent rows will be |
|
128 | + * added to the clone. This method is overidden in order to remove |
|
129 | + * frames from the cellmap properly. |
|
130 | + * |
|
131 | + * @param Frame $row |
|
132 | + */ |
|
133 | + function split($child = null) { |
|
135 | 134 | |
136 | 135 | if ( is_null($child) ) { |
137 | - parent::split(); |
|
138 | - return; |
|
136 | + parent::split(); |
|
137 | + return; |
|
139 | 138 | } |
140 | 139 | |
141 | 140 | // If $child is a header or if it is the first non-header row, do |
@@ -143,200 +142,200 @@ discard block |
||
143 | 142 | if ( count($this->_headers) && !in_array($child, $this->_headers, true) && |
144 | 143 | !in_array($child->get_prev_sibling(), $this->_headers, true) ) { |
145 | 144 | |
146 | - $first_header = null; |
|
145 | + $first_header = null; |
|
147 | 146 | |
148 | - // Insert copies of the table headers before $child |
|
149 | - foreach ($this->_headers as $header) { |
|
147 | + // Insert copies of the table headers before $child |
|
148 | + foreach ($this->_headers as $header) { |
|
150 | 149 | |
151 | 150 | $new_header = $header->deep_copy(); |
152 | 151 | |
153 | 152 | if ( is_null($first_header) ) |
154 | - $first_header = $new_header; |
|
153 | + $first_header = $new_header; |
|
155 | 154 | |
156 | 155 | $this->insert_child_before($new_header, $child); |
157 | - } |
|
156 | + } |
|
158 | 157 | |
159 | - parent::split($first_header); |
|
158 | + parent::split($first_header); |
|
160 | 159 | |
161 | 160 | } else if ( in_array($child->get_style()->display, self::$ROW_GROUPS) ) { |
162 | 161 | |
163 | - // Individual rows should have already been handled |
|
164 | - parent::split($child); |
|
162 | + // Individual rows should have already been handled |
|
163 | + parent::split($child); |
|
165 | 164 | |
166 | 165 | } else { |
167 | 166 | |
168 | - $iter = $child; |
|
167 | + $iter = $child; |
|
169 | 168 | |
170 | - while ($iter) { |
|
169 | + while ($iter) { |
|
171 | 170 | $this->_cellmap->remove_row($iter); |
172 | 171 | $iter = $iter->get_next_sibling(); |
173 | - } |
|
172 | + } |
|
174 | 173 | |
175 | - parent::split($child); |
|
174 | + parent::split($child); |
|
175 | + } |
|
176 | 176 | } |
177 | - } |
|
178 | 177 | |
179 | - /** |
|
180 | - * Static function to locate the parent table of a frame |
|
181 | - * |
|
182 | - * @param Frame $frame |
|
183 | - * @return Frame the table that is an ancestor of $frame |
|
184 | - */ |
|
185 | - static function find_parent_table(Frame $frame) { |
|
178 | + /** |
|
179 | + * Static function to locate the parent table of a frame |
|
180 | + * |
|
181 | + * @param Frame $frame |
|
182 | + * @return Frame the table that is an ancestor of $frame |
|
183 | + */ |
|
184 | + static function find_parent_table(Frame $frame) { |
|
186 | 185 | |
187 | 186 | while ( $frame = $frame->get_parent() ) |
188 | - if ( in_array($frame->get_style()->display, Style::$TABLE_TYPES) ) |
|
187 | + if ( in_array($frame->get_style()->display, Style::$TABLE_TYPES) ) |
|
189 | 188 | break; |
190 | 189 | |
191 | 190 | return $frame; |
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * Return this table's Cellmap |
|
196 | - * |
|
197 | - * @return Cellmap |
|
198 | - */ |
|
199 | - function get_cellmap() { return $this->_cellmap; } |
|
200 | - |
|
201 | - /** |
|
202 | - * Return the minimum width of this table |
|
203 | - * |
|
204 | - * @return float |
|
205 | - */ |
|
206 | - function get_min_width() { return $this->_min_width; } |
|
207 | - |
|
208 | - /** |
|
209 | - * Return the maximum width of this table |
|
210 | - * |
|
211 | - * @return float |
|
212 | - */ |
|
213 | - function get_max_width() { return $this->_max_width; } |
|
214 | - |
|
215 | - /** |
|
216 | - * Set the minimum width of the table |
|
217 | - * |
|
218 | - * @param float $width the new minimum width |
|
219 | - */ |
|
220 | - function set_min_width($width) { $this->_min_width = $width; } |
|
221 | - |
|
222 | - /** |
|
223 | - * Set the maximum width of the table |
|
224 | - * |
|
225 | - * @param float $width the new maximum width |
|
226 | - */ |
|
227 | - function set_max_width($width) { $this->_max_width = $width; } |
|
228 | - |
|
229 | - /** |
|
230 | - * Restructure tree so that the table has the correct structure. |
|
231 | - * Invalid children (i.e. all non-table-rows) are moved below the |
|
232 | - * table. |
|
233 | - */ |
|
234 | - function normalise() { |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * Return this table's Cellmap |
|
195 | + * |
|
196 | + * @return Cellmap |
|
197 | + */ |
|
198 | + function get_cellmap() { return $this->_cellmap; } |
|
199 | + |
|
200 | + /** |
|
201 | + * Return the minimum width of this table |
|
202 | + * |
|
203 | + * @return float |
|
204 | + */ |
|
205 | + function get_min_width() { return $this->_min_width; } |
|
206 | + |
|
207 | + /** |
|
208 | + * Return the maximum width of this table |
|
209 | + * |
|
210 | + * @return float |
|
211 | + */ |
|
212 | + function get_max_width() { return $this->_max_width; } |
|
213 | + |
|
214 | + /** |
|
215 | + * Set the minimum width of the table |
|
216 | + * |
|
217 | + * @param float $width the new minimum width |
|
218 | + */ |
|
219 | + function set_min_width($width) { $this->_min_width = $width; } |
|
220 | + |
|
221 | + /** |
|
222 | + * Set the maximum width of the table |
|
223 | + * |
|
224 | + * @param float $width the new maximum width |
|
225 | + */ |
|
226 | + function set_max_width($width) { $this->_max_width = $width; } |
|
227 | + |
|
228 | + /** |
|
229 | + * Restructure tree so that the table has the correct structure. |
|
230 | + * Invalid children (i.e. all non-table-rows) are moved below the |
|
231 | + * table. |
|
232 | + */ |
|
233 | + function normalise() { |
|
235 | 234 | |
236 | 235 | // Store frames generated by invalid tags and move them outside the table |
237 | 236 | $erroneous_frames = array(); |
238 | 237 | $anon_row = false; |
239 | 238 | $iter = $this->get_first_child(); |
240 | 239 | while ( $iter ) { |
241 | - $child = $iter; |
|
242 | - $iter = $iter->get_next_sibling(); |
|
240 | + $child = $iter; |
|
241 | + $iter = $iter->get_next_sibling(); |
|
243 | 242 | |
244 | - $display = $child->get_style()->display; |
|
243 | + $display = $child->get_style()->display; |
|
245 | 244 | |
246 | - if ( $anon_row ) { |
|
245 | + if ( $anon_row ) { |
|
247 | 246 | |
248 | 247 | if ( $display === "table-row" ) { |
249 | - // Add the previous anonymous row |
|
250 | - $this->insert_child_before($table_row, $child); |
|
248 | + // Add the previous anonymous row |
|
249 | + $this->insert_child_before($table_row, $child); |
|
251 | 250 | |
252 | - $table_row->normalise(); |
|
253 | - $child->normalise(); |
|
254 | - $anon_row = false; |
|
255 | - continue; |
|
251 | + $table_row->normalise(); |
|
252 | + $child->normalise(); |
|
253 | + $anon_row = false; |
|
254 | + continue; |
|
256 | 255 | } |
257 | 256 | |
258 | 257 | // add the child to the anonymous row |
259 | 258 | $table_row->append_child($child); |
260 | 259 | continue; |
261 | 260 | |
262 | - } else { |
|
261 | + } else { |
|
263 | 262 | |
264 | 263 | if ( $display === "table-row" ) { |
265 | - $child->normalise(); |
|
266 | - continue; |
|
264 | + $child->normalise(); |
|
265 | + continue; |
|
267 | 266 | } |
268 | 267 | |
269 | 268 | if ( $display === "table-cell") { |
270 | - // Create an anonymous table row |
|
271 | - $tr = $this->get_node()->ownerDocument->createElement("tr"); |
|
269 | + // Create an anonymous table row |
|
270 | + $tr = $this->get_node()->ownerDocument->createElement("tr"); |
|
272 | 271 | |
273 | - $frame = new Frame($tr); |
|
272 | + $frame = new Frame($tr); |
|
274 | 273 | |
275 | - $css = $this->get_style()->get_stylesheet(); |
|
276 | - $style = $css->create_style(); |
|
277 | - $style->inherit($this->get_style()); |
|
274 | + $css = $this->get_style()->get_stylesheet(); |
|
275 | + $style = $css->create_style(); |
|
276 | + $style->inherit($this->get_style()); |
|
278 | 277 | |
279 | - // Lookup styles for tr tags. If the user wants styles to work |
|
280 | - // better, they should make the tr explicit... I'm not going to |
|
281 | - // try to guess what they intended. |
|
282 | - if ( $tr_style = $css->lookup("tr") ) |
|
278 | + // Lookup styles for tr tags. If the user wants styles to work |
|
279 | + // better, they should make the tr explicit... I'm not going to |
|
280 | + // try to guess what they intended. |
|
281 | + if ( $tr_style = $css->lookup("tr") ) |
|
283 | 282 | $style->merge($tr_style); |
284 | 283 | |
285 | - // Okay, I have absolutely no idea why I need this clone here, but |
|
286 | - // if it's omitted, php (as of 2004-07-28) segfaults. |
|
287 | - $frame->set_style(clone $style); |
|
288 | - $table_row = Frame_Factory::decorate_frame($frame, $this->_dompdf); |
|
289 | - $table_row->set_root($this->_root); |
|
284 | + // Okay, I have absolutely no idea why I need this clone here, but |
|
285 | + // if it's omitted, php (as of 2004-07-28) segfaults. |
|
286 | + $frame->set_style(clone $style); |
|
287 | + $table_row = Frame_Factory::decorate_frame($frame, $this->_dompdf); |
|
288 | + $table_row->set_root($this->_root); |
|
290 | 289 | |
291 | - // Add the cell to the row |
|
292 | - $table_row->append_child($child); |
|
290 | + // Add the cell to the row |
|
291 | + $table_row->append_child($child); |
|
293 | 292 | |
294 | - $anon_row = true; |
|
295 | - continue; |
|
293 | + $anon_row = true; |
|
294 | + continue; |
|
296 | 295 | } |
297 | 296 | |
298 | 297 | if ( !in_array($display, self::$VALID_CHILDREN) ) { |
299 | - $erroneous_frames[] = $child; |
|
300 | - continue; |
|
298 | + $erroneous_frames[] = $child; |
|
299 | + continue; |
|
301 | 300 | } |
302 | 301 | |
303 | 302 | // Normalise other table parts (i.e. row groups) |
304 | 303 | foreach ($child->get_children() as $grandchild) { |
305 | - if ( $grandchild->get_style()->display === "table-row" ) |
|
304 | + if ( $grandchild->get_style()->display === "table-row" ) |
|
306 | 305 | $grandchild->normalise(); |
307 | 306 | } |
308 | 307 | |
309 | 308 | // Add headers and footers |
310 | 309 | if ( $display === "table-header-group" ) |
311 | - $this->_headers[] = $child; |
|
310 | + $this->_headers[] = $child; |
|
312 | 311 | |
313 | 312 | else if ( $display === "table-footer-group" ) |
314 | - $this->_footers[] = $child; |
|
315 | - } |
|
313 | + $this->_footers[] = $child; |
|
314 | + } |
|
316 | 315 | } |
317 | 316 | |
318 | 317 | if ( $anon_row ) { |
319 | - // Add the row to the table |
|
320 | - $this->_frame->append_child($table_row); |
|
321 | - $table_row->normalise(); |
|
322 | - $this->_cellmap->add_row(); |
|
318 | + // Add the row to the table |
|
319 | + $this->_frame->append_child($table_row); |
|
320 | + $table_row->normalise(); |
|
321 | + $this->_cellmap->add_row(); |
|
323 | 322 | } |
324 | 323 | |
325 | 324 | foreach ($erroneous_frames as $frame) |
326 | - $this->move_after($frame); |
|
325 | + $this->move_after($frame); |
|
327 | 326 | |
328 | - } |
|
327 | + } |
|
329 | 328 | |
330 | - //........................................................................ |
|
329 | + //........................................................................ |
|
331 | 330 | |
332 | - /** |
|
333 | - * Moves the specified frame and it's corresponding node outside of |
|
334 | - * the table. |
|
335 | - * |
|
336 | - * @param Frame $frame the frame to move |
|
337 | - */ |
|
338 | - function move_after(Frame $frame) { |
|
331 | + /** |
|
332 | + * Moves the specified frame and it's corresponding node outside of |
|
333 | + * the table. |
|
334 | + * |
|
335 | + * @param Frame $frame the frame to move |
|
336 | + */ |
|
337 | + function move_after(Frame $frame) { |
|
339 | 338 | $this->get_parent()->insert_child_after($frame, $this); |
340 | - } |
|
339 | + } |
|
341 | 340 | |
342 | 341 | } |