Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

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