@@ -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 */ |
@@ -44,9 +43,9 @@ discard block |
||
44 | 43 | */ |
45 | 44 | class Absolute_Positioner extends Positioner { |
46 | 45 | |
47 | - function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
46 | + function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
48 | 47 | |
49 | - function position() { |
|
48 | + function position() { |
|
50 | 49 | |
51 | 50 | $cb = $this->_frame->get_containing_block(); |
52 | 51 | |
@@ -61,27 +60,27 @@ discard block |
||
61 | 60 | |
62 | 61 | if ( $p ) { |
63 | 62 | |
64 | - // Get the parent's padding box (see http://www.w3.org/TR/CSS21/visuren.html#propdef-top) |
|
63 | + // Get the parent's padding box (see http://www.w3.org/TR/CSS21/visuren.html#propdef-top) |
|
65 | 64 | |
66 | - list($x, $y, $w, $h) = $p->get_padding_box(); |
|
65 | + list($x, $y, $w, $h) = $p->get_padding_box(); |
|
67 | 66 | |
68 | 67 | } else { |
69 | 68 | |
70 | - $x = $cb["x"]; |
|
71 | - $y = $cb["y"]; |
|
69 | + $x = $cb["x"]; |
|
70 | + $y = $cb["y"]; |
|
72 | 71 | |
73 | 72 | } |
74 | 73 | |
75 | 74 | if ( isset($top) ) { |
76 | - $y += $top; |
|
75 | + $y += $top; |
|
77 | 76 | } else if ( isset($bottom) ) { |
78 | - // FIXME: need to know this frame's height before we can do this correctly |
|
77 | + // FIXME: need to know this frame's height before we can do this correctly |
|
79 | 78 | } |
80 | 79 | |
81 | 80 | $x += $left; |
82 | 81 | |
83 | 82 | $this->_frame->set_position($x, $y); |
84 | 83 | |
85 | - } |
|
84 | + } |
|
86 | 85 | |
87 | 86 | } |
88 | 87 | \ No newline at end of file |
@@ -1,41 +1,40 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: cached_pdf_decorator.cls.php,v $ |
|
6 | - * Created on: 2004-07-23 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @package dompdf |
|
37 | - |
|
38 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: cached_pdf_decorator.cls.php,v $ |
|
6 | + * Created on: 2004-07-23 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @package dompdf |
|
37 | + */ |
|
39 | 38 | |
40 | 39 | /* $Id: cached_pdf_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
41 | 40 | |
@@ -53,90 +52,90 @@ discard block |
||
53 | 52 | * @package dompdf |
54 | 53 | */ |
55 | 54 | class Cached_PDF_Decorator extends CPDF_Adapter implements Canvas { |
56 | - protected $_pdf; |
|
57 | - protected $_cache_id; |
|
58 | - protected $_current_page_id; |
|
59 | - protected $_fonts; // fonts used in this document |
|
55 | + protected $_pdf; |
|
56 | + protected $_cache_id; |
|
57 | + protected $_current_page_id; |
|
58 | + protected $_fonts; // fonts used in this document |
|
60 | 59 | |
61 | - function __construct($cache_id, CPDF_Adapter $pdf) { |
|
60 | + function __construct($cache_id, CPDF_Adapter $pdf) { |
|
62 | 61 | $this->_pdf = $pdf; |
63 | 62 | $this->_cache_id = $cache_id; |
64 | 63 | $this->_fonts = array(); |
65 | 64 | |
66 | 65 | $this->_current_page_id = $this->_pdf->open_object(); |
67 | - } |
|
66 | + } |
|
68 | 67 | |
69 | - //........................................................................ |
|
68 | + //........................................................................ |
|
70 | 69 | |
71 | - function get_cpdf() { return $this->_pdf->get_cpdf(); } |
|
70 | + function get_cpdf() { return $this->_pdf->get_cpdf(); } |
|
72 | 71 | |
73 | - function open_object() { $this->_pdf->open_object(); } |
|
74 | - function reopen_object() { return $this->_pdf->reopen_object(); } |
|
72 | + function open_object() { $this->_pdf->open_object(); } |
|
73 | + function reopen_object() { return $this->_pdf->reopen_object(); } |
|
75 | 74 | |
76 | - function close_object() { $this->_pdf->close_object(); } |
|
75 | + function close_object() { $this->_pdf->close_object(); } |
|
77 | 76 | |
78 | - function add_object($object, $where = 'all') { $this->_pdf->add_object($object, $where); } |
|
77 | + function add_object($object, $where = 'all') { $this->_pdf->add_object($object, $where); } |
|
79 | 78 | |
80 | - function serialize_object($id) { $this->_pdf->serialize_object($id); } |
|
79 | + function serialize_object($id) { $this->_pdf->serialize_object($id); } |
|
81 | 80 | |
82 | - function reopen_serialized_object($obj) { $this->_pdf->reopen_serialized_object($obj); } |
|
81 | + function reopen_serialized_object($obj) { $this->_pdf->reopen_serialized_object($obj); } |
|
83 | 82 | |
84 | - //........................................................................ |
|
83 | + //........................................................................ |
|
85 | 84 | |
86 | - function get_width() { return $this->_pdf->get_width(); } |
|
87 | - function get_height() { return $this->_pdf->get_height(); } |
|
88 | - function get_page_number() { return $this->_pdf->get_page_number(); } |
|
89 | - function get_page_count() { return $this->_pdf->get_page_count(); } |
|
85 | + function get_width() { return $this->_pdf->get_width(); } |
|
86 | + function get_height() { return $this->_pdf->get_height(); } |
|
87 | + function get_page_number() { return $this->_pdf->get_page_number(); } |
|
88 | + function get_page_count() { return $this->_pdf->get_page_count(); } |
|
90 | 89 | |
91 | - function set_page_number($num) { $this->_pdf->set_page_number($num); } |
|
92 | - function set_page_count($count) { $this->_pdf->set_page_count($count); } |
|
90 | + function set_page_number($num) { $this->_pdf->set_page_number($num); } |
|
91 | + function set_page_count($count) { $this->_pdf->set_page_count($count); } |
|
93 | 92 | |
94 | - function line($x1, $y1, $x2, $y2, $color, $width, $style = array()) { |
|
93 | + function line($x1, $y1, $x2, $y2, $color, $width, $style = array()) { |
|
95 | 94 | $this->_pdf->line($x1, $y1, $x2, $y2, $color, $width, $style); |
96 | - } |
|
95 | + } |
|
97 | 96 | |
98 | - function rectangle($x1, $y1, $w, $h, $color, $width, $style = array()) { |
|
97 | + function rectangle($x1, $y1, $w, $h, $color, $width, $style = array()) { |
|
99 | 98 | $this->_pdf->rectangle($x1, $y1, $w, $h, $color, $width, $style); |
100 | - } |
|
99 | + } |
|
101 | 100 | |
102 | - function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
101 | + function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
103 | 102 | $this->_pdf->filled_rectangle($x1, $y1, $w, $h, $color); |
104 | - } |
|
103 | + } |
|
105 | 104 | |
106 | - function polygon($points, $color, $width = null, $style = array(), $fill = false) { |
|
105 | + function polygon($points, $color, $width = null, $style = array(), $fill = false) { |
|
107 | 106 | $this->_pdf->polygon($points, $color, $width, $style, $fill); |
108 | - } |
|
107 | + } |
|
109 | 108 | |
110 | - function circle($x, $y, $r1, $color, $width = null, $style = null, $fill = false) { |
|
109 | + function circle($x, $y, $r1, $color, $width = null, $style = null, $fill = false) { |
|
111 | 110 | $this->_pdf->circle($x, $y, $r1, $color, $width, $style, $fill); |
112 | - } |
|
111 | + } |
|
113 | 112 | |
114 | - function image($img_url, $x, $y, $w = null, $h = null) { |
|
113 | + function image($img_url, $x, $y, $w = null, $h = null) { |
|
115 | 114 | $this->_pdf->image($img_url, $x, $y, $w, $h); |
116 | - } |
|
115 | + } |
|
117 | 116 | |
118 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
117 | + function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
119 | 118 | $this->_fonts[$font] = true; |
120 | 119 | $this->_pdf->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
121 | - } |
|
120 | + } |
|
122 | 121 | |
123 | - function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
122 | + function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
124 | 123 | |
125 | 124 | // We want to remove this from cached pages since it may not be correct |
126 | 125 | $this->_pdf->close_object(); |
127 | 126 | $this->_pdf->page_text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
128 | 127 | $this->_pdf->reopen_object($this->_current_page_id); |
129 | - } |
|
128 | + } |
|
130 | 129 | |
131 | - function page_script($script, $type = 'text/php') { |
|
130 | + function page_script($script, $type = 'text/php') { |
|
132 | 131 | |
133 | 132 | // We want to remove this from cached pages since it may not be correct |
134 | 133 | $this->_pdf->close_object(); |
135 | 134 | $this->_pdf->page_script($script, $type); |
136 | 135 | $this->_pdf->reopen_object($this->_current_page_id); |
137 | - } |
|
136 | + } |
|
138 | 137 | |
139 | - function new_page() { |
|
138 | + function new_page() { |
|
140 | 139 | $this->_pdf->close_object(); |
141 | 140 | |
142 | 141 | // Add the object to the current page |
@@ -144,43 +143,43 @@ discard block |
||
144 | 143 | $this->_pdf->new_page(); |
145 | 144 | |
146 | 145 | Page_Cache::store_page($this->_cache_id, |
147 | - $this->_pdf->get_page_number() - 1, |
|
148 | - $this->_pdf->serialize_object($this->_current_page_id)); |
|
146 | + $this->_pdf->get_page_number() - 1, |
|
147 | + $this->_pdf->serialize_object($this->_current_page_id)); |
|
149 | 148 | |
150 | 149 | $this->_current_page_id = $this->_pdf->open_object(); |
151 | 150 | return $this->_current_page_id; |
152 | - } |
|
151 | + } |
|
153 | 152 | |
154 | - function stream($filename) { |
|
153 | + function stream($filename) { |
|
155 | 154 | // Store the last page in the page cache |
156 | 155 | if ( !is_null($this->_current_page_id) ) { |
157 | - $this->_pdf->close_object(); |
|
158 | - $this->_pdf->add_object($this->_current_page_id, "add"); |
|
159 | - Page_Cache::store_page($this->_cache_id, |
|
160 | - $this->_pdf->get_page_number(), |
|
161 | - $this->_pdf->serialize_object($this->_current_page_id)); |
|
162 | - Page_Cache::store_fonts($this->_cache_id, $this->_fonts); |
|
163 | - $this->_current_page_id = null; |
|
156 | + $this->_pdf->close_object(); |
|
157 | + $this->_pdf->add_object($this->_current_page_id, "add"); |
|
158 | + Page_Cache::store_page($this->_cache_id, |
|
159 | + $this->_pdf->get_page_number(), |
|
160 | + $this->_pdf->serialize_object($this->_current_page_id)); |
|
161 | + Page_Cache::store_fonts($this->_cache_id, $this->_fonts); |
|
162 | + $this->_current_page_id = null; |
|
164 | 163 | } |
165 | 164 | |
166 | 165 | $this->_pdf->stream($filename); |
167 | 166 | |
168 | - } |
|
167 | + } |
|
169 | 168 | |
170 | - function &output() { |
|
169 | + function &output() { |
|
171 | 170 | // Store the last page in the page cache |
172 | 171 | if ( !is_null($this->_current_page_id) ) { |
173 | - $this->_pdf->close_object(); |
|
174 | - $this->_pdf->add_object($this->_current_page_id, "add"); |
|
175 | - Page_Cache::store_page($this->_cache_id, |
|
176 | - $this->_pdf->get_page_number(), |
|
177 | - $this->_pdf->serialize_object($this->_current_page_id)); |
|
178 | - $this->_current_page_id = null; |
|
172 | + $this->_pdf->close_object(); |
|
173 | + $this->_pdf->add_object($this->_current_page_id, "add"); |
|
174 | + Page_Cache::store_page($this->_cache_id, |
|
175 | + $this->_pdf->get_page_number(), |
|
176 | + $this->_pdf->serialize_object($this->_current_page_id)); |
|
177 | + $this->_current_page_id = null; |
|
179 | 178 | } |
180 | 179 | |
181 | 180 | return $this->_pdf->output(); |
182 | - } |
|
181 | + } |
|
183 | 182 | |
184 | - function get_messages() { return $this->_pdf->get_messages(); } |
|
183 | + function get_messages() { return $this->_pdf->get_messages(); } |
|
185 | 184 | |
186 | 185 | } |
@@ -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: tcpdf_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */ |
@@ -57,98 +56,98 @@ discard block |
||
57 | 56 | */ |
58 | 57 | class TCPDF_Adapter implements Canvas { |
59 | 58 | |
60 | - /** |
|
61 | - * Dimensions of paper sizes in points |
|
62 | - * |
|
63 | - * @var array; |
|
64 | - */ |
|
65 | - static public $PAPER_SIZES = array(); // Set to |
|
59 | + /** |
|
60 | + * Dimensions of paper sizes in points |
|
61 | + * |
|
62 | + * @var array; |
|
63 | + */ |
|
64 | + static public $PAPER_SIZES = array(); // Set to |
|
66 | 65 | // CPDF_Adapter::$PAPER_SIZES below. |
67 | 66 | |
68 | 67 | |
69 | - /** |
|
70 | - * Instance of the TCPDF class |
|
71 | - * |
|
72 | - * @var TCPDF |
|
73 | - */ |
|
74 | - private $_pdf; |
|
75 | - |
|
76 | - /** |
|
77 | - * PDF width in points |
|
78 | - * |
|
79 | - * @var float |
|
80 | - */ |
|
81 | - private $_width; |
|
82 | - |
|
83 | - /** |
|
84 | - * PDF height in points |
|
85 | - * |
|
86 | - * @var float |
|
87 | - */ |
|
88 | - private $_height; |
|
89 | - |
|
90 | - /** |
|
91 | - * Last fill colour used |
|
92 | - * |
|
93 | - * @var array |
|
94 | - */ |
|
95 | - private $_last_fill_color; |
|
96 | - |
|
97 | - /** |
|
98 | - * Last stroke colour used |
|
99 | - * |
|
100 | - * @var array |
|
101 | - */ |
|
102 | - private $_last_stroke_color; |
|
103 | - |
|
104 | - /** |
|
105 | - * Last line width used |
|
106 | - * |
|
107 | - * @var float |
|
108 | - */ |
|
109 | - private $_last_line_width; |
|
68 | + /** |
|
69 | + * Instance of the TCPDF class |
|
70 | + * |
|
71 | + * @var TCPDF |
|
72 | + */ |
|
73 | + private $_pdf; |
|
74 | + |
|
75 | + /** |
|
76 | + * PDF width in points |
|
77 | + * |
|
78 | + * @var float |
|
79 | + */ |
|
80 | + private $_width; |
|
81 | + |
|
82 | + /** |
|
83 | + * PDF height in points |
|
84 | + * |
|
85 | + * @var float |
|
86 | + */ |
|
87 | + private $_height; |
|
88 | + |
|
89 | + /** |
|
90 | + * Last fill colour used |
|
91 | + * |
|
92 | + * @var array |
|
93 | + */ |
|
94 | + private $_last_fill_color; |
|
95 | + |
|
96 | + /** |
|
97 | + * Last stroke colour used |
|
98 | + * |
|
99 | + * @var array |
|
100 | + */ |
|
101 | + private $_last_stroke_color; |
|
102 | + |
|
103 | + /** |
|
104 | + * Last line width used |
|
105 | + * |
|
106 | + * @var float |
|
107 | + */ |
|
108 | + private $_last_line_width; |
|
110 | 109 | |
111 | - /** |
|
112 | - * Total number of pages |
|
113 | - * |
|
114 | - * @var int |
|
115 | - */ |
|
116 | - private $_page_count; |
|
117 | - |
|
118 | - /** |
|
119 | - * Text to display on every page |
|
120 | - * |
|
121 | - * @var array |
|
122 | - */ |
|
123 | - private $_page_text; |
|
124 | - |
|
125 | - /** |
|
126 | - * Array of pages for accessing after initial rendering is complete |
|
127 | - * |
|
128 | - * @var array |
|
129 | - */ |
|
130 | - private $_pages; |
|
131 | - |
|
132 | - /** |
|
133 | - * Class constructor |
|
134 | - * |
|
135 | - * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or |
|
136 | - * an array(xmin,ymin,xmax,ymax) |
|
137 | - * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
138 | - */ |
|
139 | - function __construct($paper = "letter", $orientation = "portrait") { |
|
110 | + /** |
|
111 | + * Total number of pages |
|
112 | + * |
|
113 | + * @var int |
|
114 | + */ |
|
115 | + private $_page_count; |
|
116 | + |
|
117 | + /** |
|
118 | + * Text to display on every page |
|
119 | + * |
|
120 | + * @var array |
|
121 | + */ |
|
122 | + private $_page_text; |
|
123 | + |
|
124 | + /** |
|
125 | + * Array of pages for accessing after initial rendering is complete |
|
126 | + * |
|
127 | + * @var array |
|
128 | + */ |
|
129 | + private $_pages; |
|
130 | + |
|
131 | + /** |
|
132 | + * Class constructor |
|
133 | + * |
|
134 | + * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or |
|
135 | + * an array(xmin,ymin,xmax,ymax) |
|
136 | + * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
137 | + */ |
|
138 | + function __construct($paper = "letter", $orientation = "portrait") { |
|
140 | 139 | |
141 | 140 | if ( is_array($paper) ) |
142 | - $size = $paper; |
|
141 | + $size = $paper; |
|
143 | 142 | else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
144 | - $size = self::$PAPER_SIZE[$paper]; |
|
143 | + $size = self::$PAPER_SIZE[$paper]; |
|
145 | 144 | else |
146 | - $size = self::$PAPER_SIZE["letter"]; |
|
145 | + $size = self::$PAPER_SIZE["letter"]; |
|
147 | 146 | |
148 | 147 | if ( mb_strtolower($orientation) === "landscape" ) { |
149 | - $a = $size[3]; |
|
150 | - $size[3] = $size[2]; |
|
151 | - $size[2] = $a; |
|
148 | + $a = $size[3]; |
|
149 | + $size[3] = $size[2]; |
|
150 | + $size[2] = $a; |
|
152 | 151 | } |
153 | 152 | |
154 | 153 | $this->_width = $size[2] - $size[0]; |
@@ -163,135 +162,135 @@ discard block |
||
163 | 162 | $this->_page_text = array(); |
164 | 163 | |
165 | 164 | $this->_last_fill_color = |
166 | - $this->_last_stroke_color = |
|
167 | - $this->_last_line_width = null; |
|
165 | + $this->_last_stroke_color = |
|
166 | + $this->_last_line_width = null; |
|
168 | 167 | |
169 | - } |
|
168 | + } |
|
170 | 169 | |
171 | - /** |
|
172 | - * Remaps y coords from 4th to 1st quadrant |
|
173 | - * |
|
174 | - * @param float $y |
|
175 | - * @return float |
|
176 | - */ |
|
177 | - protected function y($y) { return $this->_height - $y; } |
|
178 | - |
|
179 | - /** |
|
180 | - * Sets the stroke colour |
|
181 | - * |
|
182 | - * @param array $color |
|
183 | - */ |
|
184 | - protected function _set_stroke_colour($colour) { |
|
170 | + /** |
|
171 | + * Remaps y coords from 4th to 1st quadrant |
|
172 | + * |
|
173 | + * @param float $y |
|
174 | + * @return float |
|
175 | + */ |
|
176 | + protected function y($y) { return $this->_height - $y; } |
|
177 | + |
|
178 | + /** |
|
179 | + * Sets the stroke colour |
|
180 | + * |
|
181 | + * @param array $color |
|
182 | + */ |
|
183 | + protected function _set_stroke_colour($colour) { |
|
185 | 184 | $colour[0] = round(255 * $colour[0]); |
186 | 185 | $colour[1] = round(255 * $colour[1]); |
187 | 186 | $colour[2] = round(255 * $colour[2]); |
188 | 187 | |
189 | 188 | if ( is_null($this->_last_stroke_color) || $color != $this->_last_stroke_color ) { |
190 | - $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]); |
|
191 | - $this->_last_stroke_color = $color; |
|
189 | + $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]); |
|
190 | + $this->_last_stroke_color = $color; |
|
192 | 191 | } |
193 | 192 | |
194 | - } |
|
193 | + } |
|
195 | 194 | |
196 | - /** |
|
197 | - * Sets the fill colour |
|
198 | - * |
|
199 | - * @param array $color |
|
200 | - */ |
|
201 | - protected function _set_fill_colour($colour) { |
|
195 | + /** |
|
196 | + * Sets the fill colour |
|
197 | + * |
|
198 | + * @param array $color |
|
199 | + */ |
|
200 | + protected function _set_fill_colour($colour) { |
|
202 | 201 | $colour[0] = round(255 * $colour[0]); |
203 | 202 | $colour[1] = round(255 * $colour[1]); |
204 | 203 | $colour[2] = round(255 * $colour[2]); |
205 | 204 | |
206 | 205 | if ( is_null($this->_last_fill_color) || $color != $this->_last_fill_color ) { |
207 | - $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]); |
|
208 | - $this->_last_fill_color = $color; |
|
206 | + $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]); |
|
207 | + $this->_last_fill_color = $color; |
|
209 | 208 | } |
210 | 209 | |
211 | - } |
|
210 | + } |
|
212 | 211 | |
213 | - /** |
|
214 | - * Return the TCPDF instance |
|
215 | - * |
|
216 | - * @return TCPDF |
|
217 | - */ |
|
218 | - function get_tcpdf() { return $this->_pdf; } |
|
212 | + /** |
|
213 | + * Return the TCPDF instance |
|
214 | + * |
|
215 | + * @return TCPDF |
|
216 | + */ |
|
217 | + function get_tcpdf() { return $this->_pdf; } |
|
219 | 218 | |
220 | - /** |
|
221 | - * Returns the current page number |
|
222 | - * |
|
223 | - * @return int |
|
224 | - */ |
|
225 | - function get_page_number() { |
|
219 | + /** |
|
220 | + * Returns the current page number |
|
221 | + * |
|
222 | + * @return int |
|
223 | + */ |
|
224 | + function get_page_number() { |
|
226 | 225 | return $this->_page_number; |
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * Returns the total number of pages |
|
231 | - * |
|
232 | - * @return int |
|
233 | - */ |
|
234 | - function get_page_count() { |
|
226 | + } |
|
227 | + |
|
228 | + /** |
|
229 | + * Returns the total number of pages |
|
230 | + * |
|
231 | + * @return int |
|
232 | + */ |
|
233 | + function get_page_count() { |
|
235 | 234 | return $this->_page_count; |
236 | - } |
|
237 | - |
|
238 | - /** |
|
239 | - * Sets the total number of pages |
|
240 | - * |
|
241 | - * @param int $count |
|
242 | - */ |
|
243 | - function set_page_count($count) { |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * Sets the total number of pages |
|
239 | + * |
|
240 | + * @param int $count |
|
241 | + */ |
|
242 | + function set_page_count($count) { |
|
244 | 243 | $this->_page_count = (int)$count; |
245 | - } |
|
246 | - |
|
247 | - /** |
|
248 | - * Draws a line from x1,y1 to x2,y2 |
|
249 | - * |
|
250 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
251 | - * See {@link Cpdf::setLineStyle()} for a description of the format of the |
|
252 | - * $style parameter (aka dash). |
|
253 | - * |
|
254 | - * @param float $x1 |
|
255 | - * @param float $y1 |
|
256 | - * @param float $x2 |
|
257 | - * @param float $y2 |
|
258 | - * @param array $color |
|
259 | - * @param float $width |
|
260 | - * @param array $style |
|
261 | - */ |
|
262 | - function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
244 | + } |
|
245 | + |
|
246 | + /** |
|
247 | + * Draws a line from x1,y1 to x2,y2 |
|
248 | + * |
|
249 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
250 | + * See {@link Cpdf::setLineStyle()} for a description of the format of the |
|
251 | + * $style parameter (aka dash). |
|
252 | + * |
|
253 | + * @param float $x1 |
|
254 | + * @param float $y1 |
|
255 | + * @param float $x2 |
|
256 | + * @param float $y2 |
|
257 | + * @param array $color |
|
258 | + * @param float $width |
|
259 | + * @param array $style |
|
260 | + */ |
|
261 | + function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
263 | 262 | |
264 | 263 | if ( is_null($this->_last_line_width) || $width != $this->_last_line_width ) { |
265 | - $this->_pdf->SetLineWidth($width); |
|
266 | - $this->_last_line_width = $width; |
|
264 | + $this->_pdf->SetLineWidth($width); |
|
265 | + $this->_last_line_width = $width; |
|
267 | 266 | } |
268 | 267 | |
269 | 268 | $this->_set_stroke_colour($color); |
270 | 269 | |
271 | 270 | // FIXME: ugh, need to handle different styles here |
272 | 271 | $this->_pdf->line($x1, $y1, $x2, $y2); |
273 | - } |
|
274 | - |
|
275 | - /** |
|
276 | - * Draws a rectangle at x1,y1 with width w and height h |
|
277 | - * |
|
278 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
279 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
280 | - * parameter (aka dash) |
|
281 | - * |
|
282 | - * @param float $x1 |
|
283 | - * @param float $y1 |
|
284 | - * @param float $w |
|
285 | - * @param float $h |
|
286 | - * @param array $color |
|
287 | - * @param float $width |
|
288 | - * @param array $style |
|
289 | - */ |
|
290 | - function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
272 | + } |
|
273 | + |
|
274 | + /** |
|
275 | + * Draws a rectangle at x1,y1 with width w and height h |
|
276 | + * |
|
277 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
278 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
279 | + * parameter (aka dash) |
|
280 | + * |
|
281 | + * @param float $x1 |
|
282 | + * @param float $y1 |
|
283 | + * @param float $w |
|
284 | + * @param float $h |
|
285 | + * @param array $color |
|
286 | + * @param float $width |
|
287 | + * @param array $style |
|
288 | + */ |
|
289 | + function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
291 | 290 | |
292 | 291 | if ( is_null($this->_last_line_width) || $width != $this->_last_line_width ) { |
293 | - $this->_pdf->SetLineWidth($width); |
|
294 | - $this->_last_line_width = $width; |
|
292 | + $this->_pdf->SetLineWidth($width); |
|
293 | + $this->_last_line_width = $width; |
|
295 | 294 | } |
296 | 295 | |
297 | 296 | $this->_set_stroke_colour($color); |
@@ -299,165 +298,165 @@ discard block |
||
299 | 298 | // FIXME: ugh, need to handle styles here |
300 | 299 | $this->_pdf->rect($x1, $y1, $w, $h); |
301 | 300 | |
302 | - } |
|
303 | - |
|
304 | - /** |
|
305 | - * Draws a filled rectangle at x1,y1 with width w and height h |
|
306 | - * |
|
307 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
308 | - * |
|
309 | - * @param float $x1 |
|
310 | - * @param float $y1 |
|
311 | - * @param float $w |
|
312 | - * @param float $h |
|
313 | - * @param array $color |
|
314 | - */ |
|
315 | - function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
301 | + } |
|
302 | + |
|
303 | + /** |
|
304 | + * Draws a filled rectangle at x1,y1 with width w and height h |
|
305 | + * |
|
306 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
307 | + * |
|
308 | + * @param float $x1 |
|
309 | + * @param float $y1 |
|
310 | + * @param float $w |
|
311 | + * @param float $h |
|
312 | + * @param array $color |
|
313 | + */ |
|
314 | + function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
316 | 315 | |
317 | 316 | $this->_set_fill_colour($color); |
318 | 317 | |
319 | 318 | // FIXME: ugh, need to handle styles here |
320 | 319 | $this->_pdf->rect($x1, $y1, $w, $h, "F"); |
321 | - } |
|
322 | - |
|
323 | - /** |
|
324 | - * Draws a polygon |
|
325 | - * |
|
326 | - * The polygon is formed by joining all the points stored in the $points |
|
327 | - * array. $points has the following structure: |
|
328 | - * <code> |
|
329 | - * array(0 => x1, |
|
330 | - * 1 => y1, |
|
331 | - * 2 => x2, |
|
332 | - * 3 => y2, |
|
333 | - * ... |
|
334 | - * ); |
|
335 | - * </code> |
|
336 | - * |
|
337 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
338 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
339 | - * parameter (aka dash) |
|
340 | - * |
|
341 | - * @param array $points |
|
342 | - * @param array $color |
|
343 | - * @param float $width |
|
344 | - * @param array $style |
|
345 | - * @param bool $fill Fills the polygon if true |
|
346 | - */ |
|
347 | - function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
320 | + } |
|
321 | + |
|
322 | + /** |
|
323 | + * Draws a polygon |
|
324 | + * |
|
325 | + * The polygon is formed by joining all the points stored in the $points |
|
326 | + * array. $points has the following structure: |
|
327 | + * <code> |
|
328 | + * array(0 => x1, |
|
329 | + * 1 => y1, |
|
330 | + * 2 => x2, |
|
331 | + * 3 => y2, |
|
332 | + * ... |
|
333 | + * ); |
|
334 | + * </code> |
|
335 | + * |
|
336 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
337 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
338 | + * parameter (aka dash) |
|
339 | + * |
|
340 | + * @param array $points |
|
341 | + * @param array $color |
|
342 | + * @param float $width |
|
343 | + * @param array $style |
|
344 | + * @param bool $fill Fills the polygon if true |
|
345 | + */ |
|
346 | + function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
348 | 347 | // FIXME: FPDF sucks |
349 | - } |
|
350 | - |
|
351 | - /** |
|
352 | - * Draws a circle at $x,$y with radius $r |
|
353 | - * |
|
354 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
355 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
356 | - * parameter (aka dash) |
|
357 | - * |
|
358 | - * @param float $x |
|
359 | - * @param float $y |
|
360 | - * @param float $r |
|
361 | - * @param array $color |
|
362 | - * @param float $width |
|
363 | - * @param array $style |
|
364 | - * @param bool $fill Fills the circle if true |
|
365 | - */ |
|
366 | - function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false){} |
|
367 | - |
|
368 | - /** |
|
369 | - * Add an image to the pdf. |
|
370 | - * |
|
371 | - * The image is placed at the specified x and y coordinates with the |
|
372 | - * given width and height. |
|
373 | - * |
|
374 | - * @param string $img_url the path to the image |
|
375 | - * @param string $img_type the type (e.g. extension) of the image |
|
376 | - * @param float $x x position |
|
377 | - * @param float $y y position |
|
378 | - * @param int $w width (in pixels) |
|
379 | - * @param int $h height (in pixels) |
|
380 | - */ |
|
381 | - function image($img_url, $img_type, $x, $y, $w, $h){} |
|
382 | - |
|
383 | - /** |
|
384 | - * Writes text at the specified x and y coordinates |
|
385 | - * |
|
386 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
387 | - * |
|
388 | - * @param float $x |
|
389 | - * @param float $y |
|
390 | - * @param string $text the text to write |
|
391 | - * @param string $font the font file to use |
|
392 | - * @param float $size the font size, in points |
|
393 | - * @param array $color |
|
394 | - * @param float $adjust word spacing adjustment |
|
395 | - */ |
|
396 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0){} |
|
397 | - |
|
398 | - function javascript($code){} |
|
348 | + } |
|
349 | + |
|
350 | + /** |
|
351 | + * Draws a circle at $x,$y with radius $r |
|
352 | + * |
|
353 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
354 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
355 | + * parameter (aka dash) |
|
356 | + * |
|
357 | + * @param float $x |
|
358 | + * @param float $y |
|
359 | + * @param float $r |
|
360 | + * @param array $color |
|
361 | + * @param float $width |
|
362 | + * @param array $style |
|
363 | + * @param bool $fill Fills the circle if true |
|
364 | + */ |
|
365 | + function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false){} |
|
366 | + |
|
367 | + /** |
|
368 | + * Add an image to the pdf. |
|
369 | + * |
|
370 | + * The image is placed at the specified x and y coordinates with the |
|
371 | + * given width and height. |
|
372 | + * |
|
373 | + * @param string $img_url the path to the image |
|
374 | + * @param string $img_type the type (e.g. extension) of the image |
|
375 | + * @param float $x x position |
|
376 | + * @param float $y y position |
|
377 | + * @param int $w width (in pixels) |
|
378 | + * @param int $h height (in pixels) |
|
379 | + */ |
|
380 | + function image($img_url, $img_type, $x, $y, $w, $h){} |
|
381 | + |
|
382 | + /** |
|
383 | + * Writes text at the specified x and y coordinates |
|
384 | + * |
|
385 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
386 | + * |
|
387 | + * @param float $x |
|
388 | + * @param float $y |
|
389 | + * @param string $text the text to write |
|
390 | + * @param string $font the font file to use |
|
391 | + * @param float $size the font size, in points |
|
392 | + * @param array $color |
|
393 | + * @param float $adjust word spacing adjustment |
|
394 | + */ |
|
395 | + function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0){} |
|
396 | + |
|
397 | + function javascript($code){} |
|
399 | 398 | |
400 | - /** |
|
401 | - * Add a named destination (similar to <a name="foo">...</a> in html) |
|
402 | - * |
|
403 | - * @param string $anchorname The name of the named destination |
|
404 | - */ |
|
405 | - function add_named_dest($anchorname){} |
|
406 | - |
|
407 | - /** |
|
408 | - * Add a link to the pdf |
|
409 | - * |
|
410 | - * @param string $url The url to link to |
|
411 | - * @param float $x The x position of the link |
|
412 | - * @param float $y The y position of the link |
|
413 | - * @param float $width The width of the link |
|
414 | - * @param float $height The height of the link |
|
415 | - */ |
|
416 | - function add_link($url, $x, $y, $width, $height){} |
|
399 | + /** |
|
400 | + * Add a named destination (similar to <a name="foo">...</a> in html) |
|
401 | + * |
|
402 | + * @param string $anchorname The name of the named destination |
|
403 | + */ |
|
404 | + function add_named_dest($anchorname){} |
|
405 | + |
|
406 | + /** |
|
407 | + * Add a link to the pdf |
|
408 | + * |
|
409 | + * @param string $url The url to link to |
|
410 | + * @param float $x The x position of the link |
|
411 | + * @param float $y The y position of the link |
|
412 | + * @param float $width The width of the link |
|
413 | + * @param float $height The height of the link |
|
414 | + */ |
|
415 | + function add_link($url, $x, $y, $width, $height){} |
|
417 | 416 | |
418 | - /** |
|
419 | - * Calculates text size, in points |
|
420 | - * |
|
421 | - * @param string $text the text to be sized |
|
422 | - * @param string $font the desired font |
|
423 | - * @param float $size the desired font size |
|
424 | - * @param float $spacing word spacing, if any |
|
425 | - * @return float |
|
426 | - */ |
|
427 | - function get_text_width($text, $font, $size, $spacing = 0){} |
|
428 | - |
|
429 | - /** |
|
430 | - * Calculates font height, in points |
|
431 | - * |
|
432 | - * @param string $font |
|
433 | - * @param float $size |
|
434 | - * @return float |
|
435 | - */ |
|
436 | - function get_font_height($font, $size){} |
|
417 | + /** |
|
418 | + * Calculates text size, in points |
|
419 | + * |
|
420 | + * @param string $text the text to be sized |
|
421 | + * @param string $font the desired font |
|
422 | + * @param float $size the desired font size |
|
423 | + * @param float $spacing word spacing, if any |
|
424 | + * @return float |
|
425 | + */ |
|
426 | + function get_text_width($text, $font, $size, $spacing = 0){} |
|
427 | + |
|
428 | + /** |
|
429 | + * Calculates font height, in points |
|
430 | + * |
|
431 | + * @param string $font |
|
432 | + * @param float $size |
|
433 | + * @return float |
|
434 | + */ |
|
435 | + function get_font_height($font, $size){} |
|
437 | 436 | |
438 | 437 | |
439 | - /** |
|
440 | - * Starts a new page |
|
441 | - * |
|
442 | - * Subsequent drawing operations will appear on the new page. |
|
443 | - */ |
|
444 | - function new_page(){} |
|
445 | - |
|
446 | - /** |
|
447 | - * Streams the PDF directly to the browser |
|
448 | - * |
|
449 | - * @param string $filename the name of the PDF file |
|
450 | - * @param array $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0 |
|
451 | - */ |
|
452 | - function stream($filename, $options = null){} |
|
453 | - |
|
454 | - /** |
|
455 | - * Returns the PDF as a string |
|
456 | - * |
|
457 | - * @param array $options associative array: 'compress' => 1 or 0 |
|
458 | - * @return string |
|
459 | - */ |
|
460 | - function output($options = null){} |
|
438 | + /** |
|
439 | + * Starts a new page |
|
440 | + * |
|
441 | + * Subsequent drawing operations will appear on the new page. |
|
442 | + */ |
|
443 | + function new_page(){} |
|
444 | + |
|
445 | + /** |
|
446 | + * Streams the PDF directly to the browser |
|
447 | + * |
|
448 | + * @param string $filename the name of the PDF file |
|
449 | + * @param array $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0 |
|
450 | + */ |
|
451 | + function stream($filename, $options = null){} |
|
452 | + |
|
453 | + /** |
|
454 | + * Returns the PDF as a string |
|
455 | + * |
|
456 | + * @param array $options associative array: 'compress' => 1 or 0 |
|
457 | + * @return string |
|
458 | + */ |
|
459 | + function output($options = null){} |
|
461 | 460 | |
462 | 461 | } |
463 | 462 |
@@ -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: cellmap.cls.php,v $ |
|
6 | - * Created on: 2004-07-28 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @package dompdf |
|
37 | - |
|
38 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: cellmap.cls.php,v $ |
|
6 | + * Created on: 2004-07-28 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @package dompdf |
|
37 | + */ |
|
39 | 38 | |
40 | 39 | /* $Id: cellmap.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
41 | 40 | |
@@ -50,12 +49,12 @@ discard block |
||
50 | 49 | */ |
51 | 50 | class Cellmap { |
52 | 51 | |
53 | - /** |
|
54 | - * Border style weight lookup for collapsed border resolution. |
|
55 | - * |
|
56 | - * @var array |
|
57 | - */ |
|
58 | - static protected $_BORDER_STYLE_SCORE = array("inset" => 1, |
|
52 | + /** |
|
53 | + * Border style weight lookup for collapsed border resolution. |
|
54 | + * |
|
55 | + * @var array |
|
56 | + */ |
|
57 | + static protected $_BORDER_STYLE_SCORE = array("inset" => 1, |
|
59 | 58 | "groove" => 2, |
60 | 59 | "outset" => 3, |
61 | 60 | "ridge" => 4, |
@@ -65,87 +64,87 @@ discard block |
||
65 | 64 | "double" => 8, |
66 | 65 | "none" => 0); |
67 | 66 | |
68 | - /** |
|
69 | - * The table object this cellmap is attached to. |
|
70 | - * |
|
71 | - * @var Table_Frame_Decorator |
|
72 | - */ |
|
73 | - protected $_table; |
|
74 | - |
|
75 | - /** |
|
76 | - * The total number of rows in the table |
|
77 | - * |
|
78 | - * @var int |
|
79 | - */ |
|
80 | - protected $_num_rows; |
|
81 | - |
|
82 | - /** |
|
83 | - * The total number of columns in the table |
|
84 | - * |
|
85 | - * @var int |
|
86 | - */ |
|
87 | - protected $_num_cols; |
|
88 | - |
|
89 | - /** |
|
90 | - * 2D array mapping <row,column> to frames |
|
91 | - * |
|
92 | - * @var array |
|
93 | - */ |
|
94 | - protected $_cells; |
|
95 | - |
|
96 | - /** |
|
97 | - * 1D array of column dimensions |
|
98 | - * |
|
99 | - * @var array |
|
100 | - */ |
|
101 | - protected $_columns; |
|
102 | - |
|
103 | - /** |
|
104 | - * 1D array of row dimensions |
|
105 | - * |
|
106 | - * @var array |
|
107 | - */ |
|
108 | - protected $_rows; |
|
109 | - |
|
110 | - /** |
|
111 | - * 2D array of border specs |
|
112 | - * |
|
113 | - * @var array |
|
114 | - */ |
|
115 | - protected $_borders; |
|
116 | - |
|
117 | - /** |
|
118 | - * 1D Array mapping frames to (multiple) <row, col> pairs, keyed on |
|
119 | - * frame_id. |
|
120 | - * |
|
121 | - * @var array |
|
122 | - */ |
|
123 | - protected $_frames; |
|
124 | - |
|
125 | - /** |
|
126 | - * Current column when adding cells, 0-based |
|
127 | - * |
|
128 | - * @var int |
|
129 | - */ |
|
130 | - private $__col; |
|
131 | - |
|
132 | - /** |
|
133 | - * Current row when adding cells, 0-based |
|
134 | - * |
|
135 | - * @var int |
|
136 | - */ |
|
137 | - private $__row; |
|
138 | - |
|
139 | - //........................................................................ |
|
140 | - |
|
141 | - function __construct(Table_Frame_Decorator $table) { |
|
67 | + /** |
|
68 | + * The table object this cellmap is attached to. |
|
69 | + * |
|
70 | + * @var Table_Frame_Decorator |
|
71 | + */ |
|
72 | + protected $_table; |
|
73 | + |
|
74 | + /** |
|
75 | + * The total number of rows in the table |
|
76 | + * |
|
77 | + * @var int |
|
78 | + */ |
|
79 | + protected $_num_rows; |
|
80 | + |
|
81 | + /** |
|
82 | + * The total number of columns in the table |
|
83 | + * |
|
84 | + * @var int |
|
85 | + */ |
|
86 | + protected $_num_cols; |
|
87 | + |
|
88 | + /** |
|
89 | + * 2D array mapping <row,column> to frames |
|
90 | + * |
|
91 | + * @var array |
|
92 | + */ |
|
93 | + protected $_cells; |
|
94 | + |
|
95 | + /** |
|
96 | + * 1D array of column dimensions |
|
97 | + * |
|
98 | + * @var array |
|
99 | + */ |
|
100 | + protected $_columns; |
|
101 | + |
|
102 | + /** |
|
103 | + * 1D array of row dimensions |
|
104 | + * |
|
105 | + * @var array |
|
106 | + */ |
|
107 | + protected $_rows; |
|
108 | + |
|
109 | + /** |
|
110 | + * 2D array of border specs |
|
111 | + * |
|
112 | + * @var array |
|
113 | + */ |
|
114 | + protected $_borders; |
|
115 | + |
|
116 | + /** |
|
117 | + * 1D Array mapping frames to (multiple) <row, col> pairs, keyed on |
|
118 | + * frame_id. |
|
119 | + * |
|
120 | + * @var array |
|
121 | + */ |
|
122 | + protected $_frames; |
|
123 | + |
|
124 | + /** |
|
125 | + * Current column when adding cells, 0-based |
|
126 | + * |
|
127 | + * @var int |
|
128 | + */ |
|
129 | + private $__col; |
|
130 | + |
|
131 | + /** |
|
132 | + * Current row when adding cells, 0-based |
|
133 | + * |
|
134 | + * @var int |
|
135 | + */ |
|
136 | + private $__row; |
|
137 | + |
|
138 | + //........................................................................ |
|
139 | + |
|
140 | + function __construct(Table_Frame_Decorator $table) { |
|
142 | 141 | $this->_table = $table; |
143 | 142 | $this->reset(); |
144 | - } |
|
143 | + } |
|
145 | 144 | |
146 | - //........................................................................ |
|
145 | + //........................................................................ |
|
147 | 146 | |
148 | - function reset() { |
|
147 | + function reset() { |
|
149 | 148 | $this->_num_rows = 0; |
150 | 149 | $this->_num_cols = 0; |
151 | 150 | |
@@ -158,54 +157,54 @@ discard block |
||
158 | 157 | $this->_borders = array(); |
159 | 158 | |
160 | 159 | $this->__col = $this->__row = 0; |
161 | - } |
|
160 | + } |
|
162 | 161 | |
163 | - //........................................................................ |
|
162 | + //........................................................................ |
|
164 | 163 | |
165 | - function get_num_rows() { return $this->_num_rows; } |
|
166 | - function get_num_cols() { return $this->_num_cols; } |
|
164 | + function get_num_rows() { return $this->_num_rows; } |
|
165 | + function get_num_cols() { return $this->_num_cols; } |
|
167 | 166 | |
168 | - function &get_columns() { |
|
167 | + function &get_columns() { |
|
169 | 168 | return $this->_columns; |
170 | - } |
|
169 | + } |
|
171 | 170 | |
172 | - function &get_column($i) { |
|
171 | + function &get_column($i) { |
|
173 | 172 | if ( !isset($this->_columns[$i]) ) |
174 | - $this->_columns[$i] = array("x" => 0, |
|
175 | - "min-width" => 0, |
|
176 | - "max-width" => 0, |
|
177 | - "used-width" => null, |
|
178 | - "absolute" => 0, |
|
179 | - "percent" => 0, |
|
180 | - "auto" => true); |
|
173 | + $this->_columns[$i] = array("x" => 0, |
|
174 | + "min-width" => 0, |
|
175 | + "max-width" => 0, |
|
176 | + "used-width" => null, |
|
177 | + "absolute" => 0, |
|
178 | + "percent" => 0, |
|
179 | + "auto" => true); |
|
181 | 180 | |
182 | 181 | return $this->_columns[$i]; |
183 | - } |
|
182 | + } |
|
184 | 183 | |
185 | - function &get_rows() { |
|
184 | + function &get_rows() { |
|
186 | 185 | return $this->_rows; |
187 | - } |
|
186 | + } |
|
188 | 187 | |
189 | - function &get_row($j) { |
|
188 | + function &get_row($j) { |
|
190 | 189 | if ( !isset($this->_rows[$j]) ) |
191 | - $this->_rows[$j] = array("y" => 0, |
|
192 | - "first-column" => 0, |
|
193 | - "height" => null); |
|
190 | + $this->_rows[$j] = array("y" => 0, |
|
191 | + "first-column" => 0, |
|
192 | + "height" => null); |
|
194 | 193 | return $this->_rows[$j]; |
195 | - } |
|
194 | + } |
|
196 | 195 | |
197 | - function get_border($i, $j, $h_v, $prop = null) { |
|
196 | + function get_border($i, $j, $h_v, $prop = null) { |
|
198 | 197 | if ( !isset($this->_borders[$i][$j][$h_v]) ) |
199 | - $this->_borders[$i][$j][$h_v] = array("width" => 0, |
|
200 | - "style" => "solid", |
|
201 | - "color" => "black"); |
|
198 | + $this->_borders[$i][$j][$h_v] = array("width" => 0, |
|
199 | + "style" => "solid", |
|
200 | + "color" => "black"); |
|
202 | 201 | if ( isset($prop) ) |
203 | - return $this->_borders[$i][$j][$h_v][$prop]; |
|
202 | + return $this->_borders[$i][$j][$h_v][$prop]; |
|
204 | 203 | |
205 | 204 | return $this->_borders[$i][$j][$h_v]; |
206 | - } |
|
205 | + } |
|
207 | 206 | |
208 | - function get_border_properties($i, $j) { |
|
207 | + function get_border_properties($i, $j) { |
|
209 | 208 | |
210 | 209 | $left = $this->get_border($i, $j, "vertical"); |
211 | 210 | $right = $this->get_border($i, $j+1, "vertical"); |
@@ -213,119 +212,119 @@ discard block |
||
213 | 212 | $bottom = $this->get_border($i+1, $j, "horizontal"); |
214 | 213 | |
215 | 214 | return compact("top", "bottom", "left", "right"); |
216 | - } |
|
215 | + } |
|
217 | 216 | |
218 | - //........................................................................ |
|
217 | + //........................................................................ |
|
219 | 218 | |
220 | - function get_spanned_cells($frame) { |
|
219 | + function get_spanned_cells($frame) { |
|
221 | 220 | $key = $frame->get_id(); |
222 | 221 | |
223 | 222 | if ( !isset($this->_frames[$key]) ) { |
224 | - throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
223 | + throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
225 | 224 | } |
226 | 225 | |
227 | 226 | return $this->_frames[$key]; |
228 | 227 | |
229 | - } |
|
228 | + } |
|
230 | 229 | |
231 | - function frame_exists_in_cellmap($frame) { |
|
230 | + function frame_exists_in_cellmap($frame) { |
|
232 | 231 | $key = $frame->get_id(); |
233 | 232 | return isset($this->_frames[$key]); |
234 | - } |
|
233 | + } |
|
235 | 234 | |
236 | - function get_frame_position($frame) { |
|
235 | + function get_frame_position($frame) { |
|
237 | 236 | global $_dompdf_warnings; |
238 | 237 | |
239 | 238 | $key = $frame->get_id(); |
240 | 239 | |
241 | 240 | if ( !isset($this->_frames[$key]) ) { |
242 | - throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
241 | + throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
243 | 242 | } |
244 | 243 | |
245 | 244 | $col = $this->_frames[$key]["columns"][0]; |
246 | 245 | $row = $this->_frames[$key]["rows"][0]; |
247 | 246 | |
248 | 247 | if ( !isset($this->_columns[$col])) { |
249 | - $_dompdf_warnings[] = "Frame not found in columns array. Check your table layout for missing or extra TDs."; |
|
250 | - $x = 0; |
|
248 | + $_dompdf_warnings[] = "Frame not found in columns array. Check your table layout for missing or extra TDs."; |
|
249 | + $x = 0; |
|
251 | 250 | } else |
252 | - $x = $this->_columns[$col]["x"]; |
|
251 | + $x = $this->_columns[$col]["x"]; |
|
253 | 252 | |
254 | 253 | if ( !isset($this->_rows[$row])) { |
255 | - $_dompdf_warnings[] = "Frame not found in row array. Check your table layout for missing or extra TDs."; |
|
256 | - $y = 0; |
|
254 | + $_dompdf_warnings[] = "Frame not found in row array. Check your table layout for missing or extra TDs."; |
|
255 | + $y = 0; |
|
257 | 256 | } else |
258 | - $y = $this->_rows[$row]["y"]; |
|
257 | + $y = $this->_rows[$row]["y"]; |
|
259 | 258 | |
260 | 259 | return array($x, $y, "x" => $x, "y" => $y); |
261 | - } |
|
260 | + } |
|
262 | 261 | |
263 | - function get_frame_width($frame) { |
|
262 | + function get_frame_width($frame) { |
|
264 | 263 | $key = $frame->get_id(); |
265 | 264 | |
266 | 265 | if ( !isset($this->_frames[$key]) ) { |
267 | - throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
266 | + throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
268 | 267 | } |
269 | 268 | |
270 | 269 | $cols = $this->_frames[$key]["columns"]; |
271 | 270 | $w = 0; |
272 | 271 | foreach ($cols as $i) |
273 | - $w += $this->_columns[$i]["used-width"]; |
|
272 | + $w += $this->_columns[$i]["used-width"]; |
|
274 | 273 | |
275 | 274 | return $w; |
276 | 275 | |
277 | - } |
|
276 | + } |
|
278 | 277 | |
279 | - function get_frame_height($frame) { |
|
278 | + function get_frame_height($frame) { |
|
280 | 279 | $key = $frame->get_id(); |
281 | 280 | |
282 | 281 | if ( !isset($this->_frames[$key]) ) |
283 | - throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
282 | + throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
284 | 283 | |
285 | 284 | $rows = $this->_frames[$key]["rows"]; |
286 | 285 | $h = 0; |
287 | 286 | foreach ($rows as $i) { |
288 | - if ( !isset($this->_rows[$i]) ) { |
|
287 | + if ( !isset($this->_rows[$i]) ) { |
|
289 | 288 | throw new Exception("foo"); |
290 | - } |
|
291 | - $h += $this->_rows[$i]["height"]; |
|
289 | + } |
|
290 | + $h += $this->_rows[$i]["height"]; |
|
292 | 291 | } |
293 | 292 | return $h; |
294 | 293 | |
295 | - } |
|
294 | + } |
|
296 | 295 | |
297 | 296 | |
298 | - //........................................................................ |
|
297 | + //........................................................................ |
|
299 | 298 | |
300 | - function set_column_width($j, $width) { |
|
299 | + function set_column_width($j, $width) { |
|
301 | 300 | $col =& $this->get_column($j); |
302 | 301 | $col["used-width"] = $width; |
303 | 302 | $next_col =& $this->get_column($j+1); |
304 | 303 | $next_col["x"] = $next_col["x"] + $width; |
305 | - } |
|
304 | + } |
|
306 | 305 | |
307 | - function set_row_height($i, $height) { |
|
306 | + function set_row_height($i, $height) { |
|
308 | 307 | $row =& $this->get_row($i); |
309 | 308 | if ( $height <= $row["height"] ) |
310 | - return; |
|
309 | + return; |
|
311 | 310 | |
312 | 311 | $row["height"] = $height; |
313 | 312 | $next_row =& $this->get_row($i+1); |
314 | 313 | $next_row["y"] = $row["y"] + $height; |
315 | 314 | |
316 | - } |
|
315 | + } |
|
317 | 316 | |
318 | - //........................................................................ |
|
317 | + //........................................................................ |
|
319 | 318 | |
320 | 319 | |
321 | - protected function _resolve_border($i, $j, $h_v, $border_spec) { |
|
320 | + protected function _resolve_border($i, $j, $h_v, $border_spec) { |
|
322 | 321 | $n_width = $border_spec["width"]; |
323 | 322 | $n_style = $border_spec["style"]; |
324 | 323 | $n_color = $border_spec["color"]; |
325 | 324 | |
326 | 325 | if ( !isset($this->_borders[$i][$j][$h_v]) ) { |
327 | - $this->_borders[$i][$j][$h_v] = $border_spec; |
|
328 | - return $this->_borders[$i][$j][$h_v]["width"]; |
|
326 | + $this->_borders[$i][$j][$h_v] = $border_spec; |
|
327 | + return $this->_borders[$i][$j][$h_v]["width"]; |
|
329 | 328 | } |
330 | 329 | |
331 | 330 | $o_width = $this->_borders[$i][$j][$h_v]["width"]; |
@@ -341,14 +340,14 @@ discard block |
||
341 | 340 | ($o_width == $n_width && |
342 | 341 | in_array($n_style, self::$_BORDER_STYLE_SCORE) && |
343 | 342 | self::$_BORDER_STYLE_SCORE[ $n_style ] > self::$_BORDER_STYLE_SCORE[ $o_style ]) ) |
344 | - $this->_borders[$i][$j][$h_v] = $border_spec; |
|
343 | + $this->_borders[$i][$j][$h_v] = $border_spec; |
|
345 | 344 | |
346 | 345 | return $this->_borders[$i][$j][$h_v]["width"]; |
347 | - } |
|
346 | + } |
|
348 | 347 | |
349 | - //........................................................................ |
|
348 | + //........................................................................ |
|
350 | 349 | |
351 | - function add_frame(Frame $frame) { |
|
350 | + function add_frame(Frame $frame) { |
|
352 | 351 | |
353 | 352 | $style = $frame->get_style(); |
354 | 353 | $display = $style->display; |
@@ -361,39 +360,39 @@ discard block |
||
361 | 360 | $display == "inline-table" || |
362 | 361 | in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) { |
363 | 362 | |
364 | - $start_row = $this->__row; |
|
365 | - foreach ( $frame->get_children() as $child ) |
|
363 | + $start_row = $this->__row; |
|
364 | + foreach ( $frame->get_children() as $child ) |
|
366 | 365 | $this->add_frame( $child ); |
367 | 366 | |
368 | - if ( $display == "table-row" ) |
|
367 | + if ( $display == "table-row" ) |
|
369 | 368 | $this->add_row(); |
370 | 369 | |
371 | - $num_rows = $this->__row - $start_row - 1; |
|
372 | - $key = $frame->get_id(); |
|
370 | + $num_rows = $this->__row - $start_row - 1; |
|
371 | + $key = $frame->get_id(); |
|
373 | 372 | |
374 | - // Row groups always span across the entire table |
|
375 | - $this->_frames[ $key ]["columns"] = range(0,max(0,$this->_num_cols-1)); |
|
376 | - $this->_frames[ $key ]["rows"] = range($start_row, max(0, $this->__row - 1)); |
|
377 | - $this->_frames[ $key ]["frame"] = $frame; |
|
373 | + // Row groups always span across the entire table |
|
374 | + $this->_frames[ $key ]["columns"] = range(0,max(0,$this->_num_cols-1)); |
|
375 | + $this->_frames[ $key ]["rows"] = range($start_row, max(0, $this->__row - 1)); |
|
376 | + $this->_frames[ $key ]["frame"] = $frame; |
|
378 | 377 | |
379 | - if ( $display != "table-row" && $collapse ) { |
|
378 | + if ( $display != "table-row" && $collapse ) { |
|
380 | 379 | |
381 | 380 | $bp = $style->get_border_properties(); |
382 | 381 | |
383 | 382 | // Resolve the borders |
384 | 383 | for ( $i = 0; $i < $num_rows+1; $i++) { |
385 | - $this->_resolve_border($start_row + $i, 0, "vertical", $bp["left"]); |
|
386 | - $this->_resolve_border($start_row + $i, $this->_num_cols, "vertical", $bp["right"]); |
|
384 | + $this->_resolve_border($start_row + $i, 0, "vertical", $bp["left"]); |
|
385 | + $this->_resolve_border($start_row + $i, $this->_num_cols, "vertical", $bp["right"]); |
|
387 | 386 | } |
388 | 387 | |
389 | 388 | for ( $j = 0; $j < $this->_num_cols; $j++) { |
390 | - $this->_resolve_border($start_row, $j, "horizontal", $bp["top"]); |
|
391 | - $this->_resolve_border($this->__row, $j, "horizontal", $bp["bottom"]); |
|
389 | + $this->_resolve_border($start_row, $j, "horizontal", $bp["top"]); |
|
390 | + $this->_resolve_border($this->__row, $j, "horizontal", $bp["bottom"]); |
|
391 | + } |
|
392 | 392 | } |
393 | - } |
|
394 | 393 | |
395 | 394 | |
396 | - return; |
|
395 | + return; |
|
397 | 396 | } |
398 | 397 | |
399 | 398 | // Determine where this cell is going |
@@ -401,13 +400,13 @@ discard block |
||
401 | 400 | $rowspan = $frame->get_node()->getAttribute("rowspan"); |
402 | 401 | |
403 | 402 | if ( !$colspan ) { |
404 | - $colspan = 1; |
|
405 | - $frame->get_node()->setAttribute("colspan",1); |
|
403 | + $colspan = 1; |
|
404 | + $frame->get_node()->setAttribute("colspan",1); |
|
406 | 405 | } |
407 | 406 | |
408 | 407 | if ( !$rowspan ) { |
409 | - $rowspan = 1; |
|
410 | - $frame->get_node()->setAttribute("rowspan",1); |
|
408 | + $rowspan = 1; |
|
409 | + $frame->get_node()->setAttribute("rowspan",1); |
|
411 | 410 | } |
412 | 411 | $key = $frame->get_id(); |
413 | 412 | |
@@ -420,60 +419,60 @@ discard block |
||
420 | 419 | // Find the next available column (fix by Ciro Mondueri) |
421 | 420 | $ac = $this->__col; |
422 | 421 | while ( isset($this->_cells[$this->__row][$ac]) ) |
423 | - $ac++; |
|
422 | + $ac++; |
|
424 | 423 | $this->__col = $ac; |
425 | 424 | |
426 | 425 | // Rows: |
427 | 426 | for ( $i = 0; $i < $rowspan; $i++ ) { |
428 | - $row = $this->__row + $i; |
|
427 | + $row = $this->__row + $i; |
|
429 | 428 | |
430 | - $this->_frames[ $key ]["rows"][] = $row; |
|
429 | + $this->_frames[ $key ]["rows"][] = $row; |
|
431 | 430 | |
432 | - for ( $j = 0; $j < $colspan; $j++) |
|
431 | + for ( $j = 0; $j < $colspan; $j++) |
|
433 | 432 | $this->_cells[$row][$this->__col + $j] = $frame; |
434 | 433 | |
435 | - if ( $collapse ) { |
|
434 | + if ( $collapse ) { |
|
436 | 435 | // Resolve vertical borders |
437 | 436 | $max_left = max($max_left, $this->_resolve_border($row, $this->__col, "vertical", $bp["left"])); |
438 | 437 | $max_right = max($max_right, $this->_resolve_border($row, $this->__col + $colspan, "vertical", $bp["right"])); |
439 | - } |
|
438 | + } |
|
440 | 439 | } |
441 | 440 | |
442 | 441 | $max_top = $max_bottom = 0; |
443 | 442 | |
444 | 443 | // Columns: |
445 | 444 | for ( $j = 0; $j < $colspan; $j++ ) { |
446 | - $col = $this->__col + $j; |
|
447 | - $this->_frames[ $key ]["columns"][] = $col; |
|
445 | + $col = $this->__col + $j; |
|
446 | + $this->_frames[ $key ]["columns"][] = $col; |
|
448 | 447 | |
449 | - if ( $collapse ) { |
|
448 | + if ( $collapse ) { |
|
450 | 449 | // Resolve horizontal borders |
451 | 450 | $max_top = max($max_top, $this->_resolve_border($this->__row, $col, "horizontal", $bp["top"])); |
452 | 451 | $max_bottom = max($max_bottom, $this->_resolve_border($this->__row + $rowspan, $col, "horizontal", $bp["bottom"])); |
453 | - } |
|
452 | + } |
|
454 | 453 | } |
455 | 454 | |
456 | 455 | $this->_frames[ $key ]["frame"] = $frame; |
457 | 456 | |
458 | 457 | // Handle seperated border model |
459 | 458 | if ( !$collapse ) { |
460 | - list($h, $v) = $this->_table->get_style()->border_spacing; |
|
459 | + list($h, $v) = $this->_table->get_style()->border_spacing; |
|
461 | 460 | |
462 | - // Border spacing is effectively a margin between cells |
|
463 | - $v = $style->length_in_pt($v) / 2; |
|
464 | - $h = $style->length_in_pt($h) / 2; |
|
465 | - $style->margin = "$v $h"; |
|
461 | + // Border spacing is effectively a margin between cells |
|
462 | + $v = $style->length_in_pt($v) / 2; |
|
463 | + $h = $style->length_in_pt($h) / 2; |
|
464 | + $style->margin = "$v $h"; |
|
466 | 465 | |
467 | - // The additional 1/2 width gets added to the table proper |
|
466 | + // The additional 1/2 width gets added to the table proper |
|
468 | 467 | |
469 | 468 | } else { |
470 | 469 | |
471 | - // Drop the frame's actual border |
|
472 | - $style->border_left_width = $max_left / 2; |
|
473 | - $style->border_right_width = $max_right / 2; |
|
474 | - $style->border_top_width = $max_top / 2; |
|
475 | - $style->border_bottom_width = $max_bottom / 2; |
|
476 | - $style->margin = "none"; |
|
470 | + // Drop the frame's actual border |
|
471 | + $style->border_left_width = $max_left / 2; |
|
472 | + $style->border_right_width = $max_right / 2; |
|
473 | + $style->border_top_width = $max_top / 2; |
|
474 | + $style->border_bottom_width = $max_bottom / 2; |
|
475 | + $style->margin = "none"; |
|
477 | 476 | } |
478 | 477 | |
479 | 478 | // Resolve the frame's width |
@@ -482,60 +481,60 @@ discard block |
||
482 | 481 | $width = $style->width; |
483 | 482 | |
484 | 483 | if ( is_percent($width) ) { |
485 | - $var = "percent"; |
|
486 | - $val = (float)rtrim($width, "% ") / $colspan; |
|
484 | + $var = "percent"; |
|
485 | + $val = (float)rtrim($width, "% ") / $colspan; |
|
487 | 486 | |
488 | 487 | } else if ( $width !== "auto" ) { |
489 | - $var = "absolute"; |
|
490 | - $val = $style->length_in_pt($frame_min) / $colspan; |
|
488 | + $var = "absolute"; |
|
489 | + $val = $style->length_in_pt($frame_min) / $colspan; |
|
491 | 490 | } |
492 | 491 | |
493 | 492 | $min = 0; |
494 | 493 | $max = 0; |
495 | 494 | for ( $cs = 0; $cs < $colspan; $cs++ ) { |
496 | 495 | |
497 | - // Resolve the frame's width(s) with other cells |
|
498 | - $col =& $this->get_column( $this->__col + $cs ); |
|
496 | + // Resolve the frame's width(s) with other cells |
|
497 | + $col =& $this->get_column( $this->__col + $cs ); |
|
499 | 498 | |
500 | - // Note: $var is either 'percent' or 'absolute'. We compare the |
|
501 | - // requested percentage or absolute values with the existing widths |
|
502 | - // and adjust accordingly. |
|
503 | - if ( isset($var) && $val > $col[$var] ) { |
|
499 | + // Note: $var is either 'percent' or 'absolute'. We compare the |
|
500 | + // requested percentage or absolute values with the existing widths |
|
501 | + // and adjust accordingly. |
|
502 | + if ( isset($var) && $val > $col[$var] ) { |
|
504 | 503 | $col[$var] = $val; |
505 | 504 | $col["auto"] = false; |
506 | - } |
|
505 | + } |
|
507 | 506 | |
508 | - $min += $col["min-width"]; |
|
509 | - $max += $col["max-width"]; |
|
507 | + $min += $col["min-width"]; |
|
508 | + $max += $col["max-width"]; |
|
510 | 509 | } |
511 | 510 | |
512 | 511 | |
513 | 512 | if ( $frame_min > $min ) { |
514 | - // The frame needs more space. Expand each sub-column |
|
515 | - $inc = ($frame_min - $min) / $colspan; |
|
516 | - for ($c = 0; $c < $colspan; $c++) { |
|
513 | + // The frame needs more space. Expand each sub-column |
|
514 | + $inc = ($frame_min - $min) / $colspan; |
|
515 | + for ($c = 0; $c < $colspan; $c++) { |
|
517 | 516 | $col =& $this->get_column($this->__col + $c); |
518 | 517 | $col["min-width"] += $inc; |
519 | - } |
|
518 | + } |
|
520 | 519 | } |
521 | 520 | |
522 | 521 | if ( $frame_max > $max ) { |
523 | - $inc = ($frame_max - $max) / $colspan; |
|
524 | - for ($c = 0; $c < $colspan; $c++) { |
|
522 | + $inc = ($frame_max - $max) / $colspan; |
|
523 | + for ($c = 0; $c < $colspan; $c++) { |
|
525 | 524 | $col =& $this->get_column($this->__col + $c); |
526 | 525 | $col["max-width"] += $inc; |
527 | - } |
|
526 | + } |
|
528 | 527 | } |
529 | 528 | |
530 | 529 | $this->__col += $colspan; |
531 | 530 | if ( $this->__col > $this->_num_cols ) |
532 | - $this->_num_cols = $this->__col; |
|
531 | + $this->_num_cols = $this->__col; |
|
533 | 532 | |
534 | - } |
|
533 | + } |
|
535 | 534 | |
536 | - //........................................................................ |
|
535 | + //........................................................................ |
|
537 | 536 | |
538 | - function add_row() { |
|
537 | + function add_row() { |
|
539 | 538 | |
540 | 539 | $this->__row++; |
541 | 540 | $this->_num_rows++; |
@@ -543,24 +542,24 @@ discard block |
||
543 | 542 | // Find the next available column |
544 | 543 | $i = 0; |
545 | 544 | while ( isset($this->_cells[$this->__row][$i]) ) |
546 | - $i++; |
|
545 | + $i++; |
|
547 | 546 | |
548 | 547 | $this->__col = $i; |
549 | 548 | |
550 | - } |
|
549 | + } |
|
551 | 550 | |
552 | - //........................................................................ |
|
551 | + //........................................................................ |
|
553 | 552 | |
554 | - /** |
|
555 | - * Remove a row from the cellmap. |
|
556 | - * |
|
557 | - * @param Frame |
|
558 | - */ |
|
559 | - function remove_row(Frame $row) { |
|
553 | + /** |
|
554 | + * Remove a row from the cellmap. |
|
555 | + * |
|
556 | + * @param Frame |
|
557 | + */ |
|
558 | + function remove_row(Frame $row) { |
|
560 | 559 | |
561 | 560 | $key = $row->get_id(); |
562 | 561 | if ( !isset($this->_frames[$key]) ) |
563 | - return; // Presumably this row has alredy been removed |
|
562 | + return; // Presumably this row has alredy been removed |
|
564 | 563 | |
565 | 564 | $this->_row = $this->_num_rows--; |
566 | 565 | |
@@ -569,47 +568,47 @@ discard block |
||
569 | 568 | |
570 | 569 | // Remove all frames from this row |
571 | 570 | foreach ( $rows as $r ) { |
572 | - foreach ( $columns as $c ) { |
|
571 | + foreach ( $columns as $c ) { |
|
573 | 572 | if ( isset($this->_cells[$r][$c]) ) { |
574 | - $frame = $this->_cells[$r][$c]; |
|
575 | - unset($this->_frames[ $frame->get_id() ]); |
|
576 | - unset($this->_cells[$r][$c]); |
|
573 | + $frame = $this->_cells[$r][$c]; |
|
574 | + unset($this->_frames[ $frame->get_id() ]); |
|
575 | + unset($this->_cells[$r][$c]); |
|
576 | + } |
|
577 | 577 | } |
578 | - } |
|
579 | - unset($this->_rows[$r]); |
|
578 | + unset($this->_rows[$r]); |
|
580 | 579 | } |
581 | 580 | |
582 | 581 | unset($this->_frames[$key]); |
583 | 582 | |
584 | - } |
|
583 | + } |
|
585 | 584 | |
586 | - /** |
|
587 | - * Remove a row group from the cellmap. |
|
588 | - * |
|
589 | - * @param Frame $group The group to remove |
|
590 | - */ |
|
591 | - function remove_row_group(Frame $group) { |
|
585 | + /** |
|
586 | + * Remove a row group from the cellmap. |
|
587 | + * |
|
588 | + * @param Frame $group The group to remove |
|
589 | + */ |
|
590 | + function remove_row_group(Frame $group) { |
|
592 | 591 | |
593 | 592 | $key = $group->get_id(); |
594 | 593 | if ( !isset($this->_frames[$key]) ) |
595 | - return; // Presumably this row has alredy been removed |
|
594 | + return; // Presumably this row has alredy been removed |
|
596 | 595 | |
597 | 596 | $iter = $group->get_first_child(); |
598 | 597 | while ($iter) { |
599 | - $this->remove_row($iter); |
|
600 | - $iter = $iter->get_next_sibling(); |
|
598 | + $this->remove_row($iter); |
|
599 | + $iter = $iter->get_next_sibling(); |
|
601 | 600 | } |
602 | 601 | |
603 | 602 | unset($this->_frames[$key]); |
604 | - } |
|
603 | + } |
|
605 | 604 | |
606 | - /** |
|
607 | - * Update a row group after rows have been removed |
|
608 | - * |
|
609 | - * @param Frame $group The group to update |
|
610 | - * @param Frame $last_row The last row in the row group |
|
611 | - */ |
|
612 | - function update_row_group(Frame $group, Frame $last_row) { |
|
605 | + /** |
|
606 | + * Update a row group after rows have been removed |
|
607 | + * |
|
608 | + * @param Frame $group The group to update |
|
609 | + * @param Frame $last_row The last row in the row group |
|
610 | + */ |
|
611 | + function update_row_group(Frame $group, Frame $last_row) { |
|
613 | 612 | |
614 | 613 | $g_key = $group->get_id(); |
615 | 614 | $r_key = $last_row->get_id(); |
@@ -617,80 +616,80 @@ discard block |
||
617 | 616 | $r_rows = $this->_frames[$r_key]["rows"]; |
618 | 617 | $this->_frames[$g_key]["rows"] = range( $this->_frames[$g_key]["rows"][0], end($r_rows) ); |
619 | 618 | |
620 | - } |
|
619 | + } |
|
621 | 620 | |
622 | - //........................................................................ |
|
621 | + //........................................................................ |
|
623 | 622 | |
624 | - function assign_x_positions() { |
|
623 | + function assign_x_positions() { |
|
625 | 624 | // Pre-condition: widths must be resolved and assigned to columns and |
626 | 625 | // column[0]["x"] must be set. |
627 | 626 | |
628 | 627 | $x = $this->_columns[0]["x"]; |
629 | 628 | foreach ( array_keys($this->_columns) as $j ) { |
630 | - $this->_columns[$j]["x"] = $x; |
|
631 | - $x += $this->_columns[$j]["used-width"]; |
|
629 | + $this->_columns[$j]["x"] = $x; |
|
630 | + $x += $this->_columns[$j]["used-width"]; |
|
632 | 631 | |
633 | 632 | } |
634 | 633 | |
635 | - } |
|
634 | + } |
|
636 | 635 | |
637 | - function assign_frame_heights() { |
|
636 | + function assign_frame_heights() { |
|
638 | 637 | // Pre-condition: widths and heights of each column & row must be |
639 | 638 | // calcluated |
640 | 639 | |
641 | 640 | foreach ( $this->_frames as $arr ) { |
642 | - $frame = $arr["frame"]; |
|
641 | + $frame = $arr["frame"]; |
|
643 | 642 | |
644 | - $h = 0; |
|
645 | - foreach( $arr["rows"] as $row ) { |
|
643 | + $h = 0; |
|
644 | + foreach( $arr["rows"] as $row ) { |
|
646 | 645 | if ( !isset($this->_rows[$row]) ) |
647 | - // The row has been removed because of a page split, so skip it. |
|
648 | - continue; |
|
646 | + // The row has been removed because of a page split, so skip it. |
|
647 | + continue; |
|
649 | 648 | $h += $this->_rows[$row]["height"]; |
650 | - } |
|
649 | + } |
|
651 | 650 | |
652 | - if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
651 | + if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
653 | 652 | $frame->set_cell_height($h); |
654 | - else |
|
653 | + else |
|
655 | 654 | $frame->get_style()->height = $h; |
656 | 655 | } |
657 | 656 | |
658 | - } |
|
657 | + } |
|
659 | 658 | |
660 | - //........................................................................ |
|
659 | + //........................................................................ |
|
661 | 660 | |
662 | - /** |
|
663 | - * Re-adjust frame height if the table height is larger than its content |
|
664 | - */ |
|
665 | - function set_frame_heights($table_height, $content_height) { |
|
661 | + /** |
|
662 | + * Re-adjust frame height if the table height is larger than its content |
|
663 | + */ |
|
664 | + function set_frame_heights($table_height, $content_height) { |
|
666 | 665 | |
667 | 666 | |
668 | 667 | // Distribute the increased height proportionally amongst each row |
669 | 668 | foreach ( $this->_frames as $arr ) { |
670 | - $frame = $arr["frame"]; |
|
669 | + $frame = $arr["frame"]; |
|
671 | 670 | |
672 | - $h = 0; |
|
673 | - foreach ($arr["rows"] as $row ) { |
|
671 | + $h = 0; |
|
672 | + foreach ($arr["rows"] as $row ) { |
|
674 | 673 | if ( !isset($this->_rows[$row]) ) |
675 | - continue; |
|
674 | + continue; |
|
676 | 675 | |
677 | 676 | $h += $this->_rows[$row]["height"]; |
678 | - } |
|
677 | + } |
|
679 | 678 | |
680 | - $new_height = ($h / $content_height) * $table_height; |
|
679 | + $new_height = ($h / $content_height) * $table_height; |
|
681 | 680 | |
682 | - if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
681 | + if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
683 | 682 | $frame->set_cell_height($new_height); |
684 | - else |
|
683 | + else |
|
685 | 684 | $frame->get_style()->height = $new_height; |
686 | 685 | } |
687 | 686 | |
688 | - } |
|
687 | + } |
|
689 | 688 | |
690 | - //........................................................................ |
|
689 | + //........................................................................ |
|
691 | 690 | |
692 | - // Used for debugging: |
|
693 | - function __toString() { |
|
691 | + // Used for debugging: |
|
692 | + function __toString() { |
|
694 | 693 | $str = ""; |
695 | 694 | $str .= "Columns:<br/>"; |
696 | 695 | $str .= pre_r($this->_columns, true); |
@@ -700,14 +699,14 @@ discard block |
||
700 | 699 | $str .= "Frames:<br/>"; |
701 | 700 | $arr = array(); |
702 | 701 | foreach ( $this->_frames as $key => $val ) |
703 | - $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]); |
|
702 | + $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]); |
|
704 | 703 | |
705 | 704 | $str .= pre_r($arr, true); |
706 | 705 | |
707 | 706 | if ( php_sapi_name() == "cli" ) |
708 | - $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
707 | + $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
709 | 708 | array("\n",chr(27)."[01;33m", chr(27)."[0m"), |
710 | 709 | $str)); |
711 | 710 | return $str; |
712 | - } |
|
711 | + } |
|
713 | 712 | } |
@@ -1,41 +1,40 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: table_row_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: table_row_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: table_row_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
41 | 40 | |
@@ -48,17 +47,17 @@ discard block |
||
48 | 47 | class Table_Row_Frame_Reflower extends Frame_Reflower { |
49 | 48 | |
50 | 49 | |
51 | - function __construct(Table_Row_Frame_Decorator $frame) { |
|
50 | + function __construct(Table_Row_Frame_Decorator $frame) { |
|
52 | 51 | parent::__construct($frame); |
53 | - } |
|
52 | + } |
|
54 | 53 | |
55 | - //........................................................................ |
|
54 | + //........................................................................ |
|
56 | 55 | |
57 | - function reflow() { |
|
56 | + function reflow() { |
|
58 | 57 | $page = $this->_frame->get_root(); |
59 | 58 | |
60 | 59 | if ( $page->is_full() ) |
61 | - return; |
|
60 | + return; |
|
62 | 61 | |
63 | 62 | $this->_frame->position(); |
64 | 63 | $style = $this->_frame->get_style(); |
@@ -66,16 +65,16 @@ discard block |
||
66 | 65 | |
67 | 66 | foreach ($this->_frame->get_children() as $child) { |
68 | 67 | |
69 | - if ( $page->is_full() ) |
|
68 | + if ( $page->is_full() ) |
|
70 | 69 | return; |
71 | 70 | |
72 | - $child->set_containing_block($cb); |
|
73 | - $child->reflow(); |
|
71 | + $child->set_containing_block($cb); |
|
72 | + $child->reflow(); |
|
74 | 73 | |
75 | 74 | } |
76 | 75 | |
77 | 76 | if ( $page->is_full() ) |
78 | - return; |
|
77 | + return; |
|
79 | 78 | |
80 | 79 | $table = Table_Frame_Decorator::find_parent_table($this->_frame); |
81 | 80 | $cellmap = $table->get_cellmap(); |
@@ -84,11 +83,11 @@ discard block |
||
84 | 83 | |
85 | 84 | $this->_frame->set_position($cellmap->get_frame_position($this->_frame)); |
86 | 85 | |
87 | - } |
|
86 | + } |
|
88 | 87 | |
89 | - //........................................................................ |
|
88 | + //........................................................................ |
|
90 | 89 | |
91 | - function get_min_max_width() { |
|
90 | + function get_min_max_width() { |
|
92 | 91 | throw new DOMPDF_Exception("Min/max width is undefined for table rows"); |
93 | - } |
|
92 | + } |
|
94 | 93 | } |
@@ -1,47 +1,46 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: list_bullet_frame_decorator.cls.php,v $ |
|
6 | - * Created on: 2004-06-23 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @contributor Helmut Tischer <[email protected]> |
|
37 | - * @package dompdf |
|
38 | - |
|
39 | - * |
|
40 | - * Changes |
|
41 | - * @contributor Helmut Tischer <[email protected]> |
|
42 | - * @version 20090622 |
|
43 | - * - bullet size proportional to font size, center position |
|
44 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: list_bullet_frame_decorator.cls.php,v $ |
|
6 | + * Created on: 2004-06-23 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @contributor Helmut Tischer <[email protected]> |
|
37 | + * @package dompdf |
|
38 | + * |
|
39 | + * Changes |
|
40 | + * @contributor Helmut Tischer <[email protected]> |
|
41 | + * @version 20090622 |
|
42 | + * - bullet size proportional to font size, center position |
|
43 | + */ |
|
45 | 44 | |
46 | 45 | /* $Id: list_bullet_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
47 | 46 | |
@@ -53,42 +52,42 @@ discard block |
||
53 | 52 | */ |
54 | 53 | class List_Bullet_Frame_Decorator extends Frame_Decorator { |
55 | 54 | |
56 | - const BULLET_PADDING = 1; // Distance from bullet to text in pt |
|
57 | - // As fraction of font size (including descent). See also DECO_THICKNESS. |
|
58 | - const BULLET_THICKNESS = 0.04; // Thickness of bullet outline. Screen: 0.08, print: better less, e.g. 0.04 |
|
59 | - const BULLET_DESCENT = 0.3; //descent of font below baseline. Todo: Guessed for now. |
|
60 | - const BULLET_SIZE = 0.35; // bullet diameter. For now 0.5 of font_size without descent. |
|
55 | + const BULLET_PADDING = 1; // Distance from bullet to text in pt |
|
56 | + // As fraction of font size (including descent). See also DECO_THICKNESS. |
|
57 | + const BULLET_THICKNESS = 0.04; // Thickness of bullet outline. Screen: 0.08, print: better less, e.g. 0.04 |
|
58 | + const BULLET_DESCENT = 0.3; //descent of font below baseline. Todo: Guessed for now. |
|
59 | + const BULLET_SIZE = 0.35; // bullet diameter. For now 0.5 of font_size without descent. |
|
61 | 60 | |
62 | - static $BULLET_TYPES = array("disc", "circle", "square"); |
|
61 | + static $BULLET_TYPES = array("disc", "circle", "square"); |
|
63 | 62 | |
64 | - //........................................................................ |
|
63 | + //........................................................................ |
|
65 | 64 | |
66 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
65 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
67 | 66 | parent::__construct($frame, $dompdf); |
68 | - } |
|
67 | + } |
|
69 | 68 | |
70 | - function get_margin_width() { |
|
69 | + function get_margin_width() { |
|
71 | 70 | $style = $this->_frame->get_style(); |
72 | 71 | // Small hack to prevent extra indenting of list text on list_style_position === "inside" |
73 | 72 | // and on suppressed bullet |
74 | 73 | if ( $style->list_style_position === "outside" || |
75 | 74 | $style->list_style_type === "none" ) |
76 | - return 0; |
|
75 | + return 0; |
|
77 | 76 | return $style->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
78 | - } |
|
77 | + } |
|
79 | 78 | |
80 | - //hits only on "inset" lists items, to increase height of box |
|
81 | - function get_margin_height() { |
|
79 | + //hits only on "inset" lists items, to increase height of box |
|
80 | + function get_margin_height() { |
|
82 | 81 | return $this->_frame->get_style()->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
83 | - } |
|
82 | + } |
|
84 | 83 | |
85 | - function get_width() { |
|
84 | + function get_width() { |
|
86 | 85 | return $this->_frame->get_style()->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
87 | - } |
|
86 | + } |
|
88 | 87 | |
89 | - function get_height() { |
|
88 | + function get_height() { |
|
90 | 89 | return $this->_frame->get_style()->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
91 | - } |
|
90 | + } |
|
92 | 91 | |
93 | - //........................................................................ |
|
92 | + //........................................................................ |
|
94 | 93 | } |
@@ -1,41 +1,40 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: null_frame_reflower.cls.php,v $ |
|
6 | - * Created on: 2004-07-12 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @package dompdf |
|
37 | - |
|
38 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: null_frame_reflower.cls.php,v $ |
|
6 | + * Created on: 2004-07-12 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @package dompdf |
|
37 | + */ |
|
39 | 38 | |
40 | 39 | /* $Id: null_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
41 | 40 | |
@@ -47,8 +46,8 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Null_Frame_Reflower extends Frame_Reflower { |
49 | 48 | |
50 | - function __construct(Frame $frame) { parent::__construct($frame); } |
|
49 | + function __construct(Frame $frame) { parent::__construct($frame); } |
|
51 | 50 | |
52 | - function reflow() { return; } |
|
51 | + function reflow() { return; } |
|
53 | 52 | |
54 | 53 | } |