← All changes
|
vendor/phpoffice/phpexcel/Classes/PHPExcel/Style/Alignment.php
+402
-407
3.1.1
→
3.0.10
View file →
| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * PHPExcel_Style_Alignment | |
| 3 | + * PHPExcel | |
| 4 | 4 | * |
| 5 | - * Copyright (c) 2006 - 2015 PHPExcel | |
| 5 | + * Copyright (c) 2006 - 2014 PHPExcel | |
| 6 | 6 | * |
| 7 | 7 | * This library is free software; you can redistribute it and/or |
| 8 | 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | 9 | * License as published by the Free Software Foundation; either |
| @@ -18,447 +18,442 @@ | ||
| 18 | 18 | * License along with this library; if not, write to the Free Software |
| 19 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | 20 | * |
| 21 | 21 | * @category PHPExcel |
| 22 | - * @package PHPExcel_Style | |
| 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## | |
| 22 | + * @package PHPExcel_Style | |
| 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 ##VERSION##, ##DATE## | |
| 26 | 26 | */ |
| 27 | + | |
| 28 | + | |
| 29 | +/** | |
| 30 | + * PHPExcel_Style_Alignment | |
| 31 | + * | |
| 32 | + * @category PHPExcel | |
| 33 | + * @package PHPExcel_Style | |
| 34 | + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) | |
| 35 | + */ | |
| 27 | 36 | class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable |
| 28 | 37 | { |
| 29 | - /* Horizontal alignment styles */ | |
| 30 | - const HORIZONTAL_GENERAL = 'general'; | |
| 31 | - const HORIZONTAL_LEFT = 'left'; | |
| 32 | - const HORIZONTAL_RIGHT = 'right'; | |
| 33 | - const HORIZONTAL_CENTER = 'center'; | |
| 34 | - const HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous'; | |
| 35 | - const HORIZONTAL_JUSTIFY = 'justify'; | |
| 36 | - const HORIZONTAL_FILL = 'fill'; | |
| 37 | - const HORIZONTAL_DISTRIBUTED = 'distributed'; // Excel2007 only | |
| 38 | + /* Horizontal alignment styles */ | |
| 39 | + const HORIZONTAL_GENERAL = 'general'; | |
| 40 | + const HORIZONTAL_LEFT = 'left'; | |
| 41 | + const HORIZONTAL_RIGHT = 'right'; | |
| 42 | + const HORIZONTAL_CENTER = 'center'; | |
| 43 | + const HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous'; | |
| 44 | + const HORIZONTAL_JUSTIFY = 'justify'; | |
| 45 | + const HORIZONTAL_FILL = 'fill'; | |
| 46 | + const HORIZONTAL_DISTRIBUTED = 'distributed'; // Excel2007 only | |
| 38 | 47 | |
| 39 | - /* Vertical alignment styles */ | |
| 40 | - const VERTICAL_BOTTOM = 'bottom'; | |
| 41 | - const VERTICAL_TOP = 'top'; | |
| 42 | - const VERTICAL_CENTER = 'center'; | |
| 43 | - const VERTICAL_JUSTIFY = 'justify'; | |
| 44 | - const VERTICAL_DISTRIBUTED = 'distributed'; // Excel2007 only | |
| 48 | + /* Vertical alignment styles */ | |
| 49 | + const VERTICAL_BOTTOM = 'bottom'; | |
| 50 | + const VERTICAL_TOP = 'top'; | |
| 51 | + const VERTICAL_CENTER = 'center'; | |
| 52 | + const VERTICAL_JUSTIFY = 'justify'; | |
| 53 | + const VERTICAL_DISTRIBUTED = 'distributed'; // Excel2007 only | |
| 45 | 54 | |
| 46 | - /* Read order */ | |
| 47 | - const READORDER_CONTEXT = 0; | |
| 48 | - const READORDER_LTR = 1; | |
| 49 | - const READORDER_RTL = 2; | |
| 55 | + /* Read order */ | |
| 56 | + const READORDER_CONTEXT = 0; | |
| 57 | + const READORDER_LTR = 1; | |
| 58 | + const READORDER_RTL = 2; | |
| 50 | 59 | |
| 51 | - /** | |
| 52 | - * Horizontal alignment | |
| 53 | - * | |
| 54 | - * @var string | |
| 55 | - */ | |
| 56 | - protected $horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; | |
| 60 | + /** | |
| 61 | + * Horizontal alignment | |
| 62 | + * | |
| 63 | + * @var string | |
| 64 | + */ | |
| 65 | + protected $_horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; | |
| 57 | 66 | |
| 58 | - /** | |
| 59 | - * Vertical alignment | |
| 60 | - * | |
| 61 | - * @var string | |
| 62 | - */ | |
| 63 | - protected $vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM; | |
| 67 | + /** | |
| 68 | + * Vertical alignment | |
| 69 | + * | |
| 70 | + * @var string | |
| 71 | + */ | |
| 72 | + protected $_vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM; | |
| 64 | 73 | |
| 65 | - /** | |
| 66 | - * Text rotation | |
| 67 | - * | |
| 68 | - * @var integer | |
| 69 | - */ | |
| 70 | - protected $textRotation = 0; | |
| 74 | + /** | |
| 75 | + * Text rotation | |
| 76 | + * | |
| 77 | + * @var integer | |
| 78 | + */ | |
| 79 | + protected $_textRotation = 0; | |
| 71 | 80 | |
| 72 | - /** | |
| 73 | - * Wrap text | |
| 74 | - * | |
| 75 | - * @var boolean | |
| 76 | - */ | |
| 77 | - protected $wrapText = false; | |
| 81 | + /** | |
| 82 | + * Wrap text | |
| 83 | + * | |
| 84 | + * @var boolean | |
| 85 | + */ | |
| 86 | + protected $_wrapText = FALSE; | |
| 78 | 87 | |
| 79 | - /** | |
| 80 | - * Shrink to fit | |
| 81 | - * | |
| 82 | - * @var boolean | |
| 83 | - */ | |
| 84 | - protected $shrinkToFit = false; | |
| 88 | + /** | |
| 89 | + * Shrink to fit | |
| 90 | + * | |
| 91 | + * @var boolean | |
| 92 | + */ | |
| 93 | + protected $_shrinkToFit = FALSE; | |
| 85 | 94 | |
| 86 | - /** | |
| 87 | - * Indent - only possible with horizontal alignment left and right | |
| 88 | - * | |
| 89 | - * @var integer | |
| 90 | - */ | |
| 91 | - protected $indent = 0; | |
| 95 | + /** | |
| 96 | + * Indent - only possible with horizontal alignment left and right | |
| 97 | + * | |
| 98 | + * @var integer | |
| 99 | + */ | |
| 100 | + protected $_indent = 0; | |
| 92 | 101 | |
| 93 | - /** | |
| 94 | - * Read order | |
| 95 | - * | |
| 96 | - * @var integer | |
| 97 | - */ | |
| 98 | - protected $readorder = 0; | |
| 102 | + /** | |
| 103 | + * Read order | |
| 104 | + * | |
| 105 | + * @var integer | |
| 106 | + */ | |
| 107 | + protected $_readorder = 0; | |
| 99 | 108 | |
| 100 | - /** | |
| 101 | - * Create a new PHPExcel_Style_Alignment | |
| 102 | - * | |
| 103 | - * @param boolean $isSupervisor Flag indicating if this is a supervisor or not | |
| 104 | - * Leave this value at default unless you understand exactly what | |
| 105 | - * its ramifications are | |
| 106 | - * @param boolean $isConditional Flag indicating if this is a conditional style or not | |
| 107 | - * Leave this value at default unless you understand exactly what | |
| 108 | - * its ramifications are | |
| 109 | - */ | |
| 110 | - public function __construct($isSupervisor = false, $isConditional = false) | |
| 111 | - { | |
| 112 | - // Supervisor? | |
| 113 | - parent::__construct($isSupervisor); | |
| 109 | + /** | |
| 110 | + * Create a new PHPExcel_Style_Alignment | |
| 111 | + * | |
| 112 | + * @param boolean $isSupervisor Flag indicating if this is a supervisor or not | |
| 113 | + * Leave this value at default unless you understand exactly what | |
| 114 | + * its ramifications are | |
| 115 | + * @param boolean $isConditional Flag indicating if this is a conditional style or not | |
| 116 | + * Leave this value at default unless you understand exactly what | |
| 117 | + * its ramifications are | |
| 118 | + */ | |
| 119 | + public function __construct($isSupervisor = FALSE, $isConditional = FALSE) | |
| 120 | + { | |
| 121 | + // Supervisor? | |
| 122 | + parent::__construct($isSupervisor); | |
| 114 | 123 | |
| 115 | - if ($isConditional) { | |
| 116 | - $this->horizontal = null; | |
| 117 | - $this->vertical = null; | |
| 118 | - $this->textRotation = null; | |
| 119 | - } | |
| 120 | - } | |
| 124 | + if ($isConditional) { | |
| 125 | + $this->_horizontal = NULL; | |
| 126 | + $this->_vertical = NULL; | |
| 127 | + $this->_textRotation = NULL; | |
| 128 | + } | |
| 129 | + } | |
| 121 | 130 | |
| 122 | - /** | |
| 123 | - * Get the shared style component for the currently active cell in currently active sheet. | |
| 124 | - * Only used for style supervisor | |
| 125 | - * | |
| 126 | - * @return PHPExcel_Style_Alignment | |
| 127 | - */ | |
| 128 | - public function getSharedComponent() | |
| 129 | - { | |
| 130 | - return $this->parent->getSharedComponent()->getAlignment(); | |
| 131 | - } | |
| 131 | + /** | |
| 132 | + * Get the shared style component for the currently active cell in currently active sheet. | |
| 133 | + * Only used for style supervisor | |
| 134 | + * | |
| 135 | + * @return PHPExcel_Style_Alignment | |
| 136 | + */ | |
| 137 | + public function getSharedComponent() | |
| 138 | + { | |
| 139 | + return $this->_parent->getSharedComponent()->getAlignment(); | |
| 140 | + } | |
| 132 | 141 | |
| 133 | - /** | |
| 134 | - * Build style array from subcomponents | |
| 135 | - * | |
| 136 | - * @param array $array | |
| 137 | - * @return array | |
| 138 | - */ | |
| 139 | - public function getStyleArray($array) | |
| 140 | - { | |
| 141 | - return array('alignment' => $array); | |
| 142 | - } | |
| 142 | + /** | |
| 143 | + * Build style array from subcomponents | |
| 144 | + * | |
| 145 | + * @param array $array | |
| 146 | + * @return array | |
| 147 | + */ | |
| 148 | + public function getStyleArray($array) | |
| 149 | + { | |
| 150 | + return array('alignment' => $array); | |
| 151 | + } | |
| 143 | 152 | |
| 144 | - /** | |
| 145 | - * Apply styles from array | |
| 146 | - * | |
| 147 | - * <code> | |
| 148 | - * $objPHPExcel->getActiveSheet()->getStyle('B2')->getAlignment()->applyFromArray( | |
| 149 | - * array( | |
| 150 | - * 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, | |
| 151 | - * 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, | |
| 152 | - * 'rotation' => 0, | |
| 153 | - * 'wrap' => TRUE | |
| 154 | - * ) | |
| 155 | - * ); | |
| 156 | - * </code> | |
| 157 | - * | |
| 158 | - * @param array $pStyles Array containing style information | |
| 159 | - * @throws PHPExcel_Exception | |
| 160 | - * @return PHPExcel_Style_Alignment | |
| 161 | - */ | |
| 162 | - public function applyFromArray($pStyles = null) | |
| 163 | - { | |
| 164 | - if (is_array($pStyles)) { | |
| 165 | - if ($this->isSupervisor) { | |
| 166 | - $this->getActiveSheet()->getStyle($this->getSelectedCells()) | |
| 167 | - ->applyFromArray($this->getStyleArray($pStyles)); | |
| 168 | - } else { | |
| 169 | - if (isset($pStyles['horizontal'])) { | |
| 170 | - $this->setHorizontal($pStyles['horizontal']); | |
| 171 | - } | |
| 172 | - if (isset($pStyles['vertical'])) { | |
| 173 | - $this->setVertical($pStyles['vertical']); | |
| 174 | - } | |
| 175 | - if (isset($pStyles['rotation'])) { | |
| 176 | - $this->setTextRotation($pStyles['rotation']); | |
| 177 | - } | |
| 178 | - if (isset($pStyles['wrap'])) { | |
| 179 | - $this->setWrapText($pStyles['wrap']); | |
| 180 | - } | |
| 181 | - if (isset($pStyles['shrinkToFit'])) { | |
| 182 | - $this->setShrinkToFit($pStyles['shrinkToFit']); | |
| 183 | - } | |
| 184 | - if (isset($pStyles['indent'])) { | |
| 185 | - $this->setIndent($pStyles['indent']); | |
| 186 | - } | |
| 187 | - if (isset($pStyles['readorder'])) { | |
| 188 | - $this->setReadorder($pStyles['readorder']); | |
| 189 | - } | |
| 190 | - } | |
| 191 | - } else { | |
| 192 | - throw new PHPExcel_Exception("Invalid style array passed."); | |
| 193 | - } | |
| 194 | - return $this; | |
| 195 | - } | |
| 153 | + /** | |
| 154 | + * Apply styles from array | |
| 155 | + * | |
| 156 | + * <code> | |
| 157 | + * $objPHPExcel->getActiveSheet()->getStyle('B2')->getAlignment()->applyFromArray( | |
| 158 | + * array( | |
| 159 | + * 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, | |
| 160 | + * 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, | |
| 161 | + * 'rotation' => 0, | |
| 162 | + * 'wrap' => TRUE | |
| 163 | + * ) | |
| 164 | + * ); | |
| 165 | + * </code> | |
| 166 | + * | |
| 167 | + * @param array $pStyles Array containing style information | |
| 168 | + * @throws PHPExcel_Exception | |
| 169 | + * @return PHPExcel_Style_Alignment | |
| 170 | + */ | |
| 171 | + public function applyFromArray($pStyles = NULL) { | |
| 172 | + if (is_array($pStyles)) { | |
| 173 | + if ($this->_isSupervisor) { | |
| 174 | + $this->getActiveSheet()->getStyle($this->getSelectedCells()) | |
| 175 | + ->applyFromArray($this->getStyleArray($pStyles)); | |
| 176 | + } else { | |
| 177 | + if (isset($pStyles['horizontal'])) { | |
| 178 | + $this->setHorizontal($pStyles['horizontal']); | |
| 179 | + } | |
| 180 | + if (isset($pStyles['vertical'])) { | |
| 181 | + $this->setVertical($pStyles['vertical']); | |
| 182 | + } | |
| 183 | + if (isset($pStyles['rotation'])) { | |
| 184 | + $this->setTextRotation($pStyles['rotation']); | |
| 185 | + } | |
| 186 | + if (isset($pStyles['wrap'])) { | |
| 187 | + $this->setWrapText($pStyles['wrap']); | |
| 188 | + } | |
| 189 | + if (isset($pStyles['shrinkToFit'])) { | |
| 190 | + $this->setShrinkToFit($pStyles['shrinkToFit']); | |
| 191 | + } | |
| 192 | + if (isset($pStyles['indent'])) { | |
| 193 | + $this->setIndent($pStyles['indent']); | |
| 194 | + } | |
| 195 | + if (isset($pStyles['readorder'])) { | |
| 196 | + $this->setReadorder($pStyles['readorder']); | |
| 197 | + } | |
| 198 | + } | |
| 199 | + } else { | |
| 200 | + throw new PHPExcel_Exception("Invalid style array passed."); | |
| 201 | + } | |
| 202 | + return $this; | |
| 203 | + } | |
| 196 | 204 | |
| 197 | - /** | |
| 198 | - * Get Horizontal | |
| 199 | - * | |
| 200 | - * @return string | |
| 201 | - */ | |
| 202 | - public function getHorizontal() | |
| 203 | - { | |
| 204 | - if ($this->isSupervisor) { | |
| 205 | - return $this->getSharedComponent()->getHorizontal(); | |
| 206 | - } | |
| 207 | - return $this->horizontal; | |
| 208 | - } | |
| 205 | + /** | |
| 206 | + * Get Horizontal | |
| 207 | + * | |
| 208 | + * @return string | |
| 209 | + */ | |
| 210 | + public function getHorizontal() { | |
| 211 | + if ($this->_isSupervisor) { | |
| 212 | + return $this->getSharedComponent()->getHorizontal(); | |
| 213 | + } | |
| 214 | + return $this->_horizontal; | |
| 215 | + } | |
| 209 | 216 | |
| 210 | - /** | |
| 211 | - * Set Horizontal | |
| 212 | - * | |
| 213 | - * @param string $pValue | |
| 214 | - * @return PHPExcel_Style_Alignment | |
| 215 | - */ | |
| 216 | - public function setHorizontal($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) | |
| 217 | - { | |
| 218 | - if ($pValue == '') { | |
| 219 | - $pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; | |
| 220 | - } | |
| 217 | + /** | |
| 218 | + * Set Horizontal | |
| 219 | + * | |
| 220 | + * @param string $pValue | |
| 221 | + * @return PHPExcel_Style_Alignment | |
| 222 | + */ | |
| 223 | + public function setHorizontal($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) { | |
| 224 | + if ($pValue == '') { | |
| 225 | + $pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; | |
| 226 | + } | |
| 221 | 227 | |
| 222 | - if ($this->isSupervisor) { | |
| 223 | - $styleArray = $this->getStyleArray(array('horizontal' => $pValue)); | |
| 224 | - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); | |
| 225 | - } else { | |
| 226 | - $this->horizontal = $pValue; | |
| 227 | - } | |
| 228 | - return $this; | |
| 229 | - } | |
| 228 | + if ($this->_isSupervisor) { | |
| 229 | + $styleArray = $this->getStyleArray(array('horizontal' => $pValue)); | |
| 230 | + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); | |
| 231 | + } | |
| 232 | + else { | |
| 233 | + $this->_horizontal = $pValue; | |
| 234 | + } | |
| 235 | + return $this; | |
| 236 | + } | |
| 230 | 237 | |
| 231 | - /** | |
| 232 | - * Get Vertical | |
| 233 | - * | |
| 234 | - * @return string | |
| 235 | - */ | |
| 236 | - public function getVertical() | |
| 237 | - { | |
| 238 | - if ($this->isSupervisor) { | |
| 239 | - return $this->getSharedComponent()->getVertical(); | |
| 240 | - } | |
| 241 | - return $this->vertical; | |
| 242 | - } | |
| 238 | + /** | |
| 239 | + * Get Vertical | |
| 240 | + * | |
| 241 | + * @return string | |
| 242 | + */ | |
| 243 | + public function getVertical() { | |
| 244 | + if ($this->_isSupervisor) { | |
| 245 | + return $this->getSharedComponent()->getVertical(); | |
| 246 | + } | |
| 247 | + return $this->_vertical; | |
| 248 | + } | |
| 243 | 249 | |
| 244 | - /** | |
| 245 | - * Set Vertical | |
| 246 | - * | |
| 247 | - * @param string $pValue | |
| 248 | - * @return PHPExcel_Style_Alignment | |
| 249 | - */ | |
| 250 | - public function setVertical($pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM) | |
| 251 | - { | |
| 252 | - if ($pValue == '') { | |
| 253 | - $pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM; | |
| 254 | - } | |
| 250 | + /** | |
| 251 | + * Set Vertical | |
| 252 | + * | |
| 253 | + * @param string $pValue | |
| 254 | + * @return PHPExcel_Style_Alignment | |
| 255 | + */ | |
| 256 | + public function setVertical($pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM) { | |
| 257 | + if ($pValue == '') { | |
| 258 | + $pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM; | |
| 259 | + } | |
| 255 | 260 | |
| 256 | - if ($this->isSupervisor) { | |
| 257 | - $styleArray = $this->getStyleArray(array('vertical' => $pValue)); | |
| 258 | - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); | |
| 259 | - } else { | |
| 260 | - $this->vertical = $pValue; | |
| 261 | - } | |
| 262 | - return $this; | |
| 263 | - } | |
| 261 | + if ($this->_isSupervisor) { | |
| 262 | + $styleArray = $this->getStyleArray(array('vertical' => $pValue)); | |
| 263 | + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); | |
| 264 | + } else { | |
| 265 | + $this->_vertical = $pValue; | |
| 266 | + } | |
| 267 | + return $this; | |
| 268 | + } | |
| 264 | 269 | |
| 265 | - /** | |
| 266 | - * Get TextRotation | |
| 267 | - * | |
| 268 | - * @return int | |
| 269 | - */ | |
| 270 | - public function getTextRotation() | |
| 271 | - { | |
| 272 | - if ($this->isSupervisor) { | |
| 273 | - return $this->getSharedComponent()->getTextRotation(); | |
| 274 | - } | |
| 275 | - return $this->textRotation; | |
| 276 | - } | |
| 270 | + /** | |
| 271 | + * Get TextRotation | |
| 272 | + * | |
| 273 | + * @return int | |
| 274 | + */ | |
| 275 | + public function getTextRotation() { | |
| 276 | + if ($this->_isSupervisor) { | |
| 277 | + return $this->getSharedComponent()->getTextRotation(); | |
| 278 | + } | |
| 279 | + return $this->_textRotation; | |
| 280 | + } | |
| 277 | 281 | |
| 278 | - /** | |
| 279 | - * Set TextRotation | |
| 280 | - * | |
| 281 | - * @param int $pValue | |
| 282 | - * @throws PHPExcel_Exception | |
| 283 | - * @return PHPExcel_Style_Alignment | |
| 284 | - */ | |
| 285 | - public function setTextRotation($pValue = 0) | |
| 286 | - { | |
| 287 | - // Excel2007 value 255 => PHPExcel value -165 | |
| 288 | - if ($pValue == 255) { | |
| 289 | - $pValue = -165; | |
| 290 | - } | |
| 282 | + /** | |
| 283 | + * Set TextRotation | |
| 284 | + * | |
| 285 | + * @param int $pValue | |
| 286 | + * @throws PHPExcel_Exception | |
| 287 | + * @return PHPExcel_Style_Alignment | |
| 288 | + */ | |
| 289 | + public function setTextRotation($pValue = 0) { | |
| 290 | + // Excel2007 value 255 => PHPExcel value -165 | |
| 291 | + if ($pValue == 255) { | |
| 292 | + $pValue = -165; | |
| 293 | + } | |
| 291 | 294 | |
| 292 | - // Set rotation | |
| 293 | - if (($pValue >= -90 && $pValue <= 90) || $pValue == -165) { | |
| 294 | - if ($this->isSupervisor) { | |
| 295 | - $styleArray = $this->getStyleArray(array('rotation' => $pValue)); | |
| 296 | - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); | |
| 297 | - } else { | |
| 298 | - $this->textRotation = $pValue; | |
| 299 | - } | |
| 300 | - } else { | |
| 301 | - throw new PHPExcel_Exception("Text rotation should be a value between -90 and 90."); | |
| 302 | - } | |
| 295 | + // Set rotation | |
| 296 | + if ( ($pValue >= -90 && $pValue <= 90) || $pValue == -165 ) { | |
| 297 | + if ($this->_isSupervisor) { | |
| 298 | + $styleArray = $this->getStyleArray(array('rotation' => $pValue)); | |
| 299 | + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); | |
| 300 | + } else { | |
| 301 | + $this->_textRotation = $pValue; | |
| 302 | + } | |
| 303 | + } else { | |
| 304 | + throw new PHPExcel_Exception("Text rotation should be a value between -90 and 90."); | |
| 305 | + } | |
| 303 | 306 | |
| 304 | - return $this; | |
| 305 | - } | |
| 307 | + return $this; | |
| 308 | + } | |
| 306 | 309 | |
| 307 | - /** | |
| 308 | - * Get Wrap Text | |
| 309 | - * | |
| 310 | - * @return boolean | |
| 311 | - */ | |
| 312 | - public function getWrapText() | |
| 313 | - { | |
| 314 | - if ($this->isSupervisor) { | |
| 315 | - return $this->getSharedComponent()->getWrapText(); | |
| 316 | - } | |
| 317 | - return $this->wrapText; | |
| 318 | - } | |
| 310 | + /** | |
| 311 | + * Get Wrap Text | |
| 312 | + * | |
| 313 | + * @return boolean | |
| 314 | + */ | |
| 315 | + public function getWrapText() { | |
| 316 | + if ($this->_isSupervisor) { | |
| 317 | + return $this->getSharedComponent()->getWrapText(); | |
| 318 | + } | |
| 319 | + return $this->_wrapText; | |
| 320 | + } | |
| 319 | 321 | |
| 320 | - /** | |
| 321 | - * Set Wrap Text | |
| 322 | - * | |
| 323 | - * @param boolean $pValue | |
| 324 | - * @return PHPExcel_Style_Alignment | |
| 325 | - */ | |
| 326 | - public function setWrapText($pValue = false) | |
| 327 | - { | |
| 328 | - if ($pValue == '') { | |
| 329 | - $pValue = false; | |
| 330 | - } | |
| 331 | - if ($this->isSupervisor) { | |
| 332 | - $styleArray = $this->getStyleArray(array('wrap' => $pValue)); | |
| 333 | - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); | |
| 334 | - } else { | |
| 335 | - $this->wrapText = $pValue; | |
| 336 | - } | |
| 337 | - return $this; | |
| 338 | - } | |
| 322 | + /** | |
| 323 | + * Set Wrap Text | |
| 324 | + * | |
| 325 | + * @param boolean $pValue | |
| 326 | + * @return PHPExcel_Style_Alignment | |
| 327 | + */ | |
| 328 | + public function setWrapText($pValue = FALSE) { | |
| 329 | + if ($pValue == '') { | |
| 330 | + $pValue = FALSE; | |
| 331 | + } | |
| 332 | + if ($this->_isSupervisor) { | |
| 333 | + $styleArray = $this->getStyleArray(array('wrap' => $pValue)); | |
| 334 | + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); | |
| 335 | + } else { | |
| 336 | + $this->_wrapText = $pValue; | |
| 337 | + } | |
| 338 | + return $this; | |
| 339 | + } | |
| 339 | 340 | |
| 340 | - /** | |
| 341 | - * Get Shrink to fit | |
| 342 | - * | |
| 343 | - * @return boolean | |
| 344 | - */ | |
| 345 | - public function getShrinkToFit() | |
| 346 | - { | |
| 347 | - if ($this->isSupervisor) { | |
| 348 | - return $this->getSharedComponent()->getShrinkToFit(); | |
| 349 | - } | |
| 350 | - return $this->shrinkToFit; | |
| 351 | - } | |
| 341 | + /** | |
| 342 | + * Get Shrink to fit | |
| 343 | + * | |
| 344 | + * @return boolean | |
| 345 | + */ | |
| 346 | + public function getShrinkToFit() { | |
| 347 | + if ($this->_isSupervisor) { | |
| 348 | + return $this->getSharedComponent()->getShrinkToFit(); | |
| 349 | + } | |
| 350 | + return $this->_shrinkToFit; | |
| 351 | + } | |
| 352 | 352 | |
| 353 | - /** | |
| 354 | - * Set Shrink to fit | |
| 355 | - * | |
| 356 | - * @param boolean $pValue | |
| 357 | - * @return PHPExcel_Style_Alignment | |
| 358 | - */ | |
| 359 | - public function setShrinkToFit($pValue = false) | |
| 360 | - { | |
| 361 | - if ($pValue == '') { | |
| 362 | - $pValue = false; | |
| 363 | - } | |
| 364 | - if ($this->isSupervisor) { | |
| 365 | - $styleArray = $this->getStyleArray(array('shrinkToFit' => $pValue)); | |
| 366 | - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); | |
| 367 | - } else { | |
| 368 | - $this->shrinkToFit = $pValue; | |
| 369 | - } | |
| 370 | - return $this; | |
| 371 | - } | |
| 353 | + /** | |
| 354 | + * Set Shrink to fit | |
| 355 | + * | |
| 356 | + * @param boolean $pValue | |
| 357 | + * @return PHPExcel_Style_Alignment | |
| 358 | + */ | |
| 359 | + public function setShrinkToFit($pValue = FALSE) { | |
| 360 | + if ($pValue == '') { | |
| 361 | + $pValue = FALSE; | |
| 362 | + } | |
| 363 | + if ($this->_isSupervisor) { | |
| 364 | + $styleArray = $this->getStyleArray(array('shrinkToFit' => $pValue)); | |
| 365 | + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); | |
| 366 | + } else { | |
| 367 | + $this->_shrinkToFit = $pValue; | |
| 368 | + } | |
| 369 | + return $this; | |
| 370 | + } | |
| 372 | 371 | |
| 373 | - /** | |
| 374 | - * Get indent | |
| 375 | - * | |
| 376 | - * @return int | |
| 377 | - */ | |
| 378 | - public function getIndent() | |
| 379 | - { | |
| 380 | - if ($this->isSupervisor) { | |
| 381 | - return $this->getSharedComponent()->getIndent(); | |
| 382 | - } | |
| 383 | - return $this->indent; | |
| 384 | - } | |
| 372 | + /** | |
| 373 | + * Get indent | |
| 374 | + * | |
| 375 | + * @return int | |
| 376 | + */ | |
| 377 | + public function getIndent() { | |
| 378 | + if ($this->_isSupervisor) { | |
| 379 | + return $this->getSharedComponent()->getIndent(); | |
| 380 | + } | |
| 381 | + return $this->_indent; | |
| 382 | + } | |
| 385 | 383 | |
| 386 | - /** | |
| 387 | - * Set indent | |
| 388 | - * | |
| 389 | - * @param int $pValue | |
| 390 | - * @return PHPExcel_Style_Alignment | |
| 391 | - */ | |
| 392 | - public function setIndent($pValue = 0) | |
| 393 | - { | |
| 394 | - if ($pValue > 0) { | |
| 395 | - if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && | |
| 396 | - $this->getHorizontal() != self::HORIZONTAL_LEFT && | |
| 397 | - $this->getHorizontal() != self::HORIZONTAL_RIGHT) { | |
| 398 | - $pValue = 0; // indent not supported | |
| 399 | - } | |
| 400 | - } | |
| 401 | - if ($this->isSupervisor) { | |
| 402 | - $styleArray = $this->getStyleArray(array('indent' => $pValue)); | |
| 403 | - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); | |
| 404 | - } else { | |
| 405 | - $this->indent = $pValue; | |
| 406 | - } | |
| 407 | - return $this; | |
| 408 | - } | |
| 384 | + /** | |
| 385 | + * Set indent | |
| 386 | + * | |
| 387 | + * @param int $pValue | |
| 388 | + * @return PHPExcel_Style_Alignment | |
| 389 | + */ | |
| 390 | + public function setIndent($pValue = 0) { | |
| 391 | + if ($pValue > 0) { | |
| 392 | + if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && | |
| 393 | + $this->getHorizontal() != self::HORIZONTAL_LEFT && | |
| 394 | + $this->getHorizontal() != self::HORIZONTAL_RIGHT) { | |
| 395 | + $pValue = 0; // indent not supported | |
| 396 | + } | |
| 397 | + } | |
| 398 | + if ($this->_isSupervisor) { | |
| 399 | + $styleArray = $this->getStyleArray(array('indent' => $pValue)); | |
| 400 | + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); | |
| 401 | + } else { | |
| 402 | + $this->_indent = $pValue; | |
| 403 | + } | |
| 404 | + return $this; | |
| 405 | + } | |
| 409 | 406 | |
| 410 | - /** | |
| 411 | - * Get read order | |
| 412 | - * | |
| 413 | - * @return integer | |
| 414 | - */ | |
| 415 | - public function getReadorder() | |
| 416 | - { | |
| 417 | - if ($this->isSupervisor) { | |
| 418 | - return $this->getSharedComponent()->getReadorder(); | |
| 419 | - } | |
| 420 | - return $this->readorder; | |
| 421 | - } | |
| 407 | + /** | |
| 408 | + * Get read order | |
| 409 | + * | |
| 410 | + * @return integer | |
| 411 | + */ | |
| 412 | + public function getReadorder() { | |
| 413 | + if ($this->_isSupervisor) { | |
| 414 | + return $this->getSharedComponent()->getReadorder(); | |
| 415 | + } | |
| 416 | + return $this->_readorder; | |
| 417 | + } | |
| 422 | 418 | |
| 423 | - /** | |
| 424 | - * Set read order | |
| 425 | - * | |
| 426 | - * @param int $pValue | |
| 427 | - * @return PHPExcel_Style_Alignment | |
| 428 | - */ | |
| 429 | - public function setReadorder($pValue = 0) | |
| 430 | - { | |
| 431 | - if ($pValue < 0 || $pValue > 2) { | |
| 419 | + /** | |
| 420 | + * Set read order | |
| 421 | + * | |
| 422 | + * @param int $pValue | |
| 423 | + * @return PHPExcel_Style_Alignment | |
| 424 | + */ | |
| 425 | + public function setReadorder($pValue = 0) { | |
| 426 | + if ($pValue < 0 || $pValue > 2) { | |
| 432 | 427 | $pValue = 0; |
| 433 | - } | |
| 434 | - if ($this->isSupervisor) { | |
| 435 | - $styleArray = $this->getStyleArray(array('readorder' => $pValue)); | |
| 436 | - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); | |
| 437 | - } else { | |
| 438 | - $this->readorder = $pValue; | |
| 439 | - } | |
| 440 | - return $this; | |
| 441 | - } | |
| 428 | + } | |
| 429 | + if ($this->_isSupervisor) { | |
| 430 | + $styleArray = $this->getStyleArray(array('readorder' => $pValue)); | |
| 431 | + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); | |
| 432 | + } else { | |
| 433 | + $this->_readorder = $pValue; | |
| 434 | + } | |
| 435 | + return $this; | |
| 436 | + } | |
| 442 | 437 | |
| 443 | - /** | |
| 444 | - * Get hash code | |
| 445 | - * | |
| 446 | - * @return string Hash code | |
| 447 | - */ | |
| 448 | - public function getHashCode() | |
| 449 | - { | |
| 450 | - if ($this->isSupervisor) { | |
| 451 | - return $this->getSharedComponent()->getHashCode(); | |
| 452 | - } | |
| 453 | - return md5( | |
| 454 | - $this->horizontal . | |
| 455 | - $this->vertical . | |
| 456 | - $this->textRotation . | |
| 457 | - ($this->wrapText ? 't' : 'f') . | |
| 458 | - ($this->shrinkToFit ? 't' : 'f') . | |
| 459 | - $this->indent . | |
| 460 | - $this->readorder . | |
| 461 | - __CLASS__ | |
| 462 | - ); | |
| 463 | - } | |
| 438 | + /** | |
| 439 | + * Get hash code | |
| 440 | + * | |
| 441 | + * @return string Hash code | |
| 442 | + */ | |
| 443 | + public function getHashCode() { | |
| 444 | + if ($this->_isSupervisor) { | |
| 445 | + return $this->getSharedComponent()->getHashCode(); | |
| 446 | + } | |
| 447 | + return md5( | |
| 448 | + $this->_horizontal | |
| 449 | + . $this->_vertical | |
| 450 | + . $this->_textRotation | |
| 451 | + . ($this->_wrapText ? 't' : 'f') | |
| 452 | + . ($this->_shrinkToFit ? 't' : 'f') | |
| 453 | + . $this->_indent | |
| 454 | + . $this->_readorder | |
| 455 | + . __CLASS__ | |
| 456 | + ); | |
| 457 | + } | |
| 458 | + | |
| 464 | 459 | } |