Passed
Push — 1.10.x ( 6bd950...f9cbcd )
by Yannick
619:37 queued 578:35
created
main/inc/lib/phpdocx/pdf/include/text_frame_decorator.cls.php 1 patch
Indentation   +49 added lines, -50 removed lines patch added patch discarded remove patch
@@ -34,7 +34,6 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/canvas.cls.php 1 patch
Indentation   +220 added lines, -221 removed lines patch added patch discarded remove patch
@@ -1,41 +1,40 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * DOMPDF - PHP5 HTML to PDF renderer
4
- *
5
- * File: $RCSfile: canvas.cls.php,v $
6
- * Created on: 2004-06-06
7
- *
8
- * Copyright (c) 2004 - Benj Carson <[email protected]>
9
- *
10
- * This library is free software; you can redistribute it and/or
11
- * modify it under the terms of the GNU Lesser General Public
12
- * License as published by the Free Software Foundation; either
13
- * version 2.1 of the License, or (at your option) any later version.
14
- *
15
- * This library is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
- * Lesser General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU Lesser General Public License
21
- * along with this library in the file LICENSE.LGPL; if not, write to the
22
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23
- * 02111-1307 USA
24
- *
25
- * Alternatively, you may distribute this software under the terms of the
26
- * PHP License, version 3.0 or later.  A copy of this license should have
27
- * been distributed with this file in the file LICENSE.PHP .  If this is not
28
- * the case, you can obtain a copy at http://www.php.net/license/3_0.txt.
29
- *
30
- * The latest version of DOMPDF might be available at:
31
- * http://www.dompdf.com/
32
- *
33
- * @link http://www.dompdf.com/
34
- * @copyright 2004 Benj Carson
35
- * @author Benj Carson <[email protected]>
36
- * @package dompdf
37
-
38
- */
3
+     * DOMPDF - PHP5 HTML to PDF renderer
4
+     *
5
+     * File: $RCSfile: canvas.cls.php,v $
6
+     * Created on: 2004-06-06
7
+     *
8
+     * Copyright (c) 2004 - Benj Carson <[email protected]>
9
+     *
10
+     * This library is free software; you can redistribute it and/or
11
+     * modify it under the terms of the GNU Lesser General Public
12
+     * License as published by the Free Software Foundation; either
13
+     * version 2.1 of the License, or (at your option) any later version.
14
+     *
15
+     * This library is distributed in the hope that it will be useful,
16
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
+     * Lesser General Public License for more details.
19
+     *
20
+     * You should have received a copy of the GNU Lesser General Public License
21
+     * along with this library in the file LICENSE.LGPL; if not, write to the
22
+     * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23
+     * 02111-1307 USA
24
+     *
25
+     * Alternatively, you may distribute this software under the terms of the
26
+     * PHP License, version 3.0 or later.  A copy of this license should have
27
+     * been distributed with this file in the file LICENSE.PHP .  If this is not
28
+     * the case, you can obtain a copy at http://www.php.net/license/3_0.txt.
29
+     *
30
+     * The latest version of DOMPDF might be available at:
31
+     * http://www.dompdf.com/
32
+     *
33
+     * @link http://www.dompdf.com/
34
+     * @copyright 2004 Benj Carson
35
+     * @author Benj Carson <[email protected]>
36
+     * @package dompdf
37
+     */
39 38
 
40 39
 /* $Id: canvas.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
41 40
 
@@ -54,207 +53,207 @@  discard block
 block discarded – undo
54 53
  */
55 54
 interface Canvas {
56 55
 
57
-  /**
58
-   * Returns the current page number
59
-   *
60
-   * @return int
61
-   */
62
-  function get_page_number();
56
+    /**
57
+     * Returns the current page number
58
+     *
59
+     * @return int
60
+     */
61
+    function get_page_number();
63 62
 
64
-  /**
65
-   * Returns the total number of pages
66
-   *
67
-   * @return int
68
-   */
69
-  function get_page_count();
63
+    /**
64
+     * Returns the total number of pages
65
+     *
66
+     * @return int
67
+     */
68
+    function get_page_count();
70 69
 
71
-  /**
72
-   * Sets the total number of pages
73
-   *
74
-   * @param int $count
75
-   */
76
-  function set_page_count($count);
70
+    /**
71
+     * Sets the total number of pages
72
+     *
73
+     * @param int $count
74
+     */
75
+    function set_page_count($count);
77 76
 
78
-  /**
79
-   * Draws a line from x1,y1 to x2,y2
80
-   *
81
-   * See {@link Style::munge_colour()} for the format of the colour array.
82
-   * See {@link Cpdf::setLineStyle()} for a description of the format of the
83
-   * $style parameter (aka dash).
84
-   *
85
-   * @param float $x1
86
-   * @param float $y1
87
-   * @param float $x2
88
-   * @param float $y2
89
-   * @param array $color
90
-   * @param float $width
91
-   * @param array $style
92
-   */
93
-  function line($x1, $y1, $x2, $y2, $color, $width, $style = null);
77
+    /**
78
+     * Draws a line from x1,y1 to x2,y2
79
+     *
80
+     * See {@link Style::munge_colour()} for the format of the colour array.
81
+     * See {@link Cpdf::setLineStyle()} for a description of the format of the
82
+     * $style parameter (aka dash).
83
+     *
84
+     * @param float $x1
85
+     * @param float $y1
86
+     * @param float $x2
87
+     * @param float $y2
88
+     * @param array $color
89
+     * @param float $width
90
+     * @param array $style
91
+     */
92
+    function line($x1, $y1, $x2, $y2, $color, $width, $style = null);
94 93
 
95
-  /**
96
-   * Draws a rectangle at x1,y1 with width w and height h
97
-   *
98
-   * See {@link Style::munge_colour()} for the format of the colour array.
99
-   * See {@link Cpdf::setLineStyle()} for a description of the $style
100
-   * parameter (aka dash)
101
-   *
102
-   * @param float $x1
103
-   * @param float $y1
104
-   * @param float $w
105
-   * @param float $h
106
-   * @param array $color
107
-   * @param float $width
108
-   * @param array $style
109
-   */   
110
-  function rectangle($x1, $y1, $w, $h, $color, $width, $style = null);
94
+    /**
95
+     * Draws a rectangle at x1,y1 with width w and height h
96
+     *
97
+     * See {@link Style::munge_colour()} for the format of the colour array.
98
+     * See {@link Cpdf::setLineStyle()} for a description of the $style
99
+     * parameter (aka dash)
100
+     *
101
+     * @param float $x1
102
+     * @param float $y1
103
+     * @param float $w
104
+     * @param float $h
105
+     * @param array $color
106
+     * @param float $width
107
+     * @param array $style
108
+     */   
109
+    function rectangle($x1, $y1, $w, $h, $color, $width, $style = null);
111 110
 
112
-  /**
113
-   * Draws a filled rectangle at x1,y1 with width w and height h
114
-   *
115
-   * See {@link Style::munge_colour()} for the format of the colour array.
116
-   *
117
-   * @param float $x1
118
-   * @param float $y1
119
-   * @param float $w
120
-   * @param float $h
121
-   * @param array $color
122
-   */   
123
-  function filled_rectangle($x1, $y1, $w, $h, $color);
111
+    /**
112
+     * Draws a filled rectangle at x1,y1 with width w and height h
113
+     *
114
+     * See {@link Style::munge_colour()} for the format of the colour array.
115
+     *
116
+     * @param float $x1
117
+     * @param float $y1
118
+     * @param float $w
119
+     * @param float $h
120
+     * @param array $color
121
+     */   
122
+    function filled_rectangle($x1, $y1, $w, $h, $color);
124 123
 
125
-  /**
126
-   * Draws a polygon
127
-   *
128
-   * The polygon is formed by joining all the points stored in the $points
129
-   * array.  $points has the following structure:
130
-   * <code>
131
-   * array(0 => x1,
132
-   *       1 => y1,
133
-   *       2 => x2,
134
-   *       3 => y2,
135
-   *       ...
136
-   *       );
137
-   * </code>
138
-   *
139
-   * See {@link Style::munge_colour()} for the format of the colour array.
140
-   * See {@link Cpdf::setLineStyle()} for a description of the $style
141
-   * parameter (aka dash)   
142
-   *
143
-   * @param array $points
144
-   * @param array $color
145
-   * @param float $width
146
-   * @param array $style
147
-   * @param bool  $fill  Fills the polygon if true
148
-   */
149
-  function polygon($points, $color, $width = null, $style = null, $fill = false);
124
+    /**
125
+     * Draws a polygon
126
+     *
127
+     * The polygon is formed by joining all the points stored in the $points
128
+     * array.  $points has the following structure:
129
+     * <code>
130
+     * array(0 => x1,
131
+     *       1 => y1,
132
+     *       2 => x2,
133
+     *       3 => y2,
134
+     *       ...
135
+     *       );
136
+     * </code>
137
+     *
138
+     * See {@link Style::munge_colour()} for the format of the colour array.
139
+     * See {@link Cpdf::setLineStyle()} for a description of the $style
140
+     * parameter (aka dash)   
141
+     *
142
+     * @param array $points
143
+     * @param array $color
144
+     * @param float $width
145
+     * @param array $style
146
+     * @param bool  $fill  Fills the polygon if true
147
+     */
148
+    function polygon($points, $color, $width = null, $style = null, $fill = false);
150 149
 
151
-  /**
152
-   * Draws a circle at $x,$y with radius $r
153
-   *
154
-   * See {@link Style::munge_colour()} for the format of the colour array.
155
-   * See {@link Cpdf::setLineStyle()} for a description of the $style
156
-   * parameter (aka dash)
157
-   *
158
-   * @param float $x
159
-   * @param float $y
160
-   * @param float $r
161
-   * @param array $color
162
-   * @param float $width
163
-   * @param array $style
164
-   * @param bool $fill Fills the circle if true   
165
-   */   
166
-  function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false);
150
+    /**
151
+     * Draws a circle at $x,$y with radius $r
152
+     *
153
+     * See {@link Style::munge_colour()} for the format of the colour array.
154
+     * See {@link Cpdf::setLineStyle()} for a description of the $style
155
+     * parameter (aka dash)
156
+     *
157
+     * @param float $x
158
+     * @param float $y
159
+     * @param float $r
160
+     * @param array $color
161
+     * @param float $width
162
+     * @param array $style
163
+     * @param bool $fill Fills the circle if true   
164
+     */   
165
+    function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false);
167 166
 
168
-  /**
169
-   * Add an image to the pdf.
170
-   *
171
-   * The image is placed at the specified x and y coordinates with the
172
-   * given width and height.
173
-   *
174
-   * @param string $img_url the path to the image
175
-   * @param string $img_type the type (e.g. extension) of the image
176
-   * @param float $x x position
177
-   * @param float $y y position
178
-   * @param int $w width (in pixels)
179
-   * @param int $h height (in pixels)
180
-   */
181
-  function image($img_url, $img_type, $x, $y, $w, $h);
167
+    /**
168
+     * Add an image to the pdf.
169
+     *
170
+     * The image is placed at the specified x and y coordinates with the
171
+     * given width and height.
172
+     *
173
+     * @param string $img_url the path to the image
174
+     * @param string $img_type the type (e.g. extension) of the image
175
+     * @param float $x x position
176
+     * @param float $y y position
177
+     * @param int $w width (in pixels)
178
+     * @param int $h height (in pixels)
179
+     */
180
+    function image($img_url, $img_type, $x, $y, $w, $h);
182 181
 
183
-  /**
184
-   * Writes text at the specified x and y coordinates
185
-   *
186
-   * See {@link Style::munge_colour()} for the format of the colour array.
187
-   *
188
-   * @param float $x
189
-   * @param float $y
190
-   * @param string $text the text to write
191
-   * @param string $font the font file to use
192
-   * @param float $size the font size, in points
193
-   * @param array $color
194
-   * @param float $adjust word spacing adjustment
195
-   */
196
-  function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0);
182
+    /**
183
+     * Writes text at the specified x and y coordinates
184
+     *
185
+     * See {@link Style::munge_colour()} for the format of the colour array.
186
+     *
187
+     * @param float $x
188
+     * @param float $y
189
+     * @param string $text the text to write
190
+     * @param string $font the font file to use
191
+     * @param float $size the font size, in points
192
+     * @param array $color
193
+     * @param float $adjust word spacing adjustment
194
+     */
195
+    function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0);
197 196
 
198
-  /**
199
-   * Add a named destination (similar to <a name="foo">...</a> in html)
200
-   *
201
-   * @param string $anchorname The name of the named destination
202
-   */
203
-  function add_named_dest($anchorname);
197
+    /**
198
+     * Add a named destination (similar to <a name="foo">...</a> in html)
199
+     *
200
+     * @param string $anchorname The name of the named destination
201
+     */
202
+    function add_named_dest($anchorname);
204 203
 
205
-  /**
206
-   * Add a link to the pdf
207
-   *
208
-   * @param string $url The url to link to
209
-   * @param float  $x   The x position of the link
210
-   * @param float  $y   The y position of the link
211
-   * @param float  $width   The width of the link
212
-   * @param float  $height   The height of the link
213
-   */
214
-  function add_link($url, $x, $y, $width, $height);
204
+    /**
205
+     * Add a link to the pdf
206
+     *
207
+     * @param string $url The url to link to
208
+     * @param float  $x   The x position of the link
209
+     * @param float  $y   The y position of the link
210
+     * @param float  $width   The width of the link
211
+     * @param float  $height   The height of the link
212
+     */
213
+    function add_link($url, $x, $y, $width, $height);
215 214
   
216
-  /**
217
-   * Calculates text size, in points
218
-   *
219
-   * @param string $text the text to be sized
220
-   * @param string $font the desired font
221
-   * @param float  $size the desired font size
222
-   * @param float  $spacing word spacing, if any
223
-   * @return float
224
-   */
225
-  function get_text_width($text, $font, $size, $spacing = 0);
215
+    /**
216
+     * Calculates text size, in points
217
+     *
218
+     * @param string $text the text to be sized
219
+     * @param string $font the desired font
220
+     * @param float  $size the desired font size
221
+     * @param float  $spacing word spacing, if any
222
+     * @return float
223
+     */
224
+    function get_text_width($text, $font, $size, $spacing = 0);
226 225
 
227
-  /**
228
-   * Calculates font height, in points
229
-   *
230
-   * @param string $font
231
-   * @param float $size
232
-   * @return float
233
-   */
234
-  function get_font_height($font, $size);
226
+    /**
227
+     * Calculates font height, in points
228
+     *
229
+     * @param string $font
230
+     * @param float $size
231
+     * @return float
232
+     */
233
+    function get_font_height($font, $size);
235 234
 
236 235
   
237
-  /**
238
-   * Starts a new page
239
-   *
240
-   * Subsequent drawing operations will appear on the new page.
241
-   */
242
-  function new_page();
236
+    /**
237
+     * Starts a new page
238
+     *
239
+     * Subsequent drawing operations will appear on the new page.
240
+     */
241
+    function new_page();
243 242
 
244
-  /**
245
-   * Streams the PDF directly to the browser
246
-   *
247
-   * @param string $filename the name of the PDF file
248
-   * @param array  $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0
249
-   */
250
-  function stream($filename, $options = null);
243
+    /**
244
+     * Streams the PDF directly to the browser
245
+     *
246
+     * @param string $filename the name of the PDF file
247
+     * @param array  $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0
248
+     */
249
+    function stream($filename, $options = null);
251 250
 
252
-  /**
253
-   * Returns the PDF as a string
254
-   *
255
-   * @param array  $options associative array: 'compress' => 1 or 0
256
-   * @return string
257
-   */
258
-  function output($options = null);
251
+    /**
252
+     * Returns the PDF as a string
253
+     *
254
+     * @param array  $options associative array: 'compress' => 1 or 0
255
+     * @return string
256
+     */
257
+    function output($options = null);
259 258
   
