Passed
Push — 1.10.x ( 5654d2...115d5a )
by Yannick
263:14 queued 212:07
created
main/inc/lib/phpdocx/pdf/include/cached_pdf_decorator.cls.php 1 patch
Indentation   +96 added lines, -97 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: cached_pdf_decorator.cls.php,v $
6
- * Created on: 2004-07-23
7
- *
8
- * Copyright (c) 2004 - Benj Carson <[email protected]>
9
- *
10
- * This library is free software; you can redistribute it and/or
11
- * modify it under the terms of the GNU Lesser General Public
12
- * License as published by the Free Software Foundation; either
13
- * version 2.1 of the License, or (at your option) any later version.
14
- *
15
- * This library is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
- * Lesser General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU Lesser General Public License
21
- * along with this library in the file LICENSE.LGPL; if not, write to the
22
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23
- * 02111-1307 USA
24
- *
25
- * Alternatively, you may distribute this software under the terms of the
26
- * PHP License, version 3.0 or later.  A copy of this license should have
27
- * been distributed with this file in the file LICENSE.PHP .  If this is not
28
- * the case, you can obtain a copy at http://www.php.net/license/3_0.txt.
29
- *
30
- * The latest version of DOMPDF might be available at:
31
- * http://www.dompdf.com/
32
- *
33
- * @link http://www.dompdf.com/
34
- * @copyright 2004 Benj Carson
35
- * @author Benj Carson <[email protected]>
36
- * @package dompdf
37
-
38
- */
3
+     * DOMPDF - PHP5 HTML to PDF renderer
4
+     *
5
+     * File: $RCSfile: cached_pdf_decorator.cls.php,v $
6
+     * Created on: 2004-07-23
7
+     *
8
+     * Copyright (c) 2004 - Benj Carson <[email protected]>
9
+     *
10
+     * This library is free software; you can redistribute it and/or
11
+     * modify it under the terms of the GNU Lesser General Public
12
+     * License as published by the Free Software Foundation; either
13
+     * version 2.1 of the License, or (at your option) any later version.
14
+     *
15
+     * This library is distributed in the hope that it will be useful,
16
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
+     * Lesser General Public License for more details.
19
+     *
20
+     * You should have received a copy of the GNU Lesser General Public License
21
+     * along with this library in the file LICENSE.LGPL; if not, write to the
22
+     * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23
+     * 02111-1307 USA
24
+     *
25
+     * Alternatively, you may distribute this software under the terms of the
26
+     * PHP License, version 3.0 or later.  A copy of this license should have
27
+     * been distributed with this file in the file LICENSE.PHP .  If this is not
28
+     * the case, you can obtain a copy at http://www.php.net/license/3_0.txt.
29
+     *
30
+     * The latest version of DOMPDF might be available at:
31
+     * http://www.dompdf.com/
32
+     *
33
+     * @link http://www.dompdf.com/
34
+     * @copyright 2004 Benj Carson
35
+     * @author Benj Carson <[email protected]>
36
+     * @package dompdf
37
+     */
39 38
 
40 39
 /* $Id: cached_pdf_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
41 40
 
@@ -53,90 +52,90 @@  discard block
 block discarded – undo
53 52
  * @package dompdf
54 53
  */
55 54
 class Cached_PDF_Decorator extends CPDF_Adapter implements Canvas {
56
-  protected $_pdf;
57
-  protected $_cache_id;
58
-  protected $_current_page_id;
59
-  protected $_fonts;  // fonts used in this document
55
+    protected $_pdf;
56
+    protected $_cache_id;
57
+    protected $_current_page_id;
58
+    protected $_fonts;  // fonts used in this document
60 59
   
61
-  function __construct($cache_id, CPDF_Adapter $pdf) {
60
+    function __construct($cache_id, CPDF_Adapter $pdf) {
62 61
     $this->_pdf = $pdf;
63 62
     $this->_cache_id = $cache_id;
64 63
     $this->_fonts = array();
65 64
     
66 65
     $this->_current_page_id = $this->_pdf->open_object();
67
-  }
66
+    }
68 67
 
69
-  //........................................................................
68
+    //........................................................................
70 69
 
71
-  function get_cpdf() { return $this->_pdf->get_cpdf(); }
70
+    function get_cpdf() { return $this->_pdf->get_cpdf(); }
72 71
 
73
-  function open_object() { $this->_pdf->open_object(); }
74
-  function reopen_object() { return $this->_pdf->reopen_object(); }
72
+    function open_object() { $this->_pdf->open_object(); }
73
+    function reopen_object() { return $this->_pdf->reopen_object(); }
75 74
   
76
-  function close_object() { $this->_pdf->close_object(); }
75
+    function close_object() { $this->_pdf->close_object(); }
77 76
 
78
-  function add_object($object, $where = 'all') { $this->_pdf->add_object($object, $where); }
77
+    function add_object($object, $where = 'all') { $this->_pdf->add_object($object, $where); }
79 78
 
80
-  function serialize_object($id) { $this->_pdf->serialize_object($id); }
79
+    function serialize_object($id) { $this->_pdf->serialize_object($id); }
81 80
 
82
-  function reopen_serialized_object($obj) { $this->_pdf->reopen_serialized_object($obj); }
81
+    function reopen_serialized_object($obj) { $this->_pdf->reopen_serialized_object($obj); }
83 82
     
84
-  //........................................................................
83
+    //........................................................................
85 84
 
86
-  function get_width() { return $this->_pdf->get_width(); }
87
-  function get_height() {  return $this->_pdf->get_height(); }
88
-  function get_page_number() { return $this->_pdf->get_page_number(); }
89
-  function get_page_count() { return $this->_pdf->get_page_count(); }
85
+    function get_width() { return $this->_pdf->get_width(); }
86
+    function get_height() {  return $this->_pdf->get_height(); }
87
+    function get_page_number() { return $this->_pdf->get_page_number(); }
88
+    function get_page_count() { return $this->_pdf->get_page_count(); }
90 89
 
91
-  function set_page_number($num) { $this->_pdf->set_page_number($num); }
92
-  function set_page_count($count) { $this->_pdf->set_page_count($count); }
90
+    function set_page_number($num) { $this->_pdf->set_page_number($num); }
91
+    function set_page_count($count) { $this->_pdf->set_page_count($count); }
93 92
 
94
-  function line($x1, $y1, $x2, $y2, $color, $width, $style = array()) {
93
+    function line($x1, $y1, $x2, $y2, $color, $width, $style = array()) {
95 94
     $this->_pdf->line($x1, $y1, $x2, $y2, $color, $width, $style);
96
-  }
95
+    }
97 96
                               
98
-  function rectangle($x1, $y1, $w, $h, $color, $width, $style = array()) {
97
+    function rectangle($x1, $y1, $w, $h, $color, $width, $style = array()) {
99 98
     $this->_pdf->rectangle($x1, $y1, $w, $h, $color, $width, $style);
100
-  }
99
+    }
101 100
  
102
-  function filled_rectangle($x1, $y1, $w, $h, $color) {
101
+    function filled_rectangle($x1, $y1, $w, $h, $color) {
103 102
     $this->_pdf->filled_rectangle($x1, $y1, $w, $h, $color);
104
-  }
103
+    }
105 104
     
106
-  function polygon($points, $color, $width = null, $style = array(), $fill = false) {
105
+    function polygon($points, $color, $width = null, $style = array(), $fill = false) {
107 106
     $this->_pdf->polygon($points, $color, $width, $style, $fill);
108
-  }
107
+    }
109 108
 
110
-  function circle($x, $y, $r1, $color, $width = null, $style = null, $fill = false) {
109
+    function circle($x, $y, $r1, $color, $width = null, $style = null, $fill = false) {
111 110
     $this->_pdf->circle($x, $y, $r1, $color, $width, $style, $fill);
112
-  }
111
+    }
113 112
 
114
-  function image($img_url, $x, $y, $w = null, $h = null) {
113
+    function image($img_url, $x, $y, $w = null, $h = null) {
115 114
     $this->_pdf->image($img_url, $x, $y, $w, $h);
116
-  }
115
+    }
117 116
   
118
-  function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) {
117
+    function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) {
119 118
     $this->_fonts[$font] = true;
120 119
     $this->_pdf->text($x, $y, $text, $font, $size, $color, $adjust, $angle);
121
-  }
120
+    }
122 121
 
