ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules 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

◆ __readData()

OLERead::__readData (   $bl)

Definition at line 187 of file excel_reader2.php.

References $data, and BIG_BLOCK_SIZE.

Referenced by getWorkBook(), and read().

187  {
188  $block = $bl;
189  $pos = 0;
190  $data = '';
191  while ($block != -2) {
192  $pos = ($block + 1) * BIG_BLOCK_SIZE;
193  $data = $data.substr($this->data, $pos, BIG_BLOCK_SIZE);
194  $block = $this->bigBlockChain[$block];
195  }
196  return $data;
197  }
const BIG_BLOCK_SIZE
+ Here is the caller graph for this function:

◆ __readPropertySets()

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().

199  {
200  $offset = 0;
201  while ($offset < strlen($this->entry)) {
202  $d = substr($this->entry, $offset, PROPERTY_STORAGE_BLOCK_SIZE);
203  $nameSize = ord($d[SIZE_OF_NAME_POS]) | (ord($d[SIZE_OF_NAME_POS+1]) << 8);
204  $type = ord($d[TYPE_POS]);
205  $startBlock = GetInt4d($d, START_BLOCK_POS);
207  $name = '';
208  for ($i = 0; $i < $nameSize ; $i++) {
209  $name .= $d[$i];
210  }
211  $name = str_replace("\x00", "", $name);
212  $this->props[] = array (
213  'name' => $name,
214  'type' => $type,
215  'startBlock' => $startBlock,
216  'size' => $size);
217  if ((strtolower($name) == "workbook") || ( strtolower($name) == "book")) {
218  $this->wrkbook = count($this->props) - 1;
219  }
220  if ($name == "Root Entry") {
221  $this->rootentry = count($this->props) - 1;
222  }
223  $offset += PROPERTY_STORAGE_BLOCK_SIZE;
224  }
225 
226  }
const PROPERTY_STORAGE_BLOCK_SIZE
$size
Definition: RandomTest.php:79
const SIZE_POS
GetInt4d($data, $pos)
const TYPE_POS
const START_BLOCK_POS
const SIZE_OF_NAME_POS
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWorkBook()

OLERead::getWorkBook ( )

Definition at line 229 of file excel_reader2.php.

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

229  {
230  if ($this->props[$this->wrkbook]['size'] < SMALL_BLOCK_THRESHOLD){
231  $rootdata = $this->__readData($this->props[$this->rootentry]['startBlock']);
232  $streamData = '';
233  $block = $this->props[$this->wrkbook]['startBlock'];
234  $pos = 0;
235  while ($block != -2) {
236  $pos = $block * SMALL_BLOCK_SIZE;
237  $streamData .= substr($rootdata, $pos, SMALL_BLOCK_SIZE);
238  $block = $this->smallBlockChain[$block];
239  }
240  return $streamData;
241  }else{
242  $numBlocks = $this->props[$this->wrkbook]['size'] / BIG_BLOCK_SIZE;
243  if ($this->props[$this->wrkbook]['size'] % BIG_BLOCK_SIZE != 0) {
244  $numBlocks++;
245  }
246 
247  if ($numBlocks == 0) return '';
248  $streamData = '';
249  $block = $this->props[$this->wrkbook]['startBlock'];
250  $pos = 0;
251  while ($block != -2) {
252  $pos = ($block + 1) * BIG_BLOCK_SIZE;
253  $streamData .= substr($this->data, $pos, BIG_BLOCK_SIZE);
254  $block = $this->bigBlockChain[$block];
255  }
256  return $streamData;
257  }
258  }
__readData($bl)
const BIG_BLOCK_SIZE
const SMALL_BLOCK_SIZE
const SMALL_BLOCK_THRESHOLD
+ Here is the call graph for this function:

◆ OLERead()

OLERead::OLERead ( )

Definition at line 97 of file excel_reader2.php.

Referenced by Spreadsheet_Excel_Reader\Spreadsheet_Excel_Reader().

97 { }
+ Here is the caller graph for this function:

◆ read()

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.

Referenced by Spreadsheet_Excel_Reader\Spreadsheet_Excel_Reader().

