PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/common/libraries/plugin/phpexcel/PHPExcel/Worksheet/Protection.php

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