123
-  function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) {
122
+    function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) {
124 123
     
125 124
     // We want to remove this from cached pages since it may not be correct
126 125
     $this->_pdf->close_object();
127 126
     $this->_pdf->page_text($x, $y, $text, $font, $size, $color, $adjust, $angle);
128 127
     $this->_pdf->reopen_object($this->_current_page_id);
129
-  }
128
+    }
130 129
   
131
-  function page_script($script, $type = 'text/php') {
130
+    function page_script($script, $type = 'text/php') {
132 131
     
133 132
     // We want to remove this from cached pages since it may not be correct
134 133
     $this->_pdf->close_object();
135 134
     $this->_pdf->page_script($script, $type);
136 135
     $this->_pdf->reopen_object($this->_current_page_id);
137
-  }
136
+    }
138 137
   
139
-  function new_page() {
138
+    function new_page() {
140 139
     $this->_pdf->close_object();
141 140
 
142 141
     // Add the object to the current page
@@ -144,43 +143,43 @@  discard block
 block discarded – undo
144 143
     $this->_pdf->new_page();    
145 144
 
146 145
     Page_Cache::store_page($this->_cache_id,
147
-                           $this->_pdf->get_page_number() - 1,
148
-                           $this->_pdf->serialize_object($this->_current_page_id));
146
+                            $this->_pdf->get_page_number() - 1,
147
+                            $this->_pdf->serialize_object($this->_current_page_id));
149 148
 
150 149
     $this->_current_page_id = $this->_pdf->open_object();
151 150
     return $this->_current_page_id;
152
-  }
151
+    }
153 152
   
154
-  function stream($filename) {
153
+    function stream($filename) {
155 154
     // Store the last page in the page cache
156 155
     if ( !is_null($this->_current_page_id) ) {
157
-      $this->_pdf->close_object();
158
-      $this->_pdf->add_object($this->_current_page_id, "add");
159
-      Page_Cache::store_page($this->_cache_id,
160
-                             $this->_pdf->get_page_number(),
161
-                             $this->_pdf->serialize_object($this->_current_page_id));
162
-      Page_Cache::store_fonts($this->_cache_id, $this->_fonts);
163
-      $this->_current_page_id = null;
156
+        $this->_pdf->close_object();
157
+        $this->_pdf->add_object($this->_current_page_id, "add");
158
+        Page_Cache::store_page($this->_cache_id,
159
+                                $this->_pdf->get_page_number(),
160
+                                $this->_pdf->serialize_object($this->_current_page_id));
161
+        Page_Cache::store_fonts($this->_cache_id, $this->_fonts);
162
+        $this->_current_page_id = null;
164 163
     }
165 164
     
166 165
     $this->_pdf->stream($filename);
167 166
     
168
-  }
167
+    }
169 168
   
170
-  function &output() {
169
+    function &output() {
171 170
     // Store the last page in the page cache
172 171
     if ( !is_null($this->_current_page_id) ) {
173
-      $this->_pdf->close_object();
174
-      $this->_pdf->add_object($this->_current_page_id, "add");
175
-      Page_Cache::store_page($this->_cache_id,
176
-                             $this->_pdf->get_page_number(),
177
-                             $this->_pdf->serialize_object($this->_current_page_id));
178
-      $this->_current_page_id = null;
172
+        $this->_pdf->close_object();
173
+        $this->_pdf->add_object($this->_current_page_id, "add");
174
+        Page_Cache::store_page($this->_cache_id,
175
+                                $this->_pdf->get_page_number(),
176
+                                $this->_pdf->serialize_object($this->_current_page_id));
177
+        $this->_current_page_id = null;
179 178
     }
180 179
     
181 180
     return $this->_pdf->output();
182
-  }
181
+    }
183 182
   
184
-  function get_messages() { return $this->_pdf->get_messages(); }
183
+    function get_messages() { return $this->_pdf->get_messages(); }
185 184
   
186 185
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/gd_adapter.cls.php 1 patch
Indentation   +378 added lines, -379 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: gd_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */
@@ -49,73 +48,73 @@  discard block
 block discarded – undo
49 48
  */
50 49
 class GD_Adapter implements Canvas {
51 50
 
52
-  /**
53
-   * Resoure handle for the image
54
-   *
55
-   * @var resource
56
-   */
57
-  private $_img;
58
-
59
-  /**
60
-   * Image width in pixels
61
-   *
62
-   * @var int
63
-   */
64
-  private $_width;
65
-
66
-  /**
67
-   * Image height in pixels
68
-   *
69
-   * @var int
70
-   */
71
-  private $_height;
72
-
73
-  /**
74
-   * Image antialias factor
75
-   *
76
-   * @var float
77
-   */
78
-  private $_aa_factor;
79
-
80
-  /**
81
-   * Allocated colors
82
-   *
83
-   * @var array
84
-   */
85
-  private $_colors;
86
-
87
-  /**
88
-   * Background color
89
-   *
90
-   * @var int
91
-   */
92
-  private $_bg_color;
51
+    /**
52
+     * Resoure handle for the image
53
+     *
54
+     * @var resource
55
+     */
56
+    private $_img;
57
+
58
+    /**
59
+     * Image width in pixels
60
+     *
61
+     * @var int
62
+     */
63
+    private $_width;
64
+
65
+    /**
66
+     * Image height in pixels
67
+     *
68
+     * @var int
69
+     */
70
+    private $_height;
71
+
72
+    /**
73
+     * Image antialias factor
74
+     *
75
+     * @var float
76
+     */
77
+    private $_aa_factor;
78
+
79
+    /**
80
+     * Allocated colors
81
+     *
82
+     * @var array
83
+     */
84
+    private $_colors;
85
+
86
+    /**
87
+     * Background color
88
+     *
89
+     * @var int
90
+     */
91
+    private $_bg_color;
93 92
   
94
-  /**
95
-   * Class constructor
96
-   *
97
-   * @param mixed  $size         The size of image to create: array(x1,y1,x2,y2) or "letter", "legal", etc.
98
-   * @param string $orientation  The orientation of the document (either 'landscape' or 'portrait')
99
-   * @param float  $aa_factor    Anti-aliasing factor, 1 for no AA
100
-   * @param array  $bg_color     Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1
101
-   */
102
-  function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) {
93
+    /**
94
+     * Class constructor
95
+     *
96
+     * @param mixed  $size         The size of image to create: array(x1,y1,x2,y2) or "letter", "legal", etc.
97
+     * @param string $orientation  The orientation of the document (either 'landscape' or 'portrait')
98
+     * @param float  $aa_factor    Anti-aliasing factor, 1 for no AA
99
+     * @param array  $bg_color     Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1
100
+     */
101
+    function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) {
103 102
 
104 103
     if ( !is_array($size) ) {
105 104
 
106
-      if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) 
105
+        if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) 
107 106
         $size = CPDF_Adapter::$PAPER_SIZES[$size];
108
-      else
107
+        else
109 108
         $size = CPDF_Adapter::$PAPER_SIZES["letter"];
110 109
     
111 110
     }
112 111
 
113 112
     if ( strtolower($orientation) === "landscape" ) {
114
-      list($size[2],$size[3]) = array($size[3],$size[2]);
113
+        list($size[2],$size[3]) = array($size[3],$size[2]);
115 114
     }
116 115
 
117 116
     if ( $aa_factor < 1 )
118
-      $aa_factor = 1;
117
+        $aa_factor = 1;
119 118
 
120 119
     $this->_aa_factor = $aa_factor;
121 120
     
@@ -128,8 +127,8 @@  discard block
 block discarded – undo
128 127
     $this->_img = imagecreatetruecolor($this->_width, $this->_height);
129 128
 
130 129
     if ( is_null($bg_color) || !is_array($bg_color) ) {
131
-      // Pure white bg
132
-      $bg_color = array(1,1,1,0);
130
+        // Pure white bg
131
+        $bg_color = array(1,1,1,0);
133 132
     }
134 133
 
135 134
     $this->_bg_color = $this->_allocate_color($bg_color);
@@ -137,68 +136,68 @@  discard block
 block discarded – undo
137 136
     imagesavealpha($this->_img, true);
138 137
     imagefill($this->_img, 0, 0, $this->_bg_color);
139 138
         
