PageRenderTime 49ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/Application/Library/Excel/PHPExcel/Worksheet/Protection.php

https://gitlab.com/hoanghung.dev/aloads
PHP | 581 lines | 210 code | 55 blank | 316 comment | 3 complexity | 9f2fde41fad2354f771325da3ce7b1aa MD5 | raw file
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2015 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 - 2015 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_Worksheet_Protection
  29. *
  30. * @category PHPExcel
  31. * @package PHPExcel_Worksheet
  32. * @copyright Copyright (c) 2006 - 2015 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. public function isProtectionEnabled()
  150. {
  151. return $this->sheet ||
  152. $this->objects ||
  153. $this->scenarios ||
  154. $this->formatCells ||
  155. $this->formatColumns ||
  156. $this->formatRows ||
  157. $this->insertColumns ||
  158. $this->insertRows ||
  159. $this->insertHyperlinks ||
  160. $this->deleteColumns ||
  161. $this->deleteRows ||
  162. $this->selectLockedCells ||
  163. $this->sort ||
  164. $this->autoFilter ||
  165. $this->pivotTables ||
  166. $this->selectUnlockedCells;
  167. }
  168. /**
  169. * Get Sheet
  170. *
  171. * @return boolean
  172. */
  173. public function getSheet()
  174. {
  175. return $this->sheet;
  176. }
  177. /**
  178. * Set Sheet
  179. *
  180. * @param boolean $pValue
  181. * @return PHPExcel_Worksheet_Protection
  182. */
  183. public function setSheet($pValue = false)
  184. {
  185. $this->sheet = $pValue;
  186. return $this;
  187. }
  188. /**
  189. * Get Objects
  190. *
  191. * @return boolean
  192. */
  193. public function getObjects()
  194. {
  195. return $this->objects;
  196. }
  197. /**
  198. * Set Objects
  199. *
  200. * @param boolean $pValue
  201. * @return PHPExcel_Worksheet_Protection
  202. */
  203. public function setObjects($pValue = false)
  204. {
  205. $this->objects = $pValue;
  206. return $this;
  207. }
  208. /**
  209. * Get Scenarios
  210. *
  211. * @return boolean
  212. */
  213. public function getScenarios()
  214. {
  215. return $this->scenarios;
  216. }
  217. /**
  218. * Set Scenarios
  219. *
  220. * @param boolean $pValue
  221. * @return PHPExcel_Worksheet_Protection
  222. */
  223. public function setScenarios($pValue = false)
  224. {
  225. $this->scenarios = $pValue;
  226. return $this;
  227. }
  228. /**
  229. * Get FormatCells
  230. *
  231. * @return boolean
  232. */
  233. public function getFormatCells()
  234. {
  235. return $this->formatCells;
  236. }
  237. /**
  238. * Set FormatCells
  239. *
  240. * @param boolean $pValue
  241. * @return PHPExcel_Worksheet_Protection
  242. */
  243. public function setFormatCells($pValue = false)
  244. {
  245. $this->formatCells = $pValue;
  246. return $this;
  247. }
  248. /**
  249. * Get FormatColumns
  250. *
  251. * @return boolean
  252. */
  253. public function getFormatColumns()
  254. {
  255. return $this->formatColumns;
  256. }
  257. /**
  258. * Set FormatColumns
  259. *
  260. * @param boolean $pValue
  261. * @return PHPExcel_Worksheet_Protection
  262. */
  263. public function setFormatColumns($pValue = false)
  264. {
  265. $this->formatColumns = $pValue;
  266. return $this;
  267. }
  268. /**
  269. * Get FormatRows
  270. *
  271. * @return boolean
  272. */
  273. public function getFormatRows()
  274. {
  275. return $this->formatRows;
  276. }
  277. /**
  278. * Set FormatRows
  279. *
  280. * @param boolean $pValue
  281. * @return PHPExcel_Worksheet_Protection
  282. */
  283. public function setFormatRows($pValue = false)
  284. {
  285. $this->formatRows = $pValue;
  286. return $this;
  287. }
  288. /**
  289. * Get InsertColumns
  290. *
  291. * @return boolean
  292. */
  293. public function getInsertColumns()
  294. {
  295. return $this->insertColumns;
  296. }
  297. /**
  298. * Set InsertColumns
  299. *
  300. * @param boolean $pValue
  301. * @return PHPExcel_Worksheet_Protection
  302. */
  303. public function setInsertColumns($pValue = false)
  304. {
  305. $this->insertColumns = $pValue;
  306. return $this;
  307. }
  308. /**
  309. * Get InsertRows
  310. *
  311. * @return boolean
  312. */
  313. public function getInsertRows()
  314. {
  315. return $this->insertRows;
  316. }
  317. /**
  318. * Set InsertRows
  319. *
  320. * @param boolean $pValue
  321. * @return PHPExcel_Worksheet_Protection
  322. */
  323. public function setInsertRows($pValue = false)
  324. {
  325. $this->insertRows = $pValue;
  326. return $this;
  327. }
  328. /**
  329. * Get InsertHyperlinks
  330. *
  331. * @return boolean
  332. */
  333. public function getInsertHyperlinks()
  334. {
  335. return $this->insertHyperlinks;
  336. }
  337. /**
  338. * Set InsertHyperlinks
  339. *
  340. * @param boolean $pValue
  341. * @return PHPExcel_Worksheet_Protection
  342. */
  343. public function setInsertHyperlinks($pValue = false)
  344. {
  345. $this->insertHyperlinks = $pValue;
  346. return $this;
  347. }
  348. /**
  349. * Get DeleteColumns
  350. *
  351. * @return boolean
  352. */
  353. public function getDeleteColumns()
  354. {
  355. return $this->deleteColumns;
  356. }
  357. /**
  358. * Set DeleteColumns
  359. *
  360. * @param boolean $pValue
  361. * @return PHPExcel_Worksheet_Protection
  362. */
  363. public function setDeleteColumns($pValue = false)
  364. {
  365. $this->deleteColumns = $pValue;
  366. return $this;
  367. }
  368. /**
  369. * Get DeleteRows
  370. *
  371. * @return boolean
  372. */
  373. public function getDeleteRows()
  374. {
  375. return $this->deleteRows;
  376. }
  377. /**
  378. * Set DeleteRows
  379. *
  380. * @param boolean $pValue
  381. * @return PHPExcel_Worksheet_Protection
  382. */
  383. public function setDeleteRows($pValue = false)
  384. {
  385. $this->deleteRows = $pValue;
  386. return $this;
  387. }
  388. /**
  389. * Get SelectLockedCells
  390. *
  391. * @return boolean
  392. */
  393. public function getSelectLockedCells()
  394. {
  395. return $this->selectLockedCells;
  396. }
  397. /**
  398. * Set SelectLockedCells
  399. *
  400. * @param boolean $pValue
  401. * @return PHPExcel_Worksheet_Protection
  402. */
  403. public function setSelectLockedCells($pValue = false)
  404. {
  405. $this->selectLockedCells = $pValue;
  406. return $this;
  407. }
  408. /**
  409. * Get Sort
  410. *
  411. * @return boolean
  412. */
  413. public function getSort()
  414. {
  415. return $this->sort;
  416. }
  417. /**
  418. * Set Sort
  419. *
  420. * @param boolean $pValue
  421. * @return PHPExcel_Worksheet_Protection
  422. */
  423. public function setSort($pValue = false)
  424. {
  425. $this->sort = $pValue;
  426. return $this;
  427. }
  428. /**
  429. * Get AutoFilter
  430. *
  431. * @return boolean
  432. */
  433. public function getAutoFilter()
  434. {
  435. return $this->autoFilter;
  436. }
  437. /**
  438. * Set AutoFilter
  439. *
  440. * @param boolean $pValue
  441. * @return PHPExcel_Worksheet_Protection
  442. */
  443. public function setAutoFilter($pValue = false)
  444. {
  445. $this->autoFilter = $pValue;
  446. return $this;
  447. }
  448. /**
  449. * Get PivotTables
  450. *
  451. * @return boolean
  452. */
  453. public function getPivotTables()
  454. {
  455. return $this->pivotTables;
  456. }
  457. /**
  458. * Set PivotTables
  459. *
  460. * @param boolean $pValue
  461. * @return PHPExcel_Worksheet_Protection
  462. */
  463. public function setPivotTables($pValue = false)
  464. {
  465. $this->pivotTables = $pValue;
  466. return $this;
  467. }
  468. /**
  469. * Get SelectUnlockedCells
  470. *
  471. * @return boolean
  472. */
  473. public function getSelectUnlockedCells()
  474. {
  475. return $this->selectUnlockedCells;
  476. }
  477. /**
  478. * Set SelectUnlockedCells
  479. *
  480. * @param boolean $pValue
  481. * @return PHPExcel_Worksheet_Protection
  482. */
  483. public function setSelectUnlockedCells($pValue = false)
  484. {
  485. $this->selectUnlockedCells = $pValue;
  486. return $this;
  487. }
  488. /**
  489. * Get Password (hashed)
  490. *
  491. * @return string
  492. */
  493. public function getPassword()
  494. {
  495. return $this->password;
  496. }
  497. /**
  498. * Set Password
  499. *
  500. * @param string $pValue
  501. * @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
  502. * @return PHPExcel_Worksheet_Protection
  503. */
  504. public function setPassword($pValue = '', $pAlreadyHashed = false)
  505. {
  506. if (!$pAlreadyHashed) {
  507. $pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
  508. }
  509. $this->password = $pValue;
  510. return $this;
  511. }
  512. /**
  513. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  514. */
  515. public function __clone()
  516. {
  517. $vars = get_object_vars($this);
  518. foreach ($vars as $key => $value) {
  519. if (is_object($value)) {
  520. $this->$key = clone $value;
  521. } else {
  522. $this->$key = $value;
  523. }
  524. }
  525. }
  526. }