5
* Copyright (c) 2006 - 2009 PHPExcel
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.
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.
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
23
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
24
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25
* @version 1.7.0, 2009-08-10
29
/** PHPExcel root directory */
30
if (!defined('PHPEXCEL_ROOT')) {
34
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
37
/** PHPExcel_Shared_PasswordHasher */
38
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/PasswordHasher.php';
42
* PHPExcel_DocumentSecurity
46
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
48
class PHPExcel_DocumentSecurity
55
private $_lockRevision;
62
private $_lockStructure;
69
private $_lockWindows;
76
private $_revisionsPassword;
83
private $_workbookPassword;
86
* Create a new PHPExcel_DocumentSecurity
88
public function __construct()
91
$this->_lockRevision = false;
92
$this->_lockStructure = false;
93
$this->_lockWindows = false;
94
$this->_revisionsPassword = '';
95
$this->_workbookPassword = '';
99
* Is some sort of dcument security enabled?
103
function isSecurityEnabled() {
104
return $this->_lockRevision ||
105
$this->_lockStructure ||
114
function getLockRevision() {
115
return $this->_lockRevision;
121
* @param boolean $pValue
122
* @return PHPExcel_DocumentSecurity
124
function setLockRevision($pValue = false) {
125
$this->_lockRevision = $pValue;
134
function getLockStructure() {
135
return $this->_lockStructure;
141
* @param boolean $pValue
142
* @return PHPExcel_DocumentSecurity
144
function setLockStructure($pValue = false) {
145
$this->_lockStructure = $pValue;
154
function getLockWindows() {
155
return $this->_lockWindows;
161
* @param boolean $pValue
162
* @return PHPExcel_DocumentSecurity
164
function setLockWindows($pValue = false) {
165
$this->_lockWindows = $pValue;
170
* Get RevisionsPassword (hashed)
174
function getRevisionsPassword() {
175
return $this->_revisionsPassword;
179
* Set RevisionsPassword
181
* @param string $pValue
182
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
183
* @return PHPExcel_DocumentSecurity
185
function setRevisionsPassword($pValue = '', $pAlreadyHashed = false) {
186
if (!$pAlreadyHashed) {
187
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
189
$this->_revisionsPassword = $pValue;
194
* Get WorkbookPassword (hashed)
198
function getWorkbookPassword() {
199
return $this->_workbookPassword;
203
* Set WorkbookPassword
205
* @param string $pValue
206
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
207
* @return PHPExcel_DocumentSecurity
209
function setWorkbookPassword($pValue = '', $pAlreadyHashed = false) {
210
if (!$pAlreadyHashed) {
211
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
213
$this->_workbookPassword = $pValue;
218
* Implement PHP __clone to create a deep clone, not just a shallow copy.
220
public function __clone() {
221
$vars = get_object_vars($this);
222
foreach ($vars as $key => $value) {
223
if (is_object($value)) {
224
$this->$key = clone $value;
226
$this->$key = $value;