Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
namespace PhpOffice\PhpSpreadsheet;
4
 
5
class Theme
6
{
7
    /** @var string */
8
    private $themeColorName = 'Office';
9
 
10
    /** @var string */
11
    private $themeFontName = 'Office';
12
 
13
    public const COLOR_SCHEME_2013_PLUS_NAME = 'Office 2013+';
14
    public const COLOR_SCHEME_2013_PLUS = [
15
        'dk1' => '000000',
16
        'lt1' => 'FFFFFF',
17
        'dk2' => '44546A',
18
        'lt2' => 'E7E6E6',
19
        'accent1' => '4472C4',
20
        'accent2' => 'ED7D31',
21
        'accent3' => 'A5A5A5',
22
        'accent4' => 'FFC000',
23
        'accent5' => '5B9BD5',
24
        'accent6' => '70AD47',
25
        'hlink' => '0563C1',
26
        'folHlink' => '954F72',
27
    ];
28
 
29
    public const COLOR_SCHEME_2007_2010_NAME = 'Office 2007-2010';
30
    public const COLOR_SCHEME_2007_2010 = [
31
        'dk1' => '000000',
32
        'lt1' => 'FFFFFF',
33
        'dk2' => '1F497D',
34
        'lt2' => 'EEECE1',
35
        'accent1' => '4F81BD',
36
        'accent2' => 'C0504D',
37
        'accent3' => '9BBB59',
38
        'accent4' => '8064A2',
39
        'accent5' => '4BACC6',
40
        'accent6' => 'F79646',
41
        'hlink' => '0000FF',
42
        'folHlink' => '800080',
43
    ];
44
 
45
    /** @var string[] */
46
    private $themeColors = self::COLOR_SCHEME_2007_2010;
47
 
48
    /** @var string */
49
    private $majorFontLatin = 'Cambria';
50
 
51
    /** @var string */
52
    private $majorFontEastAsian = '';
53
 
54
    /** @var string */
55
    private $majorFontComplexScript = '';
56
 
57
    /** @var string */
58
    private $minorFontLatin = 'Calibri';
59
 
60
    /** @var string */
61
    private $minorFontEastAsian = '';
62
 
63
    /** @var string */
64
    private $minorFontComplexScript = '';
65
 
66
    /**
67
     * Map of Major (header) fonts to write.
68
     *
69
     * @var string[]
70
     */
71
    private $majorFontSubstitutions = self::FONTS_TIMES_SUBSTITUTIONS;
72
 
73
    /**
74
     * Map of Minor (body) fonts to write.
75
     *
76
     * @var string[]
77
     */
78
    private $minorFontSubstitutions = self::FONTS_ARIAL_SUBSTITUTIONS;
79
 
80
    public const FONTS_TIMES_SUBSTITUTIONS = [
81
        'Jpan' => 'MS Pゴシック',
82
        'Hang' => '맑은 고딕',
83
        'Hans' => '宋体',
84
        'Hant' => '新細明體',
85
        'Arab' => 'Times New Roman',
86
        'Hebr' => 'Times New Roman',
87
        'Thai' => 'Tahoma',
88
        'Ethi' => 'Nyala',
89
        'Beng' => 'Vrinda',
90
        'Gujr' => 'Shruti',
91
        'Khmr' => 'MoolBoran',
92
        'Knda' => 'Tunga',
93
        'Guru' => 'Raavi',
94
        'Cans' => 'Euphemia',
95
        'Cher' => 'Plantagenet Cherokee',
96
        'Yiii' => 'Microsoft Yi Baiti',
97
        'Tibt' => 'Microsoft Himalaya',
98
        'Thaa' => 'MV Boli',
99
        'Deva' => 'Mangal',
100
        'Telu' => 'Gautami',
101
        'Taml' => 'Latha',
102
        'Syrc' => 'Estrangelo Edessa',
103
        'Orya' => 'Kalinga',
104
        'Mlym' => 'Kartika',
105
        'Laoo' => 'DokChampa',
106
        'Sinh' => 'Iskoola Pota',
107
        'Mong' => 'Mongolian Baiti',
108
        'Viet' => 'Times New Roman',
109
        'Uigh' => 'Microsoft Uighur',
110
        'Geor' => 'Sylfaen',
111
    ];
112
 
113
    public const FONTS_ARIAL_SUBSTITUTIONS = [
114
        'Jpan' => 'MS Pゴシック',
115
        'Hang' => '맑은 고딕',
116
        'Hans' => '宋体',
117
        'Hant' => '新細明體',
118
        'Arab' => 'Arial',
119
        'Hebr' => 'Arial',
120
        'Thai' => 'Tahoma',
121
        'Ethi' => 'Nyala',
122
        'Beng' => 'Vrinda',
123
        'Gujr' => 'Shruti',
124
        'Khmr' => 'DaunPenh',
125
        'Knda' => 'Tunga',
126
        'Guru' => 'Raavi',
127
        'Cans' => 'Euphemia',
128
        'Cher' => 'Plantagenet Cherokee',
129
        'Yiii' => 'Microsoft Yi Baiti',
130
        'Tibt' => 'Microsoft Himalaya',
131
        'Thaa' => 'MV Boli',
132
        'Deva' => 'Mangal',
133
        'Telu' => 'Gautami',
134
        'Taml' => 'Latha',
135
        'Syrc' => 'Estrangelo Edessa',
136
        'Orya' => 'Kalinga',
137
        'Mlym' => 'Kartika',
138
        'Laoo' => 'DokChampa',
139
        'Sinh' => 'Iskoola Pota',
140
        'Mong' => 'Mongolian Baiti',
141
        'Viet' => 'Arial',
142
        'Uigh' => 'Microsoft Uighur',
143
        'Geor' => 'Sylfaen',
144
    ];
145
 
146
    public function getThemeColors(): array
147
    {
148
        return $this->themeColors;
149
    }
150
 
151
    public function setThemeColor(string $key, string $value): self
152
    {
153
        $this->themeColors[$key] = $value;
154
 
155
        return $this;
156
    }
157
 
158
    public function getThemeColorName(): string
159
    {
160
        return $this->themeColorName;
161
    }
162
 
163
    public function setThemeColorName(string $name, ?array $themeColors = null): self
164
    {
165
        $this->themeColorName = $name;
166
        if ($name === self::COLOR_SCHEME_2007_2010_NAME) {
167
            $themeColors = $themeColors ?? self::COLOR_SCHEME_2007_2010;
168
        } elseif ($name === self::COLOR_SCHEME_2013_PLUS_NAME) {
169
            $themeColors = $themeColors ?? self::COLOR_SCHEME_2013_PLUS;
170
        }
171
        if ($themeColors !== null) {
172
            $this->themeColors = $themeColors;
173
        }
174
 
175
        return $this;
176
    }
177
 
178
    public function getMajorFontLatin(): string
179
    {
180
        return $this->majorFontLatin;
181
    }
182
 
183
    public function getMajorFontEastAsian(): string
184
    {
185
        return $this->majorFontEastAsian;
186
    }
187
 
188
    public function getMajorFontComplexScript(): string
189
    {
190
        return $this->majorFontComplexScript;
191
    }
192
 
193
    public function getMajorFontSubstitutions(): array
194
    {
195
        return $this->majorFontSubstitutions;
196
    }
197
 
198
    /** @param null|array $substitutions */
199
    public function setMajorFontValues(?string $latin, ?string $eastAsian, ?string $complexScript, $substitutions): self
200
    {
201
        if (!empty($latin)) {
202
            $this->majorFontLatin = $latin;
203
        }
204
        if ($eastAsian !== null) {
205
            $this->majorFontEastAsian = $eastAsian;
206
        }
207
        if ($complexScript !== null) {
208
            $this->majorFontComplexScript = $complexScript;
209
        }
210
        if ($substitutions !== null) {
211
            $this->majorFontSubstitutions = $substitutions;
212
        }
213
 
214
        return $this;
215
    }
216
 
217
    public function getMinorFontLatin(): string
218
    {
219
        return $this->minorFontLatin;
220
    }
221
 
222
    public function getMinorFontEastAsian(): string
223
    {
224
        return $this->minorFontEastAsian;
225
    }
226
 
227
    public function getMinorFontComplexScript(): string
228
    {
229
        return $this->minorFontComplexScript;
230
    }
231
 
232
    public function getMinorFontSubstitutions(): array
233
    {
234
        return $this->minorFontSubstitutions;
235
    }
236
 
237
    /** @param null|array $substitutions */
238
    public function setMinorFontValues(?string $latin, ?string $eastAsian, ?string $complexScript, $substitutions): self
239
    {
240
        if (!empty($latin)) {
241
            $this->minorFontLatin = $latin;
242
        }
243
        if ($eastAsian !== null) {
244
            $this->minorFontEastAsian = $eastAsian;
245
        }
246
        if ($complexScript !== null) {
247
            $this->minorFontComplexScript = $complexScript;
248
        }
249
        if ($substitutions !== null) {
250
            $this->minorFontSubstitutions = $substitutions;
251
        }
252
 
253
        return $this;
254
    }
255
 
256
    public function getThemeFontName(): string
257
    {
258
        return $this->themeFontName;
259
    }
260
 
261
    public function setThemeFontName(?string $name): self
262
    {
263
        if (!empty($name)) {
264
            $this->themeFontName = $name;
265
        }
266
 
267
        return $this;
268
    }
269
}