~fabiocbalbuquerque/sahana-agasti/web-services

« back to all changes in this revision

Viewing changes to apps/frontend/lib/util/phpExcelReader/OLERead.class.php

  • Committer: Clayton Kramer
  • Date: 2011-06-02 20:32:55 UTC
  • mto: (1.26.1 push-trunk) (7.1.1 mayon)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: clayton.kramer@mail.cuny.edu-20110602203255-jibrhvvu4193e0sa
Staff import working. Still needs to be hooked to indexer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
 * @see         OLE, Spreadsheet_Excel_Writer
48
48
 * --------------------------------------------------------------------------
49
49
 */
50
 
 
51
50
class OLERead extends phpExcelReader
52
51
{
53
52
 
55
54
 
56
55
  function OLERead()
57
56
  {
58
 
 
 
57
    parent::construct();
 
58
    //print("<pre>" . print_r(get_defined_constants(true), true) . "</pre>");
59
59
  }
60
60
 
61
61
  function read($sFileName)
62
62
  {
63
63
    // check if file exist and is readable (Darko Miljanovic)
64
64
    if (!is_readable($sFileName)) {
 
65
      
65
66
      $this->error = 1;
66
67
      return false;
67
68
    }
70
71
      $this->error = 1;
71
72
      return false;
72
73
    }
 
74
    
73
75
    if (substr($this->data, 0, 8) != IDENTIFIER_OLE) {
74
76
      $this->error = 1;
75
77
      return false;
76
78
    }
77
 
    $this->numBigBlockDepotBlocks = GetInt4d($this->data, NUM_BIG_BLOCK_DEPOT_BLOCKS_POS);
78
 
    $this->sbdStartBlock = GetInt4d($this->data, SMALL_BLOCK_DEPOT_BLOCK_POS);
79
 
    $this->rootStartBlock = GetInt4d($this->data, ROOT_START_BLOCK_POS);
80
 
    $this->extensionBlock = GetInt4d($this->data, EXTENSION_BLOCK_POS);
81
 
    $this->numExtensionBlocks = GetInt4d($this->data, NUM_EXTENSION_BLOCK_POS);
 
79
    $this->numBigBlockDepotBlocks = parent::GetInt4d($this->data, NUM_BIG_BLOCK_DEPOT_BLOCKS_POS);
 
80
    $this->sbdStartBlock = parent::GetInt4d($this->data, SMALL_BLOCK_DEPOT_BLOCK_POS);
 
81
    $this->rootStartBlock = parent::GetInt4d($this->data, ROOT_START_BLOCK_POS);
 
82
    $this->extensionBlock = parent::GetInt4d($this->data, EXTENSION_BLOCK_POS);
 
83
    $this->numExtensionBlocks = parent::GetInt4d($this->data, NUM_EXTENSION_BLOCK_POS);
82
84
 
83
85
    $bigBlockDepotBlocks = array();
84
86
    $pos = BIG_BLOCK_DEPOT_BLOCKS_POS;
88
90
    }
89
91
 
90
92
    for ($i = 0; $i < $bbdBlocks; $i++) {
91
 
      $bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos);
 
93
      $bigBlockDepotBlocks[$i] = parent::GetInt4d($this->data, $pos);
92
94
      $pos += 4;
93
95
    }
94
96
 
98
100
      $blocksToRead = min($this->numBigBlockDepotBlocks - $bbdBlocks, BIG_BLOCK_SIZE / 4 - 1);
99
101
 
100
102
      for ($i = $bbdBlocks; $i < $bbdBlocks + $blocksToRead; $i++) {
101
 
        $bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos);
 
103
        $bigBlockDepotBlocks[$i] = parent::GetInt4d($this->data, $pos);
102
104
        $pos += 4;
103
105
      }
104
106
 
105
107
      $bbdBlocks += $blocksToRead;
106
108
      if ($bbdBlocks < $this->numBigBlockDepotBlocks) {
107
 
        $this->extensionBlock = GetInt4d($this->data, $pos);
 
109
        $this->extensionBlock = parent::GetInt4d($this->data, $pos);
108
110
      }
109
111
    }
110
112
 
117
119
      $pos = ($bigBlockDepotBlocks[$i] + 1) * BIG_BLOCK_SIZE;
118
120
      //echo "pos = $pos";
119
121
      for ($j = 0; $j < BIG_BLOCK_SIZE / 4; $j++) {
120
 
        $this->bigBlockChain[$index] = GetInt4d($this->data, $pos);
 
122
        $this->bigBlockChain[$index] = parent::GetInt4d($this->data, $pos);
121
123
        $pos += 4;
122
124
        $index++;
123
125
      }
132
134
    while ($sbdBlock != -2) {
133
135
      $pos = ($sbdBlock + 1) * BIG_BLOCK_SIZE;
134
136
      for ($j = 0; $j < BIG_BLOCK_SIZE / 4; $j++) {
135
 
        $this->smallBlockChain[$index] = GetInt4d($this->data, $pos);
 
137
        $this->smallBlockChain[$index] = parent::GetInt4d($this->data, $pos);
136
138
        $pos += 4;
137
139
        $index++;
138
140
      }
167
169
      $d = substr($this->entry, $offset, PROPERTY_STORAGE_BLOCK_SIZE);
168
170
      $nameSize = ord($d[SIZE_OF_NAME_POS]) | (ord($d[SIZE_OF_NAME_POS + 1]) << 8);
169
171
      $type = ord($d[TYPE_POS]);
170
 
      $startBlock = GetInt4d($d, START_BLOCK_POS);
171
 
      $size = GetInt4d($d, SIZE_POS);
 
172
      $startBlock = parent::GetInt4d($d, START_BLOCK_POS);
 
173
      $size = parent::GetInt4d($d, SIZE_POS);
172
174
      $name = '';
173
175
      for ($i = 0; $i < $nameSize; $i++) {
174
176
        $name .= $d[$i];
221
223
      return $streamData;
222
224
    }
223
225
  }
 
226
 
224
227
}