260 259
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/stylesheet.cls.php 1 patch
Indentation   +478 added lines, -478 removed lines patch added patch discarded remove patch
@@ -71,201 +71,201 @@  discard block
 block discarded – undo
71 71
 
72 72
 
73 73
 
74
-  /**
75
-   * the location of the default built-in CSS file.
76
-   *
77
-   */
78
-  const DEFAULT_STYLESHEET = __DEFAULT_STYLESHEET; // Hack: can't
79
-                                                   // concatenate stuff in
80
-                                                   // const declarations,
81
-                                                   // but I can do this?
82
-  // protected members
83
-
84
-  /**
85
-   *  array of currently defined styles
86
-   *  @var array
87
-   */
88
-  private $_styles;
89
-
90
-  /**
91
-   * base protocol of the document being parsed
92
-   *
93
-   * Used to handle relative urls.
94
-   *
95
-   * @var string
96
-   */
97
-  private $_protocol;
98
-
99
-  /**
100
-   * base hostname of the document being parsed
101
-   *
102
-   * Used to handle relative urls.
103
-   * @var string
104
-   */
105
-  private $_base_host;
106
-
107
-  /**
108
-   * base path of the document being parsed
109
-   *
110
-   * Used to handle relative urls.
111
-   * @var string
112
-   */
113
-  private $_base_path;
114
-
115
-
116
-  /**
117
-   * the style defined by @page rules
118
-   *
119
-   * @var Style
120
-   */
121
-  private $_page_style;
122
-
123
-
124
-  /**
125
-   * list of loaded files, used to prevent recursion
126
-   *
127
-   * @var array
128
-   */
129
-  private $_loaded_files;
130
-
131
-  /**
132
-   * accepted CSS media types
133
-   * List of types and parsing rules for future extensions:
134
-   * http://www.w3.org/TR/REC-html40/types.html
135
-   *   screen, tty, tv, projection, handheld, print, braille, aural, all
136
-   * The following are non standard extensions for undocumented specific environments.
137
-   *   static, visual, bitmap, paged
138
-   * Note, even though the generated pdf file is intended for print output,
139
-   * the desired content might be different (e.g. screen or projection view of html file).
140
-   * Therefore allow specification of content by dompdf setting DOMPDF_DEFAULT_MEDIA_TYPE.
141
-   * If given, replace media "print" by DOMPDF_DEFAULT_MEDIA_TYPE.
142
-   * (Previous version $ACCEPTED_MEDIA_TYPES = $ACCEPTED_GENERIC_MEDIA_TYPES + $ACCEPTED_DEFAULT_MEDIA_TYPE)
143
-   */
144
-  static $ACCEPTED_DEFAULT_MEDIA_TYPE = "print";
145
-  static $ACCEPTED_GENERIC_MEDIA_TYPES = array("all", "static", "visual", "bitmap", "paged");
146
-
147
-  /**
148
-   * The class constructor.
149
-   *
150
-   * The base protocol, host & path are initialized to those of
151
-   * the current script.
152
-   */
153
-  function __construct() {
74
+    /**
75
+     * the location of the default built-in CSS file.
76
+     *
77
+     */
78
+    const DEFAULT_STYLESHEET = __DEFAULT_STYLESHEET; // Hack: can't
79
+                                                    // concatenate stuff in
80
+                                                    // const declarations,
81
+                                                    // but I can do this?
82
+    // protected members
83
+
84
+    /**
85
+     *  array of currently defined styles
86
+     *  @var array
87
+     */
88
+    private $_styles;
89
+
90
+    /**
91
+     * base protocol of the document being parsed
92
+     *
93
+     * Used to handle relative urls.
94
+     *
95
+     * @var string
96
+     */
97
+    private $_protocol;
98
+
99
+    /**
100
+     * base hostname of the document being parsed
101
+     *
102
+     * Used to handle relative urls.
103
+     * @var string
104
+     */
105
+    private $_base_host;
106
+
107
+    /**
108
+     * base path of the document being parsed
109
+     *
110
+     * Used to handle relative urls.
111
+     * @var string
112
+     */
113
+    private $_base_path;
114
+
115
+
116
+    /**
117
+     * the style defined by @page rules
118
+     *
119
+     * @var Style
120
+     */
121
+    private $_page_style;
122
+
123
+
124
+    /**
125
+     * list of loaded files, used to prevent recursion
126
+     *
127
+     * @var array
128
+     */
129
+    private $_loaded_files;
130
+
131
+    /**
132
+     * accepted CSS media types
133
+     * List of types and parsing rules for future extensions:
134
+     * http://www.w3.org/TR/REC-html40/types.html
135
+     *   screen, tty, tv, projection, handheld, print, braille, aural, all
136
+     * The following are non standard extensions for undocumented specific environments.
137
+     *   static, visual, bitmap, paged
138
+     * Note, even though the generated pdf file is intended for print output,
139
+     * the desired content might be different (e.g. screen or projection view of html file).
140
+     * Therefore allow specification of content by dompdf setting DOMPDF_DEFAULT_MEDIA_TYPE.
141
+     * If given, replace media "print" by DOMPDF_DEFAULT_MEDIA_TYPE.
142
+     * (Previous version $ACCEPTED_MEDIA_TYPES = $ACCEPTED_GENERIC_MEDIA_TYPES + $ACCEPTED_DEFAULT_MEDIA_TYPE)
143
+     */
144
+    static $ACCEPTED_DEFAULT_MEDIA_TYPE = "print";
145
+    static $ACCEPTED_GENERIC_MEDIA_TYPES = array("all", "static", "visual", "bitmap", "paged");
146
+
147
+    /**
148
+     * The class constructor.
149
+     *
150
+     * The base protocol, host & path are initialized to those of
151
+     * the current script.
152
+     */
153
+    function __construct() {
154 154
     $this->_styles = array();
155 155
     $this->_loaded_files = array();
156 156
     list($this->_protocol, $this->_base_host, $this->_base_path) = explode_url($_SERVER["SCRIPT_FILENAME"]);
157 157
     $this->_page_style = null;
158
-  }
159
-
160
-  /**
161
-   * Set the base protocol
162
-   *
163
-   * @param string $proto
164
-   */
165
-  function set_protocol($proto) { $this->_protocol = $proto; }
166
-
167
-  /**
168
-   * Set the base host
169
-   *
170
-   * @param string $host
171
-   */
172
-  function set_host($host) { $this->_base_host = $host; }
173
-
174
-  /**
175
-   * Set the base path
176
-   *
177
-   * @param string $path
178
-   */
179
-  function set_base_path($path) { $this->_base_path = $path; }
180
-
181
-
182
-  /**
183
-   * Return the base protocol for this stylesheet
184
-   *
185
-   * @return string
186
-   */
187
-  function get_protocol() { return $this->_protocol; }
188
-
189
-  /**
190
-   * Return the base host for this stylesheet
191
-   *
192
-   * @return string
193
-   */
194
-  function get_host() { return $this->_base_host; }
195
-
196
-  /**
197
-   * Return the base path for this stylesheet
198
-   *
199
-   * @return string
200
-   */
201
-  function get_base_path() { return $this->_base_path; }
202
-
203
-  /**
204
-   * add a new Style object to the stylesheet
205
-   *
206
-   * add_style() adds a new Style object to the current stylesheet, or
207
-   * merges a new Style with an existing one.
208
-   *
209
-   * @param string $key   the Style's selector
210
-   * @param Style $style  the Style to be added
211
-   */
212
-  function add_style($key, Style $style) {
158
+    }
159
+
160
+    /**
161
+     * Set the base protocol
162
+     *
163
+     * @param string $proto
164
+     */
165
+    function set_protocol($proto) { $this->_protocol = $proto; }
166
+
167
+    /**
168
+     * Set the base host
169
+     *
170
+     * @param string $host
171
+     */
172
+    function set_host($host) { $this->_base_host = $host; }
173
+
174
+    /**
175
+     * Set the base path
176
+     *
177
+     * @param string $path
178
+     */
179
+    function set_base_path($path) { $this->_base_path = $path; }
180
+
181
+
182
+    /**
183
+     * Return the base protocol for this stylesheet
184
+     *
185
+     * @return string
186
+     */
187
+    function get_protocol() { return $this->_protocol; }
188
+
189
+    /**
190
+     * Return the base host for this stylesheet
191
+     *
192
+     * @return string
193
+     */
194
+    function get_host() { return $this->_base_host; }
195
+
196
+    /**
197
+     * Return the base path for this stylesheet
198
+     *
199
+     * @return string
200
+     */
201
+    function get_base_path() { return $this->_base_path; }
202
+
203
+    /**
204
+     * add a new Style object to the stylesheet
205
+     *
206
+     * add_style() adds a new Style object to the current stylesheet, or
207
+     * merges a new Style with an existing one.
208
+     *
209
+     * @param string $key   the Style's selector
210
+     * @param Style $style  the Style to be added
211
+     */
212
+    function add_style($key, Style $style) {
213 213
     if (!is_string($key))
214
-      throw new DOMPDF_Exception("CSS rule must be keyed by a string.");
214
+        throw new DOMPDF_Exception("CSS rule must be keyed by a string.");
215 215
 
216 216
     if ( isset($this->_styles[$key]) )
217
-      $this->_styles[$key]->merge($style);
217
+        $this->_styles[$key]->merge($style);
218 218
     else
219
-      $this->_styles[$key] = clone $style;
220
-  }
221
-
222
-
223
-  /**
224
-   * lookup a specifc Style object
225
-   *
226
-   * lookup() returns the Style specified by $key, or null if the Style is
227
-   * not found.
228
-   *
229
-   * @param string $key   the selector of the requested Style
230
-   * @return Style
231
-   */
232
-  function lookup($key) {
219
+        $this->_styles[$key] = clone $style;
220
+    }
221
+
222
+
223
+    /**
224
+     * lookup a specifc Style object
225
+     *
226
+     * lookup() returns the Style specified by $key, or null if the Style is
227
+     * not found.
228
+     *
229
+     * @param string $key   the selector of the requested Style
230
+     * @return Style
231
+     */
232
+    function lookup($key) {
233 233
     if ( !isset($this->_styles[$key]) )
234
-      return null;
234
+        return null;
235 235
 
236 236
     return $this->_styles[$key];
237
-  }
238
-
239
-  /**
240
-   * create a new Style object associated with this stylesheet
241
-   *
242
-   * @param Style $parent The style of this style's parent in the DOM tree
243
-   * @return Style
244
-   */
245
-  function create_style($parent = null) {
237
+    }
238
+
239
+    /**
240
+     * create a new Style object associated with this stylesheet
241
+     *
242
+     * @param Style $parent The style of this style's parent in the DOM tree
243
+     * @return Style
244
+     */
245
+    function create_style($parent = null) {
246 246
     return new Style($this, $parent);
247
-  }
247
+    }
248 248
 
249 249
 
250
-  /**
251
-   * load and parse a CSS string
252
-   *
253
-   * @param string $css
254
-   */
255
-  function load_css(&$css) { $this->_parse_css($css); }
250
+    /**
251
+     * load and parse a CSS string
252
+     *
253
+     * @param string $css
254
+     */
255
+    function load_css(&$css) { $this->_parse_css($css); }
256 256
 
257 257
 
258
-  /**
259
-   * load and parse a CSS file
260
-   *
261
-   * @param string $file
262
-   */
263
-  function load_css_file($file) {
258
+    /**
259
+     * load and parse a CSS file
260
+     *
261
+     * @param string $file
262
+     */
263
+    function load_css_file($file) {
264 264
     global $_dompdf_warnings;
265 265
 
266 266
     // Prevent circular references
267 267
     if ( isset($this->_loaded_files[$file]) )
268
-      return;
268
+        return;
269 269
 
270 270
     $this->_loaded_files[$file] = true;
271 271
     $parsed_url = explode_url($file);
@@ -274,36 +274,36 @@  discard block
 block discarded – undo
274 274
 
275 275
     if ( !DOMPDF_ENABLE_REMOTE &&
276 276
          ($this->_protocol != "" && $this->_protocol !== "file://") ) {
277
-      record_warnings(E_USER_WARNING, "Remote CSS file '$file' requested, but DOMPDF_ENABLE_REMOTE is false.", __FILE__, __LINE__);
278
-      return;
277
+        record_warnings(E_USER_WARNING, "Remote CSS file '$file' requested, but DOMPDF_ENABLE_REMOTE is false.", __FILE__, __LINE__);
278
+        return;
279 279
     }
280 280
 
281 281
     // Fix submitted by Nick Oostveen for aliased directory support:
282 282
     if ( $this->_protocol == "" )
283
-      $file = $this->_base_path . $filename;
283
+        $file = $this->_base_path . $filename;
284 284
     else
285
-      $file = build_url($this->_protocol, $this->_base_host, $this->_base_path, $filename);
285
+        $file = build_url($this->_protocol, $this->_base_host, $this->_base_path, $filename);
286 286
 
287 287
     set_error_handler("record_warnings");
288 288
     $css = file_get_contents($file);
289 289
     restore_error_handler();
290 290
 
291 291
     if ( $css == "" ) {
292
-      record_warnings(E_USER_WARNING, "Unable to load css file $file", __FILE__, __LINE__);;
293
-      return;
292
+        record_warnings(E_USER_WARNING, "Unable to load css file $file", __FILE__, __LINE__);;
293
+        return;
294 294
     }
295 295
 
296 296
     $this->_parse_css($css);
297 297
 
298
-  }
298
+    }
299 299
 
300
-  /**
301
-   * @link http://www.w3.org/TR/CSS21/cascade.html#specificity}
302
-   *
303
-   * @param string $selector
304
-   * @return int
305
-   */
306
-  private function _specificity($selector) {
300
+    /**
301
+     * @link http://www.w3.org/TR/CSS21/cascade.html#specificity}
302
+     *
303
+     * @param string $selector
304
+     * @return int
305
+     */
306
+    private function _specificity($selector) {
307 307
     // http://www.w3.org/TR/CSS21/cascade.html#specificity
308 308
     // ignoring the ":" pseudoclass modifyers
309 309
     // also ignored in _css_selector_to_xpath
@@ -325,26 +325,26 @@  discard block
 block discarded – undo
325 325
     //see _css_selector_to_xpath
326 326
 
327 327
     if ( !in_array($selector[0], array(" ", ">", ".", "#", "+", ":", "[")) ) {
328
-    	$d++;
328
+        $d++;
329 329
     }
330 330
 
331 331
     if (DEBUGCSS) {
332
-      /*DEBUGCSS*/	print "<pre>\n";
333
-      /*DEBUGCSS*/	printf("_specificity(): 0x%08x \"%s\"\n", ($a << 24) | ($b << 16) | ($c << 8) | ($d), $selector);
334
-      /*DEBUGCSS*/	print "</pre>";
332
+        /*DEBUGCSS*/	print "<pre>\n";
333
+        /*DEBUGCSS*/	printf("_specificity(): 0x%08x \"%s\"\n", ($a << 24) | ($b << 16) | ($c << 8) | ($d), $selector);
334
+        /*DEBUGCSS*/	print "</pre>";
335 335
     }
336 336
 
337 337
     return ($a << 24) | ($b << 16) | ($c << 8) | ($d);
338
-  }
338
+    }
339 339
 
340 340
 
