diff --git a/src/PhpSpreadsheet/Reader/Excel5.php b/src/PhpSpreadsheet/Reader/Excel5.php index a2b39829..75ad49b7 100644 --- a/src/PhpSpreadsheet/Reader/Excel5.php +++ b/src/PhpSpreadsheet/Reader/Excel5.php @@ -7745,284 +7745,40 @@ class Excel5 extends BaseReader implements IReader */ private static function mapBuiltInColor($color) { - switch ($color) { - case 0x00: - return array('rgb' => '000000'); - case 0x01: - return array('rgb' => 'FFFFFF'); - case 0x02: - return array('rgb' => 'FF0000'); - case 0x03: - return array('rgb' => '00FF00'); - case 0x04: - return array('rgb' => '0000FF'); - case 0x05: - return array('rgb' => 'FFFF00'); - case 0x06: - return array('rgb' => 'FF00FF'); - case 0x07: - return array('rgb' => '00FFFF'); - case 0x40: - return array('rgb' => '000000'); // system window text color - case 0x41: - return array('rgb' => 'FFFFFF'); // system window background color - default: - return array('rgb' => '000000'); + 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 $subData + * @param int $color * @return array */ - private static function mapColorBIFF5($subData) + private static function mapColorBIFF5($color) { - switch ($subData) { - case 0x08: - return array('rgb' => '000000'); - case 0x09: - return array('rgb' => 'FFFFFF'); - case 0x0A: - return array('rgb' => 'FF0000'); - case 0x0B: - return array('rgb' => '00FF00'); - case 0x0C: - return array('rgb' => '0000FF'); - case 0x0D: - return array('rgb' => 'FFFF00'); - case 0x0E: - return array('rgb' => 'FF00FF'); - case 0x0F: - return array('rgb' => '00FFFF'); - case 0x10: - return array('rgb' => '800000'); - case 0x11: - return array('rgb' => '008000'); - case 0x12: - return array('rgb' => '000080'); - case 0x13: - return array('rgb' => '808000'); - case 0x14: - return array('rgb' => '800080'); - case 0x15: - return array('rgb' => '008080'); - case 0x16: - return array('rgb' => 'C0C0C0'); - case 0x17: - return array('rgb' => '808080'); - case 0x18: - return array('rgb' => '8080FF'); - case 0x19: - return array('rgb' => '802060'); - case 0x1A: - return array('rgb' => 'FFFFC0'); - case 0x1B: - return array('rgb' => 'A0E0F0'); - case 0x1C: - return array('rgb' => '600080'); - case 0x1D: - return array('rgb' => 'FF8080'); - case 0x1E: - return array('rgb' => '0080C0'); - case 0x1F: - return array('rgb' => 'C0C0FF'); - case 0x20: - return array('rgb' => '000080'); - case 0x21: - return array('rgb' => 'FF00FF'); - case 0x22: - return array('rgb' => 'FFFF00'); - case 0x23: - return array('rgb' => '00FFFF'); - case 0x24: - return array('rgb' => '800080'); - case 0x25: - return array('rgb' => '800000'); - case 0x26: - return array('rgb' => '008080'); - case 0x27: - return array('rgb' => '0000FF'); - case 0x28: - return array('rgb' => '00CFFF'); - case 0x29: - return array('rgb' => '69FFFF'); - case 0x2A: - return array('rgb' => 'E0FFE0'); - case 0x2B: - return array('rgb' => 'FFFF80'); - case 0x2C: - return array('rgb' => 'A6CAF0'); - case 0x2D: - return array('rgb' => 'DD9CB3'); - case 0x2E: - return array('rgb' => 'B38FEE'); - case 0x2F: - return array('rgb' => 'E3E3E3'); - case 0x30: - return array('rgb' => '2A6FF9'); - case 0x31: - return array('rgb' => '3FB8CD'); - case 0x32: - return array('rgb' => '488436'); - case 0x33: - return array('rgb' => '958C41'); - case 0x34: - return array('rgb' => '8E5E42'); - case 0x35: - return array('rgb' => 'A0627A'); - case 0x36: - return array('rgb' => '624FAC'); - case 0x37: - return array('rgb' => '969696'); - case 0x38: - return array('rgb' => '1D2FBE'); - case 0x39: - return array('rgb' => '286676'); - case 0x3A: - return array('rgb' => '004500'); - case 0x3B: - return array('rgb' => '453E01'); - case 0x3C: - return array('rgb' => '6A2813'); - case 0x3D: - return array('rgb' => '85396A'); - case 0x3E: - return array('rgb' => '4A3285'); - case 0x3F: - return array('rgb' => '424242'); - default: - return array('rgb' => '000000'); + 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 $subData + * @param int $color * @return array */ - private static function mapColor($subData) + private static function mapColor($color) { - switch ($subData) { - case 0x08: - return array('rgb' => '000000'); - case 0x09: - return array('rgb' => 'FFFFFF'); - case 0x0A: - return array('rgb' => 'FF0000'); - case 0x0B: - return array('rgb' => '00FF00'); - case 0x0C: - return array('rgb' => '0000FF'); - case 0x0D: - return array('rgb' => 'FFFF00'); - case 0x0E: - return array('rgb' => 'FF00FF'); - case 0x0F: - return array('rgb' => '00FFFF'); - case 0x10: - return array('rgb' => '800000'); - case 0x11: - return array('rgb' => '008000'); - case 0x12: - return array('rgb' => '000080'); - case 0x13: - return array('rgb' => '808000'); - case 0x14: - return array('rgb' => '800080'); - case 0x15: - return array('rgb' => '008080'); - case 0x16: - return array('rgb' => 'C0C0C0'); - case 0x17: - return array('rgb' => '808080'); - case 0x18: - return array('rgb' => '9999FF'); - case 0x19: - return array('rgb' => '993366'); - case 0x1A: - return array('rgb' => 'FFFFCC'); - case 0x1B: - return array('rgb' => 'CCFFFF'); - case 0x1C: - return array('rgb' => '660066'); - case 0x1D: - return array('rgb' => 'FF8080'); - case 0x1E: - return array('rgb' => '0066CC'); - case 0x1F: - return array('rgb' => 'CCCCFF'); - case 0x20: - return array('rgb' => '000080'); - case 0x21: - return array('rgb' => 'FF00FF'); - case 0x22: - return array('rgb' => 'FFFF00'); - case 0x23: - return array('rgb' => '00FFFF'); - case 0x24: - return array('rgb' => '800080'); - case 0x25: - return array('rgb' => '800000'); - case 0x26: - return array('rgb' => '008080'); - case 0x27: - return array('rgb' => '0000FF'); - case 0x28: - return array('rgb' => '00CCFF'); - case 0x29: - return array('rgb' => 'CCFFFF'); - case 0x2A: - return array('rgb' => 'CCFFCC'); - case 0x2B: - return array('rgb' => 'FFFF99'); - case 0x2C: - return array('rgb' => '99CCFF'); - case 0x2D: - return array('rgb' => 'FF99CC'); - case 0x2E: - return array('rgb' => 'CC99FF'); - case 0x2F: - return array('rgb' => 'FFCC99'); - case 0x30: - return array('rgb' => '3366FF'); - case 0x31: - return array('rgb' => '33CCCC'); - case 0x32: - return array('rgb' => '99CC00'); - case 0x33: - return array('rgb' => 'FFCC00'); - case 0x34: - return array('rgb' => 'FF9900'); - case 0x35: - return array('rgb' => 'FF6600'); - case 0x36: - return array('rgb' => '666699'); - case 0x37: - return array('rgb' => '969696'); - case 0x38: - return array('rgb' => '003366'); - case 0x39: - return array('rgb' => '339966'); - case 0x3A: - return array('rgb' => '003300'); - case 0x3B: - return array('rgb' => '333300'); - case 0x3C: - return array('rgb' => '993300'); - case 0x3D: - return array('rgb' => '993366'); - case 0x3E: - return array('rgb' => '333399'); - case 0x3F: - return array('rgb' => '333333'); - default: - return array('rgb' => '000000'); + if (isset(Excel5\Color\BIFF8::$map[$color])) { + return array('rgb' => Excel5\Color\BIFF8::$map[$color]); } + return array('rgb' => '000000'); } private function parseRichText($is = '') diff --git a/src/PhpSpreadsheet/Reader/Excel5/Color/BIFF5.php b/src/PhpSpreadsheet/Reader/Excel5/Color/BIFF5.php new file mode 100644 index 00000000..63e997cf --- /dev/null +++ b/src/PhpSpreadsheet/Reader/Excel5/Color/BIFF5.php @@ -0,0 +1,90 @@ + '000000', + 0x09 => 'FFFFFF', + 0x0A => 'FF0000', + 0x0B => '00FF00', + 0x0C => '0000FF', + 0x0D => 'FFFF00', + 0x0E => 'FF00FF', + 0x0F => '00FFFF', + 0x10 => '800000', + 0x11 => '008000', + 0x12 => '000080', + 0x13 => '808000', + 0x14 => '800080', + 0x15 => '008080', + 0x16 => 'C0C0C0', + 0x17 => '808080', + 0x18 => '8080FF', + 0x19 => '802060', + 0x1A => 'FFFFC0', + 0x1B => 'A0E0F0', + 0x1C => '600080', + 0x1D => 'FF8080', + 0x1E => '0080C0', + 0x1F => 'C0C0FF', + 0x20 => '000080', + 0x21 => 'FF00FF', + 0x22 => 'FFFF00', + 0x23 => '00FFFF', + 0x24 => '800080', + 0x25 => '800000', + 0x26 => '008080', + 0x27 => '0000FF', + 0x28 => '00CFFF', + 0x29 => '69FFFF', + 0x2A => 'E0FFE0', + 0x2B => 'FFFF80', + 0x2C => 'A6CAF0', + 0x2D => 'DD9CB3', + 0x2E => 'B38FEE', + 0x2F => 'E3E3E3', + 0x30 => '2A6FF9', + 0x31 => '3FB8CD', + 0x32 => '488436', + 0x33 => '958C41', + 0x34 => '8E5E42', + 0x35 => 'A0627A', + 0x36 => '624FAC', + 0x37 => '969696', + 0x38 => '1D2FBE', + 0x39 => '286676', + 0x3A => '004500', + 0x3B => '453E01', + 0x3C => '6A2813', + 0x3D => '85396A', + 0x3E => '4A3285', + 0x3F => '424242', + ); +} \ No newline at end of file diff --git a/src/PhpSpreadsheet/Reader/Excel5/Color/BIFF8.php b/src/PhpSpreadsheet/Reader/Excel5/Color/BIFF8.php new file mode 100644 index 00000000..378e1dd9 --- /dev/null +++ b/src/PhpSpreadsheet/Reader/Excel5/Color/BIFF8.php @@ -0,0 +1,90 @@ + '000000', + 0x09 => 'FFFFFF', + 0x0A => 'FF0000', + 0x0B => '00FF00', + 0x0C => '0000FF', + 0x0D => 'FFFF00', + 0x0E => 'FF00FF', + 0x0F => '00FFFF', + 0x10 => '800000', + 0x11 => '008000', + 0x12 => '000080', + 0x13 => '808000', + 0x14 => '800080', + 0x15 => '008080', + 0x16 => 'C0C0C0', + 0x17 => '808080', + 0x18 => '9999FF', + 0x19 => '993366', + 0x1A => 'FFFFCC', + 0x1B => 'CCFFFF', + 0x1C => '660066', + 0x1D => 'FF8080', + 0x1E => '0066CC', + 0x1F => 'CCCCFF', + 0x20 => '000080', + 0x21 => 'FF00FF', + 0x22 => 'FFFF00', + 0x23 => '00FFFF', + 0x24 => '800080', + 0x25 => '800000', + 0x26 => '008080', + 0x27 => '0000FF', + 0x28 => '00CCFF', + 0x29 => 'CCFFFF', + 0x2A => 'CCFFCC', + 0x2B => 'FFFF99', + 0x2C => '99CCFF', + 0x2D => 'FF99CC', + 0x2E => 'CC99FF', + 0x2F => 'FFCC99', + 0x30 => '3366FF', + 0x31 => '33CCCC', + 0x32 => '99CC00', + 0x33 => 'FFCC00', + 0x34 => 'FF9900', + 0x35 => 'FF6600', + 0x36 => '666699', + 0x37 => '969696', + 0x38 => '003366', + 0x39 => '339966', + 0x3A => '003300', + 0x3B => '333300', + 0x3C => '993300', + 0x3D => '993366', + 0x3E => '333399', + 0x3F => '333333', + ); +} \ No newline at end of file diff --git a/src/PhpSpreadsheet/Reader/Excel5/Color/BuiltIn.php b/src/PhpSpreadsheet/Reader/Excel5/Color/BuiltIn.php new file mode 100644 index 00000000..c9df9c09 --- /dev/null +++ b/src/PhpSpreadsheet/Reader/Excel5/Color/BuiltIn.php @@ -0,0 +1,44 @@ + '000000', + 0x01 => 'FFFFFF', + 0x02 => 'FF0000', + 0x03 => '00FF00', + 0x04 => '0000FF', + 0x05 => 'FFFF00', + 0x06 => 'FF00FF', + 0x07 => '00FFFF', + 0x40 => '000000', // system window text color + 0x41 => 'FFFFFF', // system window background color + ); +} \ No newline at end of file