Settings.php 10 KB

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