0a90dda464752c55a8eb2e9528b8f39857a0a521.svn-base 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2014 PHPExcel
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. * @category PHPExcel
  22. * @package PHPExcel
  23. * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version ##VERSION##, ##DATE##
  26. */
  27. /**
  28. * PHPExcel_DocumentSecurity
  29. *
  30. * @category PHPExcel
  31. * @package PHPExcel
  32. * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
  33. */
  34. class PHPExcel_DocumentSecurity
  35. {
  36. /**
  37. * LockRevision
  38. *
  39. * @var boolean
  40. */
  41. private $_lockRevision;
  42. /**
  43. * LockStructure
  44. *
  45. * @var boolean
  46. */
  47. private $_lockStructure;
  48. /**
  49. * LockWindows
  50. *
  51. * @var boolean
  52. */
  53. private $_lockWindows;
  54. /**
  55. * RevisionsPassword
  56. *
  57. * @var string
  58. */
  59. private $_revisionsPassword;
  60. /**
  61. * WorkbookPassword
  62. *
  63. * @var string
  64. */
  65. private $_workbookPassword;
  66. /**
  67. * Create a new PHPExcel_DocumentSecurity
  68. */
  69. public function __construct()
  70. {
  71. // Initialise values
  72. $this->_lockRevision = false;
  73. $this->_lockStructure = false;
  74. $this->_lockWindows = false;
  75. $this->_revisionsPassword = '';
  76. $this->_workbookPassword = '';
  77. }
  78. /**
  79. * Is some sort of dcument security enabled?
  80. *
  81. * @return boolean
  82. */
  83. function isSecurityEnabled() {
  84. return $this->_lockRevision ||
  85. $this->_lockStructure ||
  86. $this->_lockWindows;
  87. }
  88. /**
  89. * Get LockRevision
  90. *
  91. * @return boolean
  92. */
  93. function getLockRevision() {
  94. return $this->_lockRevision;
  95. }
  96. /**
  97. * Set LockRevision
  98. *
  99. * @param boolean $pValue
  100. * @return PHPExcel_DocumentSecurity
  101. */
  102. function setLockRevision($pValue = false) {
  103. $this->_lockRevision = $pValue;
  104. return $this;
  105. }
  106. /**
  107. * Get LockStructure
  108. *
  109. * @return boolean
  110. */
  111. function getLockStructure() {
  112. return $this->_lockStructure;
  113. }
  114. /**
  115. * Set LockStructure
  116. *
  117. * @param boolean $pValue
  118. * @return PHPExcel_DocumentSecurity
  119. */
  120. function setLockStructure($pValue = false) {
  121. $this->_lockStructure = $pValue;
  122. return $this;
  123. }
  124. /**
  125. * Get LockWindows
  126. *
  127. * @return boolean
  128. */
  129. function getLockWindows() {
  130. return $this->_lockWindows;
  131. }
  132. /**
  133. * Set LockWindows
  134. *
  135. * @param boolean $pValue
  136. * @return PHPExcel_DocumentSecurity
  137. */
  138. function setLockWindows($pValue = false) {
  139. $this->_lockWindows = $pValue;
  140. return $this;
  141. }
  142. /**
  143. * Get RevisionsPassword (hashed)
  144. *
  145. * @return string
  146. */
  147. function getRevisionsPassword() {
  148. return $this->_revisionsPassword;
  149. }
  150. /**
  151. * Set RevisionsPassword
  152. *
  153. * @param string $pValue
  154. * @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
  155. * @return PHPExcel_DocumentSecurity
  156. */
  157. function setRevisionsPassword($pValue = '', $pAlreadyHashed = false) {
  158. if (!$pAlreadyHashed) {
  159. $pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
  160. }
  161. $this->_revisionsPassword = $pValue;
  162. return $this;
  163. }
  164. /**
  165. * Get WorkbookPassword (hashed)
  166. *
  167. * @return string
  168. */
  169. function getWorkbookPassword() {
  170. return $this->_workbookPassword;
  171. }
  172. /**
  173. * Set WorkbookPassword
  174. *
  175. * @param string $pValue
  176. * @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
  177. * @return PHPExcel_DocumentSecurity
  178. */
  179. function setWorkbookPassword($pValue = '', $pAlreadyHashed = false) {
  180. if (!$pAlreadyHashed) {
  181. $pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
  182. }
  183. $this->_workbookPassword = $pValue;
  184. return $this;
  185. }
  186. /**
  187. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  188. */
  189. public function __clone() {
  190. $vars = get_object_vars($this);
  191. foreach ($vars as $key => $value) {
  192. if (is_object($value)) {
  193. $this->$key = clone $value;
  194. } else {
  195. $this->$key = $value;
  196. }
  197. }
  198. }
  199. }