Protection.php 11 KB

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