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

Public Member Functions

 OLERead ()
 read ($sFileName)
 __readData ($bl)
 __readPropertySets ()
 getWorkBook ()

Data Fields

 $data = ''

Detailed Description

Definition at line 95 of file excel_reader2.php.

Member Function Documentation

OLERead::__readData (   $bl)

Definition at line 187 of file excel_reader2.php.

References $data, and BIG_BLOCK_SIZE.

Referenced by getWorkBook(), and read().

{
$block = $bl;
$pos = 0;
$data = '';
while ($block != -2) {
$pos = ($block + 1) * BIG_BLOCK_SIZE;
$data = $data.substr($this->data, $pos, BIG_BLOCK_SIZE);
$block = $this->bigBlockChain[$block];
}
return $data;
}

+ Here is the caller graph for this function:

OLERead::__readPropertySets ( )

Definition at line 199 of file excel_reader2.php.

References $d, $size, GetInt4d(), PROPERTY_STORAGE_BLOCK_SIZE, SIZE_OF_NAME_POS, SIZE_POS, START_BLOCK_POS, and TYPE_POS.

Referenced by read().

{
$offset = 0;
while ($offset < strlen($this->entry)) {
$d = substr($this->entry, $offset, PROPERTY_STORAGE_BLOCK_SIZE);
$nameSize = ord($d[SIZE_OF_NAME_POS]) | (ord($d[SIZE_OF_NAME_POS+1]) << 8);
$type = ord($d[TYPE_POS]);
$startBlock = GetInt4d($d, START_BLOCK_POS);
$name = '';
for ($i = 0; $i < $nameSize ; $i++) {
$name .= $d[$i];
}
$name = str_replace("\x00", "", $name);
$this->props[] = array (
'name' => $name,
'type' => $type,
'startBlock' => $startBlock,
'size' => $size);
if ((strtolower($name) == "workbook") || ( strtolower($name) == "book")) {
$this->wrkbook = count($this->props) - 1;
}
if ($name == "Root Entry") {
$this->rootentry = count($this->props) - 1;
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

OLERead::getWorkBook ( )

Definition at line 229 of file excel_reader2.php.

References __readData(), BIG_BLOCK_SIZE, SMALL_BLOCK_SIZE, and SMALL_BLOCK_THRESHOLD.

{
if ($this->props[$this->wrkbook]['size'] < SMALL_BLOCK_THRESHOLD){
$rootdata = $this->__readData($this->props[$this->rootentry]['startBlock']);
$streamData = '';
$block = $this->props[$this->wrkbook]['startBlock'];
$pos = 0;
while ($block != -2) {
$pos = $block * SMALL_BLOCK_SIZE;
$streamData .= substr($rootdata, $pos, SMALL_BLOCK_SIZE);
$block = $this->smallBlockChain[$block];
}
return $streamData;
}else{
$numBlocks = $this->props[$this->wrkbook]['size'] / BIG_BLOCK_SIZE;
if ($this->props[$this->wrkbook]['size'] % BIG_BLOCK_SIZE != 0) {
$numBlocks++;
}
if ($numBlocks == 0) return '';
$streamData = '';
$block = $this->props[$this->wrkbook]['startBlock'];
$pos = 0;
while ($block != -2) {
$pos = ($block + 1) * BIG_BLOCK_SIZE;
$streamData .= substr($this->data, $pos, BIG_BLOCK_SIZE);
$block = $this->bigBlockChain[$block];
}
return $streamData;
}
}

+ Here is the call graph for this function:

OLERead::OLERead ( )

Definition at line 97 of file excel_reader2.php.

{ }
OLERead::read (   $sFileName)

Definition at line 99 of file excel_reader2.php.

References __readData(), __readPropertySets(), BIG_BLOCK_DEPOT_BLOCKS_POS, BIG_BLOCK_SIZE, EXTENSION_BLOCK_POS, GetInt4d(), IDENTIFIER_OLE, NUM_BIG_BLOCK_DEPOT_BLOCKS_POS, NUM_EXTENSION_BLOCK_POS, ROOT_START_BLOCK_POS, and SMALL_BLOCK_DEPOT_BLOCK_POS.

{
// check if file exist and is readable (Darko Miljanovic)
if(!is_readable($sFileName)) {
$this->error = 1;
return false;
}
$this->data = @file_get_contents($sFileName);
if (!$this->data) {
$this->error = 1;
return false;
}
if (substr($this->data, 0, 8) != IDENTIFIER_OLE) {
$this->error = 1;
return false;
}
$this->numBigBlockDepotBlocks = GetInt4d($this->data, NUM_BIG_BLOCK_DEPOT_BLOCKS_POS);
$this->sbdStartBlock = GetInt4d($this->data, SMALL_BLOCK_DEPOT_BLOCK_POS);
$this->rootStartBlock = GetInt4d($this->data, ROOT_START_BLOCK_POS);
$this->extensionBlock = GetInt4d($this->data, EXTENSION_BLOCK_POS);
$this->numExtensionBlocks = GetInt4d($this->data, NUM_EXTENSION_BLOCK_POS);
$bigBlockDepotBlocks = array();
$bbdBlocks = $this->numBigBlockDepotBlocks;
if ($this->numExtensionBlocks != 0) {
}
for ($i = 0; $i < $bbdBlocks; $i++) {
$bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos);
$pos += 4;
}
for ($j = 0; $j < $this->numExtensionBlocks; $j++) {
$pos = ($this->extensionBlock + 1) * BIG_BLOCK_SIZE;
$blocksToRead = min($this->numBigBlockDepotBlocks - $bbdBlocks, BIG_BLOCK_SIZE / 4 - 1);
for ($i = $bbdBlocks; $i < $bbdBlocks + $blocksToRead; $i++) {
$bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos);
$pos += 4;
}
$bbdBlocks += $blocksToRead;
if ($bbdBlocks < $this->numBigBlockDepotBlocks) {
$this->extensionBlock = GetInt4d($this->data, $pos);
}
}
// readBigBlockDepot
$pos = 0;
$index = 0;
$this->bigBlockChain = array();
for ($i = 0; $i < $this->numBigBlockDepotBlocks; $i++) {
$pos = ($bigBlockDepotBlocks[$i] + 1) * BIG_BLOCK_SIZE;
//echo "pos = $pos";
for ($j = 0 ; $j < BIG_BLOCK_SIZE / 4; $j++) {
$this->bigBlockChain[$index] = GetInt4d($this->data, $pos);
$pos += 4 ;
$index++;
}
}
// readSmallBlockDepot();
$pos = 0;
$index = 0;
$sbdBlock = $this->sbdStartBlock;
$this->smallBlockChain = array();
while ($sbdBlock != -2) {
$pos = ($sbdBlock + 1) * BIG_BLOCK_SIZE;
for ($j = 0; $j < BIG_BLOCK_SIZE / 4; $j++) {
$this->smallBlockChain[$index] = GetInt4d($this->data, $pos);
$pos += 4;
$index++;
}
$sbdBlock = $this->bigBlockChain[$sbdBlock];
}
// readData(rootStartBlock)
$block = $this->rootStartBlock;
$pos = 0;
$this->entry = $this->__readData($block);
}

+ Here is the call graph for this function:

Field Documentation

OLERead::$data = ''

Definition at line 96 of file excel_reader2.php.

Referenced by __readData().


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