For God so loved the world, that He gave His only begotten Son, that all who believe in Him should not perish but have everlasting life
This commit is contained in:
commit
fd8b184a5f
521 files changed
+174650
No files matched your search
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class PHPExcel_Reader_Excel5_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 PHPExcel_Reader_Excel5_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 PHPExcel_Reader_Excel5_Color_BIFF8::lookup($color);
|
||||
} else {
|
||||
// BIFF5
|
||||
return PHPExcel_Reader_Excel5_Color_BIFF5::lookup($color);
|
||||
}
|
||||
}
|
||||
|
||||
return $color;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
class PHPExcel_Reader_Excel5_Color_BIFF5
|
||||
{
|
||||
protected static $map = array(
|
||||
0x08 => '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',
|
||||
);
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
class PHPExcel_Reader_Excel5_Color_BIFF8
|
||||
{
|
||||
protected static $map = array(
|
||||
0x08 => '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',
|
||||
);
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
class PHPExcel_Reader_Excel5_Color_BuiltIn
|
||||
{
|
||||
protected static $map = array(
|
||||
0x00 => '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
|
||||
);
|
||||
|
||||
/**
|
||||
* 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,28 @@
|
||||
<?php
|
||||
|
||||
class PHPExcel_Reader_Excel5_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
|
||||
*/
|
||||
public static function lookup($code)
|
||||
{
|
||||
if (isset(self::$map[$code])) {
|
||||
return self::$map[$code];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,669 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Excel5_Escher
|
||||
*
|
||||
* 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 PHPExcel_Reader_Excel5_Escher
|
||||
{
|
||||
const DGGCONTAINER = 0xF000;
|
||||
const BSTORECONTAINER = 0xF001;
|
||||
const DGCONTAINER = 0xF002;
|
||||
const SPGRCONTAINER = 0xF003;
|
||||
const SPCONTAINER = 0xF004;
|
||||
const DGG = 0xF006;
|
||||
const BSE = 0xF007;
|
||||
const DG = 0xF008;
|
||||
const SPGR = 0xF009;
|
||||
const SP = 0xF00A;
|
||||
const OPT = 0xF00B;
|
||||
const CLIENTTEXTBOX = 0xF00D;
|
||||
const CLIENTANCHOR = 0xF010;
|
||||
const CLIENTDATA = 0xF011;
|
||||
const BLIPJPEG = 0xF01D;
|
||||
const BLIPPNG = 0xF01E;
|
||||
const SPLITMENUCOLORS = 0xF11E;
|
||||
const TERTIARYOPT = 0xF122;
|
||||
|
||||
/**
|
||||
* Escher stream data (binary)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $data;
|
||||
|
||||
/**
|
||||
* Size in bytes of the Escher stream data
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $dataSize;
|
||||
|
||||
/**
|
||||
* Current position of stream pointer in Escher stream data
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $pos;
|
||||
|
||||
/**
|
||||
* The object to be returned by the reader. Modified during load.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
private $object;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_Excel5_Escher instance
|
||||
*
|
||||
* @param mixed $object
|
||||
*/
|
||||
public function __construct($object)
|
||||
{
|
||||
$this->object = $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Escher stream data. May be a partial Escher stream.
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
public function load($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
|
||||
// total byte size of Excel data (workbook global substream + sheet substreams)
|
||||
$this->dataSize = strlen($this->data);
|
||||
|
||||
$this->pos = 0;
|
||||
|
||||
// Parse Escher stream
|
||||
while ($this->pos < $this->dataSize) {
|
||||
// offset: 2; size: 2: Record Type
|
||||
$fbt = PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos + 2);
|
||||
|
||||
switch ($fbt) {
|
||||
case self::DGGCONTAINER:
|
||||
$this->readDggContainer();
|
||||
break;
|
||||
case self::DGG:
|
||||
$this->readDgg();
|
||||
break;
|
||||
case self::BSTORECONTAINER:
|
||||
$this->readBstoreContainer();
|
||||
break;
|
||||
case self::BSE:
|
||||
$this->readBSE();
|
||||
break;
|
||||
case self::BLIPJPEG:
|
||||
$this->readBlipJPEG();
|
||||
break;
|
||||
case self::BLIPPNG:
|
||||
$this->readBlipPNG();
|
||||
break;
|
||||
case self::OPT:
|
||||
$this->readOPT();
|
||||
break;
|
||||
case self::TERTIARYOPT:
|
||||
$this->readTertiaryOPT();
|
||||
break;
|
||||
case self::SPLITMENUCOLORS:
|
||||
$this->readSplitMenuColors();
|
||||
break;
|
||||
case self::DGCONTAINER:
|
||||
$this->readDgContainer();
|
||||
break;
|
||||
case self::DG:
|
||||
$this->readDg();
|
||||
break;
|
||||
case self::SPGRCONTAINER:
|
||||
$this->readSpgrContainer();
|
||||
break;
|
||||
case self::SPCONTAINER:
|
||||
$this->readSpContainer();
|
||||
break;
|
||||
case self::SPGR:
|
||||
$this->readSpgr();
|
||||
break;
|
||||
case self::SP:
|
||||
$this->readSp();
|
||||
break;
|
||||
case self::CLIENTTEXTBOX:
|
||||
$this->readClientTextbox();
|
||||
break;
|
||||
case self::CLIENTANCHOR:
|
||||
$this->readClientAnchor();
|
||||
break;
|
||||
case self::CLIENTDATA:
|
||||
$this->readClientData();
|
||||
break;
|
||||
default:
|
||||
$this->readDefault();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a generic record
|
||||
*/
|
||||
private function readDefault()
|
||||
{
|
||||
// offset 0; size: 2; recVer and recInstance
|
||||
$verInstance = PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos);
|
||||
|
||||
// offset: 2; size: 2: Record Type
|
||||
$fbt = PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos + 2);
|
||||
|
||||
// bit: 0-3; mask: 0x000F; recVer
|
||||
$recVer = (0x000F & $verInstance) >> 0;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read DggContainer record (Drawing Group Container)
|
||||
*/
|
||||
private function readDggContainer()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
// record is a container, read contents
|
||||
$dggContainer = new PHPExcel_Shared_Escher_DggContainer();
|
||||
$this->object->setDggContainer($dggContainer);
|
||||
$reader = new PHPExcel_Reader_Excel5_Escher($dggContainer);
|
||||
$reader->load($recordData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Dgg record (Drawing Group)
|
||||
*/
|
||||
private function readDgg()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read BstoreContainer record (Blip Store Container)
|
||||
*/
|
||||
private function readBstoreContainer()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
// record is a container, read contents
|
||||
$bstoreContainer = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer();
|
||||
$this->object->setBstoreContainer($bstoreContainer);
|
||||
$reader = new PHPExcel_Reader_Excel5_Escher($bstoreContainer);
|
||||
$reader->load($recordData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read BSE record
|
||||
*/
|
||||
private function readBSE()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
// add BSE to BstoreContainer
|
||||
$BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE();
|
||||
$this->object->addBSE($BSE);
|
||||
|
||||
$BSE->setBLIPType($recInstance);
|
||||
|
||||
// offset: 0; size: 1; btWin32 (MSOBLIPTYPE)
|
||||
$btWin32 = ord($recordData[0]);
|
||||
|
||||
// offset: 1; size: 1; btWin32 (MSOBLIPTYPE)
|
||||
$btMacOS = ord($recordData[1]);
|
||||
|
||||
// offset: 2; size: 16; MD4 digest
|
||||
$rgbUid = substr($recordData, 2, 16);
|
||||
|
||||
// offset: 18; size: 2; tag
|
||||
$tag = PHPExcel_Reader_Excel5::getInt2d($recordData, 18);
|
||||
|
||||
// offset: 20; size: 4; size of BLIP in bytes
|
||||
$size = PHPExcel_Reader_Excel5::getInt4d($recordData, 20);
|
||||
|
||||
// offset: 24; size: 4; number of references to this BLIP
|
||||
$cRef = PHPExcel_Reader_Excel5::getInt4d($recordData, 24);
|
||||
|
||||
// offset: 28; size: 4; MSOFO file offset
|
||||
$foDelay = PHPExcel_Reader_Excel5::getInt4d($recordData, 28);
|
||||
|
||||
// offset: 32; size: 1; unused1
|
||||
$unused1 = ord($recordData[32]);
|
||||
|
||||
// offset: 33; size: 1; size of nameData in bytes (including null terminator)
|
||||
$cbName = ord($recordData[33]);
|
||||
|
||||
// offset: 34; size: 1; unused2
|
||||
$unused2 = ord($recordData[34]);
|
||||
|
||||
// offset: 35; size: 1; unused3
|
||||
$unused3 = ord($recordData[35]);
|
||||
|
||||
// offset: 36; size: $cbName; nameData
|
||||
$nameData = substr($recordData, 36, $cbName);
|
||||
|
||||
// offset: 36 + $cbName, size: var; the BLIP data
|
||||
$blipData = substr($recordData, 36 + $cbName);
|
||||
|
||||
// record is a container, read contents
|
||||
$reader = new PHPExcel_Reader_Excel5_Escher($BSE);
|
||||
$reader->load($blipData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read BlipJPEG record. Holds raw JPEG image data
|
||||
*/
|
||||
private function readBlipJPEG()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
$pos = 0;
|
||||
|
||||
// offset: 0; size: 16; rgbUid1 (MD4 digest of)
|
||||
$rgbUid1 = substr($recordData, 0, 16);
|
||||
$pos += 16;
|
||||
|
||||
// offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
|
||||
if (in_array($recInstance, array(0x046B, 0x06E3))) {
|
||||
$rgbUid2 = substr($recordData, 16, 16);
|
||||
$pos += 16;
|
||||
}
|
||||
|
||||
// offset: var; size: 1; tag
|
||||
$tag = ord($recordData[$pos]);
|
||||
$pos += 1;
|
||||
|
||||
// offset: var; size: var; the raw image data
|
||||
$data = substr($recordData, $pos);
|
||||
|
||||
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
|
||||
$blip->setData($data);
|
||||
|
||||
$this->object->setBlip($blip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read BlipPNG record. Holds raw PNG image data
|
||||
*/
|
||||
private function readBlipPNG()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
$pos = 0;
|
||||
|
||||
// offset: 0; size: 16; rgbUid1 (MD4 digest of)
|
||||
$rgbUid1 = substr($recordData, 0, 16);
|
||||
$pos += 16;
|
||||
|
||||
// offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
|
||||
if ($recInstance == 0x06E1) {
|
||||
$rgbUid2 = substr($recordData, 16, 16);
|
||||
$pos += 16;
|
||||
}
|
||||
|
||||
// offset: var; size: 1; tag
|
||||
$tag = ord($recordData[$pos]);
|
||||
$pos += 1;
|
||||
|
||||
// offset: var; size: var; the raw image data
|
||||
$data = substr($recordData, $pos);
|
||||
|
||||
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
|
||||
$blip->setData($data);
|
||||
|
||||
$this->object->setBlip($blip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read OPT record. This record may occur within DggContainer record or SpContainer
|
||||
*/
|
||||
private function readOPT()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
$this->readOfficeArtRGFOPTE($recordData, $recInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read TertiaryOPT record
|
||||
*/
|
||||
private function readTertiaryOPT()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read SplitMenuColors record
|
||||
*/
|
||||
private function readSplitMenuColors()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read DgContainer record (Drawing Container)
|
||||
*/
|
||||
private function readDgContainer()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
// record is a container, read contents
|
||||
$dgContainer = new PHPExcel_Shared_Escher_DgContainer();
|
||||
$this->object->setDgContainer($dgContainer);
|
||||
$reader = new PHPExcel_Reader_Excel5_Escher($dgContainer);
|
||||
$escher = $reader->load($recordData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Dg record (Drawing)
|
||||
*/
|
||||
private function readDg()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read SpgrContainer record (Shape Group Container)
|
||||
*/
|
||||
private function readSpgrContainer()
|
||||
{
|
||||
// context is either context DgContainer or SpgrContainer
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
// record is a container, read contents
|
||||
$spgrContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer();
|
||||
|
||||
if ($this->object instanceof PHPExcel_Shared_Escher_DgContainer) {
|
||||
// DgContainer
|
||||
$this->object->setSpgrContainer($spgrContainer);
|
||||
} else {
|
||||
// SpgrContainer
|
||||
$this->object->addChild($spgrContainer);
|
||||
}
|
||||
|
||||
$reader = new PHPExcel_Reader_Excel5_Escher($spgrContainer);
|
||||
$escher = $reader->load($recordData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read SpContainer record (Shape Container)
|
||||
*/
|
||||
private function readSpContainer()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// add spContainer to spgrContainer
|
||||
$spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer();
|
||||
$this->object->addChild($spContainer);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
// record is a container, read contents
|
||||
$reader = new PHPExcel_Reader_Excel5_Escher($spContainer);
|
||||
$escher = $reader->load($recordData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Spgr record (Shape Group)
|
||||
*/
|
||||
private function readSpgr()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Sp record (Shape)
|
||||
*/
|
||||
private function readSp()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read ClientTextbox record
|
||||
*/
|
||||
private function readClientTextbox()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read ClientAnchor record. This record holds information about where the shape is anchored in worksheet
|
||||
*/
|
||||
private function readClientAnchor()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
// offset: 2; size: 2; upper-left corner column index (0-based)
|
||||
$c1 = PHPExcel_Reader_Excel5::getInt2d($recordData, 2);
|
||||
|
||||
// offset: 4; size: 2; upper-left corner horizontal offset in 1/1024 of column width
|
||||
$startOffsetX = PHPExcel_Reader_Excel5::getInt2d($recordData, 4);
|
||||
|
||||
// offset: 6; size: 2; upper-left corner row index (0-based)
|
||||
$r1 = PHPExcel_Reader_Excel5::getInt2d($recordData, 6);
|
||||
|
||||
// offset: 8; size: 2; upper-left corner vertical offset in 1/256 of row height
|
||||
$startOffsetY = PHPExcel_Reader_Excel5::getInt2d($recordData, 8);
|
||||
|
||||
// offset: 10; size: 2; bottom-right corner column index (0-based)
|
||||
$c2 = PHPExcel_Reader_Excel5::getInt2d($recordData, 10);
|
||||
|
||||
// offset: 12; size: 2; bottom-right corner horizontal offset in 1/1024 of column width
|
||||
$endOffsetX = PHPExcel_Reader_Excel5::getInt2d($recordData, 12);
|
||||
|
||||
// offset: 14; size: 2; bottom-right corner row index (0-based)
|
||||
$r2 = PHPExcel_Reader_Excel5::getInt2d($recordData, 14);
|
||||
|
||||
// offset: 16; size: 2; bottom-right corner vertical offset in 1/256 of row height
|
||||
$endOffsetY = PHPExcel_Reader_Excel5::getInt2d($recordData, 16);
|
||||
|
||||
// set the start coordinates
|
||||
$this->object->setStartCoordinates(PHPExcel_Cell::stringFromColumnIndex($c1) . ($r1 + 1));
|
||||
|
||||
// set the start offsetX
|
||||
$this->object->setStartOffsetX($startOffsetX);
|
||||
|
||||
// set the start offsetY
|
||||
$this->object->setStartOffsetY($startOffsetY);
|
||||
|
||||
// set the end coordinates
|
||||
$this->object->setEndCoordinates(PHPExcel_Cell::stringFromColumnIndex($c2) . ($r2 + 1));
|
||||
|
||||
// set the end offsetX
|
||||
$this->object->setEndOffsetX($endOffsetX);
|
||||
|
||||
// set the end offsetY
|
||||
$this->object->setEndOffsetY($endOffsetY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read ClientData record
|
||||
*/
|
||||
private function readClientData()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read OfficeArtRGFOPTE table of property-value pairs
|
||||
*
|
||||
* @param string $data Binary data
|
||||
* @param int $n Number of properties
|
||||
*/
|
||||
private function readOfficeArtRGFOPTE($data, $n)
|
||||
{
|
||||
$splicedComplexData = substr($data, 6 * $n);
|
||||
|
||||
// loop through property-value pairs
|
||||
for ($i = 0; $i < $n; ++$i) {
|
||||
// read 6 bytes at a time
|
||||
$fopte = substr($data, 6 * $i, 6);
|
||||
|
||||
// offset: 0; size: 2; opid
|
||||
$opid = PHPExcel_Reader_Excel5::getInt2d($fopte, 0);
|
||||
|
||||
// bit: 0-13; mask: 0x3FFF; opid.opid
|
||||
$opidOpid = (0x3FFF & $opid) >> 0;
|
||||
|
||||
// bit: 14; mask 0x4000; 1 = value in op field is BLIP identifier
|
||||
$opidFBid = (0x4000 & $opid) >> 14;
|
||||
|
||||
// bit: 15; mask 0x8000; 1 = this is a complex property, op field specifies size of complex data
|
||||
$opidFComplex = (0x8000 & $opid) >> 15;
|
||||
|
||||
// offset: 2; size: 4; the value for this property
|
||||
$op = PHPExcel_Reader_Excel5::getInt4d($fopte, 2);
|
||||
|
||||
if ($opidFComplex) {
|
||||
$complexData = substr($splicedComplexData, 0, $op);
|
||||
$splicedComplexData = substr($splicedComplexData, $op);
|
||||
|
||||
// we store string value with complex data
|
||||
$value = $complexData;
|
||||
} else {
|
||||
// we store integer value
|
||||
$value = $op;
|
||||
}
|
||||
|
||||
$this->object->setOPT($opidOpid, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,669 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Excel5_Escher
|
||||
*
|
||||
* 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 PHPExcel_Reader_Excel5_Escher
|
||||
{
|
||||
const DGGCONTAINER = 0xF000;
|
||||
const BSTORECONTAINER = 0xF001;
|
||||
const DGCONTAINER = 0xF002;
|
||||
const SPGRCONTAINER = 0xF003;
|
||||
const SPCONTAINER = 0xF004;
|
||||
const DGG = 0xF006;
|
||||
const BSE = 0xF007;
|
||||
const DG = 0xF008;
|
||||
const SPGR = 0xF009;
|
||||
const SP = 0xF00A;
|
||||
const OPT = 0xF00B;
|
||||
const CLIENTTEXTBOX = 0xF00D;
|
||||
const CLIENTANCHOR = 0xF010;
|
||||
const CLIENTDATA = 0xF011;
|
||||
const BLIPJPEG = 0xF01D;
|
||||
const BLIPPNG = 0xF01E;
|
||||
const SPLITMENUCOLORS = 0xF11E;
|
||||
const TERTIARYOPT = 0xF122;
|
||||
|
||||
/**
|
||||
* Escher stream data (binary)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $data;
|
||||
|
||||
/**
|
||||
* Size in bytes of the Escher stream data
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $dataSize;
|
||||
|
||||
/**
|
||||
* Current position of stream pointer in Escher stream data
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $pos;
|
||||
|
||||
/**
|
||||
* The object to be returned by the reader. Modified during load.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
private $object;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_Excel5_Escher instance
|
||||
*
|
||||
* @param mixed $object
|
||||
*/
|
||||
public function __construct($object)
|
||||
{
|
||||
$this->object = $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Escher stream data. May be a partial Escher stream.
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
public function load($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
|
||||
// total byte size of Excel data (workbook global substream + sheet substreams)
|
||||
$this->dataSize = strlen($this->data);
|
||||
|
||||
$this->pos = 0;
|
||||
|
||||
// Parse Escher stream
|
||||
while ($this->pos < $this->dataSize) {
|
||||
// offset: 2; size: 2: Record Type
|
||||
$fbt = PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos + 2);
|
||||
|
||||
switch ($fbt) {
|
||||
case self::DGGCONTAINER:
|
||||
$this->readDggContainer();
|
||||
break;
|
||||
case self::DGG:
|
||||
$this->readDgg();
|
||||
break;
|
||||
case self::BSTORECONTAINER:
|
||||
$this->readBstoreContainer();
|
||||
break;
|
||||
case self::BSE:
|
||||
$this->readBSE();
|
||||
break;
|
||||
case self::BLIPJPEG:
|
||||
$this->readBlipJPEG();
|
||||
break;
|
||||
case self::BLIPPNG:
|
||||
$this->readBlipPNG();
|
||||
break;
|
||||
case self::OPT:
|
||||
$this->readOPT();
|
||||
break;
|
||||
case self::TERTIARYOPT:
|
||||
$this->readTertiaryOPT();
|
||||
break;
|
||||
case self::SPLITMENUCOLORS:
|
||||
$this->readSplitMenuColors();
|
||||
break;
|
||||
case self::DGCONTAINER:
|
||||
$this->readDgContainer();
|
||||
break;
|
||||
case self::DG:
|
||||
$this->readDg();
|
||||
break;
|
||||
case self::SPGRCONTAINER:
|
||||
$this->readSpgrContainer();
|
||||
break;
|
||||
case self::SPCONTAINER:
|
||||
$this->readSpContainer();
|
||||
break;
|
||||
case self::SPGR:
|
||||
$this->readSpgr();
|
||||
break;
|
||||
case self::SP:
|
||||
$this->readSp();
|
||||
break;
|
||||
case self::CLIENTTEXTBOX:
|
||||
$this->readClientTextbox();
|
||||
break;
|
||||
case self::CLIENTANCHOR:
|
||||
$this->readClientAnchor();
|
||||
break;
|
||||
case self::CLIENTDATA:
|
||||
$this->readClientData();
|
||||
break;
|
||||
default:
|
||||
$this->readDefault();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a generic record
|
||||
*/
|
||||
private function readDefault()
|
||||
{
|
||||
// offset 0; size: 2; recVer and recInstance
|
||||
$verInstance = PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos);
|
||||
|
||||
// offset: 2; size: 2: Record Type
|
||||
$fbt = PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos + 2);
|
||||
|
||||
// bit: 0-3; mask: 0x000F; recVer
|
||||
$recVer = (0x000F & $verInstance) >> 0;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read DggContainer record (Drawing Group Container)
|
||||
*/
|
||||
private function readDggContainer()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
// record is a container, read contents
|
||||
$dggContainer = new PHPExcel_Shared_Escher_DggContainer();
|
||||
$this->object->setDggContainer($dggContainer);
|
||||
$reader = new PHPExcel_Reader_Excel5_Escher($dggContainer);
|
||||
$reader->load($recordData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Dgg record (Drawing Group)
|
||||
*/
|
||||
private function readDgg()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read BstoreContainer record (Blip Store Container)
|
||||
*/
|
||||
private function readBstoreContainer()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
// record is a container, read contents
|
||||
$bstoreContainer = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer();
|
||||
$this->object->setBstoreContainer($bstoreContainer);
|
||||
$reader = new PHPExcel_Reader_Excel5_Escher($bstoreContainer);
|
||||
$reader->load($recordData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read BSE record
|
||||
*/
|
||||
private function readBSE()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
// add BSE to BstoreContainer
|
||||
$BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE();
|
||||
$this->object->addBSE($BSE);
|
||||
|
||||
$BSE->setBLIPType($recInstance);
|
||||
|
||||
// offset: 0; size: 1; btWin32 (MSOBLIPTYPE)
|
||||
$btWin32 = ord($recordData[0]);
|
||||
|
||||
// offset: 1; size: 1; btWin32 (MSOBLIPTYPE)
|
||||
$btMacOS = ord($recordData[1]);
|
||||
|
||||
// offset: 2; size: 16; MD4 digest
|
||||
$rgbUid = substr($recordData, 2, 16);
|
||||
|
||||
// offset: 18; size: 2; tag
|
||||
$tag = PHPExcel_Reader_Excel5::getInt2d($recordData, 18);
|
||||
|
||||
// offset: 20; size: 4; size of BLIP in bytes
|
||||
$size = PHPExcel_Reader_Excel5::getInt4d($recordData, 20);
|
||||
|
||||
// offset: 24; size: 4; number of references to this BLIP
|
||||
$cRef = PHPExcel_Reader_Excel5::getInt4d($recordData, 24);
|
||||
|
||||
// offset: 28; size: 4; MSOFO file offset
|
||||
$foDelay = PHPExcel_Reader_Excel5::getInt4d($recordData, 28);
|
||||
|
||||
// offset: 32; size: 1; unused1
|
||||
$unused1 = ord($recordData{32});
|
||||
|
||||
// offset: 33; size: 1; size of nameData in bytes (including null terminator)
|
||||
$cbName = ord($recordData{33});
|
||||
|
||||
// offset: 34; size: 1; unused2
|
||||
$unused2 = ord($recordData{34});
|
||||
|
||||
// offset: 35; size: 1; unused3
|
||||
$unused3 = ord($recordData{35});
|
||||
|
||||
// offset: 36; size: $cbName; nameData
|
||||
$nameData = substr($recordData, 36, $cbName);
|
||||
|
||||
// offset: 36 + $cbName, size: var; the BLIP data
|
||||
$blipData = substr($recordData, 36 + $cbName);
|
||||
|
||||
// record is a container, read contents
|
||||
$reader = new PHPExcel_Reader_Excel5_Escher($BSE);
|
||||
$reader->load($blipData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read BlipJPEG record. Holds raw JPEG image data
|
||||
*/
|
||||
private function readBlipJPEG()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
$pos = 0;
|
||||
|
||||
// offset: 0; size: 16; rgbUid1 (MD4 digest of)
|
||||
$rgbUid1 = substr($recordData, 0, 16);
|
||||
$pos += 16;
|
||||
|
||||
// offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
|
||||
if (in_array($recInstance, array(0x046B, 0x06E3))) {
|
||||
$rgbUid2 = substr($recordData, 16, 16);
|
||||
$pos += 16;
|
||||
}
|
||||
|
||||
// offset: var; size: 1; tag
|
||||
$tag = ord($recordData{$pos});
|
||||
$pos += 1;
|
||||
|
||||
// offset: var; size: var; the raw image data
|
||||
$data = substr($recordData, $pos);
|
||||
|
||||
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
|
||||
$blip->setData($data);
|
||||
|
||||
$this->object->setBlip($blip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read BlipPNG record. Holds raw PNG image data
|
||||
*/
|
||||
private function readBlipPNG()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
$pos = 0;
|
||||
|
||||
// offset: 0; size: 16; rgbUid1 (MD4 digest of)
|
||||
$rgbUid1 = substr($recordData, 0, 16);
|
||||
$pos += 16;
|
||||
|
||||
// offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
|
||||
if ($recInstance == 0x06E1) {
|
||||
$rgbUid2 = substr($recordData, 16, 16);
|
||||
$pos += 16;
|
||||
}
|
||||
|
||||
// offset: var; size: 1; tag
|
||||
$tag = ord($recordData{$pos});
|
||||
$pos += 1;
|
||||
|
||||
// offset: var; size: var; the raw image data
|
||||
$data = substr($recordData, $pos);
|
||||
|
||||
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
|
||||
$blip->setData($data);
|
||||
|
||||
$this->object->setBlip($blip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read OPT record. This record may occur within DggContainer record or SpContainer
|
||||
*/
|
||||
private function readOPT()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
$this->readOfficeArtRGFOPTE($recordData, $recInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read TertiaryOPT record
|
||||
*/
|
||||
private function readTertiaryOPT()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read SplitMenuColors record
|
||||
*/
|
||||
private function readSplitMenuColors()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read DgContainer record (Drawing Container)
|
||||
*/
|
||||
private function readDgContainer()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
// record is a container, read contents
|
||||
$dgContainer = new PHPExcel_Shared_Escher_DgContainer();
|
||||
$this->object->setDgContainer($dgContainer);
|
||||
$reader = new PHPExcel_Reader_Excel5_Escher($dgContainer);
|
||||
$escher = $reader->load($recordData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Dg record (Drawing)
|
||||
*/
|
||||
private function readDg()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read SpgrContainer record (Shape Group Container)
|
||||
*/
|
||||
private function readSpgrContainer()
|
||||
{
|
||||
// context is either context DgContainer or SpgrContainer
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
// record is a container, read contents
|
||||
$spgrContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer();
|
||||
|
||||
if ($this->object instanceof PHPExcel_Shared_Escher_DgContainer) {
|
||||
// DgContainer
|
||||
$this->object->setSpgrContainer($spgrContainer);
|
||||
} else {
|
||||
// SpgrContainer
|
||||
$this->object->addChild($spgrContainer);
|
||||
}
|
||||
|
||||
$reader = new PHPExcel_Reader_Excel5_Escher($spgrContainer);
|
||||
$escher = $reader->load($recordData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read SpContainer record (Shape Container)
|
||||
*/
|
||||
private function readSpContainer()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// add spContainer to spgrContainer
|
||||
$spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer();
|
||||
$this->object->addChild($spContainer);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
// record is a container, read contents
|
||||
$reader = new PHPExcel_Reader_Excel5_Escher($spContainer);
|
||||
$escher = $reader->load($recordData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Spgr record (Shape Group)
|
||||
*/
|
||||
private function readSpgr()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Sp record (Shape)
|
||||
*/
|
||||
private function readSp()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read ClientTextbox record
|
||||
*/
|
||||
private function readClientTextbox()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
|
||||
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read ClientAnchor record. This record holds information about where the shape is anchored in worksheet
|
||||
*/
|
||||
private function readClientAnchor()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
|
||||
// offset: 2; size: 2; upper-left corner column index (0-based)
|
||||
$c1 = PHPExcel_Reader_Excel5::getInt2d($recordData, 2);
|
||||
|
||||
// offset: 4; size: 2; upper-left corner horizontal offset in 1/1024 of column width
|
||||
$startOffsetX = PHPExcel_Reader_Excel5::getInt2d($recordData, 4);
|
||||
|
||||
// offset: 6; size: 2; upper-left corner row index (0-based)
|
||||
$r1 = PHPExcel_Reader_Excel5::getInt2d($recordData, 6);
|
||||
|
||||
// offset: 8; size: 2; upper-left corner vertical offset in 1/256 of row height
|
||||
$startOffsetY = PHPExcel_Reader_Excel5::getInt2d($recordData, 8);
|
||||
|
||||
// offset: 10; size: 2; bottom-right corner column index (0-based)
|
||||
$c2 = PHPExcel_Reader_Excel5::getInt2d($recordData, 10);
|
||||
|
||||
// offset: 12; size: 2; bottom-right corner horizontal offset in 1/1024 of column width
|
||||
$endOffsetX = PHPExcel_Reader_Excel5::getInt2d($recordData, 12);
|
||||
|
||||
// offset: 14; size: 2; bottom-right corner row index (0-based)
|
||||
$r2 = PHPExcel_Reader_Excel5::getInt2d($recordData, 14);
|
||||
|
||||
// offset: 16; size: 2; bottom-right corner vertical offset in 1/256 of row height
|
||||
$endOffsetY = PHPExcel_Reader_Excel5::getInt2d($recordData, 16);
|
||||
|
||||
// set the start coordinates
|
||||
$this->object->setStartCoordinates(PHPExcel_Cell::stringFromColumnIndex($c1) . ($r1 + 1));
|
||||
|
||||
// set the start offsetX
|
||||
$this->object->setStartOffsetX($startOffsetX);
|
||||
|
||||
// set the start offsetY
|
||||
$this->object->setStartOffsetY($startOffsetY);
|
||||
|
||||
// set the end coordinates
|
||||
$this->object->setEndCoordinates(PHPExcel_Cell::stringFromColumnIndex($c2) . ($r2 + 1));
|
||||
|
||||
// set the end offsetX
|
||||
$this->object->setEndOffsetX($endOffsetX);
|
||||
|
||||
// set the end offsetY
|
||||
$this->object->setEndOffsetY($endOffsetY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read ClientData record
|
||||
*/
|
||||
private function readClientData()
|
||||
{
|
||||
$length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
|
||||
$recordData = substr($this->data, $this->pos + 8, $length);
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->pos += 8 + $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read OfficeArtRGFOPTE table of property-value pairs
|
||||
*
|
||||
* @param string $data Binary data
|
||||
* @param int $n Number of properties
|
||||
*/
|
||||
private function readOfficeArtRGFOPTE($data, $n)
|
||||
{
|
||||
$splicedComplexData = substr($data, 6 * $n);
|
||||
|
||||
// loop through property-value pairs
|
||||
for ($i = 0; $i < $n; ++$i) {
|
||||
// read 6 bytes at a time
|
||||
$fopte = substr($data, 6 * $i, 6);
|
||||
|
||||
// offset: 0; size: 2; opid
|
||||
$opid = PHPExcel_Reader_Excel5::getInt2d($fopte, 0);
|
||||
|
||||
// bit: 0-13; mask: 0x3FFF; opid.opid
|
||||
$opidOpid = (0x3FFF & $opid) >> 0;
|
||||
|
||||
// bit: 14; mask 0x4000; 1 = value in op field is BLIP identifier
|
||||
$opidFBid = (0x4000 & $opid) >> 14;
|
||||
|
||||
// bit: 15; mask 0x8000; 1 = this is a complex property, op field specifies size of complex data
|
||||
$opidFComplex = (0x8000 & $opid) >> 15;
|
||||
|
||||
// offset: 2; size: 4; the value for this property
|
||||
$op = PHPExcel_Reader_Excel5::getInt4d($fopte, 2);
|
||||
|
||||
if ($opidFComplex) {
|
||||
$complexData = substr($splicedComplexData, 0, $op);
|
||||
$splicedComplexData = substr($splicedComplexData, $op);
|
||||
|
||||
// we store string value with complex data
|
||||
$value = $complexData;
|
||||
} else {
|
||||
// we store integer value
|
||||
$value = $op;
|
||||
}
|
||||
|
||||
$this->object->setOPT($opidOpid, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Excel5_MD5
|
||||
*
|
||||
* 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 PHPExcel_Reader_Excel5_MD5
|
||||
{
|
||||
// Context
|
||||
private $a;
|
||||
private $b;
|
||||
private $c;
|
||||
private $d;
|
||||
|
||||
/**
|
||||
* MD5 stream constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the MD5 stream context
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->a = 0x67452301;
|
||||
$this->b = 0xEFCDAB89;
|
||||
$this->c = 0x98BADCFE;
|
||||
$this->d = 0x10325476;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get MD5 stream context
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContext()
|
||||
{
|
||||
$s = '';
|
||||
foreach (array('a', 'b', 'c', 'd') as $i) {
|
||||
$v = $this->{$i};
|
||||
$s .= chr($v & 0xff);
|
||||
$s .= chr(($v >> 8) & 0xff);
|
||||
$s .= chr(($v >> 16) & 0xff);
|
||||
$s .= chr(($v >> 24) & 0xff);
|
||||
}
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add data to context
|
||||
*
|
||||
* @param string $data Data to add
|
||||
*/
|
||||
public function add($data)
|
||||
{
|
||||
$words = array_values(unpack('V16', $data));
|
||||
|
||||
$A = $this->a;
|
||||
$B = $this->b;
|
||||
$C = $this->c;
|
||||
$D = $this->d;
|
||||
|
||||
$F = array('PHPExcel_Reader_Excel5_MD5','f');
|
||||
$G = array('PHPExcel_Reader_Excel5_MD5','g');
|
||||
$H = array('PHPExcel_Reader_Excel5_MD5','h');
|
||||
$I = array('PHPExcel_Reader_Excel5_MD5','i');
|
||||
|
||||
/* ROUND 1 */
|
||||
self::step($F, $A, $B, $C, $D, $words[0], 7, 0xd76aa478);
|
||||
self::step($F, $D, $A, $B, $C, $words[1], 12, 0xe8c7b756);
|
||||
self::step($F, $C, $D, $A, $B, $words[2], 17, 0x242070db);
|
||||
self::step($F, $B, $C, $D, $A, $words[3], 22, 0xc1bdceee);
|
||||
self::step($F, $A, $B, $C, $D, $words[4], 7, 0xf57c0faf);
|
||||
self::step($F, $D, $A, $B, $C, $words[5], 12, 0x4787c62a);
|
||||
self::step($F, $C, $D, $A, $B, $words[6], 17, 0xa8304613);
|
||||
self::step($F, $B, $C, $D, $A, $words[7], 22, 0xfd469501);
|
||||
self::step($F, $A, $B, $C, $D, $words[8], 7, 0x698098d8);
|
||||
self::step($F, $D, $A, $B, $C, $words[9], 12, 0x8b44f7af);
|
||||
self::step($F, $C, $D, $A, $B, $words[10], 17, 0xffff5bb1);
|
||||
self::step($F, $B, $C, $D, $A, $words[11], 22, 0x895cd7be);
|
||||
self::step($F, $A, $B, $C, $D, $words[12], 7, 0x6b901122);
|
||||
self::step($F, $D, $A, $B, $C, $words[13], 12, 0xfd987193);
|
||||
self::step($F, $C, $D, $A, $B, $words[14], 17, 0xa679438e);
|
||||
self::step($F, $B, $C, $D, $A, $words[15], 22, 0x49b40821);
|
||||
|
||||
/* ROUND 2 */
|
||||
self::step($G, $A, $B, $C, $D, $words[1], 5, 0xf61e2562);
|
||||
self::step($G, $D, $A, $B, $C, $words[6], 9, 0xc040b340);
|
||||
self::step($G, $C, $D, $A, $B, $words[11], 14, 0x265e5a51);
|
||||
self::step($G, $B, $C, $D, $A, $words[0], 20, 0xe9b6c7aa);
|
||||
self::step($G, $A, $B, $C, $D, $words[5], 5, 0xd62f105d);
|
||||
self::step($G, $D, $A, $B, $C, $words[10], 9, 0x02441453);
|
||||
self::step($G, $C, $D, $A, $B, $words[15], 14, 0xd8a1e681);
|
||||
self::step($G, $B, $C, $D, $A, $words[4], 20, 0xe7d3fbc8);
|
||||
self::step($G, $A, $B, $C, $D, $words[9], 5, 0x21e1cde6);
|
||||
self::step($G, $D, $A, $B, $C, $words[14], 9, 0xc33707d6);
|
||||
self::step($G, $C, $D, $A, $B, $words[3], 14, 0xf4d50d87);
|
||||
self::step($G, $B, $C, $D, $A, $words[8], 20, 0x455a14ed);
|
||||
self::step($G, $A, $B, $C, $D, $words[13], 5, 0xa9e3e905);
|
||||
self::step($G, $D, $A, $B, $C, $words[2], 9, 0xfcefa3f8);
|
||||
self::step($G, $C, $D, $A, $B, $words[7], 14, 0x676f02d9);
|
||||
self::step($G, $B, $C, $D, $A, $words[12], 20, 0x8d2a4c8a);
|
||||
|
||||
/* ROUND 3 */
|
||||
self::step($H, $A, $B, $C, $D, $words[5], 4, 0xfffa3942);
|
||||
self::step($H, $D, $A, $B, $C, $words[8], 11, 0x8771f681);
|
||||
self::step($H, $C, $D, $A, $B, $words[11], 16, 0x6d9d6122);
|
||||
self::step($H, $B, $C, $D, $A, $words[14], 23, 0xfde5380c);
|
||||
self::step($H, $A, $B, $C, $D, $words[1], 4, 0xa4beea44);
|
||||
self::step($H, $D, $A, $B, $C, $words[4], 11, 0x4bdecfa9);
|
||||
self::step($H, $C, $D, $A, $B, $words[7], 16, 0xf6bb4b60);
|
||||
self::step($H, $B, $C, $D, $A, $words[10], 23, 0xbebfbc70);
|
||||
self::step($H, $A, $B, $C, $D, $words[13], 4, 0x289b7ec6);
|
||||
self::step($H, $D, $A, $B, $C, $words[0], 11, 0xeaa127fa);
|
||||
self::step($H, $C, $D, $A, $B, $words[3], 16, 0xd4ef3085);
|
||||
self::step($H, $B, $C, $D, $A, $words[6], 23, 0x04881d05);
|
||||
self::step($H, $A, $B, $C, $D, $words[9], 4, 0xd9d4d039);
|
||||
self::step($H, $D, $A, $B, $C, $words[12], 11, 0xe6db99e5);
|
||||
self::step($H, $C, $D, $A, $B, $words[15], 16, 0x1fa27cf8);
|
||||
self::step($H, $B, $C, $D, $A, $words[2], 23, 0xc4ac5665);
|
||||
|
||||
/* ROUND 4 */
|
||||
self::step($I, $A, $B, $C, $D, $words[0], 6, 0xf4292244);
|
||||
self::step($I, $D, $A, $B, $C, $words[7], 10, 0x432aff97);
|
||||
self::step($I, $C, $D, $A, $B, $words[14], 15, 0xab9423a7);
|
||||
self::step($I, $B, $C, $D, $A, $words[5], 21, 0xfc93a039);
|
||||
self::step($I, $A, $B, $C, $D, $words[12], 6, 0x655b59c3);
|
||||
self::step($I, $D, $A, $B, $C, $words[3], 10, 0x8f0ccc92);
|
||||
self::step($I, $C, $D, $A, $B, $words[10], 15, 0xffeff47d);
|
||||
self::step($I, $B, $C, $D, $A, $words[1], 21, 0x85845dd1);
|
||||
self::step($I, $A, $B, $C, $D, $words[8], 6, 0x6fa87e4f);
|
||||
self::step($I, $D, $A, $B, $C, $words[15], 10, 0xfe2ce6e0);
|
||||
self::step($I, $C, $D, $A, $B, $words[6], 15, 0xa3014314);
|
||||
self::step($I, $B, $C, $D, $A, $words[13], 21, 0x4e0811a1);
|
||||
self::step($I, $A, $B, $C, $D, $words[4], 6, 0xf7537e82);
|
||||
self::step($I, $D, $A, $B, $C, $words[11], 10, 0xbd3af235);
|
||||
self::step($I, $C, $D, $A, $B, $words[2], 15, 0x2ad7d2bb);
|
||||
self::step($I, $B, $C, $D, $A, $words[9], 21, 0xeb86d391);
|
||||
|
||||
$this->a = ($this->a + $A) & 0xffffffff;
|
||||
$this->b = ($this->b + $B) & 0xffffffff;
|
||||
$this->c = ($this->c + $C) & 0xffffffff;
|
||||
$this->d = ($this->d + $D) & 0xffffffff;
|
||||
}
|
||||
|
||||
private static function f($X, $Y, $Z)
|
||||
{
|
||||
return (($X & $Y) | ((~ $X) & $Z)); // X AND Y OR NOT X AND Z
|
||||
}
|
||||
|
||||
private static function g($X, $Y, $Z)
|
||||
{
|
||||
return (($X & $Z) | ($Y & (~ $Z))); // X AND Z OR Y AND NOT Z
|
||||
}
|
||||
|
||||
private static function h($X, $Y, $Z)
|
||||
{
|
||||
return ($X ^ $Y ^ $Z); // X XOR Y XOR Z
|
||||
}
|
||||
|
||||
private static function i($X, $Y, $Z)
|
||||
{
|
||||
return ($Y ^ ($X | (~ $Z))) ; // Y XOR (X OR NOT Z)
|
||||
}
|
||||
|
||||
private static function step($func, &$A, $B, $C, $D, $M, $s, $t)
|
||||
{
|
||||
$A = ($A + call_user_func($func, $B, $C, $D) + $M + $t) & 0xffffffff;
|
||||
$A = self::rotate($A, $s);
|
||||
$A = ($B + $A) & 0xffffffff;
|
||||
}
|
||||
|
||||
private static function rotate($decimal, $bits)
|
||||
{
|
||||
$binary = str_pad(decbin($decimal), 32, "0", STR_PAD_LEFT);
|
||||
return bindec(substr($binary, $bits).substr($binary, 0, $bits));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Excel5_RC4
|
||||
*
|
||||
* 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 PHPExcel_Reader_Excel5_RC4
|
||||
{
|
||||
// Context
|
||||
protected $s = array();
|
||||
protected $i = 0;
|
||||
protected $j = 0;
|
||||
|
||||
/**
|
||||
* RC4 stream decryption/encryption constrcutor
|
||||
*
|
||||
* @param string $key Encryption key/passphrase
|
||||
*/
|
||||
public function __construct($key)
|
||||
{
|
||||
$len = strlen($key);
|
||||
|
||||
for ($this->i = 0; $this->i < 256; $this->i++) {
|
||||
$this->s[$this->i] = $this->i;
|
||||
}
|
||||
|
||||
$this->j = 0;
|
||||
for ($this->i = 0; $this->i < 256; $this->i++) {
|
||||
$this->j = ($this->j + $this->s[$this->i] + ord($key[$this->i % $len])) % 256;
|
||||
$t = $this->s[$this->i];
|
||||
$this->s[$this->i] = $this->s[$this->j];
|
||||
$this->s[$this->j] = $t;
|
||||
}
|
||||
$this->i = $this->j = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Symmetric decryption/encryption function
|
||||
*
|
||||
* @param string $data Data to encrypt/decrypt
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function RC4($data)
|
||||
{
|
||||
$len = strlen($data);
|
||||
for ($c = 0; $c < $len; $c++) {
|
||||
$this->i = ($this->i + 1) % 256;
|
||||
$this->j = ($this->j + $this->s[$this->i]) % 256;
|
||||
$t = $this->s[$this->i];
|
||||
$this->s[$this->i] = $this->s[$this->j];
|
||||
$this->s[$this->j] = $t;
|
||||
|
||||
$t = ($this->s[$this->i] + $this->s[$this->j]) % 256;
|
||||
|
||||
$data[$c] = chr(ord($data[$c]) ^ $this->s[$t]);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class PHPExcel_Reader_Excel5_Style_Border
|
||||
{
|
||||
protected 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,
|
||||
);
|
||||
|
||||
/**
|
||||
* 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 PHPExcel_Style_Border::BORDER_NONE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
class PHPExcel_Reader_Excel5_Style_FillPattern
|
||||
{
|
||||
protected 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,
|
||||
);
|
||||
|
||||
/**
|
||||
* 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 PHPExcel_Style_Fill::FILL_NONE;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user