← All changes
|
vendor/phpoffice/phpexcel/Classes/PHPExcel/Style/Protection.php
+130
-127
3.1.1
→
3.0.10
View file →
| @@ -1,10 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | - | |
| 3 | 2 | /** |
| 4 | - * PHPExcel_Style_Protection | |
| 3 | + * PHPExcel | |
| 5 | 4 | * |
| 6 | - * Copyright (c) 2006 - 2015 PHPExcel | |
| 5 | + * Copyright (c) 2006 - 2014 PHPExcel | |
| 7 | 6 | * |
| 8 | 7 | * This library is free software; you can redistribute it and/or |
| 9 | 8 | * modify it under the terms of the GNU Lesser General Public |
| 10 | 9 | * License as published by the Free Software Foundation; either |
| @@ -20,76 +19,85 @@ | ||
| 20 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | 20 | * |
| 22 | 21 | * @category PHPExcel |
| 23 | 22 | * @package PHPExcel_Style |
| 24 | - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | |
| 25 | - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL | |
| 26 | - * @version ##VERSION##, ##DATE## | |
| 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 1.4.5, 2007-08-23 | |
| 27 | 26 | */ |
| 27 | + | |
| 28 | + | |
| 29 | +/** | |
| 30 | + * PHPExcel_Style_Protection | |
| 31 | + * | |
| 32 | + * @category PHPExcel | |
| 33 | + * @package PHPExcel_Style | |
| 34 | + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) | |
| 35 | + */ | |
| 28 | 36 | class PHPExcel_Style_Protection extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable |
| 29 | 37 | { |
| 30 | - /** Protection styles */ | |
| 31 | - const PROTECTION_INHERIT = 'inherit'; | |
| 32 | - const PROTECTION_PROTECTED = 'protected'; | |
| 33 | - const PROTECTION_UNPROTECTED = 'unprotected'; | |
| 38 | + /** Protection styles */ | |
| 39 | + const PROTECTION_INHERIT = 'inherit'; | |
| 40 | + const PROTECTION_PROTECTED = 'protected'; | |
| 41 | + const PROTECTION_UNPROTECTED = 'unprotected'; | |
| 34 | 42 | |
| 35 | - /** | |
| 36 | - * Locked | |
| 37 | - * | |
| 38 | - * @var string | |
| 39 | - */ | |
| 40 | - protected $locked; | |
| 43 | + /** | |
| 44 | + * Locked | |
| 45 | + * | |
| 46 | + * @var string | |
| 47 | + */ | |
| 48 | + protected $_locked; | |
| 41 | 49 | |
| 42 | - /** | |
| 43 | - * Hidden | |
| 44 | - * | |
| 45 | - * @var string | |
| 46 | - */ | |
| 47 | - protected $hidden; | |
| 50 | + /** | |
| 51 | + * Hidden | |
| 52 | + * | |
| 53 | + * @var string | |
| 54 | + */ | |
| 55 | + protected $_hidden; | |
| 48 | 56 | |
| 49 | - /** | |
| 57 | + /** | |
| 50 | 58 | * Create a new PHPExcel_Style_Protection |
| 51 | - * | |
| 52 | - * @param boolean $isSupervisor Flag indicating if this is a supervisor or not | |
| 53 | - * Leave this value at default unless you understand exactly what | |
| 54 | - * its ramifications are | |
| 55 | - * @param boolean $isConditional Flag indicating if this is a conditional style or not | |
| 56 | - * Leave this value at default unless you understand exactly what | |
| 57 | - * its ramifications are | |
| 59 | + * | |
| 60 | + * @param boolean $isSupervisor Flag indicating if this is a supervisor or not | |
| 61 | + * Leave this value at default unless you understand exactly what | |
| 62 | + * its ramifications are | |
| 63 | + * @param boolean $isConditional Flag indicating if this is a conditional style or not | |
| 64 | + * Leave this value at default unless you understand exactly what | |
| 65 | + * its ramifications are | |
| 58 | 66 | */ |
| 59 | - public function __construct($isSupervisor = false, $isConditional = false) | |
| 67 | + public function __construct($isSupervisor = FALSE, $isConditional = FALSE) | |
| 60 | 68 | { |
| 61 | - // Supervisor? | |
| 62 | - parent::__construct($isSupervisor); | |
| 69 | + // Supervisor? | |
| 70 | + parent::__construct($isSupervisor); | |
| 63 | 71 | |
| 64 | - // Initialise values | |
| 65 | - if (!$isConditional) { | |
| 66 | - $this->locked = self::PROTECTION_INHERIT; | |
| 67 | - $this->hidden = self::PROTECTION_INHERIT; | |
| 68 | - } | |
| 72 | + // Initialise values | |
| 73 | + if (!$isConditional) { | |
| 74 | + $this->_locked = self::PROTECTION_INHERIT; | |
| 75 | + $this->_hidden = self::PROTECTION_INHERIT; | |
| 76 | + } | |
| 69 | 77 | } |
| 70 | 78 | |
| 71 | - /** | |
| 72 | - * Get the shared style component for the currently active cell in currently active sheet. | |
| 73 | - * Only used for style supervisor | |
| 74 | - * | |
| 75 | - * @return PHPExcel_Style_Protection | |
| 76 | - */ | |
| 77 | - public function getSharedComponent() | |
| 78 | - { | |
| 79 | - return $this->parent->getSharedComponent()->getProtection(); | |
| 80 | - } | |
| 79 | + /** | |
| 80 | + * Get the shared style component for the currently active cell in currently active sheet. | |
| 81 | + * Only used for style supervisor | |
| 82 | + * | |
| 83 | + * @return PHPExcel_Style_Protection | |
| 84 | + */ | |
| 85 | + public function getSharedComponent() | |
| 86 | + { | |
| 87 | + return $this->_parent->getSharedComponent()->getProtection(); | |
| 88 | + } | |
| 81 | 89 | |
| 82 | - /** | |
| 83 | - * Build style array from subcomponents | |
| 84 | - * | |
| 85 | - * @param array $array | |
| 86 | - * @return array | |
| 87 | - */ | |
| 88 | - public function getStyleArray($array) | |
| 89 | - { | |
| 90 | - return array('protection' => $array); | |
| 91 | - } | |
| 90 | + /** | |
| 91 | + * Build style array from subcomponents | |
| 92 | + * | |
| 93 | + * @param array $array | |
| 94 | + * @return array | |
| 95 | + */ | |
| 96 | + public function getStyleArray($array) | |
| 97 | + { | |
| 98 | + return array('protection' => $array); | |
| 99 | + } | |
| 92 | 100 | |
| 93 | 101 | /** |
| 94 | 102 | * Apply styles from array |
| 95 | 103 | * |
| @@ -94,37 +102,36 @@ | ||
| 94 | 102 | * Apply styles from array |
| 95 | 103 | * |
| 96 | 104 | * <code> |
| 97 | 105 | * $objPHPExcel->getActiveSheet()->getStyle('B2')->getLocked()->applyFromArray( |
| 98 | - * array( | |
| 99 | - * 'locked' => TRUE, | |
| 100 | - * 'hidden' => FALSE | |
| 101 | - * ) | |
| 106 | + * array( | |
| 107 | + * 'locked' => TRUE, | |
| 108 | + * 'hidden' => FALSE | |
| 109 | + * ) | |
| 102 | 110 | * ); |
| 103 | 111 | * </code> |
| 104 | 112 | * |
| 105 | - * @param array $pStyles Array containing style information | |
| 106 | - * @throws PHPExcel_Exception | |
| 113 | + * @param array $pStyles Array containing style information | |
| 114 | + * @throws PHPExcel_Exception | |
| 107 | 115 | * @return PHPExcel_Style_Protection |
| 108 | 116 | */ |
| 109 | - public function applyFromArray($pStyles = null) | |
| 110 | - { | |
| 111 | - if (is_array($pStyles)) { | |
| 112 | - if ($this->isSupervisor) { | |
| 113 | - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); | |
| 114 | - } else { | |
| 115 | - if (isset($pStyles['locked'])) { | |
| 116 | - $this->setLocked($pStyles['locked']); | |
| 117 | - } | |
| 118 | - if (isset($pStyles['hidden'])) { | |
| 119 | - $this->setHidden($pStyles['hidden']); | |
| 120 | - } | |
| 121 | - } | |
| 122 | - } else { | |
| 123 | - throw new PHPExcel_Exception("Invalid style array passed."); | |
| 124 | - } | |
| 125 | - return $this; | |
| 126 | - } | |
| 117 | + public function applyFromArray($pStyles = NULL) { | |
| 118 | + if (is_array($pStyles)) { | |
| 119 | + if ($this->_isSupervisor) { | |
| 120 | + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); | |
| 121 | + } else { | |
| 122 | + if (isset($pStyles['locked'])) { | |
| 123 | + $this->setLocked($pStyles['locked']); | |
| 124 | + } | |
| 125 | + if (isset($pStyles['hidden'])) { | |
| 126 | + $this->setHidden($pStyles['hidden']); | |
| 127 | + } | |
| 128 | + } | |
| 129 | + } else { | |
| 130 | + throw new PHPExcel_Exception("Invalid style array passed."); | |
| 131 | + } | |
| 132 | + return $this; | |
| 133 | + } | |
| 127 | 134 | |
| 128 | 135 | /** |
| 129 | 136 | * Get locked |
| 130 | 137 | * |
| @@ -129,14 +136,13 @@ | ||
| 129 | 136 | * Get locked |
| 130 | 137 | * |
| 131 | 138 | * @return string |
| 132 | 139 | */ |
| 133 | - public function getLocked() | |
| 134 | - { | |
| 135 | - if ($this->isSupervisor) { | |
| 136 | - return $this->getSharedComponent()->getLocked(); | |
| 137 | - } | |
| 138 | - return $this->locked; | |
| 140 | + public function getLocked() { | |
| 141 | + if ($this->_isSupervisor) { | |
| 142 | + return $this->getSharedComponent()->getLocked(); | |
| 143 | + } | |
| 144 | + return $this->_locked; | |
| 139 | 145 | } |
| 140 | 146 | |
| 141 | 147 | /** |
| 142 | 148 | * Set locked |
| @@ -143,17 +149,16 @@ | ||
| 143 | 149 | * |
| 144 | 150 | * @param string $pValue |
| 145 | 151 | * @return PHPExcel_Style_Protection |
| 146 | 152 | */ |
| 147 | - public function setLocked($pValue = self::PROTECTION_INHERIT) | |
| 148 | - { | |
| 149 | - if ($this->isSupervisor) { | |
| 150 | - $styleArray = $this->getStyleArray(array('locked' => $pValue)); | |
| 151 | - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); | |
| 152 | - } else { | |
| 153 | - $this->locked = $pValue; | |
| 154 | - } | |
| 155 | - return $this; | |
| 153 | + public function setLocked($pValue = self::PROTECTION_INHERIT) { | |
| 154 | + if ($this->_isSupervisor) { | |
| 155 | + $styleArray = $this->getStyleArray(array('locked' => $pValue)); | |
| 156 | + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); | |
| 157 | + } else { | |
| 158 | + $this->_locked = $pValue; | |
| 159 | + } | |
| 160 | + return $this; | |
| 156 | 161 | } |
| 157 | 162 | |
| 158 | 163 | /** |
| 159 | 164 | * Get hidden |
| @@ -159,14 +164,13 @@ | ||
| 159 | 164 | * Get hidden |
| 160 | 165 | * |
| 161 | 166 | * @return string |
| 162 | 167 | */ |
| 163 | - public function getHidden() | |
| 164 | - { | |
| 165 | - if ($this->isSupervisor) { | |
| 166 | - return $this->getSharedComponent()->getHidden(); | |
| 167 | - } | |
| 168 | - return $this->hidden; | |
| 168 | + public function getHidden() { | |
| 169 | + if ($this->_isSupervisor) { | |
| 170 | + return $this->getSharedComponent()->getHidden(); | |
| 171 | + } | |
| 172 | + return $this->_hidden; | |
| 169 | 173 | } |
| 170 | 174 | |
| 171 | 175 | /** |
| 172 | 176 | * Set hidden |
| @@ -173,32 +177,31 @@ | ||
| 173 | 177 | * |
| 174 | 178 | * @param string $pValue |
| 175 | 179 | * @return PHPExcel_Style_Protection |
| 176 | 180 | */ |
| 177 | - public function setHidden($pValue = self::PROTECTION_INHERIT) | |
| 178 | - { | |
| 179 | - if ($this->isSupervisor) { | |
| 180 | - $styleArray = $this->getStyleArray(array('hidden' => $pValue)); | |
| 181 | - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); | |
| 182 | - } else { | |
| 183 | - $this->hidden = $pValue; | |
| 184 | - } | |
| 185 | - return $this; | |
| 181 | + public function setHidden($pValue = self::PROTECTION_INHERIT) { | |
| 182 | + if ($this->_isSupervisor) { | |
| 183 | + $styleArray = $this->getStyleArray(array('hidden' => $pValue)); | |
| 184 | + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); | |
| 185 | + } else { | |
| 186 | + $this->_hidden = $pValue; | |
| 187 | + } | |
| 188 | + return $this; | |
| 186 | 189 | } |
| 187 | 190 | |
| 188 | - /** | |
| 189 | - * Get hash code | |
| 190 | - * | |
| 191 | - * @return string Hash code | |
| 192 | - */ | |
| 193 | - public function getHashCode() | |
| 194 | - { | |
| 195 | - if ($this->isSupervisor) { | |
| 196 | - return $this->getSharedComponent()->getHashCode(); | |
| 197 | - } | |
| 198 | - return md5( | |
| 199 | - $this->locked . | |
| 200 | - $this->hidden . | |
| 201 | - __CLASS__ | |
| 202 | - ); | |
| 191 | + /** | |
| 192 | + * Get hash code | |
| 193 | + * | |
| 194 | + * @return string Hash code | |
| 195 | + */ | |
| 196 | + public function getHashCode() { | |
| 197 | + if ($this->_isSupervisor) { | |
| 198 | + return $this->getSharedComponent()->getHashCode(); | |
| 199 | + } | |
| 200 | + return md5( | |
| 201 | + $this->_locked | |
| 202 | + . $this->_hidden | |
| 203 | + . __CLASS__ | |
| 204 | + ); | |
| 203 | 205 | } |
| 206 | + | |
| 204 | 207 | } |