~begerega/ihris-chw-sl/trunk

« back to all changes in this revision

Viewing changes to tools/PHPExcel/PHPExcel/CachedObjectStorage/Memory.php

  • Committer: Ese Egerega
  • Date: 2018-05-03 14:17:04 UTC
  • Revision ID: egerega@gmail.com-20180503141704-3br8dto013rgx65x
Initial import of Sierra Leone  CHW registry

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/**
 
4
 * PHPExcel_CachedObjectStorage_Memory
 
5
 *
 
6
 * Copyright (c) 2006 - 2015 PHPExcel
 
7
 *
 
8
 * This library is free software; you can redistribute it and/or
 
9
 * modify it under the terms of the GNU Lesser General Public
 
10
 * License as published by the Free Software Foundation; either
 
11
 * version 2.1 of the License, or (at your option) any later version.
 
12
 *
 
13
 * This library is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 * Lesser General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU Lesser General Public
 
19
 * License along with this library; if not, write to the Free Software
 
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
21
 *
 
22
 * @category   PHPExcel
 
23
 * @package    PHPExcel_CachedObjectStorage
 
24
 * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
 
25
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
 
26
 * @version    ##VERSION##, ##DATE##
 
27
 */
 
28
class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
 
29
{
 
30
    /**
 
31
     * Dummy method callable from CacheBase, but unused by Memory cache
 
32
     *
 
33
     * @return    void
 
34
     */
 
35
    protected function storeData()
 
36
    {
 
37
    }
 
38
 
 
39
    /**
 
40
     * Add or Update a cell in cache identified by coordinate address
 
41
     *
 
42
     * @param    string            $pCoord        Coordinate address of the cell to update
 
43
     * @param    PHPExcel_Cell    $cell        Cell to update
 
44
     * @return    PHPExcel_Cell
 
45
     * @throws    PHPExcel_Exception
 
46
     */
 
47
    public function addCacheData($pCoord, PHPExcel_Cell $cell)
 
48
    {
 
49
        $this->cellCache[$pCoord] = $cell;
 
50
 
 
51
        //    Set current entry to the new/updated entry
 
52
        $this->currentObjectID = $pCoord;
 
53
 
 
54
        return $cell;
 
55
    }
 
56
 
 
57
 
 
58
    /**
 
59
     * Get cell at a specific coordinate
 
60
     *
 
61
     * @param     string             $pCoord        Coordinate of the cell
 
62
     * @throws     PHPExcel_Exception
 
63
     * @return     PHPExcel_Cell     Cell that was found, or null if not found
 
64
     */
 
65
    public function getCacheData($pCoord)
 
66
    {
 
67
        //    Check if the entry that has been requested actually exists
 
68
        if (!isset($this->cellCache[$pCoord])) {
 
69
            $this->currentObjectID = null;
 
70
            //    Return null if requested entry doesn't exist in cache
 
71
            return null;
 
72
        }
 
73
 
 
74
        //    Set current entry to the requested entry
 
75
        $this->currentObjectID = $pCoord;
 
76
 
 
77
        //    Return requested entry
 
78
        return $this->cellCache[$pCoord];
 
79
    }
 
80
 
 
81
 
 
82
    /**
 
83
     * Clone the cell collection
 
84
     *
 
85
     * @param    PHPExcel_Worksheet    $parent        The new worksheet
 
86
     */
 
87
    public function copyCellCollection(PHPExcel_Worksheet $parent)
 
88
    {
 
89
        parent::copyCellCollection($parent);
 
90
 
 
91
        $newCollection = array();
 
92
        foreach ($this->cellCache as $k => &$cell) {
 
93
            $newCollection[$k] = clone $cell;
 
94
            $newCollection[$k]->attach($this);
 
95
        }
 
96
 
 
97
        $this->cellCache = $newCollection;
 
98
    }
 
99
 
 
100
    /**
 
101
     * Clear the cell collection and disconnect from our parent
 
102
     *
 
103
     */
 
104
    public function unsetWorksheetCells()
 
105
    {
 
106
        // Because cells are all stored as intact objects in memory, we need to detach each one from the parent
 
107
        foreach ($this->cellCache as $k => &$cell) {
 
108
            $cell->detach();
 
109
            $this->cellCache[$k] = null;
 
110
        }
 
111
        unset($cell);
 
112
 
 
113
        $this->cellCache = array();
 
114
 
 
115
        //    detach ourself from the worksheet, so that it can then delete this object successfully
 
116
        $this->parent = null;
 
117
    }
 
118
}