You are here

private function PHPExcel_Writer_Excel5::_writeSummaryInformation in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5.php \PHPExcel_Writer_Excel5::_writeSummaryInformation()

* Build the OLE Part for Summary Information *

Return value

string

1 call to PHPExcel_Writer_Excel5::_writeSummaryInformation()
PHPExcel_Writer_Excel5::save in vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5.php
* Save PHPExcel to file * *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5.php, line 764

Class

PHPExcel_Writer_Excel5
PHPExcel_Writer_Excel5

Code

private function _writeSummaryInformation() {

  // offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark)
  $data = pack('v', 0xfffe);

  // offset: 2; size: 2;
  $data .= pack('v', 0x0);

  // offset: 4; size: 2; OS version
  $data .= pack('v', 0x106);

  // offset: 6; size: 2; OS indicator
  $data .= pack('v', 0x2);

  // offset: 8; size: 16
  $data .= pack('VVVV', 0x0, 0x0, 0x0, 0x0);

  // offset: 24; size: 4; section count
  $data .= pack('V', 0x1);

  // offset: 28; size: 16; first section's class id: e0 85 9f f2 f9 4f 68 10 ab 91 08 00 2b 27 b3 d9
  $data .= pack('vvvvvvvv', 0x85e0, 0xf29f, 0x4ff9, 0x1068, 0x91ab, 0x8, 0x272b, 0xd9b3);

  // offset: 44; size: 4; offset of the start
  $data .= pack('V', 0x30);

  // SECTION
  $dataSection = array();
  $dataSection_NumProps = 0;
  $dataSection_Summary = '';
  $dataSection_Content = '';

  // CodePage : CP-1252
  $dataSection[] = array(
    'summary' => array(
      'pack' => 'V',
      'data' => 0x1,
    ),
    'offset' => array(
      'pack' => 'V',
    ),
    'type' => array(
      'pack' => 'V',
      'data' => 0x2,
    ),
    // 2 byte signed integer
    'data' => array(
      'data' => 1252,
    ),
  );
  $dataSection_NumProps++;

  //	Title
  if ($this->_phpExcel
    ->getProperties()
    ->getTitle()) {
    $dataProp = $this->_phpExcel
      ->getProperties()
      ->getTitle();
    $dataSection[] = array(
      'summary' => array(
        'pack' => 'V',
        'data' => 0x2,
      ),
      'offset' => array(
        'pack' => 'V',
      ),
      'type' => array(
        'pack' => 'V',
        'data' => 0x1e,
      ),
      // null-terminated string prepended by dword string length
      'data' => array(
        'data' => $dataProp,
        'length' => strlen($dataProp),
      ),
    );
    $dataSection_NumProps++;
  }

  //	Subject
  if ($this->_phpExcel
    ->getProperties()
    ->getSubject()) {
    $dataProp = $this->_phpExcel
      ->getProperties()
      ->getSubject();
    $dataSection[] = array(
      'summary' => array(
        'pack' => 'V',
        'data' => 0x3,
      ),
      'offset' => array(
        'pack' => 'V',
      ),
      'type' => array(
        'pack' => 'V',
        'data' => 0x1e,
      ),
      // null-terminated string prepended by dword string length
      'data' => array(
        'data' => $dataProp,
        'length' => strlen($dataProp),
      ),
    );
    $dataSection_NumProps++;
  }

  //	Author (Creator)
  if ($this->_phpExcel
    ->getProperties()
    ->getCreator()) {
    $dataProp = $this->_phpExcel
      ->getProperties()
      ->getCreator();
    $dataSection[] = array(
      'summary' => array(
        'pack' => 'V',
        'data' => 0x4,
      ),
      'offset' => array(
        'pack' => 'V',
      ),
      'type' => array(
        'pack' => 'V',
        'data' => 0x1e,
      ),
      // null-terminated string prepended by dword string length
      'data' => array(
        'data' => $dataProp,
        'length' => strlen($dataProp),
      ),
    );
    $dataSection_NumProps++;
  }

  //	Keywords
  if ($this->_phpExcel
    ->getProperties()
    ->getKeywords()) {
    $dataProp = $this->_phpExcel
      ->getProperties()
      ->getKeywords();
    $dataSection[] = array(
      'summary' => array(
        'pack' => 'V',
        'data' => 0x5,
      ),
      'offset' => array(
        'pack' => 'V',
      ),
      'type' => array(
        'pack' => 'V',
        'data' => 0x1e,
      ),
      // null-terminated string prepended by dword string length
      'data' => array(
        'data' => $dataProp,
        'length' => strlen($dataProp),
      ),
    );
    $dataSection_NumProps++;
  }

  //	Comments (Description)
  if ($this->_phpExcel
    ->getProperties()
    ->getDescription()) {
    $dataProp = $this->_phpExcel
      ->getProperties()
      ->getDescription();
    $dataSection[] = array(
      'summary' => array(
        'pack' => 'V',
        'data' => 0x6,
      ),
      'offset' => array(
        'pack' => 'V',
      ),
      'type' => array(
        'pack' => 'V',
        'data' => 0x1e,
      ),
      // null-terminated string prepended by dword string length
      'data' => array(
        'data' => $dataProp,
        'length' => strlen($dataProp),
      ),
    );
    $dataSection_NumProps++;
  }

  //	Last Saved By (LastModifiedBy)
  if ($this->_phpExcel
    ->getProperties()
    ->getLastModifiedBy()) {
    $dataProp = $this->_phpExcel
      ->getProperties()
      ->getLastModifiedBy();
    $dataSection[] = array(
      'summary' => array(
        'pack' => 'V',
        'data' => 0x8,
      ),
      'offset' => array(
        'pack' => 'V',
      ),
      'type' => array(
        'pack' => 'V',
        'data' => 0x1e,
      ),
      // null-terminated string prepended by dword string length
      'data' => array(
        'data' => $dataProp,
        'length' => strlen($dataProp),
      ),
    );
    $dataSection_NumProps++;
  }

  //	Created Date/Time
  if ($this->_phpExcel
    ->getProperties()
    ->getCreated()) {
    $dataProp = $this->_phpExcel
      ->getProperties()
      ->getCreated();
    $dataSection[] = array(
      'summary' => array(
        'pack' => 'V',
        'data' => 0xc,
      ),
      'offset' => array(
        'pack' => 'V',
      ),
      'type' => array(
        'pack' => 'V',
        'data' => 0x40,
      ),
      // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
      'data' => array(
        'data' => PHPExcel_Shared_OLE::LocalDate2OLE($dataProp),
      ),
    );
    $dataSection_NumProps++;
  }

  //	Modified Date/Time
  if ($this->_phpExcel
    ->getProperties()
    ->getModified()) {
    $dataProp = $this->_phpExcel
      ->getProperties()
      ->getModified();
    $dataSection[] = array(
      'summary' => array(
        'pack' => 'V',
        'data' => 0xd,
      ),
      'offset' => array(
        'pack' => 'V',
      ),
      'type' => array(
        'pack' => 'V',
        'data' => 0x40,
      ),
      // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
      'data' => array(
        'data' => PHPExcel_Shared_OLE::LocalDate2OLE($dataProp),
      ),
    );
    $dataSection_NumProps++;
  }

  //	Security
  $dataSection[] = array(
    'summary' => array(
      'pack' => 'V',
      'data' => 0x13,
    ),
    'offset' => array(
      'pack' => 'V',
    ),
    'type' => array(
      'pack' => 'V',
      'data' => 0x3,
    ),
    // 4 byte signed integer
    'data' => array(
      'data' => 0x0,
    ),
  );
  $dataSection_NumProps++;

  // 		4 	Section Length
  //		4 	Property count
  //		8 * $dataSection_NumProps (8 =  ID (4) + OffSet(4))
  $dataSection_Content_Offset = 8 + $dataSection_NumProps * 8;
  foreach ($dataSection as $dataProp) {

    // Summary
    $dataSection_Summary .= pack($dataProp['summary']['pack'], $dataProp['summary']['data']);

    // Offset
    $dataSection_Summary .= pack($dataProp['offset']['pack'], $dataSection_Content_Offset);

    // DataType
    $dataSection_Content .= pack($dataProp['type']['pack'], $dataProp['type']['data']);

    // Data
    if ($dataProp['type']['data'] == 0x2) {

      // 2 byte signed integer
      $dataSection_Content .= pack('V', $dataProp['data']['data']);
      $dataSection_Content_Offset += 4 + 4;
    }
    elseif ($dataProp['type']['data'] == 0x3) {

      // 4 byte signed integer
      $dataSection_Content .= pack('V', $dataProp['data']['data']);
      $dataSection_Content_Offset += 4 + 4;
    }
    elseif ($dataProp['type']['data'] == 0x1e) {

      // null-terminated string prepended by dword string length
      // Null-terminated string
      $dataProp['data']['data'] .= chr(0);
      $dataProp['data']['length'] += 1;

      // Complete the string with null string for being a %4
      $dataProp['data']['length'] = $dataProp['data']['length'] + (4 - $dataProp['data']['length'] % 4 == 4 ? 0 : 4 - $dataProp['data']['length'] % 4);
      $dataProp['data']['data'] = str_pad($dataProp['data']['data'], $dataProp['data']['length'], chr(0), STR_PAD_RIGHT);
      $dataSection_Content .= pack('V', $dataProp['data']['length']);
      $dataSection_Content .= $dataProp['data']['data'];
      $dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']);
    }
    elseif ($dataProp['type']['data'] == 0x40) {

      // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
      $dataSection_Content .= $dataProp['data']['data'];
      $dataSection_Content_Offset += 4 + 8;
    }
    else {

      // Data Type Not Used at the moment
    }
  }

  // Now $dataSection_Content_Offset contains the size of the content
  // section header
  // offset: $secOffset; size: 4; section length
  // 		+ x  Size of the content (summary + content)
  $data .= pack('V', $dataSection_Content_Offset);

  // offset: $secOffset+4; size: 4; property count
  $data .= pack('V', $dataSection_NumProps);

  // Section Summary
  $data .= $dataSection_Summary;

  // Section Content
  $data .= $dataSection_Content;
  return $data;
}