File Source for Memory.php

PHPExcel_CachedObjectStorage

# Source for file Memory.php

Documentation is available at Memory.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_Memory
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_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
38. /**
39. * Add or Update a cell in cache identified by coordinate address
40. *
41. * @param string $pCoord Coordinate address of the cell to update
42. * @param PHPExcel_Cell $cell Cell to update
43. * @return void
44. * @throws Exception
45. */
46. public function addCacheData($pCoord, PHPExcel_Cell $cell) {
47. $this->_cellCache[$pCoord] = $cell;
48. return $cell;
49. } // function addCacheData()
52. /**
53. * Get cell at a specific coordinate
54. *
55. * @param string $pCoord Coordinate of the cell
56. * @throws Exception
57. * @return PHPExcel_Cell Cell that was found, or null if not found
58. */
59. public function getCacheData($pCoord) {
60. // Check if the entry that has been requested actually exists
61. if (!isset($this->_cellCache[$pCoord])) {
62. // Return null if requested entry doesn't exist in cache
63. return null;
64. }
66. // Return requested entry
67. return $this->_cellCache[$pCoord];
68. } // function getCacheData()
71. public function copyCellCollection(PHPExcel_Worksheet $parent) {
72. parent:: copyCellCollection($parent);
74. $newCollection = array();
75. foreach($this->_cellCache as $k => &$cell) {
76. $newCollection[$k] = clone $cell;
77. $newCollection[$k]->attach($parent);
78. }
80. $this->_cellCache = $newCollection;
81. }
84. public function unsetWorksheetCells() {
85. // Because cells are all stored as intact objects in memory, we need to detach each one from the parent
86. foreach($this->_cellCache as $k => &$cell) {
87. $cell->detach();
88. $this->_cellCache[$k] = null;
89. }
90. unset($cell);
92. $this->_cellCache = array();
94. // detach ourself from the worksheet, so that it can then delete this object successfully
95. $this->_parent = null;
96. } // function unsetWorksheetCells()
98. }

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