341
-  /**
342
-   * converts a CSS selector to an XPath query.
343
-   *
344
-   * @param string $selector
345
-   * @return string
346
-   */
347
-  private function _css_selector_to_xpath($selector) {
341
+    /**
342
+     * converts a CSS selector to an XPath query.
343
+     *
344
+     * @param string $selector
345
+     * @return string
346
+     */
347
+    private function _css_selector_to_xpath($selector) {
348 348
 
349 349
     // Collapse white space and strip whitespace around delimiters
350 350
 //     $search = array("/\\s+/", "/\\s+([.>#+:])\\s+/");
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
     // Add an implicit space at the beginning of the selector if there is no
363 363
     // delimiter there already.
364 364
     if ( !in_array($selector[0], $delimiters) )
365
-      $selector = " $selector";
365
+        $selector = " $selector";
366 366
 
367 367
     $tok = "";
368 368
     $len = mb_strlen($selector);
@@ -370,37 +370,37 @@  discard block
 block discarded – undo
370 370
 
371 371
     while ( $i < $len ) {
372 372
 
373
-      $s = $selector[$i];
374
-      $i++;
373
+        $s = $selector[$i];
374
+        $i++;
375 375
 
376
-      // Eat characters up to the next delimiter
377
-      $tok = "";
376
+        // Eat characters up to the next delimiter
377
+        $tok = "";
378 378
 
379
-      while ($i < $len) {
379
+        while ($i < $len) {
380 380
         if ( in_array($selector[$i], $delimiters) )
381
-          break;
381
+            break;
382 382
         $tok .= $selector[$i++];
383
-      }
383
+        }
384 384
 
385
-      switch ($s) {
385
+        switch ($s) {
386 386
 
387
-      case " ":
387
+        case " ":
388 388
       case ">":
389 389
         // All elements matching the next token that are direct children of
390 390
         // the current token
391 391
         $expr = $s === " " ? "descendant" : "child";
392 392
 
393 393
         if ( mb_substr($query, -1, 1) !== "/" )
394
-          $query .= "/";
394
+            $query .= "/";
395 395
 
396 396
         if ( !$tok )
397
-          $tok = "*";
397
+            $tok = "*";
398 398
 
399 399
         $query .= "$expr::$tok";
400 400
         $tok = "";
401 401
         break;
402 402
 
403
-      case ".":
403
+        case ".":
404 404
       case "#":
405 405
         // All elements matching the current token with a class/id equal to
406 406
         // the _next_ token.
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 
410 410
         // empty class/id == *
411 411
         if ( mb_substr($query, -1, 1) === "/" )
412
-          $query .= "*";
412
+            $query .= "*";
413 413
 
414 414
         // Match multiple classes: $tok contains the current selected
415 415
         // class.  Search for class attributes with class="$tok",
@@ -423,28 +423,28 @@  discard block
 block discarded – undo
423 423
         $tok = "";
424 424
         break;
425 425
 
426
-      case "+":
426
+        case "+":
427 427
         // All sibling elements that folow the current token
428 428
         if ( mb_substr($query, -1, 1) !== "/" )
429
-          $query .= "/";
429
+            $query .= "/";
430 430
 
431 431
         $query .= "following-sibling::$tok";
432 432
         $tok = "";
433 433
         break;
434 434
 
435
-      case ":":
435
+        case ":":
436 436
         // Pseudo-classes
437 437
         switch ($tok) {
438 438
 
439 439
         case "first-child":
440 440
           $query .= "[1]";
441
-          $tok = "";
442
-          break;
441
+            $tok = "";
442
+            break;
443 443
 
444 444
         case "link":
445 445
           $query .= "[@href]";
446
-          $tok = "";
447
-          break;
446
+            $tok = "";
447
+            break;
448 448
 
449 449
         case "first-line":
450 450
           break;
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 
463 463
         break;
464 464
 
465
-      case "[":
465
+        case "[":
466 466
         // Attribute selectors.  All with an attribute matching the following token(s)
467 467
         $attr_delimiters = array("=", "]", "~", "|");
468 468
         $tok_len = mb_strlen($tok);
@@ -473,9 +473,9 @@  discard block
 block discarded – undo
473 473
         $value = "";
474 474
 
475 475
         while ( $j < $tok_len ) {
476
-          if ( in_array($tok[$j], $attr_delimiters) )
476
+            if ( in_array($tok[$j], $attr_delimiters) )
477 477
             break;
478
-          $attr .= $tok[$j++];
478
+            $attr .= $tok[$j++];
479 479
         }
480 480
 
481 481
         switch ( $tok[$j] ) {
@@ -484,67 +484,67 @@  discard block
 block discarded – undo
484 484
         case "|":
485 485
           $op .= $tok[$j++];
486 486
 
487
-          if ( $tok[$j] !== "=" )
487
+            if ( $tok[$j] !== "=" )
488 488
             throw new DOMPDF_Exception("Invalid CSS selector syntax: invalid attribute selector: $selector");
489 489
 
490
-          $op .= $tok[$j];
491
-          break;
490
+            $op .= $tok[$j];
491
+            break;
492 492
 
493 493
         case "=":
494 494
           $op = "=";
495
-          break;
495
+            break;
496 496
 
497 497
         }
498 498
 
499 499
         // Read the attribute value, if required
500 500
         if ( $op != "" ) {
501
-          $j++;
502
-          while ( $j < $tok_len ) {
501
+            $j++;
502
+            while ( $j < $tok_len ) {
503 503
             if ( $tok[$j] === "]" )
504
-              break;
504
+                break;
505 505
             $value .= $tok[$j++];
506
-          }
506
+            }
507 507
         }
508 508
 
509 509
         if ( $attr == "" )
510
-          throw new DOMPDF_Exception("Invalid CSS selector syntax: missing attribute name");
510
+            throw new DOMPDF_Exception("Invalid CSS selector syntax: missing attribute name");
511 511
 
512 512
         switch ( $op ) {
513 513
 
514 514
         case "":
515 515
           $query .=  "[@$attr]";
516
-          break;
516
+            break;
517 517
 
518 518
         case "=":
519 519
           $query .= "[@$attr$op\"$value\"]";
520
-          break;
520
+            break;
521 521
 
522 522
         case "~=":
523 523
           // FIXME: this will break if $value contains quoted strings
524 524
           // (e.g. [type~="a b c" "d e f"])
525 525
           $values = explode(" ", $value);
526
-          $query .=  "[";
526
+            $query .=  "[";
527 527
 
528
-          foreach ( $values as $val )
528
+            foreach ( $values as $val )
529 529
             $query .= "@$attr=\"$val\" or ";
530 530
 
531
-          $query = rtrim($query, " or ") . "]";
532
-          break;
531
+            $query = rtrim($query, " or ") . "]";
532
+            break;
533 533
 
534 534
         case "|=":
535 535
           $values = explode("-", $value);
536
-          $query .= "[";
536
+            $query .= "[";
537 537
 
538
-          foreach ($values as $val)
538
+            foreach ($values as $val)
539 539
             $query .= "starts-with(@$attr, \"$val\") or ";
540 540
 
541
-          $query = rtrim($query, " or ") . "]";
542
-          break;
541
+            $query = rtrim($query, " or ") . "]";
542
+            break;
543 543
 
544 544
         }
545 545
 
546 546
         break;
547
-      }
547
+        }
548 548
     }
549 549
     $i++;
550 550
 
@@ -571,21 +571,21 @@  discard block
 block discarded – undo
571 571
 
572 572
     // Trim the trailing '/' from the query
573 573
     if ( mb_strlen($query) > 2 )
574
-      $query = rtrim($query, "/");
574
+        $query = rtrim($query, "/");
575 575
 
576 576
     return $query;
577
-  }
578
-
579
-  /**
580
-   * applies all current styles to a particular document tree
581
-   *
582
-   * apply_styles() applies all currently loaded styles to the provided
583
-   * {@link Frame_Tree}.  Aside from parsing CSS, this is the main purpose
584
-   * of this class.
585
-   *
586
-   * @param Frame_Tree $tree
587
-   */
588
-  function apply_styles(Frame_Tree $tree) {
577
+    }
578
+
579
+    /**
580
+     * applies all current styles to a particular document tree
581
+     *
582
+     * apply_styles() applies all currently loaded styles to the provided
583
+     * {@link Frame_Tree}.  Aside from parsing CSS, this is the main purpose
584
+     * of this class.
585
+     *
586
+     * @param Frame_Tree $tree
587
+     */
588
+    function apply_styles(Frame_Tree $tree) {
589 589
 
590 590
     // Use XPath to select nodes.  This would be easier if we could attach
591 591
     // Frame objects directly to DOMNodes using the setUserData() method, but
@@ -605,67 +605,67 @@  discard block
 block discarded – undo
605 605
     // Apply all styles in stylesheet
606 606
     foreach ($this->_styles as $selector => $style) {
607 607
 
608
-      $query = $this->_css_selector_to_xpath($selector);
608
+        $query = $this->_css_selector_to_xpath($selector);
609 609
 //       pre_var_dump($selector);
610 610
 //       pre_var_dump($query);
611 611
 //        echo ($style);
612 612
 
613
-      // Retrieve the nodes
614
-      $nodes = $xp->query($query);
613
+        // Retrieve the nodes
614
+        $nodes = $xp->query($query);
615 615
 
616
-      foreach ($nodes as $node) {
616
+        foreach ($nodes as $node) {
617 617
         //echo $node->nodeName . "\n";
618 618
         // Retrieve the node id
619 619
         if ( $node->nodeType != 1 ) // Only DOMElements get styles
620
-          continue;
620
+            continue;
621 621
 
622 622
         $id = $node->getAttribute("frame_id");
623 623
 
624 624
         // Assign the current style to the scratch array
625 625
         $spec = $this->_specificity($selector);
626 626
         $styles[$id][$spec][] = $style;
627
-      }
627
+        }
628 628
     }
629 629
 
630 630
     // Now create the styles and assign them to the appropriate frames.  (We
631 631
     // iterate over the tree using an implicit Frame_Tree iterator.)
632 632
     $root_flg = false;
633 633
     foreach ($tree->get_frames() as $frame) {
634
-      // pre_r($frame->get_node()->nodeName . ":");
635
-      if ( !$root_flg && $this->_page_style ) {
634
+        // pre_r($frame->get_node()->nodeName . ":");
635
+        if ( !$root_flg && $this->_page_style ) {
636 636
         $style = $this->_page_style;
637 637
         $root_flg = true;
638
-      } else
638
+        } else
639 639
         $style = $this->create_style();
640 640
 
641
-      // Find nearest DOMElement parent
642
-      $p = $frame;
643
-      while ( $p = $p->get_parent() )
641
+        // Find nearest DOMElement parent
642
+        $p = $frame;
643
+        while ( $p = $p->get_parent() )
644 644
         if ($p->get_node()->nodeType == 1 )
645
-          break;
645
+            break;
646 646
 
647
-      // Styles can only be applied directly to DOMElements; anonymous
648
-      // frames inherit from their parent
649
-      if ( $frame->get_node()->nodeType != 1 ) {
647
+        // Styles can only be applied directly to DOMElements; anonymous
648
+        // frames inherit from their parent
649
+        if ( $frame->get_node()->nodeType != 1 ) {
650 650
         if ( $p )
651
-          $style->inherit($p->get_style());
651
+            $style->inherit($p->get_style());
652 652
         $frame->set_style($style);
653 653
         continue;
654
-      }
654
+        }
655 655
 
656
-      $id = $frame->get_id();
656
+        $id = $frame->get_id();
657 657
 
658
-      // Handle HTML 4.0 attributes
659
-      Attribute_Translator::translate_attributes($frame);
658
+        // Handle HTML 4.0 attributes
659
+        Attribute_Translator::translate_attributes($frame);
660 660
 
661
-      // Locate any additional style attributes
662
-      if ( ($str = $frame->get_node()->getAttribute("style")) !== "" ) {
661
+        // Locate any additional style attributes
662
+        if ( ($str = $frame->get_node()->getAttribute("style")) !== "" ) {
663 663
         $spec = $this->_specificity("!style attribute");
664 664
         $styles[$id][$spec][] = $this->_parse_properties($str);
665
-      }
665
+        }
666 666
 
667
-      // Grab the applicable styles
668
-      if ( isset($styles[$id]) ) {
667
+        // Grab the applicable styles
668
+        if ( isset($styles[$id]) ) {
669 669
 
670 670
         $applied_styles = $styles[ $frame->get_id() ];
671 671
 
@@ -673,101 +673,101 @@  discard block
 block discarded – undo
673 673
         ksort($applied_styles);
674 674
 
675 675
         if (DEBUGCSS) {
676
-          $debug_nodename = $frame->get_node()->nodeName;
677
-          print "<pre>\n[$debug_nodename\n";
678
-          foreach ($applied_styles as $spec => $arr) {
676
+            $debug_nodename = $frame->get_node()->nodeName;
677
+            print "<pre>\n[$debug_nodename\n";
678
+            foreach ($applied_styles as $spec => $arr) {
679 679
             printf("specificity: 0x%08x\n",$spec);
680 680
             foreach ($arr as $s) {
681
-              print "[\n";
682
-              $s->debug_print();
683
-              print "]\n";
681
+                print "[\n";
682
+                $s->debug_print();
683
+                print "]\n";
684
+            }
684 685
             }
685
-          }
686 686
         }
687 687
         
688 688
         // Merge the new styles with the inherited styles
689 689
         foreach ($applied_styles as $arr) {
690
-          foreach ($arr as $s)
690
+            foreach ($arr as $s)
691 691
             $style->merge($s);
692 692
         }
693
-      }
693
+        }
694 694
 
695
-      // Inherit parent's styles if required
696
-      if ( $p ) {
695
+        // Inherit parent's styles if required
696
+        if ( $p ) {
697 697
 
698 698
         if (DEBUGCSS) {
699
-          print "inherit:\n";
700
-          print "[\n";
701
-          $p->get_style()->debug_print();
702
-          print "]\n";
699
+            print "inherit:\n";
700
+            print "[\n";
701
+            $p->get_style()->debug_print();
702
+            print "]\n";
703 703
         }
704 704
 
705 705
         $style->inherit( $p->get_style() );
706
-      }
706
+        }
707 707
 
708
-      if (DEBUGCSS) {
708
+        if (DEBUGCSS) {
709 709
         print "DomElementStyle:\n";
710 710
         print "[\n";
711 711
         $style->debug_print();
712 712
         print "]\n";
713 713
         print "/$debug_nodename]\n</pre>";
714
-      }
714
+        }
715 715
 
716
-      /*DEBUGCSS print: see below different print debugging method
716
+        /*DEBUGCSS print: see below different print debugging method
717 717
       pre_r($frame->get_node()->nodeName . ":");
718 718
       echo "<pre>";
719 719
       echo $style;
720 720
       echo "</pre>";*/
721
-      $frame->set_style($style);
721
+        $frame->set_style($style);
722 722
 
723 723
     }
724 724
 
725 725
     // We're done!  Clean out the registry of all styles since we
726 726
     // won't be needing this later.
727 727
     foreach ( array_keys($this->_styles) as $key ) {
728
-      unset($this->_styles[$key]);
728
+        unset($this->_styles[$key]);
729 729
     }
730 730
 
731
-  }
731
+    }
732 732
 
733 733
 
734
-  /**
735
-   * parse a CSS string using a regex parser
736
-   *
737
-   * Called by {@link Stylesheet::parse_css()}
738
-   *
739
-   * @param string $str
740
-   */
741
-  private function _parse_css($str) {
734
+    /**
735
+     * parse a CSS string using a regex parser
736
+     *
737
+     * Called by {@link Stylesheet::parse_css()}
738
+     *
739
+     * @param string $str
740
+     */
741
+    private function _parse_css($str) {
742 742
 
743 743
     $str = trim($str);
744 744
     
745 745
     // Destroy comments and remove HTML comments
746 746
     $css = preg_replace(array(
747
-      "'/\*.*?\*/'si", 
748
-      "/^<!--/",
749
-      "/-->$/"
747
+        "'/\*.*?\*/'si", 
748
+        "/^<!--/",
749
+        "/-->$/"
750 750
     ), "", $str);
751 751
 
752 752
     // FIXME: handle '{' within strings, e.g. [attr="string {}"]
753 753
 
754 754
     // Something more legible:
755 755
     $re =
756
-      "/\s*                                   # Skip leading whitespace                             \n".
757
-      "( @([^\s]+)\s+([^{;]*) (?:;|({)) )?    # Match @rules followed by ';' or '{'                 \n".
758
-      "(?(1)                                  # Only parse sub-sections if we're in an @rule...     \n".
759
-      "  (?(4)                                # ...and if there was a leading '{'                   \n".
760
-      "    \s*( (?:(?>[^{}]+) ({)?            # Parse rulesets and individual @page rules           \n".
761
-      "            (?(6) (?>[^}]*) }) \s*)+?  \n".
762
-      "       )                               \n".
763
-      "   })                                  # Balancing '}'                                \n".
764
-      "|                                      # Branch to match regular rules (not preceeded by '@')\n".
765
-      "([^{]*{[^}]*}))                        # Parse normal rulesets\n".
766
-      "/xs";
756
+        "/\s*                                   # Skip leading whitespace                             \n".
757
+        "( @([^\s]+)\s+([^{;]*) (?:;|({)) )?    # Match @rules followed by ';' or '{'                 \n".
758
+        "(?(1)                                  # Only parse sub-sections if we're in an @rule...     \n".
759
+        "  (?(4)                                # ...and if there was a leading '{'                   \n".
760
+        "    \s*( (?:(?>[^{}]+) ({)?            # Parse rulesets and individual @page rules           \n".
761
+        "            (?(6) (?>[^}]*) }) \s*)+?  \n".
762
+        "       )                               \n".
763
+        "   })                                  # Balancing '}'                                \n".
764
+        "|                                      # Branch to match regular rules (not preceeded by '@')\n".
765
+        "([^{]*{[^}]*}))                        # Parse normal rulesets\n".
766
+        "/xs";
767 767
 
768 768
     if ( preg_match_all($re, $css, $matches, PREG_SET_ORDER) === false )
769
-      // An error occured
770
-      throw new DOMPDF_Exception("Error parsing css file: preg_match_all() failed.");
769
+        // An error occured
770
+        throw new DOMPDF_Exception("Error parsing css file: preg_match_all() failed.");
771 771
 
772 772
     // After matching, the array indicies are set as follows:
773 773
     //
@@ -782,27 +782,27 @@  discard block
 block discarded – undo
782 782
     //
783 783
     //pre_r($matches);
784 784
     foreach ( $matches as $match ) {
785
-      $match[2] = trim($match[2]);
785
+        $match[2] = trim($match[2]);
786 786
 
787
-      if ( $match[2] !== "" ) {
787
+        if ( $match[2] !== "" ) {
788 788
         // Handle @rules
789 789
         switch ($match[2]) {
790 790
 
791 791
         case "import":
792 792
           $this->_parse_import($match[3]);
793
-          break;
793
+            break;
794 794
 
795 795
         case "media":
796 796
           $acceptedmedia = self::$ACCEPTED_GENERIC_MEDIA_TYPES;
797
-          if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) {
797
+            if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) {
798 798
             $acceptedmedia[] = DOMPDF_DEFAULT_MEDIA_TYPE;
799
-          } else {
799
+            } else {
800 800
             $acceptedmedia[] = self::$ACCEPTED_DEFAULT_MEDIA_TYPE;
801
-          }
802
-          if ( in_array(mb_strtolower(trim($match[3])), $acceptedmedia ) ) {
801
+            }
802
+            if ( in_array(mb_strtolower(trim($match[3])), $acceptedmedia ) ) {
803 803
             $this->_parse_sections($match[5]);
804
-          }
805
-          break;
804
+            }
805
+            break;
806 806
 
807 807
         case "page":
808 808
           //This handles @page to be applied to page oriented media
@@ -827,9 +827,9 @@  discard block
 block discarded – undo
827 827
           // Store the style for later...
828 828
           if ( is_null($this->_page_style) )
829 829
             $this->_page_style = $this->_parse_properties($match[5]);
830
-          else
830
+            else
831 831
             $this->_page_style->merge($this->_parse_properties($match[5]));
832
-          break;
832
+            break;
833 833
 
834 834
         default:
835 835
           // ignore everything else
@@ -837,118 +837,118 @@  discard block
 block discarded – undo
837 837
         }
838 838
 
839 839
         continue;
840
-      }
840
+        }
841 841
 
842
-      if ( $match[7] !== "" )
842
+        if ( $match[7] !== "" )
843 843
         $this->_parse_sections($match[7]);
844 844
 
845 845
     }
846
-  }
846
+    }
847 847
 
848
-  /* See also style.cls Style::_image(), refactoring?, works also for imported css files */
849
-  protected function _image($val) {
848
+    /* See also style.cls Style::_image(), refactoring?, works also for imported css files */
849
+    protected function _image($val) {
850 850
     $DEBUGCSS=DEBUGCSS;
851 851
     
852 852
     if ( mb_strpos($val, "url") === false ) {
853
-      $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none
853
+        $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none
854 854
     }
855 855
     else {
856
-      $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/","\\1", trim($val));
856
+        $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/","\\1", trim($val));
857 857
 
858
-      // Resolve the url now in the context of the current stylesheet
859
-      $parsed_url = explode_url($val);
860
-      if ( $parsed_url["protocol"] == "" && $this->get_protocol() == "" ) {
858
+        // Resolve the url now in the context of the current stylesheet
859
+        $parsed_url = explode_url($val);
860
+        if ( $parsed_url["protocol"] == "" && $this->get_protocol() == "" ) {
861 861
         if ($parsed_url["path"]{0} === '/' || $parsed_url["path"]{0} === '\\' ) {
862
-          $path = $_SERVER["DOCUMENT_ROOT"].'/';
862
+            $path = $_SERVER["DOCUMENT_ROOT"].'/';
863 863
         } else {
864
-          $path = $this->get_base_path();
864
+            $path = $this->get_base_path();
865 865
         }
866 866
         $path .= $parsed_url["path"] . $parsed_url["file"];
867 867
         $path = realpath($path);
868 868
         // If realpath returns FALSE then specifically state that there is no background image
869 869
         if (!$path) { $path = 'none'; }
870
-      } else {
870
+        } else {
871 871
         $path = build_url($this->get_protocol(),
872
-                          $this->get_host(),
873
-                          $this->get_base_path(),
874
-                          $val);
875
-      }
872
+                            $this->get_host(),
873
+                            $this->get_base_path(),
874
+                            $val);
875
+        }
876 876
     }
877 877
     if ($DEBUGCSS) {
878
-      print "<pre>[_image\n";
879
-      print_r($parsed_url);
880
-      print $this->get_protocol()."\n".$this->get_base_path()."\n".$path."\n";
881
-      print "_image]</pre>";;
878
+        print "<pre>[_image\n";
879
+        print_r($parsed_url);
880
+        print $this->get_protocol()."\n".$this->get_base_path()."\n".$path."\n";
881
+        print "_image]</pre>";;
882 882
     }
883 883
     return $path;
884
-  }
885
-
886
-  /**
887
-   * parse @import{} sections
888
-   *
889
-   * @param string $url  the url of the imported CSS file
890
-   */
891
-  private function _parse_import($url) {
884
+    }
885
+
886
+    /**
887
+     * parse @import{} sections
888
+     *
889
+     * @param string $url  the url of the imported CSS file
890
+     */
891
+    private function _parse_import($url) {
892 892
     $arr = preg_split("/[\s\n,]/", $url,-1, PREG_SPLIT_NO_EMPTY);
893 893
     $url = array_shift($arr);
894 894
     $accept = false;
895 895
 
896 896
     if ( count($arr) > 0 ) {
897 897
 
898
-      $acceptedmedia = self::$ACCEPTED_GENERIC_MEDIA_TYPES;
899
-      if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) {
898
+        $acceptedmedia = self::$ACCEPTED_GENERIC_MEDIA_TYPES;
899
+        if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) {
900 900
         $acceptedmedia[] = DOMPDF_DEFAULT_MEDIA_TYPE;
901
-      } else {
901
+        } else {
902 902
         $acceptedmedia[] = self::$ACCEPTED_DEFAULT_MEDIA_TYPE;
903
-      }
903
+        }
904 904
               
905
-      // @import url media_type [media_type...]
906
-      foreach ( $arr as $type ) {
905
+        // @import url media_type [media_type...]
906
+        foreach ( $arr as $type ) {
907 907
         if ( in_array(mb_strtolower(trim($type)), $acceptedmedia) ) {
908
-          $accept = true;
909
-          break;
908
+            $accept = true;
909
+            break;
910
+        }
910 911
         }
911
-      }
912 912
 
913 913
     } else {
914
-      // unconditional import
915
-      $accept = true;
914
+        // unconditional import
915
+        $accept = true;
916 916
     }
917 917
 
918 918
     if ( $accept ) {
919
-      // Store our current base url properties in case the new url is elsewhere
920
-      $protocol = $this->_protocol;
921
-      $host = $this->_base_host;
922
-      $path = $this->_base_path;
919
+        // Store our current base url properties in case the new url is elsewhere
920
+        $protocol = $this->_protocol;
921
+        $host = $this->_base_host;
922
+        $path = $this->_base_path;
923 923
       
924
-      // $url = str_replace(array('"',"url", "(", ")"), "", $url);
925
-      // If the protocol is php, assume that we will import using file://
926
-      // $url = build_url($protocol == "php://" ? "file://" : $protocol, $host, $path, $url);
927
-      // Above does not work for subfolders and absolute urls.
928
-      // Todo: As above, do we need to replace php or file to an empty protocol for local files?
924
+        // $url = str_replace(array('"',"url", "(", ")"), "", $url);
925
+        // If the protocol is php, assume that we will import using file://
926
+        // $url = build_url($protocol == "php://" ? "file://" : $protocol, $host, $path, $url);
927
+        // Above does not work for subfolders and absolute urls.
928
+        // Todo: As above, do we need to replace php or file to an empty protocol for local files?
929 929
       
930
-      $url = $this->_image($url);
930
+        $url = $this->_image($url);
931 931
       
932
-      $this->load_css_file($url);
932
+        $this->load_css_file($url);
933
+
934
+        // Restore the current base url
935
+        $this->_protocol = $protocol;
936
+        $this->_base_host = $host;
937
+        $this->_base_path = $path;
938
+    }
933 939
 
934
-      // Restore the current base url
935
-      $this->_protocol = $protocol;
936
-      $this->_base_host = $host;
937
-      $this->_base_path = $path;
938 940
     }
939 941
 
940
-  }
941
-
942
-  /**
943
-   * parse regular CSS blocks
944
-   *
945
-   * _parse_properties() creates a new Style object based on the provided
946
-   * CSS rules.
947
-   *
948
-   * @param string $str  CSS rules
949
-   * @return Style
950
-   */
951
-  private function _parse_properties($str) {
942
+    /**
943
+     * parse regular CSS blocks
944
+     *
945
+     * _parse_properties() creates a new Style object based on the provided
946
+     * CSS rules.
947
+     *
948
+     * @param string $str  CSS rules
949
+     * @return Style
950
+     */
951
+    private function _parse_properties($str) {
952 952
     $properties = explode(";", $str);
953 953
 
954 954
     if (DEBUGCSS) print '[_parse_properties';
@@ -956,71 +956,71 @@  discard block
 block discarded – undo
956 956
     // Create the style
957 957
     $style = new Style($this);
958 958
     foreach ($properties as $prop) {
959
-      //A css property can have " ! important" appended (whitespace optional)
960
-      //strip this off to decode core of the property correctly.
961
-      //Pass on in the style to allow proper handling:
962
-      //!important properties can only be overridden by other !important ones.
963
-      //$style->$prop_name = is a shortcut of $style->__set($prop_name,$value);.
964
-      //If no specific set function available, set _props["prop_name"]
965
-      //style is always copied completely, or $_props handled separately
966
-      //Therefore set a _important_props["prop_name"]=true to indicate the modifier
967
-
968
-      /* Instead of short code, prefer the typical case with fast code
959
+        //A css property can have " ! important" appended (whitespace optional)
960
+        //strip this off to decode core of the property correctly.
961
+        //Pass on in the style to allow proper handling:
962
+        //!important properties can only be overridden by other !important ones.
963
+        //$style->$prop_name = is a shortcut of $style->__set($prop_name,$value);.
964
+        //If no specific set function available, set _props["prop_name"]
965
+        //style is always copied completely, or $_props handled separately
966
+        //Therefore set a _important_props["prop_name"]=true to indicate the modifier
967
+
968
+        /* Instead of short code, prefer the typical case with fast code
969 969
 	  $important = preg_match("/(.*?)!\s*important/",$prop,$match);
970 970
       if ( $important ) {
971 971
       	$prop = $match[1];
972 972
       }
973 973
       $prop = trim($prop);
974 974
       */
975
-      if (DEBUGCSS) print '(';
976
- 	  $important = false;
977
-      $prop = trim($prop);
978
-      if (substr($prop,-9) === 'important') {
979
-      	$prop_tmp = rtrim(substr($prop,0,-9));
980
-      	if (substr($prop_tmp,-1) === '!') {
981
-      		$prop = rtrim(substr($prop_tmp,0,-1));
982
-      		$important = true;
983
-      	}
984
-      }
975
+        if (DEBUGCSS) print '(';
976
+        $important = false;
977
+        $prop = trim($prop);
978
+        if (substr($prop,-9) === 'important') {
979
+            $prop_tmp = rtrim(substr($prop,0,-9));
980
+            if (substr($prop_tmp,-1) === '!') {
981
+                $prop = rtrim(substr($prop_tmp,0,-1));
982
+                $important = true;
983
+            }
984
+        }
985 985
 
986
-      if ($prop == "") {
986
+        if ($prop == "") {
987 987
         if (DEBUGCSS) print 'empty)';
988 988
         continue;
989
-      }
989
+        }
990 990
 
991
-      $i = mb_strpos($prop, ":");
992
-      if ( $i === false ) {
991
+        $i = mb_strpos($prop, ":");
992
+        if ( $i === false ) {
993 993
         if (DEBUGCSS) print 'novalue'.$prop.')';
994 994
         continue;
995
-      }
995
+        }
996 996
 
997
-      $prop_name = rtrim(mb_strtolower(mb_substr($prop, 0, $i)));
998
-      $value = ltrim(mb_substr($prop, $i+1));
999
-      if (DEBUGCSS) print $prop_name.':='.$value.($important?'!IMPORTANT':'').')';
1000
-      //New style, anyway empty
1001
-      //if ($important || !$style->important_get($prop_name) ) {
1002
-      //$style->$prop_name = array($value,$important);
1003
-      //assignment might be replaced by overloading through __set,
1004
-      //and overloaded functions might check _important_props,
1005
-      //therefore set _important_props first.
1006
-      if ($important) {
997
+        $prop_name = rtrim(mb_strtolower(mb_substr($prop, 0, $i)));
998
+        $value = ltrim(mb_substr($prop, $i+1));
999
+        if (DEBUGCSS) print $prop_name.':='.$value.($important?'!IMPORTANT':'').')';
1000
+        //New style, anyway empty
1001
+        //if ($important || !$style->important_get($prop_name) ) {
1002
+        //$style->$prop_name = array($value,$important);
1003
+        //assignment might be replaced by overloading through __set,
1004
+        //and overloaded functions might check _important_props,
1005
+        //therefore set _important_props first.
1006
+        if ($important) {
1007 1007
         $style->important_set($prop_name);
1008
-      }
1009
-      //For easier debugging, don't use overloading of assignments with __set
1010
-      $style->$prop_name = $value;
1011
-      //$style->props_set($prop_name, $value);
1008
+        }
1009
+        //For easier debugging, don't use overloading of assignments with __set
1010
+        $style->$prop_name = $value;
1011
+        //$style->props_set($prop_name, $value);
1012 1012
     }
1013 1013
     if (DEBUGCSS) print '_parse_properties]';
1014 1014
 
1015 1015
     return $style;
1016
-  }
1017
-
1018
-  /**
1019
-   * parse selector + rulesets
1020
-   *
1021
-   * @param string $str  CSS selectors and rulesets
1022
-   */
1023
-  private function _parse_sections($str) {
1016
+    }
1017
+
1018
+    /**
1019
+     * parse selector + rulesets
1020
+     *
1021
+     * @param string $str  CSS selectors and rulesets
1022
+     */
1023
+    private function _parse_sections($str) {
1024 1024
     // Pre-process: collapse all whitespace and strip whitespace around '>',
1025 1025
     // '.', ':', '+', '#'
1026 1026
 
@@ -1031,43 +1031,43 @@  discard block
 block discarded – undo
1031 1031
     $sections = explode("}", $str);
1032 1032
     if (DEBUGCSS) print '[_parse_sections';
1033 1033
     foreach ($sections as $sect) {
1034
-      $i = mb_strpos($sect, "{");
1034
+        $i = mb_strpos($sect, "{");
1035 1035
 
1036
-      $selectors = explode(",", mb_substr($sect, 0, $i));
1037
-      if (DEBUGCSS) print '[section';
1038
-      $style = $this->_parse_properties(trim(mb_substr($sect, $i+1)));
1036
+        $selectors = explode(",", mb_substr($sect, 0, $i));
1037
+        if (DEBUGCSS) print '[section';
1038
+        $style = $this->_parse_properties(trim(mb_substr($sect, $i+1)));
1039 1039
       
1040
-      // Assign it to the selected elements
1041
-      foreach ($selectors as $selector) {
1040
+        // Assign it to the selected elements
1041
+        foreach ($selectors as $selector) {
1042 1042
         $selector = trim($selector);
1043 1043
 
1044 1044
         if ($selector == "") {
1045
-          if (DEBUGCSS) print '#empty#';
1046
-          continue;
1045
+            if (DEBUGCSS) print '#empty#';
1046
+            continue;
1047 1047
         }
1048 1048
         if (DEBUGCSS) print '#'.$selector.'#';
1049 1049
         //if (DEBUGCSS) { if (strpos($selector,'p') !== false) print '!!!p!!!#'; }
1050 1050
 
1051 1051
         $this->add_style($selector, $style);
1052
-      }
1053
-      if (DEBUGCSS) print 'section]';
1052
+        }
1053
+        if (DEBUGCSS) print 'section]';
1054 1054
     }
1055 1055
     if (DEBUGCSS) print '_parse_sections]';
1056
-  }
1057
-
1058
-  /**
1059
-   * dumps the entire stylesheet as a string
1060
-   *
1061
-   * Generates a string of each selector and associated style in the
1062
-   * Stylesheet.  Useful for debugging.
1063
-   *
1064
-   * @return string
1065
-   */
1066
-  function __toString() {
1056
+    }
1057
+
1058
+    /**
1059
+     * dumps the entire stylesheet as a string
1060
+     *
1061
+     * Generates a string of each selector and associated style in the
1062
+     * Stylesheet.  Useful for debugging.
1063
+     *
1064
+     * @return string
1065
+     */
1066
+    function __toString() {
1067 1067
     $str = "";
1068 1068
     foreach ($this->_styles as $selector => $style)
1069
-      $str .= "$selector => " . $style->__toString() . "\n";
1069
+        $str .= "$selector => " . $style->__toString() . "\n";
1070 1070
 
1071 1071
     return $str;
1072
-  }
1072
+    }
1073 1073
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/cellmap.cls.php 1 patch
Indentation   +323 added lines, -324 removed lines patch added patch discarded remove patch
@@ -1,41 +1,40 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/dompdf_internal_exception.cls.php 1 patch
Indentation   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -34,7 +34,6 @@  discard block
 block discarded – undo
