ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
PHPExcel_Shared_OLE_ChainedBlockStream Class Reference
+ Collaboration diagram for PHPExcel_Shared_OLE_ChainedBlockStream:

Public Member Functions

 stream_open ($path, $mode, $options, &$openedPath)
 Implements support for fopen().
 stream_close ()
 Implements support for fclose().
 stream_read ($count)
 Implements support for fread(), fgets() etc.
 stream_eof ()
 Implements support for feof().
 stream_tell ()
 Returns the position of the file pointer, i.e.
 stream_seek ($offset, $whence)
 Implements support for fseek().
 stream_stat ()
 Implements support for fstat().

Data Fields

 $ole
 $params
 $data
 $pos

Detailed Description

Definition at line 48 of file ChainedBlockStream.php.

Member Function Documentation

PHPExcel_Shared_OLE_ChainedBlockStream::stream_close ( )

Implements support for fclose().

Returns
string

Definition at line 144 of file ChainedBlockStream.php.

References $GLOBALS.

{
$this->ole = null;
unset($GLOBALS['_OLE_INSTANCES']);
}
PHPExcel_Shared_OLE_ChainedBlockStream::stream_eof ( )

Implements support for feof().

Returns
bool TRUE if the file pointer is at EOF; otherwise FALSE

Definition at line 169 of file ChainedBlockStream.php.

Referenced by stream_read().

{
$eof = $this->pos >= strlen($this->data);
// Workaround for bug in PHP 5.0.x: http://bugs.php.net/27508
if (version_compare(PHP_VERSION, '5.0', '>=') &&
version_compare(PHP_VERSION, '5.1', '<')) {
$eof = !$eof;
}
return $eof;
}

+ Here is the caller graph for this function:

PHPExcel_Shared_OLE_ChainedBlockStream::stream_open (   $path,
  $mode,
  $options,
$openedPath 
)

Implements support for fopen().

For creating streams using this wrapper, use OLE_PPS_File::getStream().

Parameters
stringresource name including scheme, e.g. ole-chainedblockstream://oleInstanceId=1
stringonly "r" is supported
intmask of STREAM_REPORT_ERRORS and STREAM_USE_PATH
stringabsolute path of the opened stream (out parameter)
Returns
bool true on success

Definition at line 84 of file ChainedBlockStream.php.

References $GLOBALS, and $pos.

{
if ($mode != 'r') {
if ($options & STREAM_REPORT_ERRORS) {
trigger_error('Only reading is supported', E_USER_WARNING);
}
return false;
}
// 25 is length of "ole-chainedblockstream://"
parse_str(substr($path, 25), $this->params);
if (!isset($this->params['oleInstanceId'],
$this->params['blockId'],
$GLOBALS['_OLE_INSTANCES'][$this->params['oleInstanceId']])) {
if ($options & STREAM_REPORT_ERRORS) {
trigger_error('OLE stream not found', E_USER_WARNING);
}
return false;
}
$this->ole = $GLOBALS['_OLE_INSTANCES'][$this->params['oleInstanceId']];
$blockId = $this->params['blockId'];
$this->data = '';
if (isset($this->params['size']) &&
$this->params['size'] < $this->ole->bigBlockThreshold &&
$blockId != $this->ole->root->_StartBlock) {
// Block id refers to small blocks
$rootPos = $this->ole->_getBlockOffset($this->ole->root->_StartBlock);
while ($blockId != -2) {
$pos = $rootPos + $blockId * $this->ole->bigBlockSize;
$blockId = $this->ole->sbat[$blockId];
fseek($this->ole->_file_handle, $pos);
$this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize);
}
} else {
// Block id refers to big blocks
while ($blockId != -2) {
$pos = $this->ole->_getBlockOffset($blockId);
fseek($this->ole->_file_handle, $pos);
$this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize);
$blockId = $this->ole->bbat[$blockId];
}
}
if (isset($this->params['size'])) {
$this->data = substr($this->data, 0, $this->params['size']);
}
if ($options & STREAM_USE_PATH) {
$openedPath = $path;
}
return true;
}
PHPExcel_Shared_OLE_ChainedBlockStream::stream_read (   $count)

Implements support for fread(), fgets() etc.

Parameters
intmaximum number of bytes to read
Returns
string

Definition at line 155 of file ChainedBlockStream.php.

References stream_eof().

{
if ($this->stream_eof()) {
return false;
}
$s = substr($this->data, $this->pos, $count);
$this->pos += $count;
return $s;
}

+ Here is the call graph for this function:

PHPExcel_Shared_OLE_ChainedBlockStream::stream_seek (   $offset,
  $whence 
)

Implements support for fseek().

Parameters
intbyte offset
intSEEK_SET, SEEK_CUR or SEEK_END
Returns
bool

Definition at line 197 of file ChainedBlockStream.php.

References elseif().

{
if ($whence == SEEK_SET && $offset >= 0) {
$this->pos = $offset;
} elseif ($whence == SEEK_CUR && -$offset <= $this->pos) {
$this->pos += $offset;
} elseif ($whence == SEEK_END && -$offset <= sizeof($this->data)) {
$this->pos = strlen($this->data) + $offset;
} else {
return false;
}
return true;
}

+ Here is the call graph for this function:

PHPExcel_Shared_OLE_ChainedBlockStream::stream_stat ( )

Implements support for fstat().

Currently the only supported field is "size".

Returns
array

Definition at line 216 of file ChainedBlockStream.php.

{
return array(
'size' => strlen($this->data),
);
}
PHPExcel_Shared_OLE_ChainedBlockStream::stream_tell ( )

Returns the position of the file pointer, i.e.

its offset into the file stream. Implements support for ftell().

Returns
int

Definition at line 186 of file ChainedBlockStream.php.

References $pos.

{
return $this->pos;
}

Field Documentation

PHPExcel_Shared_OLE_ChainedBlockStream::$data

Definition at line 66 of file ChainedBlockStream.php.

PHPExcel_Shared_OLE_ChainedBlockStream::$ole

Definition at line 54 of file ChainedBlockStream.php.

PHPExcel_Shared_OLE_ChainedBlockStream::$params

Definition at line 60 of file ChainedBlockStream.php.

PHPExcel_Shared_OLE_ChainedBlockStream::$pos

Definition at line 72 of file ChainedBlockStream.php.

Referenced by stream_open(), and stream_tell().


The documentation for this class was generated from the following file: