Start work on namespacing Reader classes

This commit is contained in:
MarkBaker 2015-05-31 23:24:19 +01:00
parent a39e15f49d
commit ebca5d1a57
13 changed files with 353 additions and 670 deletions

View File

@ -1,253 +0,0 @@
<?php
/**
* PHPExcel_Reader_Abstract
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{
/**
* Read data only?
* Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
* or whether it should read both data and formatting
*
* @var boolean
*/
protected $readDataOnly = false;
/**
* Read charts that are defined in the workbook?
* Identifies whether the Reader should read the definitions for any charts that exist in the workbook;
*
* @var boolean
*/
protected $includeCharts = false;
/**
* Restrict which sheets should be loaded?
* This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
*
* @var array of string
*/
protected $loadSheetsOnly;
/**
* PHPExcel_Reader_IReadFilter instance
*
* @var PHPExcel_Reader_IReadFilter
*/
protected $readFilter;
protected $fileHandle = null;
/**
* Read data only?
* If this is true, then the Reader will only read data values for cells, it will not read any formatting information.
* If false (the default) it will read data and formatting.
*
* @return boolean
*/
public function getReadDataOnly()
{
return $this->readDataOnly;
}
/**
* Set read data only
* Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information.
* Set to false (the default) to advise the Reader to read both data and formatting for cells.
*
* @param boolean $pValue
*
* @return PHPExcel_Reader_IReader
*/
public function setReadDataOnly($pValue = false)
{
$this->readDataOnly = $pValue;
return $this;
}
/**
* Read charts in workbook?
* If this is true, then the Reader will include any charts that exist in the workbook.
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
* If false (the default) it will ignore any charts defined in the workbook file.
*
* @return boolean
*/
public function getIncludeCharts()
{
return $this->includeCharts;
}
/**
* Set read charts in workbook
* Set to true, to advise the Reader to include any charts that exist in the workbook.
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
* Set to false (the default) to discard charts.
*
* @param boolean $pValue
*
* @return PHPExcel_Reader_IReader
*/
public function setIncludeCharts($pValue = false)
{
$this->includeCharts = (boolean) $pValue;
return $this;
}
/**
* Get which sheets to load
* Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
* indicating that all worksheets in the workbook should be loaded.
*
* @return mixed
*/
public function getLoadSheetsOnly()
{
return $this->loadSheetsOnly;
}
/**
* Set which sheets to load
*
* @param mixed $value
* This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
* If NULL, then it tells the Reader to read all worksheets in the workbook
*
* @return PHPExcel_Reader_IReader
*/
public function setLoadSheetsOnly($value = null)
{
if ($value === null) {
return $this->setLoadAllSheets();
}
$this->loadSheetsOnly = is_array($value) ? $value : array($value);
return $this;
}
/**
* Set all sheets to load
* Tells the Reader to load all worksheets from the workbook.
*
* @return PHPExcel_Reader_IReader
*/
public function setLoadAllSheets()
{
$this->loadSheetsOnly = null;
return $this;
}
/**
* Read filter
*
* @return PHPExcel_Reader_IReadFilter
*/
public function getReadFilter()
{
return $this->readFilter;
}
/**
* Set read filter
*
* @param PHPExcel_Reader_IReadFilter $pValue
* @return PHPExcel_Reader_IReader
*/
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue)
{
$this->readFilter = $pValue;
return $this;
}
/**
* Open file for reading
*
* @param string $pFilename
* @throws PHPExcel_Reader_Exception
* @return resource
*/
protected function openFile($pFilename)
{
// Check if file exists
if (!file_exists($pFilename) || !is_readable($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Open file
$this->fileHandle = fopen($pFilename, 'r');
if ($this->fileHandle === false) {
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading.");
}
}
/**
* Can the current PHPExcel_Reader_IReader read the file?
*
* @param string $pFilename
* @return boolean
* @throws PHPExcel_Reader_Exception
*/
public function canRead($pFilename)
{
// Check if file exists
try {
$this->openFile($pFilename);
} catch (Exception $e) {
return false;
}
$readable = $this->isValidFormat();
fclose($this->fileHandle);
return $readable;
}
/**
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
*
* @param string $xml
* @throws PHPExcel_Reader_Exception
*/
public function securityScan($xml)
{
$pattern = '/\\0?' . implode('\\0?', str_split('<!DOCTYPE')) . '\\0?/';
if (preg_match($pattern, $xml)) {
throw new PHPExcel_Reader_Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
}
return $xml;
}
/**
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
*
* @param string $filestream
* @throws PHPExcel_Reader_Exception
*/
public function securityScanFile($filestream)
{
return $this->securityScan(file_get_contents($filestream));
}
}

View File

@ -1,13 +1,6 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
namespace PHPExcel\Reader;
/**
* PHPExcel_Reader_CSV
@ -34,7 +27,7 @@ if (!defined('PHPEXCEL_ROOT')) {
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
class CSV extends BaseReader implements IReader
{
/**
* Input encoding
@ -85,11 +78,11 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
/**
* Create a new PHPExcel_Reader_CSV
* Create a new CSV
*/
public function __construct()
{
$this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
$this->readFilter = new DefaultReadFilter();
}
/**
@ -161,7 +154,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
*
* @param string $pFilename
* @throws PHPExcel_Reader_Exception
* @throws Exception
*/
public function listWorksheetInfo($pFilename)
{
@ -169,7 +162,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
$this->openFile($pFilename);
if (!$this->isValidFormat()) {
fclose($this->fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
throw new Exception($pFilename . " is an Invalid Spreadsheet file.");
}
$fileHandle = $this->fileHandle;
@ -191,7 +184,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], count($rowData) - 1);
}
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
$worksheetInfo[0]['lastColumnLetter'] = \PHPExcel\Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
// Close file
@ -205,7 +198,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
*
* @param string $pFilename
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
* @throws Exception
*/
public function load($pFilename)
{
@ -222,7 +215,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
* @throws Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
@ -233,7 +226,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
$this->openFile($pFilename);
if (!$this->isValidFormat()) {
fclose($this->fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
throw new Exception($pFilename . " is an Invalid Spreadsheet file.");
}
$fileHandle = $this->fileHandle;
@ -266,7 +259,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
// Convert encoding if necessary
if ($this->inputEncoding !== 'UTF-8') {
$rowDatum = PHPExcel_Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->inputEncoding);
$rowDatum = \PHPExcel\Shared\String::ConvertEncoding($rowDatum, 'UTF-8', $this->inputEncoding);
}
// Set cell value
@ -304,7 +297,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* Set delimiter
*
* @param string $pValue Delimiter, defaults to ,
* @return PHPExcel_Reader_CSV
* @return CSV
*/
public function setDelimiter($pValue = ',')
{
@ -326,7 +319,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* Set enclosure
*
* @param string $pValue Enclosure, defaults to "
* @return PHPExcel_Reader_CSV
* @return CSV
*/
public function setEnclosure($pValue = '"')
{
@ -351,7 +344,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* Set sheet index
*
* @param integer $pValue Sheet index
* @return PHPExcel_Reader_CSV
* @return CSV
*/
public function setSheetIndex($pValue = 0)
{

View File

@ -1,13 +1,6 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
namespace PHPExcel\Reader;
/**
* PHPExcel_Reader_DefaultReadFilter
@ -34,7 +27,7 @@ if (!defined('PHPEXCEL_ROOT')) {
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter
class DefaultReadFilter implements IReadFilter
{
/**
* Should this cell be read?

View File

@ -1,13 +1,6 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
namespace PHPExcel\Reader;
/**
* PHPExcel_Reader_Excel2003XML
@ -34,7 +27,7 @@ if (!defined('PHPEXCEL_ROOT')) {
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
class Excel2003XML extends BaseReader implements IReader
{
/**
* Formats

View File

@ -1,13 +1,6 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
namespace PHPExcel\Reader;
/**
* PHPExcel_Reader_Excel2007
@ -34,7 +27,7 @@ if (!defined('PHPEXCEL_ROOT')) {
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
class Excel2007 extends BaseReader implements IReader
{
/**
* PHPExcel_ReferenceHelper instance

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,7 @@
<?php
namespace PHPExcel\Reader;
/**
* PHPExcel_Reader_Exception
*
@ -25,7 +27,7 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Reader_Exception extends PHPExcel_Exception
class Exception extends \PHPExcel\Exception
{
/**
* Error handler callback

View File

@ -1,13 +1,6 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
namespace PHPExcel\Reader;
/**
* PHPExcel_Reader_Gnumeric
@ -34,7 +27,7 @@ if (!defined('PHPEXCEL_ROOT')) {
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
class Gnumeric extends BaseReader implements IReader
{
/**
* Formats
@ -53,31 +46,31 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
private $referenceHelper = null;
/**
* Create a new PHPExcel_Reader_Gnumeric
* Create a new Gnumeric
*/
public function __construct()
{
$this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
$this->referenceHelper = PHPExcel_ReferenceHelper::getInstance();
$this->readFilter = new DefaultReadFilter();
$this->referenceHelper = \PHPExcel\ReferenceHelper::getInstance();
}
/**
* Can the current PHPExcel_Reader_IReader read the file?
* Can the current IReader read the file?
*
* @param string $pFilename
* @return boolean
* @throws PHPExcel_Reader_Exception
* @throws Exception
*/
public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Check if gzlib functions are available
if (!function_exists('gzread')) {
throw new PHPExcel_Reader_Exception("gzlib library is not enabled");
throw new Exception("gzlib library is not enabled");
}
// Read signature data (first 3 bytes)
@ -96,17 +89,17 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
*
* @param string $pFilename
* @throws PHPExcel_Reader_Exception
* @throws Exception
*/
public function listWorksheetNames($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$xml = new XMLReader();
$xml->xml($this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions());
$xml->xml($this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, \PHPExcel\Settings::getLibXmlLoaderOptions());
$xml->setParserProperty(2, true);
$worksheetNames = array();
@ -127,17 +120,17 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
*
* @param string $pFilename
* @throws PHPExcel_Reader_Exception
* @throws Exception
*/
public function listWorksheetInfo($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$xml = new XMLReader();
$xml->xml($this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions());
$xml->xml($this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, \PHPExcel\Settings::getLibXmlLoaderOptions());
$xml->setParserProperty(2, true);
$worksheetInfo = array();
@ -165,7 +158,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
break;
}
}
$tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
$tmpInfo['lastColumnLetter'] = \PHPExcel\Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
$worksheetInfo[] = $tmpInfo;
}
}
@ -191,7 +184,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
*
* @param string $pFilename
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
* @throws Exception
*/
public function load($pFilename)
{
@ -208,13 +201,13 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
* @throws Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$timezoneObj = new DateTimeZone('Europe/London');
@ -226,7 +219,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// echo htmlentities($gFileData,ENT_QUOTES,'UTF-8');
// echo '</pre><hr />';
//
$xml = simplexml_load_string($this->securityScan($gFileData), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$xml = simplexml_load_string($this->securityScan($gFileData), 'SimpleXMLElement', \PHPExcel\Settings::getLibXmlLoaderOptions());
$namespacesMeta = $xml->getNamespaces(true);
// var_dump($namespacesMeta);
@ -400,7 +393,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$maxCol = $column;
}
$column = PHPExcel_Cell::stringFromColumnIndex($column);
$column = \PHPExcel\Cell::stringFromColumnIndex($column);
// Read cell?
if ($this->getReadFilter() !== null) {
@ -414,7 +407,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// echo 'Cell ', $column, $row,'<br />';
// echo 'Type is ', $ValueType,'<br />';
// echo 'Value is ', $cell,'<br />';
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
$type = \PHPExcel\Cell\DataType::TYPE_FORMULA;
if ($ExprID > '') {
if (((string) $cell) > '') {
$this->expressions[$ExprID] = array(
@ -436,27 +429,27 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// echo 'SHARED EXPRESSION ', $ExprID,'<br />';
// echo 'New Value is ', $cell,'<br />';
}
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
$type = \PHPExcel\Cell\DataType::TYPE_FORMULA;
} else {
switch ($ValueType) {
case '10': // NULL
$type = PHPExcel_Cell_DataType::TYPE_NULL;
$type = \PHPExcel\Cell\DataType::TYPE_NULL;
break;
case '20': // Boolean
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
$type = \PHPExcel\Cell\DataType::TYPE_BOOL;
$cell = ($cell == 'TRUE') ? true: false;
break;
case '30': // Integer
$cell = intval($cell);
// Excel 2007+ doesn't differentiate between integer and float, so set the value and dropthru to the next (numeric) case
case '40': // Float
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$type = \PHPExcel\Cell\DataType::TYPE_NUMERIC;
break;
case '50': // Error
$type = PHPExcel_Cell_DataType::TYPE_ERROR;
$type = \PHPExcel\Cell\DataType::TYPE_ERROR;
break;
case '60': // String
$type = PHPExcel_Cell_DataType::TYPE_STRING;
$type = \PHPExcel\Cell\DataType::TYPE_STRING;
break;
case '70': // Cell Range
case '80': // Array
@ -480,11 +473,11 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$styleAttributes = $styleRegion->attributes();
if (($styleAttributes['startRow'] <= $maxRow) &&
($styleAttributes['startCol'] <= $maxCol)) {
$startColumn = PHPExcel_Cell::stringFromColumnIndex((int) $styleAttributes['startCol']);
$startColumn = \PHPExcel\Cell::stringFromColumnIndex((int) $styleAttributes['startCol']);
$startRow = $styleAttributes['startRow'] + 1;
$endColumn = ($styleAttributes['endCol'] > $maxCol) ? $maxCol : (int) $styleAttributes['endCol'];
$endColumn = PHPExcel_Cell::stringFromColumnIndex($endColumn);
$endColumn = \PHPExcel\Cell::stringFromColumnIndex($endColumn);
$endRow = ($styleAttributes['endRow'] > $maxRow) ? $maxRow : $styleAttributes['endRow'];
$endRow += 1;
$cellRange = $startColumn.$startRow.':'.$endColumn.$endRow;
@ -496,45 +489,45 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// We still set the number format mask for date/time values, even if readDataOnly is true
if ((!$this->readDataOnly) ||
(PHPExcel_Shared_Date::isDateTimeFormatCode((string) $styleAttributes['Format']))) {
(\PHPExcel\Shared\Date::isDateTimeFormatCode((string) $styleAttributes['Format']))) {
$styleArray = array();
$styleArray['numberformat']['code'] = (string) $styleAttributes['Format'];
// If readDataOnly is false, we set all formatting information
if (!$this->readDataOnly) {
switch ($styleAttributes['HAlign']) {
case '1':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
$styleArray['alignment']['horizontal'] = \PHPExcel\Style\Alignment::HORIZONTAL_GENERAL;
break;
case '2':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_LEFT;
$styleArray['alignment']['horizontal'] = \PHPExcel\Style\Alignment::HORIZONTAL_LEFT;
break;
case '4':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_RIGHT;
$styleArray['alignment']['horizontal'] = \PHPExcel\Style\Alignment::HORIZONTAL_RIGHT;
break;
case '8':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER;
$styleArray['alignment']['horizontal'] = \PHPExcel\Style\Alignment::HORIZONTAL_CENTER;
break;
case '16':
case '64':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS;
$styleArray['alignment']['horizontal'] = \PHPExcel\Style\Alignment::HORIZONTAL_CENTER_CONTINUOUS;
break;
case '32':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY;
$styleArray['alignment']['horizontal'] = \PHPExcel\Style\Alignment::HORIZONTAL_JUSTIFY;
break;
}
switch ($styleAttributes['VAlign']) {
case '1':
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_TOP;
$styleArray['alignment']['vertical'] = \PHPExcel\Style\Alignment::VERTICAL_TOP;
break;
case '2':
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
$styleArray['alignment']['vertical'] = \PHPExcel\Style\Alignment::VERTICAL_BOTTOM;
break;
case '4':
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_CENTER;
$styleArray['alignment']['vertical'] = \PHPExcel\Style\Alignment::VERTICAL_CENTER;
break;
case '8':
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_JUSTIFY;
$styleArray['alignment']['vertical'] = \PHPExcel\Style\Alignment::VERTICAL_JUSTIFY;
break;
}
@ -552,64 +545,64 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$styleArray['fill']['endcolor']['rgb'] = $RGB2;
switch ($shade) {
case '1':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_SOLID;
break;
case '2':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_GRADIENT_LINEAR;
break;
case '3':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_GRADIENT_PATH;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_GRADIENT_PATH;
break;
case '4':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_PATTERN_DARKDOWN;
break;
case '5':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_PATTERN_DARKGRAY;
break;
case '6':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_PATTERN_DARKGRID;
break;
case '7':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_PATTERN_DARKHORIZONTAL;
break;
case '8':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_PATTERN_DARKTRELLIS;
break;
case '9':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKUP;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_PATTERN_DARKUP;
break;
case '10':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_PATTERN_DARKVERTICAL;
break;
case '11':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_PATTERN_GRAY0625;
break;
case '12':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_GRAY125;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_PATTERN_GRAY125;
break;
case '13':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_PATTERN_LIGHTDOWN;
break;
case '14':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_PATTERN_LIGHTGRAY;
break;
case '15':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_PATTERN_LIGHTGRID;
break;
case '16':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_PATTERN_LIGHTHORIZONTAL;
break;
case '17':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_PATTERN_LIGHTTRELLIS;
break;
case '18':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_PATTERN_LIGHTUP;
break;
case '19':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_PATTERN_LIGHTVERTICAL;
break;
case '20':
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY;
$styleArray['fill']['type'] = \PHPExcel\Style\Fill::FILL_PATTERN_MEDIUMGRAY;
break;
}
}
@ -624,19 +617,19 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? true : false;
switch ($fontAttributes['Underline']) {
case '1':
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLE;
$styleArray['font']['underline'] = \PHPExcel\Style\Font::UNDERLINE_SINGLE;
break;
case '2':
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLE;
$styleArray['font']['underline'] = \PHPExcel\Style\Font::UNDERLINE_DOUBLE;
break;
case '3':
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING;
$styleArray['font']['underline'] = \PHPExcel\Style\Font::UNDERLINE_SINGLEACCOUNTING;
break;
case '4':
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING;
$styleArray['font']['underline'] = \PHPExcel\Style\Font::UNDERLINE_DOUBLEACCOUNTING;
break;
default:
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_NONE;
$styleArray['font']['underline'] = \PHPExcel\Style\Font::UNDERLINE_NONE;
break;
}
switch ($fontAttributes['Script']) {
@ -663,13 +656,13 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
}
if ((isset($styleRegion->Style->StyleBorder->Diagonal)) && (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}))) {
$styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes());
$styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_BOTH;
$styleArray['borders']['diagonaldirection'] = \PHPExcel\Style\Borders::DIAGONAL_BOTH;
} elseif (isset($styleRegion->Style->StyleBorder->Diagonal)) {
$styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes());
$styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_UP;
$styleArray['borders']['diagonaldirection'] = \PHPExcel\Style\Borders::DIAGONAL_UP;
} elseif (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'})) {
$styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}->attributes());
$styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_DOWN;
$styleArray['borders']['diagonaldirection'] = \PHPExcel\Style\Borders::DIAGONAL_DOWN;
}
}
if (isset($styleRegion->Style->HyperLink)) {
@ -696,19 +689,19 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$hidden = ((isset($columnAttributes['Hidden'])) && ($columnAttributes['Hidden'] == '1')) ? true : false;
$columnCount = (isset($columnAttributes['Count'])) ? $columnAttributes['Count'] : 1;
while ($c < $column) {
$objPHPExcel->getActiveSheet()->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($c))->setWidth($defaultWidth);
$objPHPExcel->getActiveSheet()->getColumnDimension(\PHPExcel\Cell::stringFromColumnIndex($c))->setWidth($defaultWidth);
++$c;
}
while (($c < ($column+$columnCount)) && ($c <= $maxCol)) {
$objPHPExcel->getActiveSheet()->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($c))->setWidth($columnWidth);
$objPHPExcel->getActiveSheet()->getColumnDimension(\PHPExcel\Cell::stringFromColumnIndex($c))->setWidth($columnWidth);
if ($hidden) {
$objPHPExcel->getActiveSheet()->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($c))->setVisible(false);
$objPHPExcel->getActiveSheet()->getColumnDimension(\PHPExcel\Cell::stringFromColumnIndex($c))->setVisible(false);
}
++$c;
}
}
while ($c <= $maxCol) {
$objPHPExcel->getActiveSheet()->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($c))->setWidth($defaultWidth);
$objPHPExcel->getActiveSheet()->getColumnDimension(\PHPExcel\Cell::stringFromColumnIndex($c))->setWidth($defaultWidth);
++$c;
}
}
@ -768,7 +761,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$range[0] = trim($range[0], "'");
if ($worksheet = $objPHPExcel->getSheetByName($range[0])) {
$extractedRange = str_replace('$', '', $range[1]);
$objPHPExcel->addNamedRange(new PHPExcel_NamedRange($name, $worksheet, $extractedRange));
$objPHPExcel->addNamedRange(new \PHPExcel\NamedRange($name, $worksheet, $extractedRange));
}
}
}
@ -786,46 +779,46 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
switch ($borderAttributes["Style"]) {
case '0':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_NONE;
$styleArray['style'] = \PHPExcel\Style\Border::BORDER_NONE;
break;
case '1':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_THIN;
$styleArray['style'] = \PHPExcel\Style\Border::BORDER_THIN;
break;
case '2':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUM;
$styleArray['style'] = \PHPExcel\Style\Border::BORDER_MEDIUM;
break;
case '3':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_SLANTDASHDOT;
$styleArray['style'] = \PHPExcel\Style\Border::BORDER_SLANTDASHDOT;
break;
case '4':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHED;
$styleArray['style'] = \PHPExcel\Style\Border::BORDER_DASHED;
break;
case '5':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_THICK;
$styleArray['style'] = \PHPExcel\Style\Border::BORDER_THICK;
break;
case '6':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DOUBLE;
$styleArray['style'] = \PHPExcel\Style\Border::BORDER_DOUBLE;
break;
case '7':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DOTTED;
$styleArray['style'] = \PHPExcel\Style\Border::BORDER_DOTTED;
break;
case '8':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHED;
$styleArray['style'] = \PHPExcel\Style\Border::BORDER_MEDIUMDASHED;
break;
case '9':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOT;
$styleArray['style'] = \PHPExcel\Style\Border::BORDER_DASHDOT;
break;
case '10':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT;
$styleArray['style'] = \PHPExcel\Style\Border::BORDER_MEDIUMDASHDOT;
break;
case '11':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOTDOT;
$styleArray['style'] = \PHPExcel\Style\Border::BORDER_DASHDOTDOT;
break;
case '12':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT;
$styleArray['style'] = \PHPExcel\Style\Border::BORDER_MEDIUMDASHDOTDOT;
break;
case '13':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT;
$styleArray['style'] = \PHPExcel\Style\Border::BORDER_MEDIUMDASHDOTDOT;
break;
}
return $styleArray;
@ -833,7 +826,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
private function parseRichText($is = '')
{
$value = new PHPExcel_RichText();
$value = new \PHPExcel\RichText();
$value->createText($is);
return $value;

View File

@ -1,12 +1,6 @@
<?php
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
namespace PHPExcel\Reader;
/**
* PHPExcel_Reader_HTML
@ -34,7 +28,7 @@ if (!defined('PHPEXCEL_ROOT')) {
* @version ##VERSION##, ##DATE##
*/
/** PHPExcel root directory */
class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
class HTML extends BaseReader implements IReader
{
/**

View File

@ -1,5 +1,7 @@
<?php
namespace PHPExcel\Reader;
/**
* PHPExcel_Reader_IReadFilter
*
@ -25,7 +27,7 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
interface PHPExcel_Reader_IReadFilter
interface IReadFilter
{
/**
* Should this cell be read?

View File

@ -1,5 +1,7 @@
<?php
namespace PHPExcel\Reader;
/**
* PHPExcel_Reader_IReader
*
@ -25,10 +27,10 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
interface PHPExcel_Reader_IReader
interface IReader
{
/**
* Can the current PHPExcel_Reader_IReader read the file?
* Can the current IReader read the file?
*
* @param string $pFilename
* @return boolean
@ -40,7 +42,7 @@ interface PHPExcel_Reader_IReader
*
* @param string $pFilename
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
* @throws Exception
*/
public function load($pFilename);
}

View File

@ -1,13 +1,6 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
namespace PHPExcel\Reader;
/**
* PHPExcel_Reader_OOCalc
@ -34,7 +27,7 @@ if (!defined('PHPEXCEL_ROOT')) {
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
class OOCalc extends BaseReader implements IReader
{
/**
* Formats

View File

@ -1,13 +1,6 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
namespace PHPExcel\Reader;
/**
* PHPExcel_Reader_SYLK
@ -34,7 +27,7 @@ if (!defined('PHPEXCEL_ROOT')) {
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
class SYLK extends BaseReader implements IReader
{
/**
* Input encoding