Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class oleread

Helixoleread
Hide Inherited MembersHelix Core
Description
No description.
 
Constants
No constants.
 
Properties
publicdata[ oleread ]
 
Methods
publicOLERead ( )[ oleread ]
Parameters
No parameters for this method
Code
041      function OLERead(){
042         
043         
044      }
publicgetWorkBook ( )[ oleread ]
Parameters
No parameters for this method
Code
223      function getWorkBook(){
224          if ($this->props[$this->wrkbook]['size'] < SMALL_BLOCK_THRESHOLD){
225  //          getSmallBlockStream(PropertyStorage ps)
226 
227          $rootdata = $this->__readData($this->props[$this->rootentry]['startBlock']);
228         
229          $streamData = '';
230          $block = $this->props[$this->wrkbook]['startBlock'];
231          //$count = 0;
232          $pos = 0;
233          while ($block != -2) {
234                      $pos = $block * SMALL_BLOCK_SIZE;
235                $streamData .= substr($rootdata, $pos, SMALL_BLOCK_SIZE);
236 
237                $block = $this->smallBlockChain[$block];
238          }
239         
240          return $streamData;
241             
242 
243          }else{
244         
245          $numBlocks = $this->props[$this->wrkbook]['size'] / BIG_BLOCK_SIZE;
246          if ($this->props[$this->wrkbook]['size'] % BIG_BLOCK_SIZE != 0) {
247              $numBlocks++;
248          }
249         
250          if ($numBlocks == 0) return '';
251         
252          //echo "numBlocks = $numBlocks\n";
253      //byte[] streamData = new byte[numBlocks * BIG_BLOCK_SIZE];
254          //print_r($this->wrkbook);
255          $streamData = '';
256          $block = $this->props[$this->wrkbook]['startBlock'];
257          //$count = 0;
258          $pos = 0;
259          //echo "block = $block";
260          while ($block != -2) {
261            $pos = ($block + 1) * BIG_BLOCK_SIZE;
262            $streamData .= substr($this->data, $pos, BIG_BLOCK_SIZE);
263            $block = $this->bigBlockChain[$block];
264          }  
265          //echo 'stream'.$streamData;
266          return $streamData;
267          }
268      }
publicread ( sFileName )[ oleread ]
Parameters
requiredsFileName
Code
046      function read($sFileName){
047         
048          // check if file exist and is readable (Darko Miljanovic)
049          if(!is_readable($sFileName)) {
050              $this->error = 1;
051              return false;
052          }
053         
054          $this->data = @file_get_contents($sFileName);
055          if (!$this->data) {
056              $this->error = 1;
057              return false;
058             }
059             //echo IDENTIFIER_OLE;
060             //echo 'start';
061             if (substr($this->data, 0, 8) != IDENTIFIER_OLE) {
062              $this->error = 1;
063              return false;
064             }
065          $this->numBigBlockDepotBlocks = GetInt4d($this->data, NUM_BIG_BLOCK_DEPOT_BLOCKS_POS);
066          $this->sbdStartBlock = GetInt4d($this->data, SMALL_BLOCK_DEPOT_BLOCK_POS);
067          $this->rootStartBlock = GetInt4d($this->data, ROOT_START_BLOCK_POS);
068          $this->extensionBlock = GetInt4d($this->data, EXTENSION_BLOCK_POS);
069          $this->numExtensionBlocks = GetInt4d($this->data, NUM_EXTENSION_BLOCK_POS);
070         
071  /*
072          echo $this->numBigBlockDepotBlocks." ";
073          echo $this->sbdStartBlock." ";
074          echo $this->rootStartBlock." ";
075          echo $this->extensionBlock." ";
076          echo $this->numExtensionBlocks." ";
077          */
078          //echo "sbdStartBlock = $this->sbdStartBlock\n";
079          $bigBlockDepotBlocks = array();
080          $pos = BIG_BLOCK_DEPOT_BLOCKS_POS;
081         // echo "pos = $pos";
082  $bbdBlocks = $this->numBigBlockDepotBlocks;
083         
084              if ($this->numExtensionBlocks != 0) {
085                  $bbdBlocks = (BIG_BLOCK_SIZE - BIG_BLOCK_DEPOT_BLOCKS_POS)/4;
086              }
087         
088          for ($i = 0; $i < $bbdBlocks; $i++) {
089                $bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos);
090                $pos += 4;
091          }
092         
093         
094          for ($j = 0; $j < $this->numExtensionBlocks; $j++) {
095              $pos = ($this->extensionBlock + 1) * BIG_BLOCK_SIZE;
096              $blocksToRead = min($this->numBigBlockDepotBlocks - $bbdBlocks, BIG_BLOCK_SIZE / 4 - 1);
097 
098              for ($i = $bbdBlocks; $i < $bbdBlocks + $blocksToRead; $i++) {
099                  $bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos);
100                  $pos += 4;
101              }  
102 
103              $bbdBlocks += $blocksToRead;
104              if ($bbdBlocks < $this->numBigBlockDepotBlocks) {
105                  $this->extensionBlock = GetInt4d($this->data, $pos);
106              }
107          }
108 
109         // var_dump($bigBlockDepotBlocks);
110         
111          // readBigBlockDepot
112          $pos = 0;
113          $index = 0;
114          $this->bigBlockChain = array();
115         
116          for ($i = 0; $i < $this->numBigBlockDepotBlocks; $i++) {
117              $pos = ($bigBlockDepotBlocks[$i] + 1) * BIG_BLOCK_SIZE;
118              //echo "pos = $pos";   
119              for ($j = 0 ; $j < BIG_BLOCK_SIZE / 4; $j++) {
120                  $this->bigBlockChain[$index] = GetInt4d($this->data, $pos);
121                  $pos += 4 ;
122                  $index++;
123              }
124          }
125 
126  //var_dump($this->bigBlockChain);
127          //echo '=====2';
128          // readSmallBlockDepot();
129          $pos = 0;
130      $index = 0;
131      $sbdBlock = $this->sbdStartBlock;
132      $this->smallBlockChain = array();
133 
134      while ($sbdBlock != -2) {
135 
136        $pos = ($sbdBlock + 1) * BIG_BLOCK_SIZE;
137 
138        for ($j = 0; $j < BIG_BLOCK_SIZE / 4; $j++) {
139          $this->smallBlockChain[$index] = GetInt4d($this->data, $pos);
140          $pos += 4;
141          $index++;
142        }
143 
144        $sbdBlock = $this->bigBlockChain[$sbdBlock];
145      }
146 
147         
148          // readData(rootStartBlock)
149          $block = $this->rootStartBlock;
150          $pos = 0;
151          $this->entry = $this->__readData($block);
152         
153          /*
154          while ($block != -2)  {
155              $pos = ($block + 1) * BIG_BLOCK_SIZE;
156              $this->entry = $this->entry.substr($this->data, $pos, BIG_BLOCK_SIZE);
157              $block = $this->bigBlockChain[$block];
158          }
159          */
160          //echo '==='.$this->entry."===";
161          $this->__readPropertySets();
162 
163      }
public__readData ( bl )[ oleread ]
Parameters
requiredbl
Code
165       function __readData($bl) {
166          $block = $bl;
167          $pos = 0;
168          $data = '';
169         
170          while ($block != -2)  {
171              $pos = ($block + 1) * BIG_BLOCK_SIZE;
172              $data = $data.substr($this->data, $pos, BIG_BLOCK_SIZE);
173              //echo "pos = $pos data=$data\n";   
174      $block = $this->bigBlockChain[$block];
175          }
176      return $data;
177       }
public__readPropertySets ( )[ oleread ]
Parameters
No parameters for this method
Code
179      function __readPropertySets(){
180          $offset = 0;
181          //var_dump($this->entry);
182          while ($offset < strlen($this->entry)) {
183                $d = substr($this->entry, $offset, PROPERTY_STORAGE_BLOCK_SIZE);
184             
185                $nameSize = ord($d[SIZE_OF_NAME_POS]) | (ord($d[SIZE_OF_NAME_POS+1]) << 8);
186               
187                $type = ord($d[TYPE_POS]);
188                //$maxBlock = strlen($d) / BIG_BLOCK_SIZE - 1;
189         
190                $startBlock = GetInt4d($d, START_BLOCK_POS);
191                $size = GetInt4d($d, SIZE_POS);
192         
193              $name = '';
194              for ($i = 0; $i < $nameSize ; $i++) {
195                $name .= $d[$i];
196              }
197             
198              $name = str_replace("\x00", "", $name);
199             
200              $this->props[] = array (
201                  'name' => $name,
202                  'type' => $type,
203                  'startBlock' => $startBlock,
204                  'size' => $size);
205 
206              if (($name == "Workbook") || ($name == "Book")) {
207                  $this->wrkbook = count($this->props) - 1;
208              }
209 
210              if ($name == "Root Entry") {
211                  $this->rootentry = count($this->props) - 1;
212              }
213             
214              //echo "name ==$name=\n";
215 
216             
217              $offset += PROPERTY_STORAGE_BLOCK_SIZE;
218          }  
219         
220      }
 
Accessors
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads