Validation PSR-2 : Fixes

This commit is contained in:
Progi1984 2015-05-12 12:43:52 +02:00
parent 61b5fa0beb
commit 95b3fb024a
3 changed files with 79 additions and 72 deletions

View File

@ -166,7 +166,7 @@ class PHPExcel_Writer_Excel5_Xf
* *
* @return string The XF record * @return string The XF record
*/ */
function writeXf() public function writeXf()
{ {
// Set the type of the XF record and some of the attributes. // Set the type of the XF record and some of the attributes.
if ($this->_isStyleXf) { if ($this->_isStyleXf) {
@ -256,11 +256,7 @@ class PHPExcel_Writer_Excel5_Xf
$biff8_options |= (int) $this->_style->getAlignment()->getShrinkToFit() << 4; $biff8_options |= (int) $this->_style->getAlignment()->getShrinkToFit() << 4;
$data = pack("vvvC", $ifnt, $ifmt, $style, $align); $data = pack("vvvC", $ifnt, $ifmt, $style, $align);
$data .= pack("CCC" $data .= pack("CCC", self::_mapTextRotation($this->_style->getAlignment()->getTextRotation()), $biff8_options, $used_attrib);
, self::_mapTextRotation($this->_style->getAlignment()->getTextRotation())
, $biff8_options
, $used_attrib
);
$data .= pack("VVv", $border1, $border2, $icv); $data .= pack("VVv", $border1, $border2, $icv);
return($header . $data); return($header . $data);
@ -282,7 +278,7 @@ class PHPExcel_Writer_Excel5_Xf
* @access public * @access public
* @param int $colorIndex Color index * @param int $colorIndex Color index
*/ */
function setBottomColor($colorIndex) public function setBottomColor($colorIndex)
{ {
$this->_bottom_color = $colorIndex; $this->_bottom_color = $colorIndex;
} }
@ -293,7 +289,7 @@ class PHPExcel_Writer_Excel5_Xf
* @access public * @access public
* @param int $colorIndex Color index * @param int $colorIndex Color index
*/ */
function setTopColor($colorIndex) public function setTopColor($colorIndex)
{ {
$this->_top_color = $colorIndex; $this->_top_color = $colorIndex;
} }
@ -304,7 +300,7 @@ class PHPExcel_Writer_Excel5_Xf
* @access public * @access public
* @param int $colorIndex Color index * @param int $colorIndex Color index
*/ */
function setLeftColor($colorIndex) public function setLeftColor($colorIndex)
{ {
$this->_left_color = $colorIndex; $this->_left_color = $colorIndex;
} }
@ -315,7 +311,7 @@ class PHPExcel_Writer_Excel5_Xf
* @access public * @access public
* @param int $colorIndex Color index * @param int $colorIndex Color index
*/ */
function setRightColor($colorIndex) public function setRightColor($colorIndex)
{ {
$this->_right_color = $colorIndex; $this->_right_color = $colorIndex;
} }
@ -326,7 +322,7 @@ class PHPExcel_Writer_Excel5_Xf
* @access public * @access public
* @param int $colorIndex Color index * @param int $colorIndex Color index
*/ */
function setDiagColor($colorIndex) public function setDiagColor($colorIndex)
{ {
$this->_diag_color = $colorIndex; $this->_diag_color = $colorIndex;
} }
@ -338,7 +334,7 @@ class PHPExcel_Writer_Excel5_Xf
* @access public * @access public
* @param int $colorIndex Color index * @param int $colorIndex Color index
*/ */
function setFgColor($colorIndex) public function setFgColor($colorIndex)
{ {
$this->_fg_color = $colorIndex; $this->_fg_color = $colorIndex;
} }
@ -349,7 +345,7 @@ class PHPExcel_Writer_Excel5_Xf
* @access public * @access public
* @param int $colorIndex Color index * @param int $colorIndex Color index
*/ */
function setBgColor($colorIndex) public function setBgColor($colorIndex)
{ {
$this->_bg_color = $colorIndex; $this->_bg_color = $colorIndex;
} }
@ -361,7 +357,7 @@ class PHPExcel_Writer_Excel5_Xf
* @access public * @access public
* @param integer $numberFormatIndex Index to format record * @param integer $numberFormatIndex Index to format record
*/ */
function setNumberFormatIndex($numberFormatIndex) public function setNumberFormatIndex($numberFormatIndex)
{ {
$this->_numberFormatIndex = $numberFormatIndex; $this->_numberFormatIndex = $numberFormatIndex;
} }
@ -403,9 +399,11 @@ class PHPExcel_Writer_Excel5_Xf
* @param string $borderStyle * @param string $borderStyle
* @return int * @return int
*/ */
private static function _mapBorderStyle($borderStyle) { private static function _mapBorderStyle($borderStyle)
if (isset(self::$_mapBorderStyle[$borderStyle])) {
if (isset(self::$_mapBorderStyle[$borderStyle])) {
return self::$_mapBorderStyle[$borderStyle]; return self::$_mapBorderStyle[$borderStyle];
}
return 0x00; return 0x00;
} }
@ -442,9 +440,11 @@ class PHPExcel_Writer_Excel5_Xf
* @param string $fillType * @param string $fillType
* @return int * @return int
*/ */
private static function _mapFillType($fillType) { private static function _mapFillType($fillType)
if (isset(self::$_mapFillType[$fillType])) {
if (isset(self::$_mapFillType[$fillType])) {
return self::$_mapFillType[$fillType]; return self::$_mapFillType[$fillType];
}
return 0x00; return 0x00;
} }
@ -469,8 +469,9 @@ class PHPExcel_Writer_Excel5_Xf
*/ */
private function _mapHAlign($hAlign) private function _mapHAlign($hAlign)
{ {
if (isset(self::$_mapHAlign[$hAlign])) if (isset(self::$_mapHAlign[$hAlign])) {
return self::$_mapHAlign[$hAlign]; return self::$_mapHAlign[$hAlign];
}
return 0; return 0;
} }
@ -491,8 +492,9 @@ class PHPExcel_Writer_Excel5_Xf
* @return int * @return int
*/ */
private static function _mapVAlign($vAlign) { private static function _mapVAlign($vAlign) {
if (isset(self::$_mapVAlign[$vAlign])) if (isset(self::$_mapVAlign[$vAlign])) {
return self::$_mapVAlign[$vAlign]; return self::$_mapVAlign[$vAlign];
}
return 2; return 2;
} }
@ -522,10 +524,14 @@ class PHPExcel_Writer_Excel5_Xf
*/ */
private static function _mapLocked($locked) { private static function _mapLocked($locked) {
switch ($locked) { switch ($locked) {
case PHPExcel_Style_Protection::PROTECTION_INHERIT: return 1; case PHPExcel_Style_Protection::PROTECTION_INHERIT:
case PHPExcel_Style_Protection::PROTECTION_PROTECTED: return 1; return 1;
case PHPExcel_Style_Protection::PROTECTION_UNPROTECTED: return 0; case PHPExcel_Style_Protection::PROTECTION_PROTECTED:
default: return 1; return 1;
case PHPExcel_Style_Protection::PROTECTION_UNPROTECTED:
return 0;
default:
return 1;
} }
} }
@ -537,11 +543,14 @@ class PHPExcel_Writer_Excel5_Xf
*/ */
private static function _mapHidden($hidden) { private static function _mapHidden($hidden) {
switch ($hidden) { switch ($hidden) {
case PHPExcel_Style_Protection::PROTECTION_INHERIT: return 0; case PHPExcel_Style_Protection::PROTECTION_INHERIT:
case PHPExcel_Style_Protection::PROTECTION_PROTECTED: return 1; return 0;
case PHPExcel_Style_Protection::PROTECTION_UNPROTECTED: return 0; case PHPExcel_Style_Protection::PROTECTION_PROTECTED:
default: return 0; return 1;
case PHPExcel_Style_Protection::PROTECTION_UNPROTECTED:
return 0;
default:
return 0;
} }
} }
} }

View File

@ -944,7 +944,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$css['vertical-align'] = $this->_mapVAlign($pStyle->getVertical()); $css['vertical-align'] = $this->_mapVAlign($pStyle->getVertical());
if ($textAlign = $this->_mapHAlign($pStyle->getHorizontal())) { if ($textAlign = $this->_mapHAlign($pStyle->getHorizontal())) {
$css['text-align'] = $textAlign; $css['text-align'] = $textAlign;
if (in_array($textAlign,array('left','right'))) { if (in_array($textAlign,array('left', 'right'))) {
$css['padding-'.$textAlign] = (string)((int)$pStyle->getIndent() * 9).'px'; $css['padding-'.$textAlign] = (string)((int)$pStyle->getIndent() * 9).'px';
} }
} }
@ -1265,10 +1265,9 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
} }
// General horizontal alignment: Actual horizontal alignment depends on dataType // General horizontal alignment: Actual horizontal alignment depends on dataType
$sharedStyle = $pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() ); $sharedStyle = $pSheet->getParent()->getCellXfByIndex($cell->getXfIndex());
if ($sharedStyle->getAlignment()->getHorizontal() == PHPExcel_Style_Alignment::HORIZONTAL_GENERAL if ($sharedStyle->getAlignment()->getHorizontal() == PHPExcel_Style_Alignment::HORIZONTAL_GENERAL
&& isset($this->_cssStyles['.' . $cell->getDataType()]['text-align'])) && isset($this->_cssStyles['.' . $cell->getDataType()]['text-align'])) {
{
$cssClass['text-align'] = $this->_cssStyles['.' . $cell->getDataType()]['text-align']; $cssClass['text-align'] = $this->_cssStyles['.' . $cell->getDataType()]['text-align'];
} }
} }
@ -1510,13 +1509,13 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
// loop through the individual cells in the individual merge // loop through the individual cells in the individual merge
$r = $fr - 1; $r = $fr - 1;
while($r++ < $lr) { while ($r++ < $lr) {
// also, flag this row as a HTML row that is candidate to be omitted // also, flag this row as a HTML row that is candidate to be omitted
$candidateSpannedRow[$r] = $r; $candidateSpannedRow[$r] = $r;
$c = $fc - 1; $c = $fc - 1;
while($c++ < $lc) { while ($c++ < $lc) {
if ( !($c == $fc && $r == $fr) ) { if (!($c == $fc && $r == $fr)) {
// not the upper-left cell (should not be written in HTML) // not the upper-left cell (should not be written in HTML)
$this->_isSpannedCell[$sheetIndex][$r][$c] = array( $this->_isSpannedCell[$sheetIndex][$r][$c] = array(
'baseCell' => array($fr, $fc), 'baseCell' => array($fr, $fc),
@ -1546,15 +1545,15 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
} }
// For each of the omitted rows we found above, the affected rowspans should be subtracted by 1 // For each of the omitted rows we found above, the affected rowspans should be subtracted by 1
if ( isset($this->_isSpannedRow[$sheetIndex]) ) { if (isset($this->_isSpannedRow[$sheetIndex])) {
foreach ($this->_isSpannedRow[$sheetIndex] as $rowIndex) { foreach ($this->_isSpannedRow[$sheetIndex] as $rowIndex) {
$adjustedBaseCells = array(); $adjustedBaseCells = array();
$c = -1; $c = -1;
$e = $countColumns - 1; $e = $countColumns - 1;
while($c++ < $e) { while ($c++ < $e) {
$baseCell = $this->_isSpannedCell[$sheetIndex][$rowIndex][$c]['baseCell']; $baseCell = $this->_isSpannedCell[$sheetIndex][$rowIndex][$c]['baseCell'];
if ( !in_array($baseCell, $adjustedBaseCells) ) { if (!in_array($baseCell, $adjustedBaseCells)) {
// subtract rowspan by 1 // subtract rowspan by 1
--$this->_isBaseCell[$sheetIndex][ $baseCell[0] ][ $baseCell[1] ]['rowspan']; --$this->_isBaseCell[$sheetIndex][ $baseCell[0] ][ $baseCell[1] ]['rowspan'];
$adjustedBaseCells[] = $baseCell; $adjustedBaseCells[] = $baseCell;

View File

@ -34,5 +34,4 @@ interface PHPExcel_Writer_IWriter
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function save($pFilename = null); public function save($pFilename = null);
} }