@@ -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: inline_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,11 +46,11 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Inline_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 | - //........................................................................ |
|
51 | + //........................................................................ |
|
53 | 52 | |
54 | - function reflow() { |
|
53 | + function reflow() { |
|
55 | 54 | $style = $this->_frame->get_style(); |
56 | 55 | $this->_frame->position(); |
57 | 56 | |
@@ -59,23 +58,23 @@ discard block |
||
59 | 58 | |
60 | 59 | // Add our margin, padding & border to the first and last children |
61 | 60 | if ( ($f = $this->_frame->get_first_child()) && $f instanceof Text_Frame_Decorator ) { |
62 | - $f->get_style()->margin_left = $style->margin_left; |
|
63 | - $f->get_style()->padding_left = $style->padding_left; |
|
64 | - $f->get_style()->border_left = $style->border_left; |
|
61 | + $f->get_style()->margin_left = $style->margin_left; |
|
62 | + $f->get_style()->padding_left = $style->padding_left; |
|
63 | + $f->get_style()->border_left = $style->border_left; |
|
65 | 64 | } |
66 | 65 | |
67 | 66 | if ( ($l = $this->_frame->get_last_child()) && $l instanceof Text_Frame_Decorator ) { |
68 | - $f->get_style()->margin_right = $style->margin_right; |
|
69 | - $f->get_style()->padding_right = $style->padding_right; |
|
70 | - $f->get_style()->border_right = $style->border_right; |
|
67 | + $f->get_style()->margin_right = $style->margin_right; |
|
68 | + $f->get_style()->padding_right = $style->padding_right; |
|
69 | + $f->get_style()->border_right = $style->border_right; |
|
71 | 70 | } |
72 | 71 | |
73 | 72 | // Set the containing blocks and reflow each child. The containing |
74 | 73 | // block is not changed by line boxes. |
75 | 74 | foreach ( $this->_frame->get_children() as $child ) { |
76 | 75 | |
77 | - $child->set_containing_block($cb); |
|
78 | - $child->reflow(); |
|
76 | + $child->set_containing_block($cb); |
|
77 | + $child->reflow(); |
|
78 | + } |
|
79 | 79 | } |
80 | - } |
|
81 | 80 | } |
@@ -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: text_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,34 +46,34 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Text_Frame_Decorator extends Frame_Decorator { |
49 | 48 | |
50 | - // protected members |
|
51 | - protected $_text_spacing; |
|
49 | + // protected members |
|
50 | + protected $_text_spacing; |
|
52 | 51 | |
53 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
52 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
54 | 53 | if ( $frame->get_node()->nodeName !== "#text" ) |
55 | - throw new DOMPDF_Exception("Text_Decorator can only be applied to #text nodes."); |
|
54 | + throw new DOMPDF_Exception("Text_Decorator can only be applied to #text nodes."); |
|
56 | 55 | |
57 | 56 | parent::__construct($frame, $dompdf); |
58 | 57 | $this->_text_spacing = null; |
59 | - } |
|
58 | + } |
|
60 | 59 | |
61 | - //........................................................................ |
|
60 | + //........................................................................ |
|
62 | 61 | |
63 | - function reset() { |
|
62 | + function reset() { |
|
64 | 63 | parent::reset(); |
65 | 64 | $this->_text_spacing = null; |
66 | - } |
|
65 | + } |
|
67 | 66 | |
68 | - //........................................................................ |
|
67 | + //........................................................................ |
|
69 | 68 | |
70 | - // Accessor methods |
|
71 | - function get_text_spacing() { return $this->_text_spacing; } |
|
69 | + // Accessor methods |
|
70 | + function get_text_spacing() { return $this->_text_spacing; } |
|
72 | 71 | |
73 | - function get_text() { |
|
72 | + function get_text() { |
|
74 | 73 | // FIXME: this should be in a child class (and is incorrect) |
75 | 74 | if ( $this->_frame->get_style()->content !== "normal" ) { |
76 | - $this->_frame->get_node()->data = $this->_frame->get_style()->content; |
|
77 | - $this->_frame->get_style()->content = "normal"; |
|
75 | + $this->_frame->get_node()->data = $this->_frame->get_style()->content; |
|
76 | + $this->_frame->get_style()->content = "normal"; |
|
78 | 77 | } |
79 | 78 | |
80 | 79 | // pre_r("---"); |
@@ -86,19 +85,19 @@ discard block |
||
86 | 85 | // pre_r("width: " . Font_Metrics::get_text_width($text, $style->font_family, $style->font_size)); |
87 | 86 | |
88 | 87 | return $this->_frame->get_node()->data; |
89 | - } |
|
88 | + } |
|
90 | 89 | |
91 | - //........................................................................ |
|
90 | + //........................................................................ |
|
92 | 91 | |
93 | - // Vertical margins & padding do not apply to text frames |
|
92 | + // Vertical margins & padding do not apply to text frames |
|
94 | 93 | |
95 | - // http://www.w3.org/TR/CSS21/visudet.html#inline-non-replaced: |
|
96 | - // |
|
97 | - // The vertical padding, border and margin of an inline, non-replaced box |
|
98 | - // start at the top and bottom of the content area, not the |
|
99 | - // 'line-height'. But only the 'line-height' is used to calculate the |
|
100 | - // height of the line box. |
|
101 | - function get_margin_height() { |
|
94 | + // http://www.w3.org/TR/CSS21/visudet.html#inline-non-replaced: |
|
95 | + // |
|
96 | + // The vertical padding, border and margin of an inline, non-replaced box |
|
97 | + // start at the top and bottom of the content area, not the |
|
98 | + // 'line-height'. But only the 'line-height' is used to calculate the |
|
99 | + // height of the line box. |
|
100 | + function get_margin_height() { |
|
102 | 101 | // This function is called in add_frame_to_line() and is used to |
103 | 102 | // determine the line height, so we actually want to return the |
104 | 103 | // 'line-height' property, not the actual margin box |
@@ -116,28 +115,28 @@ discard block |
||
116 | 115 | |
117 | 116 | return ($style->line_height / $size) * Font_Metrics::get_font_height($font, $size); |
118 | 117 | |
119 | - } |
|
118 | + } |
|
120 | 119 | |
121 | - function get_padding_box() { |
|
120 | + function get_padding_box() { |
|
122 | 121 | $pb = $this->_frame->get_padding_box(); |
123 | 122 | $pb[3] = $pb["h"] = $this->_frame->get_style()->height; |
124 | 123 | return $pb; |
125 | - } |
|
126 | - //........................................................................ |
|
124 | + } |
|
125 | + //........................................................................ |
|
127 | 126 | |
128 | - // Set method |
|
129 | - function set_text_spacing($spacing) { |
|
127 | + // Set method |
|
128 | + function set_text_spacing($spacing) { |
|
130 | 129 | $this->_text_spacing = $spacing; |
131 | 130 | |
132 | 131 | $style = $this->_frame->get_style(); |
133 | 132 | // Re-adjust our width to account for the change in spacing |
134 | 133 | $style->width = Font_Metrics::get_text_width($this->get_text(), $style->font_family, $style->font_size, $spacing); |
135 | - } |
|
134 | + } |
|
136 | 135 | |
137 | - //........................................................................ |
|
136 | + //........................................................................ |
|
138 | 137 | |
139 | - // Recalculate the text width |
|
140 | - function recalculate_width() { |
|
138 | + // Recalculate the text width |
|
139 | + function recalculate_width() { |
|
141 | 140 | $style = $this->get_style(); |
142 | 141 | $text = $this->get_text(); |
143 | 142 | $size = $style->font_size; |
@@ -145,17 +144,17 @@ discard block |
||
145 | 144 | $word_spacing = $style->length_in_pt($style->word_spacing); |
146 | 145 | |
147 | 146 | $style->width = Font_Metrics::get_text_width($text, $font, $size, $word_spacing); |
148 | - } |
|
147 | + } |
|
149 | 148 | |
150 | - //........................................................................ |
|
149 | + //........................................................................ |
|
151 | 150 | |
152 | - // Text manipulation methods |
|
151 | + // Text manipulation methods |
|
153 | 152 | |
154 | - // split the text in this frame at the offset specified. The remaining |
|
155 | - // text is added a sibling frame following this one and is returned. |
|
156 | - function split_text($offset) { |
|
153 | + // split the text in this frame at the offset specified. The remaining |
|
154 | + // text is added a sibling frame following this one and is returned. |
|
155 | + function split_text($offset) { |
|
157 | 156 | if ( $offset == 0 ) |
158 | - return; |
|
157 | + return; |
|
159 | 158 | |
160 | 159 | $split = $this->_frame->get_node()->splitText($offset); |
161 | 160 | $deco = $this->copy($split); |
@@ -164,20 +163,20 @@ discard block |
||
164 | 163 | $p->insert_child_after($deco, $this, false); |
165 | 164 | |
166 | 165 | if ( $p instanceof Inline_Frame_Decorator ) |
167 | - $p->split($deco); |
|
166 | + $p->split($deco); |
|
168 | 167 | |
169 | - } |
|
168 | + } |
|
170 | 169 | |
171 | - //........................................................................ |
|
170 | + //........................................................................ |
|
172 | 171 | |
173 | - function delete_text($offset, $count) { |
|
172 | + function delete_text($offset, $count) { |
|
174 | 173 | $this->_frame->get_node()->deleteData($offset, $count); |
175 | - } |
|
174 | + } |
|
176 | 175 | |
177 | - //........................................................................ |
|
176 | + //........................................................................ |
|
178 | 177 | |
179 | - function set_text($text) { |
|
178 | + function set_text($text) { |
|
180 | 179 | $this->_frame->get_node()->data = $text; |
181 | - } |
|
180 | + } |
|
182 | 181 | |
183 | 182 | } |
@@ -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_positioner.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,15 +46,15 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Table_Cell_Positioner extends Positioner { |
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 position() { |
|
53 | + function position() { |
|
55 | 54 | |
56 | 55 | $table = Table_Frame_Decorator::find_parent_table($this->_frame); |
57 | 56 | $cellmap = $table->get_cellmap(); |
58 | 57 | $this->_frame->set_position($cellmap->get_frame_position($this->_frame)); |
59 | 58 | |
60 | - } |
|
59 | + } |
|
61 | 60 | } |
@@ -1,41 +1,40 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: canvas.cls.php,v $ |
|
6 | - * Created on: 2004-06-06 |
|
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: canvas.cls.php,v $ |
|
6 | + * Created on: 2004-06-06 |
|
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: canvas.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
41 | 40 | |
@@ -54,207 +53,207 @@ discard block |
||
54 | 53 | */ |
55 | 54 | interface Canvas { |
56 | 55 | |
57 | - /** |
|
58 | - * Returns the current page number |
|
59 | - * |
|
60 | - * @return int |
|
61 | - */ |
|
62 | - function get_page_number(); |
|
56 | + /** |
|
57 | + * Returns the current page number |
|
58 | + * |
|
59 | + * @return int |
|
60 | + */ |
|
61 | + function get_page_number(); |
|
63 | 62 | |
64 | - /** |
|
65 | - * Returns the total number of pages |
|
66 | - * |
|
67 | - * @return int |
|
68 | - */ |
|
69 | - function get_page_count(); |
|
63 | + /** |
|
64 | + * Returns the total number of pages |
|
65 | + * |
|
66 | + * @return int |
|
67 | + */ |
|
68 | + function get_page_count(); |
|
70 | 69 | |
71 | - /** |
|
72 | - * Sets the total number of pages |
|
73 | - * |
|
74 | - * @param int $count |
|
75 | - */ |
|
76 | - function set_page_count($count); |
|
70 | + /** |
|
71 | + * Sets the total number of pages |
|
72 | + * |
|
73 | + * @param int $count |
|
74 | + */ |
|
75 | + function set_page_count($count); |
|
77 | 76 | |
78 | - /** |
|
79 | - * Draws a line from x1,y1 to x2,y2 |
|
80 | - * |
|
81 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
82 | - * See {@link Cpdf::setLineStyle()} for a description of the format of the |
|
83 | - * $style parameter (aka dash). |
|
84 | - * |
|
85 | - * @param float $x1 |
|
86 | - * @param float $y1 |
|
87 | - * @param float $x2 |
|
88 | - * @param float $y2 |
|
89 | - * @param array $color |
|
90 | - * @param float $width |
|
91 | - * @param array $style |
|
92 | - */ |
|
93 | - function line($x1, $y1, $x2, $y2, $color, $width, $style = null); |
|
77 | + /** |
|
78 | + * Draws a line from x1,y1 to x2,y2 |
|
79 | + * |
|
80 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
81 | + * See {@link Cpdf::setLineStyle()} for a description of the format of the |
|
82 | + * $style parameter (aka dash). |
|
83 | + * |
|
84 | + * @param float $x1 |
|
85 | + * @param float $y1 |
|
86 | + * @param float $x2 |
|
87 | + * @param float $y2 |
|
88 | + * @param array $color |
|
89 | + * @param float $width |
|
90 | + * @param array $style |
|
91 | + */ |
|
92 | + function line($x1, $y1, $x2, $y2, $color, $width, $style = null); |
|
94 | 93 | |
95 | - /** |
|
96 | - * Draws a rectangle at x1,y1 with width w and height h |
|
97 | - * |
|
98 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
99 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
100 | - * parameter (aka dash) |
|
101 | - * |
|
102 | - * @param float $x1 |
|
103 | - * @param float $y1 |
|
104 | - * @param float $w |
|
105 | - * @param float $h |
|
106 | - * @param array $color |
|
107 | - * @param float $width |
|
108 | - * @param array $style |
|
109 | - */ |
|
110 | - function rectangle($x1, $y1, $w, $h, $color, $width, $style = null); |
|
94 | + /** |
|
95 | + * Draws a rectangle at x1,y1 with width w and height h |
|
96 | + * |
|
97 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
98 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
99 | + * parameter (aka dash) |
|
100 | + * |
|
101 | + * @param float $x1 |
|
102 | + * @param float $y1 |
|
103 | + * @param float $w |
|
104 | + * @param float $h |
|
105 | + * @param array $color |
|
106 | + * @param float $width |
|
107 | + * @param array $style |
|
108 | + */ |
|
109 | + function rectangle($x1, $y1, $w, $h, $color, $width, $style = null); |
|
111 | 110 | |
112 | - /** |
|
113 | - * Draws a filled rectangle at x1,y1 with width w and height h |
|
114 | - * |
|
115 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
116 | - * |
|
117 | - * @param float $x1 |
|
118 | - * @param float $y1 |
|
119 | - * @param float $w |
|
120 | - * @param float $h |
|
121 | - * @param array $color |
|
122 | - */ |
|
123 | - function filled_rectangle($x1, $y1, $w, $h, $color); |
|
111 | + /** |
|
112 | + * Draws a filled rectangle at x1,y1 with width w and height h |
|
113 | + * |
|
114 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
115 | + * |
|
116 | + * @param float $x1 |
|
117 | + * @param float $y1 |
|
118 | + * @param float $w |
|
119 | + * @param float $h |
|
120 | + * @param array $color |
|
121 | + */ |
|
122 | + function filled_rectangle($x1, $y1, $w, $h, $color); |
|
124 | 123 | |
125 | - /** |
|
126 | - * Draws a polygon |
|
127 | - * |
|
128 | - * The polygon is formed by joining all the points stored in the $points |
|
129 | - * array. $points has the following structure: |
|
130 | - * <code> |
|
131 | - * array(0 => x1, |
|
132 | - * 1 => y1, |
|
133 | - * 2 => x2, |
|
134 | - * 3 => y2, |
|
135 | - * ... |
|
136 | - * ); |
|
137 | - * </code> |
|
138 | - * |
|
139 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
140 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
141 | - * parameter (aka dash) |
|
142 | - * |
|
143 | - * @param array $points |
|
144 | - * @param array $color |
|
145 | - * @param float $width |
|
146 | - * @param array $style |
|
147 | - * @param bool $fill Fills the polygon if true |
|
148 | - */ |
|
149 | - function polygon($points, $color, $width = null, $style = null, $fill = false); |
|
124 | + /** |
|
125 | + * Draws a polygon |
|
126 | + * |
|
127 | + * The polygon is formed by joining all the points stored in the $points |
|
128 | + * array. $points has the following structure: |
|
129 | + * <code> |
|
130 | + * array(0 => x1, |
|
131 | + * 1 => y1, |
|
132 | + * 2 => x2, |
|
133 | + * 3 => y2, |
|
134 | + * ... |
|
135 | + * ); |
|
136 | + * </code> |
|
137 | + * |
|
138 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
139 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
140 | + * parameter (aka dash) |
|
141 | + * |
|
142 | + * @param array $points |
|
143 | + * @param array $color |
|
144 | + * @param float $width |
|
145 | + * @param array $style |
|
146 | + * @param bool $fill Fills the polygon if true |
|
147 | + */ |
|
148 | + function polygon($points, $color, $width = null, $style = null, $fill = false); |
|
150 | 149 | |
151 | - /** |
|
152 | - * Draws a circle at $x,$y with radius $r |
|
153 | - * |
|
154 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
155 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
156 | - * parameter (aka dash) |
|
157 | - * |
|
158 | - * @param float $x |
|
159 | - * @param float $y |
|
160 | - * @param float $r |
|
161 | - * @param array $color |
|
162 | - * @param float $width |
|
163 | - * @param array $style |
|
164 | - * @param bool $fill Fills the circle if true |
|
165 | - */ |
|
166 | - function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false); |
|
150 | + /** |
|
151 | + * Draws a circle at $x,$y with radius $r |
|
152 | + * |
|
153 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
154 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
155 | + * parameter (aka dash) |
|
156 | + * |
|
157 | + * @param float $x |
|
158 | + * @param float $y |
|
159 | + * @param float $r |
|
160 | + * @param array $color |
|
161 | + * @param float $width |
|
162 | + * @param array $style |
|
163 | + * @param bool $fill Fills the circle if true |
|
164 | + */ |
|
165 | + function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false); |
|
167 | 166 | |
168 | - /** |
|
169 | - * Add an image to the pdf. |
|
170 | - * |
|
171 | - * The image is placed at the specified x and y coordinates with the |
|
172 | - * given width and height. |
|
173 | - * |
|
174 | - * @param string $img_url the path to the image |
|
175 | - * @param string $img_type the type (e.g. extension) of the image |
|
176 | - * @param float $x x position |
|
177 | - * @param float $y y position |
|
178 | - * @param int $w width (in pixels) |
|
179 | - * @param int $h height (in pixels) |
|
180 | - */ |
|
181 | - function image($img_url, $img_type, $x, $y, $w, $h); |
|
167 | + /** |
|
168 | + * Add an image to the pdf. |
|
169 | + * |
|
170 | + * The image is placed at the specified x and y coordinates with the |
|
171 | + * given width and height. |
|
172 | + * |
|
173 | + * @param string $img_url the path to the image |
|
174 | + * @param string $img_type the type (e.g. extension) of the image |
|
175 | + * @param float $x x position |
|
176 | + * @param float $y y position |
|
177 | + * @param int $w width (in pixels) |
|
178 | + * @param int $h height (in pixels) |
|
179 | + */ |
|
180 | + function image($img_url, $img_type, $x, $y, $w, $h); |
|
182 | 181 | |
183 | - /** |
|
184 | - * Writes text at the specified x and y coordinates |
|
185 | - * |
|
186 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
187 | - * |
|
188 | - * @param float $x |
|
189 | - * @param float $y |
|
190 | - * @param string $text the text to write |
|
191 | - * @param string $font the font file to use |
|
192 | - * @param float $size the font size, in points |
|
193 | - * @param array $color |
|
194 | - * @param float $adjust word spacing adjustment |
|
195 | - */ |
|
196 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0); |
|
182 | + /** |
|
183 | + * Writes text at the specified x and y coordinates |
|
184 | + * |
|
185 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
186 | + * |
|
187 | + * @param float $x |
|
188 | + * @param float $y |
|
189 | + * @param string $text the text to write |
|
190 | + * @param string $font the font file to use |
|
191 | + * @param float $size the font size, in points |
|
192 | + * @param array $color |
|
193 | + * @param float $adjust word spacing adjustment |
|
194 | + */ |
|
195 | + function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0); |
|
197 | 196 | |
198 | - /** |
|
199 | - * Add a named destination (similar to <a name="foo">...</a> in html) |
|
200 | - * |
|
201 | - * @param string $anchorname The name of the named destination |
|
202 | - */ |
|
203 | - function add_named_dest($anchorname); |
|
197 | + /** |
|
198 | + * Add a named destination (similar to <a name="foo">...</a> in html) |
|
199 | + * |
|
200 | + * @param string $anchorname The name of the named destination |
|
201 | + */ |
|
202 | + function add_named_dest($anchorname); |
|
204 | 203 | |
205 | - /** |
|
206 | - * Add a link to the pdf |
|
207 | - * |
|
208 | - * @param string $url The url to link to |
|
209 | - * @param float $x The x position of the link |
|
210 | - * @param float $y The y position of the link |
|
211 | - * @param float $width The width of the link |
|
212 | - * @param float $height The height of the link |
|
213 | - */ |
|
214 | - function add_link($url, $x, $y, $width, $height); |
|
204 | + /** |
|
205 | + * Add a link to the pdf |
|
206 | + * |
|
207 | + * @param string $url The url to link to |
|
208 | + * @param float $x The x position of the link |
|
209 | + * @param float $y The y position of the link |
|
210 | + * @param float $width The width of the link |
|
211 | + * @param float $height The height of the link |
|
212 | + */ |
|
213 | + function add_link($url, $x, $y, $width, $height); |
|
215 | 214 | |
216 | - /** |
|
217 | - * Calculates text size, in points |
|
218 | - * |
|
219 | - * @param string $text the text to be sized |
|
220 | - * @param string $font the desired font |
|
221 | - * @param float $size the desired font size |
|
222 | - * @param float $spacing word spacing, if any |
|
223 | - * @return float |
|
224 | - */ |
|
225 | - function get_text_width($text, $font, $size, $spacing = 0); |
|
215 | + /** |
|
216 | + * Calculates text size, in points |
|
217 | + * |
|
218 | + * @param string $text the text to be sized |
|
219 | + * @param string $font the desired font |
|
220 | + * @param float $size the desired font size |
|
221 | + * @param float $spacing word spacing, if any |
|
222 | + * @return float |
|
223 | + */ |
|
224 | + function get_text_width($text, $font, $size, $spacing = 0); |
|
226 | 225 | |
227 | - /** |
|
228 | - * Calculates font height, in points |
|
229 | - * |
|
230 | - * @param string $font |
|
231 | - * @param float $size |
|
232 | - * @return float |
|
233 | - */ |
|
234 | - function get_font_height($font, $size); |
|
226 | + /** |
|
227 | + * Calculates font height, in points |
|
228 | + * |
|
229 | + * @param string $font |
|
230 | + * @param float $size |
|
231 | + * @return float |
|
232 | + */ |
|
233 | + function get_font_height($font, $size); |
|
235 | 234 | |
236 | 235 | |
237 | - /** |
|
238 | - * Starts a new page |
|
239 | - * |
|
240 | - * Subsequent drawing operations will appear on the new page. |
|
241 | - */ |
|
242 | - function new_page(); |
|
236 | + /** |
|
237 | + * Starts a new page |
|
238 | + * |
|
239 | + * Subsequent drawing operations will appear on the new page. |
|
240 | + */ |
|
241 | + function new_page(); |
|
243 | 242 | |
244 | - /** |
|
245 | - * Streams the PDF directly to the browser |
|
246 | - * |
|
247 | - * @param string $filename the name of the PDF file |
|
248 | - * @param array $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0 |
|
249 | - */ |
|
250 | - function stream($filename, $options = null); |
|
243 | + /** |
|
244 | + * Streams the PDF directly to the browser |
|
245 | + * |
|
246 | + * @param string $filename the name of the PDF file |
|
247 | + * @param array $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0 |
|
248 | + */ |
|
249 | + function stream($filename, $options = null); |
|
251 | 250 | |
252 | - /** |
|
253 | - * Returns the PDF as a string |
|
254 | - * |
|
255 | - * @param array $options associative array: 'compress' => 1 or 0 |
|
256 | - * @return string |
|
257 | - */ |
|
258 | - function output($options = null); |
|
251 | + /** |
|
252 | + * Returns the PDF as a string |
|
253 | + * |
|
254 | + * @param array $options associative array: 'compress' => 1 or 0 |
|
255 | + * @return string |
|
256 | + */ |
|
257 | + function output($options = null); |
|
259 | 258 | |
260 | 259 | } |
@@ -71,201 +71,201 @@ discard block |
||
71 | 71 | |
72 | 72 | |
73 | 73 | |
74 | - /** |
|
75 | - * the location of the default built-in CSS file. |
|
76 | - * |
|
77 | - */ |
|
78 | - const DEFAULT_STYLESHEET = __DEFAULT_STYLESHEET; // Hack: can't |
|
79 | - // concatenate stuff in |
|
80 | - // const declarations, |
|
81 | - // but I can do this? |
|
82 | - // protected members |
|
83 | - |
|
84 | - /** |
|
85 | - * array of currently defined styles |
|
86 | - * @var array |
|
87 | - */ |
|
88 | - private $_styles; |
|
89 | - |
|
90 | - /** |
|
91 | - * base protocol of the document being parsed |
|
92 | - * |
|
93 | - * Used to handle relative urls. |
|
94 | - * |
|
95 | - * @var string |
|
96 | - */ |
|
97 | - private $_protocol; |
|
98 | - |
|
99 | - /** |
|
100 | - * base hostname of the document being parsed |
|
101 | - * |
|
102 | - * Used to handle relative urls. |
|
103 | - * @var string |
|
104 | - */ |
|
105 | - private $_base_host; |
|
106 | - |
|
107 | - /** |
|
108 | - * base path of the document being parsed |
|
109 | - * |
|
110 | - * Used to handle relative urls. |
|
111 | - * @var string |
|
112 | - */ |
|
113 | - private $_base_path; |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * the style defined by @page rules |
|
118 | - * |
|
119 | - * @var Style |
|
120 | - */ |
|
121 | - private $_page_style; |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * list of loaded files, used to prevent recursion |
|
126 | - * |
|
127 | - * @var array |
|
128 | - */ |
|
129 | - private $_loaded_files; |
|
130 | - |
|
131 | - /** |
|
132 | - * accepted CSS media types |
|
133 | - * List of types and parsing rules for future extensions: |
|
134 | - * http://www.w3.org/TR/REC-html40/types.html |
|
135 | - * screen, tty, tv, projection, handheld, print, braille, aural, all |
|
136 | - * The following are non standard extensions for undocumented specific environments. |
|
137 | - * static, visual, bitmap, paged |
|
138 | - * Note, even though the generated pdf file is intended for print output, |
|
139 | - * the desired content might be different (e.g. screen or projection view of html file). |
|
140 | - * Therefore allow specification of content by dompdf setting DOMPDF_DEFAULT_MEDIA_TYPE. |
|
141 | - * If given, replace media "print" by DOMPDF_DEFAULT_MEDIA_TYPE. |
|
142 | - * (Previous version $ACCEPTED_MEDIA_TYPES = $ACCEPTED_GENERIC_MEDIA_TYPES + $ACCEPTED_DEFAULT_MEDIA_TYPE) |
|
143 | - */ |
|
144 | - static $ACCEPTED_DEFAULT_MEDIA_TYPE = "print"; |
|
145 | - static $ACCEPTED_GENERIC_MEDIA_TYPES = array("all", "static", "visual", "bitmap", "paged"); |
|
146 | - |
|
147 | - /** |
|
148 | - * The class constructor. |
|
149 | - * |
|
150 | - * The base protocol, host & path are initialized to those of |
|
151 | - * the current script. |
|
152 | - */ |
|
153 | - function __construct() { |
|
74 | + /** |
|
75 | + * the location of the default built-in CSS file. |
|
76 | + * |
|
77 | + */ |
|
78 | + const DEFAULT_STYLESHEET = __DEFAULT_STYLESHEET; // Hack: can't |
|
79 | + // concatenate stuff in |
|
80 | + // const declarations, |
|
81 | + // but I can do this? |
|
82 | + // protected members |
|
83 | + |
|
84 | + /** |
|
85 | + * array of currently defined styles |
|
86 | + * @var array |
|
87 | + */ |
|
88 | + private $_styles; |
|
89 | + |
|
90 | + /** |
|
91 | + * base protocol of the document being parsed |
|
92 | + * |
|
93 | + * Used to handle relative urls. |
|
94 | + * |
|
95 | + * @var string |
|
96 | + */ |
|
97 | + private $_protocol; |
|
98 | + |
|
99 | + /** |
|
100 | + * base hostname of the document being parsed |
|
101 | + * |
|
102 | + * Used to handle relative urls. |
|
103 | + * @var string |
|
104 | + */ |
|
105 | + private $_base_host; |
|
106 | + |
|
107 | + /** |
|
108 | + * base path of the document being parsed |
|
109 | + * |
|
110 | + * Used to handle relative urls. |
|
111 | + * @var string |
|
112 | + */ |
|
113 | + private $_base_path; |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * the style defined by @page rules |
|
118 | + * |
|
119 | + * @var Style |
|
120 | + */ |
|
121 | + private $_page_style; |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * list of loaded files, used to prevent recursion |
|
126 | + * |
|
127 | + * @var array |
|
128 | + */ |
|
129 | + private $_loaded_files; |
|
130 | + |
|
131 | + /** |
|
132 | + * accepted CSS media types |
|
133 | + * List of types and parsing rules for future extensions: |
|
134 | + * http://www.w3.org/TR/REC-html40/types.html |
|
135 | + * screen, tty, tv, projection, handheld, print, braille, aural, all |
|
136 | + * The following are non standard extensions for undocumented specific environments. |
|
137 | + * static, visual, bitmap, paged |
|
138 | + * Note, even though the generated pdf file is intended for print output, |
|
139 | + * the desired content might be different (e.g. screen or projection view of html file). |
|
140 | + * Therefore allow specification of content by dompdf setting DOMPDF_DEFAULT_MEDIA_TYPE. |
|
141 | + * If given, replace media "print" by DOMPDF_DEFAULT_MEDIA_TYPE. |
|
142 | + * (Previous version $ACCEPTED_MEDIA_TYPES = $ACCEPTED_GENERIC_MEDIA_TYPES + $ACCEPTED_DEFAULT_MEDIA_TYPE) |
|
143 | + */ |
|
144 | + static $ACCEPTED_DEFAULT_MEDIA_TYPE = "print"; |
|
145 | + static $ACCEPTED_GENERIC_MEDIA_TYPES = array("all", "static", "visual", "bitmap", "paged"); |
|
146 | + |
|
147 | + /** |
|
148 | + * The class constructor. |
|
149 | + * |
|
150 | + * The base protocol, host & path are initialized to those of |
|
151 | + * the current script. |
|
152 | + */ |
|
153 | + function __construct() { |
|
154 | 154 | $this->_styles = array(); |
155 | 155 | $this->_loaded_files = array(); |
156 | 156 | list($this->_protocol, $this->_base_host, $this->_base_path) = explode_url($_SERVER["SCRIPT_FILENAME"]); |
157 | 157 | $this->_page_style = null; |
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * Set the base protocol |
|
162 | - * |
|
163 | - * @param string $proto |
|
164 | - */ |
|
165 | - function set_protocol($proto) { $this->_protocol = $proto; } |
|
166 | - |
|
167 | - /** |
|
168 | - * Set the base host |
|
169 | - * |
|
170 | - * @param string $host |
|
171 | - */ |
|
172 | - function set_host($host) { $this->_base_host = $host; } |
|
173 | - |
|
174 | - /** |
|
175 | - * Set the base path |
|
176 | - * |
|
177 | - * @param string $path |
|
178 | - */ |
|
179 | - function set_base_path($path) { $this->_base_path = $path; } |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * Return the base protocol for this stylesheet |
|
184 | - * |
|
185 | - * @return string |
|
186 | - */ |
|
187 | - function get_protocol() { return $this->_protocol; } |
|
188 | - |
|
189 | - /** |
|
190 | - * Return the base host for this stylesheet |
|
191 | - * |
|
192 | - * @return string |
|
193 | - */ |
|
194 | - function get_host() { return $this->_base_host; } |
|
195 | - |
|
196 | - /** |
|
197 | - * Return the base path for this stylesheet |
|
198 | - * |
|
199 | - * @return string |
|
200 | - */ |
|
201 | - function get_base_path() { return $this->_base_path; } |
|
202 | - |
|
203 | - /** |
|
204 | - * add a new Style object to the stylesheet |
|
205 | - * |
|
206 | - * add_style() adds a new Style object to the current stylesheet, or |
|
207 | - * merges a new Style with an existing one. |
|
208 | - * |
|
209 | - * @param string $key the Style's selector |
|
210 | - * @param Style $style the Style to be added |
|
211 | - */ |
|
212 | - function add_style($key, Style $style) { |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * Set the base protocol |
|
162 | + * |
|
163 | + * @param string $proto |
|
164 | + */ |
|
165 | + function set_protocol($proto) { $this->_protocol = $proto; } |
|
166 | + |
|
167 | + /** |
|
168 | + * Set the base host |
|
169 | + * |
|
170 | + * @param string $host |
|
171 | + */ |
|
172 | + function set_host($host) { $this->_base_host = $host; } |
|
173 | + |
|
174 | + /** |
|
175 | + * Set the base path |
|
176 | + * |
|
177 | + * @param string $path |
|
178 | + */ |
|
179 | + function set_base_path($path) { $this->_base_path = $path; } |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * Return the base protocol for this stylesheet |
|
184 | + * |
|
185 | + * @return string |
|
186 | + */ |
|
187 | + function get_protocol() { return $this->_protocol; } |
|
188 | + |
|
189 | + /** |
|
190 | + * Return the base host for this stylesheet |
|
191 | + * |
|
192 | + * @return string |
|
193 | + */ |
|
194 | + function get_host() { return $this->_base_host; } |
|
195 | + |
|
196 | + /** |
|
197 | + * Return the base path for this stylesheet |
|
198 | + * |
|
199 | + * @return string |
|
200 | + */ |
|
201 | + function get_base_path() { return $this->_base_path; } |
|
202 | + |
|
203 | + /** |
|
204 | + * add a new Style object to the stylesheet |
|
205 | + * |
|
206 | + * add_style() adds a new Style object to the current stylesheet, or |
|
207 | + * merges a new Style with an existing one. |
|
208 | + * |
|
209 | + * @param string $key the Style's selector |
|
210 | + * @param Style $style the Style to be added |
|
211 | + */ |
|
212 | + function add_style($key, Style $style) { |
|
213 | 213 | if (!is_string($key)) |
214 | - throw new DOMPDF_Exception("CSS rule must be keyed by a string."); |
|
214 | + throw new DOMPDF_Exception("CSS rule must be keyed by a string."); |
|
215 | 215 | |
216 | 216 | if ( isset($this->_styles[$key]) ) |
217 | - $this->_styles[$key]->merge($style); |
|
217 | + $this->_styles[$key]->merge($style); |
|
218 | 218 | else |
219 | - $this->_styles[$key] = clone $style; |
|
220 | - } |
|
221 | - |
|
222 | - |
|
223 | - /** |
|
224 | - * lookup a specifc Style object |
|
225 | - * |
|
226 | - * lookup() returns the Style specified by $key, or null if the Style is |
|
227 | - * not found. |
|
228 | - * |
|
229 | - * @param string $key the selector of the requested Style |
|
230 | - * @return Style |
|
231 | - */ |
|
232 | - function lookup($key) { |
|
219 | + $this->_styles[$key] = clone $style; |
|
220 | + } |
|
221 | + |
|
222 | + |
|
223 | + /** |
|
224 | + * lookup a specifc Style object |
|
225 | + * |
|
226 | + * lookup() returns the Style specified by $key, or null if the Style is |
|
227 | + * not found. |
|
228 | + * |
|
229 | + * @param string $key the selector of the requested Style |
|
230 | + * @return Style |
|
231 | + */ |
|
232 | + function lookup($key) { |
|
233 | 233 | if ( !isset($this->_styles[$key]) ) |
234 | - return null; |
|
234 | + return null; |
|
235 | 235 | |
236 | 236 | return $this->_styles[$key]; |
237 | - } |
|
238 | - |
|
239 | - /** |
|
240 | - * create a new Style object associated with this stylesheet |
|
241 | - * |
|
242 | - * @param Style $parent The style of this style's parent in the DOM tree |
|
243 | - * @return Style |
|
244 | - */ |
|
245 | - function create_style($parent = null) { |
|
237 | + } |
|
238 | + |
|
239 | + /** |
|
240 | + * create a new Style object associated with this stylesheet |
|
241 | + * |
|
242 | + * @param Style $parent The style of this style's parent in the DOM tree |
|
243 | + * @return Style |
|
244 | + */ |
|
245 | + function create_style($parent = null) { |
|
246 | 246 | return new Style($this, $parent); |
247 | - } |
|
247 | + } |
|
248 | 248 | |
249 | 249 | |
250 | - /** |
|
251 | - * load and parse a CSS string |
|
252 | - * |
|
253 | - * @param string $css |
|
254 | - */ |
|
255 | - function load_css(&$css) { $this->_parse_css($css); } |
|
250 | + /** |
|
251 | + * load and parse a CSS string |
|
252 | + * |
|
253 | + * @param string $css |
|
254 | + */ |
|
255 | + function load_css(&$css) { $this->_parse_css($css); } |
|
256 | 256 | |
257 | 257 | |
258 | - /** |
|
259 | - * load and parse a CSS file |
|
260 | - * |
|
261 | - * @param string $file |
|
262 | - */ |
|
263 | - function load_css_file($file) { |
|
258 | + /** |
|
259 | + * load and parse a CSS file |
|
260 | + * |
|
261 | + * @param string $file |
|
262 | + */ |
|
263 | + function load_css_file($file) { |
|
264 | 264 | global $_dompdf_warnings; |
265 | 265 | |
266 | 266 | // Prevent circular references |
267 | 267 | if ( isset($this->_loaded_files[$file]) ) |
268 | - return; |
|
268 | + return; |
|
269 | 269 | |
270 | 270 | $this->_loaded_files[$file] = true; |
271 | 271 | $parsed_url = explode_url($file); |
@@ -274,36 +274,36 @@ discard block |
||
274 | 274 | |
275 | 275 | if ( !DOMPDF_ENABLE_REMOTE && |
276 | 276 | ($this->_protocol != "" && $this->_protocol !== "file://") ) { |
277 | - record_warnings(E_USER_WARNING, "Remote CSS file '$file' requested, but DOMPDF_ENABLE_REMOTE is false.", __FILE__, __LINE__); |
|
278 | - return; |
|
277 | + record_warnings(E_USER_WARNING, "Remote CSS file '$file' requested, but DOMPDF_ENABLE_REMOTE is false.", __FILE__, __LINE__); |
|
278 | + return; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | // Fix submitted by Nick Oostveen for aliased directory support: |
282 | 282 | if ( $this->_protocol == "" ) |
283 | - $file = $this->_base_path . $filename; |
|
283 | + $file = $this->_base_path . $filename; |
|
284 | 284 | else |
285 | - $file = build_url($this->_protocol, $this->_base_host, $this->_base_path, $filename); |
|
285 | + $file = build_url($this->_protocol, $this->_base_host, $this->_base_path, $filename); |
|
286 | 286 | |
287 | 287 | set_error_handler("record_warnings"); |
288 | 288 | $css = file_get_contents($file); |
289 | 289 | restore_error_handler(); |
290 | 290 | |
291 | 291 | if ( $css == "" ) { |
292 | - record_warnings(E_USER_WARNING, "Unable to load css file $file", __FILE__, __LINE__);; |
|
293 | - return; |
|
292 | + record_warnings(E_USER_WARNING, "Unable to load css file $file", __FILE__, __LINE__);; |
|
293 | + return; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | $this->_parse_css($css); |
297 | 297 | |
298 | - } |
|
298 | + } |
|
299 | 299 | |
300 | - /** |
|
301 | - * @link http://www.w3.org/TR/CSS21/cascade.html#specificity} |
|
302 | - * |
|
303 | - * @param string $selector |
|
304 | - * @return int |
|
305 | - */ |
|
306 | - private function _specificity($selector) { |
|
300 | + /** |
|
301 | + * @link http://www.w3.org/TR/CSS21/cascade.html#specificity} |
|
302 | + * |
|
303 | + * @param string $selector |
|
304 | + * @return int |
|
305 | + */ |
|
306 | + private function _specificity($selector) { |
|
307 | 307 | // http://www.w3.org/TR/CSS21/cascade.html#specificity |
308 | 308 | // ignoring the ":" pseudoclass modifyers |
309 | 309 | // also ignored in _css_selector_to_xpath |
@@ -325,26 +325,26 @@ discard block |
||
325 | 325 | //see _css_selector_to_xpath |
326 | 326 | |
327 | 327 | if ( !in_array($selector[0], array(" ", ">", ".", "#", "+", ":", "[")) ) { |
328 | - $d++; |
|
328 | + $d++; |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | if (DEBUGCSS) { |
332 | - /*DEBUGCSS*/ print "<pre>\n"; |
|
333 | - /*DEBUGCSS*/ printf("_specificity(): 0x%08x \"%s\"\n", ($a << 24) | ($b << 16) | ($c << 8) | ($d), $selector); |
|
334 | - /*DEBUGCSS*/ print "</pre>"; |
|
332 | + /*DEBUGCSS*/ print "<pre>\n"; |
|
333 | + /*DEBUGCSS*/ printf("_specificity(): 0x%08x \"%s\"\n", ($a << 24) | ($b << 16) | ($c << 8) | ($d), $selector); |
|
334 | + /*DEBUGCSS*/ print "</pre>"; |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | return ($a << 24) | ($b << 16) | ($c << 8) | ($d); |
338 | - } |
|
338 | + } |
|
339 | 339 | |
340 | 340 | |
341 | - /** |
|
342 | - * converts a CSS selector to an XPath query. |
|
343 | - * |
|
344 | - * @param string $selector |
|
345 | - * @return string |
|
346 | - */ |
|
347 | - private function _css_selector_to_xpath($selector) { |
|
341 | + /** |
|
342 | + * converts a CSS selector to an XPath query. |
|
343 | + * |
|
344 | + * @param string $selector |
|
345 | + * @return string |
|
346 | + */ |
|
347 | + private function _css_selector_to_xpath($selector) { |
|
348 | 348 | |
349 | 349 | // Collapse white space and strip whitespace around delimiters |
350 | 350 | // $search = array("/\\s+/", "/\\s+([.>#+:])\\s+/"); |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | // Add an implicit space at the beginning of the selector if there is no |
363 | 363 | // delimiter there already. |
364 | 364 | if ( !in_array($selector[0], $delimiters) ) |
365 | - $selector = " $selector"; |
|
365 | + $selector = " $selector"; |
|
366 | 366 | |
367 | 367 | $tok = ""; |
368 | 368 | $len = mb_strlen($selector); |
@@ -370,37 +370,37 @@ discard block |
||
370 | 370 | |
371 | 371 | while ( $i < $len ) { |
372 | 372 | |
373 | - $s = $selector[$i]; |
|
374 | - $i++; |
|
373 | + $s = $selector[$i]; |
|
374 | + $i++; |
|
375 | 375 | |
376 | - // Eat characters up to the next delimiter |
|
377 | - $tok = ""; |
|
376 | + // Eat characters up to the next delimiter |
|
377 | + $tok = ""; |
|
378 | 378 | |
379 | - while ($i < $len) { |
|
379 | + while ($i < $len) { |
|
380 | 380 | if ( in_array($selector[$i], $delimiters) ) |
381 | - break; |
|
381 | + break; |
|
382 | 382 | $tok .= $selector[$i++]; |
383 | - } |
|
383 | + } |
|
384 | 384 | |
385 | - switch ($s) { |
|
385 | + switch ($s) { |
|
386 | 386 | |
387 | - case " ": |
|
387 | + case " ": |
|
388 | 388 | case ">": |
389 | 389 | // All elements matching the next token that are direct children of |
390 | 390 | // the current token |
391 | 391 | $expr = $s === " " ? "descendant" : "child"; |
392 | 392 | |
393 | 393 | if ( mb_substr($query, -1, 1) !== "/" ) |
394 | - $query .= "/"; |
|
394 | + $query .= "/"; |
|
395 | 395 | |
396 | 396 | if ( !$tok ) |
397 | - $tok = "*"; |
|
397 | + $tok = "*"; |
|
398 | 398 | |
399 | 399 | $query .= "$expr::$tok"; |
400 | 400 | $tok = ""; |
401 | 401 | break; |
402 | 402 | |
403 | - case ".": |
|
403 | + case ".": |
|
404 | 404 | case "#": |
405 | 405 | // All elements matching the current token with a class/id equal to |
406 | 406 | // the _next_ token. |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | |
410 | 410 | // empty class/id == * |
411 | 411 | if ( mb_substr($query, -1, 1) === "/" ) |
412 | - $query .= "*"; |
|
412 | + $query .= "*"; |
|
413 | 413 | |
414 | 414 | // Match multiple classes: $tok contains the current selected |
415 | 415 | // class. Search for class attributes with class="$tok", |
@@ -423,28 +423,28 @@ discard block |
||
423 | 423 | $tok = ""; |
424 | 424 | break; |
425 | 425 | |
426 | - case "+": |
|
426 | + case "+": |
|
427 | 427 | // All sibling elements that folow the current token |
428 | 428 | if ( mb_substr($query, -1, 1) !== "/" ) |
429 | - $query .= "/"; |
|
429 | + $query .= "/"; |
|
430 | 430 | |
431 | 431 | $query .= "following-sibling::$tok"; |
432 | 432 | $tok = ""; |
433 | 433 | break; |
434 | 434 | |
435 | - case ":": |
|
435 | + case ":": |
|
436 | 436 | // Pseudo-classes |
437 | 437 | switch ($tok) { |
438 | 438 | |
439 | 439 | case "first-child": |
440 | 440 | $query .= "[1]"; |
441 | - $tok = ""; |
|
442 | - break; |
|
441 | + $tok = ""; |
|
442 | + break; |
|
443 | 443 | |
444 | 444 | case "link": |
445 | 445 | $query .= "[@href]"; |
446 | - $tok = ""; |
|
447 | - break; |
|
446 | + $tok = ""; |
|
447 | + break; |
|
448 | 448 | |
449 | 449 | case "first-line": |
450 | 450 | break; |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | |
463 | 463 | break; |
464 | 464 | |
465 | - case "[": |
|
465 | + case "[": |
|
466 | 466 | // Attribute selectors. All with an attribute matching the following token(s) |
467 | 467 | $attr_delimiters = array("=", "]", "~", "|"); |
468 | 468 | $tok_len = mb_strlen($tok); |
@@ -473,9 +473,9 @@ discard block |
||
473 | 473 | $value = ""; |
474 | 474 | |
475 | 475 | while ( $j < $tok_len ) { |
476 | - if ( in_array($tok[$j], $attr_delimiters) ) |
|
476 | + if ( in_array($tok[$j], $attr_delimiters) ) |
|
477 | 477 | break; |
478 | - $attr .= $tok[$j++]; |
|
478 | + $attr .= $tok[$j++]; |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | switch ( $tok[$j] ) { |
@@ -484,67 +484,67 @@ discard block |
||
484 | 484 | case "|": |
485 | 485 | $op .= $tok[$j++]; |
486 | 486 | |
487 | - if ( $tok[$j] !== "=" ) |
|
487 | + if ( $tok[$j] !== "=" ) |
|
488 | 488 | throw new DOMPDF_Exception("Invalid CSS selector syntax: invalid attribute selector: $selector"); |
489 | 489 | |
490 | - $op .= $tok[$j]; |
|
491 | - break; |
|
490 | + $op .= $tok[$j]; |
|
491 | + break; |
|
492 | 492 | |
493 | 493 | case "=": |
494 | 494 | $op = "="; |
495 | - break; |
|
495 | + break; |
|
496 | 496 | |
497 | 497 | } |
498 | 498 | |
499 | 499 | // Read the attribute value, if required |
500 | 500 | if ( $op != "" ) { |
501 | - $j++; |
|
502 | - while ( $j < $tok_len ) { |
|
501 | + $j++; |
|
502 | + while ( $j < $tok_len ) { |
|
503 | 503 | if ( $tok[$j] === "]" ) |
504 | - break; |
|
504 | + break; |
|
505 | 505 | $value .= $tok[$j++]; |
506 | - } |
|
506 | + } |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | if ( $attr == "" ) |
510 | - throw new DOMPDF_Exception("Invalid CSS selector syntax: missing attribute name"); |
|
510 | + throw new DOMPDF_Exception("Invalid CSS selector syntax: missing attribute name"); |
|
511 | 511 | |
512 | 512 | switch ( $op ) { |
513 | 513 | |
514 | 514 | case "": |
515 | 515 | $query .= "[@$attr]"; |
516 | - break; |
|
516 | + break; |
|
517 | 517 | |
518 | 518 | case "=": |
519 | 519 | $query .= "[@$attr$op\"$value\"]"; |
520 | - break; |
|
520 | + break; |
|
521 | 521 | |
522 | 522 | case "~=": |
523 | 523 | // FIXME: this will break if $value contains quoted strings |
524 | 524 | // (e.g. [type~="a b c" "d e f"]) |
525 | 525 | $values = explode(" ", $value); |
526 | - $query .= "["; |
|
526 | + $query .= "["; |
|
527 | 527 | |
528 | - foreach ( $values as $val ) |
|
528 | + foreach ( $values as $val ) |
|
529 | 529 | $query .= "@$attr=\"$val\" or "; |
530 | 530 | |
531 | - $query = rtrim($query, " or ") . "]"; |
|
532 | - break; |
|
531 | + $query = rtrim($query, " or ") . "]"; |
|
532 | + break; |
|
533 | 533 | |
534 | 534 | case "|=": |
535 | 535 | $values = explode("-", $value); |
536 | - $query .= "["; |
|
536 | + $query .= "["; |
|
537 | 537 | |
538 | - foreach ($values as $val) |
|
538 | + foreach ($values as $val) |
|
539 | 539 | $query .= "starts-with(@$attr, \"$val\") or "; |
540 | 540 | |
541 | - $query = rtrim($query, " or ") . "]"; |
|
542 | - break; |
|
541 | + $query = rtrim($query, " or ") . "]"; |
|
542 | + break; |
|
543 | 543 | |
544 | 544 | } |
545 | 545 | |
546 | 546 | break; |
547 | - } |
|
547 | + } |
|
548 | 548 | } |
549 | 549 | $i++; |
550 | 550 | |
@@ -571,21 +571,21 @@ discard block |
||
571 | 571 | |
572 | 572 | // Trim the trailing '/' from the query |
573 | 573 | if ( mb_strlen($query) > 2 ) |
574 | - $query = rtrim($query, "/"); |
|
574 | + $query = rtrim($query, "/"); |
|
575 | 575 | |
576 | 576 | return $query; |
577 | - } |
|
578 | - |
|
579 | - /** |
|
580 | - * applies all current styles to a particular document tree |
|
581 | - * |
|
582 | - * apply_styles() applies all currently loaded styles to the provided |
|
583 | - * {@link Frame_Tree}. Aside from parsing CSS, this is the main purpose |
|
584 | - * of this class. |
|
585 | - * |
|
586 | - * @param Frame_Tree $tree |
|
587 | - */ |
|
588 | - function apply_styles(Frame_Tree $tree) { |
|
577 | + } |
|
578 | + |
|
579 | + /** |
|
580 | + * applies all current styles to a particular document tree |
|
581 | + * |
|
582 | + * apply_styles() applies all currently loaded styles to the provided |
|
583 | + * {@link Frame_Tree}. Aside from parsing CSS, this is the main purpose |
|
584 | + * of this class. |
|
585 | + * |
|
586 | + * @param Frame_Tree $tree |
|
587 | + */ |
|
588 | + function apply_styles(Frame_Tree $tree) { |
|
589 | 589 | |
590 | 590 | // Use XPath to select nodes. This would be easier if we could attach |
591 | 591 | // Frame objects directly to DOMNodes using the setUserData() method, but |
@@ -605,67 +605,67 @@ discard block |
||
605 | 605 | // Apply all styles in stylesheet |
606 | 606 | foreach ($this->_styles as $selector => $style) { |
607 | 607 | |
608 | - $query = $this->_css_selector_to_xpath($selector); |
|
608 | + $query = $this->_css_selector_to_xpath($selector); |
|
609 | 609 | // pre_var_dump($selector); |
610 | 610 | // pre_var_dump($query); |
611 | 611 | // echo ($style); |
612 | 612 | |
613 | - // Retrieve the nodes |
|
614 | - $nodes = $xp->query($query); |
|
613 | + // Retrieve the nodes |
|
614 | + $nodes = $xp->query($query); |
|
615 | 615 | |
616 | - foreach ($nodes as $node) { |
|
616 | + foreach ($nodes as $node) { |
|
617 | 617 | //echo $node->nodeName . "\n"; |
618 | 618 | // Retrieve the node id |
619 | 619 | if ( $node->nodeType != 1 ) // Only DOMElements get styles |
620 | - continue; |
|
620 | + continue; |
|
621 | 621 | |
622 | 622 | $id = $node->getAttribute("frame_id"); |
623 | 623 | |
624 | 624 | // Assign the current style to the scratch array |
625 | 625 | $spec = $this->_specificity($selector); |
626 | 626 | $styles[$id][$spec][] = $style; |
627 | - } |
|
627 | + } |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | // Now create the styles and assign them to the appropriate frames. (We |
631 | 631 | // iterate over the tree using an implicit Frame_Tree iterator.) |
632 | 632 | $root_flg = false; |
633 | 633 | foreach ($tree->get_frames() as $frame) { |
634 | - // pre_r($frame->get_node()->nodeName . ":"); |
|
635 | - if ( !$root_flg && $this->_page_style ) { |
|
634 | + // pre_r($frame->get_node()->nodeName . ":"); |
|
635 | + if ( !$root_flg && $this->_page_style ) { |
|
636 | 636 | $style = $this->_page_style; |
637 | 637 | $root_flg = true; |
638 | - } else |
|
638 | + } else |
|
639 | 639 | $style = $this->create_style(); |
640 | 640 | |
641 | - // Find nearest DOMElement parent |
|
642 | - $p = $frame; |
|
643 | - while ( $p = $p->get_parent() ) |
|
641 | + // Find nearest DOMElement parent |
|
642 | + $p = $frame; |
|
643 | + while ( $p = $p->get_parent() ) |
|
644 | 644 | if ($p->get_node()->nodeType == 1 ) |
645 | - break; |
|
645 | + break; |
|
646 | 646 | |
647 | - // Styles can only be applied directly to DOMElements; anonymous |
|
648 | - // frames inherit from their parent |
|
649 | - if ( $frame->get_node()->nodeType != 1 ) { |
|
647 | + // Styles can only be applied directly to DOMElements; anonymous |
|
648 | + // frames inherit from their parent |
|
649 | + if ( $frame->get_node()->nodeType != 1 ) { |
|
650 | 650 | if ( $p ) |
651 | - $style->inherit($p->get_style()); |
|
651 | + $style->inherit($p->get_style()); |
|
652 | 652 | $frame->set_style($style); |
653 | 653 | continue; |
654 | - } |
|
654 | + } |
|
655 | 655 | |
656 | - $id = $frame->get_id(); |
|
656 | + $id = $frame->get_id(); |
|
657 | 657 | |
658 | - // Handle HTML 4.0 attributes |
|
659 | - Attribute_Translator::translate_attributes($frame); |
|
658 | + // Handle HTML 4.0 attributes |
|
659 | + Attribute_Translator::translate_attributes($frame); |
|
660 | 660 | |
661 | - // Locate any additional style attributes |
|
662 | - if ( ($str = $frame->get_node()->getAttribute("style")) !== "" ) { |
|
661 | + // Locate any additional style attributes |
|
662 | + if ( ($str = $frame->get_node()->getAttribute("style")) !== "" ) { |
|
663 | 663 | $spec = $this->_specificity("!style attribute"); |
664 | 664 | $styles[$id][$spec][] = $this->_parse_properties($str); |
665 | - } |
|
665 | + } |
|
666 | 666 | |
667 | - // Grab the applicable styles |
|
668 | - if ( isset($styles[$id]) ) { |
|
667 | + // Grab the applicable styles |
|
668 | + if ( isset($styles[$id]) ) { |
|
669 | 669 | |
670 | 670 | $applied_styles = $styles[ $frame->get_id() ]; |
671 | 671 | |
@@ -673,101 +673,101 @@ discard block |
||
673 | 673 | ksort($applied_styles); |
674 | 674 | |
675 | 675 | if (DEBUGCSS) { |
676 | - $debug_nodename = $frame->get_node()->nodeName; |
|
677 | - print "<pre>\n[$debug_nodename\n"; |
|
678 | - foreach ($applied_styles as $spec => $arr) { |
|
676 | + $debug_nodename = $frame->get_node()->nodeName; |
|
677 | + print "<pre>\n[$debug_nodename\n"; |
|
678 | + foreach ($applied_styles as $spec => $arr) { |
|
679 | 679 | printf("specificity: 0x%08x\n",$spec); |
680 | 680 | foreach ($arr as $s) { |
681 | - print "[\n"; |
|
682 | - $s->debug_print(); |
|
683 | - print "]\n"; |
|
681 | + print "[\n"; |
|
682 | + $s->debug_print(); |
|
683 | + print "]\n"; |
|
684 | + } |
|
684 | 685 | } |
685 | - } |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | // Merge the new styles with the inherited styles |
689 | 689 | foreach ($applied_styles as $arr) { |
690 | - foreach ($arr as $s) |
|
690 | + foreach ($arr as $s) |
|
691 | 691 | $style->merge($s); |
692 | 692 | } |
693 | - } |
|
693 | + } |
|
694 | 694 | |
695 | - // Inherit parent's styles if required |
|
696 | - if ( $p ) { |
|
695 | + // Inherit parent's styles if required |
|
696 | + if ( $p ) { |
|
697 | 697 | |
698 | 698 | if (DEBUGCSS) { |
699 | - print "inherit:\n"; |
|
700 | - print "[\n"; |
|
701 | - $p->get_style()->debug_print(); |
|
702 | - print "]\n"; |
|
699 | + print "inherit:\n"; |
|
700 | + print "[\n"; |
|
701 | + $p->get_style()->debug_print(); |
|
702 | + print "]\n"; |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | $style->inherit( $p->get_style() ); |
706 | - } |
|
706 | + } |
|
707 | 707 | |
708 | - if (DEBUGCSS) { |
|
708 | + if (DEBUGCSS) { |
|
709 | 709 | print "DomElementStyle:\n"; |
710 | 710 | print "[\n"; |
711 | 711 | $style->debug_print(); |
712 | 712 | print "]\n"; |
713 | 713 | print "/$debug_nodename]\n</pre>"; |
714 | - } |
|
714 | + } |
|
715 | 715 | |
716 | - /*DEBUGCSS print: see below different print debugging method |
|
716 | + /*DEBUGCSS print: see below different print debugging method |
|
717 | 717 | pre_r($frame->get_node()->nodeName . ":"); |
718 | 718 | echo "<pre>"; |
719 | 719 | echo $style; |
720 | 720 | echo "</pre>";*/ |
721 | - $frame->set_style($style); |
|
721 | + $frame->set_style($style); |
|
722 | 722 | |
723 | 723 | } |
724 | 724 | |
725 | 725 | // We're done! Clean out the registry of all styles since we |
726 | 726 | // won't be needing this later. |
727 | 727 | foreach ( array_keys($this->_styles) as $key ) { |
728 | - unset($this->_styles[$key]); |
|
728 | + unset($this->_styles[$key]); |
|
729 | 729 | } |
730 | 730 | |
731 | - } |
|
731 | + } |
|
732 | 732 | |
733 | 733 | |
734 | - /** |
|
735 | - * parse a CSS string using a regex parser |
|
736 | - * |
|
737 | - * Called by {@link Stylesheet::parse_css()} |
|
738 | - * |
|
739 | - * @param string $str |
|
740 | - */ |
|
741 | - private function _parse_css($str) { |
|
734 | + /** |
|
735 | + * parse a CSS string using a regex parser |
|
736 | + * |
|
737 | + * Called by {@link Stylesheet::parse_css()} |
|
738 | + * |
|
739 | + * @param string $str |
|
740 | + */ |
|
741 | + private function _parse_css($str) { |
|
742 | 742 | |
743 | 743 | $str = trim($str); |
744 | 744 | |
745 | 745 | // Destroy comments and remove HTML comments |
746 | 746 | $css = preg_replace(array( |
747 | - "'/\*.*?\*/'si", |
|
748 | - "/^<!--/", |
|
749 | - "/-->$/" |
|
747 | + "'/\*.*?\*/'si", |
|
748 | + "/^<!--/", |
|
749 | + "/-->$/" |
|
750 | 750 | ), "", $str); |
751 | 751 | |
752 | 752 | // FIXME: handle '{' within strings, e.g. [attr="string {}"] |
753 | 753 | |
754 | 754 | // Something more legible: |
755 | 755 | $re = |
756 | - "/\s* # Skip leading whitespace \n". |
|
757 | - "( @([^\s]+)\s+([^{;]*) (?:;|({)) )? # Match @rules followed by ';' or '{' \n". |
|
758 | - "(?(1) # Only parse sub-sections if we're in an @rule... \n". |
|
759 | - " (?(4) # ...and if there was a leading '{' \n". |
|
760 | - " \s*( (?:(?>[^{}]+) ({)? # Parse rulesets and individual @page rules \n". |
|
761 | - " (?(6) (?>[^}]*) }) \s*)+? \n". |
|
762 | - " ) \n". |
|
763 | - " }) # Balancing '}' \n". |
|
764 | - "| # Branch to match regular rules (not preceeded by '@')\n". |
|
765 | - "([^{]*{[^}]*})) # Parse normal rulesets\n". |
|
766 | - "/xs"; |
|
756 | + "/\s* # Skip leading whitespace \n". |
|
757 | + "( @([^\s]+)\s+([^{;]*) (?:;|({)) )? # Match @rules followed by ';' or '{' \n". |
|
758 | + "(?(1) # Only parse sub-sections if we're in an @rule... \n". |
|
759 | + " (?(4) # ...and if there was a leading '{' \n". |
|
760 | + " \s*( (?:(?>[^{}]+) ({)? # Parse rulesets and individual @page rules \n". |
|
761 | + " (?(6) (?>[^}]*) }) \s*)+? \n". |
|
762 | + " ) \n". |
|
763 | + " }) # Balancing '}' \n". |
|
764 | + "| # Branch to match regular rules (not preceeded by '@')\n". |
|
765 | + "([^{]*{[^}]*})) # Parse normal rulesets\n". |
|
766 | + "/xs"; |
|
767 | 767 | |
768 | 768 | if ( preg_match_all($re, $css, $matches, PREG_SET_ORDER) === false ) |
769 | - // An error occured |
|
770 | - throw new DOMPDF_Exception("Error parsing css file: preg_match_all() failed."); |
|
769 | + // An error occured |
|
770 | + throw new DOMPDF_Exception("Error parsing css file: preg_match_all() failed."); |
|
771 | 771 | |
772 | 772 | // After matching, the array indicies are set as follows: |
773 | 773 | // |
@@ -782,27 +782,27 @@ discard block |
||
782 | 782 | // |
783 | 783 | //pre_r($matches); |
784 | 784 | foreach ( $matches as $match ) { |
785 | - $match[2] = trim($match[2]); |
|
785 | + $match[2] = trim($match[2]); |
|
786 | 786 | |
787 | - if ( $match[2] !== "" ) { |
|
787 | + if ( $match[2] !== "" ) { |
|
788 | 788 | // Handle @rules |
789 | 789 | switch ($match[2]) { |
790 | 790 | |
791 | 791 | case "import": |
792 | 792 | $this->_parse_import($match[3]); |
793 | - break; |
|
793 | + break; |
|
794 | 794 | |
795 | 795 | case "media": |
796 | 796 | $acceptedmedia = self::$ACCEPTED_GENERIC_MEDIA_TYPES; |
797 | - if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) { |
|
797 | + if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) { |
|
798 | 798 | $acceptedmedia[] = DOMPDF_DEFAULT_MEDIA_TYPE; |
799 | - } else { |
|
799 | + } else { |
|
800 | 800 | $acceptedmedia[] = self::$ACCEPTED_DEFAULT_MEDIA_TYPE; |
801 | - } |
|
802 | - if ( in_array(mb_strtolower(trim($match[3])), $acceptedmedia ) ) { |
|
801 | + } |
|
802 | + if ( in_array(mb_strtolower(trim($match[3])), $acceptedmedia ) ) { |
|
803 | 803 | $this->_parse_sections($match[5]); |
804 | - } |
|
805 | - break; |
|
804 | + } |
|
805 | + break; |
|
806 | 806 | |
807 | 807 | case "page": |
808 | 808 | //This handles @page to be applied to page oriented media |
@@ -827,9 +827,9 @@ discard block |
||
827 | 827 | // Store the style for later... |
828 | 828 | if ( is_null($this->_page_style) ) |
829 | 829 | $this->_page_style = $this->_parse_properties($match[5]); |
830 | - else |
|
830 | + else |
|
831 | 831 | $this->_page_style->merge($this->_parse_properties($match[5])); |
832 | - break; |
|
832 | + break; |
|
833 | 833 | |
834 | 834 | default: |
835 | 835 | // ignore everything else |
@@ -837,118 +837,118 @@ discard block |
||
837 | 837 | } |
838 | 838 | |
839 | 839 | continue; |
840 | - } |
|
840 | + } |
|
841 | 841 | |
842 | - if ( $match[7] !== "" ) |
|
842 | + if ( $match[7] !== "" ) |
|
843 | 843 | $this->_parse_sections($match[7]); |
844 | 844 | |
845 | 845 | } |
846 | - } |
|
846 | + } |
|
847 | 847 | |
848 | - /* See also style.cls Style::_image(), refactoring?, works also for imported css files */ |
|
849 | - protected function _image($val) { |
|
848 | + /* See also style.cls Style::_image(), refactoring?, works also for imported css files */ |
|
849 | + protected function _image($val) { |
|
850 | 850 | $DEBUGCSS=DEBUGCSS; |
851 | 851 | |
852 | 852 | if ( mb_strpos($val, "url") === false ) { |
853 | - $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none |
|
853 | + $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none |
|
854 | 854 | } |
855 | 855 | else { |
856 | - $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/","\\1", trim($val)); |
|
856 | + $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/","\\1", trim($val)); |
|
857 | 857 | |
858 | - // Resolve the url now in the context of the current stylesheet |
|
859 | - $parsed_url = explode_url($val); |
|
860 | - if ( $parsed_url["protocol"] == "" && $this->get_protocol() == "" ) { |
|
858 | + // Resolve the url now in the context of the current stylesheet |
|
859 | + $parsed_url = explode_url($val); |
|
860 | + if ( $parsed_url["protocol"] == "" && $this->get_protocol() == "" ) { |
|
861 | 861 | if ($parsed_url["path"]{0} === '/' || $parsed_url["path"]{0} === '\\' ) { |
862 | - $path = $_SERVER["DOCUMENT_ROOT"].'/'; |
|
862 | + $path = $_SERVER["DOCUMENT_ROOT"].'/'; |
|
863 | 863 | } else { |
864 | - $path = $this->get_base_path(); |
|
864 | + $path = $this->get_base_path(); |
|
865 | 865 | } |
866 | 866 | $path .= $parsed_url["path"] . $parsed_url["file"]; |
867 | 867 | $path = realpath($path); |
868 | 868 | // If realpath returns FALSE then specifically state that there is no background image |
869 | 869 | if (!$path) { $path = 'none'; } |
870 | - } else { |
|
870 | + } else { |
|
871 | 871 | $path = build_url($this->get_protocol(), |
872 | - $this->get_host(), |
|
873 | - $this->get_base_path(), |
|
874 | - $val); |
|
875 | - } |
|
872 | + $this->get_host(), |
|
873 | + $this->get_base_path(), |
|
874 | + $val); |
|
875 | + } |
|
876 | 876 | } |
877 | 877 | if ($DEBUGCSS) { |
878 | - print "<pre>[_image\n"; |
|
879 | - print_r($parsed_url); |
|
880 | - print $this->get_protocol()."\n".$this->get_base_path()."\n".$path."\n"; |
|
881 | - print "_image]</pre>";; |
|
878 | + print "<pre>[_image\n"; |
|
879 | + print_r($parsed_url); |
|
880 | + print $this->get_protocol()."\n".$this->get_base_path()."\n".$path."\n"; |
|
881 | + print "_image]</pre>";; |
|
882 | 882 | } |
883 | 883 | return $path; |
884 | - } |
|
885 | - |
|
886 | - /** |
|
887 | - * parse @import{} sections |
|
888 | - * |
|
889 | - * @param string $url the url of the imported CSS file |
|
890 | - */ |
|
891 | - private function _parse_import($url) { |
|
884 | + } |
|
885 | + |
|
886 | + /** |
|
887 | + * parse @import{} sections |
|
888 | + * |
|
889 | + * @param string $url the url of the imported CSS file |
|
890 | + */ |
|
891 | + private function _parse_import($url) { |
|
892 | 892 | $arr = preg_split("/[\s\n,]/", $url,-1, PREG_SPLIT_NO_EMPTY); |
893 | 893 | $url = array_shift($arr); |
894 | 894 | $accept = false; |
895 | 895 | |
896 | 896 | if ( count($arr) > 0 ) { |
897 | 897 | |
898 | - $acceptedmedia = self::$ACCEPTED_GENERIC_MEDIA_TYPES; |
|
899 | - if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) { |
|
898 | + $acceptedmedia = self::$ACCEPTED_GENERIC_MEDIA_TYPES; |
|
899 | + if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) { |
|
900 | 900 | $acceptedmedia[] = DOMPDF_DEFAULT_MEDIA_TYPE; |
901 | - } else { |
|
901 | + } else { |
|
902 | 902 | $acceptedmedia[] = self::$ACCEPTED_DEFAULT_MEDIA_TYPE; |
903 | - } |
|
903 | + } |
|
904 | 904 | |
905 | - // @import url media_type [media_type...] |
|
906 | - foreach ( $arr as $type ) { |
|
905 | + // @import url media_type [media_type...] |
|
906 | + foreach ( $arr as $type ) { |
|
907 | 907 | if ( in_array(mb_strtolower(trim($type)), $acceptedmedia) ) { |
908 | - $accept = true; |
|
909 | - break; |
|
908 | + $accept = true; |
|
909 | + break; |
|
910 | + } |
|
910 | 911 | } |
911 | - } |
|
912 | 912 | |
913 | 913 | } else { |
914 | - // unconditional import |
|
915 | - $accept = true; |
|
914 | + // unconditional import |
|
915 | + $accept = true; |
|
916 | 916 | } |
917 | 917 | |
918 | 918 | if ( $accept ) { |
919 | - // Store our current base url properties in case the new url is elsewhere |
|
920 | - $protocol = $this->_protocol; |
|
921 | - $host = $this->_base_host; |
|
922 | - $path = $this->_base_path; |
|
919 | + // Store our current base url properties in case the new url is elsewhere |
|
920 | + $protocol = $this->_protocol; |
|
921 | + $host = $this->_base_host; |
|
922 | + $path = $this->_base_path; |
|
923 | 923 | |
924 | - // $url = str_replace(array('"',"url", "(", ")"), "", $url); |
|
925 | - // If the protocol is php, assume that we will import using file:// |
|
926 | - // $url = build_url($protocol == "php://" ? "file://" : $protocol, $host, $path, $url); |
|
927 | - // Above does not work for subfolders and absolute urls. |
|
928 | - // Todo: As above, do we need to replace php or file to an empty protocol for local files? |
|
924 | + // $url = str_replace(array('"',"url", "(", ")"), "", $url); |
|
925 | + // If the protocol is php, assume that we will import using file:// |
|
926 | + // $url = build_url($protocol == "php://" ? "file://" : $protocol, $host, $path, $url); |
|
927 | + // Above does not work for subfolders and absolute urls. |
|
928 | + // Todo: As above, do we need to replace php or file to an empty protocol for local files? |
|
929 | 929 | |
930 | - $url = $this->_image($url); |
|
930 | + $url = $this->_image($url); |
|
931 | 931 | |
932 | - $this->load_css_file($url); |
|
932 | + $this->load_css_file($url); |
|
933 | + |
|
934 | + // Restore the current base url |
|
935 | + $this->_protocol = $protocol; |
|
936 | + $this->_base_host = $host; |
|
937 | + $this->_base_path = $path; |
|
938 | + } |
|
933 | 939 | |
934 | - // Restore the current base url |
|
935 | - $this->_protocol = $protocol; |
|
936 | - $this->_base_host = $host; |
|
937 | - $this->_base_path = $path; |
|
938 | 940 | } |
939 | 941 | |
940 | - } |
|
941 | - |
|
942 | - /** |
|
943 | - * parse regular CSS blocks |
|
944 | - * |
|
945 | - * _parse_properties() creates a new Style object based on the provided |
|
946 | - * CSS rules. |
|
947 | - * |
|
948 | - * @param string $str CSS rules |
|
949 | - * @return Style |
|
950 | - */ |
|
951 | - private function _parse_properties($str) { |
|
942 | + /** |
|
943 | + * parse regular CSS blocks |
|
944 | + * |
|
945 | + * _parse_properties() creates a new Style object based on the provided |
|
946 | + * CSS rules. |
|
947 | + * |
|
948 | + * @param string $str CSS rules |
|
949 | + * @return Style |
|
950 | + */ |
|
951 | + private function _parse_properties($str) { |
|
952 | 952 | $properties = explode(";", $str); |
953 | 953 | |
954 | 954 | if (DEBUGCSS) print '[_parse_properties'; |
@@ -956,71 +956,71 @@ discard block |
||
956 | 956 | // Create the style |
957 | 957 | $style = new Style($this); |
958 | 958 | foreach ($properties as $prop) { |
959 | - //A css property can have " ! important" appended (whitespace optional) |
|
960 | - //strip this off to decode core of the property correctly. |
|
961 | - //Pass on in the style to allow proper handling: |
|
962 | - //!important properties can only be overridden by other !important ones. |
|
963 | - //$style->$prop_name = is a shortcut of $style->__set($prop_name,$value);. |
|
964 | - //If no specific set function available, set _props["prop_name"] |
|
965 | - //style is always copied completely, or $_props handled separately |
|
966 | - //Therefore set a _important_props["prop_name"]=true to indicate the modifier |
|
967 | - |
|
968 | - /* Instead of short code, prefer the typical case with fast code |
|
959 | + //A css property can have " ! important" appended (whitespace optional) |
|
960 | + //strip this off to decode core of the property correctly. |
|
961 | + //Pass on in the style to allow proper handling: |
|
962 | + //!important properties can only be overridden by other !important ones. |
|
963 | + //$style->$prop_name = is a shortcut of $style->__set($prop_name,$value);. |
|
964 | + //If no specific set function available, set _props["prop_name"] |
|
965 | + //style is always copied completely, or $_props handled separately |
|
966 | + //Therefore set a _important_props["prop_name"]=true to indicate the modifier |
|
967 | + |
|
968 | + /* Instead of short code, prefer the typical case with fast code |
|
969 | 969 | $important = preg_match("/(.*?)!\s*important/",$prop,$match); |
970 | 970 | if ( $important ) { |
971 | 971 | $prop = $match[1]; |
972 | 972 | } |
973 | 973 | $prop = trim($prop); |
974 | 974 | */ |
975 | - if (DEBUGCSS) print '('; |
|
976 | - $important = false; |
|
977 | - $prop = trim($prop); |
|
978 | - if (substr($prop,-9) === 'important') { |
|
979 | - $prop_tmp = rtrim(substr($prop,0,-9)); |
|
980 | - if (substr($prop_tmp,-1) === '!') { |
|
981 | - $prop = rtrim(substr($prop_tmp,0,-1)); |
|
982 | - $important = true; |
|
983 | - } |
|
984 | - } |
|
975 | + if (DEBUGCSS) print '('; |
|
976 | + $important = false; |
|
977 | + $prop = trim($prop); |
|
978 | + if (substr($prop,-9) === 'important') { |
|
979 | + $prop_tmp = rtrim(substr($prop,0,-9)); |
|
980 | + if (substr($prop_tmp,-1) === '!') { |
|
981 | + $prop = rtrim(substr($prop_tmp,0,-1)); |
|
982 | + $important = true; |
|
983 | + } |
|
984 | + } |
|
985 | 985 | |
986 | - if ($prop == "") { |
|
986 | + if ($prop == "") { |
|
987 | 987 | if (DEBUGCSS) print 'empty)'; |
988 | 988 | continue; |
989 | - } |
|
989 | + } |
|
990 | 990 | |
991 | - $i = mb_strpos($prop, ":"); |
|
992 | - if ( $i === false ) { |
|
991 | + $i = mb_strpos($prop, ":"); |
|
992 | + if ( $i === false ) { |
|
993 | 993 | if (DEBUGCSS) print 'novalue'.$prop.')'; |
994 | 994 | continue; |
995 | - } |
|
995 | + } |
|
996 | 996 | |
997 | - $prop_name = rtrim(mb_strtolower(mb_substr($prop, 0, $i))); |
|
998 | - $value = ltrim(mb_substr($prop, $i+1)); |
|
999 | - if (DEBUGCSS) print $prop_name.':='.$value.($important?'!IMPORTANT':'').')'; |
|
1000 | - //New style, anyway empty |
|
1001 | - //if ($important || !$style->important_get($prop_name) ) { |
|
1002 | - //$style->$prop_name = array($value,$important); |
|
1003 | - //assignment might be replaced by overloading through __set, |
|
1004 | - //and overloaded functions might check _important_props, |
|
1005 | - //therefore set _important_props first. |
|
1006 | - if ($important) { |
|
997 | + $prop_name = rtrim(mb_strtolower(mb_substr($prop, 0, $i))); |
|
998 | + $value = ltrim(mb_substr($prop, $i+1)); |
|
999 | + if (DEBUGCSS) print $prop_name.':='.$value.($important?'!IMPORTANT':'').')'; |
|
1000 | + //New style, anyway empty |
|
1001 | + //if ($important || !$style->important_get($prop_name) ) { |
|
1002 | + //$style->$prop_name = array($value,$important); |
|
1003 | + //assignment might be replaced by overloading through __set, |
|
1004 | + //and overloaded functions might check _important_props, |
|
1005 | + //therefore set _important_props first. |
|
1006 | + if ($important) { |
|
1007 | 1007 | $style->important_set($prop_name); |
1008 | - } |
|
1009 | - //For easier debugging, don't use overloading of assignments with __set |
|
1010 | - $style->$prop_name = $value; |
|
1011 | - //$style->props_set($prop_name, $value); |
|
1008 | + } |
|
1009 | + //For easier debugging, don't use overloading of assignments with __set |
|
1010 | + $style->$prop_name = $value; |
|
1011 | + //$style->props_set($prop_name, $value); |
|
1012 | 1012 | } |
1013 | 1013 | if (DEBUGCSS) print '_parse_properties]'; |
1014 | 1014 | |
1015 | 1015 | return $style; |
1016 | - } |
|
1017 | - |
|
1018 | - /** |
|
1019 | - * parse selector + rulesets |
|
1020 | - * |
|
1021 | - * @param string $str CSS selectors and rulesets |
|
1022 | - */ |
|
1023 | - private function _parse_sections($str) { |
|
1016 | + } |
|
1017 | + |
|
1018 | + /** |
|
1019 | + * parse selector + rulesets |
|
1020 | + * |
|
1021 | + * @param string $str CSS selectors and rulesets |
|
1022 | + */ |
|
1023 | + private function _parse_sections($str) { |
|
1024 | 1024 | // Pre-process: collapse all whitespace and strip whitespace around '>', |
1025 | 1025 | // '.', ':', '+', '#' |
1026 | 1026 | |
@@ -1031,43 +1031,43 @@ discard block |
||
1031 | 1031 | $sections = explode("}", $str); |
1032 | 1032 | if (DEBUGCSS) print '[_parse_sections'; |
1033 | 1033 | foreach ($sections as $sect) { |
1034 | - $i = mb_strpos($sect, "{"); |
|
1034 | + $i = mb_strpos($sect, "{"); |
|
1035 | 1035 | |
1036 | - $selectors = explode(",", mb_substr($sect, 0, $i)); |
|
1037 | - if (DEBUGCSS) print '[section'; |
|
1038 | - $style = $this->_parse_properties(trim(mb_substr($sect, $i+1))); |
|
1036 | + $selectors = explode(",", mb_substr($sect, 0, $i)); |
|
1037 | + if (DEBUGCSS) print '[section'; |
|
1038 | + $style = $this->_parse_properties(trim(mb_substr($sect, $i+1))); |
|
1039 | 1039 | |
1040 | - // Assign it to the selected elements |
|
1041 | - foreach ($selectors as $selector) { |
|
1040 | + // Assign it to the selected elements |
|
1041 | + foreach ($selectors as $selector) { |
|
1042 | 1042 | $selector = trim($selector); |
1043 | 1043 | |
1044 | 1044 | if ($selector == "") { |
1045 | - if (DEBUGCSS) print '#empty#'; |
|
1046 | - continue; |
|
1045 | + if (DEBUGCSS) print '#empty#'; |
|
1046 | + continue; |
|
1047 | 1047 | } |
1048 | 1048 | if (DEBUGCSS) print '#'.$selector.'#'; |
1049 | 1049 | //if (DEBUGCSS) { if (strpos($selector,'p') !== false) print '!!!p!!!#'; } |
1050 | 1050 | |
1051 | 1051 | $this->add_style($selector, $style); |
1052 | - } |
|
1053 | - if (DEBUGCSS) print 'section]'; |
|
1052 | + } |
|
1053 | + if (DEBUGCSS) print 'section]'; |
|
1054 | 1054 | } |
1055 | 1055 | if (DEBUGCSS) print '_parse_sections]'; |
1056 | - } |
|
1057 | - |
|
1058 | - /** |
|
1059 | - * dumps the entire stylesheet as a string |
|
1060 | - * |
|
1061 | - * Generates a string of each selector and associated style in the |
|
1062 | - * Stylesheet. Useful for debugging. |
|
1063 | - * |
|
1064 | - * @return string |
|
1065 | - */ |
|
1066 | - function __toString() { |
|
1056 | + } |
|
1057 | + |
|
1058 | + /** |
|
1059 | + * dumps the entire stylesheet as a string |
|
1060 | + * |
|
1061 | + * Generates a string of each selector and associated style in the |
|
1062 | + * Stylesheet. Useful for debugging. |
|
1063 | + * |
|
1064 | + * @return string |
|
1065 | + */ |
|
1066 | + function __toString() { |
|
1067 | 1067 | $str = ""; |
1068 | 1068 | foreach ($this->_styles as $selector => $style) |
1069 | - $str .= "$selector => " . $style->__toString() . "\n"; |
|
1069 | + $str .= "$selector => " . $style->__toString() . "\n"; |
|
1070 | 1070 | |
1071 | 1071 | return $str; |
1072 | - } |
|
1072 | + } |
|
1073 | 1073 | } |
@@ -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 | } |
@@ -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 | } |
@@ -1,41 +1,40 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: text_frame_reflower.cls.php,v $ |
|
6 | - * Created on: 2004-06-17 |
|
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: text_frame_reflower.cls.php,v $ |
|
6 | + * Created on: 2004-06-17 |
|
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: text_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
41 | 40 | |
@@ -47,9 +46,9 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Text_Frame_Reflower extends Frame_Reflower { |
49 | 48 | |
50 | - protected $_block_parent; // Nearest block-level ancestor |
|
49 | + protected $_block_parent; // Nearest block-level ancestor |
|
51 | 50 | |
52 | - function __construct(Text_Frame_Decorator $frame) { |
|
51 | + function __construct(Text_Frame_Decorator $frame) { |
|
53 | 52 | parent::__construct($frame); |
54 | 53 | $this->_block_parent = null; |
55 | 54 | |
@@ -58,34 +57,34 @@ discard block |
||
58 | 57 | switch ( strtolower($transform) ) { |
59 | 58 | case "capitalize": |
60 | 59 | $this->_frame->set_text( ucwords($this->_frame->get_text()) ); |
61 | - break; |
|
60 | + break; |
|
62 | 61 | |
63 | 62 | case "uppercase": |
64 | 63 | $this->_frame->set_text( strtoupper($this->_frame->get_text()) ); |
65 | - break; |
|
64 | + break; |
|
66 | 65 | |
67 | 66 | case "lowercase": |
68 | 67 | $this->_frame->set_text( strtolower($this->_frame->get_text()) ); |
69 | - break; |
|
68 | + break; |
|
70 | 69 | |
71 | 70 | default: |
72 | 71 | // Do nothing |
73 | 72 | break; |
74 | 73 | } |
75 | - } |
|
74 | + } |
|
76 | 75 | |
77 | - //........................................................................ |
|
76 | + //........................................................................ |
|
78 | 77 | |
79 | - protected function _collapse_white_space($text) { |
|
78 | + protected function _collapse_white_space($text) { |
|
80 | 79 | //$text = $this->_frame->get_text(); |
81 | 80 | // if ( $this->_block_parent->get_current_line("w") == 0 ) |
82 | 81 | // $text = ltrim($text, " \n\r\t"); |
83 | 82 | return preg_replace("/[\s\n]+/u", " ", $text); |
84 | - } |
|
83 | + } |
|
85 | 84 | |
86 | - //........................................................................ |
|
85 | + //........................................................................ |
|
87 | 86 | |
88 | - protected function _line_break($text) { |
|
87 | + protected function _line_break($text) { |
|
89 | 88 | $style = $this->_frame->get_style(); |
90 | 89 | $size = $style->font_size; |
91 | 90 | $font = $style->font_family; |
@@ -106,12 +105,12 @@ discard block |
||
106 | 105 | // Determine the frame width including margin, padding & border |
107 | 106 | $text_width = Font_Metrics::get_text_width($text, $font, $size, $word_spacing); |
108 | 107 | $mbp_width = |
109 | - $style->length_in_pt( array( $style->margin_left, |
|
110 | - $style->border_left_width, |
|
111 | - $style->padding_left, |
|
112 | - $style->padding_right, |
|
113 | - $style->border_right_width, |
|
114 | - $style->margin_right), $line_width ); |
|
108 | + $style->length_in_pt( array( $style->margin_left, |
|
109 | + $style->border_left_width, |
|
110 | + $style->padding_left, |
|
111 | + $style->padding_right, |
|
112 | + $style->border_right_width, |
|
113 | + $style->margin_right), $line_width ); |
|
115 | 114 | $frame_width = $text_width + $mbp_width; |
116 | 115 | |
117 | 116 | // Debugging: |
@@ -126,7 +125,7 @@ discard block |
||
126 | 125 | // pre_r($words); |
127 | 126 | |
128 | 127 | if ( $frame_width <= $available_width ) |
129 | - return false; |
|
128 | + return false; |
|
130 | 129 | |
131 | 130 | // Determine the split point |
132 | 131 | $width = 0; |
@@ -134,20 +133,20 @@ discard block |
||
134 | 133 | reset($words); |
135 | 134 | |
136 | 135 | for ($i = 0; $i < count($words); $i += 2) { |
137 | - $word = $words[$i] . (isset($words[$i+1]) ? $words[$i+1] : ""); |
|
138 | - $word_width = Font_Metrics::get_text_width($word, $font, $size, $word_spacing); |
|
139 | - if ( $width + $word_width + $mbp_width > $available_width ) |
|
136 | + $word = $words[$i] . (isset($words[$i+1]) ? $words[$i+1] : ""); |
|
137 | + $word_width = Font_Metrics::get_text_width($word, $font, $size, $word_spacing); |
|
138 | + if ( $width + $word_width + $mbp_width > $available_width ) |
|
140 | 139 | break; |
141 | 140 | |
142 | - $width += $word_width; |
|
143 | - $str .= $word; |
|
141 | + $width += $word_width; |
|
142 | + $str .= $word; |
|
144 | 143 | |
145 | 144 | } |
146 | 145 | |
147 | 146 | // The first word has overflowed. Force it onto the line |
148 | 147 | if ( $current_line_width == 0 && $width == 0 ) { |
149 | - $width += $word_width; |
|
150 | - $str .= $word; |
|
148 | + $width += $word_width; |
|
149 | + $str .= $word; |
|
151 | 150 | } |
152 | 151 | |
153 | 152 | $offset = mb_strlen($str); |
@@ -159,22 +158,22 @@ discard block |
||
159 | 158 | |
160 | 159 | return $offset; |
161 | 160 | |
162 | - } |
|
161 | + } |
|
163 | 162 | |
164 | - //........................................................................ |
|
163 | + //........................................................................ |
|
165 | 164 | |
166 | - protected function _newline_break($text) { |
|
165 | + protected function _newline_break($text) { |
|
167 | 166 | |
168 | 167 | if ( ($i = mb_strpos($text, "\n")) === false) |
169 | - return false; |
|
168 | + return false; |
|
170 | 169 | |
171 | 170 | return $i+1; |
172 | 171 | |
173 | - } |
|
172 | + } |
|
174 | 173 | |
175 | - //........................................................................ |
|
174 | + //........................................................................ |
|
176 | 175 | |
177 | - protected function _layout_line() { |
|
176 | + protected function _layout_line() { |
|
178 | 177 | $style = $this->_frame->get_style(); |
179 | 178 | $text = $this->_frame->get_text(); |
180 | 179 | $size = $style->font_size; |
@@ -197,15 +196,15 @@ discard block |
||
197 | 196 | |
198 | 197 | case "capitalize": |
199 | 198 | $text = mb_convert_case($text, MB_CASE_TITLE, 'UTF-8'); |
200 | - break; |
|
199 | + break; |
|
201 | 200 | |
202 | 201 | case "uppercase": |
203 | 202 | $text = mb_convert_case($text, MB_CASE_UPPER, 'UTF-8'); |
204 | - break; |
|
203 | + break; |
|
205 | 204 | |
206 | 205 | case "lowercase": |
207 | 206 | $text = mb_convert_case($text, MB_CASE_LOWER, 'UTF-8'); |
208 | - break; |
|
207 | + break; |
|
209 | 208 | |
210 | 209 | } |
211 | 210 | |
@@ -217,64 +216,64 @@ discard block |
||
217 | 216 | default: |
218 | 217 | case "normal": |
219 | 218 | $this->_frame->set_text( $text = $this->_collapse_white_space($text) ); |
220 | - if ( $text == "" ) |
|
219 | + if ( $text == "" ) |
|
221 | 220 | break; |
222 | 221 | |
223 | - $split = $this->_line_break($text); |
|
224 | - break; |
|
222 | + $split = $this->_line_break($text); |
|
223 | + break; |
|
225 | 224 | |
226 | 225 | case "pre": |
227 | 226 | $split = $this->_newline_break($text); |
228 | - $add_line = $split !== false; |
|
229 | - break; |
|
227 | + $add_line = $split !== false; |
|
228 | + break; |
|
230 | 229 | |
231 | 230 | case "nowrap": |
232 | 231 | $this->_frame->set_text( $text = $this->_collapse_white_space($text) ); |
233 | - break; |
|
232 | + break; |
|
234 | 233 | |
235 | 234 | case "pre-wrap": |
236 | 235 | $split = $this->_newline_break($text); |
237 | 236 | |
238 | - if ( ($tmp = $this->_line_break($text)) !== false ) { |
|
237 | + if ( ($tmp = $this->_line_break($text)) !== false ) { |
|
239 | 238 | $add_line = $split < $tmp; |
240 | 239 | $split = min($tmp, $split); |
241 | - } else |
|
240 | + } else |
|
242 | 241 | $add_line = true; |
243 | 242 | |
244 | - break; |
|
243 | + break; |
|
245 | 244 | |
246 | 245 | case "pre-line": |
247 | 246 | // Collapse white-space except for \n |
248 | 247 | $this->_frame->set_text( $text = preg_replace( "/[ \t]+/u", " ", $text ) ); |
249 | 248 | |
250 | - if ( $text == "" ) |
|
249 | + if ( $text == "" ) |
|
251 | 250 | break; |
252 | 251 | |
253 | - $split = $this->_newline_break($text); |
|
252 | + $split = $this->_newline_break($text); |
|
254 | 253 | |
255 | - if ( ($tmp = $this->_line_break($text)) !== false ) { |
|
254 | + if ( ($tmp = $this->_line_break($text)) !== false ) { |
|
256 | 255 | $add_line = $split < $tmp; |
257 | 256 | $split = min($tmp, $split); |
258 | - } else |
|
257 | + } else |
|
259 | 258 | $add_line = true; |
260 | 259 | |
261 | - break; |
|
260 | + break; |
|
262 | 261 | |
263 | 262 | } |
264 | 263 | |
265 | 264 | // Handle degenerate case |
266 | 265 | if ( $text === "" ) |
267 | - return; |
|
266 | + return; |
|
268 | 267 | |
269 | 268 | if ( $split !== false) { |
270 | 269 | |
271 | - // Handle edge cases |
|
272 | - if ( $split == 0 && $text === " " ) { |
|
270 | + // Handle edge cases |
|
271 | + if ( $split == 0 && $text === " " ) { |
|
273 | 272 | $this->_frame->set_text(""); |
274 | 273 | return; |
275 | - } |
|
274 | + } |
|
276 | 275 | |
277 | - if ( $split == 0 ) { |
|
276 | + if ( $split == 0 ) { |
|
278 | 277 | |
279 | 278 | // Trim newlines from the beginning of the line |
280 | 279 | //$this->_frame->set_text(ltrim($text, "\n\r")); |
@@ -285,7 +284,7 @@ discard block |
||
285 | 284 | // Layout the new line |
286 | 285 | $this->_layout_line(); |
287 | 286 | |
288 | - } else if ( $split < mb_strlen($this->_frame->get_text()) ) { |
|
287 | + } else if ( $split < mb_strlen($this->_frame->get_text()) ) { |
|
289 | 288 | |
290 | 289 | // split the line if required |
291 | 290 | $this->_frame->split_text($split); |
@@ -294,28 +293,28 @@ discard block |
||
294 | 293 | $t = $this->_frame->get_text(); |
295 | 294 | |
296 | 295 | if ( $split > 1 && $t[$split-1] === "\n" ) |
297 | - $this->_frame->set_text( mb_substr($t, 0, -1) ); |
|
296 | + $this->_frame->set_text( mb_substr($t, 0, -1) ); |
|
298 | 297 | |
299 | - } |
|
298 | + } |
|
300 | 299 | |
301 | - if ( $add_line ) { |
|
300 | + if ( $add_line ) { |
|
302 | 301 | $this->_block_parent->add_line(); |
303 | 302 | $this->_frame->position(); |
304 | - } |
|
303 | + } |
|
305 | 304 | |
306 | - // Set our new width |
|
307 | - $this->_frame->recalculate_width(); |
|
305 | + // Set our new width |
|
306 | + $this->_frame->recalculate_width(); |
|
308 | 307 | |
309 | 308 | } else { |
310 | 309 | |
311 | - $this->_frame->recalculate_width(); |
|
310 | + $this->_frame->recalculate_width(); |
|
312 | 311 | |
313 | 312 | } |
314 | - } |
|
313 | + } |
|
315 | 314 | |
316 | - //........................................................................ |
|
315 | + //........................................................................ |
|
317 | 316 | |
318 | - function reflow() { |
|
317 | + function reflow() { |
|
319 | 318 | |
320 | 319 | $this->_block_parent = $this->_frame->find_block_parent(); |
321 | 320 | |
@@ -331,13 +330,13 @@ discard block |
||
331 | 330 | |
332 | 331 | $this->_layout_line(); |
333 | 332 | |
334 | - } |
|
333 | + } |
|
335 | 334 | |
336 | - //........................................................................ |
|
335 | + //........................................................................ |
|
337 | 336 | |
338 | - // Returns an array(0 => min, 1 => max, "min" => min, "max" => max) of the |
|
339 | - // minimum and maximum widths of this frame |
|
340 | - function get_min_max_width() { |
|
337 | + // Returns an array(0 => min, 1 => max, "min" => min, "max" => max) of the |
|
338 | + // minimum and maximum widths of this frame |
|
339 | + function get_min_max_width() { |
|
341 | 340 | |
342 | 341 | $style = $this->_frame->get_style(); |
343 | 342 | $this->_block_parent = $this->_frame->find_block_parent(); |
@@ -363,24 +362,24 @@ discard block |
||
363 | 362 | // faster than doing a single-pass character by character scan. Heh, |
364 | 363 | // yes I took the time to bench it ;) |
365 | 364 | $words = array_flip(preg_split("/[\s-]+/u",$str, -1, PREG_SPLIT_DELIM_CAPTURE)); |
366 | - array_walk($words, create_function('&$val,$str', |
|
367 | - '$val = Font_Metrics::get_text_width($str, "'.$font.'", '.$size.', '.$spacing.');')); |
|
368 | - arsort($words); |
|
369 | - $min = reset($words); |
|
370 | - break; |
|
365 | + array_walk($words, create_function('&$val,$str', |
|
366 | + '$val = Font_Metrics::get_text_width($str, "'.$font.'", '.$size.', '.$spacing.');')); |
|
367 | + arsort($words); |
|
368 | + $min = reset($words); |
|
369 | + break; |
|
371 | 370 | |
372 | 371 | case "pre": |
373 | 372 | $lines = array_flip(preg_split("/\n/u", $str)); |
374 | - array_walk($lines, create_function('&$val,$str', |
|
375 | - '$val = Font_Metrics::get_text_width($str, "'.$font.'", '.$size.', '.$spacing.');')); |
|
373 | + array_walk($lines, create_function('&$val,$str', |
|
374 | + '$val = Font_Metrics::get_text_width($str, "'.$font.'", '.$size.', '.$spacing.');')); |
|
376 | 375 | |
377 | - arsort($lines); |
|
378 | - $min = reset($lines); |
|
379 | - break; |
|
376 | + arsort($lines); |
|
377 | + $min = reset($lines); |
|
378 | + break; |
|
380 | 379 | |
381 | 380 | case "nowrap": |
382 | 381 | $min = Font_Metrics::get_text_width($this->_collapse_white_space($str), $font, $size, $spacing); |
383 | - break; |
|
382 | + break; |
|
384 | 383 | |
385 | 384 | } |
386 | 385 | |
@@ -390,7 +389,7 @@ discard block |
||
390 | 389 | case "normal": |
391 | 390 | case "nowrap": |
392 | 391 | $str = preg_replace("/[\s\n]+/u"," ", $text); |
393 | - break; |
|
392 | + break; |
|
394 | 393 | |
395 | 394 | case "pre-line": |
396 | 395 | $str = preg_replace( "/[ \t]+/u", " ", $text); |
@@ -398,12 +397,12 @@ discard block |
||
398 | 397 | case "pre-wrap": |
399 | 398 | // Find the longest word (i.e. minimum length) |
400 | 399 | $lines = array_flip(preg_split("/\n/", $text)); |
401 | - array_walk($lines, create_function('&$val,$str', |
|
402 | - '$val = Font_Metrics::get_text_width($str, "'.$font.'", '.$size.', '.$spacing.');')); |
|
403 | - arsort($lines); |
|
404 | - reset($lines); |
|
405 | - $str = key($lines); |
|
406 | - break; |
|
400 | + array_walk($lines, create_function('&$val,$str', |
|
401 | + '$val = Font_Metrics::get_text_width($str, "'.$font.'", '.$size.', '.$spacing.');')); |
|
402 | + arsort($lines); |
|
403 | + reset($lines); |
|
404 | + $str = key($lines); |
|
405 | + break; |
|
407 | 406 | |
408 | 407 | } |
409 | 408 | |
@@ -420,6 +419,6 @@ discard block |
||
420 | 419 | |
421 | 420 | return array($min, $max, "min" => $min, "max" => $max); |
422 | 421 | |
423 | - } |
|
422 | + } |
|
424 | 423 | |
425 | 424 | } |
@@ -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_row_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,35 +46,35 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Table_Row_Frame_Decorator extends Frame_Decorator { |
49 | 48 | |
50 | - // protected members |
|
49 | + // protected members |
|
51 | 50 | |
52 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
51 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
53 | 52 | parent::__construct($frame, $dompdf); |
54 | - } |
|
53 | + } |
|
55 | 54 | |
56 | - //........................................................................ |
|
55 | + //........................................................................ |
|
57 | 56 | |
58 | - /** |
|
59 | - * Remove all non table-cell frames from this row and move them after |
|
60 | - * the table. |
|
61 | - */ |
|
62 | - function normalise() { |
|
57 | + /** |
|
58 | + * Remove all non table-cell frames from this row and move them after |
|
59 | + * the table. |
|
60 | + */ |
|
61 | + function normalise() { |
|
63 | 62 | |
64 | 63 | // Find our table parent |
65 | 64 | $p = Table_Frame_Decorator::find_parent_table($this); |
66 | 65 | |
67 | 66 | $erroneous_frames = array(); |
68 | 67 | foreach ($this->get_children() as $child) { |
69 | - $display = $child->get_style()->display; |
|
68 | + $display = $child->get_style()->display; |
|
70 | 69 | |
71 | - if ( $display !== "table-cell" ) |
|
70 | + if ( $display !== "table-cell" ) |
|
72 | 71 | $erroneous_frames[] = $child; |
73 | 72 | } |
74 | 73 | |
75 | 74 | // dump the extra nodes after the table. |
76 | 75 | foreach ($erroneous_frames as $frame) |
77 | - $p->move_after($frame); |
|
78 | - } |
|
76 | + $p->move_after($frame); |
|
77 | + } |
|
79 | 78 | |
80 | 79 | |
81 | 80 | } |