Refactor mappers out from Excel5 Reader completely
This commit is contained in:
parent
70a557346e
commit
189a5c439e
|
@ -717,7 +717,7 @@ class Excel5 extends BaseReader implements IReader
|
||||||
if (!$this->readDataOnly) {
|
if (!$this->readDataOnly) {
|
||||||
foreach ($this->objFonts as $objFont) {
|
foreach ($this->objFonts as $objFont) {
|
||||||
if (isset($objFont->colorIndex)) {
|
if (isset($objFont->colorIndex)) {
|
||||||
$color = self::readColor($objFont->colorIndex, $this->palette, $this->version);
|
$color = Excel5\Color::map($objFont->colorIndex, $this->palette, $this->version);
|
||||||
$objFont->getColor()->setRGB($color['rgb']);
|
$objFont->getColor()->setRGB($color['rgb']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -727,11 +727,11 @@ class Excel5 extends BaseReader implements IReader
|
||||||
$fill = $objStyle->getFill();
|
$fill = $objStyle->getFill();
|
||||||
|
|
||||||
if (isset($fill->startcolorIndex)) {
|
if (isset($fill->startcolorIndex)) {
|
||||||
$startColor = self::readColor($fill->startcolorIndex, $this->palette, $this->version);
|
$startColor = Excel5\Color::map($fill->startcolorIndex, $this->palette, $this->version);
|
||||||
$fill->getStartColor()->setRGB($startColor['rgb']);
|
$fill->getStartColor()->setRGB($startColor['rgb']);
|
||||||
}
|
}
|
||||||
if (isset($fill->endcolorIndex)) {
|
if (isset($fill->endcolorIndex)) {
|
||||||
$endColor = self::readColor($fill->endcolorIndex, $this->palette, $this->version);
|
$endColor = Excel5\Color::map($fill->endcolorIndex, $this->palette, $this->version);
|
||||||
$fill->getEndColor()->setRGB($endColor['rgb']);
|
$fill->getEndColor()->setRGB($endColor['rgb']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -743,23 +743,23 @@ class Excel5 extends BaseReader implements IReader
|
||||||
$diagonal = $objStyle->getBorders()->getDiagonal();
|
$diagonal = $objStyle->getBorders()->getDiagonal();
|
||||||
|
|
||||||
if (isset($top->colorIndex)) {
|
if (isset($top->colorIndex)) {
|
||||||
$borderTopColor = self::readColor($top->colorIndex, $this->palette, $this->version);
|
$borderTopColor = Excel5\Color::map($top->colorIndex, $this->palette, $this->version);
|
||||||
$top->getColor()->setRGB($borderTopColor['rgb']);
|
$top->getColor()->setRGB($borderTopColor['rgb']);
|
||||||
}
|
}
|
||||||
if (isset($right->colorIndex)) {
|
if (isset($right->colorIndex)) {
|
||||||
$borderRightColor = self::readColor($right->colorIndex, $this->palette, $this->version);
|
$borderRightColor = Excel5\Color::map($right->colorIndex, $this->palette, $this->version);
|
||||||
$right->getColor()->setRGB($borderRightColor['rgb']);
|
$right->getColor()->setRGB($borderRightColor['rgb']);
|
||||||
}
|
}
|
||||||
if (isset($bottom->colorIndex)) {
|
if (isset($bottom->colorIndex)) {
|
||||||
$borderBottomColor = self::readColor($bottom->colorIndex, $this->palette, $this->version);
|
$borderBottomColor = Excel5\Color::map($bottom->colorIndex, $this->palette, $this->version);
|
||||||
$bottom->getColor()->setRGB($borderBottomColor['rgb']);
|
$bottom->getColor()->setRGB($borderBottomColor['rgb']);
|
||||||
}
|
}
|
||||||
if (isset($left->colorIndex)) {
|
if (isset($left->colorIndex)) {
|
||||||
$borderLeftColor = self::readColor($left->colorIndex, $this->palette, $this->version);
|
$borderLeftColor = Excel5\Color::map($left->colorIndex, $this->palette, $this->version);
|
||||||
$left->getColor()->setRGB($borderLeftColor['rgb']);
|
$left->getColor()->setRGB($borderLeftColor['rgb']);
|
||||||
}
|
}
|
||||||
if (isset($diagonal->colorIndex)) {
|
if (isset($diagonal->colorIndex)) {
|
||||||
$borderDiagonalColor = self::readColor($diagonal->colorIndex, $this->palette, $this->version);
|
$borderDiagonalColor = Excel5\Color::map($diagonal->colorIndex, $this->palette, $this->version);
|
||||||
$diagonal->getColor()->setRGB($borderDiagonalColor['rgb']);
|
$diagonal->getColor()->setRGB($borderDiagonalColor['rgb']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2194,19 +2194,19 @@ class Excel5 extends BaseReader implements IReader
|
||||||
|
|
||||||
// offset: 10; size: 4; Cell border lines and background area
|
// offset: 10; size: 4; Cell border lines and background area
|
||||||
// bit: 3-0; mask: 0x0000000F; left style
|
// bit: 3-0; mask: 0x0000000F; left style
|
||||||
if ($bordersLeftStyle = self::mapBorderStyle((0x0000000F & self::getInt4d($recordData, 10)) >> 0)) {
|
if ($bordersLeftStyle = Excel5\Style\Border::lookup((0x0000000F & self::getInt4d($recordData, 10)) >> 0)) {
|
||||||
$objStyle->getBorders()->getLeft()->setBorderStyle($bordersLeftStyle);
|
$objStyle->getBorders()->getLeft()->setBorderStyle($bordersLeftStyle);
|
||||||
}
|
}
|
||||||
// bit: 7-4; mask: 0x000000F0; right style
|
// bit: 7-4; mask: 0x000000F0; right style
|
||||||
if ($bordersRightStyle = self::mapBorderStyle((0x000000F0 & self::getInt4d($recordData, 10)) >> 4)) {
|
if ($bordersRightStyle = Excel5\Style\Border::lookup((0x000000F0 & self::getInt4d($recordData, 10)) >> 4)) {
|
||||||
$objStyle->getBorders()->getRight()->setBorderStyle($bordersRightStyle);
|
$objStyle->getBorders()->getRight()->setBorderStyle($bordersRightStyle);
|
||||||
}
|
}
|
||||||
// bit: 11-8; mask: 0x00000F00; top style
|
// bit: 11-8; mask: 0x00000F00; top style
|
||||||
if ($bordersTopStyle = self::mapBorderStyle((0x00000F00 & self::getInt4d($recordData, 10)) >> 8)) {
|
if ($bordersTopStyle = Excel5\Style\Border::lookup((0x00000F00 & self::getInt4d($recordData, 10)) >> 8)) {
|
||||||
$objStyle->getBorders()->getTop()->setBorderStyle($bordersTopStyle);
|
$objStyle->getBorders()->getTop()->setBorderStyle($bordersTopStyle);
|
||||||
}
|
}
|
||||||
// bit: 15-12; mask: 0x0000F000; bottom style
|
// bit: 15-12; mask: 0x0000F000; bottom style
|
||||||
if ($bordersBottomStyle = self::mapBorderStyle((0x0000F000 & self::getInt4d($recordData, 10)) >> 12)) {
|
if ($bordersBottomStyle = Excel5\Style\Border::lookup((0x0000F000 & self::getInt4d($recordData, 10)) >> 12)) {
|
||||||
$objStyle->getBorders()->getBottom()->setBorderStyle($bordersBottomStyle);
|
$objStyle->getBorders()->getBottom()->setBorderStyle($bordersBottomStyle);
|
||||||
}
|
}
|
||||||
// bit: 22-16; mask: 0x007F0000; left color
|
// bit: 22-16; mask: 0x007F0000; left color
|
||||||
|
@ -2242,12 +2242,12 @@ class Excel5 extends BaseReader implements IReader
|
||||||
$objStyle->getBorders()->getDiagonal()->colorIndex = (0x001FC000 & self::getInt4d($recordData, 14)) >> 14;
|
$objStyle->getBorders()->getDiagonal()->colorIndex = (0x001FC000 & self::getInt4d($recordData, 14)) >> 14;
|
||||||
|
|
||||||
// bit: 24-21; mask: 0x01E00000; diagonal style
|
// bit: 24-21; mask: 0x01E00000; diagonal style
|
||||||
if ($bordersDiagonalStyle = self::mapBorderStyle((0x01E00000 & self::getInt4d($recordData, 14)) >> 21)) {
|
if ($bordersDiagonalStyle = Excel5\Style\Border::lookup((0x01E00000 & self::getInt4d($recordData, 14)) >> 21)) {
|
||||||
$objStyle->getBorders()->getDiagonal()->setBorderStyle($bordersDiagonalStyle);
|
$objStyle->getBorders()->getDiagonal()->setBorderStyle($bordersDiagonalStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// bit: 31-26; mask: 0xFC000000 fill pattern
|
// bit: 31-26; mask: 0xFC000000 fill pattern
|
||||||
if ($fillType = self::mapFillPattern((0xFC000000 & self::getInt4d($recordData, 14)) >> 26)) {
|
if ($fillType = Excel5\Style\FillPattern::lookup((0xFC000000 & self::getInt4d($recordData, 14)) >> 26)) {
|
||||||
$objStyle->getFill()->setFillType($fillType);
|
$objStyle->getFill()->setFillType($fillType);
|
||||||
}
|
}
|
||||||
// offset: 18; size: 2; pattern and background colour
|
// offset: 18; size: 2; pattern and background colour
|
||||||
|
@ -2289,10 +2289,10 @@ class Excel5 extends BaseReader implements IReader
|
||||||
$objStyle->getFill()->endcolorIndex = (0x00003F80 & $borderAndBackground) >> 7;
|
$objStyle->getFill()->endcolorIndex = (0x00003F80 & $borderAndBackground) >> 7;
|
||||||
|
|
||||||
// bit: 21-16; mask: 0x003F0000; fill pattern
|
// bit: 21-16; mask: 0x003F0000; fill pattern
|
||||||
$objStyle->getFill()->setFillType(self::mapFillPattern((0x003F0000 & $borderAndBackground) >> 16));
|
$objStyle->getFill()->setFillType(Excel5\Style\FillPattern::lookup((0x003F0000 & $borderAndBackground) >> 16));
|
||||||
|
|
||||||
// bit: 24-22; mask: 0x01C00000; bottom line style
|
// bit: 24-22; mask: 0x01C00000; bottom line style
|
||||||
$objStyle->getBorders()->getBottom()->setBorderStyle(self::mapBorderStyle((0x01C00000 & $borderAndBackground) >> 22));
|
$objStyle->getBorders()->getBottom()->setBorderStyle(Excel5\Style\Border::lookup((0x01C00000 & $borderAndBackground) >> 22));
|
||||||
|
|
||||||
// bit: 31-25; mask: 0xFE000000; bottom line color
|
// bit: 31-25; mask: 0xFE000000; bottom line color
|
||||||
$objStyle->getBorders()->getBottom()->colorIndex = (0xFE000000 & $borderAndBackground) >> 25;
|
$objStyle->getBorders()->getBottom()->colorIndex = (0xFE000000 & $borderAndBackground) >> 25;
|
||||||
|
@ -2301,13 +2301,13 @@ class Excel5 extends BaseReader implements IReader
|
||||||
$borderLines = self::getInt4d($recordData, 12);
|
$borderLines = self::getInt4d($recordData, 12);
|
||||||
|
|
||||||
// bit: 2-0; mask: 0x00000007; top line style
|
// bit: 2-0; mask: 0x00000007; top line style
|
||||||
$objStyle->getBorders()->getTop()->setBorderStyle(self::mapBorderStyle((0x00000007 & $borderLines) >> 0));
|
$objStyle->getBorders()->getTop()->setBorderStyle(Excel5\Style\Border::lookup((0x00000007 & $borderLines) >> 0));
|
||||||
|
|
||||||
// bit: 5-3; mask: 0x00000038; left line style
|
// bit: 5-3; mask: 0x00000038; left line style
|
||||||
$objStyle->getBorders()->getLeft()->setBorderStyle(self::mapBorderStyle((0x00000038 & $borderLines) >> 3));
|
$objStyle->getBorders()->getLeft()->setBorderStyle(Excel5\Style\Border::lookup((0x00000038 & $borderLines) >> 3));
|
||||||
|
|
||||||
// bit: 8-6; mask: 0x000001C0; right line style
|
// bit: 8-6; mask: 0x000001C0; right line style
|
||||||
$objStyle->getBorders()->getRight()->setBorderStyle(self::mapBorderStyle((0x000001C0 & $borderLines) >> 6));
|
$objStyle->getBorders()->getRight()->setBorderStyle(Excel5\Style\Border::lookup((0x000001C0 & $borderLines) >> 6));
|
||||||
|
|
||||||
// bit: 15-9; mask: 0x0000FE00; top line color index
|
// bit: 15-9; mask: 0x0000FE00; top line color index
|
||||||
$objStyle->getBorders()->getTop()->colorIndex = (0x0000FE00 & $borderLines) >> 9;
|
$objStyle->getBorders()->getTop()->colorIndex = (0x0000FE00 & $borderLines) >> 9;
|
||||||
|
@ -3914,7 +3914,7 @@ class Excel5 extends BaseReader implements IReader
|
||||||
&& (ord($recordData{13}) == 255)) {
|
&& (ord($recordData{13}) == 255)) {
|
||||||
// Error formula. Error code is in +2
|
// Error formula. Error code is in +2
|
||||||
$dataType = \PHPExcel\Cell\DataType::TYPE_ERROR;
|
$dataType = \PHPExcel\Cell\DataType::TYPE_ERROR;
|
||||||
$value = self::mapErrorCode(ord($recordData{8}));
|
$value = Excel5\ErrorCode::lookup(ord($recordData{8}));
|
||||||
} elseif ((ord($recordData{6}) == 3)
|
} elseif ((ord($recordData{6}) == 3)
|
||||||
&& (ord($recordData{12}) == 255)
|
&& (ord($recordData{12}) == 255)
|
||||||
&& (ord($recordData{13}) == 255)) {
|
&& (ord($recordData{13}) == 255)) {
|
||||||
|
@ -4061,7 +4061,7 @@ class Excel5 extends BaseReader implements IReader
|
||||||
$cell->setValueExplicit($value, \PHPExcel\Cell\DataType::TYPE_BOOL);
|
$cell->setValueExplicit($value, \PHPExcel\Cell\DataType::TYPE_BOOL);
|
||||||
break;
|
break;
|
||||||
case 1: // error type
|
case 1: // error type
|
||||||
$value = self::mapErrorCode($boolErr);
|
$value = Excel5\ErrorCode::lookup($boolErr);
|
||||||
|
|
||||||
// add cell value
|
// add cell value
|
||||||
$cell->setValueExplicit($value, \PHPExcel\Cell\DataType::TYPE_ERROR);
|
$cell->setValueExplicit($value, \PHPExcel\Cell\DataType::TYPE_ERROR);
|
||||||
|
@ -4922,7 +4922,7 @@ class Excel5 extends BaseReader implements IReader
|
||||||
case 0x14:
|
case 0x14:
|
||||||
// offset: 16; size: 2; color index for sheet tab
|
// offset: 16; size: 2; color index for sheet tab
|
||||||
$colorIndex = self::getInt2d($recordData, 16);
|
$colorIndex = self::getInt2d($recordData, 16);
|
||||||
$color = self::readColor($colorIndex, $this->palette, $this->version);
|
$color = Excel5\Color::map($colorIndex, $this->palette, $this->version);
|
||||||
$this->phpSheet->getTabColor()->setRGB($color['rgb']);
|
$this->phpSheet->getTabColor()->setRGB($color['rgb']);
|
||||||
break;
|
break;
|
||||||
case 0x28:
|
case 0x28:
|
||||||
|
@ -5689,7 +5689,7 @@ class Excel5 extends BaseReader implements IReader
|
||||||
// offset: 1; size: 1; error code
|
// offset: 1; size: 1; error code
|
||||||
$name = 'tErr';
|
$name = 'tErr';
|
||||||
$size = 2;
|
$size = 2;
|
||||||
$data = self::mapErrorCode(ord($formulaData[1]));
|
$data = Excel5\ErrorCode::lookup(ord($formulaData[1]));
|
||||||
break;
|
break;
|
||||||
case 0x1D: // boolean
|
case 0x1D: // boolean
|
||||||
// offset: 1; size: 1; 0 = false, 1 = true;
|
// offset: 1; size: 1; 0 = false, 1 = true;
|
||||||
|
@ -7258,7 +7258,7 @@ class Excel5 extends BaseReader implements IReader
|
||||||
break;
|
break;
|
||||||
case 0x10: // error code
|
case 0x10: // error code
|
||||||
// offset: 1; size: 1; error code
|
// offset: 1; size: 1; error code
|
||||||
$value = self::mapErrorCode(ord($valueData[1]));
|
$value = Excel5\ErrorCode::lookup(ord($valueData[1]));
|
||||||
$size = 9;
|
$size = 9;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -7574,213 +7574,6 @@ class Excel5 extends BaseReader implements IReader
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read color
|
|
||||||
*
|
|
||||||
* @param int $color Indexed color
|
|
||||||
* @param array $palette Color palette
|
|
||||||
* @return array RGB color value, example: array('rgb' => 'FF0000')
|
|
||||||
*/
|
|
||||||
private static function readColor($color, $palette, $version)
|
|
||||||
{
|
|
||||||
if ($color <= 0x07 || $color >= 0x40) {
|
|
||||||
// special built-in color
|
|
||||||
return self::mapBuiltInColor($color);
|
|
||||||
} elseif (isset($palette) && isset($palette[$color - 8])) {
|
|
||||||
// palette color, color index 0x08 maps to pallete index 0
|
|
||||||
return $palette[$color - 8];
|
|
||||||
} else {
|
|
||||||
// default color table
|
|
||||||
if ($version == self::XLS_BIFF8) {
|
|
||||||
return self::mapColor($color);
|
|
||||||
} else {
|
|
||||||
// BIFF5
|
|
||||||
return self::mapColorBIFF5($color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $color;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Map border style
|
|
||||||
* OpenOffice documentation: 2.5.11
|
|
||||||
*
|
|
||||||
* @param int $index
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get fill pattern from index
|
|
||||||
* OpenOffice documentation: 2.5.12
|
|
||||||
*
|
|
||||||
* @param int $index
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Map error code, e.g. '#N/A'
|
|
||||||
*
|
|
||||||
* @param int $subData
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private static function mapErrorCode($subData)
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Map built-in color to RGB value
|
|
||||||
*
|
|
||||||
* @param int $color Indexed color
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private static function mapBuiltInColor($color)
|
|
||||||
{
|
|
||||||
if (isset(Excel5\Color\BuiltIn::$map[$color])) {
|
|
||||||
return array('rgb' => Excel5\Color\BuiltIn::$map[$color]);
|
|
||||||
}
|
|
||||||
return array('rgb' => '000000');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Map color array from BIFF5 built-in color index
|
|
||||||
*
|
|
||||||
* @param int $color
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private static function mapColorBIFF5($color)
|
|
||||||
{
|
|
||||||
if (isset(Excel5\Color\BIFF5::$map[$color])) {
|
|
||||||
return array('rgb' => Excel5\Color\BIFF5::$map[$color]);
|
|
||||||
}
|
|
||||||
return array('rgb' => '000000');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Map color array from BIFF8 built-in color index
|
|
||||||
*
|
|
||||||
* @param int $color
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private static function mapColor($color)
|
|
||||||
{
|
|
||||||
if (isset(Excel5\Color\BIFF8::$map[$color])) {
|
|
||||||
return array('rgb' => Excel5\Color\BIFF8::$map[$color]);
|
|
||||||
}
|
|
||||||
return array('rgb' => '000000');
|
|
||||||
}
|
|
||||||
|
|
||||||
private function parseRichText($is = '')
|
private function parseRichText($is = '')
|
||||||
{
|
{
|
||||||
$value = new \PHPExcel\RichText();
|
$value = new \PHPExcel\RichText();
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PHPExcel\Reader\Excel5;
|
||||||
|
|
||||||
|
class Color
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Read color
|
||||||
|
*
|
||||||
|
* @param int $color Indexed color
|
||||||
|
* @param array $palette Color palette
|
||||||
|
* @return array RGB color value, example: array('rgb' => 'FF0000')
|
||||||
|
*/
|
||||||
|
public static function map($color, $palette, $version)
|
||||||
|
{
|
||||||
|
if ($color <= 0x07 || $color >= 0x40) {
|
||||||
|
// special built-in color
|
||||||
|
return Color\BuiltIn::lookup($color);
|
||||||
|
} elseif (isset($palette) && isset($palette[$color - 8])) {
|
||||||
|
// palette color, color index 0x08 maps to pallete index 0
|
||||||
|
return $palette[$color - 8];
|
||||||
|
} else {
|
||||||
|
// default color table
|
||||||
|
if ($version == \PHPExcel\Reader\Excel5::XLS_BIFF8) {
|
||||||
|
return Color\BIFF8::lookup($color);
|
||||||
|
} else {
|
||||||
|
// BIFF5
|
||||||
|
return Color\BIFF5::lookup($color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $color;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,34 +2,9 @@
|
||||||
|
|
||||||
namespace PHPExcel\Reader\Excel5\Color;
|
namespace PHPExcel\Reader\Excel5\Color;
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Reader_Excel5_Color_BIFF5
|
|
||||||
*
|
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package \PHPExcel\Reader\Excel5
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
|
||||||
* @version ##VERSION##, ##DATE##
|
|
||||||
*/
|
|
||||||
class BIFF5
|
class BIFF5
|
||||||
{
|
{
|
||||||
public static $map = array(
|
protected static $map = array(
|
||||||
0x08 => '000000',
|
0x08 => '000000',
|
||||||
0x09 => 'FFFFFF',
|
0x09 => 'FFFFFF',
|
||||||
0x0A => 'FF0000',
|
0x0A => 'FF0000',
|
||||||
|
@ -87,4 +62,18 @@ class BIFF5
|
||||||
0x3E => '4A3285',
|
0x3E => '4A3285',
|
||||||
0x3F => '424242',
|
0x3F => '424242',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map color array from BIFF5 built-in color index
|
||||||
|
*
|
||||||
|
* @param int $color
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function lookup($color)
|
||||||
|
{
|
||||||
|
if (isset(self::$map[$color])) {
|
||||||
|
return array('rgb' => self::$map[$color]);
|
||||||
|
}
|
||||||
|
return array('rgb' => '000000');
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -2,34 +2,9 @@
|
||||||
|
|
||||||
namespace PHPExcel\Reader\Excel5\Color;
|
namespace PHPExcel\Reader\Excel5\Color;
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Reader_Excel5_Color_BIFF8
|
|
||||||
*
|
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package \PHPExcel\Reader\Excel5
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
|
||||||
* @version ##VERSION##, ##DATE##
|
|
||||||
*/
|
|
||||||
class BIFF8
|
class BIFF8
|
||||||
{
|
{
|
||||||
public static $map = array(
|
protected static $map = array(
|
||||||
0x08 => '000000',
|
0x08 => '000000',
|
||||||
0x09 => 'FFFFFF',
|
0x09 => 'FFFFFF',
|
||||||
0x0A => 'FF0000',
|
0x0A => 'FF0000',
|
||||||
|
@ -87,4 +62,18 @@ class BIFF8
|
||||||
0x3E => '333399',
|
0x3E => '333399',
|
||||||
0x3F => '333333',
|
0x3F => '333333',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map color array from BIFF8 built-in color index
|
||||||
|
*
|
||||||
|
* @param int $color
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function lookup($color)
|
||||||
|
{
|
||||||
|
if (isset(self::$map[$color])) {
|
||||||
|
return array('rgb' => self::$map[$color]);
|
||||||
|
}
|
||||||
|
return array('rgb' => '000000');
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -2,34 +2,9 @@
|
||||||
|
|
||||||
namespace PHPExcel\Reader\Excel5\Color;
|
namespace PHPExcel\Reader\Excel5\Color;
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Reader_Excel5_Color_BuiltIn
|
|
||||||
*
|
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package \PHPExcel\Reader\Excel5
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
|
||||||
* @version ##VERSION##, ##DATE##
|
|
||||||
*/
|
|
||||||
class BuiltIn
|
class BuiltIn
|
||||||
{
|
{
|
||||||
public static $map = array(
|
protected static $map = array(
|
||||||
0x00 => '000000',
|
0x00 => '000000',
|
||||||
0x01 => 'FFFFFF',
|
0x01 => 'FFFFFF',
|
||||||
0x02 => 'FF0000',
|
0x02 => 'FF0000',
|
||||||
|
@ -41,4 +16,18 @@ class BuiltIn
|
||||||
0x40 => '000000', // system window text color
|
0x40 => '000000', // system window text color
|
||||||
0x41 => 'FFFFFF', // system window background color
|
0x41 => 'FFFFFF', // system window background color
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map built-in color to RGB value
|
||||||
|
*
|
||||||
|
* @param int $color Indexed color
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function lookup($color)
|
||||||
|
{
|
||||||
|
if (isset(self::$map[$color])) {
|
||||||
|
return array('rgb' => self::$map[$color]);
|
||||||
|
}
|
||||||
|
return array('rgb' => '000000');
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PHPExcel\Reader\Excel5;
|
||||||
|
|
||||||
|
class ErrorCode
|
||||||
|
{
|
||||||
|
protected static $map = array(
|
||||||
|
0x00 => '#NULL!',
|
||||||
|
0x07 => '#DIV/0!',
|
||||||
|
0x0F => '#VALUE!',
|
||||||
|
0x17 => '#REF!',
|
||||||
|
0x1D => '#NAME?',
|
||||||
|
0x24 => '#NUM!',
|
||||||
|
0x2A => '#N/A',
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map error code, e.g. '#N/A'
|
||||||
|
*
|
||||||
|
* @param int $code
|
||||||
|
* @return string|boolean
|
||||||
|
*/
|
||||||
|
public static function lookup($code)
|
||||||
|
{
|
||||||
|
if (isset(self::$map[$code])) {
|
||||||
|
return self::$map[$code];
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PHPExcel\Reader\Excel5\Style;
|
||||||
|
|
||||||
|
use \PHPExcel\Style\Border;
|
||||||
|
|
||||||
|
class Border
|
||||||
|
{
|
||||||
|
protected static $map = array(
|
||||||
|
0x00 => Border::BORDER_NONE,
|
||||||
|
0x01 => Border::BORDER_THIN,
|
||||||
|
0x02 => Border::BORDER_MEDIUM,
|
||||||
|
0x03 => Border::BORDER_DASHED,
|
||||||
|
0x04 => Border::BORDER_DOTTED,
|
||||||
|
0x05 => Border::BORDER_THICK,
|
||||||
|
0x06 => Border::BORDER_DOUBLE,
|
||||||
|
0x07 => Border::BORDER_HAIR,
|
||||||
|
0x08 => Border::BORDER_MEDIUMDASHED,
|
||||||
|
0x09 => Border::BORDER_DASHDOT,
|
||||||
|
0x0A => Border::BORDER_MEDIUMDASHDOT,
|
||||||
|
0x0B => Border::BORDER_DASHDOTDOT,
|
||||||
|
0x0C => Border::BORDER_MEDIUMDASHDOTDOT,
|
||||||
|
0x0D => Border::BORDER_SLANTDASHDOT,
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map border style
|
||||||
|
* OpenOffice documentation: 2.5.11
|
||||||
|
*
|
||||||
|
* @param int $index
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function lookup($index)
|
||||||
|
{
|
||||||
|
if (isset(self::$map[$index])) {
|
||||||
|
return self::$map[$index];
|
||||||
|
}
|
||||||
|
return Border::BORDER_NONE;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PHPExcel\Reader\Excel5\Style;
|
||||||
|
|
||||||
|
use \PHPExcel\Style\Fill;
|
||||||
|
|
||||||
|
class FillPattern
|
||||||
|
{
|
||||||
|
protected static $map = array(
|
||||||
|
0x00 => Fill::FILL_NONE,
|
||||||
|
0x01 => Fill::FILL_SOLID,
|
||||||
|
0x02 => Fill::FILL_PATTERN_MEDIUMGRAY,
|
||||||
|
0x03 => Fill::FILL_PATTERN_DARKGRAY,
|
||||||
|
0x04 => Fill::FILL_PATTERN_LIGHTGRAY,
|
||||||
|
0x05 => Fill::FILL_PATTERN_DARKHORIZONTAL,
|
||||||
|
0x06 => Fill::FILL_PATTERN_DARKVERTICAL,
|
||||||
|
0x07 => Fill::FILL_PATTERN_DARKDOWN,
|
||||||
|
0x08 => Fill::FILL_PATTERN_DARKUP,
|
||||||
|
0x09 => Fill::FILL_PATTERN_DARKGRID,
|
||||||
|
0x0A => Fill::FILL_PATTERN_DARKTRELLIS,
|
||||||
|
0x0B => Fill::FILL_PATTERN_LIGHTHORIZONTAL,
|
||||||
|
0x0C => Fill::FILL_PATTERN_LIGHTVERTICAL,
|
||||||
|
0x0D => Fill::FILL_PATTERN_LIGHTDOWN,
|
||||||
|
0x0E => Fill::FILL_PATTERN_LIGHTUP,
|
||||||
|
0x0F => Fill::FILL_PATTERN_LIGHTGRID,
|
||||||
|
0x10 => Fill::FILL_PATTERN_LIGHTTRELLIS,
|
||||||
|
0x11 => Fill::FILL_PATTERN_GRAY125,
|
||||||
|
0x12 => Fill::FILL_PATTERN_GRAY0625,
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get fill pattern from index
|
||||||
|
* OpenOffice documentation: 2.5.12
|
||||||
|
*
|
||||||
|
* @param int $index
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function lookup($index)
|
||||||
|
{
|
||||||
|
if (isset(self::$map[$index])) {
|
||||||
|
return self::$map[$index];
|
||||||
|
}
|
||||||
|
return Fill::FILL_NONE;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue