Completed
Push — 1.10.x ( 181e18...3b3cbc )
by Angel Fernando Quiroz
104:16 queued 53:32
created
main/inc/lib/phpdocx/pdf/include/attribute_translator.cls.php 1 patch
Indentation   +267 added lines, -268 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: attribute_translator.cls.php 219 2010-03-11 23:18:31Z ryan.masten $ */
@@ -47,84 +46,84 @@  discard block
 block discarded – undo
47 46
  */
48 47
 class Attribute_Translator {
49 48
   
50
-  // Munged data originally from
51
-  // http://www.w3.org/TR/REC-html40/index/attributes.html
52
-  //
53
-  // thank you var_export() :D
54
-  static private $__ATTRIBUTE_LOOKUP =
49
+    // Munged data originally from
50
+    // http://www.w3.org/TR/REC-html40/index/attributes.html
51
+    //
52
+    // thank you var_export() :D
53
+    static private $__ATTRIBUTE_LOOKUP =
55 54
     array (//'caption' => array ( 'align' => '', ),
56
-           'img_inner' =>  // img tags actually end up wrapping img_inner elements
57
-           array ('align' => array('bottom' => 'vertical-align: baseline;',
58
-                                   'middle' => 'vertical-align: middle;',
59
-                                   'top' => 'vertical-align: top;',
60
-                                   'left' => 'float: left;',
61
-                                   'right' => 'float: right;'),
62
-                  'border' => 'border-width: %0.2f px;',
63
-                  'height' => 'height: %s px;',
64
-                  'hspace' => 'padding-left: %1$0.2f px; padding-right: %1$0.2f px;',
65
-                  'vspace' => 'padding-top: %1$0.2f px; padding-bottom: %1$0.2f px;',
66
-                  'width' => 'width: %s px;',
67
-                  ),
68
-           'table' =>
69
-           array ("align" => array('left' => 'margin-left: 0; margin-right: auto;',
55
+            'img_inner' =>  // img tags actually end up wrapping img_inner elements
56
+            array ('align' => array('bottom' => 'vertical-align: baseline;',
57
+                                    'middle' => 'vertical-align: middle;',
58
+                                    'top' => 'vertical-align: top;',
59
+                                    'left' => 'float: left;',
60
+                                    'right' => 'float: right;'),
61
+                    'border' => 'border-width: %0.2f px;',
62
+                    'height' => 'height: %s px;',
63
+                    'hspace' => 'padding-left: %1$0.2f px; padding-right: %1$0.2f px;',
64
+                    'vspace' => 'padding-top: %1$0.2f px; padding-bottom: %1$0.2f px;',
65
+                    'width' => 'width: %s px;',
66
+                    ),
67
+            'table' =>
68
+            array ("align" => array('left' => 'margin-left: 0; margin-right: auto;',
70 69
                         'center' => 'margin-left: auto; margin-right: auto;',
71 70
                         'right' => 'margin-left: auto; margin-right: 0;'
72 71
                         ),
73
-                  'bgcolor' => 'background-color: %s;',
74
-                  'border' => '!set_table_border',
75
-                  'cellpadding' => '!set_table_cellpadding',
76
-                  'cellspacing' => 'border-spacing: %0.2f; border-collapse: separate;',
77
-                  'frame' => array('void' => 'border-style: none;',
78
-                                   'above' => 'border-top-style: solid;',
79
-                                   'below' => 'border-bottom-style: solid;',
80
-                                   'hsides' => 'border-left-style: solid; border-right-style: solid;',
81
-                                   'vsides' => 'border-top-style: solid; border-bottom-style: solid;',
82
-                                   'lhs' => 'border-left-style: solid;',
83
-                                   'rhs' => 'border-right-style: solid;',
84
-                                   'box' => 'border-style: solid;',
85
-                                   'border' => 'border-style: solid;'),
86
-                  'rules' => '!set_table_rules',
87
-                  'width' => 'width: %s;',
88
-                  ),
89
-           'hr' =>
90
-           array (
91
-                  'align' => '!set_hr_align', // Need to grab width to set 'left' & 'right' correctly
92
-                  'noshade' => 'border-style: solid;',
93
-                  'size' => 'border-width: %0.2f px;',
94
-                  'width' => 'width: %s;',
95
-                  ),
96
-           'div' =>
97
-           array (
98
-                  'align' => 'text-align: %s;',
99
-                  ),
100
-           'h1' =>
101
-           array (
102
-                  'align' => 'text-align: %s;',
103
-                  ),
104
-           'h2' =>
105
-           array (
106
-                  'align' => 'text-align: %s;',
107
-                  ),
108
-           'h3' =>
109
-           array (
110
-                  'align' => 'text-align: %s;',
111
-                  ),
112
-           'h4' =>
113
-           array (
114
-                  'align' => 'text-align: %s;',
115
-                  ),
116
-           'h5' =>
117
-           array (
118
-                  'align' => 'text-align: %s;',
119
-                  ),
120
-           'h6' =>
121
-           array (
122
-                  'align' => 'text-align: %s;',
123
-                  ),
124
-           'p' =>
125
-           array (
126
-                  'align' => 'text-align: %s;',
127
-                  ),
72
+                    'bgcolor' => 'background-color: %s;',
73
+                    'border' => '!set_table_border',
74
+                    'cellpadding' => '!set_table_cellpadding',
75
+                    'cellspacing' => 'border-spacing: %0.2f; border-collapse: separate;',
76
+                    'frame' => array('void' => 'border-style: none;',
77
+                                    'above' => 'border-top-style: solid;',
78
+                                    'below' => 'border-bottom-style: solid;',
79
+                                    'hsides' => 'border-left-style: solid; border-right-style: solid;',
80
+                                    'vsides' => 'border-top-style: solid; border-bottom-style: solid;',
81
+                                    'lhs' => 'border-left-style: solid;',
82
+                                    'rhs' => 'border-right-style: solid;',
83
+                                    'box' => 'border-style: solid;',
84
+                                    'border' => 'border-style: solid;'),
85
+                    'rules' => '!set_table_rules',
86
+                    'width' => 'width: %s;',
87
+                    ),
88
+            'hr' =>
89
+            array (
90
+                    'align' => '!set_hr_align', // Need to grab width to set 'left' & 'right' correctly
91
+                    'noshade' => 'border-style: solid;',
92
+                    'size' => 'border-width: %0.2f px;',
93
+                    'width' => 'width: %s;',
94
+                    ),
95
+            'div' =>
96
+            array (
97
+                    'align' => 'text-align: %s;',
98
+                    ),
99
+            'h1' =>
100
+            array (
101
+                    'align' => 'text-align: %s;',
102
+                    ),
103
+            'h2' =>
104
+            array (
105
+                    'align' => 'text-align: %s;',
106
+                    ),
107
+            'h3' =>
108
+            array (
109
+                    'align' => 'text-align: %s;',
110
+                    ),
111
+            'h4' =>
112
+            array (
113
+                    'align' => 'text-align: %s;',
114
+                    ),
115
+            'h5' =>
116
+            array (
117
+                    'align' => 'text-align: %s;',
118
+                    ),
119
+            'h6' =>
120
+            array (
121
+                    'align' => 'text-align: %s;',
122
+                    ),
123
+            'p' =>
124
+            array (
125
+                    'align' => 'text-align: %s;',
126
+                    ),
128 127
 //            'col' =>
129 128
 //            array (
130 129
 //                   'align' => '',
@@ -135,219 +134,219 @@  discard block
 block discarded – undo
135 134
 //                   'align' => '',
136 135
 //                   'valign' => '',
137 136
 //                   ),
138
-           'tbody' =>
139
-           array (
140
-                  'align' => '!set_table_row_align',
141
-                  'valign' => '!set_table_row_valign',
142
-                  ),
143
-           'td' =>
144
-           array (
145
-                  'align' => 'text-align: %s;',
146
-                  'bgcolor' => 'background-color: %s;',
147
-                  'height' => 'height: %s;',
148
-                  'nowrap' => 'white-space: nowrap;',
149
-                  'valign' => 'vertical-align: %s;',
150
-                  'width' => 'width: %s;',
151
-                  ),
152
-           'tfoot' =>
153
-           array (
154
-                  'align' => '!set_table_row_align',
155
-                  'valign' => '!set_table_row_valign',
156
-                  ),
157
-           'th' =>
158
-           array (
159
-                  'align' => 'text-align: %s;',
160
-                  'bgcolor' => 'background-color: %s;',
161
-                  'height' => 'height: %s;',
162
-                  'nowrap' => 'white-space: nowrap;',
163
-                  'valign' => 'vertical-align: %s;',
164
-                  'width' => 'width: %s;',
165
-                  ),
166
-           'thead' =>
167
-           array (
168
-                  'align' => '!set_table_row_align',
169
-                  'valign' => '!set_table_row_valign',
170
-                  ),
171
-           'tr' =>
172
-           array (
173
-                  'align' => '!set_table_row_align',
174
-                  'bgcolor' => '!set_table_row_bgcolor',
175
-                  'valign' => '!set_table_row_valign',
176
-                  ),
177
-           'body' =>
178
-           array (
179
-                  'background' => 'background-image: url(%s);',
180
-                  'bgcolor' => 'background-color: %s;',
181
-                  'link' => '!set_body_link',
182
-                  'text' => 'color: %s;',
183
-                  ),
184
-           'br' =>
185
-           array (
186
-                  'clear' => 'clear: %s;',
187
-                  ),
188
-           'basefont' =>
189
-           array (
190
-                  'color' => 'color: %s;',
191
-                  'face' => 'font-family: %s;',
192
-                  'size' => '!set_basefont_size',
193
-                  ),
194
-           'font' =>
195
-           array (
196
-                  'color' => 'color: %s;',
197
-                  'face' => 'font-family: %s;',
198
-                  'size' => '!set_font_size',
199
-                  ),
200
-           'dir' =>
201
-           array (
202
-                  'compact' => 'margin: 0.5em 0;',
203
-                  ),
204
-           'dl' =>
205
-           array (
206
-                  'compact' => 'margin: 0.5em 0;',
207
-                  ),
208
-           'menu' =>
209
-           array (
210
-                  'compact' => 'margin: 0.5em 0;',
211
-                  ),
212
-           'ol' =>
213
-           array (
214
-                  'compact' => 'margin: 0.5em 0;',
215
-                  'start' => 'counter-reset: -dompdf-default-counter %d;',
216
-                  'type' => 'list-style-type: %s;',
217
-                  ),
218
-           'ul' =>
219
-           array (
220
-                  'compact' => 'margin: 0.5em 0;',
221
-                  'type' => 'list-style-type: %s;',
222
-                  ),
223
-           'li' =>
224
-           array (
225
-                  'type' => 'list-style-type: %s;',
226
-                  'value' => 'counter-reset: -dompdf-default-counter %d;',
227
-                  ),
228
-           'pre' =>
229
-           array (
230
-                  'width' => 'width: %s;',
231
-                  ),
232
-           );
137
+            'tbody' =>
138
+            array (
139
+                    'align' => '!set_table_row_align',
140
+                    'valign' => '!set_table_row_valign',
141
+                    ),
142
+            'td' =>
143
+            array (
144
+                    'align' => 'text-align: %s;',
145
+                    'bgcolor' => 'background-color: %s;',
146
+                    'height' => 'height: %s;',
147
+                    'nowrap' => 'white-space: nowrap;',
148
+                    'valign' => 'vertical-align: %s;',
149
+                    'width' => 'width: %s;',
150
+                    ),
151
+            'tfoot' =>
152
+            array (
153
+                    'align' => '!set_table_row_align',
154
+                    'valign' => '!set_table_row_valign',
155
+                    ),
156
+            'th' =>
157
+            array (
158
+                    'align' => 'text-align: %s;',
159
+                    'bgcolor' => 'background-color: %s;',
160
+                    'height' => 'height: %s;',
161
+                    'nowrap' => 'white-space: nowrap;',
162
+                    'valign' => 'vertical-align: %s;',
163
+                    'width' => 'width: %s;',
164
+                    ),
165
+            'thead' =>
166
+            array (
167
+                    'align' => '!set_table_row_align',
168
+                    'valign' => '!set_table_row_valign',
169
+                    ),
170
+            'tr' =>
171
+            array (
172
+                    'align' => '!set_table_row_align',
173
+                    'bgcolor' => '!set_table_row_bgcolor',
174
+                    'valign' => '!set_table_row_valign',
175
+                    ),
176
+            'body' =>
177
+            array (
178
+                    'background' => 'background-image: url(%s);',
179
+                    'bgcolor' => 'background-color: %s;',
180
+                    'link' => '!set_body_link',
181
+                    'text' => 'color: %s;',
182
+                    ),
183
+            'br' =>
184
+            array (
185
+                    'clear' => 'clear: %s;',
186
+                    ),
187
+            'basefont' =>
188
+            array (
189
+                    'color' => 'color: %s;',
190
+                    'face' => 'font-family: %s;',
191
+                    'size' => '!set_basefont_size',
192
+                    ),
193
+            'font' =>
194
+            array (
195
+                    'color' => 'color: %s;',
196
+                    'face' => 'font-family: %s;',
197
+                    'size' => '!set_font_size',
198
+                    ),
199
+            'dir' =>
200
+            array (
201
+                    'compact' => 'margin: 0.5em 0;',
202
+                    ),
203
+            'dl' =>
204
+            array (
205
+                    'compact' => 'margin: 0.5em 0;',
206
+                    ),
207
+            'menu' =>
208
+            array (
209
+                    'compact' => 'margin: 0.5em 0;',
210
+                    ),
211
+            'ol' =>
212
+            array (
213
+                    'compact' => 'margin: 0.5em 0;',
214
+                    'start' => 'counter-reset: -dompdf-default-counter %d;',
215
+                    'type' => 'list-style-type: %s;',
216
+                    ),
217
+            'ul' =>
218
+            array (
219
+                    'compact' => 'margin: 0.5em 0;',
220
+                    'type' => 'list-style-type: %s;',
221
+                    ),
222
+            'li' =>
223
+            array (
224
+                    'type' => 'list-style-type: %s;',
225
+                    'value' => 'counter-reset: -dompdf-default-counter %d;',
226
+                    ),
227
+            'pre' =>
228
+            array (
229
+                    'width' => 'width: %s;',
230
+                    ),
231
+            );
233 232
 
234 233
   
235
-  static protected $_last_basefont_size = 3;
236
-  static protected $_font_size_lookup = array(1=>"xx-small",
237
-                                              2=>"x-small",
238
-                                              3=>"medium",
239
-                                              4=>"large",
240
-                                              5=>"x-large",
241
-                                              6=>"xx-large",
242
-                                              7=>"300%");
234
+    static protected $_last_basefont_size = 3;
235
+    static protected $_font_size_lookup = array(1=>"xx-small",
236
+                                                2=>"x-small",
237
+                                                3=>"medium",
238
+                                                4=>"large",
239
+                                                5=>"x-large",
240
+                                                6=>"xx-large",
241
+                                                7=>"300%");
243 242
   
244 243
   
245
-  static function translate_attributes($frame) {
244
+    static function translate_attributes($frame) {
246 245
     $node = $frame->get_node();
247 246
     $tag = $node->tagName;
248 247
 
249 248
     if ( !isset(self::$__ATTRIBUTE_LOOKUP[$tag]) )
250
-      return;
249
+        return;
251 250
 
252 251
     $valid_attrs = self::$__ATTRIBUTE_LOOKUP[$tag];
253 252
     $attrs = $node->attributes;
254 253
     $style = rtrim($node->getAttribute("style"), "; ");
255 254
     if ( $style != "" )
256
-      $style .= ";";
255
+        $style .= ";";
257 256
 
258 257
     foreach ($attrs as $attr => $attr_node ) {
259
-      if ( !isset($valid_attrs[$attr]) )
258
+        if ( !isset($valid_attrs[$attr]) )
260 259
         continue;
261 260
 
262
-      $value = $attr_node->value;
261
+        $value = $attr_node->value;
263 262
 
264
-      $target = $valid_attrs[$attr];
263
+        $target = $valid_attrs[$attr];
265 264
       
266
-      // Look up $value in $target, if $target is an array:
267
-      if ( is_array($target) ) {
265
+        // Look up $value in $target, if $target is an array:
266
+        if ( is_array($target) ) {
268 267
 
269 268
         if ( isset($target[$value]) )
270
-          $style .= " " . self::_resolve_target($node, $target[$value], $value);
269
+            $style .= " " . self::_resolve_target($node, $target[$value], $value);
271 270
 
272
-      } else {
271
+        } else {
273 272
         // otherwise use target directly
274 273
         $style .= " " . self::_resolve_target($node, $target, $value);
275
-      }
274
+        }
276 275
     }
277 276
     if ( !is_null($style) ) {
278
-      $style = ltrim($style);
279
-      $node->setAttribute("style", $style);
277
+        $style = ltrim($style);
278
+        $node->setAttribute("style", $style);
280 279
     }
281 280
     
282
-  }
281
+    }
283 282
 
284
-  static protected function _resolve_target($node, $target, $value) {
283
+    static protected function _resolve_target($node, $target, $value) {
285 284
     if ( $target[0] === "!" ) {
286
-      // Function call
287
-      $func = "_" . mb_substr($target, 1);
288
-      return self::$func($node, $value);
285
+        // Function call
286
+        $func = "_" . mb_substr($target, 1);
287
+        return self::$func($node, $value);
289 288
     }
290 289
     
291 290
     return $value ? sprintf($target, $value) : "";
292
-  }
291
+    }
293 292
 
294
-  //.....................................................................
293
+    //.....................................................................
295 294
 
296
-  static protected function _set_table_cellpadding($node, $value) {
295
+    static protected function _set_table_cellpadding($node, $value) {
297 296
 
298 297
     $td_list = $node->getElementsByTagName("td");
299 298
     foreach ($td_list as $td) {
300
-      $style = rtrim($td->getAttribute("style"), ";");
301
-      $style .= "; padding: $value" . "px;";
302
-      $style = ltrim($style, ";");
303
-      $td->setAttribute("style", $style);
299
+        $style = rtrim($td->getAttribute("style"), ";");
300
+        $style .= "; padding: $value" . "px;";
301
+        $style = ltrim($style, ";");
302
+        $td->setAttribute("style", $style);
304 303
     }
305 304
     return null;
306
-  }
305
+    }
307 306
 
308
-  static protected function _set_table_border($node, $value) {
307
+    static protected function _set_table_border($node, $value) {
309 308
     $td_list = $node->getElementsByTagName("td");
310 309
     foreach ($td_list as $td) {
311
-      $style = $td->getAttribute("style");
312
-      if ( strpos($style, "border") !== false )
310
+        $style = $td->getAttribute("style");
311
+        if ( strpos($style, "border") !== false )
313 312
         continue;
314
-      $style = rtrim($style, ";");
315
-      $style .= "; border-width: $value" . "px; border-style: ridge;";
316
-      $style = ltrim($style, ";");
317
-      $td->setAttribute("style", $style);
313
+        $style = rtrim($style, ";");
314
+        $style .= "; border-width: $value" . "px; border-style: ridge;";
315
+        $style = ltrim($style, ";");
316
+        $td->setAttribute("style", $style);
318 317
     }
319 318
     $th_list = $node->getElementsByTagName("th");
320 319
     foreach ($th_list as $th) {
321
-      $style = $th->getAttribute("style");
322
-      if ( strpos($style, "border") !== false )
320
+        $style = $th->getAttribute("style");
321
+        if ( strpos($style, "border") !== false )
323 322
         continue;
324
-      $style = rtrim($style, ";");
325
-      $style .= "; border-width: $value" . "px; border-style: ridge;";
326
-      $style = ltrim($style, ";");
327
-      $th->setAttribute("style", $style);
323
+        $style = rtrim($style, ";");
324
+        $style .= "; border-width: $value" . "px; border-style: ridge;";
325
+        $style = ltrim($style, ";");
326
+        $th->setAttribute("style", $style);
328 327
     }
329 328
     
330 329
     return null;
331
-  }
330
+    }
332 331
 
333
-  static protected function _set_table_cellspacing($node, $value) {
332
+    static protected function _set_table_cellspacing($node, $value) {
334 333
     $style = rtrim($td->getAttribute($style), ";");
335 334
 
336 335
     if ( $value == 0 )
337
-      $style .= "; border-collapse: collapse;";
336
+        $style .= "; border-collapse: collapse;";
338 337
       
339 338
     else
340
-      $style = "; border-collapse: separate;";
339
+        $style = "; border-collapse: separate;";
341 340
       
342 341
     return ltrim($style, ";");
343
-  }
342
+    }
344 343
   
345
-  static protected function _set_table_rules($node, $value) {
344
+    static protected function _set_table_rules($node, $value) {
346 345
     $new_style = "; border-collapse: collapse;";
347 346
     switch ($value) {
348 347
     case "none":
349 348
       $new_style .= "border-style: none;";
350
-      break;
349
+        break;
351 350
 
352 351
     case "groups":
353 352
       // FIXME: unsupported
@@ -355,15 +354,15 @@  discard block
 block discarded – undo
355 354
 
356 355
     case "rows":
357 356
       $new_style .= "border-style: solid none solid none; border-width: 1px; ";
358
-      break;
357
+        break;
359 358
 
360 359
     case "cols":
361 360
       $new_style .= "border-style: none solid none solid; border-width: 1px; ";
362
-      break;
361
+        break;
363 362
 
364 363
     case "all":
365 364
       $new_style .= "border-style: solid; border-width: 1px; ";
366
-      break;
365
+        break;
367 366
       
368 367
     default:
369 368
       // Invalid value
@@ -373,118 +372,118 @@  discard block
 block discarded – undo
373 372
     $td_list = $node->getElementsByTagName("td");
374 373
     
375 374
     foreach ($td_list as $td) {
376
-      $style = $td->getAttribute("style");
377
-      $style .= $new_style;
378
-      $td->setAttribute("style", $style);
375
+        $style = $td->getAttribute("style");
376
+        $style .= $new_style;
377
+        $td->setAttribute("style", $style);
379 378
     }
380 379
     return null;
381
-  }
380
+    }
382 381
 
383
-  static protected function _set_hr_align($node, $value) {
382
+    static protected function _set_hr_align($node, $value) {
384 383
 
385 384
     $style = rtrim($node->getAttribute("style"),";");
386 385
     $width = $node->getAttribute("width");
387 386
     if ( $width == "" )
388
-      $width = "100%";
387
+        $width = "100%";
389 388
 
390 389
     $remainder = 100 - (double)rtrim($width, "% ");
391 390
     
392 391
     switch ($value) {
393 392
     case "left":
394 393
       $style .= "; margin-right: $remainder %;";
395
-      break;
394
+        break;
396 395
 
397 396
     case "right":
398 397
       $style .= "; margin-left: $remainder %;";
399
-      break;
398
+        break;
400 399
 
401 400
     case "center":
402 401
       $style .= "; margin-left: auto; margin-right: auto;";
403
-      break;
402
+        break;
404 403
 
405 404
     default:
406 405
       return null;
407 406
     }
408 407
     return ltrim($style, "; ");
409 408
     
410
-  }
409
+    }
411 410
 
412
-  static protected function _set_table_row_align($node, $value) {
411
+    static protected function _set_table_row_align($node, $value) {
413 412
 
414 413
     $td_list = $node->getElementsByTagName("td");
415 414
 
416 415
     foreach ($td_list as $td) {
417
-      $style = rtrim($td->getAttribute("style"), ";");
418
-      $style .= "; text-align: $value;";
419
-      $style = ltrim($style, "; ");
420
-      $td->setAttribute("style", $style);
416
+        $style = rtrim($td->getAttribute("style"), ";");
417
+        $style .= "; text-align: $value;";
418
+        $style = ltrim($style, "; ");
419
+        $td->setAttribute("style", $style);
421 420
     }
422 421
 
423 422
     return null;
424
-  }
423
+    }
425 424
 
426
-  static protected function _set_table_row_valign($node, $value) {
425
+    static protected function _set_table_row_valign($node, $value) {
427 426
 
428 427
     $td_list = $node->getElementsByTagName("td");
429 428
 
430 429
     foreach ($td_list as $td) {
431
-      $style = rtrim($td->getAttribute("style"), ";");
432
-      $style .= "; vertical-align: $value;";
433
-      $style = ltrim($style, "; ");
434
-      $td->setAttribute("style", $style);
430
+        $style = rtrim($td->getAttribute("style"), ";");
431
+        $style .= "; vertical-align: $value;";
432
+        $style = ltrim($style, "; ");
433
+        $td->setAttribute("style", $style);
435 434
     }
436 435
 
437 436
     return null;
438
-  }
437
+    }
439 438
 
440
-  static protected function _set_table_row_bgcolor($node, $value) {
439
+    static protected function _set_table_row_bgcolor($node, $value) {
441 440
 
442 441
     $td_list = $node->getElementsByTagName("td");
443 442
 
444 443
     foreach ($td_list as $td) {
445
-      $style = rtrim($td->getAttribute("style"), ";");
446
-      $style .= "; background-color: $value;";
447
-      $style = ltrim($style, "; ");
448
-      $td->setAttribute("style", $style);
444
+        $style = rtrim($td->getAttribute("style"), ";");
445
+        $style .= "; background-color: $value;";
446
+        $style = ltrim($style, "; ");
447
+        $td->setAttribute("style", $style);
449 448
     }
450 449
 
451 450
     return null;
452
-  }
451
+    }
453 452
 
454
-  static protected function _set_body_link($node, $value) {
453
+    static protected function _set_body_link($node, $value) {
455 454
 
456 455
     $a_list = $node->getElementsByTagName("a");
457 456
 
458 457
     foreach ($a_list as $a) {
459
-      $style = rtrim($a->getAttribute("style"), ";");
460
-      $style .= "; color: $value;";
461
-      $style = ltrim($style, "; ");
462
-      $a->setAttribute("style", $style);
458
+        $style = rtrim($a->getAttribute("style"), ";");
459
+        $style .= "; color: $value;";
460
+        $style = ltrim($style, "; ");
461
+        $a->setAttribute("style", $style);
463 462
     }
464 463
 
465 464
     return null;
466
-  }
465
+    }
467 466
 
468
-  static protected function _set_basefont_size($node, $value) {
467
+    static protected function _set_basefont_size($node, $value) {
469 468
     // FIXME: ? we don't actually set the font size of anything here, just
470 469
     // the base size for later modification by <font> tags.
471 470
     self::$_last_basefont_size = $value;
472 471
     return null;
473
-  }
472
+    }
474 473
   
475
-  static protected function _set_font_size($node, $value) {
474
+    static protected function _set_font_size($node, $value) {
476 475
     $style = $node->getAttribute("style");
477 476
 
478 477
     if ( $value[0] === "-" || $value[0] === "+" )
479
-      $value = self::$_last_basefont_size + (int)$value;
478
+        $value = self::$_last_basefont_size + (int)$value;
480 479
 
481 480
     if ( isset(self::$_font_size_lookup[$value]) )
482
-      $style .= "; font-size: " . self::$_font_size_lookup[$value] . ";";
481
+        $style .= "; font-size: " . self::$_font_size_lookup[$value] . ";";
483 482
     else
484
-      $style .= "; font-size: $value;";
483
+        $style .= "; font-size: $value;";
485 484
 
486 485
     return ltrim($style, "; ");
487 486
     
488
-  }
487
+    }
489 488
 
490 489
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/table_cell_positioner.cls.php 1 patch
Indentation   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,7 +34,6 @@  discard block
 block discarded – undo
34 34
  * @copyright 2004 Benj Carson
35 35
  * @author Benj Carson <[email protected]>
36 36
  * @package dompdf
37
-
38 37
  */
39 38
 
40 39
 /* $Id: table_cell_positioner.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -47,15 +46,15 @@  discard block
 block discarded – undo
47 46
  */
48 47
 class Table_Cell_Positioner extends Positioner {
49 48
 
50
-  function __construct(Frame_Decorator $frame) { parent::__construct($frame); }
49
+    function __construct(Frame_Decorator $frame) { parent::__construct($frame); }
51 50
   
52
-  //........................................................................
51
+    //........................................................................
53 52
 
54
-  function position() {
53
+    function position() {
55 54
 
56 55
     $table = Table_Frame_Decorator::find_parent_table($this->_frame);
57 56
     $cellmap = $table->get_cellmap();
58 57
     $this->_frame->set_position($cellmap->get_frame_position($this->_frame));
59 58
 
60
-  }
59
+    }
61 60
 }
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/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/block_positioner.cls.php 1 patch
Indentation   +7 added lines, -8 removed lines patch added patch discarded remove patch
@@ -34,7 +34,6 @@  discard block
 block discarded – undo
34 34
  * @copyright 2004 Benj Carson
35 35
  * @author Benj Carson <[email protected]>
36 36
  * @package dompdf
37
-
38 37
  */
39 38
 
40 39
 /* $Id: block_positioner.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -48,24 +47,24 @@  discard block
 block discarded – undo
48 47
 class Block_Positioner extends Positioner {
49 48
 
50 49
 
51
-  function __construct(Frame_Decorator $frame) { parent::__construct($frame); }
50
+    function __construct(Frame_Decorator $frame) { parent::__construct($frame); }
52 51
   
53
-  //........................................................................
52
+    //........................................................................
54 53
 
55
-  function position() {
54
+    function position() {
56 55
     $cb = $this->_frame->get_containing_block();
57 56
 
58 57
     $p = $this->_frame->find_block_parent();
59 58
     
60 59
     if ( $p ) {
61
-      $p->add_line();
62
-      $y = $p->get_current_line("y");
60
+        $p->add_line();
61
+        $y = $p->get_current_line("y");
63 62
       
64 63
     } else
65
-      $y = $cb["y"];
64
+        $y = $cb["y"];
66 65
 
67 66
     $x = $cb["x"];
68 67
     
69 68
     $this->_frame->set_position($x, $y);
70
-  }
69
+    }
71 70
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/list_bullet_positioner.cls.php 1 patch
Indentation   +16 added lines, -17 removed lines patch added patch discarded remove patch
@@ -35,7 +35,6 @@  discard block
 block discarded – undo
35 35
  * @author Benj Carson <[email protected]>
36 36
  * @contributor Helmut Tischer <[email protected]>
37 37
  * @package dompdf
38
-
39 38
  *
40 39
  * Changes
41 40
  * @contributor Helmut Tischer <[email protected]>
@@ -53,11 +52,11 @@  discard block
 block discarded – undo
53 52
  */
54 53
 class List_Bullet_Positioner extends Positioner {
55 54
 
56
-  function __construct(Frame_Decorator $frame) { parent::__construct($frame); }
55
+    function __construct(Frame_Decorator $frame) { parent::__construct($frame); }
57 56
   
58
-  //........................................................................
57
+    //........................................................................
59 58
 
60
-  function position() {
59
+    function position() {
61 60
     
62 61
     // Bullets & friends are positioned an absolute distance to the left of
63 62
     // the content edge of their parent element
@@ -75,19 +74,19 @@  discard block
 block discarded – undo
75 74
     // This is a bit of a hack...
76 75
     $n = $this->_frame->get_next_sibling();
77 76
     if ( $n ) {
78
-      $style = $n->get_style();
79
-      $y += $style->length_in_pt( array($style->margin_top, $style->padding_top),
80
-                                  $n->get_containing_block("w") );
77
+        $style = $n->get_style();
78
+        $y += $style->length_in_pt( array($style->margin_top, $style->padding_top),
79
+                                    $n->get_containing_block("w") );
81 80
     }
82 81
 
83
-	// Now the position is the left top of the block which should be marked with the bullet.
84
-	// We tried to find out the y of the start of the first text character within the block.
85
-	// But the top margin/padding does not fit, neither from this nor from the next sibling
86
-	// The "bit of a hack" above does not work also.
82
+    // Now the position is the left top of the block which should be marked with the bullet.
83
+    // We tried to find out the y of the start of the first text character within the block.
84
+    // But the top margin/padding does not fit, neither from this nor from the next sibling
85
+    // The "bit of a hack" above does not work also.
87 86
 	
88
-	// Instead let's position the bullet vertically centered to the block which should be marked.
89
-	// But for get_next_sibling() the get_containing_block is all zero, and for find_block_parent()
90
-	// the get_containing_block is paper width and the entire list as height.
87
+    // Instead let's position the bullet vertically centered to the block which should be marked.
88
+    // But for get_next_sibling() the get_containing_block is all zero, and for find_block_parent()
89
+    // the get_containing_block is paper width and the entire list as height.
91 90
 	
92 91
     // if ($p) {
93 92
     //   //$cb = $n->get_containing_block();
@@ -96,8 +95,8 @@  discard block
 block discarded – undo
96 95
     // print 'cb:'.$cb["x"].':'.$cb["y"].':'.$cb["w"].':'.$cb["h"].':';
97 96
     // }	 
98 97
 
99
-	// Todo:
100
-	// For now give up on the above. Use Guesswork with font y-pos in the middle of the line spacing
98
+    // Todo:
99
+    // For now give up on the above. Use Guesswork with font y-pos in the middle of the line spacing
101 100
 
102 101
     $style = $p->get_style();
103 102
     $font_size = $style->get_font_size();
@@ -107,5 +106,5 @@  discard block
 block discarded – undo
107 106
     //Position is x-end y-top of character position of the bullet.    
108 107
     $this->_frame->set_position($x, $y);
109 108
     
110
-  }
109
+    }
111 110
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/table_row_frame_decorator.cls.php 1 patch
Indentation   +13 added lines, -14 removed lines patch added patch discarded remove patch
@@ -34,7 +34,6 @@  discard block
 block discarded – undo
34 34
  * @copyright 2004 Benj Carson
35 35
  * @author Benj Carson <[email protected]>
36 36
  * @package dompdf
37
-
38 37
  */
39 38
 
40 39
 /* $Id: table_row_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -47,35 +46,35 @@  discard block
 block discarded – undo
47 46
  */
48 47
 class Table_Row_Frame_Decorator extends Frame_Decorator {
49 48
 
50
-  // protected members
49
+    // protected members
51 50
   
52
-  function __construct(Frame $frame, DOMPDF $dompdf) {
51
+    function __construct(Frame $frame, DOMPDF $dompdf) {
53 52
     parent::__construct($frame, $dompdf);
54
-  }
53
+    }
55 54
   
56
-  //........................................................................ 
55
+    //........................................................................ 
57 56
 
58
-  /**
59
-   * Remove all non table-cell frames from this row and move them after
60
-   * the table.
61
-   */
62
-  function normalise() {
57
+    /**
58
+     * Remove all non table-cell frames from this row and move them after
59
+     * the table.
60
+     */
61
+    function normalise() {
63 62
 
64 63
     // Find our table parent
65 64
     $p = Table_Frame_Decorator::find_parent_table($this);
66 65
     
67 66
     $erroneous_frames = array();
68 67
     foreach ($this->get_children() as $child) {      
69
-      $display = $child->get_style()->display;
68
+        $display = $child->get_style()->display;
70 69
 
71
-      if ( $display !== "table-cell" )
70
+        if ( $display !== "table-cell" )
72 71
         $erroneous_frames[] = $child;
73 72
     }
74 73
     
75 74
     //  dump the extra nodes after the table.
76 75
     foreach ($erroneous_frames as $frame) 
77
-      $p->move_after($frame);
78
-  }
76
+        $p->move_after($frame);
77
+    }
79 78
   
80 79
   
81 80
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/block_frame_reflower.cls.php 1 patch
Indentation   +172 added lines, -173 removed lines patch added patch discarded remove patch
@@ -34,7 +34,6 @@  discard block
 block discarded – undo
34 34
  * @copyright 2004 Benj Carson
35 35
  * @author Benj Carson <[email protected]>
36 36
  * @package dompdf
37
-
38 37
  */
39 38
 
40 39
 /* $Id: block_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -46,17 +45,17 @@  discard block
 block discarded – undo
46 45
  * @package dompdf
47 46
  */
48 47
 class Block_Frame_Reflower extends Frame_Reflower {
49
-  const MIN_JUSTIFY_WIDTH = 0.80;  // (Minimum line width to justify, as
50
-                                   // fraction of available width)
48
+    const MIN_JUSTIFY_WIDTH = 0.80;  // (Minimum line width to justify, as
49
+                                    // fraction of available width)
51 50
 
52
-  function __construct(Block_Frame_Decorator $frame) { parent::__construct($frame); }
51
+    function __construct(Block_Frame_Decorator $frame) { parent::__construct($frame); }
53 52
 
54
-  //........................................................................
53
+    //........................................................................
55 54
 
56
-  // Calculate the ideal used value for the width property as per:
57
-  // http://www.w3.org/TR/CSS21/visudet.html#Computing_widths_and_margins
55
+    // Calculate the ideal used value for the width property as per:
56
+    // http://www.w3.org/TR/CSS21/visudet.html#Computing_widths_and_margins
58 57
 
59
-  protected function _calculate_width($width) {
58
+    protected function _calculate_width($width) {
60 59
     $style = $this->_frame->get_style();
61 60
     $w = $this->_frame->get_containing_block("w");
62 61
 
@@ -68,20 +67,20 @@  discard block
 block discarded – undo
68 67
     
69 68
     // Handle 'auto' values
70 69
     $dims = array($style->border_left_width,
71
-                  $style->border_right_width,
72
-                  $style->padding_left,
73
-                  $style->padding_right,
74
-                  $width !== "auto" ? $width : 0,
75
-                  $rm !== "auto" ? $rm : 0,
76
-                  $lm !== "auto" ? $lm : 0);
70
+                    $style->border_right_width,
71
+                    $style->padding_left,
72
+                    $style->padding_right,
73
+                    $width !== "auto" ? $width : 0,
74
+                    $rm !== "auto" ? $rm : 0,
75
+                    $lm !== "auto" ? $lm : 0);
77 76
 
78 77
     // absolutely positioned boxes take the 'left' and 'right' properties into account
79 78
     if ( $style->position === "absolute" || $style->position === "fixed" ) {
80
-      $absolute = true;
81
-      $dims[] = $left !== "auto" ? $left : 0;
82
-      $dims[] = $right !== "auto" ? $right : 0;
79
+        $absolute = true;
80
+        $dims[] = $left !== "auto" ? $left : 0;
81
+        $dims[] = $right !== "auto" ? $right : 0;
83 82
     } else {
84
-      $absolute = false;
83
+        $absolute = false;
85 84
     }
86 85
 
87 86
     $sum = $style->length_in_pt($dims, $w);
@@ -91,99 +90,99 @@  discard block
 block discarded – undo
91 90
 
92 91
     if ( $diff > 0 ) {
93 92
 
94
-      if ( $absolute ) {
93
+        if ( $absolute ) {
95 94
 
96 95
         // resolve auto properties: see
97 96
         // http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-width
98 97
 
99 98
         if ( $width === "auto" && $left === "auto" && $right === "auto" ) {
100 99
 
101
-          if ( $lm === "auto" )
100
+            if ( $lm === "auto" )
102 101
             $lm = 0;
103
-          if ( $rm === "auto" )
102
+            if ( $rm === "auto" )
104 103
             $rm = 0;
105 104
 
106
-          // Technically, the width should be "shrink-to-fit" i.e. based on the
107
-          // preferred width of the content...  a little too costly here as a
108
-          // special case.  Just get the width to take up the slack:
109
-          $left = 0;
110
-          $right = 0;
111
-          $width = $diff;
105
+            // Technically, the width should be "shrink-to-fit" i.e. based on the
106
+            // preferred width of the content...  a little too costly here as a
107
+            // special case.  Just get the width to take up the slack:
108
+            $left = 0;
109
+            $right = 0;
110
+            $width = $diff;
112 111
 
113 112
         } else if ( $width === "auto" ) {
114 113
 
115
-          if ( $lm === "auto" )
114
+            if ( $lm === "auto" )
116 115
             $lm = 0;
117
-          if ( $rm === "auto" )
116
+            if ( $rm === "auto" )
118 117
             $rm = 0;
119
-          if ( $left === "auto" )
118
+            if ( $left === "auto" )
120 119
             $left = 0;
121
-          if ( $right === "auto" )
120
+            if ( $right === "auto" )
122 121
             $right = 0;
123 122
 
124
-          $width = $diff;
123
+            $width = $diff;
125 124
 
126 125
         } else if ( $left === "auto" ) {
127
-          if ( $lm === "auto" )
126
+            if ( $lm === "auto" )
128 127
             $lm = 0;
129
-          if ( $rm === "auto" )
128
+            if ( $rm === "auto" )
130 129
             $rm = 0;
131
-          if ( $right === "auto" )
130
+            if ( $right === "auto" )
132 131
             $right = 0;
133 132
 
134
-          $left = $diff;
133
+            $left = $diff;
135 134
 
136 135
         } else if ( $right === "auto" ) {
137 136
 
138
-          if ( $lm === "auto" )
137
+            if ( $lm === "auto" )
139 138
             $lm = 0;
140
-          if ( $rm === "auto" )
139
+            if ( $rm === "auto" )
141 140
             $rm = 0;
142 141
 
143
-          $right = $diff;
142
+            $right = $diff;
144 143
         }
145 144
 
146
-      } else {
145
+        } else {
147 146
 
148 147
         // Find auto properties and get them to take up the slack
149 148
         if ( $width === "auto" )
150
-          $width = $diff;
149
+            $width = $diff;
151 150
 
152 151
         else if ( $lm === "auto" && $rm === "auto" )
153
-          $lm = $rm = round($diff / 2);
152
+            $lm = $rm = round($diff / 2);
154 153
 
155 154
         else if ( $lm === "auto" )
156
-          $lm = $diff;
155
+            $lm = $diff;
157 156
 
158 157
         else if ( $rm === "auto" )
159
-          $rm = $diff;
160
-      }
158
+            $rm = $diff;
159
+        }
161 160
 
162 161
     } else if ($diff < 0) {
163 162
 
164
-      // We are over constrained--set margin-right to the difference
165
-      $rm = $diff;
163
+        // We are over constrained--set margin-right to the difference
164
+        $rm = $diff;
166 165
 
167 166
     }
168 167
 
169 168
     $ret = array("width"=> $width, "margin_left" => $lm, "margin_right" => $rm, "left" => $left, "right" => $right);
170 169
 
171 170
     return $ret;
172
-  }
171
+    }
173 172
 
174
-  // Call the above function, but resolve max/min widths
175
-  protected function _calculate_restricted_width() {
173
+    // Call the above function, but resolve max/min widths
174
+    protected function _calculate_restricted_width() {
176 175
     $style = $this->_frame->get_style();
177 176
     $cb = $this->_frame->get_containing_block();
178 177
 
179 178
     if ( !isset($cb["w"]) )
180
-      throw new DOMPDF_Exception("Box property calculation requires containing block width");
179
+        throw new DOMPDF_Exception("Box property calculation requires containing block width");
181 180
 
182 181
     // Treat width 100% as auto
183 182
     if ( $style->width === "100%" )
184
-      $width = "auto";
183
+        $width = "auto";
185 184
     else
186
-      $width = $style->length_in_pt($style->width, $cb["w"]);
185
+        $width = $style->length_in_pt($style->width, $cb["w"]);
187 186
 
188 187
     extract($this->_calculate_width($width));
189 188
 
@@ -192,37 +191,37 @@  discard block
 block discarded – undo
192 191
     $max_width = $style->length_in_pt($style->max_width, $cb["w"]);
193 192
 
194 193
     if ( $max_width !== "none" && $min_width > $max_width)
195
-      // Swap 'em
196
-      list($max_width, $min_width) = array($min_width, $max_width);
194
+        // Swap 'em
195
+        list($max_width, $min_width) = array($min_width, $max_width);
197 196
 
198 197
     if ( $max_width !== "none" && $width > $max_width )
199
-      extract($this->_calculate_width($max_width));
198
+        extract($this->_calculate_width($max_width));
200 199
 
201 200
     if ( $width < $min_width )
202
-      extract($this->_calculate_width($min_width));
201
+        extract($this->_calculate_width($min_width));
203 202
 
204 203
     return array($width, $margin_left, $margin_right, $left, $right);
205 204
 
206
-  }
205
+    }
207 206
 
208
-  //........................................................................
207
+    //........................................................................
209 208
 
210
-  // Determine the unrestricted height of content within the block
211
-  protected function _calculate_content_height() {
209
+    // Determine the unrestricted height of content within the block
210
+    protected function _calculate_content_height() {
212 211
 
213 212
     // Calculate the actual height
214 213
     $height = 0;
215 214
     
216 215
     // Add the height of all lines
217 216
     foreach ($this->_frame->get_lines() as $line)
218
-      $height += $line["h"];
217
+        $height += $line["h"];
219 218
 
220 219
     return $height;
221 220
 
222
-  }
221
+    }
223 222
 
224
-  // Determine the frame's restricted height
225
-  protected function _calculate_restricted_height() {
223
+    // Determine the frame's restricted height
224
+    protected function _calculate_restricted_height() {
226 225
     $style = $this->_frame->get_style();
227 226
     $content_height = $this->_calculate_content_height();
228 227
     $cb = $this->_frame->get_containing_block();
@@ -237,9 +236,9 @@  discard block
 block discarded – undo
237 236
 
238 237
     if ( $style->position === "absolute" || $style->position === "fixed" ) {
239 238
 
240
-      // see http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-height
239
+        // see http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-height
241 240
 
242
-      $dims = array($top !== "auto" ? $top : 0,
241
+        $dims = array($top !== "auto" ? $top : 0,
243 242
                     $style->margin_top !== "auto" ? $style->margin_top : 0,
244 243
                     $style->padding_top,
245 244
                     $style->border_top_width,
@@ -249,153 +248,153 @@  discard block
 block discarded – undo
249 248
                     $style->margin_bottom !== "auto" ? $style->margin_bottom : 0,
250 249
                     $bottom !== "auto" ? $bottom : 0);
251 250
 
252
-      $sum = $style->length_in_pt($dims, $cb["h"]);
251
+        $sum = $style->length_in_pt($dims, $cb["h"]);
253 252
 
254
-      $diff = $cb["h"] - $sum; 
253
+        $diff = $cb["h"] - $sum; 
255 254
 
256
-      if ( $diff > 0 ) {
255
+        if ( $diff > 0 ) {
257 256
 
258 257
         if ( $height === "auto" && $top === "auto" && $bottom === "auto" ) {
259 258
 
260
-          if ( $margin_top === "auto" ) 
259
+            if ( $margin_top === "auto" ) 
261 260
             $margin_top = 0;
262
-          if ( $margin_bottom === "auto" )
261
+            if ( $margin_bottom === "auto" )
263 262
             $margin_bottom = 0;
264 263
 
265
-          $height = $diff;
264
+            $height = $diff;
266 265
 
267 266
         } else if ( $height === "auto" && $top === "auto" ) {
268 267
 
269
-          if ( $margin_top === "auto" ) 
268
+            if ( $margin_top === "auto" ) 
270 269
             $margin_top = 0;
271
-          if ( $margin_bottom === "auto" )
270
+            if ( $margin_bottom === "auto" )
272 271
             $margin_bottom = 0;
273 272
 
274
-          $height = $content_height;
275
-          $top = $diff - $content_height;
273
+            $height = $content_height;
274
+            $top = $diff - $content_height;
276 275
 
277 276
         } else if ( $height === "auto" && $bottom === "auto" ) {
278 277
 
279
-          if ( $margin_top === "auto" ) 
278
+            if ( $margin_top === "auto" ) 
280 279
             $margin_top = 0;
281
-          if ( $margin_bottom === "auto" )
280
+            if ( $margin_bottom === "auto" )
282 281
             $margin_bottom = 0;
283 282
 
284
-          $height = $content_height;
285
-          $bottom = $diff - $content_height;
283
+            $height = $content_height;
284
+            $bottom = $diff - $content_height;
286 285
 
287 286
         } else if ( $top === "auto" && $bottom === "auto" ) {
288 287
 
289
-          if ( $margin_top === "auto" ) 
288
+            if ( $margin_top === "auto" ) 
290 289
             $margin_top = 0;
291
-          if ( $margin_bottom === "auto" )
290
+            if ( $margin_bottom === "auto" )
292 291
             $margin_bottom = 0;
293 292
 
294
-          $bottom = $diff;
293
+            $bottom = $diff;
295 294
 
296 295
         } else if ( $top === "auto" ) {
297 296
 
298
-          if ( $margin_top === "auto" ) 
297
+            if ( $margin_top === "auto" ) 
299 298
             $margin_top = 0;
300
-          if ( $margin_bottom === "auto" )
299
+            if ( $margin_bottom === "auto" )
301 300
             $margin_bottom = 0;
302 301
 
303
-          $top = $diff;
302
+            $top = $diff;
304 303
 
305 304
         } else if ( $height === "auto" ) {
306 305
 
307
-          if ( $margin_top === "auto" ) 
306
+            if ( $margin_top === "auto" ) 
308 307
             $margin_top = 0;
309
-          if ( $margin_bottom === "auto" )
308
+            if ( $margin_bottom === "auto" )
310 309
             $margin_bottom = 0;
311 310
 
312
-          $height = $diff;
311
+            $height = $diff;
313 312
 
314 313
         } else if ( $bottom === "auto" ) {
315 314
 
316
-          if ( $margin_top === "auto" ) 
315
+            if ( $margin_top === "auto" ) 
317 316
             $margin_top = 0;
318
-          if ( $margin_bottom === "auto" )
317
+            if ( $margin_bottom === "auto" )
319 318
             $margin_bottom = 0;
320 319
 
321
-          $bottom = $diff;
320
+            $bottom = $diff;
322 321
 
323 322
         } else {
324 323
 
325
-          if ( $style->overflow === "visible" ) {
324
+            if ( $style->overflow === "visible" ) {
326 325
 
327 326
             // set all autos to zero
328 327
             if ( $margin_top === "auto" ) 
329
-              $margin_top = 0;
328
+                $margin_top = 0;
330 329
             if ( $margin_bottom === "auto" )
331
-              $margin_bottom = 0;
330
+                $margin_bottom = 0;
332 331
             if ( $top === "auto" )
333
-              $top = 0;
332
+                $top = 0;
334 333
             if ( $bottom === "auto" )
335
-              $bottom = 0;
334
+                $bottom = 0;
336 335
             if ( $height === "auto" )
337
-              $height = $content_height;
336
+                $height = $content_height;
338 337
 
339
-          }
338
+            }
340 339
 
341
-          // FIXME: overflow hidden
340
+            // FIXME: overflow hidden
342 341
         }
343 342
 
344
-      }
343
+        }
345 344
 
346 345
     } else {
347 346
 
348
-      // Expand the height if overflow is visible
349
-      if ( $height == "auto" && $content_height > $height && $style->overflow === "visible" )
347
+        // Expand the height if overflow is visible
348
+        if ( $height == "auto" && $content_height > $height && $style->overflow === "visible" )
350 349
         $height = $content_height;
351 350
 
352
-      // FIXME: this should probably be moved to a seperate function as per
353
-      // _calculate_restricted_width
351
+        // FIXME: this should probably be moved to a seperate function as per
352
+        // _calculate_restricted_width
354 353
       
355
-      // Only handle min/max height if the height is independent of the frame's content
356
-      if ( !($style->overflow === "visible" ||
354
+        // Only handle min/max height if the height is independent of the frame's content
355
+        if ( !($style->overflow === "visible" ||
357 356
              ($style->overflow === "hidden" && $height === "auto")) ) {
358 357
 
359 358
         $min_height = $style->min_height;
360 359
         $max_height = $style->max_height;
361 360
 
362 361
         if ( isset($cb["h"]) ) {
363
-          $min_height = $style->length_in_pt($min_height, $cb["h"]);
364
-          $max_height = $style->length_in_pt($max_height, $cb["h"]);
362
+            $min_height = $style->length_in_pt($min_height, $cb["h"]);
363
+            $max_height = $style->length_in_pt($max_height, $cb["h"]);
365 364
 
366 365
         } else if ( isset($cb["w"]) ) {
367 366
 
368
-          if ( mb_strpos($min_height, "%") !== false )
367
+            if ( mb_strpos($min_height, "%") !== false )
369 368
             $min_height = 0;
370
-          else
369
+            else
371 370
             $min_height = $style->length_in_pt($min_height, $cb["w"]);
372 371
 
373
-          if ( mb_strpos($max_height, "%") !== false )
372
+            if ( mb_strpos($max_height, "%") !== false )
374 373
             $max_height = "none";
375
-          else
374
+            else
376 375
             $max_height = $style->length_in_pt($max_height, $cb["w"]);
377 376
         }
378 377
 
379 378
         if ( $max_height !== "none" && $min_height > $max_height )
380
-          // Swap 'em
381
-          list($max_height, $min_height) = array($min_height, $max_height);
379
+            // Swap 'em
380
+            list($max_height, $min_height) = array($min_height, $max_height);
382 381
 
383 382
         if ( $max_height !== "none" && $height > $max_height )
384
-          $height = $max_height;
383
+            $height = $max_height;
385 384
 
386 385
         if ( $height < $min_height )
387
-          $height = $min_height;
388
-      }
386
+            $height = $min_height;
387
+        }
389 388
 
390 389
     }
391 390
 
392 391
     return array($height, $margin_top, $margin_bottom, $top, $bottom);
393 392
 
394
-  }
393
+    }
395 394
 
396
-  //........................................................................
395
+    //........................................................................
397 396
 
398
-  protected function _text_align() {
397
+    protected function _text_align() {
399 398
     $style = $this->_frame->get_style();
400 399
     $w = $this->_frame->get_containing_block("w");
401 400
     $width = $style->length_in_pt($style->width, $w);
@@ -414,10 +413,10 @@  discard block
 block discarded – undo
414 413
         // Move each child over by $dx
415 414
         $dx = $width - $line["w"];
416 415
         foreach($line["frames"] as $frame)
417
-          $frame->set_position( $frame->get_position("x") + $dx );
416
+            $frame->set_position( $frame->get_position("x") + $dx );
418 417
 
419
-      }
420
-      break;
418
+        }
419
+        break;
421 420
 
422 421
 
423 422
     case "justify":
@@ -426,28 +425,28 @@  discard block
 block discarded – undo
426 425
         // Only set the spacing if the line is long enough.  This is really
427 426
         // just an aesthetic choice ;)
428 427
         if ( $line["w"] > self::MIN_JUSTIFY_WIDTH * $width ) {
429
-          // Set the spacing for each child
430
-          if ( $line["wc"] > 1 )
428
+            // Set the spacing for each child
429
+            if ( $line["wc"] > 1 )
431 430
             $spacing = ($width - $line["w"]) / ($line["wc"] - 1);
432
-          else
431
+            else
433 432
             $spacing = 0;
434 433
 
435
-          $dx = 0;
436
-          foreach($line["frames"] as $frame) {
434
+            $dx = 0;
435
+            foreach($line["frames"] as $frame) {
437 436
             if ( !$frame instanceof Text_Frame_Decorator )
438
-              continue;
437
+                continue;
439 438
 
440 439
             $frame->set_position( $frame->get_position("x") + $dx );
441 440
             $frame->set_text_spacing($spacing);
442 441
             $dx += mb_substr_count($frame->get_text(), " ") * $spacing;
443
-          }
442
+            }
444 443
 
445
-          // The line (should) now occupy the entire width
446
-          $this->_frame->set_line($i, null, $width);
444
+            // The line (should) now occupy the entire width
445
+            $this->_frame->set_line($i, null, $width);
447 446
 
448 447
         }
449
-      }
450
-      break;
448
+        }
449
+        break;
451 450
 
452 451
     case "center":
453 452
     case "centre":
@@ -455,24 +454,24 @@  discard block
 block discarded – undo
455 454
         // Centre each line by moving each frame in the line by:
456 455
         $dx = ($width - $line["w"]) / 2;
457 456
         foreach ($line["frames"] as $frame)
458
-          $frame->set_position( $frame->get_position("x") + $dx );
459
-      }
460
-      break;
457
+            $frame->set_position( $frame->get_position("x") + $dx );
458
+        }
459
+        break;
461 460
     }
462 461
 
463
-  }
464
-  /**
465
-   * Align inline children vertically
466
-   */
467
-  function vertical_align() {
462
+    }
463
+    /**
464
+     * Align inline children vertically
465
+     */
466
+    function vertical_align() {
468 467
     // Align each child vertically after each line is reflowed
469 468
     foreach ( $this->_frame->get_lines() as $i => $line ) {
470 469
 
471
-      foreach ( $line["frames"] as $frame ) {
470
+        foreach ( $line["frames"] as $frame ) {
472 471
         $style = $frame->get_style();
473 472
 
474 473
         if ( $style->display !== "inline" && $style->display !== "text" )
475
-          continue;
474
+            continue;
476 475
 
477 476
         $align = $style->vertical_align;
478 477
 
@@ -482,41 +481,41 @@  discard block
 block discarded – undo
482 481
 
483 482
         case "baseline":
484 483
           $y = $line["y"] + $line["h"] - $frame_h;
485
-          break;
484
+            break;
486 485
 
487 486
         case "middle":
488 487
           $y = $line["y"] + ($line["h"] + $frame_h) / 2;
489
-          break;
488
+            break;
490 489
 
491 490
         case "sub":
492 491
           $y = $line["y"] + 0.9 * $line["h"];
493
-          break;
492
+            break;
494 493
 
495 494
         case "super":
496 495
           $y = $line["y"] + 0.1 * $line["h"];
497
-          break;
496
+            break;
498 497
 
499 498
         case  "text-top":
500 499
         case "top": // Not strictly accurate, but good enough for now
501 500
           $y = $line["y"];
502
-          break;
501
+            break;
503 502
 
504 503
         case "text-bottom":
505 504
         case "bottom":
506 505
           $y = $line["y"] + $line["h"] - $frame_h;
507
-          break;
506
+            break;
508 507
         }
509 508
 
510 509
         $x = $frame->get_position("x");
511 510
         $frame->set_position($x, $y);
512 511
 
513
-      }
512
+        }
513
+    }
514 514
     }
