@@ -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 | } |
@@ -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 | } |
@@ -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: null_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,13 +46,13 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Null_Frame_Decorator extends Frame_Decorator { |
49 | 48 | |
50 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
49 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
51 | 50 | parent::__construct($frame, $dompdf); |
52 | 51 | $style = $this->_frame->get_style(); |
53 | 52 | $style->width = 0; |
54 | 53 | $style->height = 0; |
55 | 54 | $style->margin = 0; |
56 | 55 | $style->padding = 0; |
57 | - } |
|
56 | + } |
|
58 | 57 | |
59 | 58 | } |
@@ -60,57 +60,57 @@ discard block |
||
60 | 60 | */ |
61 | 61 | abstract class Abstract_Renderer { |
62 | 62 | |
63 | - /** |
|
64 | - * Rendering backend |
|
65 | - * |
|
66 | - * @var Canvas |
|
67 | - */ |
|
68 | - protected $_canvas; |
|
69 | - |
|
70 | - /** |
|
71 | - * Current dompdf instance |
|
72 | - * |
|
73 | - * @var DOMPDF |
|
74 | - */ |
|
75 | - protected $_dompdf; |
|
63 | + /** |
|
64 | + * Rendering backend |
|
65 | + * |
|
66 | + * @var Canvas |
|
67 | + */ |
|
68 | + protected $_canvas; |
|
69 | + |
|
70 | + /** |
|
71 | + * Current dompdf instance |
|
72 | + * |
|
73 | + * @var DOMPDF |
|
74 | + */ |
|
75 | + protected $_dompdf; |
|
76 | 76 | |
77 | - /** |
|
78 | - * Class constructor |
|
79 | - * |
|
80 | - * @param DOMPDF $dompdf The current dompdf instance |
|
81 | - */ |
|
82 | - function __construct(DOMPDF $dompdf) { |
|
77 | + /** |
|
78 | + * Class constructor |
|
79 | + * |
|
80 | + * @param DOMPDF $dompdf The current dompdf instance |
|
81 | + */ |
|
82 | + function __construct(DOMPDF $dompdf) { |
|
83 | 83 | $this->_dompdf = $dompdf; |
84 | 84 | $this->_canvas = $dompdf->get_canvas(); |
85 | - } |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * Render a frame. |
|
89 | - * |
|
90 | - * Specialized in child classes |
|
91 | - * |
|
92 | - * @param Frame $frame The frame to render |
|
93 | - */ |
|
94 | - abstract function render(Frame $frame); |
|
95 | - |
|
96 | - //........................................................................ |
|
97 | - |
|
98 | - /** |
|
99 | - * Render a background image over a rectangular area |
|
100 | - * |
|
101 | - * @param string $img The background image to load |
|
102 | - * @param float $x The left edge of the rectangular area |
|
103 | - * @param float $y The top edge of the rectangular area |
|
104 | - * @param float $width The width of the rectangular area |
|
105 | - * @param float $height The height of the rectangular area |
|
106 | - * @param Style $style The associated Style object |
|
107 | - */ |
|
108 | - protected function _background_image($url, $x, $y, $width, $height, $style) { |
|
87 | + /** |
|
88 | + * Render a frame. |
|
89 | + * |
|
90 | + * Specialized in child classes |
|
91 | + * |
|
92 | + * @param Frame $frame The frame to render |
|
93 | + */ |
|
94 | + abstract function render(Frame $frame); |
|
95 | + |
|
96 | + //........................................................................ |
|
97 | + |
|
98 | + /** |
|
99 | + * Render a background image over a rectangular area |
|
100 | + * |
|
101 | + * @param string $img The background image to load |
|
102 | + * @param float $x The left edge of the rectangular area |
|
103 | + * @param float $y The top edge of the rectangular area |
|
104 | + * @param float $width The width of the rectangular area |
|
105 | + * @param float $height The height of the rectangular area |
|
106 | + * @param Style $style The associated Style object |
|
107 | + */ |
|
108 | + protected function _background_image($url, $x, $y, $width, $height, $style) { |
|
109 | 109 | $sheet = $style->get_stylesheet(); |
110 | 110 | |
111 | 111 | // Skip degenerate cases |
112 | 112 | if ( $width == 0 || $height == 0 ) |
113 | - return; |
|
113 | + return; |
|
114 | 114 | |
115 | 115 | //debugpng |
116 | 116 | if (DEBUGPNG) print '[_background_image '.$url.']'; |
@@ -122,24 +122,24 @@ discard block |
||
122 | 122 | |
123 | 123 | // Bail if the image is no good |
124 | 124 | if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" ) |
125 | - return; |
|
125 | + return; |
|
126 | 126 | |
127 | - //Try to optimize away reading and composing of same background multiple times |
|
128 | - //Postponing read with imagecreatefrom ...() |
|
129 | - //final composition paramters and name not known yet |
|
130 | - //Therefore read dimension directly from file, instead of creating gd object first. |
|
127 | + //Try to optimize away reading and composing of same background multiple times |
|
128 | + //Postponing read with imagecreatefrom ...() |
|
129 | + //final composition paramters and name not known yet |
|
130 | + //Therefore read dimension directly from file, instead of creating gd object first. |
|
131 | 131 | //$img_w = imagesx($src); $img_h = imagesy($src); |
132 | 132 | |
133 | 133 | list($img_w, $img_h) = getimagesize($img); |
134 | 134 | if (!isset($img_w) || $img_w == 0 || !isset($img_h) || $img_h == 0) { |
135 | - return; |
|
135 | + return; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | $repeat = $style->background_repeat; |
139 | 139 | $bg_color = $style->background_color; |
140 | 140 | |
141 | - //Increase background resolution and dependent box size according to image resolution to be placed in |
|
142 | - //Then image can be copied in without resize |
|
141 | + //Increase background resolution and dependent box size according to image resolution to be placed in |
|
142 | + //Then image can be copied in without resize |
|
143 | 143 | $bg_width = round((float)($width * DOMPDF_DPI) / 72); |
144 | 144 | $bg_height = round((float)($height * DOMPDF_DPI) / 72); |
145 | 145 | |
@@ -148,27 +148,27 @@ discard block |
||
148 | 148 | list($bg_x, $bg_y) = $style->background_position; |
149 | 149 | |
150 | 150 | if ( is_percent($bg_x) ) { |
151 | - // The point $bg_x % from the left edge of the image is placed |
|
152 | - // $bg_x % from the left edge of the background rectangle |
|
153 | - $p = ((float)$bg_x)/100.0; |
|
154 | - $x1 = $p * $img_w; |
|
155 | - $x2 = $p * $bg_width; |
|
151 | + // The point $bg_x % from the left edge of the image is placed |
|
152 | + // $bg_x % from the left edge of the background rectangle |
|
153 | + $p = ((float)$bg_x)/100.0; |
|
154 | + $x1 = $p * $img_w; |
|
155 | + $x2 = $p * $bg_width; |
|
156 | 156 | |
157 | - $bg_x = round($x2 - $x1); |
|
157 | + $bg_x = round($x2 - $x1); |
|
158 | 158 | } else { |
159 | - $bg_x = round((float)($style->length_in_pt($bg_x)*DOMPDF_DPI) / 72); |
|
159 | + $bg_x = round((float)($style->length_in_pt($bg_x)*DOMPDF_DPI) / 72); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | if ( is_percent($bg_y) ) { |
163 | - // The point $bg_y % from the left edge of the image is placed |
|
164 | - // $bg_y % from the left edge of the background rectangle |
|
165 | - $p = ((float)$bg_y)/100.0; |
|
166 | - $y1 = $p * $img_h; |
|
167 | - $y2 = $p * $bg_height; |
|
163 | + // The point $bg_y % from the left edge of the image is placed |
|
164 | + // $bg_y % from the left edge of the background rectangle |
|
165 | + $p = ((float)$bg_y)/100.0; |
|
166 | + $y1 = $p * $img_h; |
|
167 | + $y2 = $p * $bg_height; |
|
168 | 168 | |
169 | - $bg_y = round($y2 - $y1); |
|
169 | + $bg_y = round($y2 - $y1); |
|
170 | 170 | } else { |
171 | - $bg_y = round((float)($style->length_in_pt($bg_y)*DOMPDF_DPI) / 72); |
|
171 | + $bg_y = round((float)($style->length_in_pt($bg_y)*DOMPDF_DPI) / 72); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | //clip background to the image area on partial repeat. Nothing to do if img off area |
@@ -177,79 +177,79 @@ discard block |
||
177 | 177 | //Handle x/y Dimensions separately |
178 | 178 | |
179 | 179 | if ( $repeat !== "repeat" && $repeat !== "repeat-x" ) { |
180 | - //No repeat x |
|
181 | - if ($bg_x < 0) { |
|
180 | + //No repeat x |
|
181 | + if ($bg_x < 0) { |
|
182 | 182 | $bg_width = $img_w + $bg_x; |
183 | - } else { |
|
183 | + } else { |
|
184 | 184 | $x += ($bg_x * 72)/DOMPDF_DPI; |
185 | 185 | $bg_width = $bg_width - $bg_x; |
186 | 186 | if ($bg_width > $img_w) { |
187 | - $bg_width = $img_w; |
|
187 | + $bg_width = $img_w; |
|
188 | 188 | } |
189 | 189 | $bg_x = 0; |
190 | - } |
|
191 | - if ($bg_width <= 0) { |
|
192 | - return; |
|
193 | - } |
|
194 | - $width = (float)($bg_width * 72)/DOMPDF_DPI; |
|
190 | + } |
|
191 | + if ($bg_width <= 0) { |
|
192 | + return; |
|
193 | + } |
|
194 | + $width = (float)($bg_width * 72)/DOMPDF_DPI; |
|
195 | 195 | } else { |
196 | - //repeat x |
|
197 | - if ($bg_x < 0) { |
|
196 | + //repeat x |
|
197 | + if ($bg_x < 0) { |
|
198 | 198 | $bg_x = - ((-$bg_x) % $img_w); |
199 | - } else { |
|
199 | + } else { |
|
200 | 200 | $bg_x = $bg_x % $img_w; |
201 | 201 | if ($bg_x > 0) { |
202 | - $bg_x -= $img_w; |
|
202 | + $bg_x -= $img_w; |
|
203 | + } |
|
203 | 204 | } |
204 | - } |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | if ( $repeat !== "repeat" && $repeat !== "repeat-y" ) { |
208 | - //no repeat y |
|
209 | - if ($bg_y < 0) { |
|
208 | + //no repeat y |
|
209 | + if ($bg_y < 0) { |
|
210 | 210 | $bg_height = $img_h + $bg_y; |
211 | - } else { |
|
211 | + } else { |
|
212 | 212 | $y += ($bg_y * 72)/DOMPDF_DPI; |
213 | 213 | $bg_height = $bg_height - $bg_y; |
214 | 214 | if ($bg_height > $img_h) { |
215 | - $bg_height = $img_h; |
|
215 | + $bg_height = $img_h; |
|
216 | 216 | } |
217 | 217 | $bg_y = 0; |
218 | - } |
|
219 | - if ($bg_height <= 0) { |
|
220 | - return; |
|
221 | - } |
|
222 | - $height = (float)($bg_height * 72)/DOMPDF_DPI; |
|
218 | + } |
|
219 | + if ($bg_height <= 0) { |
|
220 | + return; |
|
221 | + } |
|
222 | + $height = (float)($bg_height * 72)/DOMPDF_DPI; |
|
223 | 223 | } else { |
224 | - //repeat y |
|
225 | - if ($bg_y < 0) { |
|
224 | + //repeat y |
|
225 | + if ($bg_y < 0) { |
|
226 | 226 | $bg_y = - ((-$bg_y) % $img_h); |
227 | - } else { |
|
227 | + } else { |
|
228 | 228 | $bg_y = $bg_y % $img_h; |
229 | 229 | if ($bg_y > 0) { |
230 | - $bg_y -= $img_h; |
|
230 | + $bg_y -= $img_h; |
|
231 | + } |
|
231 | 232 | } |
232 | - } |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | //Optimization, if repeat has no effect |
236 | 236 | if ( $repeat === "repeat" && $bg_y <= 0 && $img_h+$bg_y >= $bg_height ) { |
237 | - $repeat = "repeat-x"; |
|
237 | + $repeat = "repeat-x"; |
|
238 | 238 | } |
239 | 239 | if ( $repeat === "repeat" && $bg_x <= 0 && $img_w+$bg_x >= $bg_width ) { |
240 | - $repeat = "repeat-y"; |
|
240 | + $repeat = "repeat-y"; |
|
241 | 241 | } |
242 | 242 | if ( ($repeat === "repeat-x" && $bg_x <= 0 && $img_w+$bg_x >= $bg_width) || |
243 | 243 | ($repeat === "repeat-y" && $bg_y <= 0 && $img_h+$bg_y >= $bg_height) ) { |
244 | - $repeat = "no-repeat"; |
|
244 | + $repeat = "no-repeat"; |
|
245 | 245 | } |
246 | 246 | |
247 | - //Use filename as indicator only |
|
248 | - //different names for different variants to have different copies in the pdf |
|
249 | - //This is not dependent of background color of box! .'_'.(is_array($bg_color) ? $bg_color["hex"] : $bg_color) |
|
250 | - //Note: Here, bg_* are the start values, not end values after going through the tile loops! |
|
247 | + //Use filename as indicator only |
|
248 | + //different names for different variants to have different copies in the pdf |
|
249 | + //This is not dependent of background color of box! .'_'.(is_array($bg_color) ? $bg_color["hex"] : $bg_color) |
|
250 | + //Note: Here, bg_* are the start values, not end values after going through the tile loops! |
|
251 | 251 | |
252 | - $filedummy = $img; |
|
252 | + $filedummy = $img; |
|
253 | 253 | |
254 | 254 | /* |
255 | 255 | //Make shorter strings with limited characters for cache associative array index - needed? |
@@ -274,50 +274,50 @@ discard block |
||
274 | 274 | } |
275 | 275 | */ |
276 | 276 | |
277 | - $filedummy .= '_'.$bg_width.'_'.$bg_height.'_'.$bg_x.'_'.$bg_y.'_'.$repeat; |
|
277 | + $filedummy .= '_'.$bg_width.'_'.$bg_height.'_'.$bg_x.'_'.$bg_y.'_'.$repeat; |
|
278 | 278 | //debugpng |
279 | 279 | //if (DEBUGPNG) print '<pre>[_background_image name '.$filedummy.']</pre>'; |
280 | 280 | |
281 | 281 | //Optimization to avoid multiple times rendering the same image. |
282 | 282 | //If check functions are existing and identical image already cached, |
283 | 283 | //then skip creation of duplicate, because it is not needed by addImagePng |
284 | - if ( method_exists( $this->_canvas, "get_cpdf" ) && |
|
285 | - method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) && |
|
286 | - method_exists( $this->_canvas->get_cpdf(), "image_iscached" ) && |
|
287 | - $this->_canvas->get_cpdf()->image_iscached($filedummy) ) { |
|
288 | - $bg = null; |
|
284 | + if ( method_exists( $this->_canvas, "get_cpdf" ) && |
|
285 | + method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) && |
|
286 | + method_exists( $this->_canvas->get_cpdf(), "image_iscached" ) && |
|
287 | + $this->_canvas->get_cpdf()->image_iscached($filedummy) ) { |
|
288 | + $bg = null; |
|
289 | 289 | |
290 | - //debugpng |
|
291 | - //if (DEBUGPNG) print '[_background_image skip]'; |
|
290 | + //debugpng |
|
291 | + //if (DEBUGPNG) print '[_background_image skip]'; |
|
292 | 292 | |
293 | - } else { |
|
293 | + } else { |
|
294 | 294 | |
295 | 295 | // Create a new image to fit over the background rectangle |
296 | 296 | $bg = imagecreatetruecolor($bg_width, $bg_height); |
297 | 297 | //anyway default |
298 | - //imagealphablending($img, true); |
|
298 | + //imagealphablending($img, true); |
|
299 | 299 | |
300 | 300 | switch (strtolower($ext)) { |
301 | 301 | |
302 | 302 | case "png": |
303 | 303 | $src = imagecreatefrompng($img); |
304 | - break; |
|
304 | + break; |
|
305 | 305 | |
306 | 306 | case "jpg": |
307 | 307 | case "jpeg": |
308 | 308 | $src = imagecreatefromjpeg($img); |
309 | - break; |
|
309 | + break; |
|
310 | 310 | |
311 | 311 | case "gif": |
312 | 312 | $src = imagecreatefromgif($img); |
313 | - break; |
|
313 | + break; |
|
314 | 314 | |
315 | 315 | default: |
316 | 316 | return; // Unsupported image type |
317 | 317 | } |
318 | 318 | |
319 | 319 | if ($src == null) { |
320 | - return; |
|
320 | + return; |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | //Background color if box is not relevant here |
@@ -325,34 +325,34 @@ discard block |
||
325 | 325 | //Transparent image: The image controls the transparency and lets shine through whatever background. |
326 | 326 | //However on transparent imaage preset the composed image with the transparency color, |
327 | 327 | //to keep the transparency when copying over the non transparent parts of the tiles. |
328 | - $ti = imagecolortransparent($src); |
|
329 | - if ($ti >= 0) { |
|
330 | - $tc = imagecolorsforindex($src,$ti); |
|
331 | - $ti = imagecolorallocate($bg,$tc['red'],$tc['green'],$tc['blue']); |
|
332 | - imagefill($bg,0,0,$ti); |
|
333 | - imagecolortransparent($bg, $ti); |
|
328 | + $ti = imagecolortransparent($src); |
|
329 | + if ($ti >= 0) { |
|
330 | + $tc = imagecolorsforindex($src,$ti); |
|
331 | + $ti = imagecolorallocate($bg,$tc['red'],$tc['green'],$tc['blue']); |
|
332 | + imagefill($bg,0,0,$ti); |
|
333 | + imagecolortransparent($bg, $ti); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | //This has only an effect for the non repeatable dimension. |
337 | 337 | //compute start of src and dest coordinates of the single copy |
338 | 338 | if ( $bg_x < 0 ) { |
339 | - $dst_x = 0; |
|
340 | - $src_x = -$bg_x; |
|
339 | + $dst_x = 0; |
|
340 | + $src_x = -$bg_x; |
|
341 | 341 | } else { |
342 | - $src_x = 0; |
|
343 | - $dst_x = $bg_x; |
|
342 | + $src_x = 0; |
|
343 | + $dst_x = $bg_x; |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | if ( $bg_y < 0 ) { |
347 | - $dst_y = 0; |
|
348 | - $src_y = -$bg_y; |
|
347 | + $dst_y = 0; |
|
348 | + $src_y = -$bg_y; |
|
349 | 349 | } else { |
350 | - $src_y = 0; |
|
351 | - $dst_y = $bg_y; |
|
350 | + $src_y = 0; |
|
351 | + $dst_y = $bg_y; |
|
352 | 352 | } |
353 | 353 | |
354 | - //For historical reasons exchange meanings of variables: |
|
355 | - //start_* will be the start values, while bg_* will be the temporary start values in the loops |
|
354 | + //For historical reasons exchange meanings of variables: |
|
355 | + //start_* will be the start values, while bg_* will be the temporary start values in the loops |
|
356 | 356 | $start_x = $bg_x; |
357 | 357 | $start_y = $bg_y; |
358 | 358 | |
@@ -360,117 +360,117 @@ discard block |
||
360 | 360 | |
361 | 361 | if ( $repeat === "no-repeat" ) { |
362 | 362 | |
363 | - // Simply place the image on the background |
|
364 | - imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $img_h); |
|
363 | + // Simply place the image on the background |
|
364 | + imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $img_h); |
|
365 | 365 | |
366 | 366 | } else if ( $repeat === "repeat-x" ) { |
367 | 367 | |
368 | - for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) { |
|
368 | + for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) { |
|
369 | 369 | if ( $bg_x < 0 ) { |
370 | - $dst_x = 0; |
|
371 | - $src_x = -$bg_x; |
|
372 | - $w = $img_w + $bg_x; |
|
370 | + $dst_x = 0; |
|
371 | + $src_x = -$bg_x; |
|
372 | + $w = $img_w + $bg_x; |
|
373 | 373 | } else { |
374 | - $dst_x = $bg_x; |
|
375 | - $src_x = 0; |
|
376 | - $w = $img_w; |
|
374 | + $dst_x = $bg_x; |
|
375 | + $src_x = 0; |
|
376 | + $w = $img_w; |
|
377 | 377 | } |
378 | 378 | imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $img_h); |
379 | - } |
|
379 | + } |
|
380 | 380 | |
381 | 381 | } else if ( $repeat === "repeat-y" ) { |
382 | 382 | |
383 | - for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) { |
|
383 | + for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) { |
|
384 | 384 | if ( $bg_y < 0 ) { |
385 | - $dst_y = 0; |
|
386 | - $src_y = -$bg_y; |
|
387 | - $h = $img_h + $bg_y; |
|
385 | + $dst_y = 0; |
|
386 | + $src_y = -$bg_y; |
|
387 | + $h = $img_h + $bg_y; |
|
388 | 388 | } else { |
389 | - $dst_y = $bg_y; |
|
390 | - $src_y = 0; |
|
391 | - $h = $img_h; |
|
389 | + $dst_y = $bg_y; |
|
390 | + $src_y = 0; |
|
391 | + $h = $img_h; |
|
392 | 392 | } |
393 | 393 | imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $h); |
394 | 394 | |
395 | - } |
|
395 | + } |
|
396 | 396 | |
397 | 397 | } else if ( $repeat === "repeat" ) { |
398 | 398 | |
399 | - for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) { |
|
399 | + for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) { |
|
400 | 400 | for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) { |
401 | 401 | |
402 | - if ( $bg_x < 0 ) { |
|
402 | + if ( $bg_x < 0 ) { |
|
403 | 403 | $dst_x = 0; |
404 | 404 | $src_x = -$bg_x; |
405 | 405 | $w = $img_w + $bg_x; |
406 | - } else { |
|
406 | + } else { |
|
407 | 407 | $dst_x = $bg_x; |
408 | 408 | $src_x = 0; |
409 | 409 | $w = $img_w; |
410 | - } |
|
410 | + } |
|
411 | 411 | |
412 | - if ( $bg_y < 0 ) { |
|
412 | + if ( $bg_y < 0 ) { |
|
413 | 413 | $dst_y = 0; |
414 | 414 | $src_y = -$bg_y; |
415 | 415 | $h = $img_h + $bg_y; |
416 | - } else { |
|
416 | + } else { |
|
417 | 417 | $dst_y = $bg_y; |
418 | 418 | $src_y = 0; |
419 | 419 | $h = $img_h; |
420 | - } |
|
421 | - imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $h); |
|
420 | + } |
|
421 | + imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $h); |
|
422 | + } |
|
422 | 423 | } |
423 | - } |
|
424 | 424 | } else { |
425 | - print 'Unknown repeat!'; |
|
425 | + print 'Unknown repeat!'; |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | } /* End optimize away creation of duplicates */ |
429 | 429 | |
430 | 430 | //img: image url string |
431 | - //img_w, img_h: original image size in px |
|
432 | - //width, height: box size in pt |
|
433 | - //bg_width, bg_height: box size in px |
|
434 | - //x, y: left/top edge of box on page in pt |
|
435 | - //start_x, start_y: placement of image relativ to pattern |
|
436 | - //$repeat: repeat mode |
|
437 | - //$bg: GD object of result image |
|
438 | - //$src: GD object of original image |
|
431 | + //img_w, img_h: original image size in px |
|
432 | + //width, height: box size in pt |
|
433 | + //bg_width, bg_height: box size in px |
|
434 | + //x, y: left/top edge of box on page in pt |
|
435 | + //start_x, start_y: placement of image relativ to pattern |
|
436 | + //$repeat: repeat mode |
|
437 | + //$bg: GD object of result image |
|
438 | + //$src: GD object of original image |
|
439 | 439 | //When using cpdf and optimization to direct png creation from gd object is available, |
440 | 440 | //don't create temp file, but place gd object directly into the pdf |
441 | - if ( method_exists( $this->_canvas, "get_cpdf" ) && method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) ) { |
|
442 | - //Note: CPDF_Adapter image converts y position |
|
443 | - $this->_canvas->get_cpdf()->addImagePng( |
|
444 | - $filedummy, |
|
445 | - $x, $this->_canvas->get_height() - $y - $height, $width, $height, $bg); |
|
446 | - } else { |
|
447 | - $tmp_file = tempnam(DOMPDF_TEMP_DIR, "bg_dompdf_img_").'.png'; |
|
448 | - //debugpng |
|
449 | - if (DEBUGPNG) print '[_background_image '.$tmp_file.']'; |
|
441 | + if ( method_exists( $this->_canvas, "get_cpdf" ) && method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) ) { |
|
442 | + //Note: CPDF_Adapter image converts y position |
|
443 | + $this->_canvas->get_cpdf()->addImagePng( |
|
444 | + $filedummy, |
|
445 | + $x, $this->_canvas->get_height() - $y - $height, $width, $height, $bg); |
|
446 | + } else { |
|
447 | + $tmp_file = tempnam(DOMPDF_TEMP_DIR, "bg_dompdf_img_").'.png'; |
|
448 | + //debugpng |
|
449 | + if (DEBUGPNG) print '[_background_image '.$tmp_file.']'; |
|
450 | 450 | |
451 | - imagepng($bg, $tmp_file); |
|
452 | - $this->_canvas->image($tmp_file, "png", $x, $y, $width, $height); |
|
451 | + imagepng($bg, $tmp_file); |
|
452 | + $this->_canvas->image($tmp_file, "png", $x, $y, $width, $height); |
|
453 | 453 | |
454 | - //debugpng |
|
455 | - if (DEBUGPNG) print '[_background_image unlink '.$tmp_file.']'; |
|
454 | + //debugpng |
|
455 | + if (DEBUGPNG) print '[_background_image unlink '.$tmp_file.']'; |
|
456 | 456 | |
457 | - if (!DEBUGKEEPTEMP) |
|
457 | + if (!DEBUGKEEPTEMP) |
|
458 | 458 | unlink($tmp_file); |
459 | 459 | } |
460 | - } |
|
460 | + } |
|
461 | 461 | |
462 | - protected function _border_none($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
462 | + protected function _border_none($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
463 | 463 | return; |
464 | - } |
|
464 | + } |
|
465 | 465 | |
466 | - // Border rendering functions |
|
467 | - protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
466 | + // Border rendering functions |
|
467 | + protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
468 | 468 | list($top, $right, $bottom, $left) = $widths; |
469 | 469 | |
470 | 470 | if ( $$side < 2 ) |
471 | - $dash = array($$side, 2); |
|
471 | + $dash = array($$side, 2); |
|
472 | 472 | else |
473 | - $dash = array($$side); |
|
473 | + $dash = array($$side); |
|
474 | 474 | |
475 | 475 | |
476 | 476 | switch ($side) { |
@@ -479,24 +479,24 @@ discard block |
||
479 | 479 | $delta = $top / 2; |
480 | 480 | case "bottom": |
481 | 481 | $delta = isset($delta) ? $delta : -$bottom / 2; |
482 | - $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, $dash); |
|
483 | - break; |
|
482 | + $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, $dash); |
|
483 | + break; |
|
484 | 484 | |
485 | 485 | case "left": |
486 | 486 | $delta = $left / 2; |
487 | 487 | case "right": |
488 | 488 | $delta = isset($delta) ? $delta : - $right / 2; |
489 | - $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, $dash); |
|
490 | - break; |
|
489 | + $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, $dash); |
|
490 | + break; |
|
491 | 491 | |
492 | 492 | default: |
493 | 493 | return; |
494 | 494 | |
495 | 495 | } |
496 | - } |
|
496 | + } |
|
497 | 497 | |
498 | 498 | |
499 | - protected function _border_dashed($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
499 | + protected function _border_dashed($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
500 | 500 | list($top, $right, $bottom, $left) = $widths; |
501 | 501 | |
502 | 502 | switch ($side) { |
@@ -505,24 +505,24 @@ discard block |
||
505 | 505 | $delta = $top / 2; |
506 | 506 | case "bottom": |
507 | 507 | $delta = isset($delta) ? $delta : -$bottom / 2; |
508 | - $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side)); |
|
509 | - break; |
|
508 | + $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side)); |
|
509 | + break; |
|
510 | 510 | |
511 | 511 | case "left": |
512 | 512 | $delta = $left / 2; |
513 | 513 | case "right": |
514 | 514 | $delta = isset($delta) ? $delta : - $right / 2; |
515 | - $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side)); |
|
516 | - break; |
|
515 | + $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side)); |
|
516 | + break; |
|
517 | 517 | |
518 | 518 | default: |
519 | 519 | return; |
520 | 520 | } |
521 | 521 | |
522 | - } |
|
522 | + } |
|
523 | 523 | |
524 | 524 | |
525 | - protected function _border_solid($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
525 | + protected function _border_solid($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
526 | 526 | list($top, $right, $bottom, $left) = $widths; |
527 | 527 | |
528 | 528 | // All this polygon business is for beveled corners... |
@@ -536,10 +536,10 @@ discard block |
||
536 | 536 | $x + $length - $right, $y + $top, |
537 | 537 | $x + $left, $y + $top); |
538 | 538 | $this->_canvas->polygon($points, $color, null, null, true); |
539 | - } else |
|
539 | + } else |
|
540 | 540 | $this->_canvas->filled_rectangle($x, $y, $length, $top, $color); |
541 | 541 | |
542 | - break; |
|
542 | + break; |
|
543 | 543 | |
544 | 544 | case "bottom": |
545 | 545 | if ( $corner_style === "bevel" ) { |
@@ -548,10 +548,10 @@ discard block |
||
548 | 548 | $x + $length - $right, $y - $bottom, |
549 | 549 | $x + $left, $y - $bottom); |
550 | 550 | $this->_canvas->polygon($points, $color, null, null, true); |
551 | - } else |
|
551 | + } else |
|
552 | 552 | $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color); |
553 | 553 | |
554 | - break; |
|
554 | + break; |
|
555 | 555 | |
556 | 556 | case "left": |
557 | 557 | if ( $corner_style === "bevel" ) { |
@@ -560,10 +560,10 @@ discard block |
||
560 | 560 | $x + $left, $y + $length - $bottom, |
561 | 561 | $x + $left, $y + $top); |
562 | 562 | $this->_canvas->polygon($points, $color, null, null, true); |
563 | - } else |
|
563 | + } else |
|
564 | 564 | $this->_canvas->filled_rectangle($x, $y, $left, $length, $color); |
565 | 565 | |
566 | - break; |
|
566 | + break; |
|
567 | 567 | |
568 | 568 | case "right": |
569 | 569 | if ( $corner_style === "bevel" ) { |
@@ -572,20 +572,20 @@ discard block |
||
572 | 572 | $x - $right, $y + $length - $bottom, |
573 | 573 | $x - $right, $y + $top); |
574 | 574 | $this->_canvas->polygon($points, $color, null, null, true); |
575 | - } else |
|
575 | + } else |
|
576 | 576 | $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color); |
577 | 577 | |
578 | - break; |
|
578 | + break; |
|
579 | 579 | |
580 | 580 | default: |
581 | 581 | return; |
582 | 582 | |
583 | 583 | } |
584 | 584 | |
585 | - } |
|
585 | + } |
|
586 | 586 | |
587 | 587 | |
588 | - protected function _border_double($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
588 | + protected function _border_double($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
589 | 589 | list($top, $right, $bottom, $left) = $widths; |
590 | 590 | |
591 | 591 | $line_width = $$side / 4; |
@@ -612,12 +612,12 @@ discard block |
||
612 | 612 | $x + $left, $y + $top); |
613 | 613 | $this->_canvas->polygon($points, $color, null, null, true); |
614 | 614 | |
615 | - } else { |
|
615 | + } else { |
|
616 | 616 | $this->_canvas->filled_rectangle($x, $y, $length, $line_width, $color); |
617 | 617 | $this->_canvas->filled_rectangle($x, $y + $top - $line_width, $length, $line_width, $color); |
618 | 618 | |
619 | - } |
|
620 | - break; |
|
619 | + } |
|
620 | + break; |
|
621 | 621 | |
622 | 622 | case "bottom": |
623 | 623 | if ( $corner_style === "bevel" ) { |
@@ -636,12 +636,12 @@ discard block |
||
636 | 636 | $x + $left, $y - $bottom); |
637 | 637 | $this->_canvas->polygon($points, $color, null, null, true); |
638 | 638 | |
639 | - } else { |
|
639 | + } else { |
|
640 | 640 | $this->_canvas->filled_rectangle($x, $y - $line_width, $length, $line_width, $color); |
641 | 641 | $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $line_width, $color); |
642 | - } |
|
642 | + } |
|
643 | 643 | |
644 | - break; |
|
644 | + break; |
|
645 | 645 | |
646 | 646 | case "left": |
647 | 647 | if ( $corner_style === "bevel" ) { |
@@ -660,12 +660,12 @@ discard block |
||
660 | 660 | $x + $left, $y + $top); |
661 | 661 | $this->_canvas->polygon($points, $color, null, null, true); |
662 | 662 | |
663 | - } else { |
|
663 | + } else { |
|
664 | 664 | $this->_canvas->filled_rectangle($x, $y, $line_width, $length, $color); |
665 | 665 | $this->_canvas->filled_rectangle($x + $left - $line_width, $y, $line_width, $length, $color); |
666 | - } |
|
666 | + } |
|
667 | 667 | |
668 | - break; |
|
668 | + break; |
|
669 | 669 | |
670 | 670 | case "right": |
671 | 671 | if ( $corner_style === "bevel" ) { |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | |
675 | 675 | |
676 | 676 | $points = array($x, $y, |
677 | - $x, $y + $length, |
|
677 | + $x, $y + $length, |
|
678 | 678 | $x - $line_width, $y + $length - $bottom_line_width, |
679 | 679 | $x - $line_width, $y + $top_line_width); |
680 | 680 | $this->_canvas->polygon($points, $color, null, null, true); |
@@ -685,21 +685,21 @@ discard block |
||
685 | 685 | $x - $right, $y + $top); |
686 | 686 | $this->_canvas->polygon($points, $color, null, null, true); |
687 | 687 | |
688 | - } else { |
|
688 | + } else { |
|
689 | 689 | $this->_canvas->filled_rectangle($x - $line_width, $y, $line_width, $length, $color); |
690 | 690 | $this->_canvas->filled_rectangle($x - $right, $y, $line_width, $length, $color); |
691 | - } |
|
691 | + } |
|
692 | 692 | |
693 | - break; |
|
693 | + break; |
|
694 | 694 | |
695 | 695 | default: |
696 | 696 | return; |
697 | 697 | |
698 | 698 | } |
699 | 699 | |
700 | - } |
|
700 | + } |
|
701 | 701 | |
702 | - protected function _border_groove($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
702 | + protected function _border_groove($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
703 | 703 | list($top, $right, $bottom, $left) = $widths; |
704 | 704 | |
705 | 705 | $half_widths = array($top / 2, $right / 2, $bottom / 2, $left / 2); |
@@ -710,27 +710,27 @@ discard block |
||
710 | 710 | |
711 | 711 | case "top": |
712 | 712 | $x += $left / 2; |
713 | - $y += $top / 2; |
|
714 | - $length -= $left / 2 + $right / 2; |
|
715 | - break; |
|
713 | + $y += $top / 2; |
|
714 | + $length -= $left / 2 + $right / 2; |
|
715 | + break; |
|
716 | 716 | |
717 | 717 | case "bottom": |
718 | 718 | $x += $left / 2; |
719 | - $y -= $bottom / 2; |
|
720 | - $length -= $left / 2 + $right / 2; |
|
721 | - break; |
|
719 | + $y -= $bottom / 2; |
|
720 | + $length -= $left / 2 + $right / 2; |
|
721 | + break; |
|
722 | 722 | |
723 | 723 | case "left": |
724 | 724 | $x += $left / 2; |
725 | - $y += $top / 2; |
|
726 | - $length -= $top / 2 + $bottom / 2; |
|
727 | - break; |
|
725 | + $y += $top / 2; |
|
726 | + $length -= $top / 2 + $bottom / 2; |
|
727 | + break; |
|
728 | 728 | |
729 | 729 | case "right": |
730 | 730 | $x -= $right / 2; |
731 | - $y += $top / 2; |
|
732 | - $length -= $top / 2 + $bottom / 2; |
|
733 | - break; |
|
731 | + $y += $top / 2; |
|
732 | + $length -= $top / 2 + $bottom / 2; |
|
733 | + break; |
|
734 | 734 | |
735 | 735 | default: |
736 | 736 | return; |
@@ -739,9 +739,9 @@ discard block |
||
739 | 739 | |
740 | 740 | $this->_border_outset($x, $y, $length, $color, $half_widths, $side); |
741 | 741 | |
742 | - } |
|
742 | + } |
|
743 | 743 | |
744 | - protected function _border_ridge($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
744 | + protected function _border_ridge($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
745 | 745 | list($top, $right, $bottom, $left) = $widths; |
746 | 746 | |
747 | 747 | $half_widths = array($top / 2, $right / 2, $bottom / 2, $left / 2); |
@@ -752,27 +752,27 @@ discard block |
||
752 | 752 | |
753 | 753 | case "top": |
754 | 754 | $x += $left / 2; |
755 | - $y += $top / 2; |
|
756 | - $length -= $left / 2 + $right / 2; |
|
757 | - break; |
|
755 | + $y += $top / 2; |
|
756 | + $length -= $left / 2 + $right / 2; |
|
757 | + break; |
|
758 | 758 | |
759 | 759 | case "bottom": |
760 | 760 | $x += $left / 2; |
761 | - $y -= $bottom / 2; |
|
762 | - $length -= $left / 2 + $right / 2; |
|
763 | - break; |
|
761 | + $y -= $bottom / 2; |
|
762 | + $length -= $left / 2 + $right / 2; |
|
763 | + break; |
|
764 | 764 | |
765 | 765 | case "left": |
766 | 766 | $x += $left / 2; |
767 | - $y += $top / 2; |
|
768 | - $length -= $top / 2 + $bottom / 2; |
|
769 | - break; |
|
767 | + $y += $top / 2; |
|
768 | + $length -= $top / 2 + $bottom / 2; |
|
769 | + break; |
|
770 | 770 | |
771 | 771 | case "right": |
772 | 772 | $x -= $right / 2; |
773 | - $y += $top / 2; |
|
774 | - $length -= $top / 2 + $bottom / 2; |
|
775 | - break; |
|
773 | + $y += $top / 2; |
|
774 | + $length -= $top / 2 + $bottom / 2; |
|
775 | + break; |
|
776 | 776 | |
777 | 777 | default: |
778 | 778 | return; |
@@ -781,23 +781,23 @@ discard block |
||
781 | 781 | |
782 | 782 | $this->_border_inset($x, $y, $length, $color, $half_widths, $side); |
783 | 783 | |
784 | - } |
|
784 | + } |
|
785 | 785 | |
786 | - protected function _tint($c) { |
|
786 | + protected function _tint($c) { |
|
787 | 787 | if ( !is_numeric($c) ) |
788 | - return $c; |
|
788 | + return $c; |
|
789 | 789 | |
790 | 790 | return min(1, $c + 0.66); |
791 | - } |
|
791 | + } |
|
792 | 792 | |
793 | - protected function _shade($c) { |
|
793 | + protected function _shade($c) { |
|
794 | 794 | if ( !is_numeric($c) ) |
795 | - return $c; |
|
795 | + return $c; |
|
796 | 796 | |
797 | 797 | return max(0, $c - 0.66); |
798 | - } |
|
798 | + } |
|
799 | 799 | |
800 | - protected function _border_inset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
800 | + protected function _border_inset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
801 | 801 | list($top, $right, $bottom, $left) = $widths; |
802 | 802 | |
803 | 803 | switch ($side) { |
@@ -805,43 +805,43 @@ discard block |
||
805 | 805 | case "top": |
806 | 806 | case "left": |
807 | 807 | $shade = array_map(array($this, "_shade"), $color); |
808 | - $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
809 | - break; |
|
808 | + $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
809 | + break; |
|
810 | 810 | |
811 | 811 | case "bottom": |
812 | 812 | case "right": |
813 | 813 | $tint = array_map(array($this, "_tint"), $color); |
814 | - $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
815 | - break; |
|
814 | + $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
815 | + break; |
|
816 | 816 | |
817 | 817 | default: |
818 | 818 | return; |
819 | 819 | } |
820 | - } |
|
820 | + } |
|
821 | 821 | |
822 | - protected function _border_outset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
822 | + protected function _border_outset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
823 | 823 | list($top, $right, $bottom, $left) = $widths; |
824 | 824 | |
825 | 825 | switch ($side) { |
826 | 826 | case "top": |
827 | 827 | case "left": |
828 | 828 | $tint = array_map(array($this, "_tint"), $color); |
829 | - $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
830 | - break; |
|
829 | + $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
830 | + break; |
|
831 | 831 | |
832 | 832 | case "bottom": |
833 | 833 | case "right": |
834 | 834 | $shade = array_map(array($this, "_shade"), $color); |
835 | - $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
836 | - break; |
|
835 | + $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
836 | + break; |
|
837 | 837 | |
838 | 838 | default: |
839 | 839 | return; |
840 | 840 | |
841 | 841 | } |
842 | - } |
|
842 | + } |
|
843 | 843 | |
844 | - //........................................................................ |
|
844 | + //........................................................................ |
|
845 | 845 | |
846 | 846 | |
847 | 847 | } |
@@ -54,23 +54,23 @@ discard block |
||
54 | 54 | */ |
55 | 55 | class Image_Frame_Reflower extends Frame_Reflower { |
56 | 56 | |
57 | - function __construct(Image_Frame_Decorator $frame) { |
|
57 | + function __construct(Image_Frame_Decorator $frame) { |
|
58 | 58 | parent::__construct($frame); |
59 | - } |
|
59 | + } |
|
60 | 60 | |
61 | - function reflow() { |
|
61 | + function reflow() { |
|
62 | 62 | |
63 | 63 | // Set the frame's width |
64 | 64 | $this->get_min_max_width(); |
65 | 65 | |
66 | - } |
|
66 | + } |
|
67 | 67 | |
68 | - function get_min_max_width() { |
|
68 | + function get_min_max_width() { |
|
69 | 69 | |
70 | 70 | if (DEBUGPNG) { |
71 | - // Determine the image's size. Time consuming. Only when really needed? |
|
72 | - list($img_width, $img_height) = getimagesize($this->_frame->get_image_url()); |
|
73 | - print "get_min_max_width() ". |
|
71 | + // Determine the image's size. Time consuming. Only when really needed? |
|
72 | + list($img_width, $img_height) = getimagesize($this->_frame->get_image_url()); |
|
73 | + print "get_min_max_width() ". |
|
74 | 74 | $this->_frame->get_style()->width.' '. |
75 | 75 | $this->_frame->get_style()->height.';'. |
76 | 76 | $this->_frame->get_parent()->get_style()->width." ". |
@@ -93,55 +93,55 @@ discard block |
||
93 | 93 | |
94 | 94 | $width = ($style->width > 0 ? $style->width : ($stylep->width > 0 ? $stylep->width : 0)); |
95 | 95 | if ( is_percent($width) ) { |
96 | - $t = 0.0; |
|
97 | - for ($f = $this->_frame->get_parent(); $f; $f = $f->get_parent()) { |
|
96 | + $t = 0.0; |
|
97 | + for ($f = $this->_frame->get_parent(); $f; $f = $f->get_parent()) { |
|
98 | 98 | $t = (float)($f->get_style()->width); //always in pt |
99 | 99 | if ((float)$t != 0) { |
100 | - break; |
|
100 | + break; |
|
101 | + } |
|
101 | 102 | } |
102 | - } |
|
103 | - $width = ((float)rtrim($width,"%") * $t)/100; //maybe 0 |
|
103 | + $width = ((float)rtrim($width,"%") * $t)/100; //maybe 0 |
|
104 | 104 | } else { |
105 | - // Don't set image original size if "%" branch was 0 or size not given. |
|
106 | - // Otherwise aspect changed on %/auto combination for width/height |
|
107 | - // Resample according to px per inch |
|
108 | - // See also List_Bullet_Image_Frame_Decorator::__construct |
|
109 | - $width = (float)($width * 72) / DOMPDF_DPI; |
|
105 | + // Don't set image original size if "%" branch was 0 or size not given. |
|
106 | + // Otherwise aspect changed on %/auto combination for width/height |
|
107 | + // Resample according to px per inch |
|
108 | + // See also List_Bullet_Image_Frame_Decorator::__construct |
|
109 | + $width = (float)($width * 72) / DOMPDF_DPI; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | $height = ($style->height > 0 ? $style->height : ($stylep->height > 0 ? $stylep->height : 0)); |
113 | 113 | if ( is_percent($height) ) { |
114 | - $t = 0.0; |
|
115 | - for ($f = $this->_frame->get_parent(); $f; $f = $f->get_parent()) { |
|
114 | + $t = 0.0; |
|
115 | + for ($f = $this->_frame->get_parent(); $f; $f = $f->get_parent()) { |
|
116 | 116 | $t = (float)($f->get_style()->height); //always in pt |
117 | 117 | if ((float)$t != 0) { |
118 | - break; |
|
118 | + break; |
|
119 | 119 | } |
120 | - } |
|
121 | - $height = ((float)rtrim($height,"%") * $t)/100; //maybe 0 |
|
120 | + } |
|
121 | + $height = ((float)rtrim($height,"%") * $t)/100; //maybe 0 |
|
122 | 122 | } else { |
123 | - // Don't set image original size if "%" branch was 0 or size not given. |
|
124 | - // Otherwise aspect changed on %/auto combination for width/height |
|
125 | - // Resample according to px per inch |
|
126 | - // See also List_Bullet_Image_Frame_Decorator::__construct |
|
127 | - $height = (float)($height * 72) / DOMPDF_DPI; |
|
123 | + // Don't set image original size if "%" branch was 0 or size not given. |
|
124 | + // Otherwise aspect changed on %/auto combination for width/height |
|
125 | + // Resample according to px per inch |
|
126 | + // See also List_Bullet_Image_Frame_Decorator::__construct |
|
127 | + $height = (float)($height * 72) / DOMPDF_DPI; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | if ($width == 0 || $height == 0) { |
131 | - // Determine the image's size. Time consuming. Only when really needed! |
|
132 | - list($img_width, $img_height) = getimagesize($this->_frame->get_image_url()); |
|
133 | - // don't treat 0 as error. Can be downscaled or can be catched elsewhere if image not readable. |
|
134 | - // Resample according to px per inch |
|
135 | - // See also List_Bullet_Image_Frame_Decorator::__construct |
|
131 | + // Determine the image's size. Time consuming. Only when really needed! |
|
132 | + list($img_width, $img_height) = getimagesize($this->_frame->get_image_url()); |
|
133 | + // don't treat 0 as error. Can be downscaled or can be catched elsewhere if image not readable. |
|
134 | + // Resample according to px per inch |
|
135 | + // See also List_Bullet_Image_Frame_Decorator::__construct |
|
136 | 136 | |
137 | - if ($width == 0 && $height == 0) { |
|
137 | + if ($width == 0 && $height == 0) { |
|
138 | 138 | $width = (float)($img_width * 72) / DOMPDF_DPI; |
139 | 139 | $height = (float)($img_height * 72) / DOMPDF_DPI; |
140 | - } elseif ($height == 0 && $width != 0) { |
|
140 | + } elseif ($height == 0 && $width != 0) { |
|
141 | 141 | $height = ($width / $img_width) * $img_height; //keep aspect ratio |
142 | - } elseif ($width == 0 && $height != 0) { |
|
142 | + } elseif ($width == 0 && $height != 0) { |
|
143 | 143 | $width = ($height / $img_height) * $img_width; //keep aspect ratio |
144 | - } |
|
144 | + } |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | if (DEBUGPNG) print $width.' '.$height.';'; |
@@ -173,5 +173,5 @@ discard block |
||
173 | 173 | |
174 | 174 | return array( $width, $width, "min" => $width, "max" => $width); |
175 | 175 | |
176 | - } |
|
176 | + } |
|
177 | 177 | } |
@@ -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_renderer.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,26 +46,26 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Block_Renderer extends Abstract_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 | - $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color ); |
|
57 | + $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color ); |
|
59 | 58 | } |
60 | 59 | |
61 | 60 | if ( ($url = $style->background_image) && $url !== "none" ) |
62 | - $this->_background_image($url, $x, $y, $w, $h, $style); |
|
61 | + $this->_background_image($url, $x, $y, $w, $h, $style); |
|
63 | 62 | |
64 | 63 | |
65 | 64 | $this->_render_border($frame); |
66 | 65 | |
67 | - } |
|
66 | + } |
|
68 | 67 | |
69 | - protected function _render_border(Frame_Decorator $frame, $corner_style = "bevel") { |
|
68 | + protected function _render_border(Frame_Decorator $frame, $corner_style = "bevel") { |
|
70 | 69 | $cb = $frame->get_containing_block(); |
71 | 70 | $style = $frame->get_style(); |
72 | 71 | |
@@ -79,36 +78,36 @@ discard block |
||
79 | 78 | $style->length_in_pt($bp["left"]["width"])); |
80 | 79 | |
81 | 80 | foreach ($bp as $side => $props) { |
82 | - list($x, $y, $w, $h) = $bbox; |
|
81 | + list($x, $y, $w, $h) = $bbox; |
|
83 | 82 | |
84 | - if ( !$props["style"] || $props["style"] === "none" || $props["width"] <= 0 ) |
|
83 | + if ( !$props["style"] || $props["style"] === "none" || $props["width"] <= 0 ) |
|
85 | 84 | continue; |
86 | 85 | |
87 | 86 | |
88 | - switch($side) { |
|
89 | - case "top": |
|
87 | + switch($side) { |
|
88 | + case "top": |
|
90 | 89 | $length = $w; |
91 | 90 | break; |
92 | 91 | |
93 | - case "bottom": |
|
92 | + case "bottom": |
|
94 | 93 | $length = $w; |
95 | 94 | $y += $h; |
96 | 95 | break; |
97 | 96 | |
98 | - case "left": |
|
97 | + case "left": |
|
99 | 98 | $length = $h; |
100 | 99 | break; |
101 | 100 | |
102 | - case "right": |
|
101 | + case "right": |
|
103 | 102 | $length = $h; |
104 | 103 | $x += $w; |
105 | 104 | break; |
106 | - default: |
|
105 | + default: |
|
107 | 106 | break; |
108 | - } |
|
109 | - $method = "_border_" . $props["style"]; |
|
107 | + } |
|
108 | + $method = "_border_" . $props["style"]; |
|
110 | 109 | |
111 | - $this->$method($x, $y, $length, $props["color"], $widths, $side, $corner_style); |
|
110 | + $this->$method($x, $y, $length, $props["color"], $widths, $side, $corner_style); |
|
111 | + } |
|
112 | 112 | } |
113 | - } |
|
114 | 113 | } |
@@ -47,20 +47,20 @@ |
||
47 | 47 | */ |
48 | 48 | class Javascript_Embedder { |
49 | 49 | |
50 | - /** |
|
51 | - * @var DOMPDF |
|
52 | - */ |
|
53 | - protected $_dompdf; |
|
50 | + /** |
|
51 | + * @var DOMPDF |
|
52 | + */ |
|
53 | + protected $_dompdf; |
|
54 | 54 | |
55 | - function __construct(DOMPDF $dompdf) { |
|
55 | + function __construct(DOMPDF $dompdf) { |
|
56 | 56 | $this->_dompdf = $dompdf; |
57 | - } |
|
57 | + } |
|
58 | 58 | |
59 | - function insert($code) { |
|
59 | + function insert($code) { |
|
60 | 60 | $this->_dompdf->get_canvas()->javascript($code); |
61 | - } |
|
61 | + } |
|
62 | 62 | |
63 | - function render($frame) { |
|
63 | + function render($frame) { |
|
64 | 64 | $this->insert($frame->get_node()->nodeValue); |
65 | - } |
|
65 | + } |
|
66 | 66 | } |
@@ -52,34 +52,34 @@ discard block |
||
52 | 52 | */ |
53 | 53 | class List_Bullet_Image_Frame_Decorator extends Frame_Decorator { |
54 | 54 | |
55 | - /** |
|
56 | - * The underlying image frame |
|
57 | - * |
|
58 | - * @var Image_Frame_Decorator |
|
59 | - */ |
|
60 | - protected $_img; |
|
55 | + /** |
|
56 | + * The underlying image frame |
|
57 | + * |
|
58 | + * @var Image_Frame_Decorator |
|
59 | + */ |
|
60 | + protected $_img; |
|
61 | 61 | |
62 | - /** |
|
63 | - * The image's width in pixels |
|
64 | - * |
|
65 | - * @var int |
|
66 | - */ |
|
67 | - protected $_width; |
|
62 | + /** |
|
63 | + * The image's width in pixels |
|
64 | + * |
|
65 | + * @var int |
|
66 | + */ |
|
67 | + protected $_width; |
|
68 | 68 | |
69 | - /** |
|
70 | - * The image's height in pixels |
|
71 | - * |
|
72 | - * @var int |
|
73 | - */ |
|
74 | - protected $_height; |
|
69 | + /** |
|
70 | + * The image's height in pixels |
|
71 | + * |
|
72 | + * @var int |
|
73 | + */ |
|
74 | + protected $_height; |
|
75 | 75 | |
76 | - /** |
|
77 | - * Class constructor |
|
78 | - * |
|
79 | - * @param Frame $frame the bullet frame to decorate |
|
80 | - * @param DOMPDF $dompdf the document's dompdf object |
|
81 | - */ |
|
82 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
76 | + /** |
|
77 | + * Class constructor |
|
78 | + * |
|
79 | + * @param Frame $frame the bullet frame to decorate |
|
80 | + * @param DOMPDF $dompdf the document's dompdf object |
|
81 | + */ |
|
82 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
83 | 83 | $style = $frame->get_style(); |
84 | 84 | $url = $style->list_style_image; |
85 | 85 | $frame->get_node()->setAttribute("src", $url); |
@@ -104,38 +104,38 @@ discard block |
||
104 | 104 | // $style->min_height = $this->_height; |
105 | 105 | //} |
106 | 106 | //$style->height = "auto"; |
107 | - } |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Return the bullet's width |
|
111 | - * |
|
112 | - * @return int |
|
113 | - */ |
|
114 | - function get_width() { |
|
109 | + /** |
|
110 | + * Return the bullet's width |
|
111 | + * |
|
112 | + * @return int |
|
113 | + */ |
|
114 | + function get_width() { |
|
115 | 115 | //ignore image width, use same width as on predefined bullet List_Bullet_Frame_Decorator |
116 | 116 | //for proper alignment of bullet image and text. Allow image to not fitting on left border. |
117 | 117 | //This controls the distance between bullet image and text |
118 | 118 | //return $this->_width; |
119 | 119 | return $this->_frame->get_style()->get_font_size()*List_Bullet_Frame_Decorator::BULLET_SIZE + |
120 | 120 | 2 * List_Bullet_Frame_Decorator::BULLET_PADDING; |
121 | - } |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * Return the bullet's height |
|
125 | - * |
|
126 | - * @return int |
|
127 | - */ |
|
128 | - function get_height() { |
|
123 | + /** |
|
124 | + * Return the bullet's height |
|
125 | + * |
|
126 | + * @return int |
|
127 | + */ |
|
128 | + function get_height() { |
|
129 | 129 | //based on image height |
130 | 130 | return $this->_height; |
131 | - } |
|
131 | + } |
|
132 | 132 | |
133 | - /** |
|
134 | - * Override get_margin_width |
|
135 | - * |
|
136 | - * @return int |
|
137 | - */ |
|
138 | - function get_margin_width() { |
|
133 | + /** |
|
134 | + * Override get_margin_width |
|
135 | + * |
|
136 | + * @return int |
|
137 | + */ |
|
138 | + function get_margin_width() { |
|
139 | 139 | //ignore image width, use same width as on predefined bullet List_Bullet_Frame_Decorator |
140 | 140 | //for proper alignment of bullet image and text. Allow image to not fitting on left border. |
141 | 141 | //This controls the extra indentation of text to make room for the bullet image. |
@@ -147,42 +147,42 @@ discard block |
||
147 | 147 | // Image Might not exist, then position like on list_bullet_frame_decorator fallback to none. |
148 | 148 | if ( $this->_frame->get_style()->list_style_position === "outside" || |
149 | 149 | $this->_width == 0) |
150 | - return 0; |
|
150 | + return 0; |
|
151 | 151 | //This aligns the "inside" image position with the text. |
152 | 152 | //The text starts to the right of the image. |
153 | 153 | //Between the image and the text there is an added margin of image width. |
154 | 154 | //Where this comes from is unknown. |
155 | 155 | //The corresponding List_Bullet_Frame_Decorator sets a smaller margin. bullet size? |
156 | 156 | return $this->_width + 2 * List_Bullet_Frame_Decorator::BULLET_PADDING; |
157 | - } |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
160 | - * Override get_margin_height() |
|
161 | - * |
|
162 | - * @return int |
|
163 | - */ |
|
164 | - function get_margin_height() { |
|
159 | + /** |
|
160 | + * Override get_margin_height() |
|
161 | + * |
|
162 | + * @return int |
|
163 | + */ |
|
164 | + function get_margin_height() { |
|
165 | 165 | //Hits only on "inset" lists items, to increase height of box |
166 | 166 | //based on image height |
167 | 167 | return $this->_height + 2 * List_Bullet_Frame_Decorator::BULLET_PADDING; |
168 | - } |
|
168 | + } |
|
169 | 169 | |
170 | - /** |
|
171 | - * Return image url |
|
172 | - * |
|
173 | - * @return string |
|
174 | - */ |
|
175 | - function get_image_url() { |
|
170 | + /** |
|
171 | + * Return image url |
|
172 | + * |
|
173 | + * @return string |
|
174 | + */ |
|
175 | + function get_image_url() { |
|
176 | 176 | return $this->_img->get_image_url(); |
177 | - } |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * Return the image extension |
|
181 | - * |
|
182 | - * @return string |
|
183 | - */ |
|
184 | - function get_image_ext() { |
|
179 | + /** |
|
180 | + * Return the image extension |
|
181 | + * |
|
182 | + * @return string |
|
183 | + */ |
|
184 | + function get_image_ext() { |
|
185 | 185 | return $this->_img->get_image_ext(); |
186 | - } |
|
186 | + } |
|
187 | 187 | |
188 | 188 | } |