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