140
-  }
141
-
142
-  /**
143
-   * Return the GF image resource
144
-   *
145
-   * @return resource
146
-   */
147
-  function get_image() { return $this->_img; }
148
-
149
-  /**
150
-   * Return the image's width in pixels
151
-   *
152
-   * @return float
153
-   */
154
-  function get_width() { return $this->_width / $this->_aa_factor; }
155
-
156
-  /**
157
-   * Return the image's height in pixels
158
-   *
159
-   * @return float
160
-   */
161
-  function get_height() { return $this->_height / $this->_aa_factor; }
139
+    }
140
+
141
+    /**
142
+     * Return the GF image resource
143
+     *
144
+     * @return resource
145
+     */
146
+    function get_image() { return $this->_img; }
147
+
148
+    /**
149
+     * Return the image's width in pixels
150
+     *
151
+     * @return float
152
+     */
153
+    function get_width() { return $this->_width / $this->_aa_factor; }
154
+
155
+    /**
156
+     * Return the image's height in pixels
157
+     *
158
+     * @return float
159
+     */
160
+    function get_height() { return $this->_height / $this->_aa_factor; }
162 161
   
163
-  /**
164
-   * Returns the current page number
165
-   *
166
-   * @return int
167
-   */
168
-  function get_page_number() {
162
+    /**
163
+     * Returns the current page number
164
+     *
165
+     * @return int
166
+     */
167
+    function get_page_number() {
169 168
     // FIXME
170
-  }
169
+    }
171 170
    
172
-  /**
173
-   * Returns the total number of pages
174
-   *
175
-   * @return int
176
-   */
177
-  function get_page_count() {
171
+    /**
172
+     * Returns the total number of pages
173
+     *
174
+     * @return int
175
+     */
176
+    function get_page_count() {
178 177
     // FIXME
179
-  }    
180
-
181
-  /**
182
-   * Sets the total number of pages
183
-   *
184
-   * @param int $count
185
-   */
186
-  function set_page_count($count) {
178
+    }    
179
+
180
+    /**
181
+     * Sets the total number of pages
182
+     *
183
+     * @param int $count
184
+     */
185
+    function set_page_count($count) {
187 186
     // FIXME
188
-  }    
189
-
190
-  /**
191
-   * Allocate a new color.  Allocate with GD as needed and store
192
-   * previously allocated colors in $this->_colors.
193
-   *
194
-   * @param array $color  The new current color
195
-   * @return int           The allocated color
196
-   */
197
-  private function _allocate_color($color) {
187
+    }    
188
+
189
+    /**
190
+     * Allocate a new color.  Allocate with GD as needed and store
191
+     * previously allocated colors in $this->_colors.
192
+     *
193
+     * @param array $color  The new current color
194
+     * @return int           The allocated color
195
+     */
196
+    private function _allocate_color($color) {
198 197
     
199 198
     // Full opacity if no alpha set
200 199
     if ( !isset($color[3]) ) 
201
-      $color[3] = 0;
200
+        $color[3] = 0;
202 201
     
203 202
     list($r,$g,$b,$a) = $color;
204 203
     
@@ -221,33 +220,33 @@  discard block
 block discarded – undo
221 220
     $key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a);
222 221
       
223 222
     if ( isset($this->_colors[$key]) )
224
-      return $this->_colors[$key];
223
+        return $this->_colors[$key];
225 224
 
226 225
     if ( $a != 0 ) 
227
-      $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a);
226
+        $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a);
228 227
     else
229
-      $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b);
228
+        $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b);
230 229
       
231 230
     return $this->_colors[$key];
232 231
     
233
-  }
232
+    }
234 233
   
235
-  /**
236
-   * Draws a line from x1,y1 to x2,y2
237
-   *
238
-   * See {@link Style::munge_color()} for the format of the color array.
239
-   * See {@link Cpdf::setLineStyle()} for a description of the format of the
240
-   * $style parameter (aka dash).
241
-   *
242
-   * @param float $x1
243
-   * @param float $y1
244
-   * @param float $x2
245
-   * @param float $y2
246
-   * @param array $color
247
-   * @param float $width
248
-   * @param array $style
249
-   */
250
-  function line($x1, $y1, $x2, $y2, $color, $width, $style = null) {
234
+    /**
235
+     * Draws a line from x1,y1 to x2,y2
236
+     *
237
+     * See {@link Style::munge_color()} for the format of the color array.
238
+     * See {@link Cpdf::setLineStyle()} for a description of the format of the
239
+     * $style parameter (aka dash).
240
+     *
241
+     * @param float $x1
242
+     * @param float $y1
243
+     * @param float $x2
244
+     * @param float $y2
245
+     * @param array $color
246
+     * @param float $width
247
+     * @param array $style
248
+     */
249
+    function line($x1, $y1, $x2, $y2, $color, $width, $style = null) {
251 250
 
252 251
     // Scale by the AA factor
253 252
     $x1 *= $this->_aa_factor;
@@ -260,63 +259,63 @@  discard block
 block discarded – undo
260 259
 
261 260
     // Convert the style array if required
262 261
     if ( !is_null($style) ) {
263
-      $gd_style = array();
262
+        $gd_style = array();
264 263
 
265
-      if ( count($style) == 1 ) {
264
+        if ( count($style) == 1 ) {
266 265
         for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) {
267
-          $gd_style[] = $c;
266
+            $gd_style[] = $c;
268 267
         }
269 268
 
270 269
         for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) {
271
-          $gd_style[] = $this->_bg_color;
270
+            $gd_style[] = $this->_bg_color;
272 271
         }
273 272
 
274
-      } else {
273
+        } else {
275 274
 
276 275
         $i = 0;
277 276
         foreach ($style as $length) {
278 277
 
279
-          if ( $i % 2 == 0 ) {
278
+            if ( $i % 2 == 0 ) {
280 279
             // 'On' pattern
281 280
             for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) 
282
-              $gd_style[] = $c;
281
+                $gd_style[] = $c;
283 282
             
284
-          } else {
283
+            } else {
285 284
             // Off pattern
286 285
             for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) 
287
-              $gd_style[] = $this->_bg_color;
286
+                $gd_style[] = $this->_bg_color;
288 287
             
289
-          }
290
-          $i++;
288
+            }
289
+            $i++;
290
+        }
291 291
         }
292
-      }
293 292
       
294
-      imagesetstyle($this->_img, $gd_style);
295
-      $c = IMG_COLOR_STYLED;
293
+        imagesetstyle($this->_img, $gd_style);
294
+        $c = IMG_COLOR_STYLED;
296 295
     }
297 296
     
298 297
     imagesetthickness($this->_img, $width);
299 298
 
300 299
     imageline($this->_img, $x1, $y1, $x2, $y2, $c);
301 300
     
