/** * Returns a string with the PPS's WK (What is a WK?) * * @access public * @return string The binary string */ public function _getPpsWk() { $ret = str_pad($this->Name, 64, ""); $ret .= pack("v", strlen($this->Name) + 2) . pack("c", $this->Type) . pack("c", 0x0) . pack("V", $this->PrevPps) . pack("V", $this->NextPps) . pack("V", $this->DirPps) . "\t" . "" . "À" . "F" . "" . PHPExcel_Shared_OLE::LocalDate2OLE($this->Time1st) . PHPExcel_Shared_OLE::LocalDate2OLE($this->Time2nd) . pack("V", isset($this->_StartBlock) ? $this->_StartBlock : 0) . pack("V", $this->Size) . pack("V", 0); // 128 return $ret; }
/** * Returns a string with the PPS's WK (What is a WK?) * * @access public * @return string The binary string */ public function _getPpsWk() { $ret = str_pad($this->Name,64,"\x00"); $ret .= pack("v", strlen($this->Name) + 2) // 66 . pack("c", $this->Type) // 67 . pack("c", 0x00) //UK // 68 . pack("V", $this->PrevPps) //Prev // 72 . pack("V", $this->NextPps) //Next // 76 . pack("V", $this->DirPps) //Dir // 80 . "\x00\x09\x02\x00" // 84 . "\x00\x00\x00\x00" // 88 . "\xc0\x00\x00\x00" // 92 . "\x00\x00\x00\x46" // 96 // Seems to be ok only for Root . "\x00\x00\x00\x00" // 100 . PHPExcel_Shared_OLE::LocalDate2OLE($this->Time1st) // 108 . PHPExcel_Shared_OLE::LocalDate2OLE($this->Time2nd) // 116 . pack("V", isset($this->_StartBlock)? $this->_StartBlock:0) // 120 . pack("V", $this->Size) // 124 . pack("V", 0); // 128 return $ret; }
/** * Build the OLE Part for Summary Information * * @return string */ 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), '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), '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), '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), '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), '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), '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), '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), '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), '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), '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; }
/** * Returns a string with the PPS's WK (What is a WK?) * * @access public * @return string The binary string */ public function _getPpsWk() { $ret = str_pad ( $this->Name, 64, "\x00" ); $ret .= pack ( "v", strlen ( $this->Name ) + 2 ) . // 66 pack ( "c", $this->Type ) . // 67 pack ( "c", 0x00 ) . // UK // 68 pack ( "V", $this->PrevPps ) . // Prev // 72 pack ( "V", $this->NextPps ) . // Next // 76 pack ( "V", $this->DirPps ) . // Dir // 80 "\x00\x09\x02\x00" . // 84 "\x00\x00\x00\x00" . // 88 "\xc0\x00\x00\x00" . // 92 "\x00\x00\x00\x46" . // 96 // Seems to be ok only for Root "\x00\x00\x00\x00" . // 100 PHPExcel_Shared_OLE::LocalDate2OLE ( $this->Time1st ) . // 108 PHPExcel_Shared_OLE::LocalDate2OLE ( $this->Time2nd ) . // 116 pack ( "V", isset ( $this->_StartBlock ) ? $this->_StartBlock : 0 ) . // 120 pack ( "V", $this->Size ) . // 124 pack ( "V", 0 ); // 128 return $ret; }