Skip to content

Commit 6c9a907

Browse files
author
Mark Baker
committed
Bugfix: Work item 18145 - Autoshape being identified in twoCellAnchor when includeCharts is TRUE triggering load error
1 parent cf78af2 commit 6c9a907

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

Classes/PHPExcel/Reader/Excel2007.php

+23-22
Original file line numberDiff line numberDiff line change
@@ -51,44 +51,44 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
5151
*
5252
* @var boolean
5353
*/
54-
private $_readDataOnly = false;
54+
private $_readDataOnly = FALSE;
5555

5656
/**
5757
* Read charts that are defined in the workbook?
5858
* Identifies whether the Reader should read the definitions for any charts that exist in the workbook;
5959
*
6060
* @var boolean
6161
*/
62-
private $_includeCharts = false;
62+
private $_includeCharts = FALSE;
6363

6464
/**
6565
* Restrict which sheets should be loaded?
6666
* This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
6767
*
6868
* @var array of string
6969
*/
70-
private $_loadSheetsOnly = null;
70+
private $_loadSheetsOnly = NULL;
7171

7272
/**
7373
* PHPExcel_Reader_IReadFilter instance
7474
*
7575
* @var PHPExcel_Reader_IReadFilter
7676
*/
77-
private $_readFilter = null;
77+
private $_readFilter = NULL;
7878

7979
/**
8080
* PHPExcel_ReferenceHelper instance
8181
*
8282
* @var PHPExcel_ReferenceHelper
8383
*/
84-
private $_referenceHelper = null;
84+
private $_referenceHelper = NULL;
8585

8686
/**
8787
* PHPExcel_Reader_Excel2007_Theme instance
8888
*
8989
* @var PHPExcel_Reader_Excel2007_Theme
9090
*/
91-
private static $_theme = null;
91+
private static $_theme = NULL;
9292

9393