515
-  }
516 515
 
517
-  //........................................................................
516
+    //........................................................................
518 517
 
519
-  function reflow() {
518
+    function reflow() {
520 519
 
521 520
     // Check if a page break is forced
522 521
     $page = $this->_frame->get_root();
@@ -524,7 +523,7 @@  discard block
 block discarded – undo
524 523
 
525 524
     // Bail if the page is full
526 525
     if ( $page->is_full() )
527
-      return;
526
+        return;
528 527
 
529 528
     // Collapse margins if required
530 529
     $this->_collapse_margins();
@@ -553,12 +552,12 @@  discard block
 block discarded – undo
553 552
 
554 553
     // Determine the content edge
555 554
     $top = $style->length_in_pt(array($style->margin_top,
556
-                                      $style->padding_top,
557
-                                      $style->border_top_width), $cb["h"]);
555
+                                        $style->padding_top,
556
+                                        $style->border_top_width), $cb["h"]);
558 557
 
559 558
     $bottom = $style->length_in_pt(array($style->border_bottom_width,
560
-                                         $style->margin_bottom,
561
-                                         $style->padding_bottom), $cb["h"]);
559
+                                            $style->margin_bottom,
560
+                                            $style->padding_bottom), $cb["h"]);
562 561
 
563 562
     $cb_x = $x + $left_margin +
