PSR-2 : Fixes

This commit is contained in:
Progi1984 2015-05-12 17:57:29 +02:00
parent 5bb747f8cc
commit f37630e938
8 changed files with 655 additions and 696 deletions

View File

@ -48,7 +48,8 @@ abstract class PHPExcel_Writer_Excel2007_WriterPart
* @param PHPExcel_Writer_IWriter $pWriter
* @throws PHPExcel_Writer_Exception
*/
public function setParentWriter(PHPExcel_Writer_IWriter $pWriter = null) {
public function setParentWriter(PHPExcel_Writer_IWriter $pWriter = null)
{
$this->_parentWriter = $pWriter;
}
@ -58,7 +59,8 @@ abstract class PHPExcel_Writer_Excel2007_WriterPart
* @return PHPExcel_Writer_IWriter
* @throws PHPExcel_Writer_Exception
*/
public function getParentWriter() {
public function getParentWriter()
{
if (!is_null($this->_parentWriter)) {
return $this->_parentWriter;
} else {
@ -72,10 +74,10 @@ abstract class PHPExcel_Writer_Excel2007_WriterPart
* @param PHPExcel_Writer_IWriter $pWriter
* @throws PHPExcel_Writer_Exception
*/
public function __construct(PHPExcel_Writer_IWriter $pWriter = null) {
public function __construct(PHPExcel_Writer_IWriter $pWriter = null)
{
if (!is_null($pWriter)) {
$this->_parentWriter = $pWriter;
}
}
}

View File

@ -95,7 +95,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
*
* @param PHPExcel $phpExcel PHPExcel object
*/
public function __construct(PHPExcel $phpExcel) {
public function __construct(PHPExcel $phpExcel)
{
$this->_phpExcel = $phpExcel;
$this->_parser = new PHPExcel_Writer_Excel5_Parser();
@ -107,13 +108,14 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
* @param string $pFilename
* @throws PHPExcel_Writer_Exception
*/
public function save($pFilename = null) {
public function save($pFilename = null)
{
// garbage collect
$this->_phpExcel->garbageCollect();
$saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog();
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(FALSE);
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(false);
$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
@ -121,18 +123,12 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$this->_colors = array();
// Initialise workbook writer
$this->_writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->_phpExcel,
$this->_str_total, $this->_str_unique, $this->_str_table,
$this->_colors, $this->_parser);
$this->_writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->_phpExcel, $this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser);
// Initialise worksheet writers
$countSheets = $this->_phpExcel->getSheetCount();
for ($i = 0; $i < $countSheets; ++$i) {
$this->_writerWorksheets[$i] = new PHPExcel_Writer_Excel5_Worksheet($this->_str_total, $this->_str_unique,
$this->_str_table, $this->_colors,
$this->_parser,
$this->_preCalculateFormulas,
$this->_phpExcel->getSheet($i));
$this->_writerWorksheets[$i] = new PHPExcel_Writer_Excel5_Worksheet($this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser, $this->_preCalculateFormulas, $this->_phpExcel->getSheet($i));
}
// build Escher objects. Escher objects for workbooks needs to be build before Escher object for workbook.
@ -229,7 +225,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
* @throws PHPExcel_Writer_Exception when directory does not exist
* @return PHPExcel_Writer_Excel5
*/
public function setTempDir($pValue = '') {
public function setTempDir($pValue = '')
{
return $this;
}
@ -444,8 +441,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
++$sheetCountShapes;
++$totalCountShapes;
$spId = $sheetCountShapes
| ($this->_phpExcel->getIndex($sheet) + 1) << 10;
$spId = $sheetCountShapes | ($this->_phpExcel->getIndex($sheet) + 1) << 10;
$spIdMax = max($spId, $spIdMax);
}
}
@ -463,13 +459,11 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
foreach ($this->_phpExcel->getAllsheets() as $sheet) {
foreach ($sheet->getDrawingCollection() as $drawing) {
if ($drawing instanceof PHPExcel_Worksheet_Drawing) {
$filename = $drawing->getPath();
list($imagesx, $imagesy, $imageFormat) = getimagesize($filename);
switch ($imageFormat) {
case 1: // GIF, not supported by BIFF8, we convert to PNG
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
ob_start();
@ -477,17 +471,14 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$blipData = ob_get_contents();
ob_end_clean();
break;
case 2: // JPEG
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG;
$blipData = file_get_contents($filename);
break;
case 3: // PNG
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
$blipData = file_get_contents($filename);
break;
case 6: // Windows DIB (BMP), we convert to PNG
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
ob_start();
@ -495,9 +486,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$blipData = ob_get_contents();
ob_end_clean();
break;
default: continue 2;
default:
continue 2;
}
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
@ -508,23 +498,18 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$BSE->setBlip($blip);
$bstoreContainer->addBSE($BSE);
} else if ($drawing instanceof PHPExcel_Worksheet_MemoryDrawing) {
switch ($drawing->getRenderingFunction()) {
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG:
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG;
$renderingFunction = 'imagejpeg';
break;
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_GIF:
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_PNG:
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT:
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
$renderingFunction = 'imagepng';
break;
}
ob_start();
@ -552,8 +537,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
* Build the OLE Part for DocumentSummary Information
* @return string
*/
private function _writeDocumentSummaryInformation(){
private function _writeDocumentSummaryInformation()
{
// offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark)
$data = pack('v', 0xFFFE);
// offset: 2; size: 2;
@ -753,7 +738,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
* Build the OLE Part for Summary Information
* @return string
*/
private function _writeSummaryInformation(){
private function _writeSummaryInformation()
{
// offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark)
$data = pack('v', 0xFFFE);
// offset: 2; size: 2;

View File

@ -136,7 +136,7 @@ class PHPExcel_Writer_Excel5_BIFFwriter
* @param string $data binary data to append
* @access private
*/
function _append($data)
private function _append($data)
{
if (strlen($data) - 4 > $this->_limit) {
$data = $this->_addContinue($data);
@ -169,7 +169,7 @@ class PHPExcel_Writer_Excel5_BIFFwriter
* 0x0010 Worksheet.
* @access private
*/
function _storeBof($type)
private function _storeBof($type)
{
$record = 0x0809; // Record identifier (BIFF5-BIFF8)
$length = 0x0010;
@ -192,7 +192,7 @@ class PHPExcel_Writer_Excel5_BIFFwriter
*
* @access private
*/
function _storeEof()
private function _storeEof()
{
$record = 0x000A; // Record identifier
$length = 0x0000; // Number of bytes to follow
@ -226,7 +226,7 @@ class PHPExcel_Writer_Excel5_BIFFwriter
* @return string A very convenient string of continue blocks
* @access private
*/
function _addContinue($data)
private function _addContinue($data)
{
$limit = $this->_limit;
$record = 0x003C; // Record identifier
@ -251,5 +251,4 @@ class PHPExcel_Writer_Excel5_BIFFwriter
return $tmp;
}
}

View File

@ -78,7 +78,6 @@ class PHPExcel_Writer_Excel5_Escher
$this->_data = '';
switch (get_class($this->_object)) {
case 'PHPExcel_Shared_Escher':
if ($dggContainer = $this->_object->getDggContainer()) {
$writer = new PHPExcel_Writer_Excel5_Escher($dggContainer);
@ -90,7 +89,6 @@ class PHPExcel_Writer_Excel5_Escher
$this->_spTypes = $writer->getSpTypes();
}
break;
case 'PHPExcel_Shared_Escher_DggContainer':
// this is a container record
@ -107,11 +105,11 @@ class PHPExcel_Writer_Excel5_Escher
// dgg data
$dggData =
pack('VVVV'
, $this->_object->getSpIdMax() // maximum shape identifier increased by one
, $this->_object->getCDgSaved() + 1 // number of file identifier clusters increased by one
, $this->_object->getCSpSaved()
, $this->_object->getCDgSaved() // count total number of drawings saved
pack('VVVV',
$this->_object->getSpIdMax(), // maximum shape identifier increased by one
$this->_object->getCDgSaved() + 1, // number of file identifier clusters increased by one
$this->_object->getCSpSaved(),
$this->_object->getCDgSaved() // count total number of drawings saved
);
// add file identifier clusters (one per drawing)
@ -143,7 +141,6 @@ class PHPExcel_Writer_Excel5_Escher
$this->_data = $header . $innerData;
break;
case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer':
// this is a container record
@ -171,7 +168,6 @@ class PHPExcel_Writer_Excel5_Escher
$this->_data = $header . $innerData;
break;
case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE':
// this is a semi-container record
@ -221,13 +217,11 @@ class PHPExcel_Writer_Excel5_Escher
$this->_data .= $data;
break;
case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip':
// this is an atom record
// write the record
switch ($this->_object->getParent()->getBlipType()) {
case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG:
// initialize
$innerData = '';
@ -281,10 +275,8 @@ class PHPExcel_Writer_Excel5_Escher
$this->_data .= $innerData;
break;
}
break;
case 'PHPExcel_Shared_Escher_DgContainer':
// this is a container record
@ -338,7 +330,6 @@ class PHPExcel_Writer_Excel5_Escher
$this->_data = $header . $innerData;
break;
case 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer':
// this is a container record
@ -378,7 +369,6 @@ class PHPExcel_Writer_Excel5_Escher
$this->_spOffsets = $spOffsets;
$this->_spTypes = $spTypes;
break;
case 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer':
// initialize
$data = '';
@ -464,9 +454,7 @@ class PHPExcel_Writer_Excel5_Escher
// end offsetY
$endOffsetY = $this->_object->getEndOffsetY();
$clientAnchorData = pack('vvvvvvvvv', $this->_object->getSpFlag(),
$c1, $startOffsetX, $r1, $startOffsetY,
$c2, $endOffsetX, $r2, $endOffsetY);
$clientAnchorData = pack('vvvvvvvvv', $this->_object->getSpFlag(), $c1, $startOffsetX, $r1, $startOffsetY, $c2, $endOffsetX, $r2, $endOffsetY);
$length = strlen($clientAnchorData);
@ -507,7 +495,6 @@ class PHPExcel_Writer_Excel5_Escher
$this->_data = $header . $data;
break;
}
return $this->_data;
@ -532,6 +519,4 @@ class PHPExcel_Writer_Excel5_Escher
{
return $this->_spTypes;
}
}

View File

@ -107,12 +107,17 @@ class PHPExcel_Writer_Excel5_Font
$grbit |= 0x20;
}
$data = pack("vvvvvCCCC",
$this->_font->getSize() * 20, // Fontsize (in twips)
$data = pack(
"vvvvvCCCC",
// Fontsize (in twips)
$this->_font->getSize() * 20,
$grbit,
$icv, // Colour
self::_mapBold($this->_font->getBold()), // Font weight
$sss, // Superscript/Subscript
// Colour
$icv,
// Font weight
self::_mapBold($this->_font->getBold()),
// Superscript/Subscript
$sss,
self::_mapUnderline($this->_font->getUnderline()),
$bFamily,
$bCharSet,
@ -132,7 +137,8 @@ class PHPExcel_Writer_Excel5_Font
* @param boolean $bold
* @return int
*/
private static function _mapBold($bold) {
private static function _mapBold($bold)
{
if ($bold) {
return 0x2BC; // 700 = Bold font weight
}
@ -144,7 +150,8 @@ class PHPExcel_Writer_Excel5_Font
* @static array of int
*
*/
private static $_mapUnderline = array( PHPExcel_Style_Font::UNDERLINE_NONE => 0x00,
private static $_mapUnderline = array(
PHPExcel_Style_Font::UNDERLINE_NONE => 0x00,
PHPExcel_Style_Font::UNDERLINE_SINGLE => 0x01,
PHPExcel_Style_Font::UNDERLINE_DOUBLE => 0x02,
PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING => 0x21,
@ -156,10 +163,11 @@ class PHPExcel_Writer_Excel5_Font
* @param string
* @return int
*/
private static function _mapUnderline($underline) {
if (isset(self::$_mapUnderline[$underline]))
private static function _mapUnderline($underline)
{
if (isset(self::$_mapUnderline[$underline])) {
return self::$_mapUnderline[$underline];
}
return 0x00;
}
}

View File

@ -136,7 +136,7 @@ class PHPExcel_Writer_Excel5_Parser
*
* @access private
*/
function _initializeHashes()
private function _initializeHashes()
{
// The Excel ptg indices
$this->ptg = array(
@ -512,7 +512,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param mixed $token The token to convert.
* @return mixed the converted token on success
*/
function _convert($token)
private function _convert($token)
{
if (preg_match("/\"([^\"]|\"\"){0,255}\"/", $token)) {
return $this->_convertString($token);
@ -573,7 +573,7 @@ class PHPExcel_Writer_Excel5_Parser
* @access private
* @param mixed $num an integer or double for conversion to its ptg value
*/
function _convertNumber($num)
private function _convertNumber($num)
{
// Integer in the range 0..2**16-1
if ((preg_match("/^\d+$/", $num)) and ($num <= 65535)) {
@ -593,7 +593,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $string A string for conversion to its ptg value.
* @return mixed the converted token on success
*/
function _convertString($string)
private function _convertString($string)
{
// chop away beggining and ending quotes
$string = substr($string, 1, strlen($string) - 2);
@ -613,7 +613,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param integer $num_args The number of arguments the function receives.
* @return string The packed ptg for the function
*/
function _convertFunction($token, $num_args)
private function _convertFunction($token, $num_args)
{
$args = $this->_functions[$token][1];
// $volatile = $this->_functions[$token][3];
@ -635,7 +635,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $range An Excel range in the A1:A2
* @param int $class
*/
function _convertRange2d($range, $class=0)
private function _convertRange2d($range, $class = 0)
{
// TODO: possible class value 0,1,2 check Formula.pm
@ -673,7 +673,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $token An Excel range in the Sheet1!A1:A2 format.
* @return mixed The packed ptgArea3d token on success.
*/
function _convertRange3d($token)
private function _convertRange3d($token)
{
// $class = 0; // formulas like Sheet1!$A$1:$A$2 in list type data validation need this class (0x3B)
@ -715,7 +715,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $cell An Excel cell reference
* @return string The cell in packed() format with the corresponding ptg
*/
function _convertRef2d($cell)
private function _convertRef2d($cell)
{
// $class = 2; // as far as I know, this is magick.
@ -745,7 +745,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $cell An Excel cell reference
* @return mixed The packed ptgRef3d token on success.
*/
function _convertRef3d($cell)
private function _convertRef3d($cell)
{
// $class = 2; // as far as I know, this is magick.
@ -779,16 +779,23 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $errorCode The error code for conversion to its ptg value
* @return string The error code ptgErr
*/
function _convertError($errorCode)
private function _convertError($errorCode)
{
switch ($errorCode) {
case '#NULL!': return pack("C", 0x00);
case '#DIV/0!': return pack("C", 0x07);
case '#VALUE!': return pack("C", 0x0F);
case '#REF!': return pack("C", 0x17);
case '#NAME?': return pack("C", 0x1D);
case '#NUM!': return pack("C", 0x24);
case '#N/A': return pack("C", 0x2A);
case '#NULL!':
return pack("C", 0x00);
case '#DIV/0!':
return pack("C", 0x07);
case '#VALUE!':
return pack("C", 0x0F);
case '#REF!':
return pack("C", 0x17);
case '#NAME?':
return pack("C", 0x1D);
case '#NUM!':
return pack("C", 0x24);
case '#N/A':
return pack("C", 0x2A);
}
return pack("C", 0xFF);
}
@ -801,7 +808,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $ext_ref The name of the external reference
* @return string The reference index in packed() format
*/
function _packExtRef($ext_ref)
private function _packExtRef($ext_ref)
{
$ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any.
$ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any.
@ -846,7 +853,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $ext_ref The name of the external reference
* @return mixed The reference index in packed() format on success
*/
function _getRefIndex($ext_ref)
private function _getRefIndex($ext_ref)
{
$ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any.
$ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any.
@ -906,7 +913,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $sheet_name Sheet name
* @return integer The sheet index, -1 if the sheet was not found
*/
function _getSheetIndex($sheet_name)
private function _getSheetIndex($sheet_name)
{
if (!isset($this->_ext_sheets[$sheet_name])) {
return -1;
@ -925,7 +932,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $name The name of the worksheet being added
* @param integer $index The index of the worksheet being added
*/
function setExtSheet($name, $index)
public function setExtSheet($name, $index)
{
$this->_ext_sheets[$name] = $index;
}
@ -937,7 +944,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $cell The Excel cell reference to be packed
* @return array Array containing the row and column in packed() format
*/
function _cellToPackedRowcol($cell)
private function _cellToPackedRowcol($cell)
{
$cell = strtoupper($cell);
list($row, $col, $row_rel, $col_rel) = $this->_cellToRowcol($cell);
@ -966,7 +973,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $range The Excel range to be packed
* @return array Array containing (row1,col1,row2,col2) in packed() format
*/
function _rangeToPackedRange($range)
private function _rangeToPackedRange($range)
{
preg_match('/(\$)?(\d+)\:(\$)?(\d+)/', $range, $match);
// return absolute rows if there is a $ in the ref
@ -1007,7 +1014,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param string $cell The Excel cell reference in A1 format.
* @return array
*/
function _cellToRowcol($cell)
private function _cellToRowcol($cell)
{
preg_match('/(\$)?([A-I]?[A-Z])(\$)?(\d+)/', $cell, $match);
// return absolute column if there is a $ in the ref
@ -1037,7 +1044,7 @@ class PHPExcel_Writer_Excel5_Parser
*
* @access private
*/
function _advance()
private function _advance()
{
$i = $this->_current_char;
$formula_length = strlen($this->_formula);
@ -1088,7 +1095,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param mixed $token The token to check.
* @return mixed The checked token or false on failure
*/
function _match($token)
private function _match($token)
{
switch($token) {
case "+":
@ -1126,62 +1133,52 @@ class PHPExcel_Writer_Excel5_Parser
if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/', $token) and
!preg_match("/[0-9]/", $this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.') and
($this->_lookahead != '!'))
{
($this->_lookahead != '!')) {
return $token;
}
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1)
elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $token) and
!preg_match("/[0-9]/", $this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.'))
{
($this->_lookahead != ':') and ($this->_lookahead != '.')) {
return $token;
}
// If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1)
elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u", $token) and
!preg_match("/[0-9]/", $this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.'))
{
($this->_lookahead != ':') and ($this->_lookahead != '.')) {
return $token;
}
// if it's a range A1:A2 or $A$1:$A$2
elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $token) and
!preg_match("/[0-9]/",$this->_lookahead))
{
!preg_match("/[0-9]/", $this->_lookahead)) {
return $token;
}
// If it's an external range like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2
elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $token) and
!preg_match("/[0-9]/",$this->_lookahead))
{
!preg_match("/[0-9]/", $this->_lookahead)) {
return $token;
}
// If it's an external range like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2
elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u", $token) and
!preg_match("/[0-9]/",$this->_lookahead))
{
!preg_match("/[0-9]/", $this->_lookahead)) {
return $token;
}
// If it's a number (check that it's not a sheet name or range)
elseif (is_numeric($token) and
(!is_numeric($token.$this->_lookahead) or ($this->_lookahead == '')) and
($this->_lookahead != '!') and ($this->_lookahead != ':'))
{
($this->_lookahead != '!') and ($this->_lookahead != ':')) {
return $token;
}
// If it's a string (of maximum 255 characters)
elseif (preg_match("/\"([^\"]|\"\"){0,255}\"/",$token) and $this->_lookahead != '"' and (substr_count($token, '"')%2 == 0))
{
elseif (preg_match("/\"([^\"]|\"\"){0,255}\"/", $token) and $this->_lookahead != '"' and (substr_count($token, '"')%2 == 0)) {
return $token;
}
// If it's an error code
elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $token) or $token == '#N/A')
{
elseif (preg_match("/^#[A-Z0\/]{3,5}[!?]{1}$/", $token) or $token == '#N/A') {
return $token;
}
// if it's a function call
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$token) and ($this->_lookahead == "("))
{
elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i", $token) and ($this->_lookahead == "(")) {
return $token;
}
// It's an argument of some description (e.g. a named range),
@ -1201,7 +1198,7 @@ class PHPExcel_Writer_Excel5_Parser
* sign (=).
* @return mixed true on success
*/
function parse($formula)
public function parse($formula)
{
$this->_current_char = 0;
$this->_formula = $formula;
@ -1218,7 +1215,7 @@ class PHPExcel_Writer_Excel5_Parser
* @access private
* @return mixed The parsed ptg'd tree on success
*/
function _condition()
private function _condition()
{
$result = $this->_expression();
if ($this->_current_token == "<") {
@ -1264,7 +1261,7 @@ class PHPExcel_Writer_Excel5_Parser
* @access private
* @return mixed The parsed ptg'd tree on success
*/
function _expression()
private function _expression()
{
// If it's a string return a string node
if (preg_match("/\"([^\"]|\"\"){0,255}\"/", $this->_current_token)) {
@ -1323,7 +1320,7 @@ class PHPExcel_Writer_Excel5_Parser
* @see _fact()
* @return array The parsed ptg'd tree
*/
function _parenthesizedExpression()
private function _parenthesizedExpression()
{
$result = $this->_createTree('ptgParen', $this->_expression(), '');
return $result;
@ -1336,7 +1333,7 @@ class PHPExcel_Writer_Excel5_Parser
* @access private
* @return mixed The parsed ptg'd tree on success
*/
function _term()
private function _term()
{
$result = $this->_fact();
while (($this->_current_token == "*") or
@ -1366,7 +1363,7 @@ class PHPExcel_Writer_Excel5_Parser
* @access private
* @return mixed The parsed ptg'd tree on success
*/
function _fact()
private function _fact()
{
if ($this->_current_token == "(") {
$this->_advance(); // eat the "("
@ -1455,7 +1452,7 @@ class PHPExcel_Writer_Excel5_Parser
* @access private
* @return mixed The parsed ptg'd tree on success
*/
function _func()
private function _func()
{
$num_args = 0; // number of arguments received
$function = strtoupper($this->_current_token);
@ -1505,7 +1502,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param mixed $right The right array (sub-tree) or a final node.
* @return array A tree
*/
function _createTree($value, $left, $right)
private function _createTree($value, $left, $right)
{
return array('value' => $value, 'left' => $left, 'right' => $right);
}
@ -1537,7 +1534,7 @@ class PHPExcel_Writer_Excel5_Parser
* @param array $tree The optional tree to convert.
* @return string The tree in reverse polish notation
*/
function toReversePolish($tree = array())
public function toReversePolish($tree = array())
{
$polish = ""; // the string we are going to return
if (empty($tree)) { // If it's the first call use _parse_tree
@ -1579,5 +1576,4 @@ class PHPExcel_Writer_Excel5_Parser
$polish .= $converted_tree;
return $polish;
}
}

View File

@ -200,9 +200,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* @param array &$colors Colour Table
* @param mixed $parser The formula parser created for the Workbook
*/
public function __construct(PHPExcel $phpExcel = null,
&$str_total, &$str_unique, &$str_table, &$colors,
$parser )
public function __construct(PHPExcel $phpExcel = null, &$str_total, &$str_unique, &$str_table, &$colors, $parser)
{
// It needs to call its parent's constructor explicitly
parent::__construct();
@ -324,7 +322,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* @param string $rgb E.g. 'FF00AA'
* @return int Color index
*/
private function _addColor($rgb) {
private function _addColor($rgb)
{
if (!isset($this->_colors[$rgb])) {
if (count($this->_colors) < 57) {
// then we add a custom color altering the palette
@ -354,7 +353,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
*
* @access private
*/
function _setPaletteXl97()
private function _setPaletteXl97()
{
$this->_palette = array(
0x08 => array(0x00, 0x00, 0x00, 0x00),
@ -477,7 +476,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
*
* @access private
*/
function _calcSheetOffsets()
private function _calcSheetOffsets()
{
$boundsheet_length = 10; // fixed length for a BOUNDSHEET record
@ -612,7 +611,6 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// (exclusive) either repeatColumns or repeatRows
} else if ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) {
// Columns to repeat
if ($sheetSetup->isColumnsToRepeatAtLeftSet()) {
$repeat = $sheetSetup->getColumnsToRepeatAtLeft();
@ -658,7 +656,6 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// Loop named ranges
$namedRanges = $this->_phpExcel->getNamedRanges();
foreach ($namedRanges as $namedRange) {
// Create absolute coordinate
$range = PHPExcel_Cell::splitRange($namedRange->getRange());
for ($i = 0; $i < count($range); $i++) {
@ -721,7 +718,6 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// (exclusive) either repeatColumns or repeatRows
} else if ($sheetSetup->isColumnsToRepeatAtLeftSet() || $sheetSetup->isRowsToRepeatAtTopSet()) {
// Columns to repeat
if ($sheetSetup->isColumnsToRepeatAtLeftSet()) {
$repeat = $sheetSetup->getColumnsToRepeatAtLeft();
@ -842,7 +838,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* @param boolean $isHidden
* @return string Complete binary record data
* */
private function _writeShortNameBiff8($name, $sheetIndex = 0, $rangeBounds, $isHidden = false){
private function _writeShortNameBiff8($name, $sheetIndex = 0, $rangeBounds, $isHidden = false)
{
$record = 0x0018;
// option flags
@ -854,7 +851,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$rangeBounds[0][1] - 1,
$rangeBounds[1][1] - 1,
$rangeBounds[0][0] - 1,
$rangeBounds[1][0] - 1);
$rangeBounds[1][0] - 1
);
// size of the formula (in bytes)
$sz = strlen($extra);
@ -909,10 +907,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$itabCur = $this->_phpExcel->getActiveSheetIndex(); // Active worksheet
$header = pack("vv", $record, $length);
$data = pack("vvvvvvvvv", $xWn, $yWn, $dxWn, $dyWn,
$grbit,
$itabCur, $itabFirst,
$ctabsel, $wTabRatio);
$data = pack("vvvvvvvvv", $xWn, $yWn, $dxWn, $dyWn, $grbit, $itabCur, $itabFirst, $ctabsel, $wTabRatio);
$this->_append($header . $data);
}
@ -929,10 +924,18 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// sheet state
switch ($sheet->getSheetState()) {
case PHPExcel_Worksheet::SHEETSTATE_VISIBLE: $ss = 0x00; break;
case PHPExcel_Worksheet::SHEETSTATE_HIDDEN: $ss = 0x01; break;
case PHPExcel_Worksheet::SHEETSTATE_VERYHIDDEN: $ss = 0x02; break;
default: $ss = 0x00; break;
case PHPExcel_Worksheet::SHEETSTATE_VISIBLE:
$ss = 0x00;
break;
case PHPExcel_Worksheet::SHEETSTATE_HIDDEN:
$ss = 0x01;
break;
case PHPExcel_Worksheet::SHEETSTATE_VERYHIDDEN:
$ss = 0x02;
break;
default:
$ss = 0x00;
break;
}
// sheet type
@ -1307,7 +1310,6 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// loop through all (unique) strings in shared strings table
foreach (array_keys($this->_str_table) as $string) {
// here $string is a BIFF8 encoded string
// length = character count
@ -1320,7 +1322,6 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$finished = false;
while ($finished === false) {
// normally, there will be only one cycle, but if string cannot immediately be written as is
// there will be need for more than one cylcle, if string longer than one record data block, there
// may be need for even more cycles
@ -1422,7 +1423,6 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack("vv", $record, $length);
return $this->writeData($header . $data);
} else {
return '';
}

View File

@ -1590,15 +1590,15 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// record data
$recordData = pack(
'vVVCVVvv'
, 0x0867 // repeated record identifier
, 0x0000 // not used
, 0x0000 // not used
, 0x00 // not used
, 0x01000200 // unknown data
, 0xFFFFFFFF // unknown data
, $options // options
, 0x0000 // not used
'vVVCVVvv',
0x0867, // repeated record identifier
0x0000, // not used
0x0000, // not used
0x00, // not used
0x01000200, // unknown data
0xFFFFFFFF, // unknown data
$options, // options
0x0000 // not used
);
$length = strlen($recordData);
@ -1846,14 +1846,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
}
$header = pack("vv", $record, $length);
$data1 = pack("vvvvvvvv", $iPaperSize,
$iScale,
$iPageStart,
$iFitWidth,
$iFitHeight,
$grbit,
$iRes,
$iVRes);
$data1 = pack("vvvvvvvv", $iPaperSize, $iScale, $iPageStart, $iFitWidth, $iFitHeight, $grbit, $iRes, $iVRes);
$data2 = $numHdr.$numFtr;
$data3 = pack("v", $iCopies);
$this->_append($header . $data1 . $data2 . $data3);
@ -2194,7 +2187,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
//horizontal page breaks
if (!empty($hbreaks)) {
// Sort and filter array of page breaks
sort($hbreaks, SORT_NUMERIC);
if ($hbreaks[0] == 0) { // don't use first break if it's 0
@ -2218,7 +2210,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// vertical page breaks
if (!empty($vbreaks)) {
// 1000 vertical pagebreaks appears to be an internal Excel 5 limit.
// It is slightly higher in Excel 97/200, approx. 1026
$vbreaks = array_slice($vbreaks, 0, 1000);
@ -2472,10 +2463,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$x2 = $width / PHPExcel_Shared_Excel5::sizeCol($this->_phpSheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object
$y2 = $height / PHPExcel_Shared_Excel5::sizeRow($this->_phpSheet, $row_end + 1) * 256; // Distance to bottom of object
$this->_writeObjPicture($col_start, $x1,
$row_start, $y1,
$col_end, $x2,
$row_end, $y2);
$this->_writeObjPicture($col_start, $x1, $row_start, $y1, $col_end, $x2, $row_end, $y2);
}
/**
@ -2748,15 +2736,15 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
if ($spTypes[$i] == 0x00C9) {
// Add ftCmo (common object data) subobject
$objData .=
pack('vvvvvVVV'
, 0x0015 // 0x0015 = ftCmo
, 0x0012 // length of ftCmo data
, 0x0014 // object type, 0x0014 = filter
, $i // object id number, Excel seems to use 1-based index, local for the sheet
, 0x2101 // option flags, 0x2001 is what OpenOffice.org uses
, 0 // reserved
, 0 // reserved
, 0 // reserved
pack('vvvvvVVV',
0x0015, // 0x0015 = ftCmo
0x0012, // length of ftCmo data
0x0014, // object type, 0x0014 = filter
$i, // object id number, Excel seems to use 1-based index, local for the sheet
0x2101, // option flags, 0x2001 is what OpenOffice.org uses
0, // reserved
0, // reserved
0 // reserved
);
// Add ftSbs Scroll bar subobject
@ -2765,27 +2753,26 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// Add ftLbsData (List box data) subobject
$objData .= pack('vv', 0x0013, 0x1FEE);
$objData .= pack('H*', '00000000010001030000020008005700');
}
else {
} else {
// Add ftCmo (common object data) subobject
$objData .=
pack('vvvvvVVV'
, 0x0015 // 0x0015 = ftCmo
, 0x0012 // length of ftCmo data
, 0x0008 // object type, 0x0008 = picture
, $i // object id number, Excel seems to use 1-based index, local for the sheet
, 0x6011 // option flags, 0x6011 is what OpenOffice.org uses
, 0 // reserved
, 0 // reserved
, 0 // reserved
pack('vvvvvVVV',
0x0015, // 0x0015 = ftCmo
0x0012, // length of ftCmo data
0x0008, // object type, 0x0008 = picture
$i, // object id number, Excel seems to use 1-based index, local for the sheet
0x6011, // option flags, 0x6011 is what OpenOffice.org uses
0, // reserved
0, // reserved
0 // reserved
);
}
// ftEnd
$objData .=
pack('vv'
, 0x0000 // 0x0000 = ftEnd
, 0x0000 // length of ftEnd data
pack('vv',
0x0000, // 0x0000 = ftEnd
0x0000 // length of ftEnd data
);
$length = strlen($objData);
@ -2805,7 +2792,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// Write data validations?
if (!empty($dataValidationCollection)) {
// DATAVALIDATIONS record
$record = 0x01B2; // Record identifier
$length = 0x0012; // Bytes to follow
@ -2816,8 +2802,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$objId = 0xFFFFFFFF; // Object identifier of drop down arrow object, or -1 if not visible
$header = pack('vv', $record, $length);
$data = pack('vVVVV', $grbit, $horPos, $verPos, $objId,
count($dataValidationCollection));
$data = pack('vVVVV', $grbit, $horPos, $verPos, $objId, count($dataValidationCollection));
$this->_append($header.$data);
// DATAVALIDATION records
@ -2953,7 +2938,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$this->_parser->parse($formula1);
$formula1 = $this->_parser->toReversePolish();
$sz1 = strlen($formula1);
} catch (PHPExcel_Exception $e) {
$sz1 = 0;
$formula1 = '';
@ -2970,7 +2954,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$this->_parser->parse($formula2);
$formula2 = $this->_parser->toReversePolish();
$sz2 = strlen($formula2);
} catch (PHPExcel_Exception $e) {
$sz2 = 0;
$formula2 = '';