302
-  }
303
-
304
-  /**
305
-   * Draws a rectangle at x1,y1 with width w and height h
306
-   *
307
-   * See {@link Style::munge_color()} for the format of the color array.
308
-   * See {@link Cpdf::setLineStyle()} for a description of the $style
309
-   * parameter (aka dash)
310
-   *
311
-   * @param float $x1
312
-   * @param float $y1
313
-   * @param float $w
314
-   * @param float $h
315
-   * @param array $color
316
-   * @param float $width
317
-   * @param array $style
318
-   */   
319
-  function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) {
301
+    }
302
+
303
+    /**
304
+     * Draws a rectangle at x1,y1 with width w and height h
305
+     *
306
+     * See {@link Style::munge_color()} for the format of the color array.
307
+     * See {@link Cpdf::setLineStyle()} for a description of the $style
308
+     * parameter (aka dash)
309
+     *
310
+     * @param float $x1
311
+     * @param float $y1
312
+     * @param float $w
313
+     * @param float $h
314
+     * @param array $color
315
+     * @param float $width
316
+     * @param array $style
317
+     */   
318
+    function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) {
320 319
 
321 320
     // Scale by the AA factor
322 321
     $x1 *= $this->_aa_factor;
@@ -328,36 +327,36 @@  discard block
 block discarded – undo
328 327
 
329 328
     // Convert the style array if required
330 329
     if ( !is_null($style) ) {
331
-      $gd_style = array();
330
+        $gd_style = array();
332 331
 
333
-      foreach ($style as $length) {
332
+        foreach ($style as $length) {
334 333
         for ($i = 0; $i < $length; $i++) {
335
-          $gd_style[] = $c;
334
+            $gd_style[] = $c;
335
+        }
336 336
         }
337
-      }
338 337
 
339
-      imagesetstyle($this->_img, $gd_style);
340
-      $c = IMG_COLOR_STYLED;
338
+        imagesetstyle($this->_img, $gd_style);
339
+        $c = IMG_COLOR_STYLED;
341 340
     }
342 341
 
343 342
     imagesetthickness($this->_img, $width);
344 343
 
345 344
     imagerectangle($this->_img, $x1, $y1, $x1 + $w, $y1 + $h, $c);
346 345
     
347
-  }
348
-
349
-  /**
350
-   * Draws a filled rectangle at x1,y1 with width w and height h
351
-   *
352
-   * See {@link Style::munge_color()} for the format of the color array.
353
-   *
354
-   * @param float $x1
355
-   * @param float $y1
356
-   * @param float $w
357
-   * @param float $h
358
-   * @param array $color
359
-   */   
360
-  function filled_rectangle($x1, $y1, $w, $h, $color) {
346
+    }
347
+
348
+    /**
349
+     * Draws a filled rectangle at x1,y1 with width w and height h
350
+     *
351
+     * See {@link Style::munge_color()} for the format of the color array.
352
+     *
353
+     * @param float $x1
354
+     * @param float $y1
355
+     * @param float $w
356
+     * @param float $h
357
+     * @param array $color
358
+     */   
359
+    function filled_rectangle($x1, $y1, $w, $h, $color) {
361 360
 
362 361
     // Scale by the AA factor
363 362
     $x1 *= $this->_aa_factor;
@@ -369,79 +368,79 @@  discard block
 block discarded – undo
369 368
 
370 369
     imagefilledrectangle($this->_img, $x1, $y1, $x1 + $w, $y1 + $h, $c);
371 370
 
372
-  }
373
-
374
-  /**
375
-   * Draws a polygon
376
-   *
377
-   * The polygon is formed by joining all the points stored in the $points
378
-   * array.  $points has the following structure:
379
-   * <code>
380
-   * array(0 => x1,
381
-   *       1 => y1,
382
-   *       2 => x2,
383
-   *       3 => y2,
384
-   *       ...
385
-   *       );
386
-   * </code>
387
-   *
388
-   * See {@link Style::munge_color()} for the format of the color array.
389
-   * See {@link Cpdf::setLineStyle()} for a description of the $style
390
-   * parameter (aka dash)   
391
-   *
392
-   * @param array $points
393
-   * @param array $color
394
-   * @param float $width
395
-   * @param array $style
396
-   * @param bool  $fill  Fills the polygon if true
397
-   */
398
-  function polygon($points, $color, $width = null, $style = null, $fill = false) {
371
+    }
372
+
373
+    /**
374
+     * Draws a polygon
375
+     *
376
+     * The polygon is formed by joining all the points stored in the $points
377
+     * array.  $points has the following structure:
378
+     * <code>
379
+     * array(0 => x1,
380
+     *       1 => y1,
381
+     *       2 => x2,
382
+     *       3 => y2,
383
+     *       ...
384
+     *       );
385
+     * </code>
386
+     *
387
+     * See {@link Style::munge_color()} for the format of the color array.
388
+     * See {@link Cpdf::setLineStyle()} for a description of the $style
389
+     * parameter (aka dash)   
390
+     *
391
+     * @param array $points
392
+     * @param array $color
393
+     * @param float $width
394
+     * @param array $style
395
+     * @param bool  $fill  Fills the polygon if true
396
+     */
397
+    function polygon($points, $color, $width = null, $style = null, $fill = false) {
399 398
 
400 399
     // Scale each point by the AA factor
401 400
     foreach (array_keys($points) as $i)
402
-      $points[$i] *= $this->_aa_factor;
401
+        $points[$i] *= $this->_aa_factor;
403 402
 
404 403
     $c = $this->_allocate_color($color);
405 404
 
406 405
     // Convert the style array if required
407 406
     if ( !is_null($style) && !$fill ) {
408
-      $gd_style = array();
407
+        $gd_style = array();
409 408
 
410
-      foreach ($style as $length) {
409
+        foreach ($style as $length) {
411 410
         for ($i = 0; $i < $length; $i++) {
412
-          $gd_style[] = $c;
411
+            $gd_style[] = $c;
412
+        }
413 413
         }
414
-      }
415 414
 
416
-      imagesetstyle($this->_img, $gd_style);
417
-      $c = IMG_COLOR_STYLED;
415
+        imagesetstyle($this->_img, $gd_style);
416
+        $c = IMG_COLOR_STYLED;
418 417
     }
419 418
 
420 419
     imagesetthickness($this->_img, $width);
421 420
 
422 421
     if ( $fill ) 
423
-      imagefilledpolygon($this->_img, $points, count($points) / 2, $c);
422
+        imagefilledpolygon($this->_img, $points, count($points) / 2, $c);
424 423
     else
425
-      imagepolygon($this->_img, $points, count($points) / 2, $c);
424
+        imagepolygon($this->_img, $points, count($points) / 2, $c);
426 425
         
427
-  }
428
-
429
-  /**
430
-   * Draws a circle at $x,$y with radius $r
431
-   *
432
-   * See {@link Style::munge_color()} for the format of the color array.
433
-   * See {@link Cpdf::setLineStyle()} for a description of the $style
434
-   * parameter (aka dash)
435
-   *
436
-   * @param float $x
437
-   * @param float $y
438
-   * @param float $r
439
-   * @param array $color
440
-   * @param float $width
441
-   * @param array $style
442
-   * @param bool $fill Fills the circle if true   
443
-   */   
444
-  function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) {
426
+    }
427
+
428
+    /**
429
+     * Draws a circle at $x,$y with radius $r
430
+     *
431
+     * See {@link Style::munge_color()} for the format of the color array.
432
+     * See {@link Cpdf::setLineStyle()} for a description of the $style
433
+     * parameter (aka dash)
434
+     *
435
+     * @param float $x
436
+     * @param float $y
437
+     * @param float $r
438
+     * @param array $color
439
+     * @param float $width
440
+     * @param array $style
441
+     * @param bool $fill Fills the circle if true   
442
+     */   
443
+    function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) {
445 444
 
446 445
     // Scale by the AA factor
447 446
     $x *= $this->_aa_factor;
@@ -452,55 +451,55 @@  discard block
 block discarded – undo
452 451
 
453 452
     // Convert the style array if required
454 453
     if ( !is_null($style) && !$fill ) {
455
-      $gd_style = array();
454
+        $gd_style = array();
456 455
 
457
-      foreach ($style as $length) {
456
+        foreach ($style as $length) {
458 457
         for ($i = 0; $i < $length; $i++) {
459
-          $gd_style[] = $c;
458
+            $gd_style[] = $c;
459
+        }
460 460
         }
461
-      }
462 461
 
463
-      imagesetstyle($this->_img, $gd_style);
464
-      $c = IMG_COLOR_STYLED;
462
+        imagesetstyle($this->_img, $gd_style);
463
+        $c = IMG_COLOR_STYLED;
465 464
     }
466 465
 
467 466
     imagesetthickness($this->_img, $width);
468 467
 
469 468
     if ( $fill )
470
-      imagefilledellipse($this->_img, $x, $y, $r, $r, $c);
469
+        imagefilledellipse($this->_img, $x, $y, $r, $r, $c);
471 470
     else
472
-      imageellipse($this->_img, $x, $y, $r, $r, $c);
471
+        imageellipse($this->_img, $x, $y, $r, $r, $c);
473 472
         
474
-  }
475
-
476
-  /**
477
-   * Add an image to the pdf.
478
-   *
479
-   * The image is placed at the specified x and y coordinates with the
480
-   * given width and height.
481
-   *
482
-   * @param string $img_url the path to the image
483
-   * @param string $img_type the type (e.g. extension) of the image
484
-   * @param float $x x position
485
-   * @param float $y y position
486
-   * @param int $w width (in pixels)
487
-   * @param int $h height (in pixels)
488
-   */
489
-  function image($img_url, $img_type, $x, $y, $w, $h) {
473
+    }
474
+
475
+    /**
476
+     * Add an image to the pdf.
477
+     *
478
+     * The image is placed at the specified x and y coordinates with the
479
+     * given width and height.
480
+     *
481
+     * @param string $img_url the path to the image
482
+     * @param string $img_type the type (e.g. extension) of the image
483
+     * @param float $x x position
484
+     * @param float $y y position
485
+     * @param int $w width (in pixels)
486
+     * @param int $h height (in pixels)
487
+     */
488
+    function image($img_url, $img_type, $x, $y, $w, $h) {
490 489
 
491 490
     switch ($img_type) {
492 491
     case "png":
493 492
       $src = @imagecreatefrompng($img_url);
494
-      break;
493
+        break;
495 494
       
496 495
     case "gif":
497 496
       $src = @imagecreatefromgif($img_url);
498
-      break;
497
+        break;
499 498
       
500 499
     case "jpg":
501 500
     case "jpeg":
502 501
       $src = @imagecreatefromjpeg($img_url);
503
-      break;
502
+        break;
504 503
 
505 504
     default:
506 505
       break;
@@ -508,7 +507,7 @@  discard block
 block discarded – undo
508 507
     }
509 508
 
510 509
     if ( !$src )
511
-      return; // Probably should add to $_dompdf_errors or whatever here
510
+        return; // Probably should add to $_dompdf_errors or whatever here
512 511
     
513 512
     // Scale by the AA factor
514 513
     $x *= $this->_aa_factor;
@@ -523,23 +522,23 @@  discard block
 block discarded – undo
523 522
     
524 523
     imagecopyresampled($this->_img, $src, $x, $y, 0, 0, $w, $h, $img_w, $img_h);
525 524
     
526
-  }
527
-
528
-  /**
529
-   * Writes text at the specified x and y coordinates
530
-   *
531
-   * See {@link Style::munge_color()} for the format of the color array.
532
-   *
533
-   * @param float $x
534
-   * @param float $y
535
-   * @param string $text the text to write
536
-   * @param string $font the font file to use
537
-   * @param float $size the font size, in points
538
-   * @param array $color
539
-   * @param float $adjust word spacing adjustment
540
-   * @param float $angle Text angle
541
-   */
542
-  function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) {
525
+    }
526
+
527
+    /**
528
+     * Writes text at the specified x and y coordinates
529
+     *
530
+     * See {@link Style::munge_color()} for the format of the color array.
531
+     *
532
+     * @param float $x
533
+     * @param float $y
534
+     * @param string $text the text to write
535
+     * @param string $font the font file to use
536
+     * @param float $size the font size, in points
537
+     * @param array $color
538
+     * @param float $adjust word spacing adjustment
539
+     * @param float $angle Text angle
540
+     */
541
+    function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) {
543 542
 
544 543
     // Scale by the AA factor
545 544
     $x *= $this->_aa_factor;
@@ -551,106 +550,106 @@  discard block
 block discarded – undo
551 550
     $c = $this->_allocate_color($color);
552 551
 
553 552
     if ( strpos($font, '.ttf') === false )
554
-      $font .= ".ttf";
553
+        $font .= ".ttf";
555 554
 
556 555
     // FIXME: word spacing
557 556
     imagettftext($this->_img, $size, $angle, $x, $y + $h, $c, $font, $text);
558 557
     
559
-  }
558
+    }
560 559
   