564 563
       $style->length_in_pt($style->border_left_width, $cb["w"]) +
@@ -574,23 +573,23 @@  discard block
 block discarded – undo
574 573
     // Set the containing blocks and reflow each child
575 574
     foreach ( $this->_frame->get_children() as $child ) {
576 575
 
577
-      // Bail out if the page is full
578
-      if ( $page->is_full() )
576
+        // Bail out if the page is full
577
+        if ( $page->is_full() )
579 578
         break;
580 579
       
581
-      $child->set_containing_block($cb_x, $cb_y, $w, $cb_h);
582
-      $child->reflow();
580
+        $child->set_containing_block($cb_x, $cb_y, $w, $cb_h);
581
+        $child->reflow();
583 582
 
584
-      // Don't add the child to the line if a page break has occurred
585
-      if ( $page->check_page_break($child) )
583
+        // Don't add the child to the line if a page break has occurred
584
+        if ( $page->check_page_break($child) )
586 585
         break;
587 586
 
588
-      // If the frame is not absolutely positioned, It's okay to add the frame
589
-      // to the line
590
-      if ( $child->get_style()->position !== "absolute" &&
587
+        // If the frame is not absolutely positioned, It's okay to add the frame
588
+        // to the line
589
+        if ( $child->get_style()->position !== "absolute" &&
591 590
            $child->get_style()->position !== "fixed" ) {
592 591
         $this->_frame->add_frame_to_line( $child );
593
-      }
592
+        }
594 593
     }
595 594
 
596 595
     // Determine our height
@@ -604,8 +603,8 @@  discard block
 block discarded – undo
604 603
     $this->_text_align();
605 604
 
606 605
     $this->vertical_align();
607
-  }
606
+    }
608 607
 
609
-  //........................................................................
608
+    //........................................................................
610 609
 
611 610
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/list_bullet_frame_reflower.cls.php 1 patch
Indentation   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -34,7 +34,6 @@  discard block
 block discarded – undo
34 34
  * @copyright 2004 Benj Carson
35 35
  * @author Benj Carson <[email protected]>
36 36
  * @package dompdf
37
-
38 37
  */
39 38
 
40 39
 /* $Id: list_bullet_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -47,20 +46,20 @@  discard block
 block discarded – undo
47 46
  */
48 47
 class List_Bullet_Frame_Reflower extends Frame_Reflower {
49 48
 
50
-  function __construct(Frame_Decorator $frame) { parent::__construct($frame); }
49
+    function __construct(Frame_Decorator $frame) { parent::__construct($frame); }
51 50
     
52
-  //........................................................................
51
+    //........................................................................
53 52
 
54
-  function reflow() {
53
+    function reflow() {
55 54
     $style = $this->_frame->get_style();
56 55
 
57 56
     $style->width = $this->_frame->get_width();
58 57
     $this->_frame->position();
59 58
 
60 59
     if ( $style->list_style_position === "inside" ) {
61
-      $p = $this->_frame->find_block_parent();
62
-      $p->add_frame_to_line($this->_frame);
60
+        $p = $this->_frame->find_block_parent();
61
+        $p->add_frame_to_line($this->_frame);
63 62
     }
64 63
 
65
-  }
64
+    }
66 65
 }
Please login to merge, or discard this patch.