File Source for PPS.php

PHPExcel_Shared_OLE

# Source for file PPS.php

Documentation is available at PPS.php

1. <?php
2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
3. // +----------------------------------------------------------------------+
4. // | PHP Version 4 |
5. // +----------------------------------------------------------------------+
6. // | Copyright (c) 1997-2002 The PHP Group |
7. // +----------------------------------------------------------------------+
8. // | This source file is subject to version 2.02 of the PHP license, |
9. // | that is bundled with this package in the file LICENSE, and is |
10. // | available at through the world-wide-web at |
11. // | http://www.php.net/license/2_02.txt. |
12. // | If you did not receive a copy of the PHP license and are unable to |
13. // | obtain it through the world-wide-web, please send a note to |
14. // | license@php.net so we can mail you a copy immediately. |
15. // +----------------------------------------------------------------------+
16. // | Author: Xavier Noguer <xnoguer@php.net> |
17. // | Based on OLE::Storage_Lite by Kawai, Takanori |
18. // +----------------------------------------------------------------------+
19. //
20. // $Id: PPS.php,v 1.7 2007/02/13 21:00:42 schmidt Exp $
23. /**
24. * Class for creating PPS's for OLE containers
25. *
26. * @author Xavier Noguer <xnoguer@php.net>
27. * @category PHPExcel
28. * @package PHPExcel_Shared_OLE
29. */
30. class PHPExcel_Shared_OLE_PPS
31. {
32. /**
33. * The PPS index
34. * @var integer
35. */
36. public $No;
38. /**
39. * The PPS name (in Unicode)
40. * @var string
41. */
42. public $Name;
44. /**
45. * The PPS type. Dir, Root or File
46. * @var integer
47. */
48. public $Type;
50. /**
51. * The index of the previous PPS
52. * @var integer
53. */
54. public $PrevPps;
56. /**
57. * The index of the next PPS
58. * @var integer
59. */
60. public $NextPps;
62. /**
63. * The index of it's first child if this is a Dir or Root PPS
64. * @var integer
65. */
66. public $DirPps;
68. /**
69. * A timestamp
70. * @var integer
71. */
72. public $Time1st;
74. /**
75. * A timestamp
76. * @var integer
77. */
78. public $Time2nd;
80. /**
81. * Starting block (small or big) for this PPS's data inside the container
82. * @var integer
83. */
84. public $_StartBlock;
86. /**
87. * The size of the PPS's data (in bytes)
88. * @var integer
89. */
90. public $Size;
92. /**
93. * The PPS's data (only used if it's not using a temporary file)
94. * @var string
95. */
96. public $_data;
98. /**
99. * Array of child PPS's (only used by Root and Dir PPS's)
100. * @var array
101. */
102. public $children = array();
104. /**
105. * Pointer to OLE container
106. * @var OLE
107. */
108. public $ole;
110. /**
111. * The constructor
112. *
113. * @access public
114. * @param integer $No The PPS index
115. * @param string $name The PPS name
116. * @param integer $type The PPS type. Dir, Root or File
117. * @param integer $prev The index of the previous PPS
118. * @param integer $next The index of the next PPS
119. * @param integer $dir The index of it's first child if this is a Dir or Root PPS
120. * @param integer $time_1st A timestamp
121. * @param integer $time_2nd A timestamp
122. * @param string $data The (usually binary) source data of the PPS
123. * @param array $children Array containing children PPS for this PPS
124. */
125. public function __construct($No, $name, $type, $prev, $next, $dir, $time_1st, $time_2nd, $data, $children)
126. {
127. $this-> No = $No;
128. $this-> Name = $name;
129. $this-> Type = $type;
130. $this-> PrevPps = $prev;
131. $this-> NextPps = $next;
132. $this-> DirPps = $dir;
133. $this-> Time1st = $time_1st;
134. $this-> Time2nd = $time_2nd;
135. $this->_data = $data;
136. $this-> children = $children;
137. if ($data != '') {
138. $this-> Size = strlen($data);
139. } else {
140. $this-> Size = 0;
141. }
142. }
144. /**
145. * Returns the amount of data saved for this PPS
146. *
147. * @access public
148. * @return integer The amount of data (in bytes)
149. */
150. public function _DataLen()
151. {
152. if (!isset($this->_data)) {
153. return 0;
154. }
155. //if (isset($this->_PPS_FILE)) {
156. // fseek($this->_PPS_FILE, 0);
157. // $stats = fstat($this->_PPS_FILE);
158. // return $stats[7];
159. //} else {
160. return strlen($this->_data);
161. //}
162. }
164. /**
165. * Returns a string with the PPS's WK (What is a WK?)
166. *
167. * @access public
168. * @return string The binary string
169. */
170. public function _getPpsWk()
171. {
172. $ret = str_pad($this-> Name,64,"\x00");
174. $ret .= pack("v", strlen($this-> Name) + 2) // 66
175. . pack("c", $this-> Type) // 67
176. . pack("c", 0x00) //UK // 68
177. . pack("V", $this-> PrevPps) //Prev // 72
178. . pack("V", $this-> NextPps) //Next // 76
179. . pack("V", $this-> DirPps) //Dir // 80
180. . "\x00\x09\x02\x00" // 84
181. . "\x00\x00\x00\x00" // 88
182. . "\xc0\x00\x00\x00" // 92
183. . "\x00\x00\x00\x46" // 96 // Seems to be ok only for Root
184. . "\x00\x00\x00\x00" // 100
185. . PHPExcel_Shared_OLE:: LocalDate2OLE($this-> Time1st) // 108
186. . PHPExcel_Shared_OLE:: LocalDate2OLE($this-> Time2nd) // 116
187. . pack("V", isset($this->_StartBlock)?
188. $this->_StartBlock:0) // 120
189. . pack("V", $this-> Size) // 124
190. . pack("V", 0); // 128
191. return $ret;
192. }
194. /**
195. * Updates index and pointers to previous, next and children PPS's for this
196. * PPS. I don't think it'll work with Dir PPS's.
197. *
198. * @access public
199. * @param array &$pps_array Reference to the array of PPS's for the whole OLE
200. * container
201. * @return integer The index for this PPS
202. */
203. public function _savePpsSetPnt(&$pps_array)
204. {
205. $pps_array[ count($pps_array)] = &$this;
206. $this-> No = count($pps_array) - 1;
207. $this-> PrevPps = 0xFFFFFFFF;
208. $this-> NextPps = 0xFFFFFFFF;
209. if ( count($this-> children) > 0) {
210. $this-> DirPps = $this-> children[0]->_savePpsSetPnt($pps_array);
211. } else {
212. $this-> DirPps = 0xFFFFFFFF;
213. }
214. return $this-> No;
215. }
216. }

Documentation generated on Sun, 27 Feb 2011 16:33:29 -0800 by phpDocumentor 1.4.3