561
-  function javascript($code) {
560
+    function javascript($code) {
562 561
     // Not implemented
563
-  }
564
-
565
-  /**
566
-   * Add a named destination (similar to <a name="foo">...</a> in html)
567
-   *
568
-   * @param string $anchorname The name of the named destination
569
-   */
570
-  function add_named_dest($anchorname) {
562
+    }
563
+
564
+    /**
565
+     * Add a named destination (similar to <a name="foo">...</a> in html)
566
+     *
567
+     * @param string $anchorname The name of the named destination
568
+     */
569
+    function add_named_dest($anchorname) {
571 570
     // Not implemented
572
-  }
573
-
574
-  /**
575
-   * Add a link to the pdf
576
-   *
577
-   * @param string $url The url to link to
578
-   * @param float  $x   The x position of the link
579
-   * @param float  $y   The y position of the link
580
-   * @param float  $width   The width of the link
581
-   * @param float  $height   The height of the link
582
-   */
583
-  function add_link($url, $x, $y, $width, $height) {
571
+    }
572
+
573
+    /**
574
+     * Add a link to the pdf
575
+     *
576
+     * @param string $url The url to link to
577
+     * @param float  $x   The x position of the link
578
+     * @param float  $y   The y position of the link
579
+     * @param float  $width   The width of the link
580
+     * @param float  $height   The height of the link
581
+     */
582
+    function add_link($url, $x, $y, $width, $height) {
584 583
     // Not implemented
585
-  }
586
-
587
-  /**
588
-   * Calculates text size, in points
589
-   *
590
-   * @param string $text the text to be sized
591
-   * @param string $font the desired font
592
-   * @param float  $size the desired font size
593
-   * @param float  $spacing word spacing, if any
594
-   * @return float
595
-   */
596
-  function get_text_width($text, $font, $size, $spacing = 0) {    
584
+    }
585
+
586
+    /**
587
+     * Calculates text size, in points
588
+     *
589
+     * @param string $text the text to be sized
590
+     * @param string $font the desired font
591
+     * @param float  $size the desired font size
592
+     * @param float  $spacing word spacing, if any
593
+     * @return float
594
+     */
595
+    function get_text_width($text, $font, $size, $spacing = 0) {    
597 596
 
598 597
     if ( strpos($font, '.ttf') === false )
599
-      $font .= ".ttf";
598
+        $font .= ".ttf";
600 599
 
601 600
     // FIXME: word spacing
602 601
     list($x1,,$x2) = imagettfbbox($size, 0, $font, $text);
603 602
     return $x2 - $x1;
604
-  }
605
-
606
-  /**
607
-   * Calculates font height, in points
608
-   *
609
-   * @param string $font
610
-   * @param float $size
611
-   * @return float
612
-   */
613
-  function get_font_height($font, $size) {
603
+    }
604
+
605
+    /**
606
+     * Calculates font height, in points
607
+     *
608
+     * @param string $font
609
+     * @param float $size
610
+     * @return float
611
+     */
612
+    function get_font_height($font, $size) {
614 613
     if ( strpos($font, '.ttf') === false )
615
-      $font .= ".ttf";
614
+        $font .= ".ttf";
616 615
 
617 616
     // FIXME: word spacing
618 617
     list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl");  // Test string with ascenders, descenders and caps
619 618
     return $y2 - $y1;
620
-  }
619
+    }
621 620
 
622 621
   
623
-  /**
624
-   * Starts a new page
625
-   *
626
-   * Subsequent drawing operations will appear on the new page.
627
-   */
628
-  function new_page() {
622
+    /**
623
+     * Starts a new page
624
+     *
625
+     * Subsequent drawing operations will appear on the new page.
626
+     */
627
+    function new_page() {
629 628
     // FIXME
630
-  }    
629
+    }    
631 630
 
632
-  /**
633
-   * Streams the image directly to the browser
634
-   *
635
-   * @param string $filename the name of the image file (ignored)
636
-   * @param array  $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only)
637
-   */
638
-  function stream($filename, $options = null) {
631
+    /**
632
+     * Streams the image directly to the browser
633
+     *
634
+     * @param string $filename the name of the image file (ignored)
635
+     * @param array  $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only)
636
+     */
637
+    function stream($filename, $options = null) {
639 638
 
640 639
     // Perform any antialiasing
641 640
     if ( $this->_aa_factor != 1 ) {
642
-      $dst_w = $this->_width / $this->_aa_factor;
643
-      $dst_h = $this->_height / $this->_aa_factor;
644
-      $dst = imagecreatetruecolor($dst_w, $dst_h);
645
-      imagecopyresampled($dst, $this->_img, 0, 0, 0, 0,
646
-                         $dst_w, $dst_h,
647
-                         $this->_width, $this->_height);
641
+        $dst_w = $this->_width / $this->_aa_factor;
642
+        $dst_h = $this->_height / $this->_aa_factor;
643
+        $dst = imagecreatetruecolor($dst_w, $dst_h);
644
+        imagecopyresampled($dst, $this->_img, 0, 0, 0, 0,
645
+                            $dst_w, $dst_h,
646
+                            $this->_width, $this->_height);
648 647
     } else {
649
-      $dst = $this->_img;
648
+        $dst = $this->_img;
650 649
     }
651 650
 
652 651
     if ( !isset($options["type"]) )
653
-      $options["type"] = "png";
652
+        $options["type"] = "png";
654 653
 
655 654
     $type = strtolower($options["type"]);
656 655
     
@@ -663,42 +662,42 @@  discard block
 block discarded – undo
663 662
       if ( !isset($options["quality"]) )
664 663
         $options["quality"] = 75;
665 664
       
666
-      header("Content-type: image/jpeg");
667
-      imagejpeg($dst, '', $options["quality"]);
668
-      break;
665
+        header("Content-type: image/jpeg");
666
+        imagejpeg($dst, '', $options["quality"]);
667
+        break;
669 668
 
670 669
     case "png":
671 670
     default:
672 671
       header("Content-type: image/png");
673
-      imagepng($dst);
674
-      break;
672
+        imagepng($dst);
673
+        break;
675 674
     }
676 675
 
677 676
     if ( $this->_aa_factor != 1 ) 
678
-      imagedestroy($dst);
679
-  }
677
+        imagedestroy($dst);
678
+    }
680 679
 
