PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / libraries / vendor / PhpSpreadsheet / Reader / Xml / Style / Alignment.php

Alignment.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Reader/Xml/Style/Alignment.php

72 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TablePress\PhpOffice\PhpSpreadsheet\Reader\Xml\Style;
4
5 use TablePress\PhpOffice\PhpSpreadsheet\Style\Alignment as AlignmentStyles;
6 use SimpleXMLElement;
7
8 class Alignment extends StyleBase
9 {
10 protected const VERTICAL_ALIGNMENT_STYLES = [
11 AlignmentStyles::VERTICAL_BOTTOM,
12 AlignmentStyles::VERTICAL_TOP,
13 AlignmentStyles::VERTICAL_CENTER,
14 AlignmentStyles::VERTICAL_JUSTIFY,
15 ];
16
17 protected const HORIZONTAL_ALIGNMENT_STYLES = [
18 AlignmentStyles::HORIZONTAL_GENERAL,
19 AlignmentStyles::HORIZONTAL_LEFT,
20 AlignmentStyles::HORIZONTAL_RIGHT,
21 AlignmentStyles::HORIZONTAL_CENTER,
22 AlignmentStyles::HORIZONTAL_CENTER_CONTINUOUS,
23 AlignmentStyles::HORIZONTAL_JUSTIFY,
24 ];
25
26 /** @return mixed[] */
27 public function parseStyle(SimpleXMLElement $styleAttributes): array
28 {
29 $style = [];
30
31 foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
32 $styleAttributeValue = (string) $styleAttributeValue;
33 switch ($styleAttributeKey) {
34 case 'Vertical':
35 if (self::identifyFixedStyleValue(self::VERTICAL_ALIGNMENT_STYLES, $styleAttributeValue)) {
36 $style['alignment']['vertical'] = $styleAttributeValue;
37 }
38
39 break;
40 case 'Horizontal':
41 if (self::identifyFixedStyleValue(self::HORIZONTAL_ALIGNMENT_STYLES, $styleAttributeValue)) {
42 $style['alignment']['horizontal'] = $styleAttributeValue;
43 }
44
45 break;
46 case 'WrapText':
47 $style['alignment']['wrapText'] = true;
48
49 break;
50 case 'Rotate':
51 $style['alignment']['textRotation'] = $styleAttributeValue;
52
53 break;
54 case 'Indent':
55 $style['alignment']['indent'] = $styleAttributeValue;
56
57 break;
58 case 'ReadingOrder':
59 if ($styleAttributeValue === 'RightToLeft') {
60 $style['alignment']['readOrder'] = AlignmentStyles::READORDER_RTL;
61 } elseif ($styleAttributeValue === 'LeftToRight') {
62 $style['alignment']['readOrder'] = AlignmentStyles::READORDER_LTR;
63 }
64
65 break;
66 }
67 }
68
69 return $style;
70 }
71 }
72