29 if (!defined(
'PHPEXCEL_ROOT')) {
33 define(
'PHPEXCEL_ROOT', dirname(__FILE__) .
'/../../../');
36 require_once PHPEXCEL_ROOT .
'PHPExcel/Shared/OLE.php';
84 public function stream_open($path, $mode, $options, &$openedPath)
87 if ($options & STREAM_REPORT_ERRORS) {
88 trigger_error(
'Only reading is supported', E_USER_WARNING);
94 parse_str(substr($path, 25), $this->params);
95 if (!isset($this->params[
'oleInstanceId'],
96 $this->params[
'blockId'],
97 $GLOBALS[
'_OLE_INSTANCES'][$this->params[
'oleInstanceId']])) {
99 if ($options & STREAM_REPORT_ERRORS) {
100 trigger_error(
'OLE stream not found', E_USER_WARNING);
104 $this->ole =
$GLOBALS[
'_OLE_INSTANCES'][$this->params[
'oleInstanceId']];
106 $blockId = $this->params[
'blockId'];
108 if (isset($this->params[
'size']) &&
109 $this->params[
'size'] < $this->ole->bigBlockThreshold &&
110 $blockId != $this->ole->root->_StartBlock) {
113 $rootPos = $this->ole->_getBlockOffset($this->ole->root->_StartBlock);
114 while ($blockId != -2) {
115 $pos = $rootPos + $blockId * $this->ole->bigBlockSize;
116 $blockId = $this->ole->sbat[$blockId];
117 fseek($this->ole->_file_handle,
$pos);
118 $this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize);
122 while ($blockId != -2) {
123 $pos = $this->ole->_getBlockOffset($blockId);
124 fseek($this->ole->_file_handle,
$pos);
125 $this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize);
126 $blockId = $this->ole->bbat[$blockId];
129 if (isset($this->params[
'size'])) {
130 $this->data = substr($this->data, 0, $this->params[
'size']);
133 if ($options & STREAM_USE_PATH) {
160 $s = substr($this->data, $this->pos, $count);
161 $this->pos += $count;
171 $eof = $this->pos >= strlen($this->data);
173 if (version_compare(PHP_VERSION,
'5.0',
'>=') &&
174 version_compare(PHP_VERSION,
'5.1',
'<')) {
199 if ($whence == SEEK_SET && $offset >= 0) {
200 $this->pos = $offset;
201 }
elseif ($whence == SEEK_CUR && -$offset <= $this->pos) {
202 $this->pos += $offset;
203 }
elseif ($whence == SEEK_END && -$offset <=
sizeof($this->data)) {
204 $this->pos = strlen($this->data) + $offset;
219 'size' => strlen($this->data),