681
-  /**
682
-   * Returns the PNG as a string
683
-   *
684
-   * @param array  $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only)
685
-   * @return string
686
-   */
687
-  function output($options = null) {
680
+    /**
681
+     * Returns the PNG as a string
682
+     *
683
+     * @param array  $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only)
684
+     * @return string
685
+     */
686
+    function output($options = null) {
688 687
 
689 688
     if ( $this->_aa_factor != 1 ) {
690
-      $dst_w = $this->_width / $this->_aa_factor;
691
-      $dst_h = $this->_height / $this->_aa_factor;
692
-      $dst = imagecreatetruecolor($dst_w, $dst_h);
693
-      imagecopyresampled($dst, $this->_img, 0, 0, 0, 0,
694
-                         $dst_w, $dst_h,
695
-                         $this->_width, $this->_height);
689
+        $dst_w = $this->_width / $this->_aa_factor;
690
+        $dst_h = $this->_height / $this->_aa_factor;
691
+        $dst = imagecreatetruecolor($dst_w, $dst_h);
692
+        imagecopyresampled($dst, $this->_img, 0, 0, 0, 0,
693
+                            $dst_w, $dst_h,
694
+                            $this->_width, $this->_height);
696 695
     } else {
697
-      $dst = $this->_img;
696
+        $dst = $this->_img;
698 697
     }
699 698
     
700 699
     if ( !isset($options["type"]) )
701
-      $options["type"] = "png";
700
+        $options["type"] = "png";
702 701
 
703 702
     $type = $options["type"];
704 703
     
@@ -711,23 +710,23 @@  discard block
 block discarded – undo
711 710
       if ( !isset($options["quality"]) )
712 711
         $options["quality"] = 75;
713 712
       
714
-      imagejpeg($dst, '', $options["quality"]);
715
-      break;
713
+        imagejpeg($dst, '', $options["quality"]);
714
+        break;
716 715
 
717 716
     case "png":
718 717
     default:
719 718
       imagepng($dst);
720
-      break;
719
+        break;
721 720
     }
722 721
 
723 722
     $image = ob_get_contents();
724 723
     ob_end_clean();
725 724
 
726 725
     if ( $this->_aa_factor != 1 )
727
-      imagedestroy($dst);
726
+        imagedestroy($dst);
728 727
     
729 728
     return $image;
730
-  }
729
+    }
731 730
   
732 731
   
733 732
 }
Please login to merge, or discard this patch.
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/image_renderer.cls.php 1 patch
Indentation   +37 added lines, -38 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: image_renderer.cls.php,v $
6
- * Created on: 2004-08-04
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: image_renderer.cls.php,v $
6
+     * Created on: 2004-08-04
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: image_renderer.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
41 40
 
@@ -47,7 +46,7 @@  discard block
 block discarded – undo
47 46
  */
48 47
 class Image_Renderer extends Abstract_Renderer {
49 48
 
50
-  function render(Frame $frame) {
49
+    function render(Frame $frame) {
51 50
 
52 51
     // Render background & borders
53 52
     //parent::render($frame);
@@ -65,5 +64,5 @@  discard block
 block discarded – undo
65 64
 
66 65
     $this->_canvas->image( $frame->get_image_url(), $frame->get_image_ext(), $x, $y, $w, $h);
67 66
 
68
-  }
67
+    }
69 68
 }
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/table_row_frame_reflower.cls.php 1 patch
Indentation   +48 added lines, -49 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: table_row_frame_reflower.cls.php,v $
6
- * Created on: 2004-06-17
7
- *
8
- * Copyright (c) 2004 - Benj Carson <[email protected]>
9
- *
10
- * This library is free software; you can redistribute it and/or
11
- * modify it under the terms of the GNU Lesser General Public
12
- * License as published by the Free Software Foundation; either
13
- * version 2.1 of the License, or (at your option) any later version.
14
- *
15
- * This library is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
- * Lesser General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU Lesser General Public License
21
- * along with this library in the file LICENSE.LGPL; if not, write to the
22
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23
- * 02111-1307 USA
24
- *
25
- * Alternatively, you may distribute this software under the terms of the
26
- * PHP License, version 3.0 or later.  A copy of this license should have
27
- * been distributed with this file in the file LICENSE.PHP .  If this is not
28
- * the case, you can obtain a copy at http://www.php.net/license/3_0.txt.
29
- *
30
- * The latest version of DOMPDF might be available at:
31
- * http://www.dompdf.com/
32
- *
33
- * @link http://www.dompdf.com/
34
- * @copyright 2004 Benj Carson
35
- * @author Benj Carson <[email protected]>
36
- * @package dompdf
37
-
38
- */
3
+     * DOMPDF - PHP5 HTML to PDF renderer
4
+     *
5
+     * File: $RCSfile: table_row_frame_reflower.cls.php,v $
6
+     * Created on: 2004-06-17
7
+     *
8
+     * Copyright (c) 2004 - Benj Carson <[email protected]>
9
+     *
10
+     * This library is free software; you can redistribute it and/or
11
+     * modify it under the terms of the GNU Lesser General Public
12
+     * License as published by the Free Software Foundation; either
13
+     * version 2.1 of the License, or (at your option) any later version.
14
+     *
15
+     * This library is distributed in the hope that it will be useful,
16
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
+     * Lesser General Public License for more details.
19
+     *
20
+     * You should have received a copy of the GNU Lesser General Public License
21
+     * along with this library in the file LICENSE.LGPL; if not, write to the
22
+     * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23
+     * 02111-1307 USA
24
+     *
25
+     * Alternatively, you may distribute this software under the terms of the
26
+     * PHP License, version 3.0 or later.  A copy of this license should have
27
+     * been distributed with this file in the file LICENSE.PHP .  If this is not
28
+     * the case, you can obtain a copy at http://www.php.net/license/3_0.txt.
29
+     *
30
+     * The latest version of DOMPDF might be available at:
31
+     * http://www.dompdf.com/
32
+     *
33
+     * @link http://www.dompdf.com/
34
+     * @copyright 2004 Benj Carson
35
+     * @author Benj Carson <[email protected]>
36
+     * @package dompdf
37
+     */
39 38
 