34 34
  * @copyright 2004 Benj Carson
35 35
  * @author Benj Carson <[email protected]>
36 36
  * @package dompdf
37
-
38 37
  */
39 38
 
40 39
 /* $Id: dompdf_internal_exception.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -46,14 +45,14 @@  discard block
 block discarded – undo
46 45
  */
47 46
 class DOMPDF_Internal_Exception extends Exception {
48 47
 
49
-  /**
50
-   * Class constructor
51
-   *
52
-   * @param string $message Error message
53
-   * @param int $code Error code
54
-   */
55
-  function __construct($message = NULL, $code = 0) {
48
+    /**
49
+     * Class constructor
50
+     *
51
+     * @param string $message Error message
52
+     * @param int $code Error code
53
+     */
54
+    function __construct($message = NULL, $code = 0) {
56 55
     parent::__construct($message, $code);
57
-  }
56
+    }
58 57
 
59 58
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/dompdf.cls.php 1 patch
Indentation   +379 added lines, -380 removed lines patch added patch discarded remove patch
@@ -1,41 +1,40 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * DOMPDF - PHP5 HTML to PDF renderer
4
- *
5
- * File: $RCSfile: dompdf.cls.php,v $
6
- * Created on: 2004-06-09
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: dompdf.cls.php,v $
6
+     * Created on: 2004-06-09
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: dompdf.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
41 40
 
@@ -89,90 +88,90 @@  discard block
 block discarded – undo
89 88
 class DOMPDF {
90 89
 
91 90
 
92
-  /**
93
-   * DomDocument representing the HTML document
94
-   *
95
-   * @var DomDocument
96
-   */
97
-  protected $_xml;
98
-
99
-  /**
100
-   * Frame_Tree derived from the DOM tree
101
-   *
102
-   * @var Frame_Tree
103
-   */
104
-  protected $_tree;
105
-
106
-  /**
107
-   * Stylesheet for the document
108
-   *
109
-   * @var Stylesheet
110
-   */
111
-  protected $_css;
112
-
113
-  /**
114
-   * Actual PDF renderer
115
-   *
116
-   * @var Canvas
117
-   */
118
-  protected $_pdf;
119
-
120
-  /**
121
-   * Desired paper size ('letter', 'legal', 'A4', etc.)
122
-   *
123
-   * @var string
124
-   */
125
-  protected $_paper_size;
126
-
127
-  /**
128
-   * Paper orientation ('portrait' or 'landscape')
129
-   *
130
-   * @var string
131
-   */
132
-  protected $_paper_orientation;
133
-
134
-  /**
135
-   * Callbacks on new page and new element
136
-   *
137
-   * @var array
138
-   */
139
-  protected $_callbacks;
140
-
141
-  /**
142
-   * Experimental caching capability
143
-   *
144
-   * @var string
145
-   */
146
-  private $_cache_id;
147
-
148
-  /**
149
-   * Base hostname
150
-   *
151
-   * Used for relative paths/urls
152
-   * @var string
153
-   */
154
-  protected $_base_host;
155
-
156
-  /**
157
-   * Absolute base path
158
-   *
159
-   * Used for relative paths/urls
160
-   * @var string
161
-   */
162
-  protected $_base_path;
163
-
164
-  /**
165
-   * Protcol used to request file (file://, http://, etc)
166
-   *
167
-   * @var string
168
-   */
169
-  protected $_protocol;
170
-
171
-
172
-  /**
173
-   * Class constructor
174
-   */
175
-  function __construct() {
91
+    /**
92
+     * DomDocument representing the HTML document
93
+     *
94
+     * @var DomDocument
95
+     */
96
+    protected $_xml;
97
+
98
+    /**
99
+     * Frame_Tree derived from the DOM tree
100
+     *
101
+     * @var Frame_Tree
102
+     */
103
+    protected $_tree;
104
+
105
+    /**
106
+     * Stylesheet for the document
107
+     *
108
+     * @var Stylesheet
109
+     */
110
+    protected $_css;
111
+
112
+    /**
113
+     * Actual PDF renderer
114
+     *
115
+     * @var Canvas
116
+     */
117
+    protected $_pdf;
118
+
119
+    /**
120
+     * Desired paper size ('letter', 'legal', 'A4', etc.)
121
+     *
122
+     * @var string
123
+     */
124
+    protected $_paper_size;
125
+
126
+    /**
127
+     * Paper orientation ('portrait' or 'landscape')
128
+     *
129
+     * @var string
130
+     */
131
+    protected $_paper_orientation;
132
+
133
+    /**
134
+     * Callbacks on new page and new element
135
+     *
136
+     * @var array
137
+     */
138
+    protected $_callbacks;
139
+
140
+    /**
141
+     * Experimental caching capability
142
+     *
143
+     * @var string
144
+     */
145
+    private $_cache_id;
146
+
147
+    /**
148
+     * Base hostname
149
+     *
150
+     * Used for relative paths/urls
151
+     * @var string
152
+     */
153
+    protected $_base_host;
154
+
155
+    /**
156
+     * Absolute base path
157
+     *
158
+     * Used for relative paths/urls
159
+     * @var string
160
+     */
161
+    protected $_base_path;
162
+
163
+    /**
164
+     * Protcol used to request file (file://, http://, etc)
165
+     *
166
+     * @var string
167
+     */
168
+    protected $_protocol;
169
+
170
+
171
+    /**
172
+     * Class constructor
173
+     */
174
+    function __construct() {
176 175
     $this->_messages = array();
177 176
     $this->_xml = new DOMDocument();
178 177
     $this->_xml->preserveWhiteSpace = true;
@@ -186,203 +185,203 @@  discard block
 block discarded – undo
186 185
     $this->_base_path = "";
187 186
     $this->_callbacks = array();
188 187
     $this->_cache_id = null;
189
-  }
190
-
191
-  /**
192
-   * Returns the underlying {@link Frame_Tree} object
193
-   *
194
-   * @return Frame_Tree
195
-   */
196
-  function get_tree() { return $this->_tree; }
197
-
198
-  //........................................................................
199
-
200
-  /**
201
-   * Sets the protocol to use
202
-   *
203
-   * @param string $proto
204
-   */
205
-  // FIXME: validate these
206
-  function set_protocol($proto) { $this->_protocol = $proto; }
207
-
208
-  /**
209
-   * Sets the base hostname
210
-   *
211
-   * @param string $host
212
-   */
213
-  function set_host($host) { $this->_base_host = $host; }
214
-
215
-  /**
216
-   * Sets the base path
217
-   *
218
-   * @param string $path
219
-   */
220
-  function set_base_path($path) { $this->_base_path = $path; }
221
-
222
-  /**
223
-   * Returns the protocol in use
224
-   *
225
-   * @return string
226
-   */
227
-  function get_protocol() { return $this->_protocol; }
228
-
229
-  /**
230
-   * Returns the base hostname
231
-   *
232
-   * @return string
233
-   */
234
-  function get_host() { return $this->_base_host; }
235
-
236
-  /**
237
-   * Returns the base path
238
-   *
239
-   * @return string
240
-   */
241
-  function get_base_path() { return $this->_base_path; }
242
-
243
-  /**
244
-   * Return the underlying Canvas instance (e.g. CPDF_Adapter, GD_Adapter)
245
-   *
246
-   * @return Canvas
247
-   */
248
-  function get_canvas() { return $this->_pdf; }
249
-
250
-  /**
251
-   * Returns the callbacks array
252
-   *
253
-   * @return array
254
-   */
255
-  function get_callbacks() { return $this->_callbacks; }
188
+    }
189
+
190
+    /**
191
+     * Returns the underlying {@link Frame_Tree} object
192
+     *
193
+     * @return Frame_Tree
194
+     */
195
+    function get_tree() { return $this->_tree; }
196
+
197
+    //........................................................................
198
+
199
+    /**
200
+     * Sets the protocol to use
201
+     *
202
+     * @param string $proto
203
+     */
204
+    // FIXME: validate these
205
+    function set_protocol($proto) { $this->_protocol = $proto; }
206
+
207
+    /**
208
+     * Sets the base hostname
209
+     *
210
+     * @param string $host
211
+     */
212
+    function set_host($host) { $this->_base_host = $host; }
213
+
214
+    /**
215
+     * Sets the base path
216
+     *
217
+     * @param string $path
218
+     */
219
+    function set_base_path($path) { $this->_base_path = $path; }
220
+
221
+    /**
222
+     * Returns the protocol in use
223
+     *
224
+     * @return string
225
+     */
226
+    function get_protocol() { return $this->_protocol; }
227
+
228
+    /**
229
+     * Returns the base hostname
230
+     *
231
+     * @return string
232
+     */
233
+    function get_host() { return $this->_base_host; }
234
+
235
+    /**
236
+     * Returns the base path
237
+     *
238
+     * @return string
239
+     */
240
+    function get_base_path() { return $this->_base_path; }
241
+
242
+    /**
243
+     * Return the underlying Canvas instance (e.g. CPDF_Adapter, GD_Adapter)
244
+     *
245
+     * @return Canvas
246
+     */
247
+    function get_canvas() { return $this->_pdf; }
248
+
249
+    /**
250
+     * Returns the callbacks array
251
+     *
252
+     * @return array
253
+     */
254
+    function get_callbacks() { return $this->_callbacks; }
256 255
   
257
-  //........................................................................
258
-
259
-  /**
260
-   * Loads an HTML file
261
-   *
262
-   * Parse errors are stored in the global array _dompdf_warnings.
263
-   *
264
-   * @param string $file a filename or url to load
265
-   */
266
-  function load_html_file($file) {
256
+    //........................................................................
257
+
258
+    /**
259
+     * Loads an HTML file
260
+     *
261
+     * Parse errors are stored in the global array _dompdf_warnings.
262
+     *
263
+     * @param string $file a filename or url to load
264
+     */
265
+    function load_html_file($file) {
267 266
     // Store parsing warnings as messages (this is to prevent output to the
268 267
     // browser if the html is ugly and the dom extension complains,
269 268
     // preventing the pdf from being streamed.)
270 269
     if ( !$this->_protocol && !$this->_base_host && !$this->_base_path )
271
-      list($this->_protocol, $this->_base_host, $this->_base_path) = explode_url($file);
270
+        list($this->_protocol, $this->_base_host, $this->_base_path) = explode_url($file);
272 271
 
273 272
     if ( !DOMPDF_ENABLE_REMOTE &&
274 273
          ($this->_protocol != "" && $this->_protocol !== "file://" ) )
275
-      throw new DOMPDF_Exception("Remote file requested, but DOMPDF_ENABLE_REMOTE is false.");
274
+        throw new DOMPDF_Exception("Remote file requested, but DOMPDF_ENABLE_REMOTE is false.");
276 275
 
277 276
     if ($this->_protocol == "" || $this->_protocol === "file://") {
278 277
 
279
-      $realfile = realpath($file);
280
-      if ( !$file )
278
+        $realfile = realpath($file);
279
+        if ( !$file )
281 280
         throw new DOMPDF_Exception("File '$file' not found.");
282 281
 
283
-      if ( strpos($realfile, DOMPDF_CHROOT) !== 0 )
282
+        if ( strpos($realfile, DOMPDF_CHROOT) !== 0 )
284 283
         throw new DOMPDF_Exception("Permission denied on $file.");
285 284
 
286
-      // Exclude dot files (e.g. .htaccess)
287
-      if ( substr(basename($realfile),0,1) === "." )
285
+        // Exclude dot files (e.g. .htaccess)
286
+        if ( substr(basename($realfile),0,1) === "." )
288 287
         throw new DOMPDF_Exception("Permission denied on $file.");
289 288
 
290
-      $file = $realfile;
289
+        $file = $realfile;
291 290
     }
292 291
 
293 292
     $this->load_html(file_get_contents($file));
294
-  }
295
-
296
-  /**
297
-   * Loads an HTML string
298
-   *
299
-   * Parse errors are stored in the global array _dompdf_warnings.
300
-   *
301
-   * @param string $str HTML text to load
302
-   */
303
-  function load_html($str) {
293
+    }
294
+
295
+    /**
296
+     * Loads an HTML string
297
+     *
298
+     * Parse errors are stored in the global array _dompdf_warnings.
299
+     *
300
+     * @param string $str HTML text to load
301
+     */
302
+    function load_html($str) {
304 303
     // FIXME: Determine character encoding, switch to UTF8, update meta tag. Need better http/file stream encoding detection, currently relies on text or meta tag.
305 304
     mb_detect_order('auto');
306 305
     if (mb_detect_encoding($str) != 'UTF-8') {
307
-      if (mb_detect_encoding($str) == '') {
306
+        if (mb_detect_encoding($str) == '') {
308 307
         if (preg_match('@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s*?charset=([^\s"]+))?@i',$str,$matches)) {
309
-          $encoding = strtoupper($matches[3]);
308
+            $encoding = strtoupper($matches[3]);
310 309
         } else {
311
-          $encoding = 'UTF-8';
310
+            $encoding = 'UTF-8';
312 311
         }
313
-      } else {
312
+        } else {
314 313
         if (preg_match('@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s*?charset=([^\s"]+))?@i',$str,$matches)) {
315
-          $encoding = strtoupper($matches[3]);
314
+            $encoding = strtoupper($matches[3]);
316 315
         } else {
317
-          $encoding = 'auto';
316
+            $encoding = 'auto';
317
+        }
318 318
         }
319
-      }
320
-      if ($encoding != 'UTF-8') { $str = mb_convert_encoding($str, 'UTF-8', $encoding); }
321
-      if (preg_match('@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s+charset=([^\s"]+))?@i',$str,$matches)) {
319
+        if ($encoding != 'UTF-8') { $str = mb_convert_encoding($str, 'UTF-8', $encoding); }
320
+        if (preg_match('@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s+charset=([^\s"]+))?@i',$str,$matches)) {
322 321
         $str = preg_replace('/charset=([^\s"]+)/i','charset=UTF-8',$str);
323
-      } else {
322
+        } else {
324 323
         $str = str_replace('<head>', '<head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">', $str);
325
-      }
324
+        }
326 325
     }
327 326
 
328 327
     // Parse embedded php, first-pass
329 328
     if ( DOMPDF_ENABLE_PHP ) {
330
-      ob_start();
331
-      eval("?" . ">$str");
332
-      $str = ob_get_contents();
333
-      ob_end_clean();
329
+        ob_start();
330
+        eval("?" . ">$str");
331
+        $str = ob_get_contents();
332
+        ob_end_clean();
334 333
     }
335 334
 
336 335
     // Store parsing warnings as messages
337 336
     set_error_handler("record_warnings");
338 337
     $this->_xml->loadHTML($str);
339 338
     restore_error_handler();
340
-  }
339
+    }
341 340
 
342
-  /**
343
-   * Builds the {@link Frame_Tree}, loads any CSS and applies the styles to
344
-   * the {@link Frame_Tree}
345
-   */
346
-  protected function _process_html() {
341
+    /**
342
+     * Builds the {@link Frame_Tree}, loads any CSS and applies the styles to
343
+     * the {@link Frame_Tree}
344
+     */
345
+    protected function _process_html() {
347 346
     $this->_tree->build_tree();
348 347
 
349 348
     $this->_css->load_css_file(Stylesheet::DEFAULT_STYLESHEET);
350 349
 
351 350
     $acceptedmedia = Stylesheet::$ACCEPTED_GENERIC_MEDIA_TYPES;
352 351
     if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) {
353
-      $acceptedmedia[] = DOMPDF_DEFAULT_MEDIA_TYPE;
352
+        $acceptedmedia[] = DOMPDF_DEFAULT_MEDIA_TYPE;
354 353
     } else {
355
-      $acceptedmedia[] = Stylesheet::$ACCEPTED_DEFAULT_MEDIA_TYPE;
354
+        $acceptedmedia[] = Stylesheet::$ACCEPTED_DEFAULT_MEDIA_TYPE;
356 355
     }
357 356
           
358 357
     // load <link rel="STYLESHEET" ... /> tags
359 358
     $links = $this->_xml->getElementsByTagName("link");
360 359
     foreach ($links as $link) {
361
-      if ( mb_strtolower($link->getAttribute("rel")) === "stylesheet" ||
360
+        if ( mb_strtolower($link->getAttribute("rel")) === "stylesheet" ||
362 361
            mb_strtolower($link->getAttribute("type")) === "text/css" ) {
363 362
         //Check if the css file is for an accepted media type
364 363
         //media not given then always valid
365 364
         $formedialist = preg_split("/[\s\n,]/", $link->getAttribute("media"),-1, PREG_SPLIT_NO_EMPTY);
366 365
         if ( count($formedialist) > 0 ) {
367
-          $accept = false;
368
-          foreach ( $formedialist as $type ) {
366
+            $accept = false;
367
+            foreach ( $formedialist as $type ) {
369 368
             if ( in_array(mb_strtolower(trim($type)), $acceptedmedia) ) {
370
-              $accept = true;
371
-              break;
369
+                $accept = true;
370
+                break;
371
+            }
372 372
             }
373
-          }
374
-          if (!$accept) {
373
+            if (!$accept) {
375 374
             //found at least one mediatype, but none of the accepted ones
376 375
             //Skip this css file.
377 376
             continue;
378
-          }
377
+            }
379 378
         }
380 379
            
381 380
         $url = $link->getAttribute("href");
382 381
         $url = build_url($this->_protocol, $this->_base_host, $this->_base_path, $url);
383 382
 
384 383
         $this->_css->load_css_file($url);
385
-      }
384
+        }
386 385
 
387 386
     }
388 387
 
@@ -390,94 +389,94 @@  discard block
 block discarded – undo
390 389
     $styles = $this->_xml->getElementsByTagName("style");
391 390
     foreach ($styles as $style) {
392 391
 
393
-      // Accept all <style> tags by default (note this is contrary to W3C
394
-      // HTML 4.0 spec:
395
-      // http://www.w3.org/TR/REC-html40/present/styles.html#adef-media
396
-      // which states that the default media type is 'screen'
397
-      if ( $style->hasAttributes() &&
392
+        // Accept all <style> tags by default (note this is contrary to W3C
393
+        // HTML 4.0 spec:
394
+        // http://www.w3.org/TR/REC-html40/present/styles.html#adef-media
395
+        // which states that the default media type is 'screen'
396
+        if ( $style->hasAttributes() &&
398 397
            ($media = $style->getAttribute("media")) &&
399 398
            !in_array($media, $acceptedmedia) )
400 399
         continue;
401 400
 
402
-      $css = "";
403
-      if ( $style->hasChildNodes() ) {
401
+        $css = "";
402
+        if ( $style->hasChildNodes() ) {
404 403
 
405 404
         $child = $style->firstChild;
406 405
         while ( $child ) {
407
-          $css .= $child->nodeValue; // Handle <style><!-- blah --></style>
408
-          $child = $child->nextSibling;
406
+            $css .= $child->nodeValue; // Handle <style><!-- blah --></style>
407
+            $child = $child->nextSibling;
409 408
         }
410 409
 
411
-      } else
410
+        } else
412 411
         $css = $style->nodeValue;
413 412
       
414
-      // Set the base path of the Stylesheet to that of the file being processed
415
-      $this->_css->set_protocol($this->_protocol);
416
-      $this->_css->set_host($this->_base_host);
417
-      $this->_css->set_base_path($this->_base_path);
413
+        // Set the base path of the Stylesheet to that of the file being processed
414
+        $this->_css->set_protocol($this->_protocol);
415
+        $this->_css->set_host($this->_base_host);
416
+        $this->_css->set_base_path($this->_base_path);
418 417
 
419
-      $this->_css->load_css($css);
418
+        $this->_css->load_css($css);
420 419
     }
421 420
 
422
-  }
421
+    }
423 422
 
424
-  //........................................................................
423
+    //........................................................................
425 424
 
426
-  /**
427
-   * Sets the paper size & orientation
428
-   *
429
-   * @param string $size 'letter', 'legal', 'A4', etc. {@link CPDF_Adapter::$PAPER_SIZES}
430
-   * @param string $orientation 'portrait' or 'landscape'
431
-   */
432
-  function set_paper($size, $orientation = "portrait") {
425
+    /**
426
+     * Sets the paper size & orientation
427
+     *
428
+     * @param string $size 'letter', 'legal', 'A4', etc. {@link CPDF_Adapter::$PAPER_SIZES}
429
+     * @param string $orientation 'portrait' or 'landscape'
430
+     */
431
+    function set_paper($size, $orientation = "portrait") {
433 432
     $this->_paper_size = $size;
434 433
     $this->_paper_orientation = $orientation;
435
-  }
434
+    }
436 435
 
437
-  //........................................................................
436
+    //........................................................................
438 437
 
439
-  /**
440
-   * Enable experimental caching capability
441
-   * @access private
442
-   */
443
-  function enable_caching($cache_id) {
438
+    /**
439
+     * Enable experimental caching capability
440
+     * @access private
441
+     */
442
+    function enable_caching($cache_id) {
444 443
     $this->_cache_id = $cache_id;
445
-  }
446
-
447
-  //........................................................................
448
-
449
-  /**
450
-   * Sets callbacks for events like rendering of pages and elements.
451
-   * The callbacks array contains arrays with 'event' set to 'begin_page',
452
-   * 'end_page', 'begin_frame', or 'end_frame' and 'f' set to a function or
453
-   * object plus method to be called.
454
-   *
455
-   * The function 'f' must take an array as argument, which contains info
456
-   * about the event.
457
-   *
458
-   * @param array $callbacks the set of callbacks to set
459
-   */
460
-  function set_callbacks($callbacks) {
444
+    }
445
+
446
+    //........................................................................
447
+
448
+    /**
449
+     * Sets callbacks for events like rendering of pages and elements.
450
+     * The callbacks array contains arrays with 'event' set to 'begin_page',
451
+     * 'end_page', 'begin_frame', or 'end_frame' and 'f' set to a function or
452
+     * object plus method to be called.
453
+     *
454
+     * The function 'f' must take an array as argument, which contains info
455
+     * about the event.
456
+     *
457
+     * @param array $callbacks the set of callbacks to set
458
+     */
459
+    function set_callbacks($callbacks) {
461 460
     if (is_array($callbacks)) {
462
-      $this->_callbacks = array();
463
-      foreach ($callbacks as $c) {
461
+        $this->_callbacks = array();
462
+        foreach ($callbacks as $c) {
464 463
         if (is_array($c) && isset($c['event']) && isset($c['f'])) {
465
-          $event = $c['event'];
466
-          $f = $c['f'];
467
-          if (is_callable($f) && is_string($event)) {
464
+            $event = $c['event'];
465
+            $f = $c['f'];
466
+            if (is_callable($f) && is_string($event)) {
468 467
             $this->_callbacks[$event][] = $f;
469
-          }
468
+            }
469
+        }
470 470
         }
471
-      }
472 471
     }
473
-  }
472
+    }
474 473
   
475
-  //........................................................................
474
+    //........................................................................
476 475
 
477
-  /**
478
-   * Renders the HTML to PDF
479
-   */
480
-  function render() {
476
+    /**
477
+     * Renders the HTML to PDF
478
+     */
479
+    function render() {
481 480
 
482 481
     //enable_mem_profile();
483 482
 
@@ -488,19 +487,19 @@  discard block
 block discarded – undo
488 487
     $root = null;
489 488
 
490 489
     foreach ($this->_tree->get_frames() as $frame) {
491
-      // Set up the root frame
490
+        // Set up the root frame
492 491
 
493
-      if ( is_null($root) ) {
492
+        if ( is_null($root) ) {
494 493
         $root = Frame_Factory::decorate_root( $this->_tree->get_root(), $this );
495 494
         continue;
496
-      }
495
+        }
497 496
 
498
-      // Create the appropriate decorators, reflowers & positioners.
499
-      $deco = Frame_Factory::decorate_frame($frame, $this);
500
-      $deco->set_root($root);
497
+        // Create the appropriate decorators, reflowers & positioners.
498
+        $deco = Frame_Factory::decorate_frame($frame, $this);
499
+        $deco->set_root($root);
501 500
 
502
-      // FIXME: handle generated content
503
-      if ( $frame->get_style()->display === "list-item" ) {
501
+        // FIXME: handle generated content
502
+        if ( $frame->get_style()->display === "list-item" ) {
504 503
 
505 504
         // Insert a list-bullet frame
506 505
         $node = $this->_xml->createElement("bullet"); // arbitrary choice
@@ -512,7 +511,7 @@  discard block
 block discarded – undo
512 511
         $b_f->set_style($style);
513 512
 
514 513
         $deco->prepend_child( Frame_Factory::decorate_frame($b_f, $this) );
515
-      }
514
+        }
516 515
 
517 516
     }
518 517
 
@@ -529,83 +528,83 @@  discard block
 block discarded – undo
529 528
     
530 529
     global $_dompdf_warnings, $_dompdf_show_warnings;
531 530
     if ( $_dompdf_show_warnings ) {
532
-      echo '<b>DOMPDF Warnings</b><br><pre>';
533
-      foreach ($_dompdf_warnings as $msg)
531
+        echo '<b>DOMPDF Warnings</b><br><pre>';
532
+        foreach ($_dompdf_warnings as $msg)
534 533
         echo $msg . "\n";
535
-      echo $this->get_canvas()->get_cpdf()->messages;
536
-      echo '</pre>';
537
-      flush();
534
+        echo $this->get_canvas()->get_cpdf()->messages;
535
+        echo '</pre>';
536
+        flush();
537
+    }
538 538
     }
539
-  }
540 539
 
541
-  //........................................................................
540
+    //........................................................................
542 541
 
543
-  /**
544
-   * Add meta information to the PDF after rendering
545
-   */
546
-  function add_info($label, $value) {
542
+    /**
543
+     * Add meta information to the PDF after rendering
544
+     */
545
+    function add_info($label, $value) {
547 546
     if (!is_null($this->_pdf))
548
-      $this->_pdf->add_info($label, $value);
549
-  }
547
+        $this->_pdf->add_info($label, $value);
548
+    }
550 549
   
551
-  //........................................................................
552
-
553
-  /**
554
-   * Streams the PDF to the client
555
-   *
556
-   * The file will open a download dialog by default.  The options
557
-   * parameter controls the output.  Accepted options are:
558
-   *
559
-   * 'Accept-Ranges' => 1 or 0 - if this is not set to 1, then this
560
-   *    header is not included, off by default this header seems to
561
-   *    have caused some problems despite the fact that it is supposed
562
-   *    to solve them, so I am leaving it off by default.
563
-   *
564
-   * 'compress' = > 1 or 0 - apply content stream compression, this is
565
-   *    on (1) by default
566
-   *
567
-   * 'Attachment' => 1 or 0 - if 1, force the browser to open a
568
-   *    download dialog, on (1) by default
569
-   *
570
-   * @param string $filename the name of the streamed file
571
-   * @param array  $options header options (see above)
572
-   */
573
-  function stream($filename, $options = null) {
550
+    //........................................................................
551
+
552
+    /**
553
+     * Streams the PDF to the client
554
+     *
555
+     * The file will open a download dialog by default.  The options
556
+     * parameter controls the output.  Accepted options are:
557
+     *
558
+     * 'Accept-Ranges' => 1 or 0 - if this is not set to 1, then this
559
+     *    header is not included, off by default this header seems to
560
+     *    have caused some problems despite the fact that it is supposed
561
+     *    to solve them, so I am leaving it off by default.
562
+     *
563
+     * 'compress' = > 1 or 0 - apply content stream compression, this is
564
+     *    on (1) by default
565
+     *
566
+     * 'Attachment' => 1 or 0 - if 1, force the browser to open a
567
+     *    download dialog, on (1) by default
568
+     *
569
+     * @param string $filename the name of the streamed file
570
+     * @param array  $options header options (see above)
571
+     */
572
+    function stream($filename, $options = null) {
574 573
     if (!is_null($this->_pdf))
575
-      $this->_pdf->stream($filename, $options);
576
-  }
577
-
578
-  /**
579
-   * Returns the PDF as a string
580
-   *
581
-   * The file will open a download dialog by default.  The options
582
-   * parameter controls the output.  Accepted options are:
583
-   *
584
-   *
585
-   * 'compress' = > 1 or 0 - apply content stream compression, this is
586
-   *    on (1) by default
587
-   *
588
-   *
589
-   * @param array  $options options (see above)
590
-   * @return string
591
-   */
592
-  function output($options = null) {
574
+        $this->_pdf->stream($filename, $options);
575
+    }
576
+
577
+    /**
578
+     * Returns the PDF as a string
579
+     *
580
+     * The file will open a download dialog by default.  The options
581
+     * parameter controls the output.  Accepted options are:
582
+     *
583
+     *
584
+     * 'compress' = > 1 or 0 - apply content stream compression, this is
585
+     *    on (1) by default
586
+     *
587
+     *
588
+     * @param array  $options options (see above)
589
+     * @return string
590
+     */
591
+    function output($options = null) {
593 592
 
594 593
     if ( is_null($this->_pdf) )
595
-      return null;
594
+        return null;
596 595
 
597 596
     return $this->_pdf->output( $options );
598
-  }
597
+    }
599 598
 
600 599
 
601
-  /**
602
-   * Returns the underlying HTML document as a string
603
-   *
604
-   * @return string
605
-   */
606
-  function output_html() {
600
+    /**
601
+     * Returns the underlying HTML document as a string
602
+     *
603
+     * @return string
604
+     */
605
+    function output_html() {
607 606
     return $this->_xml->saveHTML();
608
-  }
609
-  //........................................................................
607
+    }
608
+    //........................................................................
610 609
 
611 610
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/table_row_frame_decorator.cls.php 1 patch
Indentation   +13 added lines, -14 removed lines patch added patch discarded remove patch
@@ -34,7 +34,6 @@  discard block
 block discarded – undo
34 34
  * @copyright 2004 Benj Carson
35 35
  * @author Benj Carson <[email protected]>
36 36
  * @package dompdf
37
-
38 37
  */
39 38
 
40 39
 /* $Id: table_row_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -47,35 +46,35 @@  discard block
 block discarded – undo
47 46
  */
48 47
 class Table_Row_Frame_Decorator extends Frame_Decorator {
49 48
 
50
-  // protected members
49
+    // protected members
51 50
   
52
-  function __construct(Frame $frame, DOMPDF $dompdf) {
51
+    function __construct(Frame $frame, DOMPDF $dompdf) {
53 52
     parent::__construct($frame, $dompdf);
54
-  }
53
+    }
55 54
   
56
-  //........................................................................ 
55
+    //........................................................................ 
57 56
 
58
-  /**
59
-   * Remove all non table-cell frames from this row and move them after
60
-   * the table.
61
-   */
62
-  function normalise() {
57
+    /**
58
+     * Remove all non table-cell frames from this row and move them after
59
+     * the table.
60
+     */
61
+    function normalise() {
63 62
 
64 63
     // Find our table parent
65 64
     $p = Table_Frame_Decorator::find_parent_table($this);
66 65
     
67 66
     $erroneous_frames = array();
68 67
     foreach ($this->get_children() as $child) {      
69
-      $display = $child->get_style()->display;
68
+        $display = $child->get_style()->display;
70 69
 
71
-      if ( $display !== "table-cell" )
70
+        if ( $display !== "table-cell" )
72 71
         $erroneous_frames[] = $child;
73 72
     }
74 73
     
75 74
     //  dump the extra nodes after the table.
76 75
     foreach ($erroneous_frames as $frame) 
77
-      $p->move_after($frame);
78
-  }
76
+        $p->move_after($frame);
77
+    }
79 78
   
80 79
   
81 80
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/block_frame_reflower.cls.php 1 patch
Indentation   +172 added lines, -173 removed lines patch added patch discarded remove patch
@@ -34,7 +34,6 @@  discard block
 block discarded – undo
34 34
  * @copyright 2004 Benj Carson
35 35
  * @author Benj Carson <[email protected]>
36 36
  * @package dompdf
37
-
38 37
  */
39 38
 
40 39
 /* $Id: block_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -46,17 +45,17 @@  discard block
 block discarded – undo
46 45
  * @package dompdf
47 46
  */
48 47
 class Block_Frame_Reflower extends Frame_Reflower {
49
-  const MIN_JUSTIFY_WIDTH = 0.80;  // (Minimum line width to justify, as
50
-                                   // fraction of available width)
48
+    const MIN_JUSTIFY_WIDTH = 0.80;  // (Minimum line width to justify, as
49
+                                    // fraction of available width)
51 50
 
52
-  function __construct(Block_Frame_Decorator $frame) { parent::__construct($frame); }
51
+    function __construct(Block_Frame_Decorator $frame) { parent::__construct($frame); }
53 52
 
54
-  //........................................................................
53
+    //........................................................................
55 54
 
56
-  // Calculate the ideal used value for the width property as per:
57
-  // http://www.w3.org/TR/CSS21/visudet.html#Computing_widths_and_margins
55
+    // Calculate the ideal used value for the width property as per:
56
+    // http://www.w3.org/TR/CSS21/visudet.html#Computing_widths_and_margins
58 57
 
59
-  protected function _calculate_width($width) {
58
+    protected function _calculate_width($width) {
60 59
     $style = $this->_frame->get_style();
61 60
     $w = $this->_frame->get_containing_block("w");
62 61
 
@@ -68,20 +67,20 @@  discard block
 block discarded – undo
68 67
     
69 68
     // Handle 'auto' values
70 69
     $dims = array($style->border_left_width,
71
-                  $style->border_right_width,
72
-                  $style->padding_left,
73
-                  $style->padding_right,
74
-                  $width !== "auto" ? $width : 0,
75
-                  $rm !== "auto" ? $rm : 0,
76
-                  $lm !== "auto" ? $lm : 0);
70
+                    $style->border_right_width,
71
+                    $style->padding_left,
72
+                    $style->padding_right,
73
+                    $width !== "auto" ? $width : 0,
74
+                    $rm !== "auto" ? $rm : 0,
75
+                    $lm !== "auto" ? $lm : 0);
77 76
 
78 77
     // absolutely positioned boxes take the 'left' and 'right' properties into account
79 78
     if ( $style->position === "absolute" || $style->position === "fixed" ) {
80
-      $absolute = true;
81
-      $dims[] = $left !== "auto" ? $left : 0;
82
-      $dims[] = $right !== "auto" ? $right : 0;
79
+        $absolute = true;
80
+        $dims[] = $left !== "auto" ? $left : 0;
81
+        $dims[] = $right !== "auto" ? $right : 0;
83 82
     } else {
84
-      $absolute = false;
83
+        $absolute = false;
85 84
     }
86 85
 
87 86
     $sum = $style->length_in_pt($dims, $w);
@@ -91,99 +90,99 @@  discard block
 block discarded – undo
91 90
 
92 91
     if ( $diff > 0 ) {
93 92
 
94
-      if ( $absolute ) {
93
+        if ( $absolute ) {
95 94
 
96 95
         // resolve auto properties: see
97 96
         // http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-width
98 97
 
99 98
         if ( $width === "auto" && $left === "auto" && $right === "auto" ) {
100 99
 
101
-          if ( $lm === "auto" )
100
+            if ( $lm === "auto" )
102 101
             $lm = 0;
103
-          if ( $rm === "auto" )
102
+            if ( $rm === "auto" )
104 103
             $rm = 0;
105 104
 
106
-          // Technically, the width should be "shrink-to-fit" i.e. based on the
107
-          // preferred width of the content...  a little too costly here as a
108
-          // special case.  Just get the width to take up the slack:
109
-          $left = 0;
110
-          $right = 0;
111
-          $width = $diff;
105
+            // Technically, the width should be "shrink-to-fit" i.e. based on the
106
+            // preferred width of the content...  a little too costly here as a
107
+            // special case.  Just get the width to take up the slack:
108
+            $left = 0;
109
+            $right = 0;
110
+            $width = $diff;
112 111
 
113 112
         } else if ( $width === "auto" ) {
114 113
 
115
-          if ( $lm === "auto" )
114
+            if ( $lm === "auto" )
116 115
             $lm = 0;
117
-          if ( $rm === "auto" )
116
+            if ( $rm === "auto" )
118 117
             $rm = 0;
119
-          if ( $left === "auto" )
118
+            if ( $left === "auto" )
120 119
             $left = 0;
121
-          if ( $right === "auto" )
120
+            if ( $right === "auto" )
122 121
             $right = 0;
123 122
 
124
-          $width = $diff;
123
+            $width = $diff;
125 124
 
126 125
         } else if ( $left === "auto" ) {
127
-          if ( $lm === "auto" )
126
+            if ( $lm === "auto" )
128 127
             $lm = 0;
129
-          if ( $rm === "auto" )
128
+            if ( $rm === "auto" )
130 129
             $rm = 0;
131
-          if ( $right === "auto" )
130
+            if ( $right === "auto" )
132 131
             $right = 0;
133 132
 
134
-          $left = $diff;
133
+            $left = $diff;
135 134
 
136 135
         } else if ( $right === "auto" ) {
137 136
 
138
-          if ( $lm === "auto" )
137
+            if ( $lm === "auto" )
139 138
             $lm = 0;
140
-          if ( $rm === "auto" )
139
+            if ( $rm === "auto" )
141 140
             $rm = 0;
142 141
 
143
-          $right = $diff;
142
+            $right = $diff;
144 143
         }
145 144
 
146
-      } else {
145
+        } else {
147 146
 
148 147
         // Find auto properties and get them to take up the slack
149 148
         if ( $width === "auto" )
150
-          $width = $diff;
149
+            $width = $diff;
151 150
 
152 151
         else if ( $lm === "auto" && $rm === "auto" )
153
-          $lm = $rm = round($diff / 2);
152
+            $lm = $rm = round($diff / 2);
154 153
 
155 154
         else if ( $lm === "auto" )
156
-          $lm = $diff;
155
+            $lm = $diff;
157 156
 
158 157
         else if ( $rm === "auto" )
159
-          $rm = $diff;
160
-      }
158
+            $rm = $diff;
159
+        }
161 160
 
162 161
     } else if ($diff < 0) {
163 162
 
164
-      // We are over constrained--set margin-right to the difference
165
-      $rm = $diff;
163
+        // We are over constrained--set margin-right to the difference
164
+        $rm = $diff;
166 165
 
167 166
     }
168 167
 
169 168
     $ret = array("width"=> $width, "margin_left" => $lm, "margin_right" => $rm, "left" => $left, "right" => $right);
170 169
 
171 170
     return $ret;
172
-  }
171
+    }
173 172
 
174
-  // Call the above function, but resolve max/min widths
175
-  protected function _calculate_restricted_width() {
173
+    // Call the above function, but resolve max/min widths
174
+    protected function _calculate_restricted_width() {
176 175
     $style = $this->_frame->get_style();
177 176
     $cb = $this->_frame->get_containing_block();
178 177
 
179 178
     if ( !isset($cb["w"]) )
180
-      throw new DOMPDF_Exception("Box property calculation requires containing block width");
179
+        throw new DOMPDF_Exception("Box property calculation requires containing block width");
181 180
 
182 181
     // Treat width 100% as auto
183 182
     if ( $style->width === "100%" )
184
-      $width = "auto";
183
+        $width = "auto";
185 184
     else
186
-      $width = $style->length_in_pt($style->width, $cb["w"]);
185
+        $width = $style->length_in_pt($style->width, $cb["w"]);
187 186
 
188 187
     extract($this->_calculate_width($width));
189 188
 
@@ -192,37 +191,37 @@  discard block
 block discarded – undo
192 191
     $max_width = $style->length_in_pt($style->max_width, $cb["w"]);
193 192
 
194 193
     if ( $max_width !== "none" && $min_width > $max_width)
195
-      // Swap 'em
196
-      list($max_width, $min_width) = array($min_width, $max_width);
194
+        // Swap 'em
195
+        list($max_width, $min_width) = array($min_width, $max_width);
197 196
 
198 197
     if ( $max_width !== "none" && $width > $max_width )
199
-      extract($this->_calculate_width($max_width));
198
+        extract($this->_calculate_width($max_width));
200 199
 
201 200
     if ( $width < $min_width )
202
-      extract($this->_calculate_width($min_width));
201
+        extract($this->_calculate_width($min_width));
203 202
 
204 203
     return array($width, $margin_left, $margin_right, $left, $right);
205 204
 
206
-  }
205
+    }
207 206
 
208
-  //........................................................................
207
+    //........................................................................
209 208
 
210
-  // Determine the unrestricted height of content within the block
211
-  protected function _calculate_content_height() {
209
+    // Determine the unrestricted height of content within the block
210
+    protected function _calculate_content_height() {
212 211
 
213 212
     // Calculate the actual height
214 213
     $height = 0;
215 214
     
216 215
     // Add the height of all lines
217 216
     foreach ($this->_frame->get_lines() as $line)
218
-      $height += $line["h"];
217
+        $height += $line["h"];
219 218
 
220 219
     return $height;
221 220
 
222
-  }
221
+    }
223 222
 
224
-  // Determine the frame's restricted height
225
-  protected function _calculate_restricted_height() {
223
+    // Determine the frame's restricted height
224
+    protected function _calculate_restricted_height() {
226 225
     $style = $this->_frame->get_style();
227 226
     $content_height = $this->_calculate_content_height();
228 227
     $cb = $this->_frame->get_containing_block();
@@ -237,9 +236,9 @@  discard block
 block discarded – undo
237 236
 
238 237
     if ( $style->position === "absolute" || $style->position === "fixed" ) {
239 238
 
240
-      // see http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-height
239
+        // see http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-height
241 240
 
242
-      $dims = array($top !== "auto" ? $top : 0,
241
+        $dims = array($top !== "auto" ? $top : 0,
243 242
                     $style->margin_top !== "auto" ? $style->margin_top : 0,
244 243
                     $style->padding_top,
245 244
                     $style->border_top_width,
@@ -249,153 +248,153 @@  discard block
 block discarded – undo
249 248
                     $style->margin_bottom !== "auto" ? $style->margin_bottom : 0,
250 249
                     $bottom !== "auto" ? $bottom : 0);
251 250
 
252
-      $sum = $style->length_in_pt($dims, $cb["h"]);
251
+        $sum = $style->length_in_pt($dims, $cb["h"]);
253 252
 
254
-      $diff = $cb["h"] - $sum; 
253
+        $diff = $cb["h"] - $sum; 
255 254
 
256
-      if ( $diff > 0 ) {
255
+        if ( $diff > 0 ) {
257 256
 
258 257
         if ( $height === "auto" && $top === "auto" && $bottom === "auto" ) {
259 258
 
260
-          if ( $margin_top === "auto" ) 
259
+            if ( $margin_top === "auto" ) 
261 260
             $margin_top = 0;
262
-          if ( $margin_bottom === "auto" )
261
+            if ( $margin_bottom === "auto" )
263 262
             $margin_bottom = 0;
264 263
 
265
-          $height = $diff;
264
+            $height = $diff;
266 265
 
267 266
         } else if ( $height === "auto" && $top === "auto" ) {
268 267
 
269
-          if ( $margin_top === "auto" ) 
268
+            if ( $margin_top === "auto" ) 
270 269
             $margin_top = 0;
271
-          if ( $margin_bottom === "auto" )
270
+            if ( $margin_bottom === "auto" )
272 271
             $margin_bottom = 0;
273 272
 
274
-          $height = $content_height;
275
-          $top = $diff - $content_height;
273
+            $height = $content_height;
274
+            $top = $diff - $content_height;
276 275
 
277 276
         } else if ( $height === "auto" && $bottom === "auto" ) {
278 277
 
279
-          if ( $margin_top === "auto" ) 
278
+            if ( $margin_top === "auto" ) 
280 279
             $margin_top = 0;
281
-          if ( $margin_bottom === "auto" )
280
+            if ( $margin_bottom === "auto" )
282 281
             $margin_bottom = 0;
283 282
 
284
-          $height = $content_height;
285
-          $bottom = $diff - $content_height;
283
+            $height = $content_height;
284
+            $bottom = $diff - $content_height;
286 285
 
287 286
         } else if ( $top === "auto" && $bottom === "auto" ) {
288 287
 
289
-          if ( $margin_top === "auto" ) 
288
+            if ( $margin_top === "auto" ) 
290 289
             $margin_top = 0;
291
-          if ( $margin_bottom === "auto" )
290
+            if ( $margin_bottom === "auto" )
292 291
             $margin_bottom = 0;
293 292
 
294
-          $bottom = $diff;
293
+            $bottom = $diff;
295 294
 
296 295
         } else if ( $top === "auto" ) {
297 296
 
298
-          if ( $margin_top === "auto" ) 
297
+            if ( $margin_top === "auto" ) 
299 298
             $margin_top = 0;
300
-          if ( $margin_bottom === "auto" )
299
+            if ( $margin_bottom === "auto" )
301 300
             $margin_bottom = 0;
302 301
 
303
-          $top = $diff;
302
+            $top = $diff;
304 303
 
305 304
         } else if ( $height === "auto" ) {
306 305
 
307
-          if ( $margin_top === "auto" ) 
306
+            if ( $margin_top === "auto" ) 
308 307
             $margin_top = 0;
309
-          if ( $margin_bottom === "auto" )
308
+            if ( $margin_bottom === "auto" )
310 309
             $margin_bottom = 0;
311 310
 
312
-          $height = $diff;
311
+            $height = $diff;
313 312
 
314 313
         } else if ( $bottom === "auto" ) {
315 314
 
316
-          if ( $margin_top === "auto" ) 
315
+            if ( $margin_top === "auto" ) 
317 316
             $margin_top = 0;
318
-          if ( $margin_bottom === "auto" )
317
+            if ( $margin_bottom === "auto" )
319 318
             $margin_bottom = 0;
320 319
 
321
-          $bottom = $diff;
320
+            $bottom = $diff;
322 321
 
323 322
         } else {
324 323
 
325
-          if ( $style->overflow === "visible" ) {
324
+            if ( $style->overflow === "visible" ) {
326 325
 
327 326
             // set all autos to zero
328 327
             if ( $margin_top === "auto" ) 
329
-              $margin_top = 0;
328
+                $margin_top = 0;
330 329
             if ( $margin_bottom === "auto" )
331
-              $margin_bottom = 0;
330
+                $margin_bottom = 0;
332 331
             if ( $top === "auto" )
333
-              $top = 0;
332
+                $top = 0;
334 333
             if ( $bottom === "auto" )
335
-              $bottom = 0;
334
+                $bottom = 0;
336 335
             if ( $height === "auto" )
337
-              $height = $content_height;
336
+                $height = $content_height;
338 337
 
339
-          }
338
+            }
340 339
 
341
-          // FIXME: overflow hidden
340
+            // FIXME: overflow hidden
342 341
         }
343 342
 
344
-      }
343
+        }
345 344
 
346 345
     } else {
347 346
 
348
-      // Expand the height if overflow is visible
349
-      if ( $height == "auto" && $content_height > $height && $style->overflow === "visible" )
347
+        // Expand the height if overflow is visible
348
+        if ( $height == "auto" && $content_height > $height && $style->overflow === "visible" )
350 349
         $height = $content_height;
351 350
 
352
-      // FIXME: this should probably be moved to a seperate function as per
353
-      // _calculate_restricted_width
351
+        // FIXME: this should probably be moved to a seperate function as per
352
+        // _calculate_restricted_width
354 353
       
355
-      // Only handle min/max height if the height is independent of the frame's content
356
-      if ( !($style->overflow === "visible" ||
354
+        // Only handle min/max height if the height is independent of the frame's content
355
+        if ( !($style->overflow === "visible" ||
357 356
              ($style->overflow === "hidden" && $height === "auto")) ) {
358 357
 
359 358
         $min_height = $style->min_height;
360 359
         $max_height = $style->max_height;
361 360
 
362 361
         if ( isset($cb["h"]) ) {
363
-          $min_height = $style->length_in_pt($min_height, $cb["h"]);
364
-          $max_height = $style->length_in_pt($max_height, $cb["h"]);
362
+            $min_height = $style->length_in_pt($min_height, $cb["h"]);
363
+            $max_height = $style->length_in_pt($max_height, $cb["h"]);
365 364
 
366 365
         } else if ( isset($cb["w"]) ) {
367 366
 
368
-          if ( mb_strpos($min_height, "%") !== false )
367
+            if ( mb_strpos($min_height, "%") !== false )
369 368
             $min_height = 0;
370
-          else
369
+            else
371 370
             $min_height = $style->length_in_pt($min_height, $cb["w"]);
372 371
 
373
-          if ( mb_strpos($max_height, "%") !== false )
372
+            if ( mb_strpos($max_height, "%") !== false )
374 373
             $max_height = "none";
375
-          else
374
+            else
376 375
             $max_height = $style->length_in_pt($max_height, $cb["w"]);
377 376
         }
378 377
 
379 378
         if ( $max_height !== "none" && $min_height > $max_height )
380
-          // Swap 'em
381
-          list($max_height, $min_height) = array($min_height, $max_height);
379
+            // Swap 'em
380
+            list($max_height, $min_height) = array($min_height, $max_height);
382 381
 
383 382
         if ( $max_height !== "none" && $height > $max_height )
384
-          $height = $max_height;
383
+            $height = $max_height;
385 384
 
386 385
         if ( $height < $min_height )
387
-          $height = $min_height;
388
-      }
386
+            $height = $min_height;
387
+        }
389 388
 
390 389
     }
391 390
 
392 391
     return array($height, $margin_top, $margin_bottom, $top, $bottom);
393 392
 
394
-  }
393
+    }
395 394
 
396
-  //........................................................................
395
+    //........................................................................
397 396
 
398
-  protected function _text_align() {
397
+    protected function _text_align() {
399 398
     $style = $this->_frame->get_style();
400 399
     $w = $this->_frame->get_containing_block("w");
401 400
     $width = $style->length_in_pt($style->width, $w);
@@ -414,10 +413,10 @@  discard block
 block discarded – undo
414 413
         // Move each child over by $dx
415 414
         $dx = $width - $line["w"];
416 415
         foreach($line["frames"] as $frame)
417
-          $frame->set_position( $frame->get_position("x") + $dx );
416
+            $frame->set_position( $frame->get_position("x") + $dx );
418 417
 
419
-      }
420
-      break;
418
+        }
419
+        break;
421 420
 
422 421
 
423 422
     case "justify":
@@ -426,28 +425,28 @@  discard block
 block discarded – undo
426 425
         // Only set the spacing if the line is long enough.  This is really
427 426
         // just an aesthetic choice ;)
428 427
         if ( $line["w"] > self::MIN_JUSTIFY_WIDTH * $width ) {
429
-          // Set the spacing for each child
430
-          if ( $line["wc"] > 1 )
428
+            // Set the spacing for each child
429
+            if ( $line["wc"] > 1 )
431 430
             $spacing = ($width - $line["w"]) / ($line["wc"] - 1);
432
-          else
431
+            else
433 432
             $spacing = 0;
434 433
 
435
-          $dx = 0;
436
-          foreach($line["frames"] as $frame) {
434
+            $dx = 0;
435
+            foreach($line["frames"] as $frame) {
437 436
             if ( !$frame instanceof Text_Frame_Decorator )
438
-              continue;
437
+                continue;
439 438
 
440 439
             $frame->set_position( $frame->get_position("x") + $dx );
441 440
             $frame->set_text_spacing($spacing);
442 441
             $dx += mb_substr_count($frame->get_text(), " ") * $spacing;
443
-          }
442
+            }
444 443
 
445
-          // The line (should) now occupy the entire width
446
-          $this->_frame->set_line($i, null, $width);
444
+            // The line (should) now occupy the entire width
445
+            $this->_frame->set_line($i, null, $width);
447 446
 
448 447
         }
449
-      }
450
-      break;
448
+        }
449
+        break;
451 450
 
452 451
     case "center":
453 452
     case "centre":
@@ -455,24 +454,24 @@  discard block
 block discarded – undo
455 454
         // Centre each line by moving each frame in the line by:
456 455
         $dx = ($width - $line["w"]) / 2;
457 456
         foreach ($line["frames"] as $frame)
458
-          $frame->set_position( $frame->get_position("x") + $dx );
459
-      }
460
-      break;
457
+            $frame->set_position( $frame->get_position("x") + $dx );
458
+        }
459
+        break;
461 460
     }
