More refactoring of Excel5 Reader mappings

This commit is contained in:
MarkBaker 2015-12-30 20:01:29 +00:00
parent e11a76759f
commit dbb819003c
4 changed files with 71 additions and 97 deletions

View File

@ -7627,38 +7627,10 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
*/
private static function mapBorderStyle($index)
{
switch ($index) {
case 0x00:
return PHPExcel_Style_Border::BORDER_NONE;
case 0x01:
return PHPExcel_Style_Border::BORDER_THIN;
case 0x02:
return PHPExcel_Style_Border::BORDER_MEDIUM;
case 0x03:
return PHPExcel_Style_Border::BORDER_DASHED;
case 0x04:
return PHPExcel_Style_Border::BORDER_DOTTED;
case 0x05:
return PHPExcel_Style_Border::BORDER_THICK;
case 0x06:
return PHPExcel_Style_Border::BORDER_DOUBLE;
case 0x07:
return PHPExcel_Style_Border::BORDER_HAIR;
case 0x08:
return PHPExcel_Style_Border::BORDER_MEDIUMDASHED;
case 0x09:
return PHPExcel_Style_Border::BORDER_DASHDOT;
case 0x0A:
return PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT;
case 0x0B:
return PHPExcel_Style_Border::BORDER_DASHDOTDOT;
case 0x0C:
return PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT;
case 0x0D:
return PHPExcel_Style_Border::BORDER_SLANTDASHDOT;
default:
return PHPExcel_Style_Border::BORDER_NONE;
if (isset(PHPExcel_Reader_Excel5_Style_Border::$map[$index])) {
return PHPExcel_Reader_Excel5_Style_Border::$map[$index];
}
return PHPExcel_Style_Border::BORDER_NONE;
}
@ -7671,48 +7643,10 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
*/
private static function mapFillPattern($index)
{
switch ($index) {
case 0x00:
return PHPExcel_Style_Fill::FILL_NONE;
case 0x01:
return PHPExcel_Style_Fill::FILL_SOLID;
case 0x02:
return PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY;
case 0x03:
return PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY;
case 0x04:
return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY;
case 0x05:
return PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL;
case 0x06:
return PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL;
case 0x07:
return PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN;
case 0x08:
return PHPExcel_Style_Fill::FILL_PATTERN_DARKUP;
case 0x09:
return PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID;
case 0x0A:
return PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS;
case 0x0B:
return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL;
case 0x0C:
return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL;
case 0x0D:
return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN;
case 0x0E:
return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP;
case 0x0F:
return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID;
case 0x10:
return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS;
case 0x11:
return PHPExcel_Style_Fill::FILL_PATTERN_GRAY125;
case 0x12:
return PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625;
default:
return PHPExcel_Style_Fill::FILL_NONE;
if (isset(PHPExcel_Reader_Excel5_Style_FillPattern::$map[$index])) {
return PHPExcel_Reader_Excel5_Style_FillPattern::$map[$index];
}
return PHPExcel_Style_Fill::FILL_NONE;
}
@ -7722,33 +7656,12 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
* @param int $subData
* @return string
*/
private static function mapErrorCode($subData)
private static function mapErrorCode($code)
{
switch ($subData) {
case 0x00:
return '#NULL!';
break;
case 0x07:
return '#DIV/0!';
break;
case 0x0F:
return '#VALUE!';
break;
case 0x17:
return '#REF!';
break;
case 0x1D:
return '#NAME?';
break;
case 0x24:
return '#NUM!';
break;
case 0x2A:
return '#N/A';
break;
default:
return false;
if (isset(PHPExcel_Reader_Excel5_ErrorCode::$map[$code])) {
return PHPExcel_Reader_Excel5_ErrorCode::$map[$code];
}
return false;
}

View File

@ -0,0 +1,14 @@
<?php
class PHPExcel_Reader_Excel5_ErrorCode
{
public static $map = array(
0x00 => '#NULL!',
0x07 => '#DIV/0!',
0x0F => '#VALUE!',
0x17 => '#REF!',
0x1D => '#NAME?',
0x24 => '#NUM!',
0x2A => '#N/A',
);
}

View File

@ -0,0 +1,21 @@
<?php
class PHPExcel_Reader_Excel5_Style_Border
{
public static $map = array(
0x00 => PHPExcel_Style_Border::BORDER_NONE,
0x01 => PHPExcel_Style_Border::BORDER_THIN,
0x02 => PHPExcel_Style_Border::BORDER_MEDIUM,
0x03 => PHPExcel_Style_Border::BORDER_DASHED,
0x04 => PHPExcel_Style_Border::BORDER_DOTTED,
0x05 => PHPExcel_Style_Border::BORDER_THICK,
0x06 => PHPExcel_Style_Border::BORDER_DOUBLE,
0x07 => PHPExcel_Style_Border::BORDER_HAIR,
0x08 => PHPExcel_Style_Border::BORDER_MEDIUMDASHED,
0x09 => PHPExcel_Style_Border::BORDER_DASHDOT,
0x0A => PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT,
0x0B => PHPExcel_Style_Border::BORDER_DASHDOTDOT,
0x0C => PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT,
0x0D => PHPExcel_Style_Border::BORDER_SLANTDASHDOT,
);
}

View File

@ -0,0 +1,26 @@
<?php
class PHPExcel_Reader_Excel5_Style_FillPattern
{
public static $map = array(
0x00 => PHPExcel_Style_Fill::FILL_NONE,
0x01 => PHPExcel_Style_Fill::FILL_SOLID,
0x02 => PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY,
0x03 => PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY,
0x04 => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY,
0x05 => PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL,
0x06 => PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL,
0x07 => PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN,
0x08 => PHPExcel_Style_Fill::FILL_PATTERN_DARKUP,
0x09 => PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID,
0x0A => PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS,
0x0B => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL,
0x0C => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL,
0x0D => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN,
0x0E => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP,
0x0F => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID,
0x10 => PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS,
0x11 => PHPExcel_Style_Fill::FILL_PATTERN_GRAY125,
0x12 => PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625,
);
}