Skip to content

Commit 4e8dea7

Browse files
author
Dominik Bonsch
committed
Merge remote-tracking branch 'origin/experimental' into develop
2 parents 49783ef + 2863152 commit 4e8dea7

File tree

5 files changed

+705
-687
lines changed

5 files changed

+705
-687
lines changed

Classes/PHPExcel.php

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ public function sheetNameExists($pSheetName)
227227
public function addSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = NULL)
228228
{
229229
if ($this->sheetNameExists($pSheet->getTitle())) {
230-
throw new PHPExcel_Exception("Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename this worksheet first.");
230+
throw new PHPExcel_Exception(
231+
"Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename this worksheet first."
232+
);
231233
}
232234

233235
if($iSheetIndex === NULL) {
@@ -260,8 +262,13 @@ public function addSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = NULL)
260262
*/
261263
public function removeSheetByIndex($pIndex = 0)
262264
{
263-
if ($pIndex > count($this->_workSheetCollection) - 1) {
264-
throw new PHPExcel_Exception("Sheet index is out of bounds.");
265+
266+
$numSheets = count($this->_workSheetCollection);
267+
268+
if ($pIndex > $numSheets - 1) {
269+
throw new PHPExcel_Exception(
270+
"You tried to remove a sheet by the out of bounds index: {$pIndex}. The actual number of sheets is {$numSheets}."
271+
);
265272
} else {
266273
array_splice($this->_workSheetCollection, $pIndex, 1);
267274
}
@@ -282,8 +289,13 @@ public function removeSheetByIndex($pIndex = 0)
282289
*/
283290
public function getSheet($pIndex = 0)
284291
{
285-
if ($pIndex > count($this->_workSheetCollection) - 1) {
286-
throw new PHPExcel_Exception("Sheet index is out of bounds.");
292+
293+
$numSheets = count($this->_workSheetCollection);
294+
295+
if ($pIndex > $numSheets - 1) {
296+
throw new PHPExcel_Exception(
297+
"Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}."
298+
);
287299
} else {
288300
return $this->_workSheetCollection[$pIndex];
289301
}
@@ -389,8 +401,12 @@ public function getActiveSheetIndex()
389401
*/
390402
public function setActiveSheetIndex($pIndex = 0)
391403
{
392-
if ($pIndex > count($this->_workSheetCollection) - 1) {
393-
throw new PHPExcel_Exception("Active sheet index is out of bounds.");
404+
$numSheets = count($this->_workSheetCollection);
405+
406+
if ($pIndex > $numSheets - 1) {
407+
throw new PHPExcel_Exception(
408+
"You tried to set a sheet active by the out of bounds index: {$pIndex}. The actual number of sheets is {$numSheets}."
409+
);
394410
} else {
395411
$this->_activeSheetIndex = $pIndex;
396412
}

Classes/PHPExcel/Comment.php

Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @category PHPExcel
2222
* @package PHPExcel
2323
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
24-
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
24+
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
2525
* @version ##VERSION##, ##DATE##
2626
*/
2727

@@ -35,68 +35,68 @@
3535
*/
3636
class PHPExcel_Comment implements PHPExcel_IComparable
3737
{
38-
/**
39-
* Author
40-
*
41-
* @var string
42-
*/
43-
private $_author;
38+
/**
39+
* Author
40+
*
41+
* @var string
42+
*/
43+
private $_author;
4444

45-
/**
46-
* Rich text comment
47-
*
48-
* @var PHPExcel_RichText
49-
*/
50-
private $_text;
45+
/**
46+
* Rich text comment
47+
*
48+
* @var PHPExcel_RichText
49+
*/
50+
private $_text;
5151

52-
/**
53-
* Comment width (CSS style, i.e. XXpx or YYpt)
54-
*
55-
* @var string
56-
*/
57-
private $_width = '96pt';
52+
/**
53+
* Comment width (CSS style, i.e. XXpx or YYpt)
54+
*
55+
* @var string
56+
*/
57+
private $_width = '96pt';
5858

59-
/**
60-
* Left margin (CSS style, i.e. XXpx or YYpt)
61-
*
62-
* @var string
63-
*/
64-
private $_marginLeft = '59.25pt';
59+
/**
60+
* Left margin (CSS style, i.e. XXpx or YYpt)
61+
*
62+
* @var string
63+
*/
64+
private $_marginLeft = '59.25pt';
6565

66-
/**
67-
* Top margin (CSS style, i.e. XXpx or YYpt)
68-
*
69-
* @var string
70-
*/
71-
private $_marginTop = '1.5pt';
66+
/**
67+
* Top margin (CSS style, i.e. XXpx or YYpt)
68+
*
69+
* @var string
70+
*/
71+
private $_marginTop = '1.5pt';
7272

73-
/**
74-
* Visible
75-
*
76-
* @var boolean
77-
*/
78-
private $_visible = false;
73+
/**
74+
* Visible
75+
*
76+
* @var boolean
77+
*/
78+
private $_visible = false;
7979

80-
/**
81-
* Comment height (CSS style, i.e. XXpx or YYpt)
82-
*
83-
* @var string
84-
*/
85-
private $_height = '55.5pt';
80+
/**
81+
* Comment height (CSS style, i.e. XXpx or YYpt)
82+
*
83+
* @var string
84+
*/
85+
private $_height = '55.5pt';
8686

87-
/**
88-
* Comment fill color
89-
*
90-
* @var PHPExcel_Style_Color
91-
*/
92-
private $_fillColor;
87+
/**
88+
* Comment fill color
89+
*
90+
* @var PHPExcel_Style_Color
91+
*/
92+
private $_fillColor;
9393

94-
/**
95-
* Alignment
96-
*
97-
* @var string
98-
*/
99-
private $_alignment;
94+
/**
95+
* Alignment
96+
*
97+
* @var string
98+
*/
99+
private $_alignment;
100100

101101
/**
102102
* Create a new PHPExcel_Comment
@@ -105,11 +105,11 @@ class PHPExcel_Comment implements PHPExcel_IComparable
105105
*/
106106
public function __construct()
107107
{
108-
// Initialise variables
109-
$this->_author = 'Author';
110-
$this->_text = new PHPExcel_RichText();
111-
$this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1');
112-
$this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
108+
// Initialise variables
109+
$this->_author = 'Author';
110+
$this->_text = new PHPExcel_RichText();
111+
$this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1');
112+
$this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
113113
}
114114

115115
/**
@@ -118,7 +118,7 @@ public function __construct()
118118
* @return string
119119
*/
120120
public function getAuthor() {
121-
return $this->_author;
121+
return $this->_author;
122122
}
123123

124124
/**
@@ -127,18 +127,18 @@ public function getAuthor() {
127127
* @param string $pValue
128128
* @return PHPExcel_Comment
129129
*/
130-
public function setAuthor($pValue = '') {
131-
$this->_author = $pValue;
132-
return $this;
133-
}
130+
public function setAuthor($pValue = '') {
131+
$this->_author = $pValue;
132+
return $this;
133+
}
134134

135135
/**
136136
* Get Rich text comment
137137
*
138138
* @return PHPExcel_RichText
139139
*/
140140
public function getText() {
141-
return $this->_text;
141+
return $this->_text;
142142
}
143143

144144
/**
@@ -148,8 +148,8 @@ public function getText() {
148148
* @return PHPExcel_Comment
149149
*/
150150
public function setText(PHPExcel_RichText $pValue) {
151-
$this->_text = $pValue;
152-
return $this;
151+
$this->_text = $pValue;
152+
return $this;
153153
}
154154

155155
/**
@@ -268,8 +268,8 @@ public function getFillColor() {
268268
* @return PHPExcel_Comment
269269
*/
270270
public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) {
271-
$this->_alignment = $pValue;
272-
return $this;
271+
$this->_alignment = $pValue;
272+
return $this;
273273
}
274274

275275
/**
@@ -278,40 +278,40 @@ public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENE
278278
* @return string
279279
*/
280280
public function getAlignment() {
281-
return $this->_alignment;
281+
return $this->_alignment;
282282
}
283283

284-
/**
285-
* Get hash code
286-
*
287-
* @return string Hash code
288-
*/
289-
public function getHashCode() {
290-
return md5(
291-
$this->_author
292-
. $this->_text->getHashCode()
293-
. $this->_width
294-
. $this->_height
295-
. $this->_marginLeft
296-
. $this->_marginTop
297-
. ($this->_visible ? 1 : 0)
298-
. $this->_fillColor->getHashCode()
299-
. $this->_alignment
300-
. __CLASS__
301-
);
284+
/**
285+
* Get hash code
286+
*
287+
* @return string Hash code
288+
*/
289+
public function getHashCode() {
290+
return md5(
291+
$this->_author
292+
. $this->_text->getHashCode()
293+
. $this->_width
294+
. $this->_height
295+
. $this->_marginLeft
296+
. $this->_marginTop
297+
. ($this->_visible ? 1 : 0)
298+
. $this->_fillColor->getHashCode()
299+
. $this->_alignment
300+
. __CLASS__
301+
);
302302
}
303303

304-
/**
305-
* Implement PHP __clone to create a deep clone, not just a shallow copy.
306-
*/
307-
public function __clone() {
308-
$vars = get_object_vars($this);
309-
foreach ($vars as $key => $value) {
310-
if (is_object($value)) {
311-
$this->$key = clone $value;
312-
} else {
313-
$this->$key = $value;
314-
}
315-
}
316-
}
304+
/**
305+
* Implement PHP __clone to create a deep clone, not just a shallow copy.
306+
*/
307+
public function __clone() {
308+
$vars = get_object_vars($this);
309+
foreach ($vars as $key => $value) {
310+
if (is_object($value)) {
311+
$this->$key = clone $value;
312+
} else {
313+
$this->$key = $value;
314+
}
315+
}
316+
}
317317
}

0 commit comments

Comments
 (0)