462 461
 
463
-  }
464
-  /**
465
-   * Align inline children vertically
466
-   */
467
-  function vertical_align() {
462
+    }
463
+    /**
464
+     * Align inline children vertically
465
+     */
466
+    function vertical_align() {
468 467
     // Align each child vertically after each line is reflowed
469 468
     foreach ( $this->_frame->get_lines() as $i => $line ) {
470 469
 
471
-      foreach ( $line["frames"] as $frame ) {
470
+        foreach ( $line["frames"] as $frame ) {
472 471
         $style = $frame->get_style();
473 472
 
474 473
         if ( $style->display !== "inline" && $style->display !== "text" )
475
-          continue;
474
+            continue;
476 475
 
477 476
         $align = $style->vertical_align;
478 477
 
@@ -482,41 +481,41 @@  discard block
 block discarded – undo
482 481
 
483 482
         case "baseline":
484 483
           $y = $line["y"] + $line["h"] - $frame_h;
485
-          break;
484
+            break;
486 485
 
487 486
         case "middle":
488 487
           $y = $line["y"] + ($line["h"] + $frame_h) / 2;
489
-          break;
488
+            break;
490 489
 
491 490
         case "sub":
492 491
           $y = $line["y"] + 0.9 * $line["h"];
493
-          break;
492
+            break;
494 493
 
495 494
         case "super":
496 495
           $y = $line["y"] + 0.1 * $line["h"];
497
-          break;
496
+            break;
498 497
 
499 498
         case  "text-top":
500 499
         case "top": // Not strictly accurate, but good enough for now
501 500
           $y = $line["y"];
502
-          break;
501
+            break;
503 502
 
504 503
         case "text-bottom":
505 504
         case "bottom":
506 505
           $y = $line["y"] + $line["h"] - $frame_h;
507
-          break;
506
+            break;
508 507
         }
509 508
 
510 509
         $x = $frame->get_position("x");
511 510
         $frame->set_position($x, $y);
512 511
 
513
-      }
512
+        }
513
+    }
514 514
     }
