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

Source for file OLE_PPS.php

Documentation is available at OLE_PPS.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2002 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license,      |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Author: Xavier Noguer <xnoguer@php.net>                              |
  17. // | Based on OLE::Storage_Lite by Kawai, Takanori                        |
  18. // +----------------------------------------------------------------------+
  19. //
  20. // $Id: PPS.php,v 1.7 2007/02/13 21:00:42 schmidt Exp $
  21.  
  22.  
  23. require_once 'PHPExcel/Shared/OLE.php';
  24.  
  25. /**
  26. * Class for creating PPS's for OLE containers
  27. *
  28. @author   Xavier Noguer <xnoguer@php.net>
  29. @category PHPExcel
  30. @package  PHPExcel_Shared_OLE
  31. */
  32. {
  33.     /**
  34.     * The PPS index
  35.     * @var integer 
  36.     */
  37.     public $No;
  38.  
  39.     /**
  40.     * The PPS name (in Unicode)
  41.     * @var string 
  42.     */
  43.     public $Name;
  44.  
  45.     /**
  46.     * The PPS type. Dir, Root or File
  47.     * @var integer 
  48.     */
  49.     public $Type;
  50.  
  51.     /**
  52.     * The index of the previous PPS
  53.     * @var integer 
  54.     */
  55.     public $PrevPps;
  56.  
  57.     /**
  58.     * The index of the next PPS
  59.     * @var integer 
  60.     */
  61.     public $NextPps;
  62.  
  63.     /**
  64.     * The index of it's first child if this is a Dir or Root PPS
  65.     * @var integer 
  66.     */
  67.     public $DirPps;
  68.  
  69.     /**
  70.     * A timestamp
  71.     * @var integer 
  72.     */
  73.     public $Time1st;
  74.  
  75.     /**
  76.     * A timestamp
  77.     * @var integer 
  78.     */
  79.     public $Time2nd;
  80.  
  81.     /**
  82.     * Starting block (small or big) for this PPS's data  inside the container
  83.     * @var integer 
  84.     */
  85.     public $_StartBlock;
  86.  
  87.     /**
  88.     * The size of the PPS's data (in bytes)
  89.     * @var integer 
  90.     */
  91.     public $Size;
  92.  
  93.     /**
  94.     * The PPS's data (only used if it's not using a temporary file)
  95.     * @var string 
  96.     */
  97.     public $_data;
  98.  
  99.     /**
  100.     * Array of child PPS's (only used by Root and Dir PPS's)
  101.     * @var array 
  102.     */
  103.     public $children = array();
  104.  
  105.     /**
  106.     * Pointer to OLE container
  107.     * @var OLE 
  108.     */
  109.     public $ole;
  110.  
  111.     /**
  112.     * The constructor
  113.     *
  114.     * @access public
  115.     * @param integer $No   The PPS index
  116.     * @param string  $name The PPS name
  117.     * @param integer $type The PPS type. Dir, Root or File
  118.     * @param integer $prev The index of the previous PPS
  119.     * @param integer $next The index of the next PPS
  120.     * @param integer $dir  The index of it's first child if this is a Dir or Root PPS
  121.     * @param integer $time_1st A timestamp
  122.     * @param integer $time_2nd A timestamp
  123.     * @param string  $data  The (usually binary) source data of the PPS
  124.     * @param array   $children Array containing children PPS for this PPS
  125.     */
  126.     public function __construct($No$name$type$prev$next$dir$time_1st$time_2nd$data$children)
  127.     {
  128.         $this->No      = $No;
  129.         $this->Name    = $name;
  130.         $this->Type    = $type;
  131.         $this->PrevPps = $prev;
  132.         $this->NextPps = $next;
  133.         $this->DirPps  = $dir;
  134.         $this->Time1st = $time_1st;
  135.         $this->Time2nd = $time_2nd;
  136.         $this->_data      = $data;
  137.         $this->children   = $children;
  138.         if ($data != ''{
  139.             $this->Size = strlen($data);
  140.         else {
  141.             $this->Size = 0;
  142.         }
  143.     }
  144.  
  145.     /**
  146.     * Returns the amount of data saved for this PPS
  147.     *
  148.     * @access public
  149.     * @return integer The amount of data (in bytes)
  150.     */
  151.     public function _DataLen()
  152.     {
  153.         if (!isset($this->_data)) {
  154.             return 0;
  155.         }
  156.         if (isset($this->_PPS_FILE)) {
  157.             fseek($this->_PPS_FILE0);
  158.             $stats fstat($this->_PPS_FILE);
  159.             return $stats[7];
  160.         else {
  161.             return strlen($this->_data);
  162.         }
  163.     }
  164.  
  165.     /**
  166.     * Returns a string with the PPS's WK (What is a WK?)
  167.     *
  168.     * @access public
  169.     * @return string The binary string
  170.     */
  171.     public function _getPpsWk()
  172.     {
  173.         $ret $this->Name;
  174.         for ($i 0$i (64 strlen($this->Name))++$i{
  175.             $ret .= "\x00";
  176.         }
  177.         $ret .= pack("v"strlen($this->Name2)  // 66
  178.               . pack("c"$this->Type)              // 67
  179.               . pack("c"0x00//UK                // 68
  180.               . pack("V"$this->PrevPps//Prev    // 72
  181.               . pack("V"$this->NextPps//Next    // 76
  182.               . pack("V"$this->DirPps)  //Dir     // 80
  183.               . "\x00\x09\x02\x00"                  // 84
  184.               . "\x00\x00\x00\x00"                  // 88
  185.               . "\xc0\x00\x00\x00"                  // 92
  186.               . "\x00\x00\x00\x46"                  // 96 // Seems to be ok only for Root
  187.               . "\x00\x00\x00\x00"                  // 100
  188.               . PHPExcel_Shared_OLE::LocalDate2OLE($this->Time1st)       // 108
  189.               . PHPExcel_Shared_OLE::LocalDate2OLE($this->Time2nd)       // 116
  190.               . pack("V"isset($this->_StartBlock)?
  191.                         $this->_StartBlock:0)        // 120
  192.               . pack("V"$this->Size)               // 124
  193.               . pack("V"0);                        // 128
  194.         return $ret;
  195.     }
  196.  
  197.     /**
  198.     * Updates index and pointers to previous, next and children PPS's for this
  199.     * PPS. I don't think it'll work with Dir PPS's.
  200.     *
  201.     * @access public
  202.     * @param array &$pps_array Reference to the array of PPS's for the whole OLE
  203.     *                           container
  204.     * @return integer          The index for this PPS
  205.     */
  206.     public function _savePpsSetPnt(&$pps_array)
  207.     {
  208.         $pps_array[count($pps_array)&$this;
  209.         $this->No = count($pps_array1;
  210.         $this->PrevPps = 0xFFFFFFFF;
  211.         $this->NextPps = 0xFFFFFFFF;
  212.         if (count($this->children0{
  213.             $this->DirPps = $this->children[0]->_savePpsSetPnt($pps_array);
  214.         else {
  215.             $this->DirPps = 0xFFFFFFFF;
  216.         }
  217.         return $this->No;
  218.     }
  219.     }

Documentation generated on Mon, 05 Jan 2009 20:38:12 +0100 by phpDocumentor 1.4.1