99  {
100  // check if file exist and is readable (Darko Miljanovic)
101  if(!is_readable($sFileName)) {
102  $this->error = 1;
103  return false;
104  }
105  $this->data = @file_get_contents($sFileName);
106  if (!$this->data) {
107  $this->error = 1;
108  return false;
109  }
110  if (substr($this->data, 0, 8) != IDENTIFIER_OLE) {
111  $this->error = 1;
112  return false;
113  }
114  $this->numBigBlockDepotBlocks = GetInt4d($this->data, NUM_BIG_BLOCK_DEPOT_BLOCKS_POS);
115  $this->sbdStartBlock = GetInt4d($this->data, SMALL_BLOCK_DEPOT_BLOCK_POS);
116  $this->rootStartBlock = GetInt4d($this->data, ROOT_START_BLOCK_POS);
117  $this->extensionBlock = GetInt4d($this->data, EXTENSION_BLOCK_POS);
118  $this->numExtensionBlocks = GetInt4d($this->data, NUM_EXTENSION_BLOCK_POS);
119 
120  $bigBlockDepotBlocks = array();
122  $bbdBlocks = $this->numBigBlockDepotBlocks;
123  if ($this->numExtensionBlocks != 0) {
124  $bbdBlocks = (BIG_BLOCK_SIZE - BIG_BLOCK_DEPOT_BLOCKS_POS)/4;
125  }
126 
127  for ($i = 0; $i < $bbdBlocks; $i++) {
128  $bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos);
129  $pos += 4;
130  }
131 
132 
133  for ($j = 0; $j < $this->numExtensionBlocks; $j++) {
134  $pos = ($this->extensionBlock + 1) * BIG_BLOCK_SIZE;
135  $blocksToRead = min($this->numBigBlockDepotBlocks - $bbdBlocks, BIG_BLOCK_SIZE / 4 - 1);
136 
137  for ($i = $bbdBlocks; $i < $bbdBlocks + $blocksToRead; $i++) {
138  $bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos);
139  $pos += 4;
140  }
141 
142  $bbdBlocks += $blocksToRead;
143  if ($bbdBlocks < $this->numBigBlockDepotBlocks) {
144  $this->extensionBlock = GetInt4d($this->data, $pos);
145  }
146  }
147 
148  // readBigBlockDepot
149  $pos = 0;
150  $index = 0;
151  $this->bigBlockChain = array();
152 
153  for ($i = 0; $i < $this->numBigBlockDepotBlocks; $i++) {
154  $pos = ($bigBlockDepotBlocks[$i] + 1) * BIG_BLOCK_SIZE;
155  //echo "pos = $pos";
156  for ($j = 0 ; $j < BIG_BLOCK_SIZE / 4; $j++) {
157  $this->bigBlockChain[$index] = GetInt4d($this->data, $pos);
158  $pos += 4 ;
159  $index++;
160  }
161  }
162 
163  // readSmallBlockDepot();
164  $pos = 0;
165  $index = 0;
166  $sbdBlock = $this->sbdStartBlock;
167  $this->smallBlockChain = array();
168 
169  while ($sbdBlock != -2) {
170  $pos = ($sbdBlock + 1) * BIG_BLOCK_SIZE;
171  for ($j = 0; $j < BIG_BLOCK_SIZE / 4; $j++) {
172  $this->smallBlockChain[$index] = GetInt4d($this->data, $pos);
173  $pos += 4;
174  $index++;
175  }
176  $sbdBlock = $this->bigBlockChain[$sbdBlock];
177  }
178 
179 
180  // readData(rootStartBlock)
181  $block = $this->rootStartBlock;
182  $pos = 0;
183  $this->entry = $this->__readData($block);
184  $this->__readPropertySets();
185  }
const EXTENSION_BLOCK_POS
const ROOT_START_BLOCK_POS
__readData($bl)
const BIG_BLOCK_DEPOT_BLOCKS_POS
GetInt4d($data, $pos)
__readPropertySets()
const BIG_BLOCK_SIZE
const IDENTIFIER_OLE
const NUM_EXTENSION_BLOCK_POS
const NUM_BIG_BLOCK_DEPOT_BLOCKS_POS
const SMALL_BLOCK_DEPOT_BLOCK_POS
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $data


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