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 / Fill.php

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

77 lines 2.6 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\Fill as FillStyles;
6 use SimpleXMLElement;
7
8 class Fill extends StyleBase
9 {
10 public const FILL_MAPPINGS = [
11 'fillType' => [
12 'solid' => FillStyles::FILL_SOLID,
13 'gray75' => FillStyles::FILL_PATTERN_DARKGRAY,
14 'gray50' => FillStyles::FILL_PATTERN_MEDIUMGRAY,
15 'gray25' => FillStyles::FILL_PATTERN_LIGHTGRAY,
16 'gray125' => FillStyles::FILL_PATTERN_GRAY125,
17 'gray0625' => FillStyles::FILL_PATTERN_GRAY0625,
18 'horzstripe' => FillStyles::FILL_PATTERN_DARKHORIZONTAL, // horizontal stripe
19 'vertstripe' => FillStyles::FILL_PATTERN_DARKVERTICAL, // vertical stripe
20 'reversediagstripe' => FillStyles::FILL_PATTERN_DARKUP, // reverse diagonal stripe
21 'diagstripe' => FillStyles::FILL_PATTERN_DARKDOWN, // diagonal stripe
22 'diagcross' => FillStyles::FILL_PATTERN_DARKGRID, // diagoanl crosshatch
23 'thickdiagcross' => FillStyles::FILL_PATTERN_DARKTRELLIS, // thick diagonal crosshatch
24 'thinhorzstripe' => FillStyles::FILL_PATTERN_LIGHTHORIZONTAL,
25 'thinvertstripe' => FillStyles::FILL_PATTERN_LIGHTVERTICAL,
26 'thinreversediagstripe' => FillStyles::FILL_PATTERN_LIGHTUP,
27 'thindiagstripe' => FillStyles::FILL_PATTERN_LIGHTDOWN,
28 'thinhorzcross' => FillStyles::FILL_PATTERN_LIGHTGRID, // thin horizontal crosshatch
29 'thindiagcross' => FillStyles::FILL_PATTERN_LIGHTTRELLIS, // thin diagonal crosshatch
30 ],
31 ];
32
33 /** @return array{
34 * fill?: array{
35 * endColor?: array{rgb:string},
36 * startColor?: array{rgb:string},
37 * fillType?: string,
38 * }
39 * }
40 */
41 public function parseStyle(SimpleXMLElement $styleAttributes): array
42 {
43 /** @var array{
44 * fill?: array{
45 * endColor?: array{rgb:string},
46 * startColor?: array{rgb:string},
47 * fillType?: string,
48 * }
49 * }
50 */
51 $style = [];
52
53 foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValuex) {
54 $styleAttributeValue = (string) $styleAttributeValuex;
55 switch ($styleAttributeKey) {
56 case 'Color':
57 $style['fill']['endColor']['rgb'] = (string) substr($styleAttributeValue, 1);
58 $style['fill']['startColor']['rgb'] = (string) substr($styleAttributeValue, 1);
59
60 break;
61 case 'PatternColor':
62 $style['fill']['startColor']['rgb'] = (string) substr($styleAttributeValue, 1);
63
64 break;
65 case 'Pattern':
66 $lcStyleAttributeValue = strtolower((string) $styleAttributeValue);
67 $style['fill']['fillType']
68 = self::FILL_MAPPINGS['fillType'][$lcStyleAttributeValue] ?? FillStyles::FILL_NONE;
69
70 break;
71 }
72 }
73
74 return $style;
75 }
76 }
77