File Source for MemoryGZip.php

PHPExcel_CachedObjectStorage

# Source for file MemoryGZip.php

Documentation is available at MemoryGZip.php

1. <?php
2. /**
3. * PHPExcel
4. *
5. * Copyright (c) 2006 - 2011 PHPExcel
6. *
7. * This library is free software; you can redistribute it and/or
8. * modify it under the terms of the GNU Lesser General Public
9. * License as published by the Free Software Foundation; either
10. * version 2.1 of the License, or (at your option) any later version.
11. *
12. * This library is distributed in the hope that it will be useful,
13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15. * Lesser General Public License for more details.
16. *
17. * You should have received a copy of the GNU Lesser General Public
18. * License along with this library; if not, write to the Free Software
19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20. *
21. * @category PHPExcel
22. * @package PHPExcel_CachedObjectStorage
23. * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25. * @version 1.7.6, 2011-02-27
26. */
29. /**
30. * PHPExcel_CachedObjectStorage_MemoryGZip
31. *
32. * @category PHPExcel
33. * @package PHPExcel_CachedObjectStorage
34. * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
35. */
36. class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
38. private function _storeData() {
39. $this->_currentObject->detach();
41. $this->_cellCache[$this->_currentObjectID] = gzdeflate( serialize($this->_currentObject));
42. $this->_currentObjectID = $this->_currentObject = null;
43. } // function _storeData()
46. /**
47. * Add or Update a cell in cache identified by coordinate address
48. *
49. * @param string $pCoord Coordinate address of the cell to update
50. * @param PHPExcel_Cell $cell Cell to update
51. * @return void
52. * @throws Exception
53. */
54. public function addCacheData($pCoord, PHPExcel_Cell $cell) {
55. if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
56. $this->_storeData();
57. }
59. $this->_currentObjectID = $pCoord;
60. $this->_currentObject = $cell;
62. return $cell;
63. } // function addCacheData()
66. /**
67. * Get cell at a specific coordinate
68. *
69. * @param string $pCoord Coordinate of the cell
70. * @throws Exception
71. * @return PHPExcel_Cell Cell that was found, or null if not found
72. */
73. public function getCacheData($pCoord) {
74. if ($pCoord === $this->_currentObjectID) {
75. return $this->_currentObject;
76. }
77. $this->_storeData();
79. // Check if the entry that has been requested actually exists
80. if (!isset($this->_cellCache[$pCoord])) {
81. // Return null if requested entry doesn't exist in cache
82. return null;
83. }
85. // Set current entry to the requested entry
86. $this->_currentObjectID = $pCoord;
87. $this->_currentObject = unserialize( gzinflate($this->_cellCache[$pCoord]));
88. // Re-attach the parent worksheet
89. $this->_currentObject->attach($this->_parent);
91. // Return requested entry
92. return $this->_currentObject;
93. } // function getCacheData()
96. public function unsetWorksheetCells() {
97. if(! is_null($this->_currentObject)) {
98. $this->_currentObject->detach();
99. $this->_currentObject = $this->_currentObjectID = null;
100. }
101. $this->_cellCache = array();
103. // detach ourself from the worksheet, so that it can then delete this object successfully
104. $this->_parent = null;
105. } // function unsetWorksheetCells()
107. }

Documentation generated on Sun, 27 Feb 2011 16:32:47 -0800 by phpDocumentor 1.4.3