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

Source for file PPS.php

Documentation is available at 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. /**
  24. * Class for creating PPS's for OLE containers
  25. *
  26. @author   Xavier Noguer <xnoguer@php.net>
  27. @category PHPExcel
  28. @package  PHPExcel_Shared_OLE
  29. */
  30. {
  31.     /**
  32.     * The PPS index
  33.     * @var integer 
  34.     */
  35.     public $No;
  36.  
  37.     /**
  38.     * The PPS name (in Unicode)
  39.     * @var string 
  40.     */
  41.     public $Name;
  42.  
  43.     /**
  44.     * The PPS type. Dir, Root or File
  45.     * @var integer 
  46.     */
  47.     public $Type;
  48.  
  49.     /**
  50.     * The index of the previous PPS
  51.     * @var integer 
  52.     */
  53.     public $PrevPps;
  54.  
  55.     /**
  56.     * The index of the next PPS
  57.     * @var integer 
  58.     */
  59.     public $NextPps;
  60.  
  61.     /**
  62.     * The index of it's first child if this is a Dir or Root PPS
  63.     * @var integer 
  64.     */
  65.     public $DirPps;
  66.  
  67.     /**
  68.     * A timestamp
  69.     * @var integer 
  70.     */
  71.     public $Time1st;
  72.  
  73.     /**
  74.     * A timestamp
  75.     * @var integer 
  76.     */
  77.     public $Time2nd;
  78.  
  79.     /**
  80.     * Starting block (small or big) for this PPS's data  inside the container
  81.     * @var integer 
  82.     */
  83.     public $_StartBlock;
  84.  
  85.     /**
  86.     * The size of the PPS's data (in bytes)
  87.     * @var integer 
  88.     */
  89.     public $Size;
  90.  
  91.     /**
  92.     * The PPS's data (only used if it's not using a temporary file)
  93.     * @var string 
  94.     */
  95.     public $_data;
  96.  
  97.     /**
  98.     * Array of child PPS's (only used by Root and Dir PPS's)
  99.     * @var array 
  100.     */
  101.     public $children = array();
  102.  
  103.     /**
  104.     * Pointer to OLE container
  105.     * @var OLE 
  106.     */
  107.     public $ole;
  108.  
  109.     /**
  110.     * The constructor
  111.     *
  112.     * @access public
  113.     * @param integer $No   The PPS index
  114.     * @param string  $name The PPS name
  115.     * @param integer $type The PPS type. Dir, Root or File
  116.     * @param integer $prev The index of the previous PPS
  117.     * @param integer $next The index of the next PPS
  118.     * @param integer $dir  The index of it's first child if this is a Dir or Root PPS
  119.     * @param integer $time_1st A timestamp
  120.     * @param integer $time_2nd A timestamp
  121.     * @param string  $data  The (usually binary) source data of the PPS
  122.     * @param array   $children Array containing children PPS for this PPS
  123.     */
  124.     public function __construct($No$name$type$prev$next$dir$time_1st$time_2nd$data$children)
  125.     {
  126.         $this->No      = $No;
  127.         $this->Name    = $name;
  128.         $this->Type    = $type;
  129.         $this->PrevPps = $prev;
  130.         $this->NextPps = $next;
  131.         $this->DirPps  = $dir;
  132.         $this->Time1st = $time_1st;
  133.         $this->Time2nd = $time_2nd;
  134.         $this->_data      = $data;
  135.         $this->children   = $children;
  136.         if ($data != ''{
  137.             $this->Size = strlen($data);
  138.         else {
  139.             $this->Size = 0;
  140.         }
  141.     }
  142.  
  143.     /**
  144.     * Returns the amount of data saved for this PPS
  145.     *
  146.     * @access public
  147.     * @return integer The amount of data (in bytes)
  148.     */
  149.     public function _DataLen()
  150.     {
  151.         if (!isset($this->_data)) {
  152.             return 0;
  153.         }
  154.         //if (isset($this->_PPS_FILE)) {
  155.         //    fseek($this->_PPS_FILE, 0);
  156.         //    $stats = fstat($this->_PPS_FILE);
  157.         //    return $stats[7];
  158.         //} else {
  159.             return strlen($this->_data);
  160.         //}
  161.     }
  162.  
  163.     /**
  164.     * Returns a string with the PPS's WK (What is a WK?)
  165.     *
  166.     * @access public
  167.     * @return string The binary string
  168.     */
  169.     public function _getPpsWk()
  170.     {
  171.         $ret str_pad($this->Name,64,"\x00");
  172.  
  173.         $ret .= pack("v"strlen($this->Name2)  // 66
  174.               . pack("c"$this->Type)              // 67
  175.               . pack("c"0x00//UK                // 68
  176.               . pack("V"$this->PrevPps//Prev    // 72
  177.               . pack("V"$this->NextPps//Next    // 76
  178.               . pack("V"$this->DirPps)  //Dir     // 80
  179.               . "\x00\x09\x02\x00"                  // 84
  180.               . "\x00\x00\x00\x00"                  // 88
  181.               . "\xc0\x00\x00\x00"                  // 92
  182.               . "\x00\x00\x00\x46"                  // 96 // Seems to be ok only for Root
  183.               . "\x00\x00\x00\x00"                  // 100
  184.               . PHPExcel_Shared_OLE::LocalDate2OLE($this->Time1st)       // 108
  185.               . PHPExcel_Shared_OLE::LocalDate2OLE($this->Time2nd)       // 116
  186.               . pack("V"isset($this->_StartBlock)?
  187.                         $this->_StartBlock:0)        // 120
  188.               . pack("V"$this->Size)               // 124
  189.               . pack("V"0);                        // 128
  190.         return $ret;
  191.     }
  192.  
  193.     /**
  194.     * Updates index and pointers to previous, next and children PPS's for this
  195.     * PPS. I don't think it'll work with Dir PPS's.
  196.     *
  197.     * @access public
  198.     * @param array &$pps_array Reference to the array of PPS's for the whole OLE
  199.     *                           container
  200.     * @return integer          The index for this PPS
  201.     */
  202.     public function _savePpsSetPnt(&$pps_array)
  203.     {
  204.         $pps_array[count($pps_array)&$this;
  205.         $this->No = count($pps_array1;
  206.         $this->PrevPps = 0xFFFFFFFF;
  207.         $this->NextPps = 0xFFFFFFFF;
  208.         if (count($this->children0{
  209.             $this->DirPps = $this->children[0]->_savePpsSetPnt($pps_array);
  210.         else {
  211.             $this->DirPps = 0xFFFFFFFF;
  212.         }
  213.         return $this->No;
  214.     }
  215. }

Documentation generated on Sun, 27 Feb 2011 16:33:29 -0800 by phpDocumentor 1.4.3