PHPExcel_Reader_Excel5
[ class tree: PHPExcel_Reader_Excel5 ] [ index: PHPExcel_Reader_Excel5 ] [ all elements ]

Source for file Escher.php

Documentation is available at Escher.php

  1. <?php
  2. /**
  3.  * PHPExcel
  4.  *
  5.  * Copyright (c) 2006 - 2009 PHPExcel
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  *
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  *
  17.  * You should have received a copy of tshhe GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20.  *
  21.  * @category   PHPExcel
  22.  * @package    PHPExcel_Reader_Excel5
  23.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.6.5, 2009-01-05
  26.  */
  27.  
  28. /** PHPExcel_Cell */
  29. require_once 'PHPExcel/Cell.php';
  30.  
  31. /** PHPExcel_Shared_Escher_DggContainer */
  32. require_once 'PHPExcel/Shared/Escher/DggContainer.php';
  33.  
  34. /** PHPExcel_Shared_Escher_DggContainer_BstoreContainer */
  35. require_once 'PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php';
  36.  
  37. /** PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE */
  38. require_once 'PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php';
  39.  
  40. /** PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip */
  41. require_once 'PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php';
  42.  
  43. /** PHPExcel_Shared_Escher_DgContainer */
  44. require_once 'PHPExcel/Shared/Escher/DgContainer.php';
  45.  
  46. /** PHPExcel_Shared_Escher_DgContainer_SpgrContainer */
  47. require_once 'PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php';
  48.  
  49. /** PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */
  50. require_once 'PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php';
  51.  
  52. /**
  53.  * PHPExcel_Reader_Excel5_Escher
  54.  *
  55.  * @category   PHPExcel
  56.  * @package    PHPExcel_Reader_Excel5
  57.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  58.  */
  59. {
  60.     const DGGCONTAINER        0xF000;
  61.     const BSTORECONTAINER    0xF001;
  62.     const DGCONTAINER        0xF002;
  63.     const SPGRCONTAINER        0xF003;
  64.     const SPCONTAINER        0xF004;
  65.     const DGG                0xF006;
  66.     const BSE                0xF007;
  67.     const DG                0xF008;
  68.     const SPGR                0xF009;
  69.     const SP                0xF00A;
  70.     const OPT                0xF00B;
  71.     const CLIENTTEXTBOX        0xF00D;
  72.     const CLIENTANCHOR        0xF010;
  73.     const CLIENTDATA        0xF011;
  74.     const BLIPJPEG            0xF01D;
  75.     const BLIPPNG            0xF01E;
  76.     const SPLITMENUCOLORS    0xF11E;
  77.     const TERTIARYOPT        0xF122;
  78.  
  79.     /**
  80.      * Escher stream data (binary)
  81.      *
  82.      * @var string 
  83.      */
  84.     private $_data;
  85.  
  86.     /**
  87.      * Size in bytes of the Escher stream data
  88.      *
  89.      * @var int 
  90.      */
  91.     private $_dataSize;
  92.  
  93.     /**
  94.      * Current position of stream pointer in Escher stream data
  95.      *
  96.      * @var int 
  97.      */
  98.     private $_pos;
  99.  
  100.     /**
  101.      * The object to be returned by the reader. Modified during load.
  102.      *
  103.      * @var mixed 
  104.      */
  105.     private $_object;
  106.  
  107.     /**
  108.      * Create a new PHPExcel_Reader_Excel5_Escher instance
  109.      *
  110.      * @param mixed $object 
  111.      */
  112.     public function __construct($object)
  113.     {
  114.         $this->_object = $object;
  115.     }
  116.     
  117.     /**
  118.      * Load Escher stream data. May be a partial Escher stream.
  119.      *
  120.      * @param string $data 
  121.      */
  122.     public function load($data)
  123.     {
  124.         $this->_data = $data;
  125.  
  126.         // total byte size of Excel data (workbook global substream + sheet substreams)
  127.         $this->_dataSize = strlen($this->_data);
  128.  
  129.         $this->_pos = 0;
  130.         
  131.         // Parse Escher stream
  132.         while ($this->_pos < $this->_dataSize{
  133.             
  134.             
  135.             // offset: 2; size: 2: Record Type
  136.             $fbt $this->_GetInt2d($this->_data$this->_pos + 2);
  137.             
  138.             switch ($fbt{
  139.                 case self::DGGCONTAINER:    $this->_readDggContainer();        break;
  140.                 case self::DGG:                $this->_readDgg();                break;
  141.                 case self::BSTORECONTAINER:    $this->_readBstoreContainer();    break;
  142.                 case self::BSE:                $this->_readBSE();                break;
  143.                 case self::BLIPJPEG:        $this->_readBlipJPEG();            break;
  144.                 case self::BLIPPNG:            $this->_readBlipPNG();            break;
  145.                 case self::OPT:                $this->_readOPT();                break;
  146.                 case self::TERTIARYOPT:        $this->_readTertiaryOPT();        break;
  147.                 case self::SPLITMENUCOLORS:    $this->_readSplitMenuColors();    break;
  148.                 case self::DGCONTAINER:        $this->_readDgContainer();        break;
  149.                 case self::DG:                $this->_readDg();                break;
  150.                 case self::SPGRCONTAINER:    $this->_readSpgrContainer();    break;
  151.                 case self::SPCONTAINER:        $this->_readSpContainer();        break;
  152.                 case self::SPGR:            $this->_readSpgr();                break;
  153.                 case self::SP:                $this->_readSp();                break;
  154.                 case self::CLIENTTEXTBOX:    $this->_readClientTextbox();    break;
  155.                 case self::CLIENTANCHOR:    $this->_readClientAnchor();        break;
  156.                 case self::CLIENTDATA:        $this->_readClientData();        break;
  157.                 default:                    $this->_readDefault();            break;
  158.             }
  159.         }
  160.         
  161.         return $this->_object;
  162.     }
  163.  
  164.     /**
  165.      * Read a generic record
  166.      */
  167.     private function _readDefault()
  168.     {
  169.         // offset 0; size: 2; recVer and recInstance
  170.         $verInstance $this->_GetInt2d($this->_data$this->_pos);
  171.         
  172.         // offset: 2; size: 2: Record Type
  173.         $fbt $this->_GetInt2d($this->_data$this->_pos + 2);
  174.  
  175.         // bit: 0-3; mask: 0x000F; recVer
  176.         $recVer (0x000F $verInstance>> 0;
  177.         
  178.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  179.         $recordData substr($this->_data$this->_pos + 8$length);
  180.         
  181.         // move stream pointer to next record
  182.         $this->_pos += $length;
  183.     }
  184.  
  185.     /**
  186.      * Read DggContainer record (Drawing Group Container)
  187.      */
  188.     private function _readDggContainer()
  189.     {
  190.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  191.         $recordData substr($this->_data$this->_pos + 8$length);
  192.  
  193.         // move stream pointer to next record
  194.         $this->_pos += $length;
  195.  
  196.         // record is a container, read contents
  197.         $dggContainer new PHPExcel_Shared_Escher_DggContainer();
  198.         $this->_object->setDggContainer($dggContainer);
  199.         $reader new PHPExcel_Reader_Excel5_Escher($dggContainer);
  200.         $reader->load($recordData);
  201.     }
  202.  
  203.     /**
  204.      * Read Dgg record (Drawing Group)
  205.      */
  206.     private function _readDgg()
  207.     {
  208.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  209.         $recordData substr($this->_data$this->_pos + 8$length);
  210.         
  211.         // move stream pointer to next record
  212.         $this->_pos += $length;
  213.     }
  214.  
  215.     /**
  216.      * Read BstoreContainer record (Blip Store Container)
  217.      */
  218.     private function _readBstoreContainer()
  219.     {
  220.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  221.         $recordData substr($this->_data$this->_pos + 8$length);
  222.  
  223.         // move stream pointer to next record
  224.         $this->_pos += $length;
  225.  
  226.         // record is a container, read contents
  227.         $bstoreContainer new PHPExcel_Shared_Escher_DggContainer_BstoreContainer();
  228.         $this->_object->setBstoreContainer($bstoreContainer);
  229.         $reader new PHPExcel_Reader_Excel5_Escher($bstoreContainer);
  230.         $reader->load($recordData);
  231.     }
  232.  
  233.     /**
  234.      * Read BSE record
  235.      */
  236.     private function _readBSE()
  237.     {
  238.         // offset: 0; size: 2; recVer and recInstance
  239.         
  240.         // bit: 4-15; mask: 0xFFF0; recInstance
  241.         $recInstance (0xFFF0 $this->_GetInt2d($this->_data$this->_pos)) >> 4;
  242.  
  243.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  244.         $recordData substr($this->_data$this->_pos + 8$length);
  245.         
  246.         // move stream pointer to next record
  247.         $this->_pos += $length;
  248.         
  249.         // add BSE to BstoreContainer
  250.         $this->_object->addBSE($BSE);
  251.  
  252.         $BSE->setBLIPType($recInstance);
  253.         
  254.         // offset: 0; size: 1; btWin32 (MSOBLIPTYPE)
  255.         $btWin32 ord($recordData[0]);
  256.  
  257.         // offset: 1; size: 1; btWin32 (MSOBLIPTYPE)
  258.         $btMacOS ord($recordData[1]);
  259.  
  260.         // offset: 2; size: 16; MD4 digest
  261.         $rgbUid substr($recordData216);
  262.  
  263.         // offset: 18; size: 2; tag
  264.         $tag $this->_GetInt2d($recordData18);
  265.  
  266.         // offset: 20; size: 4; size of BLIP in bytes
  267.         $size $this->_GetInt4d($recordData20);
  268.  
  269.         // offset: 24; size: 4; number of references to this BLIP
  270.         $cRef $this->_GetInt4d($recordData24);
  271.  
  272.         // offset: 28; size: 4; MSOFO file offset
  273.         $foDelay $this->_GetInt4d($recordData28);
  274.  
  275.         // offset: 32; size: 1; unused1
  276.         $unused1 ord($recordData{32});
  277.  
  278.         // offset: 33; size: 1; size of nameData in bytes (including null terminator)
  279.         $cbName ord($recordData{33});
  280.  
  281.         // offset: 34; size: 1; unused2
  282.         $unused2 ord($recordData{34});
  283.  
  284.         // offset: 35; size: 1; unused3
  285.         $unused3 ord($recordData{35});
  286.  
  287.         // offset: 36; size: $cbName; nameData
  288.         $nameData substr($recordData36$cbName);
  289.  
  290.         // offset: 36 + $cbName, size: var; the BLIP data
  291.         $blipData substr($recordData36 $cbName);
  292.  
  293.         // record is a container, read contents
  294.         $reader new PHPExcel_Reader_Excel5_Escher($BSE);
  295.         $reader->load($blipData);
  296.     }
  297.  
  298.     /**
  299.      * Read BlipJPEG record. Holds raw JPEG image data
  300.      */
  301.     private function _readBlipJPEG()
  302.     {
  303.         // offset: 0; size: 2; recVer and recInstance
  304.         
  305.         // bit: 4-15; mask: 0xFFF0; recInstance
  306.         $recInstance (0xFFF0 $this->_GetInt2d($this->_data$this->_pos)) >> 4;
  307.  
  308.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  309.         $recordData substr($this->_data$this->_pos + 8$length);
  310.         
  311.         // move stream pointer to next record
  312.         $this->_pos += $length;
  313.         
  314.         $pos 0;
  315.         
  316.         // offset: 0; size: 16; rgbUid1 (MD4 digest of)
  317.         $rgbUid1 substr($recordData016);
  318.         $pos += 16;
  319.         
  320.         // offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
  321.         if (in_array($recInstancearray(0x046B0x06E3))) {
  322.             $rgbUid2 substr($recordData1616);
  323.             $pos += 16;
  324.         }
  325.         
  326.         // offset: var; size: 1; tag
  327.         $tag ord($recordData{$pos});
  328.         $pos += 1;
  329.         
  330.         // offset: var; size: var; the raw image data
  331.         $data substr($recordData$pos);
  332.         
  333.         $blip->setData($data);
  334.         
  335.         $this->_object->setBlip($blip);
  336.     }
  337.  
  338.     /**
  339.      * Read BlipPNG record. Holds raw PNG image data
  340.      */
  341.     private function _readBlipPNG()
  342.     {
  343.         // offset: 0; size: 2; recVer and recInstance
  344.         
  345.         // bit: 4-15; mask: 0xFFF0; recInstance
  346.         $recInstance (0xFFF0 $this->_GetInt2d($this->_data$this->_pos)) >> 4;
  347.  
  348.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  349.         $recordData substr($this->_data$this->_pos + 8$length);
  350.         
  351.         // move stream pointer to next record
  352.         $this->_pos += $length;
  353.         
  354.         $pos 0;
  355.         
  356.         // offset: 0; size: 16; rgbUid1 (MD4 digest of)
  357.         $rgbUid1 substr($recordData016);
  358.         $pos += 16;
  359.         
  360.         // offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
  361.         if ($recInstance == 0x06E1{
  362.             $rgbUid2 substr($recordData1616);
  363.             $pos += 16;
  364.         }
  365.         
  366.         // offset: var; size: 1; tag
  367.         $tag ord($recordData{$pos});
  368.         $pos += 1;
  369.         
  370.         // offset: var; size: var; the raw image data
  371.         $data substr($recordData$pos);
  372.         
  373.         $blip->setData($data);
  374.         
  375.         $this->_object->setBlip($blip);
  376.     }
  377.  
  378.     /**
  379.      * Read OPT record. This record may occur within DggContainer record or SpContainer
  380.      */
  381.     private function _readOPT()
  382.     {
  383.         // offset: 0; size: 2; recVer and recInstance
  384.         
  385.         // bit: 4-15; mask: 0xFFF0; recInstance
  386.         $recInstance (0xFFF0 $this->_GetInt2d($this->_data$this->_pos)) >> 4;
  387.  
  388.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  389.         $recordData substr($this->_data$this->_pos + 8$length);
  390.         
  391.         // move stream pointer to next record
  392.         $this->_pos += $length;
  393.  
  394.         $this->_readOfficeArtRGFOPTE($recordData$recInstance);
  395.     }
  396.  
  397.     /**
  398.      * Read TertiaryOPT record
  399.      */
  400.     private function _readTertiaryOPT()
  401.     {
  402.         // offset: 0; size: 2; recVer and recInstance
  403.         
  404.         // bit: 4-15; mask: 0xFFF0; recInstance
  405.         $recInstance (0xFFF0 $this->_GetInt2d($this->_data$this->_pos)) >> 4;
  406.  
  407.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  408.         $recordData substr($this->_data$this->_pos + 8$length);
  409.  
  410.         // move stream pointer to next record
  411.         $this->_pos += $length;
  412.     }
  413.  
  414.     /**
  415.      * Read SplitMenuColors record
  416.      */
  417.     private function _readSplitMenuColors()
  418.     {
  419.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  420.         $recordData substr($this->_data$this->_pos + 8$length);
  421.  
  422.         // move stream pointer to next record
  423.         $this->_pos += $length;
  424.     }
  425.  
  426.     /**
  427.      * Read DgContainer record (Drawing Container)
  428.      */
  429.     private function _readDgContainer()
  430.     {
  431.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  432.         $recordData substr($this->_data$this->_pos + 8$length);
  433.  
  434.         // move stream pointer to next record
  435.         $this->_pos += $length;
  436.  
  437.         // record is a container, read contents
  438.         $dgContainer new PHPExcel_Shared_Escher_DgContainer();
  439.         $this->_object->setDgContainer($dgContainer);
  440.         $reader new PHPExcel_Reader_Excel5_Escher($dgContainer);
  441.         $escher $reader->load($recordData);
  442.     }
  443.  
  444.     /**
  445.      * Read Dg record (Drawing)
  446.      */
  447.     private function _readDg()
  448.     {
  449.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  450.         $recordData substr($this->_data$this->_pos + 8$length);
  451.  
  452.         // move stream pointer to next record
  453.         $this->_pos += $length;
  454.     }
  455.  
  456.     /**
  457.      * Read SpgrContainer record (Shape Group Container)
  458.      */
  459.     private function _readSpgrContainer()
  460.     {
  461.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  462.         $recordData substr($this->_data$this->_pos + 8$length);
  463.  
  464.         // move stream pointer to next record
  465.         $this->_pos += $length;
  466.  
  467.         // record is a container, read contents
  468.         $spgrContainer new PHPExcel_Shared_Escher_DgContainer_SpgrContainer();
  469.         $this->_object->setSpgrContainer($spgrContainer);
  470.         $reader new PHPExcel_Reader_Excel5_Escher($spgrContainer);
  471.         $escher $reader->load($recordData);
  472.     }
  473.  
  474.     /**
  475.      * Read SpContainer record (Shape Container)
  476.      */
  477.     private function _readSpContainer()
  478.     {
  479.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  480.         $recordData substr($this->_data$this->_pos + 8$length);
  481.  
  482.         // add BSE to BstoreContainer
  483.         $spContainer new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer();
  484.         $this->_object->addSpContainer($spContainer);
  485.  
  486.         // move stream pointer to next record
  487.         $this->_pos += $length;
  488.  
  489.         // record is a container, read contents
  490.         $reader new PHPExcel_Reader_Excel5_Escher($spContainer);
  491.         $escher $reader->load($recordData);
  492.     }
  493.  
  494.     /**
  495.      * Read Spgr record (Shape Group)
  496.      */
  497.     private function _readSpgr()
  498.     {
  499.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  500.         $recordData substr($this->_data$this->_pos + 8$length);
  501.  
  502.         // move stream pointer to next record
  503.         $this->_pos += $length;
  504.     }
  505.  
  506.     /**
  507.      * Read Sp record (Shape)
  508.      */
  509.     private function _readSp()
  510.     {
  511.         // offset: 0; size: 2; recVer and recInstance
  512.  
  513.         // bit: 4-15; mask: 0xFFF0; recInstance
  514.         $recInstance (0xFFF0 $this->_GetInt2d($this->_data$this->_pos)) >> 4;
  515.  
  516.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  517.         $recordData substr($this->_data$this->_pos + 8$length);
  518.  
  519.         // move stream pointer to next record
  520.         $this->_pos += $length;
  521.     }
  522.  
  523.     /**
  524.      * Read ClientTextbox record
  525.      */
  526.     private function _readClientTextbox()
  527.     {
  528.         // offset: 0; size: 2; recVer and recInstance
  529.  
  530.         // bit: 4-15; mask: 0xFFF0; recInstance
  531.         $recInstance (0xFFF0 $this->_GetInt2d($this->_data$this->_pos)) >> 4;
  532.  
  533.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  534.         $recordData substr($this->_data$this->_pos + 8$length);
  535.  
  536.         // move stream pointer to next record
  537.         $this->_pos += $length;
  538.     }
  539.  
  540.     /**
  541.      * Read ClientAnchor record. This record holds information about where the shape is anchored in worksheet
  542.      */
  543.     private function _readClientAnchor()
  544.     {
  545.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  546.         $recordData substr($this->_data$this->_pos + 8$length);
  547.         
  548.         // move stream pointer to next record
  549.         $this->_pos += $length;
  550.         
  551.         // offset: 2; size: 2; upper-left corner column index (0-based)
  552.         $c1 $this->_GetInt2d($recordData2);
  553.  
  554.         // offset: 6; size: 2; upper-left corner row index (0-based)
  555.         $r1 $this->_GetInt2d($recordData6);
  556.  
  557.         // set the start coordinates
  558.         $this->_object->setStartCoordinates(PHPExcel_Cell::stringFromColumnIndex($c1($r1 1));
  559.     }
  560.  
  561.     /**
  562.      * Read ClientData record
  563.      */
  564.     private function _readClientData()
  565.     {
  566.         $length $this->_GetInt4d($this->_data$this->_pos + 4);
  567.         $recordData substr($this->_data$this->_pos + 8$length);
  568.  
  569.         // move stream pointer to next record
  570.         $this->_pos += $length;
  571.     }
  572.  
  573.     /**
  574.      * Read OfficeArtRGFOPTE table of property-value pairs
  575.      *
  576.      * @param string $data Binary data
  577.      * @param int $n Number of properties
  578.      */
  579.     private function _readOfficeArtRGFOPTE($data$n{
  580.  
  581.         $splicedComplexData substr($data$n);
  582.  
  583.         // loop through property-value pairs
  584.         for ($i 0$i $n++$i{
  585.             // read 6 bytes at a time
  586.             $fopte substr($data$i6);
  587.  
  588.             // offset: 0; size: 2; opid
  589.             $opid $this->_GetInt2d($fopte0);
  590.  
  591.             // bit: 0-13; mask: 0x3FFF; opid.opid
  592.             $opidOpid (0x3FFF $opid>> 0;
  593.  
  594.             // bit: 14; mask 0x4000; 1 = value in op field is BLIP identifier
  595.             $opidFBid (0x4000 $opid>> 14;
  596.  
  597.             // bit: 15; mask 0x8000; 1 = this is a complex property, op field specifies size of complex data
  598.             $opidFComplex (0x8000 $opid>> 15;
  599.  
  600.             // offset: 2; size: 4; the value for this property
  601.             $op $this->_GetInt4d($fopte2);
  602.  
  603.             if ($opidFComplex{
  604.                 $complexData substr($splicedComplexData0$op);
  605.                 $splicedComplexData substr($splicedComplexData$op);
  606.  
  607.                 $value $complexData;
  608.             else {
  609.                 $value dechex($op);
  610.             }
  611.  
  612.             $this->_object->setOPT($opidOpid$value);
  613.         }
  614.     }
  615.  
  616.     /**
  617.      * Read 16-bit unsigned integer
  618.      *
  619.      * @param string $data 
  620.      * @param int $pos 
  621.      * @return int 
  622.      */
  623.     private function _GetInt2d($data$pos)
  624.     {
  625.         return ord($data[$pos](ord($data[$pos 1]<< 8);
  626.     }
  627.  
  628.     /**
  629.      * Read 32-bit signed integer
  630.      *
  631.      * @param string $data 
  632.      * @param int $pos 
  633.      * @return int 
  634.      */
  635.     private function _GetInt4d($data$pos)
  636.     {
  637.         //return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) |
  638.         //    (ord($data[$pos + 2]) << 16) | (ord($data[$pos + 3]) << 24);
  639.  
  640.         // FIX: represent numbers correctly on 64-bit system
  641.         // http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334
  642.         $_or_24 ord($data[$pos 3]);
  643.         if ($_or_24 >= 128{
  644.             // negative number
  645.             $_ord_24 = -abs((256 $_or_24<< 24);
  646.         else {
  647.             $_ord_24 ($_or_24 127<< 24;
  648.         }
  649.         return ord($data[$pos](ord($data[$pos 1]<< 8(ord($data[$pos 2]<< 16$_ord_24;
  650.     }
  651.  
  652. }

Documentation generated on Mon, 05 Jan 2009 20:36:54 +0100 by phpDocumentor 1.4.1