40 39
 /* $Id: table_row_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
41 40
 
@@ -48,17 +47,17 @@  discard block
 block discarded – undo
48 47
 class Table_Row_Frame_Reflower extends Frame_Reflower {
49 48
 
50 49
 
51
-  function __construct(Table_Row_Frame_Decorator $frame) {
50
+    function __construct(Table_Row_Frame_Decorator $frame) {
52 51
     parent::__construct($frame);
53
-  }
52
+    }
54 53
 
55
-  //........................................................................
54
+    //........................................................................
56 55
 
57
-  function reflow() {
56
+    function reflow() {
58 57
     $page = $this->_frame->get_root();
59 58
 
60 59
     if ( $page->is_full() )
61
-      return;
60
+        return;
62 61
 
63 62
     $this->_frame->position();
64 63
     $style = $this->_frame->get_style();
@@ -66,16 +65,16 @@  discard block
 block discarded – undo
66 65
 
67 66
     foreach ($this->_frame->get_children() as $child) {
68 67
 
69
-      if ( $page->is_full() )
68
+        if ( $page->is_full() )
70 69
         return;
71 70
 
72
-      $child->set_containing_block($cb);
73
-      $child->reflow();
71
+        $child->set_containing_block($cb);
72
+        $child->reflow();
74 73
 
75 74
     }
76 75
 
77 76
     if ( $page->is_full() )
78
-      return;
77
+        return;
79 78
 
80 79
     $table = Table_Frame_Decorator::find_parent_table($this->_frame);
81 80
     $cellmap = $table->get_cellmap();
@@ -84,11 +83,11 @@  discard block
 block discarded – undo
84 83
 
85 84
     $this->_frame->set_position($cellmap->get_frame_position($this->_frame));
86 85
 
87
-  }
86
+    }
88 87
 
89
-  //........................................................................
88
+    //........................................................................
90 89
 
91
-  function get_min_max_width() {
90
+    function get_min_max_width() {
92 91
     throw new DOMPDF_Exception("Min/max width is undefined for table rows");
93
-  }
92
+    }
94 93
 }
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/text_frame_reflower.cls.php 1 patch
Indentation   +124 added lines, -125 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: text_frame_reflower.cls.php,v $
6
- * Created on: 2004-06-17
7
- *
8
- * Copyright (c) 2004 - Benj Carson <[email protected]>
9
- *
10
- * This library is free software; you can redistribute it and/or
11
- * modify it under the terms of the GNU Lesser General Public
12
- * License as published by the Free Software Foundation; either
13
- * version 2.1 of the License, or (at your option) any later version.
14
- *
15
- * This library is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
- * Lesser General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU Lesser General Public License
21
- * along with this library in the file LICENSE.LGPL; if not, write to the
22
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23
- * 02111-1307 USA
24
- *
25
- * Alternatively, you may distribute this software under the terms of the
26
- * PHP License, version 3.0 or later.  A copy of this license should have
27
- * been distributed with this file in the file LICENSE.PHP .  If this is not
28
- * the case, you can obtain a copy at http://www.php.net/license/3_0.txt.
29
- *
30
- * The latest version of DOMPDF might be available at:
31
- * http://www.dompdf.com/
32
- *
33
- * @link http://www.dompdf.com/
34
- * @copyright 2004 Benj Carson
35
- * @author Benj Carson <[email protected]>
36
- * @package dompdf
37
-
38
- */
3
+     * DOMPDF - PHP5 HTML to PDF renderer
4
+     *
5
+     * File: $RCSfile: text_frame_reflower.cls.php,v $
6
+     * Created on: 2004-06-17
7
+     *
8
+     * Copyright (c) 2004 - Benj Carson <[email protected]>
9
+     *
10
+     * This library is free software; you can redistribute it and/or
11
+     * modify it under the terms of the GNU Lesser General Public
12
+     * License as published by the Free Software Foundation; either
13
+     * version 2.1 of the License, or (at your option) any later version.
14
+     *
15
+     * This library is distributed in the hope that it will be useful,
16
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
+     * Lesser General Public License for more details.
19
+     *
20
+     * You should have received a copy of the GNU Lesser General Public License
21
+     * along with this library in the file LICENSE.LGPL; if not, write to the
22
+     * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23
+     * 02111-1307 USA
24
+     *
25
+     * Alternatively, you may distribute this software under the terms of the
26
+     * PHP License, version 3.0 or later.  A copy of this license should have
27
+     * been distributed with this file in the file LICENSE.PHP .  If this is not
28
+     * the case, you can obtain a copy at http://www.php.net/license/3_0.txt.
29
+     *
30
+     * The latest version of DOMPDF might be available at:
31
+     * http://www.dompdf.com/
32
+     *
33
+     * @link http://www.dompdf.com/
34
+     * @copyright 2004 Benj Carson
35
+     * @author Benj Carson <[email protected]>
36
+     * @package dompdf
37
+     */
39 38
 
40 39
 /* $Id: text_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
41 40
 
@@ -47,9 +46,9 @@  discard block
 block discarded – undo
47 46
  */
48 47
 class Text_Frame_Reflower extends Frame_Reflower {
49 48
 
50
-  protected $_block_parent; // Nearest block-level ancestor
49
+    protected $_block_parent; // Nearest block-level ancestor
51 50
 
52
-  function __construct(Text_Frame_Decorator $frame) {
51
+    function __construct(Text_Frame_Decorator $frame) {
53 52
     parent::__construct($frame);
54 53
     $this->_block_parent = null;
55 54
 
@@ -58,34 +57,34 @@  discard block
 block discarded – undo
58 57
     switch ( strtolower($transform) ) {
59 58
     case "capitalize":
60 59
       $this->_frame->set_text( ucwords($this->_frame->get_text()) );
61
-      break;
60
+        break;
62 61
 
63 62
     case "uppercase":
64 63
       $this->_frame->set_text( strtoupper($this->_frame->get_text()) );
65
-      break;
64
+        break;
66 65
 
67 66
     case "lowercase":
68 67
       $this->_frame->set_text( strtolower($this->_frame->get_text()) );
69
-      break;
68
+        break;
70 69
 
71 70
     default:
72 71
       // Do nothing
73 72
       break;
74 73
     }
75
-  }
74
+    }
76 75
 
77
-  //........................................................................
76
+    //........................................................................
78 77
 
79
-  protected function _collapse_white_space($text) {
78
+    protected function _collapse_white_space($text) {
80 79
     //$text = $this->_frame->get_text();
81 80
 //     if ( $this->_block_parent->get_current_line("w") == 0 )
82 81
 //       $text = ltrim($text, " \n\r\t");
83 82
     return preg_replace("/[\s\n]+/u", " ", $text);
84
-  }
83
+    }
85 84
 
86
-  //........................................................................
85
+    //........................................................................
87 86
 
88
-  protected function _line_break($text) {
87
+    protected function _line_break($text) {
89 88
     $style = $this->_frame->get_style();
90 89
     $size = $style->font_size;
91 90
     $font = $style->font_family;
@@ -106,12 +105,12 @@  discard block
 block discarded – undo
106 105
     // Determine the frame width including margin, padding & border
107 106
     $text_width = Font_Metrics::get_text_width($text, $font, $size, $word_spacing);
108 107
     $mbp_width =
109
-      $style->length_in_pt( array( $style->margin_left,
110
-                                   $style->border_left_width,
111
-                                   $style->padding_left,
112
-                                   $style->padding_right,
113
-                                   $style->border_right_width,
114
-                                   $style->margin_right), $line_width );
108
+        $style->length_in_pt( array( $style->margin_left,
109
+                                    $style->border_left_width,
110
+                                    $style->padding_left,
111
+                                    $style->padding_right,
112
+                                    $style->border_right_width,
113
+                                    $style->margin_right), $line_width );
115 114
     $frame_width = $text_width + $mbp_width;
116 115
 
117 116
 // Debugging:
@@ -126,7 +125,7 @@  discard block
 block discarded – undo
126 125
 //     pre_r($words);
127 126
 
128 127
     if ( $frame_width <= $available_width )
129
-      return false;
128
+        return false;
130 129
 
131 130
     // Determine the split point
132 131
     $width = 0;
@@ -134,20 +133,20 @@  discard block
 block discarded – undo
134 133
     reset($words);
135 134
 
136 135
     for ($i = 0; $i < count($words); $i += 2) {
137
-      $word = $words[$i] . (isset($words[$i+1]) ? $words[$i+1] : "");
138
-      $word_width = Font_Metrics::get_text_width($word, $font, $size, $word_spacing);
139
-      if ( $width + $word_width + $mbp_width > $available_width )
136
+        $word = $words[$i] . (isset($words[$i+1]) ? $words[$i+1] : "");
137
+        $word_width = Font_Metrics::get_text_width($word, $font, $size, $word_spacing);
138
+        if ( $width + $word_width + $mbp_width > $available_width )
140 139
         break;
141 140
 
142
-      $width += $word_width;
143
-      $str .= $word;
141
+        $width += $word_width;
142
+        $str .= $word;
144 143
 
145 144
     }
146 145
 
147 146
     // The first word has overflowed.   Force it onto the line
148 147
     if ( $current_line_width == 0 && $width == 0 ) {
149
-      $width += $word_width;
150
-      $str .= $word;
148
+        $width += $word_width;
149
+        $str .= $word;
151 150
     }
152 151
 
153 152
     $offset = mb_strlen($str);
@@ -159,22 +158,22 @@  discard block
 block discarded – undo
159 158
 
160 159
     return $offset;
161 160
 
162
-  }
161
+    }
163 162
 
164
-  //........................................................................
163
+    //........................................................................
165 164
 
166
-  protected function _newline_break($text) {
165
+    protected function _newline_break($text) {
167 166
 
168 167
     if ( ($i = mb_strpos($text, "\n")) === false)
169
-      return false;
168
+        return false;
170 169
 
171 170
     return $i+1;
172 171
 
173
-  }
172
+    }
174 173
 
175
-  //........................................................................
174
+    //........................................................................
176 175
 
177
-  protected function _layout_line() {
176
+    protected function _layout_line() {
178 177
     $style = $this->_frame->get_style();
179 178
     $text = $this->_frame->get_text();
180 179
     $size = $style->font_size;
@@ -197,15 +196,15 @@  discard block
 block discarded – undo
197 196
 
198 197
     case "capitalize":
199 198
       $text = mb_convert_case($text, MB_CASE_TITLE, 'UTF-8');
200
-      break;
199
+        break;
201 200
 
202 201
     case "uppercase":
203 202
       $text = mb_convert_case($text, MB_CASE_UPPER, 'UTF-8');
204
-      break;
203
+        break;
205 204
 
206 205
     case "lowercase":
207 206
       $text = mb_convert_case($text, MB_CASE_LOWER, 'UTF-8');
208
-      break;
207
+        break;
209 208
 
210 209
     }
211 210
     
@@ -217,64 +216,64 @@  discard block
 block discarded – undo
217 216
     default:
218 217
     case "normal":
219 218
       $this->_frame->set_text( $text = $this->_collapse_white_space($text) );
220
-      if ( $text == "" )
219
+        if ( $text == "" )
221 220
         break;
222 221
 
223
-      $split = $this->_line_break($text);
224
-      break;
222
+        $split = $this->_line_break($text);
223
+        break;
225 224
 
226 225
     case "pre":
227 226
       $split = $this->_newline_break($text);
228
-      $add_line = $split !== false;
229
-      break;
227
+        $add_line = $split !== false;
228
+        break;
230 229
 
231 230
     case "nowrap":
232 231
       $this->_frame->set_text( $text = $this->_collapse_white_space($text) );
233
-      break;
232
+        break;
234 233
 
235 234
     case "pre-wrap":
236 235
       $split = $this->_newline_break($text);
237 236
 
238
-      if ( ($tmp = $this->_line_break($text)) !== false ) {
237
+        if ( ($tmp = $this->_line_break($text)) !== false ) {
239 238
         $add_line = $split < $tmp;
240 239
         $split = min($tmp, $split);
241
-      } else
240
+        } else
242 241
         $add_line = true;
243 242
 
244
-      break;
243
+        break;
245 244
 
246 245
     case "pre-line":
247 246
       // Collapse white-space except for \n
248 247
       $this->_frame->set_text( $text = preg_replace( "/[ \t]+/u", " ", $text ) );
249 248
 
250
-      if ( $text == "" )
249
+        if ( $text == "" )
251 250
         break;
252 251
 
253
-      $split = $this->_newline_break($text);
252
+        $split = $this->_newline_break($text);
254 253
 
255
-      if ( ($tmp = $this->_line_break($text)) !== false ) {
254
+        if ( ($tmp = $this->_line_break($text)) !== false ) {
256 255
         $add_line = $split < $tmp;
257 256
         $split = min($tmp, $split);
258
-      } else
257
+        } else
259 258
         $add_line = true;
260 259
 
261
-      break;
260
+        break;
262 261
 
263 262
     }
264 263
 
265 264
     // Handle degenerate case
266 265
     if ( $text === "" )
267
-      return;
266
+        return;
268 267
 
269 268
     if ( $split !== false) {
270 269
 
271
-      // Handle edge cases
272
-      if ( $split == 0 && $text === " " ) {
270
+        // Handle edge cases
271
+        if ( $split == 0 && $text === " " ) {
273 272
         $this->_frame->set_text("");
274 273
         return;
275
-      }
274
+        }
276 275
 
277
-      if ( $split == 0 ) {
276
+        if ( $split == 0 ) {
278 277
 
279 278
         // Trim newlines from the beginning of the line
280 279
         //$this->_frame->set_text(ltrim($text, "\n\r"));
@@ -285,7 +284,7 @@  discard block
 block discarded – undo
285 284
         // Layout the new line
286 285
         $this->_layout_line();
287 286
 
288
-      } else if ( $split < mb_strlen($this->_frame->get_text()) ) {
287
+        } else if ( $split < mb_strlen($this->_frame->get_text()) ) {
289 288
 
290 289
         // split the line if required
291 290
         $this->_frame->split_text($split);
@@ -294,28 +293,28 @@  discard block
 block discarded – undo
294 293
         $t = $this->_frame->get_text();
295 294
 
296 295
         if ( $split > 1 && $t[$split-1] === "\n" )
297
-          $this->_frame->set_text( mb_substr($t, 0, -1) );
296
+            $this->_frame->set_text( mb_substr($t, 0, -1) );
298 297
 
299
-      }
298
+        }
300 299
 
301
-      if ( $add_line ) {
300
+        if ( $add_line ) {
302 301
         $this->_block_parent->add_line();
303 302
         $this->_frame->position();
304
-      }
303
+        }
305 304
 
306
-      // Set our new width
307
-      $this->_frame->recalculate_width();
305
+        // Set our new width
306
+        $this->_frame->recalculate_width();
308 307
 
309 308
     } else {
310 309
 
311
-      $this->_frame->recalculate_width();
310
+        $this->_frame->recalculate_width();
312 311
 
313 312
     }
314
-  }
313
+    }
315 314
 