515
-  }
516 515
 
517
-  //........................................................................
516
+    //........................................................................
518 517
 
519
-  function reflow() {
518
+    function reflow() {
520 519
 
521 520
     // Check if a page break is forced
522 521
     $page = $this->_frame->get_root();
@@ -524,7 +523,7 @@  discard block
 block discarded – undo
524 523
 
525 524
     // Bail if the page is full
526 525
     if ( $page->is_full() )
527
-      return;
526
+        return;
528 527
 
529 528
     // Collapse margins if required
530 529
     $this->_collapse_margins();
@@ -553,12 +552,12 @@  discard block
 block discarded – undo
553 552
 
554 553
     // Determine the content edge
555 554
     $top = $style->length_in_pt(array($style->margin_top,
556
-                                      $style->padding_top,
557
-                                      $style->border_top_width), $cb["h"]);
555
+                                        $style->padding_top,
556
+                                        $style->border_top_width), $cb["h"]);
558 557
 
559 558
     $bottom = $style->length_in_pt(array($style->border_bottom_width,
560
-                                         $style->margin_bottom,
561
-                                         $style->padding_bottom), $cb["h"]);
559
+                                            $style->margin_bottom,
560
+                                            $style->padding_bottom), $cb["h"]);
562 561
 
563 562
     $cb_x = $x + $left_margin +
