Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
47 / 47
100.00% covered (success)
100.00%
38 / 38
CRAP
100.00% covered (success)
100.00%
1 / 1
Settings
100.00% covered (success)
100.00%
47 / 47
100.00% covered (success)
100.00%
38 / 38
48
100.00% covered (success)
100.00%
1 / 1
 getDocumentProtection
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 setDocumentProtection
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getProofState
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 setProofState
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 hasHideSpellingErrors
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setHideSpellingErrors
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 hasHideGrammaticalErrors
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setHideGrammaticalErrors
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 hasEvenAndOddHeaders
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setEvenAndOddHeaders
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 getRevisionView
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setRevisionView
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 hasTrackRevisions
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setTrackRevisions
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 hasDoNotTrackMoves
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setDoNotTrackMoves
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 hasDoNotTrackFormatting
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setDoNotTrackFormatting
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 getZoom
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setZoom
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 hasMirrorMargins
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setMirrorMargins
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getThemeFontLang
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setThemeFontLang
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 hasUpdateFields
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setUpdateFields
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 getDecimalSymbol
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setDecimalSymbol
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 hasAutoHyphenation
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setAutoHyphenation
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getConsecutiveHyphenLimit
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setConsecutiveHyphenLimit
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getHyphenationZone
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setHyphenationZone
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 hasDoNotHyphenateCaps
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setDoNotHyphenateCaps
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 hasBookFoldPrinting
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setBookFoldPrinting
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * This file is part of PHPWord - A pure PHP library for reading and writing
4 * word processing documents.
5 *
6 * PHPWord is free software distributed under the terms of the GNU Lesser
7 * General Public License version 3 as published by the Free Software Foundation.
8 *
9 * For the full copyright and license information, please read the LICENSE
10 * file that was distributed with this source code. For the full list of
11 * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
12 *
13 * @see         https://github.com/PHPOffice/PHPWord
14 *
15 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16 */
17
18namespace PhpOffice\PhpWord\Metadata;
19
20use PhpOffice\PhpWord\ComplexType\ProofState;
21use PhpOffice\PhpWord\ComplexType\TrackChangesView;
22use PhpOffice\PhpWord\SimpleType\Zoom;
23use PhpOffice\PhpWord\Style\Language;
24
25/**
26 * Setting class.
27 *
28 * @since 0.14.0
29 * @see  http://www.datypic.com/sc/ooxml/t-w_CT_Settings.html
30 */
31class Settings
32{
33    /**
34     * Magnification Setting.
35     *
36     * @see  http://www.datypic.com/sc/ooxml/e-w_zoom-1.html
37     *
38     * @var mixed either integer, in which case it treated as a percent, or one of PhpOffice\PhpWord\SimpleType\Zoom
39     */
40    private $zoom = 100;
41
42    /**
43     * Mirror Page Margins.
44     *
45     * @see http://www.datypic.com/sc/ooxml/e-w_mirrorMargins-1.html
46     *
47     * @var bool
48     */
49    private $mirrorMargins;
50
51    /**
52     * Hide spelling errors.
53     *
54     * @var bool
55     */
56    private $hideSpellingErrors = false;
57
58    /**
59     * Hide grammatical errors.
60     *
61     * @var bool
62     */
63    private $hideGrammaticalErrors = false;
64
65    /**
66     * Visibility of Annotation Types.
67     *
68     * @var TrackChangesView
69     */
70    private $revisionView;
71
72    /**
73     * Track Revisions to Document.
74     *
75     * @var bool
76     */
77    private $trackRevisions = false;
78
79    /**
80     * Do Not Use Move Syntax When Tracking Revisions.
81     *
82     * @var bool
83     */
84    private $doNotTrackMoves = false;
85
86    /**
87     * Do Not Track Formatting Revisions When Tracking Revisions.
88     *
89     * @var bool
90     */
91    private $doNotTrackFormatting = false;
92
93    /**
94     * Spelling and Grammatical Checking State.
95     *
96     * @var \PhpOffice\PhpWord\ComplexType\ProofState
97     */
98    private $proofState;
99
100    /**
101     * Document Editing Restrictions.
102     *
103     * @var \PhpOffice\PhpWord\Metadata\Protection
104     */
105    private $documentProtection;
106
107    /**
108     * Enables different header for odd and even pages.
109     *
110     * @var bool
111     */
112    private $evenAndOddHeaders = false;
113
114    /**
115     * Theme Font Languages.
116     *
117     * @var ?Language
118     */
119    private $themeFontLang;
120
121    /**
122     * Automatically Recalculate Fields on Open.
123     *
124     * @var bool
125     */
126    private $updateFields = false;
127
128    /**
129     * Radix Point for Field Code Evaluation.
130     *
131     * @var string
132     */
133    private $decimalSymbol = '.';
134
135    /**
136     * Automatically hyphenate document contents when displayed.
137     *
138     * @var null|bool
139     */
140    private $autoHyphenation;
141
142    /**
143     * Maximum number of consecutively hyphenated lines.
144     *
145     * @var null|int
146     */
147    private $consecutiveHyphenLimit;
148
149    /**
150     * The allowed amount of whitespace before hyphenation is applied.
151     *
152     * @var null|float|int
153     */
154    private $hyphenationZone;
155
156    /**
157     * Do not hyphenate words in all capital letters.
158     *
159     * @var null|bool
160     */
161    private $doNotHyphenateCaps;
162
163    /**
164     * Enable or disable book-folded printing.
165     *
166     * @var bool
167     */
168    private $bookFoldPrinting = false;
169
170    /**
171     * @return Protection
172     */
173    public function getDocumentProtection()
174    {
175        if ($this->documentProtection == null) {
176            $this->documentProtection = new Protection();
177        }
178
179        return $this->documentProtection;
180    }
181
182    /**
183     * @param Protection $documentProtection
184     */
185    public function setDocumentProtection($documentProtection): void
186    {
187        $this->documentProtection = $documentProtection;
188    }
189
190    /**
191     * @return ProofState
192     */
193    public function getProofState()
194    {
195        if ($this->proofState == null) {
196            $this->proofState = new ProofState();
197        }
198
199        return $this->proofState;
200    }
201
202    /**
203     * @param ProofState $proofState
204     */
205    public function setProofState($proofState): void
206    {
207        $this->proofState = $proofState;
208    }
209
210    /**
211     * Are spelling errors hidden.
212     *
213     * @return bool
214     */
215    public function hasHideSpellingErrors()
216    {
217        return $this->hideSpellingErrors;
218    }
219
220    /**
221     * Hide spelling errors.
222     *
223     * @param ?bool $hideSpellingErrors
224     */
225    public function setHideSpellingErrors($hideSpellingErrors): void
226    {
227        $this->hideSpellingErrors = $hideSpellingErrors === null ? true : $hideSpellingErrors;
228    }
229
230    /**
231     * Are grammatical errors hidden.
232     *
233     * @return bool
234     */
235    public function hasHideGrammaticalErrors()
236    {
237        return $this->hideGrammaticalErrors;
238    }
239
240    /**
241     * Hide grammatical errors.
242     *
243     * @param ?bool $hideGrammaticalErrors
244     */
245    public function setHideGrammaticalErrors($hideGrammaticalErrors): void
246    {
247        $this->hideGrammaticalErrors = $hideGrammaticalErrors === null ? true : $hideGrammaticalErrors;
248    }
249
250    /**
251     * @return bool
252     */
253    public function hasEvenAndOddHeaders()
254    {
255        return $this->evenAndOddHeaders;
256    }
257
258    /**
259     * @param ?bool $evenAndOddHeaders
260     */
261    public function setEvenAndOddHeaders($evenAndOddHeaders): void
262    {
263        $this->evenAndOddHeaders = $evenAndOddHeaders === null ? true : $evenAndOddHeaders;
264    }
265
266    /**
267     * Get the Visibility of Annotation Types.
268     *
269     * @return \PhpOffice\PhpWord\ComplexType\TrackChangesView
270     */
271    public function getRevisionView()
272    {
273        return $this->revisionView;
274    }
275
276    /**
277     * Set the Visibility of Annotation Types.
278     */
279    public function setRevisionView(?TrackChangesView $trackChangesView = null): void
280    {
281        $this->revisionView = $trackChangesView;
282    }
283
284    /**
285     * @return bool
286     */
287    public function hasTrackRevisions()
288    {
289        return $this->trackRevisions;
290    }
291
292    /**
293     * @param ?bool $trackRevisions
294     */
295    public function setTrackRevisions($trackRevisions): void
296    {
297        $this->trackRevisions = $trackRevisions === null ? true : $trackRevisions;
298    }
299
300    /**
301     * @return bool
302     */
303    public function hasDoNotTrackMoves()
304    {
305        return $this->doNotTrackMoves;
306    }
307
308    /**
309     * @param ?bool $doNotTrackMoves
310     */
311    public function setDoNotTrackMoves($doNotTrackMoves): void
312    {
313        $this->doNotTrackMoves = $doNotTrackMoves === null ? true : $doNotTrackMoves;
314    }
315
316    /**
317     * @return bool
318     */
319    public function hasDoNotTrackFormatting()
320    {
321        return $this->doNotTrackFormatting;
322    }
323
324    /**
325     * @param ?bool $doNotTrackFormatting
326     */
327    public function setDoNotTrackFormatting($doNotTrackFormatting): void
328    {
329        $this->doNotTrackFormatting = $doNotTrackFormatting === null ? true : $doNotTrackFormatting;
330    }
331
332    /**
333     * @return mixed
334     */
335    public function getZoom()
336    {
337        return $this->zoom;
338    }
339
340    /**
341     * @param mixed $zoom
342     */
343    public function setZoom($zoom): void
344    {
345        if (is_numeric($zoom)) {
346            // zoom is a percentage
347            $this->zoom = $zoom;
348        } else {
349            Zoom::validate($zoom);
350            $this->zoom = $zoom;
351        }
352    }
353
354    /**
355     * @return bool
356     */
357    public function hasMirrorMargins()
358    {
359        return $this->mirrorMargins;
360    }
361
362    /**
363     * @param bool $mirrorMargins
364     */
365    public function setMirrorMargins($mirrorMargins): void
366    {
367        $this->mirrorMargins = $mirrorMargins;
368    }
369
370    /**
371     * Returns the Language.
372     */
373    public function getThemeFontLang(): ?Language
374    {
375        return $this->themeFontLang;
376    }
377
378    /**
379     * Sets the Language for this document.
380     */
381    public function setThemeFontLang(Language $themeFontLang): self
382    {
383        $this->themeFontLang = $themeFontLang;
384
385        return $this;
386    }
387
388    /**
389     * @return bool
390     */
391    public function hasUpdateFields()
392    {
393        return $this->updateFields;
394    }
395
396    /**
397     * @param ?bool $updateFields
398     */
399    public function setUpdateFields($updateFields): void
400    {
401        $this->updateFields = $updateFields === null ? false : $updateFields;
402    }
403
404    /**
405     * Returns the Radix Point for Field Code Evaluation.
406     *
407     * @return string
408     */
409    public function getDecimalSymbol()
410    {
411        return $this->decimalSymbol;
412    }
413
414    /**
415     * sets the Radix Point for Field Code Evaluation.
416     *
417     * @param string $decimalSymbol
418     */
419    public function setDecimalSymbol($decimalSymbol): void
420    {
421        $this->decimalSymbol = $decimalSymbol;
422    }
423
424    /**
425     * @return null|bool
426     */
427    public function hasAutoHyphenation()
428    {
429        return $this->autoHyphenation;
430    }
431
432    /**
433     * @param bool $autoHyphenation
434     */
435    public function setAutoHyphenation($autoHyphenation): void
436    {
437        $this->autoHyphenation = (bool) $autoHyphenation;
438    }
439
440    /**
441     * @return null|int
442     */
443    public function getConsecutiveHyphenLimit()
444    {
445        return $this->consecutiveHyphenLimit;
446    }
447
448    /**
449     * @param int $consecutiveHyphenLimit
450     */
451    public function setConsecutiveHyphenLimit($consecutiveHyphenLimit): void
452    {
453        $this->consecutiveHyphenLimit = (int) $consecutiveHyphenLimit;
454    }
455
456    /**
457     * @return null|float|int
458     */
459    public function getHyphenationZone()
460    {
461        return $this->hyphenationZone;
462    }
463
464    /**
465     * @param null|float|int $hyphenationZone Measurement unit is twip
466     */
467    public function setHyphenationZone($hyphenationZone): void
468    {
469        $this->hyphenationZone = $hyphenationZone;
470    }
471
472    /**
473     * @return null|bool
474     */
475    public function hasDoNotHyphenateCaps()
476    {
477        return $this->doNotHyphenateCaps;
478    }
479
480    /**
481     * @param bool $doNotHyphenateCaps
482     */
483    public function setDoNotHyphenateCaps($doNotHyphenateCaps): void
484    {
485        $this->doNotHyphenateCaps = (bool) $doNotHyphenateCaps;
486    }
487
488    public function hasBookFoldPrinting(): bool
489    {
490        return $this->bookFoldPrinting;
491    }
492
493    public function setBookFoldPrinting(bool $bookFoldPrinting): self
494    {
495        $this->bookFoldPrinting = $bookFoldPrinting;
496
497        return $this;
498    }
499}