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

Documentation generated on Tue, 01 Jun 2010 17:03:04 +0200 by phpDocumentor 1.4.3