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

Documentation generated on Mon, 10 Aug 2009 08:06:56 +0200 by phpDocumentor 1.4.1