564 563
       $style->length_in_pt($style->border_left_width, $cb["w"]) +
@@ -574,23 +573,23 @@  discard block
 block discarded – undo
574 573
     // Set the containing blocks and reflow each child
575 574
     foreach ( $this->_frame->get_children() as $child ) {
576 575
 
577
-      // Bail out if the page is full
578
-      if ( $page->is_full() )
576
+        // Bail out if the page is full
577
+        if ( $page->is_full() )
579 578
         break;
580 579
       
581
-      $child->set_containing_block($cb_x, $cb_y, $w, $cb_h);
582
-      $child->reflow();
580
+        $child->set_containing_block($cb_x, $cb_y, $w, $cb_h);
581
+        $child->reflow();
583 582
 
584
-      // Don't add the child to the line if a page break has occurred
585
-      if ( $page->check_page_break($child) )
583
+        // Don't add the child to the line if a page break has occurred
584
+        if ( $page->check_page_break($child) )
586 585
         break;
587 586
 
588
-      // If the frame is not absolutely positioned, It's okay to add the frame
589
-      // to the line
590
-      if ( $child->get_style()->position !== "absolute" &&
587
+        // If the frame is not absolutely positioned, It's okay to add the frame
588
+        // to the line
589
+        if ( $child->get_style()->position !== "absolute" &&
591 590
            $child->get_style()->position !== "fixed" ) {
592 591
         $this->_frame->add_frame_to_line( $child );
593
-      }
592
+        }
594 593
     }
595 594
 
596 595
     // Determine our height
@@ -604,8 +603,8 @@  discard block
 block discarded – undo
604 603
     $this->_text_align();
605 604
 
606 605
     $this->vertical_align();
607
-  }
606
+    }
608 607
 
609
-  //........................................................................
608
+    //........................................................................
610 609
 
611 610
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/list_bullet_frame_reflower.cls.php 1 patch
Indentation   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -34,7 +34,6 @@  discard block
 block discarded – undo
34 34
  * @copyright 2004 Benj Carson
35 35
  * @author Benj Carson <[email protected]>
36 36
  * @package dompdf
37
-
38 37
  */
39 38
 
40 39
 /* $Id: list_bullet_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -47,20 +46,20 @@  discard block
 block discarded – undo
47 46
  */
48 47
 class List_Bullet_Frame_Reflower extends Frame_Reflower {
49 48
 
50
-  function __construct(Frame_Decorator $frame) { parent::__construct($frame); }
49
+    function __construct(Frame_Decorator $frame) { parent::__construct($frame); }
51 50
     
52
-  //........................................................................
51
+    //........................................................................
53 52
 
54
-  function reflow() {
53
+    function reflow() {
55 54
     $style = $this->_frame->get_style();
56 55
 
57 56
     $style->width = $this->_frame->get_width();
58 57
     $this->_frame->position();
59 58
 
60 59
     if ( $style->list_style_position === "inside" ) {
61
-      $p = $this->_frame->find_block_parent();
62
-      $p->add_frame_to_line($this->_frame);
60
+        $p = $this->_frame->find_block_parent();
61
+        $p->add_frame_to_line($this->_frame);
63 62
     }
64 63
 
65
-  }
64
+    }
66 65
 }
Please login to merge, or discard this patch.