9494
/**
@@ -121,7 +121,7 @@ public function getReadDataOnly() {
121121
*
122122
* @return PHPExcel_Reader_Excel2007
123123
*/
124-
public function setReadDataOnly($pValue = false) {
124+
public function setReadDataOnly($pValue = FALSE) {
125125
$this->_readDataOnly = $pValue;
126126
return $this;
127127
}
@@ -150,7 +150,7 @@ public function getIncludeCharts() {
150150
*
151151
* @return PHPExcel_Reader_Excel2007
152152
*/
153-
public function setIncludeCharts($pValue = false) {
153+
public function setIncludeCharts($pValue = FALSE) {
154154
$this->_includeCharts = (boolean) $pValue;
155155
return $this;
156156
}
@@ -178,7 +178,7 @@ public function getLoadSheetsOnly()
178178
*
179179
* @return PHPExcel_Reader_Excel2007
180180
*/
181-
public function setLoadSheetsOnly($value = null)
181+
public function setLoadSheetsOnly($value = NULL)
182182
{
183183
$this->_loadSheetsOnly = is_array($value) ?
184184
$value : array($value);
@@ -194,7 +194,7 @@ public function setLoadSheetsOnly($value = null)
194194
*/
195195
public function setLoadAllSheets()
196196
{
197-
$this->_loadSheetsOnly = null;
197+
$this->_loadSheetsOnly = NULL;
198198
return $this;
199199
}
200200

@@ -342,11 +342,11 @@ public function listWorksheetInfo($pFilename)
342342

343343
private static function _castToBool($c) {
344344
// echo 'Initial Cast to Boolean<br />';
345-
$value = isset($c->v) ? (string) $c->v : null;
345+
$value = isset($c->v) ? (string) $c->v : NULL;
346346
if ($value == '0') {
347-
return false;
347+
return FALSE;
348348
} elseif ($value == '1') {
349-
return true;
349+
return TRUE;
350350
} else {
351351
return (bool)$c->v;
352352
}
@@ -356,26 +356,26 @@ private static function _castToBool($c) {
356356

357357
private static function _castToError($c) {
358358
// echo 'Initial Cast to Error<br />';
359-
return isset($c->v) ? (string) $c->v : null;;
359+
return isset($c->v) ? (string) $c->v : NULL;
360360
} // function _castToError()
361361

362362

363363
private static function _castToString($c) {
364364
// echo 'Initial Cast to String<br />';
365-
return isset($c->v) ? (string) $c->v : null;;
365+
return isset($c->v) ? (string) $c->v : NULL;
366366
} // function _castToString()
367367

368368

369369
private function _castToFormula($c,$r,&$cellDataType,&$value,&$calculatedValue,&$sharedFormulas,$castBaseType) {
370-
// echo '<font color="darkgreen">Formula</font><br />';
370+
// echo 'Formula<br />';
371371
// echo '$c->f is '.$c->f.'<br />';
372372
$cellDataType = 'f';
373373
$value = "={$c->f}";
374374
$calculatedValue = self::$castBaseType($c);
375375

376376
// Shared formula?
377377
if (isset($c->f['t']) && strtolower((string)$c->f['t']) == 'shared') {
378-
// echo '<font color="darkgreen">SHARED FORMULA</font><br />';
378+
// echo 'SHARED FORMULA<br />';
379379
$instance = (string)$c->f['si'];
380380

381381
// echo 'Instance ID = '.$instance.'<br />';
@@ -384,7 +384,7 @@ private function _castToFormula($c,$r,&$cellDataType,&$value,&$calculatedValue,&
384384
// print_r($sharedFormulas);
385385
// echo '</pre>';
386386
if (!isset($sharedFormulas[(string)$c->f['si']])) {
387-
// echo '<font color="darkgreen">SETTING NEW SHARED FORMULA</font><br />';
387+
// echo 'SETTING NEW SHARED FORMULA<br />';
388388
// echo 'Master is '.$r.'<br />';
389389
// echo 'Formula is '.$value.'<br />';
390390
$sharedFormulas[$instance] = array( 'master' => $r,
@@ -394,7 +394,7 @@ private function _castToFormula($c,$r,&$cellDataType,&$value,&$calculatedValue,&
394394
// print_r($sharedFormulas);
395395
// echo '</pre>';
396396
} else {
397-
// echo '<font color="darkgreen">GETTING SHARED FORMULA</font><br />';
397+
// echo 'GETTING SHARED FORMULA<br />';
398398
// echo 'Master is '.$sharedFormulas[$instance]['master'].'<br />';
399399
// echo 'Formula is '.$sharedFormulas[$instance]['formula'].'<br />';
400400
$master = PHPExcel_Cell::coordinateFromString($sharedFormulas[$instance]['master']);
@@ -1408,7 +1408,7 @@ public function load($pFilename)
14081408

14091409
}
14101410

1411-
// TODO: Make sure drawings and graph are loaded differently!
1411+
// TODO: Autoshapes from twoCellAnchors!
14121412
if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
14131413
$relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships");
14141414
$drawings = array();
@@ -1469,6 +1469,7 @@ public function load($pFilename)
14691469
}
14701470
$objDrawing->setWorksheet($docSheet);
14711471
} else {
1472+
// ? Can charts be positioned with a oneCellAnchor ?
14721473
$coordinates = PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1);
14731474
$offsetX = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff);
14741475
$offsetY = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff);
@@ -1509,7 +1510,7 @@ public function load($pFilename)
15091510
$shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(), "val") / 1000);
15101511
}
15111512
$objDrawing->setWorksheet($docSheet);
1512-
} elseif($this->_includeCharts) {
1513+
} elseif(($this->_includeCharts) && ($twoCellAnchor->graphicFrame)) {
15131514
$fromCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1);
15141515
$fromOffsetX = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff);
15151516
$fromOffsetY = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff);
@@ -1733,7 +1734,7 @@ public function load($pFilename)
17331734
}
17341735

17351736

1736-
private static function _readColor($color, $background=false) {
1737+
private static function _readColor($color, $background=FALSE) {
17371738
if (isset($color["rgb"])) {
17381739
return (string)$color["rgb"];
17391740
} else if (isset($color["indexed"])) {

changelog.txt

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ Fixed in develop branch:
9999
- Bugfix: (MBaker) Fix to Excel5 Reader when cell annotations are defined before their referenced text objects
100100
- Bugfix: (MBaker) OOCalc Reader modified to process number-rows-repeated
101101
- Bugfix: (MBaker) Work item 18377 - Chart Title compatibility on Excel 2007
102+
- Bugfix: (MBaker) Work item 18146 - Chart Refresh returning cell reference rather than values
103+
- Bugfix: (MBaker) Work item 18145 - Autoshape being identified in twoCellAnchor when includeCharts is TRUE triggering load error
102104

103105

104106
2012-05-19 (v1.7.7):

0 commit comments

Comments
 (0)