Close to the end of the psr-2 work, just trends to go

This commit is contained in:
MarkBaker 2015-05-20 23:55:01 +01:00
parent c4ff34dde4
commit 85692956a7
8 changed files with 189 additions and 205 deletions

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Shared_String
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Shared_String
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_String class PHPExcel_Shared_String
{ {
/** Constants */ /** Constants */
@ -46,60 +38,60 @@ class PHPExcel_Shared_String
* *
* @var string[] * @var string[]
*/ */
private static $_controlCharacters = array(); private static $controlCharacters = array();
/** /**
* SYLK Characters array * SYLK Characters array
* *
* $var array * $var array
*/ */
private static $_SYLKCharacters = array(); private static $SYLKCharacters = array();
/** /**
* Decimal separator * Decimal separator
* *
* @var string * @var string
*/ */
private static $_decimalSeparator; private static $decimalSeparator;
/** /**
* Thousands separator * Thousands separator
* *
* @var string * @var string
*/ */
private static $_thousandsSeparator; private static $thousandsSeparator;
/** /**
* Currency code * Currency code
* *
* @var string * @var string
*/ */
private static $_currencyCode; private static $currencyCode;
/** /**
* Is mbstring extension avalable? * Is mbstring extension avalable?
* *
* @var boolean * @var boolean
*/ */
private static $_isMbstringEnabled; private static $isMbstringEnabled;
/** /**
* Is iconv extension avalable? * Is iconv extension avalable?
* *
* @var boolean * @var boolean
*/ */
private static $_isIconvEnabled; private static $isIconvEnabled;
/** /**
* Build control characters array * Build control characters array
*/ */
private static function _buildControlCharacters() private static function buildControlCharacters()
{ {
for ($i = 0; $i <= 31; ++$i) { for ($i = 0; $i <= 31; ++$i) {
if ($i != 9 && $i != 10 && $i != 13) { if ($i != 9 && $i != 10 && $i != 13) {
$find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_'; $find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_';
$replace = chr($i); $replace = chr($i);
self::$_controlCharacters[$find] = $replace; self::$controlCharacters[$find] = $replace;
} }
} }
} }
@ -107,9 +99,9 @@ class PHPExcel_Shared_String
/** /**
* Build SYLK characters array * Build SYLK characters array
*/ */
private static function _buildSYLKCharacters() private static function buildSYLKCharacters()
{ {
self::$_SYLKCharacters = array( self::$SYLKCharacters = array(
"\x1B 0" => chr(0), "\x1B 0" => chr(0),
"\x1B 1" => chr(1), "\x1B 1" => chr(1),
"\x1B 2" => chr(2), "\x1B 2" => chr(2),
@ -276,14 +268,14 @@ class PHPExcel_Shared_String
*/ */
public static function getIsMbstringEnabled() public static function getIsMbstringEnabled()
{ {
if (isset(self::$_isMbstringEnabled)) { if (isset(self::$isMbstringEnabled)) {
return self::$_isMbstringEnabled; return self::$isMbstringEnabled;
} }
self::$_isMbstringEnabled = function_exists('mb_convert_encoding') ? self::$isMbstringEnabled = function_exists('mb_convert_encoding') ?
true : false; true : false;
return self::$_isMbstringEnabled; return self::$isMbstringEnabled;
} }
/** /**
@ -293,47 +285,47 @@ class PHPExcel_Shared_String
*/ */
public static function getIsIconvEnabled() public static function getIsIconvEnabled()
{ {
if (isset(self::$_isIconvEnabled)) { if (isset(self::$isIconvEnabled)) {
return self::$_isIconvEnabled; return self::$isIconvEnabled;
} }
// Fail if iconv doesn't exist // Fail if iconv doesn't exist
if (!function_exists('iconv')) { if (!function_exists('iconv')) {
self::$_isIconvEnabled = false; self::$isIconvEnabled = false;
return false; return false;
} }
// Sometimes iconv is not working, and e.g. iconv('UTF-8', 'UTF-16LE', 'x') just returns false, // Sometimes iconv is not working, and e.g. iconv('UTF-8', 'UTF-16LE', 'x') just returns false,
if (!@iconv('UTF-8', 'UTF-16LE', 'x')) { if (!@iconv('UTF-8', 'UTF-16LE', 'x')) {
self::$_isIconvEnabled = false; self::$isIconvEnabled = false;
return false; return false;
} }
// Sometimes iconv_substr('A', 0, 1, 'UTF-8') just returns false in PHP 5.2.0 // Sometimes iconv_substr('A', 0, 1, 'UTF-8') just returns false in PHP 5.2.0
// we cannot use iconv in that case either (http://bugs.php.net/bug.php?id=37773) // we cannot use iconv in that case either (http://bugs.php.net/bug.php?id=37773)
if (!@iconv_substr('A', 0, 1, 'UTF-8')) { if (!@iconv_substr('A', 0, 1, 'UTF-8')) {
self::$_isIconvEnabled = false; self::$isIconvEnabled = false;
return false; return false;
} }
// CUSTOM: IBM AIX iconv() does not work // CUSTOM: IBM AIX iconv() does not work
if (defined('PHP_OS') && @stristr(PHP_OS, 'AIX') && defined('ICONV_IMPL') && (@strcasecmp(ICONV_IMPL, 'unknown') == 0) && defined('ICONV_VERSION') && (@strcasecmp(ICONV_VERSION, 'unknown') == 0)) { if (defined('PHP_OS') && @stristr(PHP_OS, 'AIX') && defined('ICONV_IMPL') && (@strcasecmp(ICONV_IMPL, 'unknown') == 0) && defined('ICONV_VERSION') && (@strcasecmp(ICONV_VERSION, 'unknown') == 0)) {
self::$_isIconvEnabled = false; self::$isIconvEnabled = false;
return false; return false;
} }
// If we reach here no problems were detected with iconv // If we reach here no problems were detected with iconv
self::$_isIconvEnabled = true; self::$isIconvEnabled = true;
return true; return true;
} }
public static function buildCharacterSets() public static function buildCharacterSets()
{ {
if (empty(self::$_controlCharacters)) { if (empty(self::$controlCharacters)) {
self::_buildControlCharacters(); self::buildControlCharacters();
} }
if (empty(self::$_SYLKCharacters)) { if (empty(self::$SYLKCharacters)) {
self::_buildSYLKCharacters(); self::buildSYLKCharacters();
} }
} }
@ -353,7 +345,7 @@ class PHPExcel_Shared_String
*/ */
public static function ControlCharacterOOXML2PHP($value = '') public static function ControlCharacterOOXML2PHP($value = '')
{ {
return str_replace(array_keys(self::$_controlCharacters), array_values(self::$_controlCharacters), $value); return str_replace(array_keys(self::$controlCharacters), array_values(self::$controlCharacters), $value);
} }
/** /**
@ -372,7 +364,7 @@ class PHPExcel_Shared_String
*/ */
public static function ControlCharacterPHP2OOXML($value = '') public static function ControlCharacterPHP2OOXML($value = '')
{ {
return str_replace(array_values(self::$_controlCharacters), array_keys(self::$_controlCharacters), $value); return str_replace(array_values(self::$controlCharacters), array_keys(self::$controlCharacters), $value);
} }
/** /**
@ -701,17 +693,17 @@ class PHPExcel_Shared_String
*/ */
public static function getDecimalSeparator() public static function getDecimalSeparator()
{ {
if (!isset(self::$_decimalSeparator)) { if (!isset(self::$decimalSeparator)) {
$localeconv = localeconv(); $localeconv = localeconv();
self::$_decimalSeparator = ($localeconv['decimal_point'] != '') self::$decimalSeparator = ($localeconv['decimal_point'] != '')
? $localeconv['decimal_point'] : $localeconv['mon_decimal_point']; ? $localeconv['decimal_point'] : $localeconv['mon_decimal_point'];
if (self::$_decimalSeparator == '') { if (self::$decimalSeparator == '') {
// Default to . // Default to .
self::$_decimalSeparator = '.'; self::$decimalSeparator = '.';
} }
} }
return self::$_decimalSeparator; return self::$decimalSeparator;
} }
/** /**
@ -722,7 +714,7 @@ class PHPExcel_Shared_String
*/ */
public static function setDecimalSeparator($pValue = '.') public static function setDecimalSeparator($pValue = '.')
{ {
self::$_decimalSeparator = $pValue; self::$decimalSeparator = $pValue;
} }
/** /**
@ -733,17 +725,17 @@ class PHPExcel_Shared_String
*/ */
public static function getThousandsSeparator() public static function getThousandsSeparator()
{ {
if (!isset(self::$_thousandsSeparator)) { if (!isset(self::$thousandsSeparator)) {
$localeconv = localeconv(); $localeconv = localeconv();
self::$_thousandsSeparator = ($localeconv['thousands_sep'] != '') self::$thousandsSeparator = ($localeconv['thousands_sep'] != '')
? $localeconv['thousands_sep'] : $localeconv['mon_thousands_sep']; ? $localeconv['thousands_sep'] : $localeconv['mon_thousands_sep'];
if (self::$_thousandsSeparator == '') { if (self::$thousandsSeparator == '') {
// Default to . // Default to .
self::$_thousandsSeparator = ','; self::$thousandsSeparator = ',';
} }
} }
return self::$_thousandsSeparator; return self::$thousandsSeparator;
} }
/** /**
@ -754,7 +746,7 @@ class PHPExcel_Shared_String
*/ */
public static function setThousandsSeparator($pValue = ',') public static function setThousandsSeparator($pValue = ',')
{ {
self::$_thousandsSeparator = $pValue; self::$thousandsSeparator = $pValue;
} }
/** /**
@ -765,17 +757,17 @@ class PHPExcel_Shared_String
*/ */
public static function getCurrencyCode() public static function getCurrencyCode()
{ {
if (!isset(self::$_currencyCode)) { if (!isset(self::$currencyCode)) {
$localeconv = localeconv(); $localeconv = localeconv();
self::$_currencyCode = ($localeconv['currency_symbol'] != '') self::$currencyCode = ($localeconv['currency_symbol'] != '')
? $localeconv['currency_symbol'] : $localeconv['int_curr_symbol']; ? $localeconv['currency_symbol'] : $localeconv['int_curr_symbol'];
if (self::$_currencyCode == '') { if (self::$currencyCode == '') {
// Default to $ // Default to $
self::$_currencyCode = '$'; self::$currencyCode = '$';
} }
} }
return self::$_currencyCode; return self::$currencyCode;
} }
/** /**
@ -786,7 +778,7 @@ class PHPExcel_Shared_String
*/ */
public static function setCurrencyCode($pValue = '$') public static function setCurrencyCode($pValue = '$')
{ {
self::$_currencyCode = $pValue; self::$currencyCode = $pValue;
} }
/** /**
@ -802,7 +794,7 @@ class PHPExcel_Shared_String
return $pValue; return $pValue;
} }
foreach (self::$_SYLKCharacters as $k => $v) { foreach (self::$SYLKCharacters as $k => $v) {
$pValue = str_replace($k, $v, $pValue); $pValue = str_replace($k, $v, $pValue);
} }

View File

@ -42,7 +42,7 @@ class PHPExcel_Shared_TimeZone
* @private * @private
* @var string * @var string
*/ */
protected static $_timezone = 'UTC'; protected static $timezone = 'UTC';
/** /**
* Validate a Timezone name * Validate a Timezone name
@ -67,11 +67,11 @@ class PHPExcel_Shared_TimeZone
public static function setTimeZone($timezone) public static function setTimeZone($timezone)
{ {
if (self::_validateTimezone($timezone)) { if (self::_validateTimezone($timezone)) {
self::$_timezone = $timezone; self::$timezone = $timezone;
return true; return true;
} }
return false; return false;
} // function setTimezone() }
/** /**
@ -81,8 +81,8 @@ class PHPExcel_Shared_TimeZone
*/ */
public static function getTimeZone() public static function getTimeZone()
{ {
return self::$_timezone; return self::$timezone;
} // function getTimezone() }
/** /**
@ -92,7 +92,7 @@ class PHPExcel_Shared_TimeZone
* @param integer $timestamp PHP date/time value for finding the current transition * @param integer $timestamp PHP date/time value for finding the current transition
* @return array The current transition details * @return array The current transition details
*/ */
private static function _getTimezoneTransitions($objTimezone, $timestamp) private static function getTimezoneTransitions($objTimezone, $timestamp)
{ {
$allTransitions = $objTimezone->getTransitions(); $allTransitions = $objTimezone->getTransitions();
$transitions = array(); $transitions = array();
@ -125,7 +125,7 @@ class PHPExcel_Shared_TimeZone
throw new PHPExcel_Exception("Invalid timezone " . $timezone); throw new PHPExcel_Exception("Invalid timezone " . $timezone);
} }
} else { } else {
$timezone = self::$_timezone; $timezone = self::$timezone;
} }
if ($timezone == 'UST') { if ($timezone == 'UST') {
@ -136,7 +136,7 @@ class PHPExcel_Shared_TimeZone
if (version_compare(PHP_VERSION, '5.3.0') >= 0) { if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
$transitions = $objTimezone->getTransitions($timestamp, $timestamp); $transitions = $objTimezone->getTransitions($timestamp, $timestamp);
} else { } else {
$transitions = self::_getTimezoneTransitions($objTimezone, $timestamp); $transitions = self::getTimezoneTransitions($objTimezone, $timestamp);
} }
return (count($transitions) > 0) ? $transitions[0]['offset'] : 0; return (count($transitions) > 0) ? $transitions[0]['offset'] : 0;

View File

@ -1,6 +1,15 @@
<?php <?php
if (!defined('DATE_W3C')) {
define('DATE_W3C', 'Y-m-d\TH:i:sP');
}
if (!defined('DEBUGMODE_ENABLED')) {
define('DEBUGMODE_ENABLED', false);
}
/** /**
* PHPExcel * PHPExcel_Shared_XMLWriter
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,22 +33,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
if (!defined('DATE_W3C')) {
define('DATE_W3C', 'Y-m-d\TH:i:sP');
}
if (!defined('DEBUGMODE_ENABLED')) {
define('DEBUGMODE_ENABLED', false);
}
/**
* PHPExcel_Shared_XMLWriter
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_XMLWriter extends XMLWriter class PHPExcel_Shared_XMLWriter extends XMLWriter
{ {
/** Temporary storage method */ /** Temporary storage method */
@ -51,7 +44,7 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter
* *
* @var string * @var string
*/ */
private $_tempFileName = ''; private $tempFileName = '';
/** /**
* Create a new PHPExcel_Shared_XMLWriter instance * Create a new PHPExcel_Shared_XMLWriter instance
@ -69,10 +62,10 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter
if ($pTemporaryStorageFolder === null) { if ($pTemporaryStorageFolder === null) {
$pTemporaryStorageFolder = PHPExcel_Shared_File::sys_get_temp_dir(); $pTemporaryStorageFolder = PHPExcel_Shared_File::sys_get_temp_dir();
} }
$this->_tempFileName = @tempnam($pTemporaryStorageFolder, 'xml'); $this->tempFileName = @tempnam($pTemporaryStorageFolder, 'xml');
// Open storage // Open storage
if ($this->openUri($this->_tempFileName) === false) { if ($this->openUri($this->tempFileName) === false) {
// Fallback to memory... // Fallback to memory...
$this->openMemory(); $this->openMemory();
} }
@ -90,8 +83,8 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter
public function __destruct() public function __destruct()
{ {
// Unlink temporary files // Unlink temporary files
if ($this->_tempFileName != '') { if ($this->tempFileName != '') {
@unlink($this->_tempFileName); @unlink($this->tempFileName);
} }
} }
@ -102,11 +95,11 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter
*/ */
public function getData() public function getData()
{ {
if ($this->_tempFileName == '') { if ($this->tempFileName == '') {
return $this->outputMemory(true); return $this->outputMemory(true);
} else { } else {
$this->flush(); $this->flush();
return file_get_contents($this->_tempFileName); return file_get_contents($this->tempFileName);
} }
} }

View File

@ -43,14 +43,14 @@ class PHPExcel_Shared_ZipArchive
* *
* @var string * @var string
*/ */
private $_tempDir; private $tempDir;
/** /**
* Zip Archive Stream Handle * Zip Archive Stream Handle
* *
* @var string * @var string
*/ */
private $_zip; private $zip;
/** /**
@ -61,9 +61,8 @@ class PHPExcel_Shared_ZipArchive
*/ */
public function open($fileName) public function open($fileName)
{ {
$this->_tempDir = PHPExcel_Shared_File::sys_get_temp_dir(); $this->tempDir = PHPExcel_Shared_File::sys_get_temp_dir();
$this->zip = new PclZip($fileName);
$this->_zip = new PclZip($fileName);
return true; return true;
} }
@ -88,16 +87,16 @@ class PHPExcel_Shared_ZipArchive
{ {
$filenameParts = pathinfo($localname); $filenameParts = pathinfo($localname);
$handle = fopen($this->_tempDir.'/'.$filenameParts["basename"], "wb"); $handle = fopen($this->tempDir.'/'.$filenameParts["basename"], "wb");
fwrite($handle, $contents); fwrite($handle, $contents);
fclose($handle); fclose($handle);
$res = $this->_zip->add($this->_tempDir.'/'.$filenameParts["basename"], PCLZIP_OPT_REMOVE_PATH, $this->_tempDir, PCLZIP_OPT_ADD_PATH, $filenameParts["dirname"]); $res = $this->zip->add($this->tempDir.'/'.$filenameParts["basename"], PCLZIP_OPT_REMOVE_PATH, $this->tempDir, PCLZIP_OPT_ADD_PATH, $filenameParts["dirname"]);
if ($res == 0) { if ($res == 0) {
throw new PHPExcel_Writer_Exception("Error zipping files : " . $this->_zip->errorInfo(true)); throw new PHPExcel_Writer_Exception("Error zipping files : " . $this->zip->errorInfo(true));
} }
unlink($this->_tempDir.'/'.$filenameParts["basename"]); unlink($this->tempDir.'/'.$filenameParts["basename"]);
} }
/** /**
@ -108,7 +107,7 @@ class PHPExcel_Shared_ZipArchive
*/ */
public function locateName($fileName) public function locateName($fileName)
{ {
$list = $this->_zip->listContent(); $list = $this->zip->listContent();
$listCount = count($list); $listCount = count($list);
$list_index = -1; $list_index = -1;
for ($i = 0; $i < $listCount; ++$i) { for ($i = 0; $i < $listCount; ++$i) {
@ -129,7 +128,7 @@ class PHPExcel_Shared_ZipArchive
*/ */
public function getFromName($fileName) public function getFromName($fileName)
{ {
$list = $this->_zip->listContent(); $list = $this->zip->listContent();
$listCount = count($list); $listCount = count($list);
$list_index = -1; $list_index = -1;
for ($i = 0; $i < $listCount; ++$i) { for ($i = 0; $i < $listCount; ++$i) {
@ -142,7 +141,7 @@ class PHPExcel_Shared_ZipArchive
$extracted = ""; $extracted = "";
if ($list_index != -1) { if ($list_index != -1) {
$extracted = $this->_zip->extractByIndex($list_index, PCLZIP_OPT_EXTRACT_AS_STRING); $extracted = $this->zip->extractByIndex($list_index, PCLZIP_OPT_EXTRACT_AS_STRING);
} else { } else {
$filename = substr($fileName, 1); $filename = substr($fileName, 1);
$list_index = -1; $list_index = -1;
@ -153,7 +152,7 @@ class PHPExcel_Shared_ZipArchive
break; break;
} }
} }
$extracted = $this->_zip->extractByIndex($list_index, PCLZIP_OPT_EXTRACT_AS_STRING); $extracted = $this->zip->extractByIndex($list_index, PCLZIP_OPT_EXTRACT_AS_STRING);
} }
if ((is_array($extracted)) && ($extracted != 0)) { if ((is_array($extracted)) && ($extracted != 0)) {
$contents = $extracted[0]["content"]; $contents = $extracted[0]["content"];

View File

@ -32,28 +32,28 @@ class PHPExcel_Shared_ZipStreamWrapper
* *
* @var ZipArchive * @var ZipArchive
*/ */
private $_archive; private $archive;
/** /**
* Filename in ZipAcrhive * Filename in ZipAcrhive
* *
* @var string * @var string
*/ */
private $_fileNameInArchive = ''; private $fileNameInArchive = '';
/** /**
* Position in file * Position in file
* *
* @var int * @var int
*/ */
private $_position = 0; private $position = 0;
/** /**
* Data * Data
* *
* @var mixed * @var mixed
*/ */
private $_data = ''; private $data = '';
/** /**
* Register wrapper * Register wrapper
@ -85,12 +85,12 @@ class PHPExcel_Shared_ZipStreamWrapper
$url['fragment'] = substr($path, $pos + 1); $url['fragment'] = substr($path, $pos + 1);
// Open archive // Open archive
$this->_archive = new ZipArchive(); $this->archive = new ZipArchive();
$this->_archive->open($url['host']); $this->archive->open($url['host']);
$this->_fileNameInArchive = $url['fragment']; $this->fileNameInArchive = $url['fragment'];
$this->_position = 0; $this->position = 0;
$this->_data = $this->_archive->getFromName($this->_fileNameInArchive); $this->data = $this->archive->getFromName($this->fileNameInArchive);
return true; return true;
} }
@ -102,7 +102,7 @@ class PHPExcel_Shared_ZipStreamWrapper
*/ */
public function statName() public function statName()
{ {
return $this->_fileNameInArchive; return $this->fileNameInArchive;
} }
/** /**
@ -112,7 +112,7 @@ class PHPExcel_Shared_ZipStreamWrapper
*/ */
public function url_stat() public function url_stat()
{ {
return $this->statName($this->_fileNameInArchive); return $this->statName($this->fileNameInArchive);
} }
/** /**
@ -122,7 +122,7 @@ class PHPExcel_Shared_ZipStreamWrapper
*/ */
public function stream_stat() public function stream_stat()
{ {
return $this->_archive->statName($this->_fileNameInArchive); return $this->archive->statName($this->fileNameInArchive);
} }
/** /**
@ -133,8 +133,8 @@ class PHPExcel_Shared_ZipStreamWrapper
*/ */
public function stream_read($count) public function stream_read($count)
{ {
$ret = substr($this->_data, $this->_position, $count); $ret = substr($this->data, $this->position, $count);
$this->_position += strlen($ret); $this->position += strlen($ret);
return $ret; return $ret;
} }
@ -146,7 +146,7 @@ class PHPExcel_Shared_ZipStreamWrapper
*/ */
public function stream_tell() public function stream_tell()
{ {
return $this->_position; return $this->position;
} }
/** /**
@ -156,7 +156,7 @@ class PHPExcel_Shared_ZipStreamWrapper
*/ */
public function stream_eof() public function stream_eof()
{ {
return $this->_position >= strlen($this->_data); return $this->position >= strlen($this->data);
} }
/** /**
@ -170,8 +170,8 @@ class PHPExcel_Shared_ZipStreamWrapper
{ {
switch ($whence) { switch ($whence) {
case SEEK_SET: case SEEK_SET:
if ($offset < strlen($this->_data) && $offset >= 0) { if ($offset < strlen($this->data) && $offset >= 0) {
$this->_position = $offset; $this->position = $offset;
return true; return true;
} else { } else {
return false; return false;
@ -179,15 +179,15 @@ class PHPExcel_Shared_ZipStreamWrapper
break; break;
case SEEK_CUR: case SEEK_CUR:
if ($offset >= 0) { if ($offset >= 0) {
$this->_position += $offset; $this->position += $offset;
return true; return true;
} else { } else {
return false; return false;
} }
break; break;
case SEEK_END: case SEEK_END:
if (strlen($this->_data) + $offset >= 0) { if (strlen($this->data) + $offset >= 0) {
$this->_position = strlen($this->_data) + $offset; $this->position = strlen($this->data) + $offset;
return true; return true;
} else { } else {
return false; return false;

View File

@ -46,77 +46,77 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* *
* @var string * @var string
*/ */
protected $_name; protected $name;
/** /**
* Description * Description
* *
* @var string * @var string
*/ */
protected $_description; protected $description;
/** /**
* Worksheet * Worksheet
* *
* @var PHPExcel_Worksheet * @var PHPExcel_Worksheet
*/ */
protected $_worksheet; protected $worksheet;
/** /**
* Coordinates * Coordinates
* *
* @var string * @var string
*/ */
protected $_coordinates; protected $coordinates;
/** /**
* Offset X * Offset X
* *
* @var int * @var int
*/ */
protected $_offsetX; protected $offsetX;
/** /**
* Offset Y * Offset Y
* *
* @var int * @var int
*/ */
protected $_offsetY; protected $offsetY;
/** /**
* Width * Width
* *
* @var int * @var int
*/ */
protected $_width; protected $width;
/** /**
* Height * Height
* *
* @var int * @var int
*/ */
protected $_height; protected $height;
/** /**
* Proportional resize * Proportional resize
* *
* @var boolean * @var boolean
*/ */
protected $_resizeProportional; protected $resizeProportional;
/** /**
* Rotation * Rotation
* *
* @var int * @var int
*/ */
protected $_rotation; protected $rotation;
/** /**
* Shadow * Shadow
* *
* @var PHPExcel_Worksheet_Drawing_Shadow * @var PHPExcel_Worksheet_Drawing_Shadow
*/ */
protected $_shadow; protected $shadow;
/** /**
* Create a new PHPExcel_Worksheet_BaseDrawing * Create a new PHPExcel_Worksheet_BaseDrawing
@ -124,17 +124,17 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function __construct() public function __construct()
{ {
// Initialise values // Initialise values
$this->_name = ''; $this->name = '';
$this->_description = ''; $this->description = '';
$this->_worksheet = null; $this->worksheet = null;
$this->_coordinates = 'A1'; $this->coordinates = 'A1';
$this->_offsetX = 0; $this->offsetX = 0;
$this->_offsetY = 0; $this->offsetY = 0;
$this->_width = 0; $this->width = 0;
$this->_height = 0; $this->height = 0;
$this->_resizeProportional = true; $this->resizeProportional = true;
$this->_rotation = 0; $this->rotation = 0;
$this->_shadow = new PHPExcel_Worksheet_Drawing_Shadow(); $this->shadow = new PHPExcel_Worksheet_Drawing_Shadow();
// Set image index // Set image index
self::$imageCounter++; self::$imageCounter++;
@ -158,7 +158,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function getName() public function getName()
{ {
return $this->_name; return $this->name;
} }
/** /**
@ -169,7 +169,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function setName($pValue = '') public function setName($pValue = '')
{ {
$this->_name = $pValue; $this->name = $pValue;
return $this; return $this;
} }
@ -180,7 +180,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function getDescription() public function getDescription()
{ {
return $this->_description; return $this->description;
} }
/** /**
@ -191,7 +191,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function setDescription($pValue = '') public function setDescription($pValue = '')
{ {
$this->_description = $pValue; $this->description = $pValue;
return $this; return $this;
} }
@ -202,7 +202,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function getWorksheet() public function getWorksheet()
{ {
return $this->_worksheet; return $this->worksheet;
} }
/** /**
@ -215,20 +215,20 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function setWorksheet(PHPExcel_Worksheet $pValue = null, $pOverrideOld = false) public function setWorksheet(PHPExcel_Worksheet $pValue = null, $pOverrideOld = false)
{ {
if (is_null($this->_worksheet)) { if (is_null($this->worksheet)) {
// Add drawing to PHPExcel_Worksheet // Add drawing to PHPExcel_Worksheet
$this->_worksheet = $pValue; $this->worksheet = $pValue;
$this->_worksheet->getCell($this->_coordinates); $this->worksheet->getCell($this->coordinates);
$this->_worksheet->getDrawingCollection()->append($this); $this->worksheet->getDrawingCollection()->append($this);
} else { } else {
if ($pOverrideOld) { if ($pOverrideOld) {
// Remove drawing from old PHPExcel_Worksheet // Remove drawing from old PHPExcel_Worksheet
$iterator = $this->_worksheet->getDrawingCollection()->getIterator(); $iterator = $this->worksheet->getDrawingCollection()->getIterator();
while ($iterator->valid()) { while ($iterator->valid()) {
if ($iterator->current()->getHashCode() == $this->getHashCode()) { if ($iterator->current()->getHashCode() == $this->getHashCode()) {
$this->_worksheet->getDrawingCollection()->offsetUnset($iterator->key()); $this->worksheet->getDrawingCollection()->offsetUnset($iterator->key());
$this->_worksheet = null; $this->worksheet = null;
break; break;
} }
} }
@ -249,7 +249,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function getCoordinates() public function getCoordinates()
{ {
return $this->_coordinates; return $this->coordinates;
} }
/** /**
@ -260,7 +260,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function setCoordinates($pValue = 'A1') public function setCoordinates($pValue = 'A1')
{ {
$this->_coordinates = $pValue; $this->coordinates = $pValue;
return $this; return $this;
} }
@ -271,7 +271,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function getOffsetX() public function getOffsetX()
{ {
return $this->_offsetX; return $this->offsetX;
} }
/** /**
@ -282,7 +282,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function setOffsetX($pValue = 0) public function setOffsetX($pValue = 0)
{ {
$this->_offsetX = $pValue; $this->offsetX = $pValue;
return $this; return $this;
} }
@ -293,7 +293,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function getOffsetY() public function getOffsetY()
{ {
return $this->_offsetY; return $this->offsetY;
} }
/** /**
@ -304,7 +304,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function setOffsetY($pValue = 0) public function setOffsetY($pValue = 0)
{ {
$this->_offsetY = $pValue; $this->offsetY = $pValue;
return $this; return $this;
} }
@ -315,7 +315,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function getWidth() public function getWidth()
{ {
return $this->_width; return $this->width;
} }
/** /**
@ -327,13 +327,13 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function setWidth($pValue = 0) public function setWidth($pValue = 0)
{ {
// Resize proportional? // Resize proportional?
if ($this->_resizeProportional && $pValue != 0) { if ($this->resizeProportional && $pValue != 0) {
$ratio = $this->_height / ($this->_width != 0 ? $this->_width : 1); $ratio = $this->height / ($this->width != 0 ? $this->width : 1);
$this->_height = round($ratio * $pValue); $this->height = round($ratio * $pValue);
} }
// Set width // Set width
$this->_width = $pValue; $this->width = $pValue;
return $this; return $this;
} }
@ -345,7 +345,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function getHeight() public function getHeight()
{ {
return $this->_height; return $this->height;
} }
/** /**
@ -357,13 +357,13 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function setHeight($pValue = 0) public function setHeight($pValue = 0)
{ {
// Resize proportional? // Resize proportional?
if ($this->_resizeProportional && $pValue != 0) { if ($this->resizeProportional && $pValue != 0) {
$ratio = $this->_width / ($this->_height != 0 ? $this->_height : 1); $ratio = $this->width / ($this->height != 0 ? $this->height : 1);
$this->_width = round($ratio * $pValue); $this->width = round($ratio * $pValue);
} }
// Set height // Set height
$this->_height = $pValue; $this->height = $pValue;
return $this; return $this;
} }
@ -383,19 +383,19 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function setWidthAndHeight($width = 0, $height = 0) public function setWidthAndHeight($width = 0, $height = 0)
{ {
$xratio = $width / ($this->_width != 0 ? $this->_width : 1); $xratio = $width / ($this->width != 0 ? $this->width : 1);
$yratio = $height / ($this->_height != 0 ? $this->_height : 1); $yratio = $height / ($this->height != 0 ? $this->height : 1);
if ($this->_resizeProportional && !($width == 0 || $height == 0)) { if ($this->resizeProportional && !($width == 0 || $height == 0)) {
if (($xratio * $this->_height) < $height) { if (($xratio * $this->height) < $height) {
$this->_height = ceil($xratio * $this->_height); $this->height = ceil($xratio * $this->height);
$this->_width = $width; $this->width = $width;
} else { } else {
$this->_width = ceil($yratio * $this->_width); $this->width = ceil($yratio * $this->width);
$this->_height = $height; $this->height = $height;
} }
} else { } else {
$this->_width = $width; $this->width = $width;
$this->_height = $height; $this->height = $height;
} }
return $this; return $this;
@ -408,7 +408,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function getResizeProportional() public function getResizeProportional()
{ {
return $this->_resizeProportional; return $this->resizeProportional;
} }
/** /**
@ -419,7 +419,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function setResizeProportional($pValue = true) public function setResizeProportional($pValue = true)
{ {
$this->_resizeProportional = $pValue; $this->resizeProportional = $pValue;
return $this; return $this;
} }
@ -430,7 +430,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function getRotation() public function getRotation()
{ {
return $this->_rotation; return $this->rotation;
} }
/** /**
@ -441,7 +441,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function setRotation($pValue = 0) public function setRotation($pValue = 0)
{ {
$this->_rotation = $pValue; $this->rotation = $pValue;
return $this; return $this;
} }
@ -452,7 +452,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function getShadow() public function getShadow()
{ {
return $this->_shadow; return $this->shadow;
} }
/** /**
@ -464,7 +464,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function setShadow(PHPExcel_Worksheet_Drawing_Shadow $pValue = null) public function setShadow(PHPExcel_Worksheet_Drawing_Shadow $pValue = null)
{ {
$this->_shadow = $pValue; $this->shadow = $pValue;
return $this; return $this;
} }
@ -476,16 +476,16 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getHashCode() public function getHashCode()
{ {
return md5( return md5(
$this->_name . $this->name .
$this->_description . $this->description .
$this->_worksheet->getHashCode() . $this->worksheet->getHashCode() .
$this->_coordinates . $this->coordinates .
$this->_offsetX . $this->offsetX .
$this->_offsetY . $this->offsetY .
$this->_width . $this->width .
$this->_height . $this->height .
$this->_rotation . $this->rotation .
$this->_shadow->getHashCode() . $this->shadow->getHashCode() .
__CLASS__ __CLASS__
); );
} }

View File

@ -103,9 +103,9 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
if (file_exists($pValue)) { if (file_exists($pValue)) {
$this->path = $pValue; $this->path = $pValue;
if ($this->_width == 0 && $this->_height == 0) { if ($this->width == 0 && $this->height == 0) {
// Get width/height // Get width/height
list($this->_width, $this->_height) = getimagesize($pValue); list($this->width, $this->height) = getimagesize($pValue);
} }
} else { } else {
throw new PHPExcel_Exception("File $pValue not found!"); throw new PHPExcel_Exception("File $pValue not found!");

View File

@ -104,8 +104,8 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
if (!is_null($this->imageResource)) { if (!is_null($this->imageResource)) {
// Get width/height // Get width/height
$this->_width = imagesx($this->imageResource); $this->width = imagesx($this->imageResource);
$this->_height = imagesy($this->imageResource); $this->height = imagesy($this->imageResource);
} }
return $this; return $this;
} }