PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/public/assets/javascript/gelSheet/server/export/PHPExcel/Classes/PHPExcel/Worksheet/Protection.php

https://github.com/libersoft/fengoffice-ls
PHP | 529 lines | 174 code | 55 blank | 300 comment | 3 complexity | f56fa4626f6bff246bfc296782ccc6fd MD5 | raw file
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2008 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_Worksheet
  23. * @copyright Copyright (c) 2006 - 2008 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version 1.6.3, 2008-08-25
  26. */
  27. /**
  28. * PHPExcel_Worksheet_Protection
  29. *
  30. * @category PHPExcel
  31. * @package PHPExcel_Worksheet
  32. * @copyright Copyright (c) 2006 - 2008 PHPExcel (http://www.codeplex.com/PHPExcel)
  33. */
  34. class PHPExcel_Worksheet_Protection
  35. {
  36. /**
  37. * Sheet
  38. *
  39. * @var boolean
  40. */
  41. private $_sheet;
  42. /**
  43. * Objects
  44. *
  45. * @var boolean
  46. */
  47. private $_objects;
  48. /**
  49. * Scenarios
  50. *
  51. * @var boolean
  52. */
  53. private $_scenarios;
  54. /**
  55. * Format cells
  56. *
  57. * @var boolean
  58. */
  59. private $_formatCells;
  60. /**
  61. * Format columns
  62. *
  63. * @var boolean
  64. */
  65. private $_formatColumns;
  66. /**
  67. * Format rows
  68. *
  69. * @var boolean
  70. */
  71. private $_formatRows;
  72. /**
  73. * Insert columns
  74. *
  75. * @var boolean
  76. */
  77. private $_insertColumns;
  78. /**
  79. * Insert rows
  80. *
  81. * @var boolean
  82. */
  83. private $_insertRows;
  84. /**
  85. * Insert hyperlinks
  86. *
  87. * @var boolean
  88. */
  89. private $_insertHyperlinks;
  90. /**
  91. * Delete columns
  92. *
  93. * @var boolean
  94. */
  95. private $_deleteColumns;
  96. /**
  97. * Delete rows
  98. *
  99. * @var boolean
  100. */
  101. private $_deleteRows;
  102. /**
  103. * Select locked cells
  104. *
  105. * @var boolean
  106. */
  107. private $_selectLockedCells;
  108. /**
  109. * Sort
  110. *
  111. * @var boolean
  112. */
  113. private $_sort;
  114. /**
  115. * AutoFilter
  116. *
  117. * @var boolean
  118. */
  119. private $_autoFilter;
  120. /**
  121. * Pivot tables
  122. *
  123. * @var boolean
  124. */
  125. private $_pivotTables;
  126. /**
  127. * Select unlocked cells
  128. *
  129. * @var boolean
  130. */
  131. private $_selectUnlockedCells;
  132. /**
  133. * Password
  134. *
  135. * @var string
  136. */
  137. private $_password;
  138. /**
  139. * Create a new PHPExcel_Worksheet_Protection
  140. */
  141. public function __construct()
  142. {
  143. // Initialise values
  144. $this->_sheet = false;
  145. $this->_objects = false;
  146. $this->_scenarios = false;
  147. $this->_formatCells = false;
  148. $this->_formatColumns = false;
  149. $this->_formatRows = false;
  150. $this->_insertColumns = false;
  151. $this->_insertRows = false;
  152. $this->_insertHyperlinks = false;
  153. $this->_deleteColumns = false;
  154. $this->_deleteRows = false;
  155. $this->_selectLockedCells = false;
  156. $this->_sort = false;
  157. $this->_autoFilter = false;
  158. $this->_pivotTables = false;
  159. $this->_selectUnlockedCells = false;
  160. $this->_password = '';
  161. }
  162. /**
  163. * Is some sort of protection enabled?
  164. *
  165. * @return boolean
  166. */
  167. function isProtectionEnabled() {
  168. return $this->_sheet ||
  169. $this->_objects ||
  170. $this->_scenarios ||
  171. $this->_formatCells ||
  172. $this->_formatColumns ||
  173. $this->_formatRows ||
  174. $this->_insertColumns ||
  175. $this->_insertRows ||
  176. $this->_insertHyperlinks ||
  177. $this->_deleteColumns ||
  178. $this->_deleteRows ||
  179. $this->_selectLockedCells ||
  180. $this->_sort ||
  181. $this->_autoFilter ||
  182. $this->_pivotTables ||
  183. $this->_selectUnlockedCells;
  184. }
  185. /**
  186. * Get Sheet
  187. *
  188. * @return boolean
  189. */
  190. function getSheet() {
  191. return $this->_sheet;
  192. }
  193. /**
  194. * Set Sheet
  195. *
  196. * @param boolean $pValue
  197. */
  198. function setSheet($pValue = false) {
  199. $this->_sheet = $pValue;
  200. }
  201. /**
  202. * Get Objects
  203. *
  204. * @return boolean
  205. */
  206. function getObjects() {
  207. return $this->_objects;
  208. }
  209. /**
  210. * Set Objects
  211. *
  212. * @param boolean $pValue
  213. */
  214. function setObjects($pValue = false) {
  215. $this->_objects = $pValue;
  216. }
  217. /**
  218. * Get Scenarios
  219. *
  220. * @return boolean
  221. */
  222. function getScenarios() {
  223. return $this->_scenarios;
  224. }
  225. /**
  226. * Set Scenarios
  227. *
  228. * @param boolean $pValue
  229. */
  230. function setScenarios($pValue = false) {
  231. $this->_scenarios = $pValue;
  232. }
  233. /**
  234. * Get FormatCells
  235. *
  236. * @return boolean
  237. */
  238. function getFormatCells() {
  239. return $this->_formatCells;
  240. }
  241. /**
  242. * Set FormatCells
  243. *
  244. * @param boolean $pValue
  245. */
  246. function setFormatCells($pValue = false) {
  247. $this->_formatCells = $pValue;
  248. }
  249. /**
  250. * Get FormatColumns
  251. *
  252. * @return boolean
  253. */
  254. function getFormatColumns() {
  255. return $this->_formatColumns;
  256. }
  257. /**
  258. * Set FormatColumns
  259. *
  260. * @param boolean $pValue
  261. */
  262. function setFormatColumns($pValue = false) {
  263. $this->_formatColumns = $pValue;
  264. }
  265. /**
  266. * Get FormatRows
  267. *
  268. * @return boolean
  269. */
  270. function getFormatRows() {
  271. return $this->_formatRows;
  272. }
  273. /**
  274. * Set FormatRows
  275. *
  276. * @param boolean $pValue
  277. */
  278. function setFormatRows($pValue = false) {
  279. $this->_formatRows = $pValue;
  280. }
  281. /**
  282. * Get InsertColumns
  283. *
  284. * @return boolean
  285. */
  286. function getInsertColumns() {
  287. return $this->_insertColumns;
  288. }
  289. /**
  290. * Set InsertColumns
  291. *
  292. * @param boolean $pValue
  293. */
  294. function setInsertColumns($pValue = false) {
  295. $this->_insertColumns = $pValue;
  296. }
  297. /**
  298. * Get InsertRows
  299. *
  300. * @return boolean
  301. */
  302. function getInsertRows() {
  303. return $this->_insertRows;
  304. }
  305. /**
  306. * Set InsertRows
  307. *
  308. * @param boolean $pValue
  309. */
  310. function setInsertRows($pValue = false) {
  311. $this->_insertRows = $pValue;
  312. }
  313. /**
  314. * Get InsertHyperlinks
  315. *
  316. * @return boolean
  317. */
  318. function getInsertHyperlinks() {
  319. return $this->_insertHyperlinks;
  320. }
  321. /**
  322. * Set InsertHyperlinks
  323. *
  324. * @param boolean $pValue
  325. */
  326. function setInsertHyperlinks($pValue = false) {
  327. $this->_insertHyperlinks = $pValue;
  328. }
  329. /**
  330. * Get DeleteColumns
  331. *
  332. * @return boolean
  333. */
  334. function getDeleteColumns() {
  335. return $this->_deleteColumns;
  336. }
  337. /**
  338. * Set DeleteColumns
  339. *
  340. * @param boolean $pValue
  341. */
  342. function setDeleteColumns($pValue = false) {
  343. $this->_deleteColumns = $pValue;
  344. }
  345. /**
  346. * Get DeleteRows
  347. *
  348. * @return boolean
  349. */
  350. function getDeleteRows() {
  351. return $this->_deleteRows;
  352. }
  353. /**
  354. * Set DeleteRows
  355. *
  356. * @param boolean $pValue
  357. */
  358. function setDeleteRows($pValue = false) {
  359. $this->_deleteRows = $pValue;
  360. }
  361. /**
  362. * Get SelectLockedCells
  363. *
  364. * @return boolean
  365. */
  366. function getSelectLockedCells() {
  367. return $this->_selectLockedCells;
  368. }
  369. /**
  370. * Set SelectLockedCells
  371. *
  372. * @param boolean $pValue
  373. */
  374. function setSelectLockedCells($pValue = false) {
  375. $this->_selectLockedCells = $pValue;
  376. }
  377. /**
  378. * Get Sort
  379. *
  380. * @return boolean
  381. */
  382. function getSort() {
  383. return $this->_sort;
  384. }
  385. /**
  386. * Set Sort
  387. *
  388. * @param boolean $pValue
  389. */
  390. function setSort($pValue = false) {
  391. $this->_sort = $pValue;
  392. }
  393. /**
  394. * Get AutoFilter
  395. *
  396. * @return boolean
  397. */
  398. function getAutoFilter() {
  399. return $this->_autoFilter;
  400. }
  401. /**
  402. * Set AutoFilter
  403. *
  404. * @param boolean $pValue
  405. */
  406. function setAutoFilter($pValue = false) {
  407. $this->_autoFilter = $pValue;
  408. }
  409. /**
  410. * Get PivotTables
  411. *
  412. * @return boolean
  413. */
  414. function getPivotTables() {
  415. return $this->_pivotTables;
  416. }
  417. /**
  418. * Set PivotTables
  419. *
  420. * @param boolean $pValue
  421. */
  422. function setPivotTables($pValue = false) {
  423. $this->_pivotTables = $pValue;
  424. }
  425. /**
  426. * Get SelectUnlockedCells
  427. *
  428. * @return boolean
  429. */
  430. function getSelectUnlockedCells() {
  431. return $this->_selectUnlockedCells;
  432. }
  433. /**
  434. * Set SelectUnlockedCells
  435. *
  436. * @param boolean $pValue
  437. */
  438. function setSelectUnlockedCells($pValue = false) {
  439. $this->_selectUnlockedCells = $pValue;
  440. }
  441. /**
  442. * Get Password (hashed)
  443. *
  444. * @return string
  445. */
  446. function getPassword() {
  447. return $this->_password;
  448. }
  449. /**
  450. * Set Password
  451. *
  452. * @param string $pValue
  453. * @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
  454. */
  455. function setPassword($pValue = '', $pAlreadyHashed = false) {
  456. if (!$pAlreadyHashed) {
  457. $pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
  458. }
  459. $this->_password = $pValue;
  460. }
  461. /**
  462. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  463. */
  464. public function __clone() {
  465. $vars = get_object_vars($this);
  466. foreach ($vars as $key => $value) {
  467. if (is_object($value)) {
  468. $this->$key = clone $value;
  469. } else {
  470. $this->$key = $value;
  471. }
  472. }
  473. }
  474. }