316
-  //........................................................................
315
+    //........................................................................
317 316
 
318
-  function reflow() {
317
+    function reflow() {
319 318
 
320 319
     $this->_block_parent = $this->_frame->find_block_parent();
321 320
 
@@ -331,13 +330,13 @@  discard block
 block discarded – undo
331 330
 
332 331
     $this->_layout_line();
333 332
 
334
-  }
333
+    }
335 334
 
336
-  //........................................................................
335
+    //........................................................................
337 336
 
338
-  // Returns an array(0 => min, 1 => max, "min" => min, "max" => max) of the
339
-  // minimum and maximum widths of this frame
340
-  function get_min_max_width() {
337
+    // Returns an array(0 => min, 1 => max, "min" => min, "max" => max) of the
338
+    // minimum and maximum widths of this frame
339
+    function get_min_max_width() {
341 340
 
342 341
     $style = $this->_frame->get_style();
343 342
     $this->_block_parent = $this->_frame->find_block_parent();
@@ -363,24 +362,24 @@  discard block
 block discarded – undo
363 362
       // faster than doing a single-pass character by character scan.  Heh,
364 363
       // yes I took the time to bench it ;)
365 364
       $words = array_flip(preg_split("/[\s-]+/u",$str, -1, PREG_SPLIT_DELIM_CAPTURE));
366
-      array_walk($words, create_function('&$val,$str',
367
-                                         '$val = Font_Metrics::get_text_width($str, "'.$font.'", '.$size.', '.$spacing.');'));
368
-      arsort($words);
369
-      $min = reset($words);
370
-      break;
365
+        array_walk($words, create_function('&$val,$str',
366
+                                            '$val = Font_Metrics::get_text_width($str, "'.$font.'", '.$size.', '.$spacing.');'));
367
+        arsort($words);
368
+        $min = reset($words);
369
+        break;
371 370
 
372 371
     case "pre":
373 372
       $lines = array_flip(preg_split("/\n/u", $str));
374
-      array_walk($lines, create_function('&$val,$str',
375
-                                         '$val = Font_Metrics::get_text_width($str, "'.$font.'", '.$size.', '.$spacing.');'));
373
+        array_walk($lines, create_function('&$val,$str',
374
+                                            '$val = Font_Metrics::get_text_width($str, "'.$font.'", '.$size.', '.$spacing.');'));
376 375
 
377
-      arsort($lines);
378
-      $min = reset($lines);
379
-      break;
376
+        arsort($lines);
377
+        $min = reset($lines);
378
+        break;
380 379
 
381 380
     case "nowrap":
382 381
       $min = Font_Metrics::get_text_width($this->_collapse_white_space($str), $font, $size, $spacing);
383
-      break;
382
+        break;
384 383
 
385 384
     }
386 385
 
@@ -390,7 +389,7 @@  discard block
 block discarded – undo
390 389
     case "normal":
391 390
     case "nowrap":
392 391
       $str = preg_replace("/[\s\n]+/u"," ", $text);
393
-      break;
392
+        break;
394 393
 
395 394
     case "pre-line":
396 395
       $str = preg_replace( "/[ \t]+/u", " ", $text);
@@ -398,12 +397,12 @@  discard block
 block discarded – undo
398 397
     case "pre-wrap":
399 398
       // Find the longest word (i.e. minimum length)
400 399
       $lines = array_flip(preg_split("/\n/", $text));
401
-      array_walk($lines, create_function('&$val,$str',
402
-                                         '$val = Font_Metrics::get_text_width($str, "'.$font.'", '.$size.', '.$spacing.');'));
403
-      arsort($lines);
404
-      reset($lines);
405
-      $str = key($lines);
406
-      break;
400
+        array_walk($lines, create_function('&$val,$str',
401
+                                            '$val = Font_Metrics::get_text_width($str, "'.$font.'", '.$size.', '.$spacing.');'));
402
+        arsort($lines);
403
+        reset($lines);
404
+        $str = key($lines);
405
+        break;
407 406
 
408 407
     }
409 408
 
@@ -420,6 +419,6 @@  discard block
 block discarded – undo
420 419
 
421 420
     return array($min, $max, "min" => $min, "max" => $max);
422 421
 
423
-  }
422
+    }
424 423
 
425 424
 }
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.