You are here

public function PHPExcel_Shared_OLE::_readPpsWks in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/OLE.php \PHPExcel_Shared_OLE::_readPpsWks()

* Gets information about all PPS's on the OLE container from the PPS WK's * creates an OLE_PPS object for each one. * * @access public *

Parameters

integer the block id of the first block: * @return mixed true on success, PEAR_Error on failure

1 call to PHPExcel_Shared_OLE::_readPpsWks()
PHPExcel_Shared_OLE::read in vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/OLE.php
* Reads an OLE container from the contents of the file given. * * @acces public *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/OLE.php, line 266

Class

PHPExcel_Shared_OLE
OLE package base class.

Code

public function _readPpsWks($blockId) {
  $fh = $this
    ->getStream($blockId);
  for ($pos = 0;; $pos += 128) {
    fseek($fh, $pos, SEEK_SET);
    $nameUtf16 = fread($fh, 64);
    $nameLength = self::_readInt2($fh);
    $nameUtf16 = substr($nameUtf16, 0, $nameLength - 2);

    // Simple conversion from UTF-16LE to ISO-8859-1
    $name = str_replace("\0", "", $nameUtf16);
    $type = self::_readInt1($fh);
    switch ($type) {
      case self::OLE_PPS_TYPE_ROOT:
        $pps = new PHPExcel_Shared_OLE_PPS_Root(null, null, array());
        $this->root = $pps;
        break;
      case self::OLE_PPS_TYPE_DIR:
        $pps = new PHPExcel_Shared_OLE_PPS(null, null, null, null, null, null, null, null, null, array());
        break;
      case self::OLE_PPS_TYPE_FILE:
        $pps = new PHPExcel_Shared_OLE_PPS_File($name);
        break;
      default:
        continue;
    }
    fseek($fh, 1, SEEK_CUR);
    $pps->Type = $type;
    $pps->Name = $name;
    $pps->PrevPps = self::_readInt4($fh);
    $pps->NextPps = self::_readInt4($fh);
    $pps->DirPps = self::_readInt4($fh);
    fseek($fh, 20, SEEK_CUR);
    $pps->Time1st = self::OLE2LocalDate(fread($fh, 8));
    $pps->Time2nd = self::OLE2LocalDate(fread($fh, 8));
    $pps->_StartBlock = self::_readInt4($fh);
    $pps->Size = self::_readInt4($fh);
    $pps->No = count($this->_list);
    $this->_list[] = $pps;

    // check if the PPS tree (starting from root) is complete
    if (isset($this->root) && $this
      ->_ppsTreeComplete($this->root->No)) {
      break;
    }
  }
  fclose($fh);

  // Initialize $pps->children on directories
  foreach ($this->_list as $pps) {
    if ($pps->Type == self::OLE_PPS_TYPE_DIR || $pps->Type == self::OLE_PPS_TYPE_ROOT) {
      $nos = array(
        $pps->DirPps,
      );
      $pps->children = array();
      while ($nos) {
        $no = array_pop($nos);
        if ($no != -1) {
          $childPps = $this->_list[$no];
          $nos[] = $childPps->PrevPps;
          $nos[] = $childPps->NextPps;
          $pps->children[] = $childPps;
        }
      }
    }
  }
  return true;
}