You are here

public function PHPExcel_Shared_OLE_PPS_Root::_saveHeader in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/OLE/PPS/Root.php \PHPExcel_Shared_OLE_PPS_Root::_saveHeader()

* Save OLE header * * @access public *

Parameters

integer $iSBDcnt: * @param integer $iBBcnt * @param integer $iPPScnt

1 call to PHPExcel_Shared_OLE_PPS_Root::_saveHeader()
PHPExcel_Shared_OLE_PPS_Root::save in vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/OLE/PPS/Root.php
* Method for saving the whole OLE container (including files). * In fact, if called with an empty argument (or '-'), it saves to a * temporary file and then outputs it's contents to stdout. * If a resource pointer to a stream created…

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/OLE/PPS/Root.php, line 180

Class

PHPExcel_Shared_OLE_PPS_Root
Class for creating Root PPS's for OLE containers

Code

public function _saveHeader($iSBDcnt, $iBBcnt, $iPPScnt) {
  $FILE = $this->_FILEH_;

  // Calculate Basic Setting
  $iBlCnt = $this->_BIG_BLOCK_SIZE / PHPExcel_Shared_OLE::OLE_LONG_INT_SIZE;
  $i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4c) / PHPExcel_Shared_OLE::OLE_LONG_INT_SIZE;
  $iBdExL = 0;
  $iAll = $iBBcnt + $iPPScnt + $iSBDcnt;
  $iAllW = $iAll;
  $iBdCntW = floor($iAllW / $iBlCnt) + ($iAllW % $iBlCnt ? 1 : 0);
  $iBdCnt = floor(($iAll + $iBdCntW) / $iBlCnt) + (($iAllW + $iBdCntW) % $iBlCnt ? 1 : 0);

  // Calculate BD count
  if ($iBdCnt > $i1stBdL) {
    while (1) {
      ++$iBdExL;
      ++$iAllW;
      $iBdCntW = floor($iAllW / $iBlCnt) + ($iAllW % $iBlCnt ? 1 : 0);
      $iBdCnt = floor(($iAllW + $iBdCntW) / $iBlCnt) + (($iAllW + $iBdCntW) % $iBlCnt ? 1 : 0);
      if ($iBdCnt <= $iBdExL * $iBlCnt + $i1stBdL) {
        break;
      }
    }
  }

  // Save Header
  fwrite($FILE, "" . "\0\0\0\0" . "\0\0\0\0" . "\0\0\0\0" . "\0\0\0\0" . pack("v", 0x3b) . pack("v", 0x3) . pack("v", -2) . pack("v", 9) . pack("v", 6) . pack("v", 0) . "\0\0\0\0" . "\0\0\0\0" . pack("V", $iBdCnt) . pack("V", $iBBcnt + $iSBDcnt) . pack("V", 0) . pack("V", 0x1000) . pack("V", $iSBDcnt ? 0 : -2) . pack("V", $iSBDcnt));

  // Extra BDList Start, Count
  if ($iBdCnt < $i1stBdL) {
    fwrite($FILE, pack("V", -2) . pack("V", 0));
  }
  else {
    fwrite($FILE, pack("V", $iAll + $iBdCnt) . pack("V", $iBdExL));
  }

  // BDList
  for ($i = 0; $i < $i1stBdL && $i < $iBdCnt; ++$i) {
    fwrite($FILE, pack("V", $iAll + $i));
  }
  if ($i < $i1stBdL) {
    $jB = $i1stBdL - $i;
    for ($j = 0; $j < $jB; ++$j) {
      fwrite($FILE, pack("V", -1));
    }
  }
}