diff --git a/application/controllers/admin/responses.php b/application/controllers/admin/responses.php index ad7dc5e5025..b5fb189fd13 100644 --- a/application/controllers/admin/responses.php +++ b/application/controllers/admin/responses.php @@ -281,6 +281,7 @@ public function view($iSurveyID, $iId, $sBrowseLang = '') $answervalue = "Y"; } } else { + // File upload question type. if (isset($fnames[$i]['type']) && $fnames[$i]['type'] == Question::QT_VERTICAL_FILE_UPLOAD) { $index = $fnames[$i]['index']; $metadata = $fnames[$i]['metadata']; @@ -302,7 +303,7 @@ public function view($iSurveyID, $iId, $sBrowseLang = '') } $aData['bHasFile'] = true; } else { - $answervalue = ""; + $answervalue = ""; } } else { $answervalue = htmlspecialchars(strip_tags(stripJavaScript(getExtendedAnswer($iSurveyID, $fnames[$i][0], $iIdrow[$fnames[$i][0]], $sBrowseLanguage))), ENT_QUOTES); diff --git a/application/core/Survey_Common_Action.php b/application/core/Survey_Common_Action.php index 84971a61860..af5f6c54e21 100644 --- a/application/core/Survey_Common_Action.php +++ b/application/core/Survey_Common_Action.php @@ -428,7 +428,7 @@ public function _showadminmenu($aData) $not = new UniqueNotification(array( 'user_id' => App()->user->id, 'importance' => Notification::HIGH_IMPORTANCE, - 'title' => 'Password warning', + 'title' => gT('Password warning'), 'message' => ' '. gT("Warning: You are still using the default password ('password'). Please change your password and re-login again.") )); diff --git a/application/helpers/SurveyRuntimeHelper.php b/application/helpers/SurveyRuntimeHelper.php index 00ff3908784..27ed1c6d72e 100644 --- a/application/helpers/SurveyRuntimeHelper.php +++ b/application/helpers/SurveyRuntimeHelper.php @@ -383,7 +383,9 @@ public function run($surveyid, $args) // easier to understand for survey maker $aGroup['aQuestions'][$qid]['qid'] = $qa[4]; + $aGroup['aQuestions'][$qid]['gid'] = $qinfo['info']['gid']; $aGroup['aQuestions'][$qid]['code'] = $qa[5]; + $aGroup['aQuestions'][$qid]['type'] = $qinfo['info']['type']; $aGroup['aQuestions'][$qid]['number'] = $qa[0]['number']; $aGroup['aQuestions'][$qid]['text'] = LimeExpressionManager::ProcessString($qa[0]['text'], $qa[4], $aStandardsReplacementFields, 3, 1, false, true, false); $aGroup['aQuestions'][$qid]['SGQ'] = $qa[7]; @@ -395,6 +397,7 @@ public function run($surveyid, $args) $aGroup['aQuestions'][$qid]['answer'] = LimeExpressionManager::ProcessString($qa[1], $qa[4], null, 3, 1, false, true, false); $aGroup['aQuestions'][$qid]['help']['show'] = (flattenText($lemQuestionInfo['info']['help'], true, true) != ''); $aGroup['aQuestions'][$qid]['help']['text'] = LimeExpressionManager::ProcessString($lemQuestionInfo['info']['help'], $qa[4], null, 3, 1, false, true, false); + $aGroup['aQuestions'][$qid] = $this->doBeforeQuestionRenderEvent($aGroup['aQuestions'][$qid]); } $aGroup['show_last_group'] = $aGroup['show_last_answer'] = false; $aGroup['lastgroup'] = $aGroup['lastanswer'] = ''; @@ -1328,10 +1331,10 @@ public static function getQuestionReplacement($aQuestionQanda) $aSurveyinfo = getSurveyInfo($iSurveyId, App()->getLanguage()); // Check global setting to see if survey level setting should be applied if ($showqnumcode_global_ == 'choose') { -// Use survey level settings + // Use survey level settings $showqnumcode_ = $aSurveyinfo['showqnumcode']; //B, N, C, or X } else { -// Use global setting + // Use global setting $showqnumcode_ = $showqnumcode_global_; //both, number, code, or none } @@ -1806,4 +1809,44 @@ private function fixMaxStep() } } + /** + * Apply the plugin even beforeQuestionRender to + * question data. + * + * @see https://manual.limesurvey.org/BeforeQuestionRender + * + * @param array $data Question data + * @return array Question data modified by plugin + */ + protected function doBeforeQuestionRenderEvent($data) + { + $event = new PluginEvent('beforeQuestionRender'); + $event->set('surveyId', $this->iSurveyid); + $event->set('type', $data['type']); + $event->set('code', $data['code']); + $event->set('qid', $data['qid']); + $event->set('gid', $data['gid']); + $event->set('text', $data['text']); + $event->set('input_error_class', $data['input_error_class']); + $event->set('answers', $data['answer']); // NB: "answers" in plugin, "answer" in $data. + $event->set('help', $data['help']['text']); + $event->set('man_message', $data['man_message']); + $event->set('valid_message', $data['valid_message']); + $event->set('file_valid_message', $data['file_valid_message']); + //$event->set('aHtmlOptions', $aHtmlOptions); // TODO + + App()->getPluginManager()->dispatchEvent($event); + + $data['text'] = $event->get('text'); + $data['mandatory'] = $event->get('mandatory',$data['mandatory']); + $data['input_error_class'] = $event->get('input_error_class'); + $data['valid_message'] = $event->get('valid_message'); + $data['file_valid_message'] = $event->get('file_valid_message'); + $data['man_message'] = $event->get('man_message'); + $data['answer'] = $event->get('answers'); + $data['help']['text'] = $event->get('help'); + $data['help']['show'] = flattenText($data['help']['text'], true, true) != ''; + + return $data; + } } diff --git a/application/models/Response.php b/application/models/Response.php index 6a19c88e45a..10b9f0e7faa 100644 --- a/application/models/Response.php +++ b/application/models/Response.php @@ -39,11 +39,21 @@ public static function create($surveyId, $scenario = 'insert') /** * Get all files related to this response and (optionally) question ID. * + * @param int $qid * @return array */ - public function getFiles() + public function getFiles($qid = null) { - $questions = Question::model()->findAllByAttributes(array('sid' => $this->dynamicId, 'type' => Question::QT_VERTICAL_FILE_UPLOAD)); + $survey = Survey::model()->findByPk($this->dynamicId); + $conditions = [ + 'sid' => $this->dynamicId, + 'type' => Question::QT_VERTICAL_FILE_UPLOAD, + 'language'=>$survey->language + ]; + if ($qid !== null) { + $conditions['qid'] = $qid; + } + $questions = Question::model()->findAllByAttributes($conditions); $files = array(); foreach ($questions as $question) { $field = $question->sid.'X'.$question->gid.'X'.$question->qid; diff --git a/application/models/SurveysGroups.php b/application/models/SurveysGroups.php index dbf33505504..74f99b7f89f 100644 --- a/application/models/SurveysGroups.php +++ b/application/models/SurveysGroups.php @@ -65,16 +65,16 @@ public function relations() public function attributeLabels() { return array( - 'gsid' => gT('ID'), - 'name' => gT('Name'), - 'title' => 'Title', + 'gsid' => gT('ID'), + 'name' => gT('Name'), + 'title' => gT('Title'), 'description' => gT('Description'), - 'sortorder' => gT('Sort order'), - 'owner_uid' => gT('Owner UID'), - 'parent_id' => gT('Parent group'), - 'created' => gT('Created on'), - 'modified' => gT('Modified on'), - 'created_by' => gT('Created by'), + 'sortorder' => gT('Sort order'), + 'owner_uid' => gT('Owner UID'), + 'parent_id' => gT('Parent group'), + 'created' => gT('Created on'), + 'modified' => gT('Modified on'), + 'created_by' => gT('Created by'), ); } diff --git a/application/models/User.php b/application/models/User.php index b6ab03950ea..8c2bd65701c 100644 --- a/application/models/User.php +++ b/application/models/User.php @@ -109,6 +109,21 @@ public function getSurveysCreated() return $noofsurveys; } + /** + * @return string + */ + public function getDateFormat() + { + $dateFormat = getDateFormatData(Yii::app()->session['dateformat']); + return $dateFormat['phpdate']; + } + + public function getFormattedDateCreated() + { + $dateCreated = $this->created; + $date = new DateTime($dateCreated); + return $date->format($this->dateFormat); + } /** * Returns onetime password * @@ -458,6 +473,13 @@ public function getColums() "name" =>"parentUserName", "header" => gT("Created by"), ); + + $cols[] = array( + "name" =>"created", + "header" => gT("Created on"), + "value" => '$data->formattedDateCreated', + + ); return $cols; } diff --git a/application/third_party/pear/Spreadsheet/Excel/Writer/BIFFwriter.php b/application/third_party/pear/Spreadsheet/Excel/Writer/BIFFwriter.php index d368e47339b..c84419abf46 100644 --- a/application/third_party/pear/Spreadsheet/Excel/Writer/BIFFwriter.php +++ b/application/third_party/pear/Spreadsheet/Excel/Writer/BIFFwriter.php @@ -1,125 +1,112 @@ -* -* The majority of this is _NOT_ my code. I simply ported it from the -* PERL Spreadsheet::WriteExcel module. -* -* The author of the Spreadsheet::WriteExcel module is John McNamara -* -* -* I _DO_ maintain this code, and John McNamara has nothing to do with the -* porting of this code to PHP. Any questions directly related to this -* class library should be directed to me. -* -* License Information: -* -* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets -* Copyright (c) 2002-2003 Xavier Noguer xnoguer@php.net -* -* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + * Module written/ported by Xavier Noguer + * + * The majority of this is _NOT_ my code. I simply ported it from the + * PERL Spreadsheet::WriteExcel module. + * + * The author of the Spreadsheet::WriteExcel module is John McNamara + * + * + * I _DO_ maintain this code, and John McNamara has nothing to do with the + * porting of this code to PHP. Any questions directly related to this + * class library should be directed to me. + * + * License Information: + * + * Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets + * Copyright (c) 2002-2003 Xavier Noguer xnoguer@php.net + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');} require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'PEAR.php'; /** -* Class for writing Excel BIFF records. -* -* From "MICROSOFT EXCEL BINARY FILE FORMAT" by Mark O'Brien (Microsoft Corporation): -* -* BIFF (BInary File Format) is the file format in which Excel documents are -* saved on disk. A BIFF file is a complete description of an Excel document. -* BIFF files consist of sequences of variable-length records. There are many -* different types of BIFF records. For example, one record type describes a -* formula entered into a cell; one describes the size and location of a -* window into a document; another describes a picture format. -* -* @author Xavier Noguer -* @category FileFormats -* @package Spreadsheet_Excel_Writer -*/ + * Class for writing Excel BIFF records. + * + * From "MICROSOFT EXCEL BINARY FILE FORMAT" by Mark O'Brien (Microsoft Corporation): + * + * BIFF (BInary File Format) is the file format in which Excel documents are + * saved on disk. A BIFF file is a complete description of an Excel document. + * BIFF files consist of sequences of variable-length records. There are many + * different types of BIFF records. For example, one record type describes a + * formula entered into a cell; one describes the size and location of a + * window into a document; another describes a picture format. + * + * @author Xavier Noguer + * @category FileFormats + * @package Spreadsheet_Excel_Writer + */ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR { /** - * The BIFF/Excel version (5). - * @var integer - */ - public $_BIFF_version = 0x0500; + * The BIFF/Excel version (5). + * @var integer + */ + var $_BIFF_version = 0x0500; /** - * The byte order of this architecture. 0 => little endian, 1 => big endian - * @var integer - */ - public $_byte_order; + * The byte order of this architecture. 0 => little endian, 1 => big endian + * @var integer + */ + var $_byte_order; /** - * The string containing the data of the BIFF stream - * @var string - */ - public $_data; + * The string containing the data of the BIFF stream + * @var string + */ + var $_data; /** - * The size of the data in bytes. Should be the same as strlen($this->_data) - * @var integer - */ - public $_datasize; + * The size of the data in bytes. Should be the same as strlen($this->_data) + * @var integer + */ + var $_datasize; /** - * The maximun length for a BIFF record. See _addContinue() - * @var integer - * @see _addContinue() - */ - public $_limit; + * The maximun length for a BIFF record. See _addContinue() + * @var integer + * @see _addContinue() + */ + var $_limit; /** - * The temporary dir for storing the OLE file - * @var string - */ - public $_tmp_dir; - - /** - * The temporary file for storing the OLE file - * @var string - */ - public $_tmp_file; - - /** - * Constructor - * - * @access public - */ - public function __construct() + * Constructor + * + * @access public + */ + function Spreadsheet_Excel_Writer_BIFFwriter() { $this->_byte_order = ''; $this->_data = ''; $this->_datasize = 0; $this->_limit = 2080; - $this->_tmp_dir = ''; // Set the byte order $this->_setByteOrder(); } /** - * Determine the byte order and store it as class data to avoid - * recalculating it for each call to new(). - * - * @access private - */ - protected function _setByteOrder() + * Determine the byte order and store it as class data to avoid + * recalculating it for each call to new(). + * + * @access private + */ + function _setByteOrder() { // Check if "pack" gives the required IEEE 64bit float $teststr = pack("d", 1.2345); @@ -137,12 +124,12 @@ protected function _setByteOrder() } /** - * General storage public function - * - * @param string $data binary data to prepend - * @access private - */ - protected function _prepend($data) + * General storage function + * + * @param string $data binary data to prepend + * @access private + */ + function _prepend($data) { if (strlen($data) > $this->_limit) { $data = $this->_addContinue($data); @@ -152,12 +139,12 @@ protected function _prepend($data) } /** - * General storage public function - * - * @param string $data binary data to append - * @access private - */ - protected function _append($data) + * General storage function + * + * @param string $data binary data to append + * @access private + */ + function _append($data) { if (strlen($data) > $this->_limit) { $data = $this->_addContinue($data); @@ -167,14 +154,14 @@ protected function _append($data) } /** - * Writes Excel BOF record to indicate the beginning of a stream or - * sub-stream in the BIFF file. - * - * @param integer $type Type of BIFF file to write: 0x0005 Workbook, - * 0x0010 Worksheet. - * @access private - */ - protected function _storeBof($type) + * Writes Excel BOF record to indicate the beginning of a stream or + * sub-stream in the BIFF file. + * + * @param integer $type Type of BIFF file to write: 0x0005 Workbook, + * 0x0010 Worksheet. + * @access private + */ + function _storeBof($type) { $record = 0x0809; // Record identifier @@ -199,11 +186,11 @@ protected function _storeBof($type) } /** - * Writes Excel EOF record to indicate the end of a BIFF stream. - * - * @access private - */ - protected function _storeEof() + * Writes Excel EOF record to indicate the end of a BIFF stream. + * + * @access private + */ + function _storeEof() { $record = 0x000A; // Record identifier $length = 0x0000; // Number of bytes to follow @@ -212,18 +199,18 @@ protected function _storeEof() } /** - * Excel limits the size of BIFF records. In Excel 5 the limit is 2084 bytes. In - * Excel 97 the limit is 8228 bytes. Records that are longer than these limits - * must be split up into CONTINUE blocks. - * - * This public function takes a long BIFF record and inserts CONTINUE records as - * necessary. - * - * @param string $data The original binary data to be written - * @return string A very convenient string of continue blocks - * @access private - */ - protected function _addContinue($data) + * Excel limits the size of BIFF records. In Excel 5 the limit is 2084 bytes. In + * Excel 97 the limit is 8228 bytes. Records that are longer than these limits + * must be split up into CONTINUE blocks. + * + * This function takes a long BIFF record and inserts CONTINUE records as + * necessary. + * + * @param string $data The original binary data to be written + * @return string A very convenient string of continue blocks + * @access private + */ + function _addContinue($data) { $limit = $this->_limit; $record = 0x003C; // Record identifier @@ -248,20 +235,5 @@ protected function _addContinue($data) return $tmp; } - - /** - * Sets the temp dir used for storing the OLE file - * - * @access public - * @param string $dir The dir to be used as temp dir - * @return true if given dir is valid, false otherwise - */ - public function setTempDir($dir) - { - if (is_dir($dir)) { - $this->_tmp_dir = $dir; - return true; - } - return false; - } -} \ No newline at end of file +} +?> diff --git a/application/third_party/pear/Spreadsheet/Excel/Writer/Format.php b/application/third_party/pear/Spreadsheet/Excel/Writer/Format.php index 39987ec5363..f62406282a4 100644 --- a/application/third_party/pear/Spreadsheet/Excel/Writer/Format.php +++ b/application/third_party/pear/Spreadsheet/Excel/Writer/Format.php @@ -1,257 +1,257 @@ -* -* The majority of this is _NOT_ my code. I simply ported it from the -* PERL Spreadsheet::WriteExcel module. -* -* The author of the Spreadsheet::WriteExcel module is John McNamara -* -* -* I _DO_ maintain this code, and John McNamara has nothing to do with the -* porting of this code to PHP. Any questions directly related to this -* class library should be directed to me. -* -* License Information: -* -* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets -* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com -* -* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + * Module written/ported by Xavier Noguer + * + * The majority of this is _NOT_ my code. I simply ported it from the + * PERL Spreadsheet::WriteExcel module. + * + * The author of the Spreadsheet::WriteExcel module is John McNamara + * + * + * I _DO_ maintain this code, and John McNamara has nothing to do with the + * porting of this code to PHP. Any questions directly related to this + * class library should be directed to me. + * + * License Information: + * + * Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets + * Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');} require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'PEAR.php'; /** -* Class for generating Excel XF records (formats) -* -* @author Xavier Noguer -* @category FileFormats -* @package Spreadsheet_Excel_Writer -*/ + * Class for generating Excel XF records (formats) + * + * @author Xavier Noguer + * @category FileFormats + * @package Spreadsheet_Excel_Writer + */ class Spreadsheet_Excel_Writer_Format extends PEAR { /** - * The index given by the workbook when creating a new format. - * @var integer - */ - public $_xf_index; + * The index given by the workbook when creating a new format. + * @var integer + */ + var $_xf_index; /** - * Index to the FONT record. - * @var integer - */ - public $font_index; + * Index to the FONT record. + * @var integer + */ + var $font_index; /** - * The font name (ASCII). - * @var string - */ - public $_font_name; + * The font name (ASCII). + * @var string + */ + var $_font_name; /** - * Height of font (1/20 of a point) - * @var integer - */ - public $_size; + * Height of font (1/20 of a point) + * @var integer + */ + var $_size; /** - * Bold style - * @var integer - */ - public $_bold; + * Bold style + * @var integer + */ + var $_bold; /** - * Bit specifiying if the font is italic. - * @var integer - */ - public $_italic; + * Bit specifiying if the font is italic. + * @var integer + */ + var $_italic; /** - * Index to the cell's color - * @var integer - */ - public $_color; + * Index to the cell's color + * @var integer + */ + var $_color; /** - * The text underline property - * @var integer - */ - public $_underline; + * The text underline property + * @var integer + */ + var $_underline; /** - * Bit specifiying if the font has strikeout. - * @var integer - */ - public $_font_strikeout; + * Bit specifiying if the font has strikeout. + * @var integer + */ + var $_font_strikeout; /** - * Bit specifiying if the font has outline. - * @var integer - */ - public $_font_outline; + * Bit specifiying if the font has outline. + * @var integer + */ + var $_font_outline; /** - * Bit specifiying if the font has shadow. - * @var integer - */ - public $_font_shadow; + * Bit specifiying if the font has shadow. + * @var integer + */ + var $_font_shadow; /** - * 2 bytes specifiying the script type for the font. - * @var integer - */ - public $_font_script; + * 2 bytes specifiying the script type for the font. + * @var integer + */ + var $_font_script; /** - * Byte specifiying the font family. - * @var integer - */ - public $_font_family; + * Byte specifiying the font family. + * @var integer + */ + var $_font_family; /** - * Byte specifiying the font charset. - * @var integer - */ - public $_font_charset; + * Byte specifiying the font charset. + * @var integer + */ + var $_font_charset; /** - * An index (2 bytes) to a FORMAT record (number format). - * @var integer - */ - public $_num_format; + * An index (2 bytes) to a FORMAT record (number format). + * @var integer + */ + var $_num_format; /** - * Bit specifying if formulas are hidden. - * @var integer - */ - public $_hidden; + * Bit specifying if formulas are hidden. + * @var integer + */ + var $_hidden; /** - * Bit specifying if the cell is locked. - * @var integer - */ - public $_locked; + * Bit specifying if the cell is locked. + * @var integer + */ + var $_locked; /** - * The three bits specifying the text horizontal alignment. - * @var integer - */ - public $_text_h_align; + * The three bits specifying the text horizontal alignment. + * @var integer + */ + var $_text_h_align; /** - * Bit specifying if the text is wrapped at the right border. - * @var integer - */ - public $_text_wrap; + * Bit specifying if the text is wrapped at the right border. + * @var integer + */ + var $_text_wrap; /** - * The three bits specifying the text vertical alignment. - * @var integer - */ - public $_text_v_align; + * The three bits specifying the text vertical alignment. + * @var integer + */ + var $_text_v_align; /** - * 1 bit, apparently not used. - * @var integer - */ - public $_text_justlast; + * 1 bit, apparently not used. + * @var integer + */ + var $_text_justlast; /** - * The two bits specifying the text rotation. - * @var integer - */ - public $_rotation; + * The two bits specifying the text rotation. + * @var integer + */ + var $_rotation; /** - * The cell's foreground color. - * @var integer - */ - public $_fg_color; + * The cell's foreground color. + * @var integer + */ + var $_fg_color; /** - * The cell's background color. - * @var integer - */ - public $_bg_color; + * The cell's background color. + * @var integer + */ + var $_bg_color; /** - * The cell's background fill pattern. - * @var integer - */ - public $_pattern; + * The cell's background fill pattern. + * @var integer + */ + var $_pattern; /** - * Style of the bottom border of the cell - * @var integer - */ - public $_bottom; + * Style of the bottom border of the cell + * @var integer + */ + var $_bottom; /** - * Color of the bottom border of the cell. - * @var integer - */ - public $_bottom_color; + * Color of the bottom border of the cell. + * @var integer + */ + var $_bottom_color; /** - * Style of the top border of the cell - * @var integer - */ - public $_top; + * Style of the top border of the cell + * @var integer + */ + var $_top; /** - * Color of the top border of the cell. - * @var integer - */ - public $_top_color; + * Color of the top border of the cell. + * @var integer + */ + var $_top_color; /** - * Style of the left border of the cell - * @var integer - */ - public $_left; + * Style of the left border of the cell + * @var integer + */ + var $_left; /** - * Color of the left border of the cell. - * @var integer - */ - public $_left_color; + * Color of the left border of the cell. + * @var integer + */ + var $_left_color; /** - * Style of the right border of the cell - * @var integer - */ - public $_right; + * Style of the right border of the cell + * @var integer + */ + var $_right; /** - * Color of the right border of the cell. - * @var integer - */ - public $_right_color; + * Color of the right border of the cell. + * @var integer + */ + var $_right_color; /** - * Constructor - * - * @access private - * @param integer $index the XF index for the format. - * @param array $properties array with properties to be set on initialization. - */ - public function __construct($BIFF_version, $index = 0, $properties = array()) + * Constructor + * + * @access private + * @param integer $index the XF index for the format. + * @param array $properties array with properties to be set on initialization. + */ + function Spreadsheet_Excel_Writer_Format($BIFF_version, $index = 0, $properties = array()) { $this->_xf_index = $index; $this->_BIFF_version = $BIFF_version; @@ -309,12 +309,12 @@ public function __construct($BIFF_version, $index = 0, $properties = array()) /** - * Generate an Excel BIFF XF record (style or cell). - * - * @param string $style The type of the XF record ('style' or 'cell'). - * @return string The XF record - */ - public function getXf($style) + * Generate an Excel BIFF XF record (style or cell). + * + * @param string $style The type of the XF record ('style' or 'cell'). + * @return string The XF record + */ + function getXf($style) { // Set the type of the XF record and some of the attributes. if ($style == 'style') { @@ -329,12 +329,12 @@ public function getXf($style) $atr_fnt = ($this->font_index != 0)?1:0; $atr_alc = ($this->_text_wrap)?1:0; $atr_bdr = ($this->_bottom || - $this->_top || - $this->_left || - $this->_right)?1:0; + $this->_top || + $this->_left || + $this->_right)?1:0; $atr_pat = (($this->_fg_color != 0x40) || - ($this->_bg_color != 0x41) || - $this->_pattern)?1:0; + ($this->_bg_color != 0x41) || + $this->_pattern)?1:0; $atr_prot = $this->_locked | $this->_hidden; // Zero the default border colour if the border has not been set. @@ -394,8 +394,8 @@ public function getXf($style) $header = pack("vv", $record, $length); $data = pack("vvvvvvvv", $ifnt, $ifmt, $style, $align, - $icv, $fill, - $border1, $border2); + $icv, $fill, + $border1, $border2); } elseif ($this->_BIFF_version == 0x0600) { $align = $this->_text_h_align; // Alignment $align |= $this->_text_wrap << 3; @@ -431,7 +431,7 @@ public function getXf($style) $header = pack("vv", $record, $length); - $rotation = $this->_rotation; + $rotation = 0x00; $biff8_options = 0x00; $data = pack("vvvC", $ifnt, $ifmt, $style, $align); $data .= pack("CCC", $rotation, $biff8_options, $used_attrib); @@ -442,11 +442,11 @@ public function getXf($style) } /** - * Generate an Excel BIFF FONT record. - * - * @return string The FONT record - */ - public function getFont() + * Generate an Excel BIFF FONT record. + * + * @return string The FONT record + */ + function getFont() { $dyHeight = $this->_size * 20; // Height of font (1/20 of a point) $icv = $this->_color; // Index to color palette @@ -482,27 +482,27 @@ public function getFont() $header = pack("vv", $record, $length); if ($this->_BIFF_version == 0x0500) { $data = pack("vvvvvCCCCC", $dyHeight, $grbit, $icv, $bls, - $sss, $uls, $bFamily, - $bCharSet, $reserved, $cch); + $sss, $uls, $bFamily, + $bCharSet, $reserved, $cch); } elseif ($this->_BIFF_version == 0x0600) { $data = pack("vvvvvCCCCCC", $dyHeight, $grbit, $icv, $bls, - $sss, $uls, $bFamily, - $bCharSet, $reserved, $cch, $encoding); + $sss, $uls, $bFamily, + $bCharSet, $reserved, $cch, $encoding); } return($header . $data . $this->_font_name); } /** - * Returns a unique hash key for a font. - * Used by Spreadsheet_Excel_Writer_Workbook::_storeAllFonts() - * - * The elements that form the key are arranged to increase the probability of - * generating a unique key. Elements that hold a large range of numbers - * (eg. _color) are placed between two binary elements such as _italic - * - * @return string A key for this font - */ - public function getFontKey() + * Returns a unique hash key for a font. + * Used by Spreadsheet_Excel_Writer_Workbook::_storeAllFonts() + * + * The elements that form the key are arranged to increase the probability of + * generating a unique key. Elements that hold a large range of numbers + * (eg. _color) are placed between two binary elements such as _italic + * + * @return string A key for this font + */ + function getFontKey() { $key = "$this->_font_name$this->_size"; $key .= "$this->_font_script$this->_underline"; @@ -514,49 +514,49 @@ public function getFontKey() } /** - * Returns the index used by Spreadsheet_Excel_Writer_Worksheet::_XF() - * - * @return integer The index for the XF record - */ - public function getXfIndex() + * Returns the index used by Spreadsheet_Excel_Writer_Worksheet::_XF() + * + * @return integer The index for the XF record + */ + function getXfIndex() { return($this->_xf_index); } /** - * Used in conjunction with the set_xxx_color methods to convert a color - * string into a number. Color range is 0..63 but we will restrict it - * to 8..63 to comply with Gnumeric. Colors 0..7 are repeated in 8..15. - * - * @access private - * @param string $name_color name of the color (i.e.: 'blue', 'red', etc..). Optional. - * @return integer The color index - */ - protected function _getColor($name_color = '') + * Used in conjunction with the set_xxx_color methods to convert a color + * string into a number. Color range is 0..63 but we will restrict it + * to 8..63 to comply with Gnumeric. Colors 0..7 are repeated in 8..15. + * + * @access private + * @param string $name_color name of the color (i.e.: 'blue', 'red', etc..). Optional. + * @return integer The color index + */ + function _getColor($name_color = '') { $colors = array( - 'aqua' => 0x07, - 'cyan' => 0x07, - 'black' => 0x00, - 'blue' => 0x04, - 'brown' => 0x10, - 'magenta' => 0x06, - 'fuchsia' => 0x06, - 'gray' => 0x17, - 'grey' => 0x17, - 'green' => 0x11, - 'lime' => 0x03, - 'navy' => 0x12, - 'orange' => 0x35, - 'purple' => 0x14, - 'red' => 0x02, - 'silver' => 0x16, - 'white' => 0x01, - 'yellow' => 0x05 - ); + 'aqua' => 0x0F, + 'cyan' => 0x0F, + 'black' => 0x08, + 'blue' => 0x0C, + 'brown' => 0x10, + 'magenta' => 0x0E, + 'fuchsia' => 0x0E, + 'gray' => 0x17, + 'grey' => 0x17, + 'green' => 0x11, + 'lime' => 0x0B, + 'navy' => 0x12, + 'orange' => 0x35, + 'purple' => 0x14, + 'red' => 0x0A, + 'silver' => 0x16, + 'white' => 0x09, + 'yellow' => 0x0D + ); // Return the default color, 0x7FFF, if undef, - if ($name_color === '') { + if ($name_color == '') { return(0x7FFF); } @@ -570,6 +570,11 @@ protected function _getColor($name_color = '') return(0x7FFF); } + // or an index < 8 mapped into the correct range, + if ($name_color < 8) { + return($name_color + 8); + } + // or the default color if arg is outside range, if ($name_color > 63) { return(0x7FFF); @@ -580,12 +585,12 @@ protected function _getColor($name_color = '') } /** - * Set cell alignment. - * - * @access public - * @param string $location alignment for the cell ('left', 'right', etc...). - */ - public function setAlign($location) + * Set cell alignment. + * + * @access public + * @param string $location alignment for the cell ('left', 'right', etc...). + */ + function setAlign($location) { if (preg_match("/\d/",$location)) { return; // Ignore numbers @@ -638,12 +643,12 @@ public function setAlign($location) } /** - * Set cell horizontal alignment. - * - * @access public - * @param string $location alignment for the cell ('left', 'right', etc...). - */ - public function setHAlign($location) + * Set cell horizontal alignment. + * + * @access public + * @param string $location alignment for the cell ('left', 'right', etc...). + */ + function setHAlign($location) { if (preg_match("/\d/",$location)) { return; // Ignore numbers @@ -678,12 +683,12 @@ public function setHAlign($location) } /** - * Set cell vertical alignment. - * - * @access public - * @param string $location alignment for the cell ('top', 'vleft', 'vright', etc...). - */ - public function setVAlign($location) + * Set cell vertical alignment. + * + * @access public + * @param string $location alignment for the cell ('top', 'vleft', 'vright', etc...). + */ + function setVAlign($location) { if (preg_match("/\d/",$location)) { return; // Ignore numbers @@ -712,26 +717,26 @@ public function setVAlign($location) } /** - * This is an alias for the unintuitive setAlign('merge') - * - * @access public - */ - public function setMerge() + * This is an alias for the unintuitive setAlign('merge') + * + * @access public + */ + function setMerge() { $this->setAlign('merge'); } /** - * Sets the boldness of the text. - * Bold has a range 100..1000. - * 0 (400) is normal. 1 (700) is bold. - * - * @access public - * @param integer $weight Weight for the text, 0 maps to 400 (normal text), - 1 maps to 700 (bold text). Valid range is: 100-1000. - It's Optional, default is 1 (bold). - */ - public function setBold($weight = 1) + * Sets the boldness of the text. + * Bold has a range 100..1000. + * 0 (400) is normal. 1 (700) is bold. + * + * @access public + * @param integer $weight Weight for the text, 0 maps to 400 (normal text), + 1 maps to 700 (bold text). Valid range is: 100-1000. + It's Optional, default is 1 (bold). + */ + function setBold($weight = 1) { if ($weight == 1) { $weight = 0x2BC; // Bold text @@ -750,61 +755,61 @@ public function setBold($weight = 1) /************************************ - * FUNCTIONS FOR SETTING CELLS BORDERS - */ + * FUNCTIONS FOR SETTING CELLS BORDERS + */ /** - * Sets the width for the bottom border of the cell - * - * @access public - * @param integer $style style of the cell border. 1 => thin, 2 => thick. - */ - public function setBottom($style) + * Sets the width for the bottom border of the cell + * + * @access public + * @param integer $style style of the cell border. 1 => thin, 2 => thick. + */ + function setBottom($style) { $this->_bottom = $style; } /** - * Sets the width for the top border of the cell - * - * @access public - * @param integer $style style of the cell top border. 1 => thin, 2 => thick. - */ - public function setTop($style) + * Sets the width for the top border of the cell + * + * @access public + * @param integer $style style of the cell top border. 1 => thin, 2 => thick. + */ + function setTop($style) { $this->_top = $style; } /** - * Sets the width for the left border of the cell - * - * @access public - * @param integer $style style of the cell left border. 1 => thin, 2 => thick. - */ - public function setLeft($style) + * Sets the width for the left border of the cell + * + * @access public + * @param integer $style style of the cell left border. 1 => thin, 2 => thick. + */ + function setLeft($style) { $this->_left = $style; } /** - * Sets the width for the right border of the cell - * - * @access public - * @param integer $style style of the cell right border. 1 => thin, 2 => thick. - */ - public function setRight($style) + * Sets the width for the right border of the cell + * + * @access public + * @param integer $style style of the cell right border. 1 => thin, 2 => thick. + */ + function setRight($style) { $this->_right = $style; } /** - * Set cells borders to the same style - * - * @access public - * @param integer $style style to apply for all cell borders. 1 => thin, 2 => thick. - */ - public function setBorder($style) + * Set cells borders to the same style + * + * @access public + * @param integer $style style to apply for all cell borders. 1 => thin, 2 => thick. + */ + function setBorder($style) { $this->setBottom($style); $this->setTop($style); @@ -814,17 +819,17 @@ public function setBorder($style) /******************************************* - * FUNCTIONS FOR SETTING CELLS BORDERS COLORS - */ + * FUNCTIONS FOR SETTING CELLS BORDERS COLORS + */ /** - * Sets all the cell's borders to the same color - * - * @access public - * @param mixed $color The color we are setting. Either a string (like 'blue'), - * or an integer (range is [8...63]). - */ - public function setBorderColor($color) + * Sets all the cell's borders to the same color + * + * @access public + * @param mixed $color The color we are setting. Either a string (like 'blue'), + * or an integer (range is [8...63]). + */ + function setBorderColor($color) { $this->setBottomColor($color); $this->setTopColor($color); @@ -833,48 +838,48 @@ public function setBorderColor($color) } /** - * Sets the cell's bottom border color - * - * @access public - * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). - */ - public function setBottomColor($color) + * Sets the cell's bottom border color + * + * @access public + * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). + */ + function setBottomColor($color) { $value = $this->_getColor($color); $this->_bottom_color = $value; } /** - * Sets the cell's top border color - * - * @access public - * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). - */ - public function setTopColor($color) + * Sets the cell's top border color + * + * @access public + * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). + */ + function setTopColor($color) { $value = $this->_getColor($color); $this->_top_color = $value; } /** - * Sets the cell's left border color - * - * @access public - * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). - */ - public function setLeftColor($color) + * Sets the cell's left border color + * + * @access public + * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). + */ + function setLeftColor($color) { $value = $this->_getColor($color); $this->_left_color = $value; } /** - * Sets the cell's right border color - * - * @access public - * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). - */ - public function setRightColor($color) + * Sets the cell's right border color + * + * @access public + * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). + */ + function setRightColor($color) { $value = $this->_getColor($color); $this->_right_color = $value; @@ -882,12 +887,12 @@ public function setRightColor($color) /** - * Sets the cell's foreground color - * - * @access public - * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). - */ - public function setFgColor($color) + * Sets the cell's foreground color + * + * @access public + * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). + */ + function setFgColor($color) { $value = $this->_getColor($color); $this->_fg_color = $value; @@ -897,12 +902,12 @@ public function setFgColor($color) } /** - * Sets the cell's background color - * - * @access public - * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). - */ - public function setBgColor($color) + * Sets the cell's background color + * + * @access public + * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). + */ + function setBgColor($color) { $value = $this->_getColor($color); $this->_bg_color = $value; @@ -912,80 +917,80 @@ public function setBgColor($color) } /** - * Sets the cell's color - * - * @access public - * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). - */ - public function setColor($color) + * Sets the cell's color + * + * @access public + * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). + */ + function setColor($color) { $value = $this->_getColor($color); $this->_color = $value; } /** - * Sets the fill pattern attribute of a cell - * - * @access public - * @param integer $arg Optional. Defaults to 1. Meaningful values are: 0-18, - * 0 meaning no background. - */ - public function setPattern($arg = 1) + * Sets the fill pattern attribute of a cell + * + * @access public + * @param integer $arg Optional. Defaults to 1. Meaningful values are: 0-18, + * 0 meaning no background. + */ + function setPattern($arg = 1) { $this->_pattern = $arg; } /** - * Sets the underline of the text - * - * @access public - * @param integer $underline The value for underline. Possible values are: - * 1 => underline, 2 => double underline. - */ - public function setUnderline($underline) + * Sets the underline of the text + * + * @access public + * @param integer $underline The value for underline. Possible values are: + * 1 => underline, 2 => double underline. + */ + function setUnderline($underline) { $this->_underline = $underline; } /** - * Sets the font style as italic - * - * @access public - */ - public function setItalic() + * Sets the font style as italic + * + * @access public + */ + function setItalic() { $this->_italic = 1; } /** - * Sets the font size - * - * @access public - * @param integer $size The font size (in pixels I think). - */ - public function setSize($size) + * Sets the font size + * + * @access public + * @param integer $size The font size (in pixels I think). + */ + function setSize($size) { $this->_size = $size; } /** - * Sets text wrapping - * - * @access public - */ - public function setTextWrap() + * Sets text wrapping + * + * @access public + */ + function setTextWrap() { $this->_text_wrap = 1; } /** - * Sets the orientation of the text - * - * @access public - * @param integer $angle The rotation angle for the text (clockwise). Possible - values are: 0, 90, 270 and -1 for stacking top-to-bottom. - */ - public function setTextRotation($angle) + * Sets the orientation of the text + * + * @access public + * @param integer $angle The rotation angle for the text (clockwise). Possible + values are: 0, 90, 270 and -1 for stacking top-to-bottom. + */ + function setTextRotation($angle) { switch ($angle) { @@ -993,25 +998,13 @@ public function setTextRotation($angle) $this->_rotation = 0; break; case 90: - if ($this->_BIFF_version == 0x0500) { $this->_rotation = 3; - } elseif ($this->_BIFF_version == 0x0600) { - $this->_rotation = 180; - } break; case 270: - if ($this->_BIFF_version == 0x0500) { $this->_rotation = 2; - } elseif ($this->_BIFF_version == 0x0600) { - $this->_rotation = 90; - } break; case -1: - if ($this->_BIFF_version == 0x0500) { $this->_rotation = 1; - } elseif ($this->_BIFF_version == 0x0600) { - $this->_rotation = 255; - } break; default : return $this->raiseError("Invalid value for angle.". @@ -1023,88 +1016,89 @@ public function setTextRotation($angle) } /** - * Sets the numeric format. - * It can be date, time, currency, etc... - * - * @access public - * @param integer $num_format The numeric format. - */ - public function setNumFormat($num_format) + * Sets the numeric format. + * It can be date, time, currency, etc... + * + * @access public + * @param integer $num_format The numeric format. + */ + function setNumFormat($num_format) { $this->_num_format = $num_format; } /** - * Sets font as strikeout. - * - * @access public - */ - public function setStrikeOut() + * Sets font as strikeout. + * + * @access public + */ + function setStrikeOut() { $this->_font_strikeout = 1; } /** - * Sets outlining for a font. - * - * @access public - */ - public function setOutLine() + * Sets outlining for a font. + * + * @access public + */ + function setOutLine() { $this->_font_outline = 1; } /** - * Sets font as shadow. - * - * @access public - */ - public function setShadow() + * Sets font as shadow. + * + * @access public + */ + function setShadow() { $this->_font_shadow = 1; } /** - * Sets the script type of the text - * - * @access public - * @param integer $script The value for script type. Possible values are: - * 1 => superscript, 2 => subscript. - */ - public function setScript($script) + * Sets the script type of the text + * + * @access public + * @param integer $script The value for script type. Possible values are: + * 1 => superscript, 2 => subscript. + */ + function setScript($script) { $this->_font_script = $script; } - /** + /** * Locks a cell. * * @access public */ - public function setLocked() - { - $this->_locked = 1; - } + function setLocked() + { + $this->_locked = 1; + } /** - * Unlocks a cell. Useful for unprotecting particular cells of a protected sheet. - * - * @access public - */ - public function setUnLocked() + * Unlocks a cell. Useful for unprotecting particular cells of a protected sheet. + * + * @access public + */ + function setUnLocked() { $this->_locked = 0; } /** - * Sets the font family name. - * - * @access public - * @param string $fontfamily The font family name. Possible values are: - * 'Times New Roman', 'Arial', 'Courier'. - */ - public function setFontFamily($font_family) + * Sets the font family name. + * + * @access public + * @param string $fontfamily The font family name. Possible values are: + * 'Times New Roman', 'Arial', 'Courier'. + */ + function setFontFamily($font_family) { $this->_font_name = $font_family; } -} \ No newline at end of file +} +?> diff --git a/application/third_party/pear/Spreadsheet/Excel/Writer/Parser.php b/application/third_party/pear/Spreadsheet/Excel/Writer/Parser.php index 855be2b6b99..953a756992e 100644 --- a/application/third_party/pear/Spreadsheet/Excel/Writer/Parser.php +++ b/application/third_party/pear/Spreadsheet/Excel/Writer/Parser.php @@ -1,176 +1,172 @@ " -*/ + * @const SPREADSHEET_EXCEL_WRITER_GT token identifier for character ">" + */ define('SPREADSHEET_EXCEL_WRITER_GT', ">"); /** -* @const SPREADSHEET_EXCEL_WRITER_LT token identifier for character "<" -*/ + * @const SPREADSHEET_EXCEL_WRITER_LT token identifier for character "<" + */ define('SPREADSHEET_EXCEL_WRITER_LT', "<"); /** -* @const SPREADSHEET_EXCEL_WRITER_LE token identifier for character "<=" -*/ + * @const SPREADSHEET_EXCEL_WRITER_LE token identifier for character "<=" + */ define('SPREADSHEET_EXCEL_WRITER_LE', "<="); /** -* @const SPREADSHEET_EXCEL_WRITER_GE token identifier for character ">=" -*/ + * @const SPREADSHEET_EXCEL_WRITER_GE token identifier for character ">=" + */ define('SPREADSHEET_EXCEL_WRITER_GE', ">="); /** -* @const SPREADSHEET_EXCEL_WRITER_EQ token identifier for character "=" -*/ + * @const SPREADSHEET_EXCEL_WRITER_EQ token identifier for character "=" + */ define('SPREADSHEET_EXCEL_WRITER_EQ', "="); /** -* @const SPREADSHEET_EXCEL_WRITER_NE token identifier for character "<>" -*/ + * @const SPREADSHEET_EXCEL_WRITER_NE token identifier for character "<>" + */ define('SPREADSHEET_EXCEL_WRITER_NE', "<>"); -/** -* * @const SPREADSHEET_EXCEL_WRITER_CONCAT token identifier for character "&" -*/ -define('SPREADSHEET_EXCEL_WRITER_CONCAT', "&"); if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');} require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'PEAR.php'; /** -* Class for parsing Excel formulas -* -* @author Xavier Noguer -* @category FileFormats -* @package Spreadsheet_Excel_Writer -*/ + * Class for parsing Excel formulas + * + * @author Xavier Noguer + * @category FileFormats + * @package Spreadsheet_Excel_Writer + */ class Spreadsheet_Excel_Writer_Parser extends PEAR { /** - * The index of the character we are currently looking at - * @var integer - */ - public $_current_char; + * The index of the character we are currently looking at + * @var integer + */ + var $_current_char; /** - * The token we are working on. - * @var string - */ - public $_current_token; + * The token we are working on. + * @var string + */ + var $_current_token; /** - * The formula to parse - * @var string - */ - public $_formula; + * The formula to parse + * @var string + */ + var $_formula; /** - * The character ahead of the current char - * @var string - */ - public $_lookahead; + * The character ahead of the current char + * @var string + */ + var $_lookahead; /** - * The parse tree to be generated - * @var string - */ - public $_parse_tree; + * The parse tree to be generated + * @var string + */ + var $_parse_tree; /** - * The byte order. 1 => big endian, 0 => little endian. - * @var integer - */ - public $_byte_order; + * The byte order. 1 => big endian, 0 => little endian. + * @var integer + */ + var $_byte_order; /** - * Array of external sheets - * @var array - */ - public $_ext_sheets; + * Array of external sheets + * @var array + */ + var $_ext_sheets; /** - * Array of sheet references in the form of REF structures - * @var array - */ - public $_references; + * Array of sheet references in the form of REF structures + * @var array + */ + var $_references; /** - * The BIFF version for the workbook - * @var integer - */ - public $_BIFF_version; + * The BIFF version for the workbook + * @var integer + */ + var $_BIFF_version; /** - * The class constructor - * - * @param integer $byte_order The byte order (Little endian or Big endian) of the architecture - (optional). 1 => big endian, 0 (default) little endian. - */ - public function __construct($byte_order, $biff_version) + * The class constructor + * + * @param integer $byte_order The byte order (Little endian or Big endian) of the architecture + (optional). 1 => big endian, 0 (default) little endian. + */ + function Spreadsheet_Excel_Writer_Parser($byte_order, $biff_version) { $this->_current_char = 0; $this->_BIFF_version = $biff_version; @@ -178,18 +174,18 @@ public function __construct($byte_order, $biff_version) $this->_formula = ''; // The formula to parse. $this->_lookahead = ''; // The character ahead of the current char. $this->_parse_tree = ''; // The parse tree to be generated. - $this->_initializeHashes(); // Initialize the hashes: ptg's and public function's ptg's + $this->_initializeHashes(); // Initialize the hashes: ptg's and function's ptg's $this->_byte_order = $byte_order; // Little Endian or Big Endian $this->_ext_sheets = array(); $this->_references = array(); } /** - * Initialize the ptg and public function hashes. - * - * @access private - */ - protected function _initializeHashes() + * Initialize the ptg and function hashes. + * + * @access private + */ + function _initializeHashes() { // The Excel ptg indices $this->ptg = array( @@ -288,23 +284,23 @@ protected function _initializeHashes() 'ptgArea3dA' => 0x7B, 'ptgRefErr3dA' => 0x7C, 'ptgAreaErr3d' => 0x7D - ); + ); // Thanks to Michael Meeks and Gnumeric for the initial arg values. // // The following hash was generated by "function_locale.pl" in the distro. - // Refer to function_locale.pl for non-English public function names. + // Refer to function_locale.pl for non-English function names. // // The array elements are as follow: - // ptg: The Excel public function ptg code. - // args: The number of arguments that the public function takes: + // ptg: The Excel function ptg code. + // args: The number of arguments that the function takes: // >=0 is a fixed number of arguments. // -1 is a variable number of arguments. - // class: The reference, value or array class of the public function args. - // vol: The public function is volatile. + // class: The reference, value or array class of the function args. + // vol: The function is volatile. // $this->_functions = array( - // public function ptg args class vol + // function ptg args class vol 'COUNT' => array( 0, -1, 0, 0 ), 'IF' => array( 1, -1, 1, 0 ), 'ISNA' => array( 2, 1, 1, 0 ), @@ -530,18 +526,18 @@ protected function _initializeHashes() 'COUNTIF' => array( 346, 2, 0, 0 ), 'COUNTBLANK' => array( 347, 1, 0, 0 ), 'ROMAN' => array( 354, -1, 1, 0 ) - ); + ); } /** - * Convert a token to the proper ptg value. - * - * @access private - * @param mixed $token The token to convert. - * @return mixed the converted token on success. PEAR_Error if the token - * is not recognized - */ - protected function _convert($token) + * Convert a token to the proper ptg value. + * + * @access private + * @param mixed $token The token to convert. + * @return mixed the converted token on success. PEAR_Error if the token + * is not recognized + */ + function _convert($token) { if (preg_match("/^\"[^\"]{0,255}\"$/", $token)) { return $this->_convertString($token); @@ -549,45 +545,45 @@ protected function _convert($token) } elseif (is_numeric($token)) { return $this->_convertNumber($token); - // match references like A1 or $A$1 + // match references like A1 or $A$1 } elseif (preg_match('/^\$?([A-Ia-i]?[A-Za-z])\$?(\d+)$/',$token)) { return $this->_convertRef2d($token); - // match external references like Sheet1!A1 or Sheet1:Sheet2!A1 + // match external references like Sheet1!A1 or Sheet1:Sheet2!A1 } elseif (preg_match("/^\w+(\:\w+)?\![A-Ia-i]?[A-Za-z](\d+)$/u",$token)) { return $this->_convertRef3d($token); - // match external references like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1 + // match external references like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1 } elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\![A-Ia-i]?[A-Za-z](\d+)$/u",$token)) { return $this->_convertRef3d($token); - // match ranges like A1:B2 + // match ranges like A1:B2 } elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\:(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/",$token)) { return $this->_convertRange2d($token); - // match ranges like A1..B2 + // match ranges like A1..B2 } elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/",$token)) { return $this->_convertRange2d($token); - // match external ranges like Sheet1!A1 or Sheet1:Sheet2!A1:B2 + // match external ranges like Sheet1!A1 or Sheet1:Sheet2!A1:B2 } elseif (preg_match("/^\w+(\:\w+)?\!([A-Ia-i]?[A-Za-z])?(\d+)\:([A-Ia-i]?[A-Za-z])?(\d+)$/u",$token)) { return $this->_convertRange3d($token); - // match external ranges like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1:B2 + // match external ranges like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1:B2 } elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!([A-Ia-i]?[A-Za-z])?(\d+)\:([A-Ia-i]?[A-Za-z])?(\d+)$/u",$token)) { return $this->_convertRange3d($token); - // operators (including parentheses) + // operators (including parentheses) } elseif (isset($this->ptg[$token])) { return pack("C", $this->ptg[$token]); - // commented so argument number can be processed correctly. See toReversePolish(). - /*elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]+/",$token)) - { + // commented so argument number can be processed correctly. See toReversePolish(). + /*elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]+/",$token)) + { return($this->_convertFunction($token,$this->_func_args)); - }*/ + }*/ - // if it's an argument, ignore the token (the argument remains) + // if it's an argument, ignore the token (the argument remains) } elseif ($token == 'arg') { return ''; } @@ -596,12 +592,12 @@ protected function _convert($token) } /** - * Convert a number token to ptgInt or ptgNum - * - * @access private - * @param mixed $num an integer or double for conversion to its ptg value - */ - protected function _convertNumber($num) + * Convert a number token to ptgInt or ptgNum + * + * @access private + * @param mixed $num an integer or double for conversion to its ptg value + */ + function _convertNumber($num) { // Integer in the range 0..2**16-1 if ((preg_match("/^\d+$/", $num)) and ($num <= 65535)) { @@ -615,14 +611,14 @@ protected function _convertNumber($num) } /** - * Convert a string token to ptgStr - * - * @access private - * @param string $string A string for conversion to its ptg value. - * @return mixed the converted token on success. PEAR_Error if the string - * is longer than 255 characters. - */ - protected function _convertString($string) + * Convert a string token to ptgStr + * + * @access private + * @param string $string A string for conversion to its ptg value. + * @return mixed the converted token on success. PEAR_Error if the string + * is longer than 255 characters. + */ + function _convertString($string) { // chop away beggining and ending quotes $string = substr($string, 1, strlen($string) - 2); @@ -639,15 +635,15 @@ protected function _convertString($string) } /** - * Convert a public function to a ptgFunc or ptgFuncVarV depending on the number of - * args that it takes. - * - * @access private - * @param string $token The name of the public function for convertion to ptg value. - * @param integer $num_args The number of arguments the public function receives. - * @return string The packed ptg for the public function - */ - protected function _convertFunction($token, $num_args) + * Convert a function to a ptgFunc or ptgFuncVarV depending on the number of + * args that it takes. + * + * @access private + * @param string $token The name of the function for convertion to ptg value. + * @param integer $num_args The number of arguments the function receives. + * @return string The packed ptg for the function + */ + function _convertFunction($token, $num_args) { $args = $this->_functions[$token][1]; $volatile = $this->_functions[$token][3]; @@ -663,20 +659,20 @@ protected function _convertFunction($token, $num_args) } /** - * Convert an Excel range such as A1:D4 to a ptgRefV. - * - * @access private - * @param string $range An Excel range in the A1:A2 or A1..A2 format. - */ - protected function _convertRange2d($range, $class=0) + * Convert an Excel range such as A1:D4 to a ptgRefV. + * + * @access private + * @param string $range An Excel range in the A1:A2 or A1..A2 format. + */ + function _convertRange2d($range) { + $class = 2; // as far as I know, this is magick. - // TODO: possible class value 0,1,2 check Formula.pm // Split the range into 2 cell refs if (preg_match("/^([A-Ia-i]?[A-Za-z])(\d+)\:([A-Ia-i]?[A-Za-z])(\d+)$/", $range)) { - list($cell1, $cell2) = explode(':', $range); + list($cell1, $cell2) = split(':', $range); } elseif (preg_match("/^([A-Ia-i]?[A-Za-z])(\d+)\.\.([A-Ia-i]?[A-Za-z])(\d+)$/", $range)) { - list($cell1, $cell2) = explode('..', $range); + list($cell1, $cell2) = split('\.\.', $range); } else { // TODO: use real error codes @@ -710,19 +706,19 @@ protected function _convertRange2d($range, $class=0) } /** - * Convert an Excel 3d range such as "Sheet1!A1:D4" or "Sheet1:Sheet2!A1:D4" to - * a ptgArea3d. - * - * @access private - * @param string $token An Excel range in the Sheet1!A1:A2 format. - * @return mixed The packed ptgArea3d token on success, PEAR_Error on failure. - */ - protected function _convertRange3d($token) + * Convert an Excel 3d range such as "Sheet1!A1:D4" or "Sheet1:Sheet2!A1:D4" to + * a ptgArea3d. + * + * @access private + * @param string $token An Excel range in the Sheet1!A1:A2 format. + * @return mixed The packed ptgArea3d token on success, PEAR_Error on failure. + */ + function _convertRange3d($token) { $class = 2; // as far as I know, this is magick. // Split the ref at the ! symbol - list($ext_ref, $range) = explode('!', $token); + list($ext_ref, $range) = split('!', $token); // Convert the external reference part (different for BIFF8) if ($this->_BIFF_version == 0x0500) { @@ -731,14 +727,14 @@ protected function _convertRange3d($token) return $ext_ref; } } elseif ($this->_BIFF_version == 0x0600) { - $ext_ref = $this->_getRefIndex($ext_ref); - if (PEAR::isError($ext_ref)) { - return $ext_ref; - } + $ext_ref = $this->_getRefIndex($ext_ref); + if (PEAR::isError($ext_ref)) { + return $ext_ref; + } } // Split the range into 2 cell refs - list($cell1, $cell2) = explode(':', $range); + list($cell1, $cell2) = split(':', $range); // Convert the cell references if (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/", $cell1)) { @@ -753,11 +749,11 @@ protected function _convertRange3d($token) } list($row2, $col2) = $cell_array2; } else { // It's a rows range (like 26:27) - $cells_array = $this->_rangeToPackedRange($cell1.':'.$cell2); - if (PEAR::isError($cells_array)) { - return $cells_array; - } - list($row1, $col1, $row2, $col2) = $cells_array; + $cells_array = $this->_rangeToPackedRange($cell1.':'.$cell2); + if (PEAR::isError($cells_array)) { + return $cells_array; + } + list($row1, $col1, $row2, $col2) = $cells_array; } // The ptg value depends on the class of the ptg. @@ -775,13 +771,13 @@ protected function _convertRange3d($token) } /** - * Convert an Excel reference such as A1, $B2, C$3 or $D$4 to a ptgRefV. - * - * @access private - * @param string $cell An Excel cell reference - * @return string The cell in packed() format with the corresponding ptg - */ - protected function _convertRef2d($cell) + * Convert an Excel reference such as A1, $B2, C$3 or $D$4 to a ptgRefV. + * + * @access private + * @param string $cell An Excel cell reference + * @return string The cell in packed() format with the corresponding ptg + */ + function _convertRef2d($cell) { $class = 2; // as far as I know, this is magick. @@ -807,19 +803,19 @@ protected function _convertRef2d($cell) } /** - * Convert an Excel 3d reference such as "Sheet1!A1" or "Sheet1:Sheet2!A1" to a - * ptgRef3d. - * - * @access private - * @param string $cell An Excel cell reference - * @return mixed The packed ptgRef3d token on success, PEAR_Error on failure. - */ - protected function _convertRef3d($cell) + * Convert an Excel 3d reference such as "Sheet1!A1" or "Sheet1:Sheet2!A1" to a + * ptgRef3d. + * + * @access private + * @param string $cell An Excel cell reference + * @return mixed The packed ptgRef3d token on success, PEAR_Error on failure. + */ + function _convertRef3d($cell) { $class = 2; // as far as I know, this is magick. // Split the ref at the ! symbol - list($ext_ref, $cell) = explode('!', $cell); + list($ext_ref, $cell) = split('!', $cell); // Convert the external reference part (different for BIFF8) if ($this->_BIFF_version == 0x0500) { @@ -852,21 +848,21 @@ protected function _convertRef3d($cell) } /** - * Convert the sheet name part of an external reference, for example "Sheet1" or - * "Sheet1:Sheet2", to a packed structure. - * - * @access private - * @param string $ext_ref The name of the external reference - * @return string The reference index in packed() format - */ - protected function _packExtRef($ext_ref) + * Convert the sheet name part of an external reference, for example "Sheet1" or + * "Sheet1:Sheet2", to a packed structure. + * + * @access private + * @param string $ext_ref The name of the external reference + * @return string The reference index in packed() format + */ + function _packExtRef($ext_ref) { $ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any. $ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any. // Check if there is a sheet range eg., Sheet1:Sheet2. if (preg_match("/:/", $ext_ref)) { - list($sheet_name1, $sheet_name2) = explode(':', $ext_ref); + list($sheet_name1, $sheet_name2) = split(':', $ext_ref); $sheet1 = $this->_getSheetIndex($sheet_name1); if ($sheet1 == -1) { @@ -896,23 +892,23 @@ protected function _packExtRef($ext_ref) } /** - * Look up the REF index that corresponds to an external sheet name - * (or range). If it doesn't exist yet add it to the workbook's references - * array. It assumes all sheet names given must exist. - * - * @access private - * @param string $ext_ref The name of the external reference - * @return mixed The reference index in packed() format on success, - * PEAR_Error on failure - */ - protected function _getRefIndex($ext_ref) + * Look up the REF index that corresponds to an external sheet name + * (or range). If it doesn't exist yet add it to the workbook's references + * array. It assumes all sheet names given must exist. + * + * @access private + * @param string $ext_ref The name of the external reference + * @return mixed The reference index in packed() format on success, + * PEAR_Error on failure + */ + function _getRefIndex($ext_ref) { $ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any. $ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any. // Check if there is a sheet range eg., Sheet1:Sheet2. if (preg_match("/:/", $ext_ref)) { - list($sheet_name1, $sheet_name2) = explode(':', $ext_ref); + list($sheet_name1, $sheet_name2) = split(':', $ext_ref); $sheet1 = $this->_getSheetIndex($sheet_name1); if ($sheet1 == -1) { @@ -956,14 +952,14 @@ protected function _getRefIndex($ext_ref) } /** - * Look up the index that corresponds to an external sheet name. The hash of - * sheet names is updated by the addworksheet() method of the - * Spreadsheet_Excel_Writer_Workbook class. - * - * @access private - * @return integer The sheet index, -1 if the sheet was not found - */ - protected function _getSheetIndex($sheet_name) + * Look up the index that corresponds to an external sheet name. The hash of + * sheet names is updated by the addworksheet() method of the + * Spreadsheet_Excel_Writer_Workbook class. + * + * @access private + * @return integer The sheet index, -1 if the sheet was not found + */ + function _getSheetIndex($sheet_name) { if (!isset($this->_ext_sheets[$sheet_name])) { return -1; @@ -973,28 +969,28 @@ protected function _getSheetIndex($sheet_name) } /** - * This method is used to update the array of sheet names. It is - * called by the addWorksheet() method of the - * Spreadsheet_Excel_Writer_Workbook class. - * - * @access public - * @see Spreadsheet_Excel_Writer_Workbook::addWorksheet() - * @param string $name The name of the worksheet being added - * @param integer $index The index of the worksheet being added - */ - public function setExtSheet($name, $index) + * This method is used to update the array of sheet names. It is + * called by the addWorksheet() method of the + * Spreadsheet_Excel_Writer_Workbook class. + * + * @access public + * @see Spreadsheet_Excel_Writer_Workbook::addWorksheet() + * @param string $name The name of the worksheet being added + * @param integer $index The index of the worksheet being added + */ + function setExtSheet($name, $index) { $this->_ext_sheets[$name] = $index; } /** - * pack() row and column into the required 3 or 4 byte format. - * - * @access private - * @param string $cell The Excel cell reference to be packed - * @return array Array containing the row and column in packed() format - */ - protected function _cellToPackedRowcol($cell) + * pack() row and column into the required 3 or 4 byte format. + * + * @access private + * @param string $cell The Excel cell reference to be packed + * @return array Array containing the row and column in packed() format + */ + function _cellToPackedRowcol($cell) { $cell = strtoupper($cell); list($row, $col, $row_rel, $col_rel) = $this->_cellToRowcol($cell); @@ -1022,14 +1018,14 @@ protected function _cellToPackedRowcol($cell) } /** - * pack() row range into the required 3 or 4 byte format. - * Just using maximum col/rows, which is probably not the correct solution - * - * @access private - * @param string $range The Excel range to be packed - * @return array Array containing (row1,col1,row2,col2) in packed() format - */ - protected function _rangeToPackedRange($range) + * pack() row range into the required 3 or 4 byte format. + * Just using maximum col/rows, which is probably not the correct solution + * + * @access private + * @param string $range The Excel range to be packed + * @return array Array containing (row1,col1,row2,col2) in packed() format + */ + function _rangeToPackedRange($range) { preg_match('/(\$)?(\d+)\:(\$)?(\d+)/', $range, $match); // return absolute rows if there is a $ in the ref @@ -1068,15 +1064,15 @@ protected function _rangeToPackedRange($range) } /** - * Convert an Excel cell reference such as A1 or $B2 or C$3 or $D$4 to a zero - * indexed row and column number. Also returns two (0,1) values to indicate - * whether the row or column are relative references. - * - * @access private - * @param string $cell The Excel cell reference in A1 format. - * @return array - */ - protected function _cellToRowcol($cell) + * Convert an Excel cell reference such as A1 or $B2 or C$3 or $D$4 to a zero + * indexed row and column number. Also returns two (0,1) values to indicate + * whether the row or column are relative references. + * + * @access private + * @param string $cell The Excel cell reference in A1 format. + * @return array + */ + function _cellToRowcol($cell) { preg_match('/(\$)?([A-I]?[A-Z])(\$)?(\d+)/',$cell,$match); // return absolute column if there is a $ in the ref @@ -1102,11 +1098,11 @@ protected function _cellToRowcol($cell) } /** - * Advance to the next valid token. - * - * @access private - */ - protected function _advance() + * Advance to the next valid token. + * + * @access private + */ + function _advance() { $i = $this->_current_char; $formula_length = strlen($this->_formula); @@ -1150,13 +1146,13 @@ protected function _advance() } /** - * Checks if it's a valid token. - * - * @access private - * @param mixed $token The token to check. - * @return mixed The checked token or false on failure - */ - protected function _match($token) + * Checks if it's a valid token. + * + * @access private + * @param mixed $token The token to check. + * @return mixed The checked token or false on failure + */ + function _match($token) { switch($token) { case SPREADSHEET_EXCEL_WRITER_ADD: @@ -1208,60 +1204,57 @@ protected function _match($token) case SPREADSHEET_EXCEL_WRITER_NE: return $token; break; - case SPREADSHEET_EXCEL_WRITER_CONCAT: - return $token; - break; default: // if it's a reference 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 != '!')) + !preg_match("/[0-9]/",$this->_lookahead) and + ($this->_lookahead != ':') and ($this->_lookahead != '.') and + ($this->_lookahead != '!')) { return $token; } // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1) elseif (preg_match("/^\w+(\:\w+)?\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and - !preg_match("/[0-9]/",$this->_lookahead) and - ($this->_lookahead != ':') and ($this->_lookahead != '.')) + !preg_match("/[0-9]/",$this->_lookahead) and + ($this->_lookahead != ':') and ($this->_lookahead != '.')) { return $token; } // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1) elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and - !preg_match("/[0-9]/",$this->_lookahead) and - ($this->_lookahead != ':') and ($this->_lookahead != '.')) + !preg_match("/[0-9]/",$this->_lookahead) and + ($this->_lookahead != ':') and ($this->_lookahead != '.')) { return $token; } // if it's a range (A1:A2) 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 a range (A1..A2) 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 or Sheet1:Sheet2!A1:B2 elseif (preg_match("/^\w+(\:\w+)?\!([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 or 'Sheet1:Sheet2'!A1:B2 elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!([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 != ':')) + (!is_numeric($token.$this->_lookahead) or ($this->_lookahead == '')) and + ($this->_lookahead != '!') and ($this->_lookahead != ':')) { return $token; } @@ -1270,7 +1263,7 @@ protected function _match($token) { return $token; } - // if it's a public function call + // if it's a function call elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$token) and ($this->_lookahead == "(")) { return $token; @@ -1280,14 +1273,14 @@ protected function _match($token) } /** - * The parsing method. It parses a formula. - * - * @access public - * @param string $formula The formula to parse, without the initial equal - * sign (=). - * @return mixed true on success, PEAR_Error on failure - */ - public function parse($formula) + * The parsing method. It parses a formula. + * + * @access public + * @param string $formula The formula to parse, without the initial equal + * sign (=). + * @return mixed true on success, PEAR_Error on failure + */ + function parse($formula) { $this->_current_char = 0; $this->_formula = $formula; @@ -1301,13 +1294,13 @@ public function parse($formula) } /** - * It parses a condition. It assumes the following rule: - * Cond -> Expr [(">" | "<") Expr] - * - * @access private - * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure - */ - protected function _condition() + * It parses a condition. It assumes the following rule: + * Cond -> Expr [(">" | "<") Expr] + * + * @access private + * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure + */ + function _condition() { $result = $this->_expression(); if (PEAR::isError($result)) { @@ -1355,27 +1348,20 @@ protected function _condition() return $result2; } $result = $this->_createTree('ptgNE', $result, $result2); - } elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_CONCAT) { - $this->_advance(); - $result2 = $this->_expression(); - if (PEAR::isError($result2)) { - return $result2; - } - $result = $this->_createTree('ptgConcat', $result, $result2); } return $result; } /** - * It parses a expression. It assumes the following rule: - * Expr -> Term [("+" | "-") Term] - * -> "string" - * -> "-" Term - * - * @access private - * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure - */ - protected function _expression() + * It parses a expression. It assumes the following rule: + * Expr -> Term [("+" | "-") Term] + * -> "string" + * -> "-" Term + * + * @access private + * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure + */ + function _expression() { // If it's a string return a string node if (preg_match("/^\"[^\"]{0,255}\"$/", $this->_current_token)) { @@ -1394,8 +1380,8 @@ protected function _expression() return $result; } while (($this->_current_token == SPREADSHEET_EXCEL_WRITER_ADD) or - ($this->_current_token == SPREADSHEET_EXCEL_WRITER_SUB)) { - /**/ + ($this->_current_token == SPREADSHEET_EXCEL_WRITER_SUB)) { + /**/ if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_ADD) { $this->_advance(); $result2 = $this->_term(); @@ -1416,35 +1402,35 @@ protected function _expression() } /** - * This public function just introduces a ptgParen element in the tree, so that Excel - * doesn't get confused when working with a parenthesized formula afterwards. - * - * @access private - * @see _fact() - * @return array The parsed ptg'd tree - */ - protected function _parenthesizedExpression() + * This function just introduces a ptgParen element in the tree, so that Excel + * doesn't get confused when working with a parenthesized formula afterwards. + * + * @access private + * @see _fact() + * @return array The parsed ptg'd tree + */ + function _parenthesizedExpression() { $result = $this->_createTree('ptgParen', $this->_expression(), ''); return $result; } /** - * It parses a term. It assumes the following rule: - * Term -> Fact [("*" | "/") Fact] - * - * @access private - * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure - */ - protected function _term() + * It parses a term. It assumes the following rule: + * Term -> Fact [("*" | "/") Fact] + * + * @access private + * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure + */ + function _term() { $result = $this->_fact(); if (PEAR::isError($result)) { return $result; } while (($this->_current_token == SPREADSHEET_EXCEL_WRITER_MUL) or - ($this->_current_token == SPREADSHEET_EXCEL_WRITER_DIV)) { - /**/ + ($this->_current_token == SPREADSHEET_EXCEL_WRITER_DIV)) { + /**/ if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_MUL) { $this->_advance(); $result2 = $this->_fact(); @@ -1465,17 +1451,17 @@ protected function _term() } /** - * It parses a factor. It assumes the following rule: - * Fact -> ( Expr ) - * | CellRef - * | CellRange - * | Number - * | Function - * - * @access private - * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure - */ - protected function _fact() + * It parses a factor. It assumes the following rule: + * Fact -> ( Expr ) + * | CellRef + * | CellRange + * | Number + * | Function + * + * @access private + * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure + */ + function _fact() { if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_OPEN) { $this->_advance(); // eat the "(" @@ -1509,7 +1495,7 @@ protected function _fact() } // if it's a range elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token) or - preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token)) + preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token)) { $result = $this->_current_token; $this->_advance(); @@ -1535,7 +1521,7 @@ protected function _fact() $this->_advance(); return $result; } - // if it's a public function call + // if it's a function call elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$this->_current_token)) { $result = $this->_func(); @@ -1547,13 +1533,13 @@ protected function _fact() } /** - * It parses a public function call. It assumes the following rule: - * Func -> ( Expr [,Expr]* ) - * - * @access private - * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure - */ - protected function _func() + * It parses a function call. It assumes the following rule: + * Func -> ( Expr [,Expr]* ) + * + * @access private + * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure + */ + function _func() { $num_args = 0; // number of arguments received $function = strtoupper($this->_current_token); @@ -1561,15 +1547,15 @@ protected function _func() $this->_advance(); $this->_advance(); // eat the "(" while ($this->_current_token != ')') { - /**/ + /**/ if ($num_args > 0) { if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_COMA or - $this->_current_token == SPREADSHEET_EXCEL_WRITER_SEMICOLON) + $this->_current_token == SPREADSHEET_EXCEL_WRITER_SEMICOLON) { $this->_advance(); // eat the "," or ";" } else { return $this->raiseError("Syntax error: comma expected in ". - "public function $function, arg #{$num_args}"); + "function $function, arg #{$num_args}"); } $result2 = $this->_condition(); if (PEAR::isError($result2)) { @@ -1591,7 +1577,7 @@ protected function _func() $args = $this->_functions[$function][1]; // If fixed number of args eg. TIME($i,$j,$k). Check that the number of args is valid. if (($args >= 0) and ($args != $num_args)) { - return $this->raiseError("Incorrect number of arguments in public function $function() "); + return $this->raiseError("Incorrect number of arguments in function $function() "); } $result = $this->_createTree($function, $result, $num_args); @@ -1600,48 +1586,48 @@ protected function _func() } /** - * Creates a tree. In fact an array which may have one or two arrays (sub-trees) - * as elements. - * - * @access private - * @param mixed $value The value of this node. - * @param mixed $left The left array (sub-tree) or a final node. - * @param mixed $right The right array (sub-tree) or a final node. - * @return array A tree - */ - protected function _createTree($value, $left, $right) + * Creates a tree. In fact an array which may have one or two arrays (sub-trees) + * as elements. + * + * @access private + * @param mixed $value The value of this node. + * @param mixed $left The left array (sub-tree) or a final node. + * @param mixed $right The right array (sub-tree) or a final node. + * @return array A tree + */ + function _createTree($value, $left, $right) { return array('value' => $value, 'left' => $left, 'right' => $right); } /** - * Builds a string containing the tree in reverse polish notation (What you - * would use in a HP calculator stack). - * The following tree: - * - * + - * / \ - * 2 3 - * - * produces: "23+" - * - * The following tree: - * - * + - * / \ - * 3 * - * / \ - * 6 A1 - * - * produces: "36A1*+" - * - * In fact all operands, functions, references, etc... are written as ptg's - * - * @access public - * @param array $tree The optional tree to convert. - * @return string The tree in reverse polish notation - */ - public function toReversePolish($tree = array()) + * Builds a string containing the tree in reverse polish notation (What you + * would use in a HP calculator stack). + * The following tree: + * + * + + * / \ + * 2 3 + * + * produces: "23+" + * + * The following tree: + * + * + + * / \ + * 3 * + * / \ + * 6 A1 + * + * produces: "36A1*+" + * + * In fact all operands, functions, references, etc... are written as ptg's + * + * @access public + * @param array $tree The optional tree to convert. + * @return string The tree in reverse polish notation + */ + function toReversePolish($tree = array()) { $polish = ""; // the string we are going to return if (empty($tree)) { // If it's the first call use _parse_tree @@ -1673,14 +1659,14 @@ public function toReversePolish($tree = array()) } $polish .= $converted_tree; } - // if it's a public function convert it here (so we can set it's arguments) + // if it's a function convert it here (so we can set it's arguments) if (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/",$tree['value']) and - !preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/',$tree['value']) and - !preg_match("/^[A-Ia-i]?[A-Za-z](\d+)\.\.[A-Ia-i]?[A-Za-z](\d+)$/",$tree['value']) and - !is_numeric($tree['value']) and - !isset($this->ptg[$tree['value']])) + !preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/',$tree['value']) and + !preg_match("/^[A-Ia-i]?[A-Za-z](\d+)\.\.[A-Ia-i]?[A-Za-z](\d+)$/",$tree['value']) and + !is_numeric($tree['value']) and + !isset($this->ptg[$tree['value']])) { - // left subtree for a public function is always an array. + // left subtree for a function is always an array. if ($tree['left'] != '') { $left_tree = $this->toReversePolish($tree['left']); } else { @@ -1700,4 +1686,5 @@ public function toReversePolish($tree = array()) $polish .= $converted_tree; return $polish; } -} \ No newline at end of file +} +?> diff --git a/application/third_party/pear/Spreadsheet/Excel/Writer/Validator.php b/application/third_party/pear/Spreadsheet/Excel/Writer/Validator.php index e2bd4cf3867..f10b84d15ad 100644 --- a/application/third_party/pear/Spreadsheet/Excel/Writer/Validator.php +++ b/application/third_party/pear/Spreadsheet/Excel/Writer/Validator.php @@ -1,26 +1,26 @@ -* -* License Information: -* -* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets -* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com -* -* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + * Module written by Herman Kuiper + * + * License Information: + * + * Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets + * Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ //require_once('PEAR.php'); @@ -39,35 +39,35 @@ define("OP_LTE", 0x07); /** -* Baseclass for generating Excel DV records (validations) -* -* @author Herman Kuiper -* @category FileFormats -* @package Spreadsheet_Excel_Writer -*/ + * Baseclass for generating Excel DV records (validations) + * + * @author Herman Kuiper + * @category FileFormats + * @package Spreadsheet_Excel_Writer + */ class Spreadsheet_Excel_Writer_Validator { - public $_type; - public $_style; - public $_fixedList; - public $_blank; - public $_incell; - public $_showprompt; - public $_showerror; - public $_title_prompt; - public $_descr_prompt; - public $_title_error; - public $_descr_error; - public $_operator; - public $_formula1; - public $_formula2; + var $_type; + var $_style; + var $_fixedList; + var $_blank; + var $_incell; + var $_showprompt; + var $_showerror; + var $_title_prompt; + var $_descr_prompt; + var $_title_error; + var $_descr_error; + var $_operator; + var $_formula1; + var $_formula2; /** - * The parser from the workbook. Used to parse validation formulas also - * @var Spreadsheet_Excel_Writer_Parser - */ - public $_parser; + * The parser from the workbook. Used to parse validation formulas also + * @var Spreadsheet_Excel_Writer_Parser + */ + var $_parser; - public function __construct($parser) + function Spreadsheet_Excel_Writer_Validator(&$parser) { $this->_parser = $parser; $this->_type = 0x01; // FIXME: add method for setting datatype @@ -86,41 +86,41 @@ public function __construct($parser) $this->_formula2 = ''; } - public function setPrompt($promptTitle = "\x00", $promptDescription = "\x00", $showPrompt = true) - { - $this->_showprompt = $showPrompt; - $this->_title_prompt = $promptTitle; - $this->_descr_prompt = $promptDescription; - } - - public function setError($errorTitle = "\x00", $errorDescription = "\x00", $showError = true) - { - $this->_showerror = $showError; - $this->_title_error = $errorTitle; - $this->_descr_error = $errorDescription; - } - - public function allowBlank() - { - $this->_blank = true; - } - - public function onInvalidStop() - { - $this->_style = 0x00; - } - - public function onInvalidWarn() + function setPrompt($promptTitle = "\x00", $promptDescription = "\x00", $showPrompt = true) + { + $this->_showprompt = $showPrompt; + $this->_title_prompt = $promptTitle; + $this->_descr_prompt = $promptDescription; + } + + function setError($errorTitle = "\x00", $errorDescription = "\x00", $showError = true) + { + $this->_showerror = $showError; + $this->_title_error = $errorTitle; + $this->_descr_error = $errorDescription; + } + + function allowBlank() + { + $this->_blank = true; + } + + function onInvalidStop() + { + $this->_style = 0x00; + } + + function onInvalidWarn() { $this->_style = 0x01; } - public function onInvalidInfo() + function onInvalidInfo() { $this->_style = 0x02; } - public function setFormula1($formula) + function setFormula1($formula) { // Parse the formula using the parser in Parser.php $error = $this->_parser->parse($formula); @@ -135,7 +135,7 @@ public function setFormula1($formula) return true; } - public function setFormula2($formula) + function setFormula2($formula) { // Parse the formula using the parser in Parser.php $error = $this->_parser->parse($formula); @@ -150,7 +150,7 @@ public function setFormula2($formula) return true; } - protected function _getOptions() + function _getOptions() { $options = $this->_type; $options |= $this->_style << 3; @@ -169,60 +169,62 @@ protected function _getOptions() if ($this->_showerror) { $options |= 0x80000; } - $options |= $this->_operator << 20; + $options |= $this->_operator << 20; - return $options; - } + return $options; + } - protected function _getData() - { - $title_prompt_len = strlen($this->_title_prompt); - $descr_prompt_len = strlen($this->_descr_prompt); - $title_error_len = strlen($this->_title_error); - $descr_error_len = strlen($this->_descr_error); + function _getData() + { + $title_prompt_len = strlen($this->_title_prompt); + $descr_prompt_len = strlen($this->_descr_prompt); + $title_error_len = strlen($this->_title_error); + $descr_error_len = strlen($this->_descr_error); - $formula1_size = strlen($this->_formula1); - $formula2_size = strlen($this->_formula2); + $formula1_size = strlen($this->_formula1); + $formula2_size = strlen($this->_formula2); - $data = pack("V", $this->_getOptions()); - $data .= pack("vC", $title_prompt_len, 0x00) . $this->_title_prompt; - $data .= pack("vC", $title_error_len, 0x00) . $this->_title_error; - $data .= pack("vC", $descr_prompt_len, 0x00) . $this->_descr_prompt; - $data .= pack("vC", $descr_error_len, 0x00) . $this->_descr_error; + $data = pack("V", $this->_getOptions()); + $data .= pack("vC", $title_prompt_len, 0x00) . $this->_title_prompt; + $data .= pack("vC", $title_error_len, 0x00) . $this->_title_error; + $data .= pack("vC", $descr_prompt_len, 0x00) . $this->_descr_prompt; + $data .= pack("vC", $descr_error_len, 0x00) . $this->_descr_error; - $data .= pack("vv", $formula1_size, 0x0000) . $this->_formula1; - $data .= pack("vv", $formula2_size, 0x0000) . $this->_formula2; + $data .= pack("vv", $formula1_size, 0x0000) . $this->_formula1; + $data .= pack("vv", $formula2_size, 0x0000) . $this->_formula2; - return $data; - } + return $data; + } } /*class Spreadsheet_Excel_Writer_Validation_List extends Spreadsheet_Excel_Writer_Validation -{ - public function Spreadsheet_Excel_Writer_Validation_list() - { - parent::Spreadsheet_Excel_Writer_Validation(); - $this->_type = 0x03; - } - - public function setList($source, $incell = true) - { - $this->_incell = $incell; - $this->_fixedList = true; - - $source = implode("\x00", $source); - $this->_formula1 = pack("CCC", 0x17, strlen($source), 0x0c) . $source; - } - - public function setRow($row, $col1, $col2, $incell = true) - { - $this->_incell = $incell; - //$this->_formula1 = ...; - } - - public function setCol($col, $row1, $row2, $incell = true) - { - $this->_incell = $incell; - //$this->_formula1 = ...; - } -}*/ \ No newline at end of file + { + function Spreadsheet_Excel_Writer_Validation_list() + { + parent::Spreadsheet_Excel_Writer_Validation(); + $this->_type = 0x03; + } + + function setList($source, $incell = true) + { + $this->_incell = $incell; + $this->_fixedList = true; + + $source = implode("\x00", $source); + $this->_formula1 = pack("CCC", 0x17, strlen($source), 0x0c) . $source; + } + + function setRow($row, $col1, $col2, $incell = true) + { + $this->_incell = $incell; + //$this->_formula1 = ...; + } + + function setCol($col, $row1, $row2, $incell = true) + { + $this->_incell = $incell; + //$this->_formula1 = ...; + } + }*/ + +?> diff --git a/application/third_party/pear/Spreadsheet/Excel/Writer/Workbook.php b/application/third_party/pear/Spreadsheet/Excel/Writer/Workbook.php index 0e29fea9a84..3532ddf5347 100644 --- a/application/third_party/pear/Spreadsheet/Excel/Writer/Workbook.php +++ b/application/third_party/pear/Spreadsheet/Excel/Writer/Workbook.php @@ -1,36 +1,36 @@ -* -* The majority of this is _NOT_ my code. I simply ported it from the -* PERL Spreadsheet::WriteExcel module. -* -* The author of the Spreadsheet::WriteExcel module is John McNamara -* -* -* I _DO_ maintain this code, and John McNamara has nothing to do with the -* porting of this code to PHP. Any questions directly related to this -* class library should be directed to me. -* -* License Information: -* -* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets -* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com -* -* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + * Module written/ported by Xavier Noguer + * + * The majority of this is _NOT_ my code. I simply ported it from the + * PERL Spreadsheet::WriteExcel module. + * + * The author of the Spreadsheet::WriteExcel module is John McNamara + * + * + * I _DO_ maintain this code, and John McNamara has nothing to do with the + * porting of this code to PHP. Any questions directly related to this + * class library should be directed to me. + * + * License Information: + * + * Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets + * Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');} @@ -42,144 +42,147 @@ require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'OLE'.DIRECTORY_SEPARATOR.'PPS'.DIRECTORY_SEPARATOR.'File.php'; /** -* Class for generating Excel Spreadsheets -* -* @author Xavier Noguer -* @category FileFormats -* @package Spreadsheet_Excel_Writer -*/ + * Class for generating Excel Spreadsheets + * + * @author Xavier Noguer + * @category FileFormats + * @package Spreadsheet_Excel_Writer + */ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwriter { /** - * Filename for the Workbook - * @var string - */ - public $_filename; + * Filename for the Workbook + * @var string + */ + var $_filename; /** - * Formula parser - * @var Spreadsheet_Excel_Writer_Parser - */ - public $_parser; + * Formula parser + * @var object Parser + */ + var $_parser; /** - * Flag for 1904 date system (0 => base date is 1900, 1 => base date is 1904) - * @var integer - */ - public $_1904; + * Flag for 1904 date system (0 => base date is 1900, 1 => base date is 1904) + * @var integer + */ + var $_1904; /** - * The active worksheet of the workbook (0 indexed) - * @var integer - */ - public $_activesheet; + * The active worksheet of the workbook (0 indexed) + * @var integer + */ + var $_activesheet; /** - * 1st displayed worksheet in the workbook (0 indexed) - * @var integer - */ - public $_firstsheet; + * 1st displayed worksheet in the workbook (0 indexed) + * @var integer + */ + var $_firstsheet; /** - * Number of workbook tabs selected - * @var integer - */ - public $_selected; + * Number of workbook tabs selected + * @var integer + */ + var $_selected; /** - * Index for creating adding new formats to the workbook - * @var integer - */ - public $_xf_index; + * Index for creating adding new formats to the workbook + * @var integer + */ + var $_xf_index; /** - * Flag for preventing close from being called twice. - * @var integer - * @see close() - */ - public $_fileclosed; + * Flag for preventing close from being called twice. + * @var integer + * @see close() + */ + var $_fileclosed; /** - * The BIFF file size for the workbook. - * @var integer - * @see _calcSheetOffsets() - */ - public $_biffsize; + * The BIFF file size for the workbook. + * @var integer + * @see _calcSheetOffsets() + */ + var $_biffsize; /** - * The default sheetname for all sheets created. - * @var string - */ - public $_sheetname; + * The default sheetname for all sheets created. + * @var string + */ + var $_sheetname; /** - * The default XF format. - * @var Spreadsheet_Excel_Writer_Format - */ - public $_tmp_format; + * The default XF format. + * @var object Format + */ + var $_tmp_format; /** - * Array containing references to all of this workbook's worksheets - * @var array - */ - public $_worksheets; + * Array containing references to all of this workbook's worksheets + * @var array + */ + var $_worksheets; /** - * Array of sheetnames for creating the EXTERNSHEET records - * @var array - */ - public $_sheetnames; + * Array of sheetnames for creating the EXTERNSHEET records + * @var array + */ + var $_sheetnames; /** - * Array containing references to all of this workbook's formats - * @var array - */ - public $_formats; + * Array containing references to all of this workbook's formats + * @var array + */ + var $_formats; /** - * Array containing the colour palette - * @var array - */ - public $_palette; + * Array containing the colour palette + * @var array + */ + var $_palette; /** - * The default format for URLs. - * @var Spreadsheet_Excel_Writer_Format - */ - public $_url_format; + * The default format for URLs. + * @var object Format + */ + var $_url_format; /** - * The codepage indicates the text encoding used for strings - * @var integer - */ - public $_codepage; + * The codepage indicates the text encoding used for strings + * @var integer + */ + var $_codepage; /** - * The country code used for localization - * @var integer - */ - public $_country_code; + * The country code used for localization + * @var integer + */ + var $_country_code; /** - * number of bytes for sizeinfo of strings - * @var integer - */ - public $_string_sizeinfo_size; + * The temporary dir for storing the OLE file + * @var string + */ + var $_tmp_dir; - /** @var int */ - public $_timestamp; + /** + * number of bytes for sizeinfo of strings + * @var integer + */ + var $_string_sizeinfo_size; /** - * Class constructor - * - * @param string filename for storing the workbook. "-" for writing to stdout. - * @access public - */ - public function __construct($filename) + * Class constructor + * + * @param string filename for storing the workbook. "-" for writing to stdout. + * @access public + */ + function Spreadsheet_Excel_Writer_Workbook($filename) { // It needs to call its parent's constructor explicitly - parent::__construct(); + $this->Spreadsheet_Excel_Writer_BIFFwriter(); $this->_filename = $filename; $this->_parser = new Spreadsheet_Excel_Writer_Parser($this->_byte_order, $this->_BIFF_version); @@ -201,23 +204,22 @@ public function __construct($filename) $this->_string_sizeinfo = 3; // Add the default format for hyperlinks - $this->_url_format = $this->addFormat(array('color' => 'blue', 'underline' => 1)); + $this->_url_format =& $this->addFormat(array('color' => 'blue', 'underline' => 1)); $this->_str_total = 0; $this->_str_unique = 0; $this->_str_table = array(); - $this->_timestamp = time(); - $this->_setPaletteXl97(); + $this->_tmp_dir = ''; } /** - * Calls finalization methods. - * This method should always be the last one to be called on every workbook - * - * @access public - * @return mixed true on success. PEAR_Error on failure - */ - public function close() + * Calls finalization methods. + * This method should always be the last one to be called on every workbook + * + * @access public + * @return mixed true on success. PEAR_Error on failure + */ + function close() { if ($this->_fileclosed) { // Prevent close() from being called twice. return true; @@ -231,42 +233,42 @@ public function close() } /** - * An accessor for the _worksheets[] array - * Returns an array of the worksheet objects in a workbook - * It actually calls to worksheets() - * - * @access public - * @see worksheets() - * @return array - */ - public function sheets() + * An accessor for the _worksheets[] array + * Returns an array of the worksheet objects in a workbook + * It actually calls to worksheets() + * + * @access public + * @see worksheets() + * @return array + */ + function sheets() { return $this->worksheets(); } /** - * An accessor for the _worksheets[] array. - * Returns an array of the worksheet objects in a workbook - * - * @access public - * @return array - */ - public function worksheets() + * An accessor for the _worksheets[] array. + * Returns an array of the worksheet objects in a workbook + * + * @access public + * @return array + */ + function worksheets() { return $this->_worksheets; } /** - * Sets the BIFF version. - * This method exists just to access experimental public functionality - * from BIFF8. It will be deprecated ! - * Only possible value is 8 (Excel 97/2000). - * For any other value it fails silently. - * - * @access public - * @param integer $version The BIFF version - */ - public function setVersion($version) + * Sets the BIFF version. + * This method exists just to access experimental functionality + * from BIFF8. It will be deprecated ! + * Only possible value is 8 (Excel 97/2000). + * For any other value it fails silently. + * + * @access public + * @param integer $version The BIFF version + */ + function setVersion($version) { if ($version == 8) { // only accept version 8 $version = 0x0600; @@ -276,7 +278,6 @@ public function setVersion($version) $this->_tmp_format->_BIFF_version = $version; $this->_url_format->_BIFF_version = $version; $this->_parser->_BIFF_version = $version; - $this->_codepage = 0x04B0; $total_worksheets = count($this->_worksheets); // change version for all worksheets too @@ -293,28 +294,28 @@ public function setVersion($version) } /** - * Set the country identifier for the workbook - * - * @access public - * @param integer $code Is the international calling country code for the - * chosen country. - */ - public function setCountry($code) + * Set the country identifier for the workbook + * + * @access public + * @param integer $code Is the international calling country code for the + * chosen country. + */ + function setCountry($code) { $this->_country_code = $code; } /** - * Add a new worksheet to the Excel workbook. - * If no name is given the name of the worksheet will be Sheeti$i, with - * $i in [1..]. - * - * @access public - * @param string $name the optional name of the worksheet - * @return mixed reference to a worksheet object on success, PEAR_Error - * on failure - */ - public function addWorksheet($name = '') + * Add a new worksheet to the Excel workbook. + * If no name is given the name of the worksheet will be Sheeti$i, with + * $i in [1..]. + * + * @access public + * @param string $name the optional name of the worksheet + * @return mixed reference to a worksheet object on success, PEAR_Error + * on failure + */ + function &addWorksheet($name = '') { $index = count($this->_worksheets); $sheetname = $this->_sheetname; @@ -329,10 +330,6 @@ public function addWorksheet($name = '') if (strlen($name) > 31) { return $this->raiseError("Sheetname $name must be <= 31 chars"); } - } else { - if(function_exists('iconv')) { - $name = iconv('UTF-8','UTF-16LE',$name); - } } // Check that the worksheet name doesn't already exist: a fatal Excel error. @@ -344,31 +341,31 @@ public function addWorksheet($name = '') } $worksheet = new Spreadsheet_Excel_Writer_Worksheet($this->_BIFF_version, - $name, $index, - $this->_activesheet, $this->_firstsheet, - $this->_str_total, $this->_str_unique, - $this->_str_table, $this->_url_format, - $this->_parser, $this->_tmp_dir); + $name, $index, + $this->_activesheet, $this->_firstsheet, + $this->_str_total, $this->_str_unique, + $this->_str_table, $this->_url_format, + $this->_parser); - $this->_worksheets[$index] = $worksheet; // Store ref for iterator + $this->_worksheets[$index] = &$worksheet; // Store ref for iterator $this->_sheetnames[$index] = $name; // Store EXTERNSHEET names $this->_parser->setExtSheet($name, $index); // Register worksheet name with parser return $worksheet; } /** - * Add a new format to the Excel workbook. - * Also, pass any properties to the Format constructor. - * - * @access public - * @param array $properties array with properties for initializing the format. - * @return Spreadsheet_Excel_Writer_Format - */ - public function addFormat($properties = array()) + * Add a new format to the Excel workbook. + * Also, pass any properties to the Format constructor. + * + * @access public + * @param array $properties array with properties for initializing the format. + * @return &Spreadsheet_Excel_Writer_Format reference to an Excel Format + */ + function &addFormat($properties = array()) { $format = new Spreadsheet_Excel_Writer_Format($this->_BIFF_version, $this->_xf_index, $properties); $this->_xf_index += 1; - $this->_formats[] = $format; + $this->_formats[] = &$format; return $format; } @@ -376,33 +373,31 @@ public function addFormat($properties = array()) * Create new validator. * * @access public - * @return Spreadsheet_Excel_Writer_Validator + * @return &Spreadsheet_Excel_Writer_Validator reference to a Validator */ - public function addValidator() + function &addValidator() { - if (!class_exists('Spreadsheet_Excel_Writer_Validator')) { - include_once 'Spreadsheet/Excel/Writer/Validator.php'; - } + include_once 'Spreadsheet/Excel/Writer/Validator.php'; /* FIXME: check for successful inclusion*/ $valid = new Spreadsheet_Excel_Writer_Validator($this->_parser); return $valid; } /** - * Change the RGB components of the elements in the colour palette. - * - * @access public - * @param integer $index colour index - * @param integer $red red RGB value [0-255] - * @param integer $green green RGB value [0-255] - * @param integer $blue blue RGB value [0-255] - * @return integer The palette index for the custom color - */ - public function setCustomColor($index, $red, $green, $blue) + * Change the RGB components of the elements in the colour palette. + * + * @access public + * @param integer $index colour index + * @param integer $red red RGB value [0-255] + * @param integer $green green RGB value [0-255] + * @param integer $blue blue RGB value [0-255] + * @return integer The palette index for the custom color + */ + function setCustomColor($index, $red, $green, $blue) { // Match a HTML #xxyyzz style parameter /*if (defined $_[1] and $_[1] =~ /^#(\w\w)(\w\w)(\w\w)/ ) { - @_ = ($_[0], hex $1, hex $2, hex $3); + @_ = ($_[0], hex $1, hex $2, hex $3); }*/ // Check that the colour index is the right range @@ -413,8 +408,8 @@ public function setCustomColor($index, $red, $green, $blue) // Check that the colour components are in the right range if (($red < 0 or $red > 255) || - ($green < 0 or $green > 255) || - ($blue < 0 or $blue > 255)) + ($green < 0 or $green > 255) || + ($blue < 0 or $blue > 255)) { return $this->raiseError("Color component outside range: 0 <= color <= 255"); } @@ -427,85 +422,81 @@ public function setCustomColor($index, $red, $green, $blue) } /** - * Sets the colour palette to the Excel 97+ default. - * - * @access private - */ - protected function _setPaletteXl97() + * Sets the colour palette to the Excel 97+ default. + * + * @access private + */ + function _setPaletteXl97() { $this->_palette = array( - array(0x00, 0x00, 0x00, 0x00), // 8 - array(0xff, 0xff, 0xff, 0x00), // 9 - array(0xff, 0x00, 0x00, 0x00), // 10 - array(0x00, 0xff, 0x00, 0x00), // 11 - array(0x00, 0x00, 0xff, 0x00), // 12 - array(0xff, 0xff, 0x00, 0x00), // 13 - array(0xff, 0x00, 0xff, 0x00), // 14 - array(0x00, 0xff, 0xff, 0x00), // 15 - array(0x80, 0x00, 0x00, 0x00), // 16 - array(0x00, 0x80, 0x00, 0x00), // 17 - array(0x00, 0x00, 0x80, 0x00), // 18 - array(0x80, 0x80, 0x00, 0x00), // 19 - array(0x80, 0x00, 0x80, 0x00), // 20 - array(0x00, 0x80, 0x80, 0x00), // 21 - array(0xc0, 0xc0, 0xc0, 0x00), // 22 - array(0x80, 0x80, 0x80, 0x00), // 23 - array(0x99, 0x99, 0xff, 0x00), // 24 - array(0x99, 0x33, 0x66, 0x00), // 25 - array(0xff, 0xff, 0xcc, 0x00), // 26 - array(0xcc, 0xff, 0xff, 0x00), // 27 - array(0x66, 0x00, 0x66, 0x00), // 28 - array(0xff, 0x80, 0x80, 0x00), // 29 - array(0x00, 0x66, 0xcc, 0x00), // 30 - array(0xcc, 0xcc, 0xff, 0x00), // 31 - array(0x00, 0x00, 0x80, 0x00), // 32 - array(0xff, 0x00, 0xff, 0x00), // 33 - array(0xff, 0xff, 0x00, 0x00), // 34 - array(0x00, 0xff, 0xff, 0x00), // 35 - array(0x80, 0x00, 0x80, 0x00), // 36 - array(0x80, 0x00, 0x00, 0x00), // 37 - array(0x00, 0x80, 0x80, 0x00), // 38 - array(0x00, 0x00, 0xff, 0x00), // 39 - array(0x00, 0xcc, 0xff, 0x00), // 40 - array(0xcc, 0xff, 0xff, 0x00), // 41 - array(0xcc, 0xff, 0xcc, 0x00), // 42 - array(0xff, 0xff, 0x99, 0x00), // 43 - array(0x99, 0xcc, 0xff, 0x00), // 44 - array(0xff, 0x99, 0xcc, 0x00), // 45 - array(0xcc, 0x99, 0xff, 0x00), // 46 - array(0xff, 0xcc, 0x99, 0x00), // 47 - array(0x33, 0x66, 0xff, 0x00), // 48 - array(0x33, 0xcc, 0xcc, 0x00), // 49 - array(0x99, 0xcc, 0x00, 0x00), // 50 - array(0xff, 0xcc, 0x00, 0x00), // 51 - array(0xff, 0x99, 0x00, 0x00), // 52 - array(0xff, 0x66, 0x00, 0x00), // 53 - array(0x66, 0x66, 0x99, 0x00), // 54 - array(0x96, 0x96, 0x96, 0x00), // 55 - array(0x00, 0x33, 0x66, 0x00), // 56 - array(0x33, 0x99, 0x66, 0x00), // 57 - array(0x00, 0x33, 0x00, 0x00), // 58 - array(0x33, 0x33, 0x00, 0x00), // 59 - array(0x99, 0x33, 0x00, 0x00), // 60 - array(0x99, 0x33, 0x66, 0x00), // 61 - array(0x33, 0x33, 0x99, 0x00), // 62 - array(0x33, 0x33, 0x33, 0x00), // 63 - ); + array(0x00, 0x00, 0x00, 0x00), // 8 + array(0xff, 0xff, 0xff, 0x00), // 9 + array(0xff, 0x00, 0x00, 0x00), // 10 + array(0x00, 0xff, 0x00, 0x00), // 11 + array(0x00, 0x00, 0xff, 0x00), // 12 + array(0xff, 0xff, 0x00, 0x00), // 13 + array(0xff, 0x00, 0xff, 0x00), // 14 + array(0x00, 0xff, 0xff, 0x00), // 15 + array(0x80, 0x00, 0x00, 0x00), // 16 + array(0x00, 0x80, 0x00, 0x00), // 17 + array(0x00, 0x00, 0x80, 0x00), // 18 + array(0x80, 0x80, 0x00, 0x00), // 19 + array(0x80, 0x00, 0x80, 0x00), // 20 + array(0x00, 0x80, 0x80, 0x00), // 21 + array(0xc0, 0xc0, 0xc0, 0x00), // 22 + array(0x80, 0x80, 0x80, 0x00), // 23 + array(0x99, 0x99, 0xff, 0x00), // 24 + array(0x99, 0x33, 0x66, 0x00), // 25 + array(0xff, 0xff, 0xcc, 0x00), // 26 + array(0xcc, 0xff, 0xff, 0x00), // 27 + array(0x66, 0x00, 0x66, 0x00), // 28 + array(0xff, 0x80, 0x80, 0x00), // 29 + array(0x00, 0x66, 0xcc, 0x00), // 30 + array(0xcc, 0xcc, 0xff, 0x00), // 31 + array(0x00, 0x00, 0x80, 0x00), // 32 + array(0xff, 0x00, 0xff, 0x00), // 33 + array(0xff, 0xff, 0x00, 0x00), // 34 + array(0x00, 0xff, 0xff, 0x00), // 35 + array(0x80, 0x00, 0x80, 0x00), // 36 + array(0x80, 0x00, 0x00, 0x00), // 37 + array(0x00, 0x80, 0x80, 0x00), // 38 + array(0x00, 0x00, 0xff, 0x00), // 39 + array(0x00, 0xcc, 0xff, 0x00), // 40 + array(0xcc, 0xff, 0xff, 0x00), // 41 + array(0xcc, 0xff, 0xcc, 0x00), // 42 + array(0xff, 0xff, 0x99, 0x00), // 43 + array(0x99, 0xcc, 0xff, 0x00), // 44 + array(0xff, 0x99, 0xcc, 0x00), // 45 + array(0xcc, 0x99, 0xff, 0x00), // 46 + array(0xff, 0xcc, 0x99, 0x00), // 47 + array(0x33, 0x66, 0xff, 0x00), // 48 + array(0x33, 0xcc, 0xcc, 0x00), // 49 + array(0x99, 0xcc, 0x00, 0x00), // 50 + array(0xff, 0xcc, 0x00, 0x00), // 51 + array(0xff, 0x99, 0x00, 0x00), // 52 + array(0xff, 0x66, 0x00, 0x00), // 53 + array(0x66, 0x66, 0x99, 0x00), // 54 + array(0x96, 0x96, 0x96, 0x00), // 55 + array(0x00, 0x33, 0x66, 0x00), // 56 + array(0x33, 0x99, 0x66, 0x00), // 57 + array(0x00, 0x33, 0x00, 0x00), // 58 + array(0x33, 0x33, 0x00, 0x00), // 59 + array(0x99, 0x33, 0x00, 0x00), // 60 + array(0x99, 0x33, 0x66, 0x00), // 61 + array(0x33, 0x33, 0x99, 0x00), // 62 + array(0x33, 0x33, 0x33, 0x00), // 63 + ); } /** - * Assemble worksheets into a workbook and send the BIFF data to an OLE - * storage. - * - * @access private - * @return mixed true on success. PEAR_Error on failure - */ - protected function _storeWorkbook() + * Assemble worksheets into a workbook and send the BIFF data to an OLE + * storage. + * + * @access private + * @return mixed true on success. PEAR_Error on failure + */ + function _storeWorkbook() { - if (count($this->_worksheets) == 0) { - return true; - } - // Ensure that at least one worksheet has been selected. if ($this->_activesheet == 0) { $this->_worksheets[0]->selected = 1; @@ -571,18 +562,30 @@ protected function _storeWorkbook() } /** - * Store the workbook in an OLE container - * - * @access private - * @return mixed true on success. PEAR_Error on failure - */ - protected function _storeOLEFile() + * Sets the temp dir used for storing the OLE file + * + * @access public + * @param string $dir The dir to be used as temp dir + * @return true if given dir is valid, false otherwise + */ + function setTempDir($dir) { - if($this->_BIFF_version == 0x0600) { - $OLE = new OLE_PPS_File(OLE::Asc2Ucs('Workbook')); - } else { - $OLE = new OLE_PPS_File(OLE::Asc2Ucs('Book')); + if (is_dir($dir)) { + $this->_tmp_dir = $dir; + return true; } + return false; + } + + /** + * Store the workbook in an OLE container + * + * @access private + * @return mixed true on success. PEAR_Error on failure + */ + function _storeOLEFile() + { + $OLE = new OLE_PPS_File(OLE::Asc2Ucs('Book')); if ($this->_tmp_dir != '') { $OLE->setTempDir($this->_tmp_dir); } @@ -599,7 +602,7 @@ protected function _storeOLEFile() } } - $root = new OLE_PPS_Root($this->_timestamp, $this->_timestamp, array($OLE)); + $root = new OLE_PPS_Root(time(), time(), array($OLE)); if ($this->_tmp_dir != '') { $root->setTempDir($this->_tmp_dir); } @@ -612,11 +615,11 @@ protected function _storeOLEFile() } /** - * Calculate offsets for Worksheet BOF records. - * - * @access private - */ - protected function _calcSheetOffsets() + * Calculate offsets for Worksheet BOF records. + * + * @access private + */ + function _calcSheetOffsets() { if ($this->_BIFF_version == 0x0600) { $boundsheet_length = 12; // fixed length for a BOUNDSHEET record @@ -651,11 +654,11 @@ protected function _calcSheetOffsets() } /** - * Store the Excel FONT records. - * - * @access private - */ - protected function _storeAllFonts() + * Store the Excel FONT records. + * + * @access private + */ + function _storeAllFonts() { // tmp_format is added by the constructor. We use this to write the default XF's $format = $this->_tmp_format; @@ -695,11 +698,11 @@ protected function _storeAllFonts() } /** - * Store user defined numerical formats i.e. FORMAT records - * - * @access private - */ - protected function _storeAllNumFormats() + * Store user defined numerical formats i.e. FORMAT records + * + * @access private + */ + function _storeAllNumFormats() { // Leaning num_format syndrome $hash_num_formats = array(); @@ -743,11 +746,11 @@ protected function _storeAllNumFormats() } /** - * Write all XF records. - * - * @access private - */ - protected function _storeAllXfs() + * Write all XF records. + * + * @access private + */ + function _storeAllXfs() { // _tmp_format is added by the constructor. We use this to write the default XF's // The default font index is 0 @@ -770,23 +773,22 @@ protected function _storeAllXfs() } /** - * Write all STYLE records. - * - * @access private - */ - protected function _storeAllStyles() + * Write all STYLE records. + * + * @access private + */ + function _storeAllStyles() { $this->_storeStyle(); } /** - * Write the EXTERNCOUNT and EXTERNSHEET records. These are used as indexes for - * the NAME records. - * - * @access private - */ - protected function _storeExterns() - + * Write the EXTERNCOUNT and EXTERNSHEET records. These are used as indexes for + * the NAME records. + * + * @access private + */ + function _storeExterns() { // Create EXTERNCOUNT with number of worksheets $this->_storeExterncount(count($this->_worksheets)); @@ -798,11 +800,11 @@ protected function _storeExterns() } /** - * Write the NAME record to define the print area and the repeat rows and cols. - * - * @access private - */ - protected function _storeNames() + * Write the NAME record to define the print area and the repeat rows and cols. + * + * @access private + */ + function _storeNames() { // Create the print area NAME records $total_worksheets = count($this->_worksheets); @@ -810,13 +812,13 @@ protected function _storeNames() // Write a Name record if the print area has been defined if (isset($this->_worksheets[$i]->print_rowmin)) { $this->_storeNameShort( - $this->_worksheets[$i]->index, - 0x06, // NAME type - $this->_worksheets[$i]->print_rowmin, - $this->_worksheets[$i]->print_rowmax, - $this->_worksheets[$i]->print_colmin, - $this->_worksheets[$i]->print_colmax - ); + $this->_worksheets[$i]->index, + 0x06, // NAME type + $this->_worksheets[$i]->print_rowmin, + $this->_worksheets[$i]->print_rowmax, + $this->_worksheets[$i]->print_colmin, + $this->_worksheets[$i]->print_colmax + ); } } @@ -835,33 +837,33 @@ protected function _storeNames() // Row and column titles have been defined. // Row title has been defined. $this->_storeNameLong( - $this->_worksheets[$i]->index, - 0x07, // NAME type - $rowmin, - $rowmax, - $colmin, - $colmax - ); + $this->_worksheets[$i]->index, + 0x07, // NAME type + $rowmin, + $rowmax, + $colmin, + $colmax + ); } elseif (isset($rowmin)) { // Row title has been defined. $this->_storeNameShort( - $this->_worksheets[$i]->index, - 0x07, // NAME type - $rowmin, - $rowmax, - 0x00, - 0xff - ); + $this->_worksheets[$i]->index, + 0x07, // NAME type + $rowmin, + $rowmax, + 0x00, + 0xff + ); } elseif (isset($colmin)) { // Column title has been defined. $this->_storeNameShort( - $this->_worksheets[$i]->index, - 0x07, // NAME type - 0x0000, - 0x3fff, - $colmin, - $colmax - ); + $this->_worksheets[$i]->index, + 0x07, // NAME type + 0x0000, + 0x3fff, + $colmin, + $colmax + ); } else { // Print title hasn't been defined. } @@ -872,17 +874,17 @@ protected function _storeNames() /****************************************************************************** - * - * BIFF RECORDS - * - */ + * + * BIFF RECORDS + * + */ /** - * Stores the CODEPAGE biff record. - * - * @access private - */ - protected function _storeCodepage() + * Stores the CODEPAGE biff record. + * + * @access private + */ + function _storeCodepage() { $record = 0x0042; // Record identifier $length = 0x0002; // Number of bytes to follow @@ -895,11 +897,11 @@ protected function _storeCodepage() } /** - * Write Excel BIFF WINDOW1 record. - * - * @access private - */ - protected function _storeWindow1() + * Write Excel BIFF WINDOW1 record. + * + * @access private + */ + function _storeWindow1() { $record = 0x003D; // Record identifier $length = 0x0012; // Number of bytes to follow @@ -918,21 +920,21 @@ protected function _storeWindow1() $header = pack("vv", $record, $length); $data = pack("vvvvvvvvv", $xWn, $yWn, $dxWn, $dyWn, - $grbit, - $itabCur, $itabFirst, - $ctabsel, $wTabRatio); + $grbit, + $itabCur, $itabFirst, + $ctabsel, $wTabRatio); $this->_append($header . $data); } /** - * Writes Excel BIFF BOUNDSHEET record. - * FIXME: inconsistent with BIFF documentation - * - * @param string $sheetname Worksheet name - * @param integer $offset Location of worksheet BOF - * @access private - */ - protected function _storeBoundsheet($sheetname,$offset) + * Writes Excel BIFF BOUNDSHEET record. + * FIXME: inconsistent with BIFF documentation + * + * @param string $sheetname Worksheet name + * @param integer $offset Location of worksheet BOF + * @access private + */ + function _storeBoundsheet($sheetname,$offset) { $record = 0x0085; // Record identifier if ($this->_BIFF_version == 0x0600) { @@ -942,15 +944,11 @@ protected function _storeBoundsheet($sheetname,$offset) } $grbit = 0x0000; // Visibility and sheet type - if ($this->_BIFF_version == 0x0600) { - $cch = mb_strlen($sheetname,'UTF-16LE'); // Length of sheet name - } else { - $cch = strlen($sheetname); // Length of sheet name - } + $cch = strlen($sheetname); // Length of sheet name $header = pack("vv", $record, $length); if ($this->_BIFF_version == 0x0600) { - $data = pack("VvCC", $offset, $grbit, $cch, 0x1); + $data = pack("Vvv", $offset, $grbit, $cch); } else { $data = pack("VvC", $offset, $grbit, $cch); } @@ -958,11 +956,11 @@ protected function _storeBoundsheet($sheetname,$offset) } /** - * Write Internal SUPBOOK record - * - * @access private - */ - protected function _storeSupbookInternal() + * Write Internal SUPBOOK record + * + * @access private + */ + function _storeSupbookInternal() { $record = 0x01AE; // Record identifier $length = 0x0004; // Bytes to follow @@ -973,13 +971,13 @@ protected function _storeSupbookInternal() } /** - * Writes the Excel BIFF EXTERNSHEET record. These references are used by - * formulas. - * - * @param string $sheetname Worksheet name - * @access private - */ - protected function _storeExternsheetBiff8() + * Writes the Excel BIFF EXTERNSHEET record. These references are used by + * formulas. + * + * @param string $sheetname Worksheet name + * @access private + */ + function _storeExternsheetBiff8() { $total_references = count($this->_parser->_references); $record = 0x0017; // Record identifier @@ -995,11 +993,11 @@ protected function _storeExternsheetBiff8() } /** - * Write Excel BIFF STYLE records. - * - * @access private - */ - protected function _storeStyle() + * Write Excel BIFF STYLE records. + * + * @access private + */ + function _storeStyle() { $record = 0x0293; // Record identifier $length = 0x0004; // Bytes to follow @@ -1015,13 +1013,13 @@ protected function _storeStyle() /** - * Writes Excel FORMAT record for non "built-in" numerical formats. - * - * @param string $format Custom format string - * @param integer $ifmt Format index code - * @access private - */ - protected function _storeNumFormat($format, $ifmt) + * Writes Excel FORMAT record for non "built-in" numerical formats. + * + * @param string $format Custom format string + * @param integer $ifmt Format index code + * @access private + */ + function _storeNumFormat($format, $ifmt) { $record = 0x041E; // Record identifier @@ -1032,34 +1030,23 @@ protected function _storeNumFormat($format, $ifmt) $length = 3 + strlen($format); // Number of bytes to follow } - if ( $this->_BIFF_version == 0x0600 && function_exists('iconv') ) { // Encode format String - if (mb_detect_encoding($format, 'auto') !== 'UTF-16LE'){ - $format = iconv(mb_detect_encoding($format, 'auto'),'UTF-16LE',$format); - } - $encoding = 1; - $cch = function_exists('mb_strlen') ? mb_strlen($format, 'UTF-16LE') : (strlen($format) / 2); - } else { - $encoding = 0; - $cch = strlen($format); // Length of format string - } - $length = strlen($format); + $cch = strlen($format); // Length of format string + $header = pack("vv", $record, $length); if ($this->_BIFF_version == 0x0600) { - $header = pack("vv", $record, 5 + $length); $data = pack("vvC", $ifmt, $cch, $encoding); } elseif ($this->_BIFF_version == 0x0500) { - $header = pack("vv", $record, 3 + $length); $data = pack("vC", $ifmt, $cch); } $this->_append($header . $data . $format); } /** - * Write DATEMODE record to indicate the date system in use (1904 or 1900). - * - * @access private - */ - protected function _storeDatemode() + * Write DATEMODE record to indicate the date system in use (1904 or 1900). + * + * @access private + */ + function _storeDatemode() { $record = 0x0022; // Record identifier $length = 0x0002; // Bytes to follow @@ -1073,19 +1060,19 @@ protected function _storeDatemode() /** - * Write BIFF record EXTERNCOUNT to indicate the number of external sheet - * references in the workbook. - * - * Excel only stores references to external sheets that are used in NAME. - * The workbook NAME record is required to define the print area and the repeat - * rows and columns. - * - * A similar method is used in Worksheet.php for a slightly different purpose. - * - * @param integer $cxals Number of external references - * @access private - */ - protected function _storeExterncount($cxals) + * Write BIFF record EXTERNCOUNT to indicate the number of external sheet + * references in the workbook. + * + * Excel only stores references to external sheets that are used in NAME. + * The workbook NAME record is required to define the print area and the repeat + * rows and columns. + * + * A similar method is used in Worksheet.php for a slightly different purpose. + * + * @param integer $cxals Number of external references + * @access private + */ + function _storeExterncount($cxals) { $record = 0x0016; // Record identifier $length = 0x0002; // Number of bytes to follow @@ -1097,16 +1084,16 @@ protected function _storeExterncount($cxals) /** - * Writes the Excel BIFF EXTERNSHEET record. These references are used by - * formulas. NAME record is required to define the print area and the repeat - * rows and columns. - * - * A similar method is used in Worksheet.php for a slightly different purpose. - * - * @param string $sheetname Worksheet name - * @access private - */ - protected function _storeExternsheet($sheetname) + * Writes the Excel BIFF EXTERNSHEET record. These references are used by + * formulas. NAME record is required to define the print area and the repeat + * rows and columns. + * + * A similar method is used in Worksheet.php for a slightly different purpose. + * + * @param string $sheetname Worksheet name + * @access private + */ + function _storeExternsheet($sheetname) { $record = 0x0017; // Record identifier $length = 0x02 + strlen($sheetname); // Number of bytes to follow @@ -1121,18 +1108,18 @@ protected function _storeExternsheet($sheetname) /** - * Store the NAME record in the short format that is used for storing the print - * area, repeat rows only and repeat columns only. - * - * @param integer $index Sheet index - * @param integer $type Built-in name type - * @param integer $rowmin Start row - * @param integer $rowmax End row - * @param integer $colmin Start colum - * @param integer $colmax End column - * @access private - */ - protected function _storeNameShort($index, $type, $rowmin, $rowmax, $colmin, $colmax) + * Store the NAME record in the short format that is used for storing the print + * area, repeat rows only and repeat columns only. + * + * @param integer $index Sheet index + * @param integer $type Built-in name type + * @param integer $rowmin Start row + * @param integer $rowmax End row + * @param integer $colmin Start colum + * @param integer $colmax End column + * @access private + */ + function _storeNameShort($index, $type, $rowmin, $rowmax, $colmin, $colmax) { $record = 0x0018; // Record identifier $length = 0x0024; // Number of bytes to follow @@ -1185,20 +1172,20 @@ protected function _storeNameShort($index, $type, $rowmin, $rowmax, $colmin, $co /** - * Store the NAME record in the long format that is used for storing the repeat - * rows and columns when both are specified. This shares a lot of code with - * _storeNameShort() but we use a separate method to keep the code clean. - * Code abstraction for reuse can be carried too far, and I should know. ;-) - * - * @param integer $index Sheet index - * @param integer $type Built-in name type - * @param integer $rowmin Start row - * @param integer $rowmax End row - * @param integer $colmin Start colum - * @param integer $colmax End column - * @access private - */ - protected function _storeNameLong($index, $type, $rowmin, $rowmax, $colmin, $colmax) + * Store the NAME record in the long format that is used for storing the repeat + * rows and columns when both are specified. This shares a lot of code with + * _storeNameShort() but we use a separate method to keep the code clean. + * Code abstraction for reuse can be carried too far, and I should know. ;-) + * + * @param integer $index Sheet index + * @param integer $type Built-in name type + * @param integer $rowmin Start row + * @param integer $rowmax End row + * @param integer $colmin Start colum + * @param integer $colmax End column + * @access private + */ + function _storeNameLong($index, $type, $rowmin, $rowmax, $colmin, $colmax) { $record = 0x0018; // Record identifier $length = 0x003d; // Number of bytes to follow @@ -1269,11 +1256,11 @@ protected function _storeNameLong($index, $type, $rowmin, $rowmax, $colmin, $col } /** - * Stores the COUNTRY record for localization - * - * @access private - */ - protected function _storeCountry() + * Stores the COUNTRY record for localization + * + * @access private + */ + function _storeCountry() { $record = 0x008C; // Record identifier $length = 4; // Number of bytes to follow @@ -1285,11 +1272,11 @@ protected function _storeCountry() } /** - * Stores the PALETTE biff record. - * - * @access private - */ - protected function _storePalette() + * Stores the PALETTE biff record. + * + * @access private + */ + function _storePalette() { $aref = $this->_palette; @@ -1310,24 +1297,25 @@ protected function _storePalette() } /** - * Calculate - * Handling of the SST continue blocks is complicated by the need to include an - * additional continuation byte depending on whether the string is split between - * blocks or whether it starts at the beginning of the block. (There are also - * additional complications that will arise later when/if Rich Strings are - * supported). - * - * @access private - */ - protected function _calculateSharedStringsSizes() + * Calculate + * Handling of the SST continue blocks is complicated by the need to include an + * additional continuation byte depending on whether the string is split between + * blocks or whether it starts at the beginning of the block. (There are also + * additional complications that will arise later when/if Rich Strings are + * supported). + * + * @access private + */ + function _calculateSharedStringsSizes() { /* Iterate through the strings to calculate the CONTINUE block sizes. - For simplicity we use the same size for the SST and CONTINUE records: - 8228 : Maximum Excel97 block size - -4 : Length of block header - -8 : Length of additional SST header information - -8 : Arbitrary number to keep within _add_continue() limit = 8208 - */ + For simplicity we use the same size for the SST and CONTINUE records: + 8228 : Maximum Excel97 block size + -4 : Length of block header + -8 : Length of additional SST header information + -8 : Arbitrary number to keep within _add_continue() limit + = 8208 + */ $continue_limit = 8208; $block_length = 0; $written = 0; @@ -1362,23 +1350,23 @@ protected function _calculateSharedStringsSizes() /* TODO: Unicode data should only be split on char (2 byte) - boundaries. Therefore, in some cases we need to reduce the - amount of available - */ + boundaries. Therefore, in some cases we need to reduce the + amount of available + */ $align = 0; - // Only applies to Unicode strings + # Only applies to Unicode strings if ($encoding == 1) { - // Min string + header size -1 + # Min string + header size -1 $header_length = 4; if ($space_remaining > $header_length) { - // String contains 3 byte header => split on odd boundary + # String contains 3 byte header => split on odd boundary if (!$split_string && $space_remaining % 2 != 1) { $space_remaining--; $align = 1; } - // Split section without header => split on even boundary + # Split section without header => split on even boundary else if ($split_string && $space_remaining % 2 == 1) { $space_remaining--; $align = 1; @@ -1438,34 +1426,34 @@ protected function _calculateSharedStringsSizes() The SST record will have a length even if it contains no strings. This length is required to set the offsets in the BOUNDSHEET records since they must be written before the SST records - */ + */ $tmp_block_sizes = array(); $tmp_block_sizes = $this->_block_sizes; $length = 12; if (!empty($tmp_block_sizes)) { - $length += array_shift($tmp_block_sizes); // SST + $length += array_shift($tmp_block_sizes); # SST } while (!empty($tmp_block_sizes)) { - $length += 4 + array_shift($tmp_block_sizes); // CONTINUEs + $length += 4 + array_shift($tmp_block_sizes); # CONTINUEs } return $length; } /** - * Write all of the workbooks strings into an indexed array. - * See the comments in _calculate_shared_string_sizes() for more information. - * - * The Excel documentation says that the SST record should be followed by an - * EXTSST record. The EXTSST record is a hash table that is used to optimise - * access to SST. However, despite the documentation it doesn't seem to be - * required so we will ignore it. - * - * @access private - */ - protected function _storeSharedStringsTable() + * Write all of the workbooks strings into an indexed array. + * See the comments in _calculate_shared_string_sizes() for more information. + * + * The Excel documentation says that the SST record should be followed by an + * EXTSST record. The EXTSST record is a hash table that is used to optimise + * access to SST. However, despite the documentation it doesn't seem to be + * required so we will ignore it. + * + * @access private + */ + function _storeSharedStringsTable() { $record = 0x00fc; // Record identifier $length = 0x0008; // Number of bytes to follow @@ -1479,16 +1467,16 @@ protected function _storeSharedStringsTable() // sizes are upside down $tmp_block_sizes = $this->_block_sizes; - // $tmp_block_sizes = array_reverse($this->_block_sizes); + // $tmp_block_sizes = array_reverse($this->_block_sizes); - // The SST record is required even if it contains no strings. Thus we will - // always have a length - // + # The SST record is required even if it contains no strings. Thus we will + # always have a length + # if (!empty($tmp_block_sizes)) { $length = 8 + array_shift($tmp_block_sizes); } else { - // No strings + # No strings $length = 8; } @@ -1614,7 +1602,5 @@ protected function _storeSharedStringsTable() } } } - - } - +?> diff --git a/application/third_party/pear/Spreadsheet/Excel/Writer/Worksheet.php b/application/third_party/pear/Spreadsheet/Excel/Writer/Worksheet.php index 7df8faab343..1f6b4f30994 100644 --- a/application/third_party/pear/Spreadsheet/Excel/Writer/Worksheet.php +++ b/application/third_party/pear/Spreadsheet/Excel/Writer/Worksheet.php @@ -1,418 +1,393 @@ -* -* The majority of this is _NOT_ my code. I simply ported it from the -* PERL Spreadsheet::WriteExcel module. -* -* The author of the Spreadsheet::WriteExcel module is John McNamara -* -* -* I _DO_ maintain this code, and John McNamara has nothing to do with the -* porting of this code to PHP. Any questions directly related to this -* class library should be directed to me. -* -* License Information: -* -* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets -* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com -* -* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + * Module written/ported by Xavier Noguer + * + * The majority of this is _NOT_ my code. I simply ported it from the + * PERL Spreadsheet::WriteExcel module. + * + * The author of the Spreadsheet::WriteExcel module is John McNamara + * + * + * I _DO_ maintain this code, and John McNamara has nothing to do with the + * porting of this code to PHP. Any questions directly related to this + * class library should be directed to me. + * + * License Information: + * + * Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets + * Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');} require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'Parser.php'; require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'BIFFwriter.php'; /** -* Class for generating Excel Spreadsheets -* -* @author Xavier Noguer -* @category FileFormats -* @package Spreadsheet_Excel_Writer -*/ + * Class for generating Excel Spreadsheets + * + * @author Xavier Noguer + * @category FileFormats + * @package Spreadsheet_Excel_Writer + */ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwriter { /** - * Name of the Worksheet - * @var string - */ - public $name; - - /** - * Index for the Worksheet - * @var integer - */ - public $index; - - /** - * Reference to the (default) Format object for URLs - * @var Spreadsheet_Excel_Writer_Format - */ - public $_url_format; - - /** - * Reference to the parser used for parsing formulas - * @var Spreadsheet_Excel_Writer_Format - */ - public $_parser; - - /** - * Filehandle to the temporary file for storing data - * @var resource - */ - public $_filehandle; + * Name of the Worksheet + * @var string + */ + var $name; /** - * Boolean indicating if we are using a temporary file for storing data - * @var bool - */ - public $_using_tmpfile; + * Index for the Worksheet + * @var integer + */ + var $index; /** - * Maximum number of rows for an Excel spreadsheet (BIFF5) - * @var integer - */ - public $_xls_rowmax; + * Reference to the (default) Format object for URLs + * @var object Format + */ + var $_url_format; /** - * Maximum number of columns for an Excel spreadsheet (BIFF5) - * @var integer - */ - public $_xls_colmax; + * Reference to the parser used for parsing formulas + * @var object Format + */ + var $_parser; /** - * Maximum number of characters for a string (LABEL record in BIFF5) - * @var integer - */ - public $_xls_strmax; + * Filehandle to the temporary file for storing data + * @var resource + */ + var $_filehandle; /** - * First row for the DIMENSIONS record - * @var integer - * @see _storeDimensions() - */ - public $_dim_rowmin; + * Boolean indicating if we are using a temporary file for storing data + * @var bool + */ + var $_using_tmpfile; /** - * Last row for the DIMENSIONS record - * @var integer - * @see _storeDimensions() - */ - public $_dim_rowmax; + * Maximum number of rows for an Excel spreadsheet (BIFF5) + * @var integer + */ + var $_xls_rowmax; /** - * First column for the DIMENSIONS record - * @var integer - * @see _storeDimensions() - */ - public $_dim_colmin; + * Maximum number of columns for an Excel spreadsheet (BIFF5) + * @var integer + */ + var $_xls_colmax; /** - * Last column for the DIMENSIONS record - * @var integer - * @see _storeDimensions() - */ - public $_dim_colmax; + * Maximum number of characters for a string (LABEL record in BIFF5) + * @var integer + */ + var $_xls_strmax; /** - * Array containing format information for columns - * @var array - */ - public $_colinfo; + * First row for the DIMENSIONS record + * @var integer + * @see _storeDimensions() + */ + var $_dim_rowmin; /** - * Array containing the selected area for the worksheet - * @var array - */ - public $_selection; + * Last row for the DIMENSIONS record + * @var integer + * @see _storeDimensions() + */ + var $_dim_rowmax; /** - * Array containing the panes for the worksheet - * @var array - */ - public $_panes; + * First column for the DIMENSIONS record + * @var integer + * @see _storeDimensions() + */ + var $_dim_colmin; /** - * The active pane for the worksheet - * @var integer - */ - public $_active_pane; + * Last column for the DIMENSIONS record + * @var integer + * @see _storeDimensions() + */ + var $_dim_colmax; /** - * Bit specifying if panes are frozen - * @var integer - */ - public $_frozen; + * Array containing format information for columns + * @var array + */ + var $_colinfo; /** - * Bit specifying if the worksheet is selected - * @var integer - */ - public $selected; + * Array containing the selected area for the worksheet + * @var array + */ + var $_selection; /** - * The paper size (for printing) (DOCUMENT!!!) - * @var integer - */ - public $_paper_size; + * Array containing the panes for the worksheet + * @var array + */ + var $_panes; /** - * Bit specifying paper orientation (for printing). 0 => landscape, 1 => portrait - * @var integer - */ - public $_orientation; + * The active pane for the worksheet + * @var integer + */ + var $_active_pane; /** - * The page header caption - * @var string - */ - public $_header; + * Bit specifying if panes are frozen + * @var integer + */ + var $_frozen; /** - * The page footer caption - * @var string - */ - public $_footer; + * Bit specifying if the worksheet is selected + * @var integer + */ + var $selected; /** - * The horizontal centering value for the page - * @var integer - */ - public $_hcenter; + * The paper size (for printing) (DOCUMENT!!!) + * @var integer + */ + var $_paper_size; /** - * The vertical centering value for the page - * @var integer - */ - public $_vcenter; + * Bit specifying paper orientation (for printing). 0 => landscape, 1 => portrait + * @var integer + */ + var $_orientation; /** - * The margin for the header - * @var float - */ - public $_margin_head; + * The page header caption + * @var string + */ + var $_header; /** - * The margin for the footer - * @var float - */ - public $_margin_foot; + * The page footer caption + * @var string + */ + var $_footer; /** - * The left margin for the worksheet in inches - * @var float - */ - public $_margin_left; + * The horizontal centering value for the page + * @var integer + */ + var $_hcenter; /** - * The right margin for the worksheet in inches - * @var float - */ - public $_margin_right; + * The vertical centering value for the page + * @var integer + */ + var $_vcenter; /** - * The top margin for the worksheet in inches - * @var float - */ - public $_margin_top; + * The margin for the header + * @var float + */ + var $_margin_head; /** - * The bottom margin for the worksheet in inches - * @var float - */ - public $_margin_bottom; + * The margin for the footer + * @var float + */ + var $_margin_foot; /** - * First row to reapeat on each printed page - * @var integer - */ - public $title_rowmin; + * The left margin for the worksheet in inches + * @var float + */ + var $_margin_left; /** - * Last row to reapeat on each printed page - * @var integer - */ - public $title_rowmax; + * The right margin for the worksheet in inches + * @var float + */ + var $_margin_right; /** - * First column to reapeat on each printed page - * @var integer - */ - public $title_colmin; + * The top margin for the worksheet in inches + * @var float + */ + var $_margin_top; /** - * First row of the area to print - * @var integer - */ - public $print_rowmin; + * The bottom margin for the worksheet in inches + * @var float + */ + var $_margin_bottom; /** - * Last row to of the area to print - * @var integer - */ - public $print_rowmax; + * First row to reapeat on each printed page + * @var integer + */ + var $title_rowmin; /** - * First column of the area to print - * @var integer - */ - public $print_colmin; + * Last row to reapeat on each printed page + * @var integer + */ + var $title_rowmax; /** - * Last column of the area to print - * @var integer - */ - public $print_colmax; + * First column to reapeat on each printed page + * @var integer + */ + var $title_colmin; /** - * Whether to display RightToLeft. - * @var integer - */ - public $_Arabic; + * First row of the area to print + * @var integer + */ + var $print_rowmin; /** - * Whether to use outline. - * @var integer - */ - public $_outline_on; + * Last row to of the area to print + * @var integer + */ + var $print_rowmax; /** - * Auto outline styles. - * @var bool - */ - public $_outline_style; + * First column of the area to print + * @var integer + */ + var $print_colmin; /** - * Whether to have outline summary below. - * @var bool - */ - public $_outline_below; + * Last column of the area to print + * @var integer + */ + var $print_colmax; /** - * Whether to have outline summary at the right. - * @var bool - */ - public $_outline_right; + * Whether to use outline. + * @var integer + */ + var $_outline_on; /** - * Outline row level. - * @var integer - */ - public $_outline_row_level; + * Auto outline styles. + * @var bool + */ + var $_outline_style; /** - * Whether to fit to page when printing or not. - * @var bool - */ - public $_fit_page; + * Whether to have outline summary below. + * @var bool + */ + var $_outline_below; /** - * Number of pages to fit wide - * @var integer - */ - public $_fit_width; + * Whether to have outline summary at the right. + * @var bool + */ + var $_outline_right; /** - * Number of pages to fit high - * @var integer - */ - public $_fit_height; + * Outline row level. + * @var integer + */ + var $_outline_row_level; /** - * Reference to the total number of strings in the workbook - * @var integer - */ - public $_str_total; + * Whether to fit to page when printing or not. + * @var bool + */ + var $_fit_page; /** - * Reference to the number of unique strings in the workbook - * @var integer - */ - public $_str_unique; + * Number of pages to fit wide + * @var integer + */ + var $_fit_width; /** - * Reference to the array containing all the unique strings in the workbook - * @var array - */ - public $_str_table; + * Number of pages to fit high + * @var integer + */ + var $_fit_height; /** - * Number of merged cell ranges in actual record - * @var int $_merged_cells_counter + * Reference to the total number of strings in the workbook + * @var integer */ - public $_merged_cells_counter = 0; + var $_str_total; /** - * Number of actual mergedcells record - * @var int $_merged_cells_record + * Reference to the number of unique strings in the workbook + * @var integer */ - public $_merged_cells_record = 0; + var $_str_unique; /** - * Merged cell ranges - * @var array - */ - public $_merged_ranges; + * Reference to the array containing all the unique strings in the workbook + * @var array + */ + var $_str_table; /** - * Charset encoding currently used when calling writeString() - * @var string - */ - public $_input_encoding; + * Merged cell ranges + * @var array + */ + var $_merged_ranges; /** - * Constructor - * - * @param string $name The name of the new worksheet - * @param integer $index The index of the new worksheet - * @param mixed $activesheet The current activesheet of the workbook we belong to - * @param mixed $firstsheet The first worksheet in the workbook we belong to - * @param int &$str_total Reference to the total number of strings in the workbook - * @param int &$str_unique Reference to the number of unique strings in the workbook - * @param array &$str_table Reference to the array containing all the unique strings in the workbook - * @param mixed $url_format The default format for hyperlinks - * @param mixed $parser The formula parser created for the Workbook - * @param string $tmp_dir The path to the directory for temporary files - * @access private - */ - public function __construct($BIFF_version, $name, - $index, $activesheet, - $firstsheet, &$str_total, - &$str_unique, &$str_table, - $url_format, $parser, - $tmp_dir) + * Charset encoding currently used when calling writeString() + * @var string + */ + var $_input_encoding; + + /** + * Constructor + * + * @param string $name The name of the new worksheet + * @param integer $index The index of the new worksheet + * @param mixed &$activesheet The current activesheet of the workbook we belong to + * @param mixed &$firstsheet The first worksheet in the workbook we belong to + * @param mixed &$url_format The default format for hyperlinks + * @param mixed &$parser The formula parser created for the Workbook + * @access private + */ + function Spreadsheet_Excel_Writer_Worksheet($BIFF_version, $name, + $index, &$activesheet, + &$firstsheet, &$str_total, + &$str_unique, &$str_table, + &$url_format, &$parser) { // It needs to call its parent's constructor explicitly - parent::__construct(); + $this->Spreadsheet_Excel_Writer_BIFFwriter(); $this->_BIFF_version = $BIFF_version; $rowmax = 65536; // 16384 in Excel 5 $colmax = 256; $this->name = $name; $this->index = $index; - $this->activesheet = $activesheet; - $this->firstsheet = $firstsheet; - // _str_total _str_unique _str_table - are actual references - // everything breaks if they're not + $this->activesheet = &$activesheet; + $this->firstsheet = &$firstsheet; $this->_str_total = &$str_total; $this->_str_unique = &$str_unique; $this->_str_table = &$str_table; - $this->_url_format = $url_format; - $this->_parser = $parser; + $this->_url_format = &$url_format; + $this->_parser = &$parser; //$this->ext_sheets = array(); $this->_filehandle = ''; @@ -480,7 +455,6 @@ public function __construct($BIFF_version, $name, $this->_outline_below = 1; $this->_outline_right = 1; $this->_outline_on = 1; - $this->_Arabic = 0; $this->_merged_ranges = array(); @@ -488,66 +462,45 @@ public function __construct($BIFF_version, $name, $this->_dv = array(); - $this->_tmp_dir = $tmp_dir; - $this->_tmp_file = ''; - $this->_initialize(); } /** - * Open a tmp file to store the majority of the Worksheet data. If this fails, - * for example due to write permissions, store the data in memory. This can be - * slow for large files. - * - * @access private - */ - protected function _initialize() + * Open a tmp file to store the majority of the Worksheet data. If this fails, + * for example due to write permissions, store the data in memory. This can be + * slow for large files. + * + * @access private + */ + function _initialize() { - if ($this->_using_tmpfile == false) { - return; - } - - if ($this->_tmp_dir === '' && ini_get('open_basedir') === true) { - // open_basedir restriction in effect - store data in memory - // ToDo: Let the error actually have an effect somewhere - $this->_using_tmpfile = false; - return new PEAR_Error('Temp file could not be opened since open_basedir restriction in effect - please use setTmpDir() - using memory storage instead'); - } - // Open tmp file for storing Worksheet data - if ($this->_tmp_dir === '') { - $fh = tmpfile(); + $fh = @tmpfile(); + if ($fh) { + // Store filehandle + $this->_filehandle = $fh; } else { - // For people with open base dir restriction - $this->_tmp_file = tempnam($this->_tmp_dir, "Spreadsheet_Excel_Writer"); - $fh = @fopen($this->_tmp_file, "w+b"); - } - - if ($fh === false) { // If tmpfile() fails store data in memory $this->_using_tmpfile = false; - } else { - // Store filehandle - $this->_filehandle = $fh; } } /** - * Add data to the beginning of the workbook (note the reverse order) - * and to the end of the workbook. - * - * @access public - * @see Spreadsheet_Excel_Writer_Workbook::storeWorkbook() - * @param array $sheetnames The array of sheetnames from the Workbook this - * worksheet belongs to - */ - public function close($sheetnames) + * Add data to the beginning of the workbook (note the reverse order) + * and to the end of the workbook. + * + * @access public + * @see Spreadsheet_Excel_Writer_Workbook::storeWorkbook() + * @param array $sheetnames The array of sheetnames from the Workbook this + * worksheet belongs to + */ + function close($sheetnames) { $num_sheets = count($sheetnames); /*********************************************** - * Prepend in reverse order!! - */ + * Prepend in reverse order!! + */ // Prepend the sheet dimensions $this->_storeDimensions(); @@ -598,7 +551,7 @@ public function close($sheetnames) // Prepend GRIDSET $this->_storeGridset(); - // Prepend GUTS + // Prepend GUTS if ($this->_BIFF_version == 0x0500) { $this->_storeGuts(); } @@ -635,8 +588,8 @@ public function close($sheetnames) $this->_storeBof(0x0010); /* - * End of prepend. Read upwards from here. - ***********************************************/ + * End of prepend. Read upwards from here. + ***********************************************/ // Append $this->_storeWindow2(); @@ -648,40 +601,30 @@ public function close($sheetnames) $this->_storeMergedCells(); /* TODO: add data validity */ /*if ($this->_BIFF_version == 0x0600) { - $this->_storeDataValidity(); - }*/ + $this->_storeDataValidity(); + }*/ $this->_storeEof(); - - if ( $this->_tmp_file != '' ) { - if ( $this->_filehandle ) { - fclose($this->_filehandle); - $this->_filehandle = ''; - } - @unlink($this->_tmp_file); - $this->_tmp_file = ''; - $this->_using_tmpfile = true; - } } /** - * Retrieve the worksheet name. - * This is usefull when creating worksheets without a name. - * - * @access public - * @return string The worksheet's name - */ - public function getName() + * Retrieve the worksheet name. + * This is usefull when creating worksheets without a name. + * + * @access public + * @return string The worksheet's name + */ + function getName() { return $this->name; } /** - * Retrieves data from memory in one chunk, or from disk in $buffer - * sized chunks. - * - * @return string The data - */ - public function getData() + * Retrieves data from memory in one chunk, or from disk in $buffer + * sized chunks. + * + * @return string The data + */ + function getData() { $buffer = 4096; @@ -707,218 +650,185 @@ public function getData() } /** - * Sets a merged cell range - * - * @access public - * @param integer $first_row First row of the area to merge - * @param integer $first_col First column of the area to merge - * @param integer $last_row Last row of the area to merge - * @param integer $last_col Last column of the area to merge - */ - public function setMerge($first_row, $first_col, $last_row, $last_col) + * Sets a merged cell range + * + * @access public + * @param integer $first_row First row of the area to merge + * @param integer $first_col First column of the area to merge + * @param integer $last_row Last row of the area to merge + * @param integer $last_col Last column of the area to merge + */ + function setMerge($first_row, $first_col, $last_row, $last_col) { if (($last_row < $first_row) || ($last_col < $first_col)) { return; } - - $max_record_ranges = floor(($this->_limit - 6) / 8); - if($this->_merged_cells_counter >= $max_record_ranges) - { - $this->_merged_cells_record++; - $this->_merged_cells_counter = 0; - } - // don't check rowmin, rowmax, etc... because we don't know when this // is going to be called - $this->_merged_ranges[$this->_merged_cells_record][] = array($first_row, $first_col, $last_row, $last_col); - $this->_merged_cells_counter++; + $this->_merged_ranges[] = array($first_row, $first_col, $last_row, $last_col); } /** - * Set this worksheet as a selected worksheet, - * i.e. the worksheet has its tab highlighted. - * - * @access public - */ - public function select() + * Set this worksheet as a selected worksheet, + * i.e. the worksheet has its tab highlighted. + * + * @access public + */ + function select() { $this->selected = 1; } /** - * Set this worksheet as the active worksheet, - * i.e. the worksheet that is displayed when the workbook is opened. - * Also set it as selected. - * - * @access public - */ - public function activate() + * Set this worksheet as the active worksheet, + * i.e. the worksheet that is displayed when the workbook is opened. + * Also set it as selected. + * + * @access public + */ + function activate() { $this->selected = 1; $this->activesheet = $this->index; } /** - * Set this worksheet as the first visible sheet. - * This is necessary when there are a large number of worksheets and the - * activated worksheet is not visible on the screen. - * - * @access public - */ - public function setFirstSheet() + * Set this worksheet as the first visible sheet. + * This is necessary when there are a large number of worksheets and the + * activated worksheet is not visible on the screen. + * + * @access public + */ + function setFirstSheet() { $this->firstsheet = $this->index; } /** - * Set the worksheet protection flag - * to prevent accidental modification and to - * hide formulas if the locked and hidden format properties have been set. - * - * @access public - * @param string $password The password to use for protecting the sheet. - */ - public function protect($password) + * Set the worksheet protection flag + * to prevent accidental modification and to + * hide formulas if the locked and hidden format properties have been set. + * + * @access public + * @param string $password The password to use for protecting the sheet. + */ + function protect($password) { $this->_protect = 1; $this->_password = $this->_encodePassword($password); } /** - * Set the width of a single column or a range of columns. - * - * @access public - * @param integer $firstcol first column on the range - * @param integer $lastcol last column on the range - * @param integer $width width to set - * @param mixed $format The optional XF format to apply to the columns - * @param integer $hidden The optional hidden atribute - * @param integer $level The optional outline level - */ - public function setColumn($firstcol, $lastcol, $width, $format = null, $hidden = 0, $level = 0) - { // added by Dan Lynn _colinfo as $key => $colinfo) - { - $existing_start = $colinfo[0]; $existing_end = $colinfo[1]; - // if the new range starts within another range - if ($firstcol > $existing_start && $firstcol < $existing_end) - { // trim the existing range to the beginning of the new range - $this->_colinfo[$key][1] = $firstcol - 1; - // if the new range lies WITHIN the existing range - if ($lastcol < $existing_end) - { // split the existing range by adding a range after our new range - $this->_colinfo[] = array($lastcol+1, $existing_end, $colinfo[2], /* format */ $colinfo[3], $colinfo[4], $colinfo[5]); - } - } // if the new range ends inside an existing range - elseif ($lastcol > $existing_start && $lastcol < $existing_end) - { // trim the existing range to the end of the new range - $this->_colinfo[$key][0] = $lastcol + 1; - } // if the new range completely overlaps the existing range - elseif ($firstcol <= $existing_start && $lastcol >= $existing_end) - { - unset($this->_colinfo[$key]); - } - } // added by Dan Lynn _colinfo = array_values($this->_colinfo); - $this->_colinfo[] = array($firstcol, $lastcol, $width, $format, $hidden, $level); + * Set the width of a single column or a range of columns. + * + * @access public + * @param integer $firstcol first column on the range + * @param integer $lastcol last column on the range + * @param integer $width width to set + * @param mixed $format The optional XF format to apply to the columns + * @param integer $hidden The optional hidden atribute + * @param integer $level The optional outline level + */ + function setColumn($firstcol, $lastcol, $width, $format = null, $hidden = 0, $level = 0) + { + $this->_colinfo[] = array($firstcol, $lastcol, $width, &$format, $hidden, $level); + // Set width to zero if column is hidden $width = ($hidden) ? 0 : $width; - for ($col = $firstcol; $col <= $lastcol; $col++) - { + + for ($col = $firstcol; $col <= $lastcol; $col++) { $this->col_sizes[$col] = $width; } } /** - * Set which cell or cells are selected in a worksheet - * - * @access public - * @param integer $first_row first row in the selected quadrant - * @param integer $first_column first column in the selected quadrant - * @param integer $last_row last row in the selected quadrant - * @param integer $last_column last column in the selected quadrant - */ - public function setSelection($first_row,$first_column,$last_row,$last_column) + * Set which cell or cells are selected in a worksheet + * + * @access public + * @param integer $first_row first row in the selected quadrant + * @param integer $first_column first column in the selected quadrant + * @param integer $last_row last row in the selected quadrant + * @param integer $last_column last column in the selected quadrant + */ + function setSelection($first_row,$first_column,$last_row,$last_column) { $this->_selection = array($first_row,$first_column,$last_row,$last_column); } /** - * Set panes and mark them as frozen. - * - * @access public - * @param array $panes This is the only parameter received and is composed of the following: - * 0 => Vertical split position, - * 1 => Horizontal split position - * 2 => Top row visible - * 3 => Leftmost column visible - * 4 => Active pane - */ - public function freezePanes($panes) + * Set panes and mark them as frozen. + * + * @access public + * @param array $panes This is the only parameter received and is composed of the following: + * 0 => Vertical split position, + * 1 => Horizontal split position + * 2 => Top row visible + * 3 => Leftmost column visible + * 4 => Active pane + */ + function freezePanes($panes) { $this->_frozen = 1; $this->_panes = $panes; } /** - * Set panes and mark them as unfrozen. - * - * @access public - * @param array $panes This is the only parameter received and is composed of the following: - * 0 => Vertical split position, - * 1 => Horizontal split position - * 2 => Top row visible - * 3 => Leftmost column visible - * 4 => Active pane - */ - public function thawPanes($panes) + * Set panes and mark them as unfrozen. + * + * @access public + * @param array $panes This is the only parameter received and is composed of the following: + * 0 => Vertical split position, + * 1 => Horizontal split position + * 2 => Top row visible + * 3 => Leftmost column visible + * 4 => Active pane + */ + function thawPanes($panes) { $this->_frozen = 0; $this->_panes = $panes; } /** - * Set the page orientation as portrait. - * - * @access public - */ - public function setPortrait() + * Set the page orientation as portrait. + * + * @access public + */ + function setPortrait() { $this->_orientation = 1; } /** - * Set the page orientation as landscape. - * - * @access public - */ - public function setLandscape() + * Set the page orientation as landscape. + * + * @access public + */ + function setLandscape() { $this->_orientation = 0; } /** - * Set the paper type. Ex. 1 = US Letter, 9 = A4 - * - * @access public - * @param integer $size The type of paper size to use - */ - public function setPaper($size = 0) + * Set the paper type. Ex. 1 = US Letter, 9 = A4 + * + * @access public + * @param integer $size The type of paper size to use + */ + function setPaper($size = 0) { $this->_paper_size = $size; } /** - * Set the page header caption and optional margin. - * - * @access public - * @param string $string The header text - * @param float $margin optional head margin in inches. - */ - public function setHeader($string,$margin = 0.50) + * Set the page header caption and optional margin. + * + * @access public + * @param string $string The header text + * @param float $margin optional head margin in inches. + */ + function setHeader($string,$margin = 0.50) { if (strlen($string) >= 255) { //carp 'Header string must be less than 255 characters'; @@ -929,13 +839,13 @@ public function setHeader($string,$margin = 0.50) } /** - * Set the page footer caption and optional margin. - * - * @access public - * @param string $string The footer text - * @param float $margin optional foot margin in inches. - */ - public function setFooter($string,$margin = 0.50) + * Set the page footer caption and optional margin. + * + * @access public + * @param string $string The footer text + * @param float $margin optional foot margin in inches. + */ + function setFooter($string,$margin = 0.50) { if (strlen($string) >= 255) { //carp 'Footer string must be less than 255 characters'; @@ -946,34 +856,34 @@ public function setFooter($string,$margin = 0.50) } /** - * Center the page horinzontally. - * - * @access public - * @param integer $center the optional value for centering. Defaults to 1 (center). - */ - public function centerHorizontally($center = 1) + * Center the page horinzontally. + * + * @access public + * @param integer $center the optional value for centering. Defaults to 1 (center). + */ + function centerHorizontally($center = 1) { $this->_hcenter = $center; } /** - * Center the page vertically. - * - * @access public - * @param integer $center the optional value for centering. Defaults to 1 (center). - */ - public function centerVertically($center = 1) + * Center the page vertically. + * + * @access public + * @param integer $center the optional value for centering. Defaults to 1 (center). + */ + function centerVertically($center = 1) { $this->_vcenter = $center; } /** - * Set all the page margins to the same value in inches. - * - * @access public - * @param float $margin The margin to set in inches - */ - public function setMargins($margin) + * Set all the page margins to the same value in inches. + * + * @access public + * @param float $margin The margin to set in inches + */ + function setMargins($margin) { $this->setMarginLeft($margin); $this->setMarginRight($margin); @@ -982,81 +892,81 @@ public function setMargins($margin) } /** - * Set the left and right margins to the same value in inches. - * - * @access public - * @param float $margin The margin to set in inches - */ - public function setMargins_LR($margin) + * Set the left and right margins to the same value in inches. + * + * @access public + * @param float $margin The margin to set in inches + */ + function setMargins_LR($margin) { $this->setMarginLeft($margin); $this->setMarginRight($margin); } /** - * Set the top and bottom margins to the same value in inches. - * - * @access public - * @param float $margin The margin to set in inches - */ - public function setMargins_TB($margin) + * Set the top and bottom margins to the same value in inches. + * + * @access public + * @param float $margin The margin to set in inches + */ + function setMargins_TB($margin) { $this->setMarginTop($margin); $this->setMarginBottom($margin); } /** - * Set the left margin in inches. - * - * @access public - * @param float $margin The margin to set in inches - */ - public function setMarginLeft($margin = 0.75) + * Set the left margin in inches. + * + * @access public + * @param float $margin The margin to set in inches + */ + function setMarginLeft($margin = 0.75) { $this->_margin_left = $margin; } /** - * Set the right margin in inches. - * - * @access public - * @param float $margin The margin to set in inches - */ - public function setMarginRight($margin = 0.75) + * Set the right margin in inches. + * + * @access public + * @param float $margin The margin to set in inches + */ + function setMarginRight($margin = 0.75) { $this->_margin_right = $margin; } /** - * Set the top margin in inches. - * - * @access public - * @param float $margin The margin to set in inches - */ - public function setMarginTop($margin = 1.00) + * Set the top margin in inches. + * + * @access public + * @param float $margin The margin to set in inches + */ + function setMarginTop($margin = 1.00) { $this->_margin_top = $margin; } /** - * Set the bottom margin in inches. - * - * @access public - * @param float $margin The margin to set in inches - */ - public function setMarginBottom($margin = 1.00) + * Set the bottom margin in inches. + * + * @access public + * @param float $margin The margin to set in inches + */ + function setMarginBottom($margin = 1.00) { $this->_margin_bottom = $margin; } /** - * Set the rows to repeat at the top of each printed page. - * - * @access public - * @param integer $first_row First row to repeat - * @param integer $last_row Last row to repeat. Optional. - */ - public function repeatRows($first_row, $last_row = null) + * Set the rows to repeat at the top of each printed page. + * + * @access public + * @param integer $first_row First row to repeat + * @param integer $last_row Last row to repeat. Optional. + */ + function repeatRows($first_row, $last_row = null) { $this->title_rowmin = $first_row; if (isset($last_row)) { //Second row is optional @@ -1067,13 +977,13 @@ public function repeatRows($first_row, $last_row = null) } /** - * Set the columns to repeat at the left hand side of each printed page. - * - * @access public - * @param integer $first_col First column to repeat - * @param integer $last_col Last column to repeat. Optional. - */ - public function repeatColumns($first_col, $last_col = null) + * Set the columns to repeat at the left hand side of each printed page. + * + * @access public + * @param integer $first_col First column to repeat + * @param integer $last_col Last column to repeat. Optional. + */ + function repeatColumns($first_col, $last_col = null) { $this->title_colmin = $first_col; if (isset($last_col)) { // Second col is optional @@ -1084,15 +994,15 @@ public function repeatColumns($first_col, $last_col = null) } /** - * Set the area of each worksheet that will be printed. - * - * @access public - * @param integer $first_row First row of the area to print - * @param integer $first_col First column of the area to print - * @param integer $last_row Last row of the area to print - * @param integer $last_col Last column of the area to print - */ - public function printArea($first_row, $first_col, $last_row, $last_col) + * Set the area of each worksheet that will be printed. + * + * @access public + * @param integer $first_row First row of the area to print + * @param integer $first_col First column of the area to print + * @param integer $last_row Last row of the area to print + * @param integer $last_col Last column of the area to print + */ + function printArea($first_row, $first_col, $last_row, $last_col) { $this->print_rowmin = $first_row; $this->print_colmin = $first_col; @@ -1102,46 +1012,46 @@ public function printArea($first_row, $first_col, $last_row, $last_col) /** - * Set the option to hide gridlines on the printed page. - * - * @access public - */ - public function hideGridlines() + * Set the option to hide gridlines on the printed page. + * + * @access public + */ + function hideGridlines() { $this->_print_gridlines = 0; } /** - * Set the option to hide gridlines on the worksheet (as seen on the screen). - * - * @access public - */ - public function hideScreenGridlines() + * Set the option to hide gridlines on the worksheet (as seen on the screen). + * + * @access public + */ + function hideScreenGridlines() { $this->_screen_gridlines = 0; } /** - * Set the option to print the row and column headers on the printed page. - * - * @access public - * @param integer $print Whether to print the headers or not. Defaults to 1 (print). - */ - public function printRowColHeaders($print = 1) + * Set the option to print the row and column headers on the printed page. + * + * @access public + * @param integer $print Whether to print the headers or not. Defaults to 1 (print). + */ + function printRowColHeaders($print = 1) { $this->_print_headers = $print; } /** - * Set the vertical and horizontal number of pages that will define the maximum area printed. - * It doesn't seem to work with OpenOffice. - * - * @access public - * @param integer $width Maximun width of printed area in pages - * @param integer $height Maximun heigth of printed area in pages - * @see setPrintScale() - */ - public function fitToPages($width, $height) + * Set the vertical and horizontal number of pages that will define the maximum area printed. + * It doesn't seem to work with OpenOffice. + * + * @access public + * @param integer $width Maximun width of printed area in pages + * @param integer $height Maximun heigth of printed area in pages + * @see setPrintScale() + */ + function fitToPages($width, $height) { $this->_fit_page = 1; $this->_fit_width = $width; @@ -1149,13 +1059,13 @@ public function fitToPages($width, $height) } /** - * Store the horizontal page breaks on a worksheet (for printing). - * The breaks represent the row after which the break is inserted. - * - * @access public - * @param array $breaks Array containing the horizontal page breaks - */ - public function setHPagebreaks($breaks) + * Store the horizontal page breaks on a worksheet (for printing). + * The breaks represent the row after which the break is inserted. + * + * @access public + * @param array $breaks Array containing the horizontal page breaks + */ + function setHPagebreaks($breaks) { foreach ($breaks as $break) { array_push($this->_hbreaks, $break); @@ -1163,13 +1073,13 @@ public function setHPagebreaks($breaks) } /** - * Store the vertical page breaks on a worksheet (for printing). - * The breaks represent the column after which the break is inserted. - * - * @access public - * @param array $breaks Array containing the vertical page breaks - */ - public function setVPagebreaks($breaks) + * Store the vertical page breaks on a worksheet (for printing). + * The breaks represent the column after which the break is inserted. + * + * @access public + * @param array $breaks Array containing the vertical page breaks + */ + function setVPagebreaks($breaks) { foreach ($breaks as $break) { array_push($this->_vbreaks, $break); @@ -1178,12 +1088,12 @@ public function setVPagebreaks($breaks) /** - * Set the worksheet zoom factor. - * - * @access public - * @param integer $scale The zoom factor - */ - public function setZoom($scale = 100) + * Set the worksheet zoom factor. + * + * @access public + * @param integer $scale The zoom factor + */ + function setZoom($scale = 100) { // Confine the scale to Excel's range if ($scale < 10 || $scale > 400) { @@ -1195,13 +1105,13 @@ public function setZoom($scale = 100) } /** - * Set the scale factor for the printed page. - * It turns off the "fit to page" option - * - * @access public - * @param integer $scale The optional scale factor. Defaults to 100 - */ - public function setPrintScale($scale = 100) + * Set the scale factor for the printed page. + * It turns off the "fit to page" option + * + * @access public + * @param integer $scale The optional scale factor. Defaults to 100 + */ + function setPrintScale($scale = 100) { // Confine the scale to Excel's range if ($scale < 10 || $scale > 400) { @@ -1216,20 +1126,20 @@ public function setPrintScale($scale = 100) } /** - * Map to the appropriate write method acording to the token recieved. - * - * @access public - * @param integer $row The row of the cell we are writing to - * @param integer $col The column of the cell we are writing to - * @param mixed $token What we are writing - * @param mixed $format The optional format to apply to the cell - */ - public function write($row, $col, $token, $format = null) + * Map to the appropriate write method acording to the token recieved. + * + * @access public + * @param integer $row The row of the cell we are writing to + * @param integer $col The column of the cell we are writing to + * @param mixed $token What we are writing + * @param mixed $format The optional format to apply to the cell + */ + function write($row, $col, $token, $format = null) { // Check for a cell reference in A1 notation and substitute row and column /*if ($_[0] =~ /^\D/) { - @_ = $this->_substituteCellref(@_); - }*/ + @_ = $this->_substituteCellref(@_); + }*/ if (preg_match("/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/", $token)) { // Match number @@ -1246,6 +1156,9 @@ public function write($row, $col, $token, $format = null) } elseif (preg_match("/^=/", $token)) { // Match formula return $this->writeFormula($row, $col, $token, $format); + } elseif (preg_match("/^@/", $token)) { + // Match formula + return $this->writeFormula($row, $col, $token, $format); } elseif ($token == '') { // Match blank return $this->writeBlank($row, $col, $format); @@ -1256,17 +1169,17 @@ public function write($row, $col, $token, $format = null) } /** - * Write an array of values as a row - * - * @access public - * @param integer $row The row we are writing to - * @param integer $col The first col (leftmost col) we are writing to - * @param array $val The array of values to write - * @param mixed $format The optional format to apply to the cell - * @return mixed PEAR_Error on failure - */ + * Write an array of values as a row + * + * @access public + * @param integer $row The row we are writing to + * @param integer $col The first col (leftmost col) we are writing to + * @param array $val The array of values to write + * @param mixed $format The optional format to apply to the cell + * @return mixed PEAR_Error on failure + */ - public function writeRow($row, $col, $val, $format = null) + function writeRow($row, $col, $val, $format = null) { $retval = ''; if (is_array($val)) { @@ -1285,17 +1198,17 @@ public function writeRow($row, $col, $val, $format = null) } /** - * Write an array of values as a column - * - * @access public - * @param integer $row The first row (uppermost row) we are writing to - * @param integer $col The col we are writing to - * @param array $val The array of values to write - * @param mixed $format The optional format to apply to the cell - * @return mixed PEAR_Error on failure - */ + * Write an array of values as a column + * + * @access public + * @param integer $row The first row (uppermost row) we are writing to + * @param integer $col The col we are writing to + * @param array $val The array of values to write + * @param mixed $format The optional format to apply to the cell + * @return mixed PEAR_Error on failure + */ - public function writeCol($row, $col, $val, $format = null) + function writeCol($row, $col, $val, $format = null) { $retval = ''; if (is_array($val)) { @@ -1310,13 +1223,13 @@ public function writeCol($row, $col, $val, $format = null) } /** - * Returns an index to the XF record in the workbook - * - * @access private - * @param mixed $format The optional XF format - * @return integer The XF record index - */ - protected function _XF($format) + * Returns an index to the XF record in the workbook + * + * @access private + * @param mixed &$format The optional XF format + * @return integer The XF record index + */ + function _XF(&$format) { if ($format) { return($format->getXfIndex()); @@ -1327,20 +1240,20 @@ protected function _XF($format) /****************************************************************************** - ******************************************************************************* - * - * Internal methods - */ + ******************************************************************************* + * + * Internal methods + */ /** - * Store Worksheet data in memory using the parent's class append() or to a - * temporary file, the default. - * - * @access private - * @param string $data The binary data to append - */ - protected function _append($data) + * Store Worksheet data in memory using the parent's class append() or to a + * temporary file, the default. + * + * @access private + * @param string $data The binary data to append + */ + function _append($data) { if ($this->_using_tmpfile) { // Add CONTINUE records if necessary @@ -1355,16 +1268,16 @@ protected function _append($data) } /** - * Substitute an Excel cell reference in A1 notation for zero based row and - * column values in an argument list. - * - * Ex: ("A4", "Hello") is converted to (3, 0, "Hello"). - * - * @access private - * @param string $cell The cell reference. Or range of cells. - * @return array - */ - protected function _substituteCellref($cell) + * Substitute an Excel cell reference in A1 notation for zero based row and + * column values in an argument list. + * + * Ex: ("A4", "Hello") is converted to (3, 0, "Hello"). + * + * @access private + * @param string $cell The cell reference. Or range of cells. + * @return array + */ + function _substituteCellref($cell) { $cell = strtoupper($cell); @@ -1393,21 +1306,21 @@ protected function _substituteCellref($cell) } /** - * Convert an Excel cell reference in A1 notation to a zero based row and column - * reference; converts C1 to (0, 2). - * - * @access private - * @param string $cell The cell reference. - * @return array containing (row, column) - */ - protected function _cellToRowcol($cell) + * Convert an Excel cell reference in A1 notation to a zero based row and column + * reference; converts C1 to (0, 2). + * + * @access private + * @param string $cell The cell reference. + * @return array containing (row, column) + */ + function _cellToRowcol($cell) { preg_match("/\$?([A-I]?[A-Z])\$?(\d+)/",$cell,$match); $col = $match[1]; $row = $match[2]; // Convert base26 column string to number - $chars = explode('', $col); + $chars = split('', $col); $expn = 0; $col = 0; @@ -1425,13 +1338,13 @@ protected function _cellToRowcol($cell) } /** - * Based on the algorithm provided by Daniel Rentz of OpenOffice. - * - * @access private - * @param string $plaintext The password to be encoded in plaintext. - * @return string The encoded password - */ - protected function _encodePassword($plaintext) + * Based on the algorithm provided by Daniel Rentz of OpenOffice. + * + * @access private + * @param string $plaintext The password to be encoded in plaintext. + * @return string The encoded password + */ + function _encodePassword($plaintext) { $password = 0x0000; $i = 1; // char position @@ -1453,15 +1366,15 @@ protected function _encodePassword($plaintext) } /** - * This method sets the properties for outlining and grouping. The defaults - * correspond to Excel's defaults. - * - * @param bool $visible - * @param bool $symbols_below - * @param bool $symbols_right - * @param bool $auto_style - */ - public function setOutline($visible = true, $symbols_below = true, $symbols_right = true, $auto_style = false) + * This method sets the properties for outlining and grouping. The defaults + * correspond to Excel's defaults. + * + * @param bool $visible + * @param bool $symbols_below + * @param bool $symbols_right + * @param bool $auto_style + */ + function setOutline($visible = true, $symbols_below = true, $symbols_right = true, $auto_style = false) { $this->_outline_on = $visible; $this->_outline_below = $symbols_below; @@ -1472,41 +1385,31 @@ public function setOutline($visible = true, $symbols_below = true, $symbols_righ if ($this->_outline_on) { $this->_outline_on = 1; } - } - - /** - * This method sets the worksheet direction to right-to-left (RTL) - * - * @param bool $rtl - */ - public function setRTL($rtl = true) - { - $this->_Arabic = ($rtl ? 1 : 0); - } + } /****************************************************************************** - ******************************************************************************* - * - * BIFF RECORDS - */ - - - /** - * Write a double to the specified row and column (zero indexed). - * An integer can be written as a double. Excel will display an - * integer. $format is optional. - * - * Returns 0 : normal termination - * -2 : row or column out of range - * - * @access public - * @param integer $row Zero indexed row - * @param integer $col Zero indexed column - * @param float $num The number to write - * @param mixed $format The optional XF format - * @return integer - */ - public function writeNumber($row, $col, $num, $format = null) + ******************************************************************************* + * + * BIFF RECORDS + */ + + + /** + * Write a double to the specified row and column (zero indexed). + * An integer can be written as a double. Excel will display an + * integer. $format is optional. + * + * Returns 0 : normal termination + * -2 : row or column out of range + * + * @access public + * @param integer $row Zero indexed row + * @param integer $col Zero indexed column + * @param float $num The number to write + * @param mixed $format The optional XF format + * @return integer + */ + function writeNumber($row, $col, $num, $format = null) { $record = 0x0203; // Record identifier $length = 0x000E; // Number of bytes to follow @@ -1545,21 +1448,21 @@ public function writeNumber($row, $col, $num, $format = null) } /** - * Write a string to the specified row and column (zero indexed). - * NOTE: there is an Excel 5 defined limit of 255 characters. - * $format is optional. - * Returns 0 : normal termination - * -2 : row or column out of range - * -3 : long string truncated to 255 chars - * - * @access public - * @param integer $row Zero indexed row - * @param integer $col Zero indexed column - * @param string $str The string to write - * @param mixed $format The XF format for the cell - * @return integer - */ - public function writeString($row, $col, $str, $format = null) + * Write a string to the specified row and column (zero indexed). + * NOTE: there is an Excel 5 defined limit of 255 characters. + * $format is optional. + * Returns 0 : normal termination + * -2 : row or column out of range + * -3 : long string truncated to 255 chars + * + * @access public + * @param integer $row Zero indexed row + * @param integer $col Zero indexed column + * @param string $str The string to write + * @param mixed $format The XF format for the cell + * @return integer + */ + function writeString($row, $col, $str, $format = null) { if ($this->_BIFF_version == 0x0600) { return $this->writeStringBIFF8($row, $col, $str, $format); @@ -1605,55 +1508,50 @@ public function writeString($row, $col, $str, $format = null) } /** - * Sets Input Encoding for writing strings - * - * @access public - * @param string $encoding The encoding. Ex: 'UTF-16LE', 'utf-8', 'ISO-859-7' - */ - public function setInputEncoding($encoding) + * Sets Input Encoding for writing strings + * + * @access public + * @param string $encoding The encoding. Ex: 'UTF-16LE', 'utf-8', 'ISO-859-7' + */ + function setInputEncoding($encoding) + { + if ($encoding != 'UTF-16LE' && !function_exists('iconv')) { + $this->raiseError("Using an input encoding other than UTF-16LE requires PHP support for iconv"); + } + $this->_input_encoding = $encoding; + } + + /** + * Write a string to the specified row and column (zero indexed). + * This is the BIFF8 version (no 255 chars limit). + * $format is optional. + * Returns 0 : normal termination + * -2 : row or column out of range + * -3 : long string truncated to 255 chars + * + * @access public + * @param integer $row Zero indexed row + * @param integer $col Zero indexed column + * @param string $str The string to write + * @param mixed $format The XF format for the cell + * @return integer + */ + function writeStringBIFF8($row, $col, $str, $format = null) { - if ($encoding != 'UTF-16LE' && !function_exists('iconv')) { - $this->raiseError("Using an input encoding other than UTF-16LE requires PHP support for iconv"); - } - $this->_input_encoding = $encoding; - } - - /** - * Write a string to the specified row and column (zero indexed). - * This is the BIFF8 version (no 255 chars limit). - * $format is optional. - * Returns 0 : normal termination - * -2 : row or column out of range - * -3 : long string truncated to 255 chars - * - * @access public - * @param integer $row Zero indexed row - * @param integer $col Zero indexed column - * @param string $str The string to write - * @param mixed $format The XF format for the cell - * @return integer - */ - public function writeStringBIFF8($row, $col, $str, $format = null) - { - // If the string is Unicode and contains any "surrogate pairs" then using mb_strlen($str, 'UTF-16LE') - // as the string length will cause a "found unreadable content" error when opening the worksheet in Excel - // (apparently the length is expected to be the number of 16-bit code points, not the number of characters). - // Instead, always use the byte length divided by two for Unicode strings, and if mb_strlen() exists use - // mb_strlen($str, '8bit') just in case mbstring.func_overload is set to overload strlen(). if ($this->_input_encoding == 'UTF-16LE') { - $strlen = (function_exists('mb_strlen') ? mb_strlen($str, '8bit') : strlen($str)) / 2; + $strlen = function_exists('mb_strlen') ? mb_strlen($str, 'UTF-16LE') : (strlen($str) / 2); $encoding = 0x1; } elseif ($this->_input_encoding != '') { - $str = iconv($this->_input_encoding, 'UTF-16LE', $str); - $strlen = (function_exists('mb_strlen') ? mb_strlen($str, '8bit') : strlen($str)) / 2; + $str = @iconv($this->_input_encoding, 'UTF-16LE', $str); + $strlen = function_exists('mb_strlen') ? mb_strlen($str, 'UTF-16LE') : (strlen($str) / 2); $encoding = 0x1; } else { - $strlen = function_exists('mb_strlen') ? mb_strlen($str, '8bit') : strlen($str); + $strlen = strlen($str); $encoding = 0x0; } $record = 0x00FD; // Record identifier @@ -1682,16 +1580,16 @@ public function writeStringBIFF8($row, $col, $str, $format = null) } /** - * Check row and col before writing to a cell, and update the sheet's - * dimensions accordingly - * - * @access private - * @param integer $row Zero indexed row - * @param integer $col Zero indexed column - * @return boolean true for success, false if row and/or col are grester - * then maximums allowed. - */ - protected function _checkRowCol($row, $col) + * Check row and col before writing to a cell, and update the sheet's + * dimensions accordingly + * + * @access private + * @param integer $row Zero indexed row + * @param integer $col Zero indexed column + * @return boolean true for success, false if row and/or col are grester + * then maximums allowed. + */ + function _checkRowCol($row, $col) { if ($row >= $this->_xls_rowmax) { return false; @@ -1715,15 +1613,15 @@ protected function _checkRowCol($row, $col) } /** - * Writes a note associated with the cell given by the row and column. - * NOTE records don't have a length limit. - * - * @access public - * @param integer $row Zero indexed row - * @param integer $col Zero indexed column - * @param string $note The note to write - */ - public function writeNote($row, $col, $note) + * Writes a note associated with the cell given by the row and column. + * NOTE records don't have a length limit. + * + * @access public + * @param integer $row Zero indexed row + * @param integer $col Zero indexed column + * @param string $note The note to write + */ + function writeNote($row, $col, $note) { $note_length = strlen($note); $record = 0x001C; // Record identifier @@ -1767,23 +1665,23 @@ public function writeNote($row, $col, $note) } /** - * Write a blank cell to the specified row and column (zero indexed). - * A blank cell is used to specify formatting without adding a string - * or a number. - * - * A blank cell without a format serves no purpose. Therefore, we don't write - * a BLANK record unless a format is specified. - * - * Returns 0 : normal termination (including no format) - * -1 : insufficient number of arguments - * -2 : row or column out of range - * - * @access public - * @param integer $row Zero indexed row - * @param integer $col Zero indexed column - * @param mixed $format The XF format - */ - public function writeBlank($row, $col, $format) + * Write a blank cell to the specified row and column (zero indexed). + * A blank cell is used to specify formatting without adding a string + * or a number. + * + * A blank cell without a format serves no purpose. Therefore, we don't write + * a BLANK record unless a format is specified. + * + * Returns 0 : normal termination (including no format) + * -1 : insufficient number of arguments + * -2 : row or column out of range + * + * @access public + * @param integer $row Zero indexed row + * @param integer $col Zero indexed column + * @param mixed $format The XF format + */ + function writeBlank($row, $col, $format) { // Don't write a blank cell unless it has a format if (!$format) { @@ -1821,22 +1719,22 @@ public function writeBlank($row, $col, $format) } /** - * Write a formula to the specified row and column (zero indexed). - * The textual representation of the formula is passed to the parser in - * Parser.php which returns a packed binary string. - * - * Returns 0 : normal termination - * -1 : formula errors (bad formula) - * -2 : row or column out of range - * - * @access public - * @param integer $row Zero indexed row - * @param integer $col Zero indexed column - * @param string $formula The formula text string - * @param mixed $format The optional XF format - * @return integer - */ - public function writeFormula($row, $col, $formula, $format = null) + * Write a formula to the specified row and column (zero indexed). + * The textual representation of the formula is passed to the parser in + * Parser.php which returns a packed binary string. + * + * Returns 0 : normal termination + * -1 : formula errors (bad formula) + * -2 : row or column out of range + * + * @access public + * @param integer $row Zero indexed row + * @param integer $col Zero indexed column + * @param string $formula The formula text string + * @param mixed $format The optional XF format + * @return integer + */ + function writeFormula($row, $col, $formula, $format = null) { $record = 0x0006; // Record identifier @@ -1885,60 +1783,60 @@ public function writeFormula($row, $col, $formula, $format = null) $header = pack("vv", $record, $length); $data = pack("vvvdvVv", $row, $col, $xf, $num, - $grbit, $unknown, $formlen); + $grbit, $unknown, $formlen); $this->_append($header . $data . $formula); return 0; } /** - * Write a hyperlink. - * This is comprised of two elements: the visible label and - * the invisible link. The visible label is the same as the link unless an - * alternative string is specified. The label is written using the - * writeString() method. Therefore the 255 characters string limit applies. - * $string and $format are optional. - * - * The hyperlink can be to a http, ftp, mail, internal sheet (not yet), or external - * directory url. - * - * Returns 0 : normal termination - * -2 : row or column out of range - * -3 : long string truncated to 255 chars - * - * @access public - * @param integer $row Row - * @param integer $col Column - * @param string $url URL string - * @param string $string Alternative label - * @param mixed $format The cell format - * @return integer - */ - public function writeUrl($row, $col, $url, $string = '', $format = null) + * Write a hyperlink. + * This is comprised of two elements: the visible label and + * the invisible link. The visible label is the same as the link unless an + * alternative string is specified. The label is written using the + * writeString() method. Therefore the 255 characters string limit applies. + * $string and $format are optional. + * + * The hyperlink can be to a http, ftp, mail, internal sheet (not yet), or external + * directory url. + * + * Returns 0 : normal termination + * -2 : row or column out of range + * -3 : long string truncated to 255 chars + * + * @access public + * @param integer $row Row + * @param integer $col Column + * @param string $url URL string + * @param string $string Alternative label + * @param mixed $format The cell format + * @return integer + */ + function writeUrl($row, $col, $url, $string = '', $format = null) { // Add start row and col to arg list return($this->_writeUrlRange($row, $col, $row, $col, $url, $string, $format)); } /** - * This is the more general form of writeUrl(). It allows a hyperlink to be - * written to a range of cells. This public function also decides the type of hyperlink - * to be written. These are either, Web (http, ftp, mailto), Internal - * (Sheet1!A1) or external ('c:\temp\foo.xls#Sheet1!A1'). - * - * @access private - * @see writeUrl() - * @param integer $row1 Start row - * @param integer $col1 Start column - * @param integer $row2 End row - * @param integer $col2 End column - * @param string $url URL string - * @param string $string Alternative label - * @param mixed $format The cell format - * @return integer - */ + * This is the more general form of writeUrl(). It allows a hyperlink to be + * written to a range of cells. This function also decides the type of hyperlink + * to be written. These are either, Web (http, ftp, mailto), Internal + * (Sheet1!A1) or external ('c:\temp\foo.xls#Sheet1!A1'). + * + * @access private + * @see writeUrl() + * @param integer $row1 Start row + * @param integer $col1 Start column + * @param integer $row2 End row + * @param integer $col2 End column + * @param string $url URL string + * @param string $string Alternative label + * @param mixed $format The cell format + * @return integer + */ - protected function _writeUrlRange($row1, $col1, $row2, $col2, $url, $string = '', $format = null) + function _writeUrlRange($row1, $col1, $row2, $col2, $url, $string = '', $format = null) { // Check for internal/external sheet links or default to web link @@ -1953,22 +1851,22 @@ protected function _writeUrlRange($row1, $col1, $row2, $col2, $url, $string = '' /** - * Used to write http, ftp and mailto hyperlinks. - * The link type ($options) is 0x03 is the same as absolute dir ref without - * sheet. However it is differentiated by the $unknown2 data stream. - * - * @access private - * @see writeUrl() - * @param integer $row1 Start row - * @param integer $col1 Start column - * @param integer $row2 End row - * @param integer $col2 End column - * @param string $url URL string - * @param string $str Alternative label - * @param mixed $format The cell format - * @return integer - */ - protected function _writeUrlWeb($row1, $col1, $row2, $col2, $url, $str, $format = null) + * Used to write http, ftp and mailto hyperlinks. + * The link type ($options) is 0x03 is the same as absolute dir ref without + * sheet. However it is differentiated by the $unknown2 data stream. + * + * @access private + * @see writeUrl() + * @param integer $row1 Start row + * @param integer $col1 Start column + * @param integer $row2 End row + * @param integer $col2 End column + * @param string $url URL string + * @param string $str Alternative label + * @param mixed $format The cell format + * @return integer + */ + function _writeUrlWeb($row1, $col1, $row2, $col2, $url, $str, $format = null) { $record = 0x01B8; // Record identifier $length = 0x00000; // Bytes to follow @@ -1981,7 +1879,7 @@ protected function _writeUrlWeb($row1, $col1, $row2, $col2, $url, $str, $format if ($str == '') { $str = $url; } - $str_error = is_numeric($str) ? $this->writeNumber($row1, $col1, $str, $format) : $this->writeString($row1, $col1, $str, $format); + $str_error = $this->writeString($row1, $col1, $str, $format); if (($str_error == -2) || ($str_error == -3)) { return $str_error; } @@ -2009,26 +1907,26 @@ protected function _writeUrlWeb($row1, $col1, $row2, $col2, $url, $str, $format // Write the packed data $this->_append($header . $data . - $unknown1 . $options . - $unknown2 . $url_len . $url); + $unknown1 . $options . + $unknown2 . $url_len . $url); return($str_error); } /** - * Used to write internal reference hyperlinks such as "Sheet1!A1". - * - * @access private - * @see writeUrl() - * @param integer $row1 Start row - * @param integer $col1 Start column - * @param integer $row2 End row - * @param integer $col2 End column - * @param string $url URL string - * @param string $str Alternative label - * @param mixed $format The cell format - * @return integer - */ - protected function _writeUrlInternal($row1, $col1, $row2, $col2, $url, $str, $format = null) + * Used to write internal reference hyperlinks such as "Sheet1!A1". + * + * @access private + * @see writeUrl() + * @param integer $row1 Start row + * @param integer $col1 Start column + * @param integer $row2 End row + * @param integer $col2 End column + * @param string $url URL string + * @param string $str Alternative label + * @param mixed $format The cell format + * @return integer + */ + function _writeUrlInternal($row1, $col1, $row2, $col2, $url, $str, $format = null) { $record = 0x01B8; // Record identifier $length = 0x00000; // Bytes to follow @@ -2044,7 +1942,7 @@ protected function _writeUrlInternal($row1, $col1, $row2, $col2, $url, $str, $fo if ($str == '') { $str = $url; } - $str_error = is_numeric($str) ? $this->writeNumber($row1, $col1, $str, $format) : $this->writeString($row1, $col1, $str, $format); + $str_error = $this->writeString($row1, $col1, $str, $format); if (($str_error == -2) || ($str_error == -3)) { return $str_error; } @@ -2071,30 +1969,30 @@ protected function _writeUrlInternal($row1, $col1, $row2, $col2, $url, $str, $fo // Write the packed data $this->_append($header . $data . - $unknown1 . $options . - $url_len . $url); + $unknown1 . $options . + $url_len . $url); return($str_error); } /** - * Write links to external directory names such as 'c:\foo.xls', - * c:\foo.xls#Sheet1!A1', '../../foo.xls'. and '../../foo.xls#Sheet1!A1'. - * - * Note: Excel writes some relative links with the $dir_long string. We ignore - * these cases for the sake of simpler code. - * - * @access private - * @see writeUrl() - * @param integer $row1 Start row - * @param integer $col1 Start column - * @param integer $row2 End row - * @param integer $col2 End column - * @param string $url URL string - * @param string $str Alternative label - * @param mixed $format The cell format - * @return integer - */ - protected function _writeUrlExternal($row1, $col1, $row2, $col2, $url, $str, $format = null) + * Write links to external directory names such as 'c:\foo.xls', + * c:\foo.xls#Sheet1!A1', '../../foo.xls'. and '../../foo.xls#Sheet1!A1'. + * + * Note: Excel writes some relative links with the $dir_long string. We ignore + * these cases for the sake of simpler code. + * + * @access private + * @see writeUrl() + * @param integer $row1 Start row + * @param integer $col1 Start column + * @param integer $row2 End row + * @param integer $col2 End column + * @param string $url URL string + * @param string $str Alternative label + * @param mixed $format The cell format + * @return integer + */ + function _writeUrlExternal($row1, $col1, $row2, $col2, $url, $str, $format = null) { // Network drives are different. We will handle them separately // MS/Novell network drives and shares start with \\ @@ -2118,7 +2016,7 @@ protected function _writeUrlExternal($row1, $col1, $row2, $col2, $url, $str, $fo if ($str == '') { $str = preg_replace('/\#/', ' - ', $url); } - $str_error = is_numeric($str) ? $this->writeNumber($row1, $col1, $str, $format) : $this->writeString($row1, $col1, $str, $format); + $str_error = $this->writeString($row1, $col1, $str, $format); if (($str_error == -2) or ($str_error == -3)) { return $str_error; } @@ -2141,20 +2039,20 @@ protected function _writeUrlExternal($row1, $col1, $row2, $col2, $url, $str, $fo // parameters accordingly. // Split the dir name and sheet name (if it exists) /*if (preg_match("/\#/", $url)) { - list($dir_long, $sheet) = split("\#", $url); - } else { - $dir_long = $url; - } + list($dir_long, $sheet) = split("\#", $url); + } else { + $dir_long = $url; + } - if (isset($sheet)) { - $link_type |= 0x08; - $sheet_len = pack("V", strlen($sheet) + 0x01); - $sheet = join("\0", split('', $sheet)); - $sheet .= "\0\0\0"; - } else { - $sheet_len = ''; - $sheet = ''; - }*/ + if (isset($sheet)) { + $link_type |= 0x08; + $sheet_len = pack("V", strlen($sheet) + 0x01); + $sheet = join("\0", split('', $sheet)); + $sheet .= "\0\0\0"; + } else { + $sheet_len = ''; + $sheet = ''; + }*/ $dir_long = $url; if (preg_match("/\#/", $url)) { $link_type |= 0x08; @@ -2189,19 +2087,19 @@ protected function _writeUrlExternal($row1, $col1, $row2, $col2, $url, $str, $fo // Pack the main data stream $data = pack("vvvv", $row1, $row2, $col1, $col2) . - $unknown1 . - $link_type . - $unknown2 . - $up_count . - $dir_short_len. - $dir_short . - $unknown3 . - $stream_len ;/*. - $dir_long_len . - $unknown4 . - $dir_long . - $sheet_len . - $sheet ;*/ + $unknown1 . + $link_type . + $unknown2 . + $up_count . + $dir_short_len. + $dir_short . + $unknown3 . + $stream_len ;/*. + $dir_long_len . + $unknown4 . + $dir_long . + $sheet_len . + $sheet ;*/ // Pack the header data $length = strlen($data); @@ -2214,17 +2112,17 @@ protected function _writeUrlExternal($row1, $col1, $row2, $col2, $url, $str, $fo /** - * This method is used to set the height and format for a row. - * - * @access public - * @param integer $row The row to set - * @param integer $height Height we are giving to the row. - * Use null to set XF without setting height - * @param mixed $format XF format we are giving to the row - * @param bool $hidden The optional hidden attribute - * @param integer $level The optional outline level for row, in range [0,7] - */ - public function setRow($row, $height, $format = null, $hidden = false, $level = 0) + * This method is used to set the height and format for a row. + * + * @access public + * @param integer $row The row to set + * @param integer $height Height we are giving to the row. + * Use null to set XF without setting height + * @param mixed $format XF format we are giving to the row + * @param bool $hidden The optional hidden attribute + * @param integer $level The optional outline level for row, in range [0,7] + */ + function setRow($row, $height, $format = null, $hidden = false, $level = 0) { $record = 0x0208; // Record identifier $length = 0x0010; // Number of bytes to follow @@ -2268,16 +2166,16 @@ public function setRow($row, $height, $format = null, $hidden = false, $level = $header = pack("vv", $record, $length); $data = pack("vvvvvvvv", $row, $colMic, $colMac, $miyRw, - $irwMac,$reserved, $grbit, $ixfe); + $irwMac,$reserved, $grbit, $ixfe); $this->_append($header.$data); } /** - * Writes Excel DIMENSIONS to define the area in which there is data. - * - * @access private - */ - protected function _storeDimensions() + * Writes Excel DIMENSIONS to define the area in which there is data. + * + * @access private + */ + function _storeDimensions() { $record = 0x0200; // Record identifier $row_min = $this->_dim_rowmin; // First row @@ -2289,22 +2187,22 @@ protected function _storeDimensions() if ($this->_BIFF_version == 0x0500) { $length = 0x000A; // Number of bytes to follow $data = pack("vvvvv", $row_min, $row_max, - $col_min, $col_max, $reserved); + $col_min, $col_max, $reserved); } elseif ($this->_BIFF_version == 0x0600) { $length = 0x000E; $data = pack("VVvvv", $row_min, $row_max, - $col_min, $col_max, $reserved); + $col_min, $col_max, $reserved); } $header = pack("vv", $record, $length); $this->_prepend($header.$data); } /** - * Write BIFF record Window2. - * - * @access private - */ - protected function _storeWindow2() + * Write BIFF record Window2. + * + * @access private + */ + function _storeWindow2() { $record = 0x023E; // Record identifier if ($this->_BIFF_version == 0x0500) { @@ -2325,7 +2223,7 @@ protected function _storeWindow2() $fFrozen = $this->_frozen; // 3 $fDspZeros = 1; // 4 $fDefaultHdr = 1; // 5 - $fArabic = $this->_Arabic; // 6 + $fArabic = 0; // 6 $fDspGuts = $this->_outline_on; // 7 $fFrozenNoSplit = 0; // 0 - bit $fSelected = $this->selected; // 1 @@ -2359,11 +2257,11 @@ protected function _storeWindow2() } /** - * Write BIFF record DEFCOLWIDTH if COLINFO records are in use. - * - * @access private - */ - protected function _storeDefcol() + * Write BIFF record DEFCOLWIDTH if COLINFO records are in use. + * + * @access private + */ + function _storeDefcol() { $record = 0x0055; // Record identifier $length = 0x0002; // Number of bytes to follow @@ -2375,21 +2273,21 @@ protected function _storeDefcol() } /** - * Write BIFF record COLINFO to define column widths - * - * Note: The SDK says the record length is 0x0B but Excel writes a 0x0C - * length record. - * - * @access private - * @param array $col_array This is the only parameter received and is composed of the following: - * 0 => First formatted column, - * 1 => Last formatted column, - * 2 => Col width (8.43 is Excel default), - * 3 => The optional XF format of the column, - * 4 => Option flags. - * 5 => Optional outline level - */ - protected function _storeColinfo($col_array) + * Write BIFF record COLINFO to define column widths + * + * Note: The SDK says the record length is 0x0B but Excel writes a 0x0C + * length record. + * + * @access private + * @param array $col_array This is the only parameter received and is composed of the following: + * 0 => First formatted column, + * 1 => Last formatted column, + * 2 => Col width (8.43 is Excel default), + * 3 => The optional XF format of the column, + * 4 => Option flags. + * 5 => Optional outline level + */ + function _storeColinfo($col_array) { if (isset($col_array[0])) { $colFirst = $col_array[0]; @@ -2431,18 +2329,18 @@ protected function _storeColinfo($col_array) $header = pack("vv", $record, $length); $data = pack("vvvvvC", $colFirst, $colLast, $coldx, - $ixfe, $grbit, $reserved); + $ixfe, $grbit, $reserved); $this->_prepend($header.$data); } /** - * Write BIFF record SELECTION. - * - * @access private - * @param array $array array containing ($rwFirst,$colFirst,$rwLast,$colLast) - * @see setSelection() - */ - protected function _storeSelection($array) + * Write BIFF record SELECTION. + * + * @access private + * @param array $array array containing ($rwFirst,$colFirst,$rwLast,$colLast) + * @see setSelection() + */ + function _storeSelection($array) { list($rwFirst,$colFirst,$rwLast,$colLast) = $array; $record = 0x001D; // Record identifier @@ -2472,50 +2370,48 @@ protected function _storeSelection($array) $header = pack("vv", $record, $length); $data = pack("CvvvvvvCC", $pnn, $rwAct, $colAct, - $irefAct, $cref, - $rwFirst, $rwLast, - $colFirst, $colLast); + $irefAct, $cref, + $rwFirst, $rwLast, + $colFirst, $colLast); $this->_append($header . $data); } /** - * Store the MERGEDCELLS record for all ranges of merged cells - * - * @access private - */ - protected function _storeMergedCells() + * Store the MERGEDCELLS record for all ranges of merged cells + * + * @access private + */ + function _storeMergedCells() { // if there are no merged cell ranges set, return if (count($this->_merged_ranges) == 0) { return; } $record = 0x00E5; - foreach($this->_merged_ranges as $ranges) - { - $length = 2 + count($ranges) * 8; - $header = pack('vv', $record, $length); - $data = pack('v', count($ranges)); - foreach ($ranges as $range) - $data .= pack('vvvv', $range[0], $range[2], $range[1], $range[3]); - $string = $header.$data; - $this->_append($string, true); - } - } - - /** - * Write BIFF record EXTERNCOUNT to indicate the number of external sheet - * references in a worksheet. - * - * Excel only stores references to external sheets that are used in formulas. - * For simplicity we store references to all the sheets in the workbook - * regardless of whether they are used or not. This reduces the overall - * complexity and eliminates the need for a two way dialogue between the formula - * parser the worksheet objects. - * - * @access private - * @param integer $count The number of external sheet references in this worksheet - */ - protected function _storeExterncount($count) + $length = 2 + count($this->_merged_ranges) * 8; + + $header = pack('vv', $record, $length); + $data = pack('v', count($this->_merged_ranges)); + foreach ($this->_merged_ranges as $range) { + $data .= pack('vvvv', $range[0], $range[2], $range[1], $range[3]); + } + $this->_append($header . $data); + } + + /** + * Write BIFF record EXTERNCOUNT to indicate the number of external sheet + * references in a worksheet. + * + * Excel only stores references to external sheets that are used in formulas. + * For simplicity we store references to all the sheets in the workbook + * regardless of whether they are used or not. This reduces the overall + * complexity and eliminates the need for a two way dialogue between the formula + * parser the worksheet objects. + * + * @access private + * @param integer $count The number of external sheet references in this worksheet + */ + function _storeExterncount($count) { $record = 0x0016; // Record identifier $length = 0x0002; // Number of bytes to follow @@ -2526,15 +2422,15 @@ protected function _storeExterncount($count) } /** - * Writes the Excel BIFF EXTERNSHEET record. These references are used by - * formulas. A formula references a sheet name via an index. Since we store a - * reference to all of the external worksheets the EXTERNSHEET index is the same - * as the worksheet index. - * - * @access private - * @param string $sheetname The name of a external worksheet - */ - protected function _storeExternsheet($sheetname) + * Writes the Excel BIFF EXTERNSHEET record. These references are used by + * formulas. A formula references a sheet name via an index. Since we store a + * reference to all of the external worksheets the EXTERNSHEET index is the same + * as the worksheet index. + * + * @access private + * @param string $sheetname The name of a external worksheet + */ + function _storeExternsheet($sheetname) { $record = 0x0017; // Record identifier @@ -2558,20 +2454,20 @@ protected function _storeExternsheet($sheetname) } /** - * Writes the Excel BIFF PANE record. - * The panes can either be frozen or thawed (unfrozen). - * Frozen panes are specified in terms of an integer number of rows and columns. - * Thawed panes are specified in terms of Excel's units for rows and columns. - * - * @access private - * @param array $panes This is the only parameter received and is composed of the following: - * 0 => Vertical split position, - * 1 => Horizontal split position - * 2 => Top row visible - * 3 => Leftmost column visible - * 4 => Active pane - */ - protected function _storePanes($panes) + * Writes the Excel BIFF PANE record. + * The panes can either be frozen or thawed (unfrozen). + * Frozen panes are specified in terms of an integer number of rows and columns. + * Thawed panes are specified in terms of Excel's units for rows and columns. + * + * @access private + * @param array $panes This is the only parameter received and is composed of the following: + * 0 => Vertical split position, + * 1 => Horizontal split position + * 2 => Top row visible + * 3 => Leftmost column visible + * 4 => Active pane + */ + function _storePanes($panes) { $y = $panes[0]; $x = $panes[1]; @@ -2639,11 +2535,11 @@ protected function _storePanes($panes) } /** - * Store the page setup SETUP BIFF record. - * - * @access private - */ - protected function _storeSetup() + * Store the page setup SETUP BIFF record. + * + * @access private + */ + function _storeSetup() { $record = 0x00A1; // Record identifier $length = 0x0022; // Number of bytes to follow @@ -2687,24 +2583,24 @@ protected function _storeSetup() $header = pack("vv", $record, $length); $data1 = pack("vvvvvvvv", $iPaperSize, - $iScale, - $iPageStart, - $iFitWidth, - $iFitHeight, - $grbit, - $iRes, - $iVRes); + $iScale, + $iPageStart, + $iFitWidth, + $iFitHeight, + $grbit, + $iRes, + $iVRes); $data2 = $numHdr.$numFtr; $data3 = pack("v", $iCopies); $this->_prepend($header . $data1 . $data2 . $data3); } /** - * Store the header caption BIFF record. - * - * @access private - */ - protected function _storeHeader() + * Store the header caption BIFF record. + * + * @access private + */ + function _storeHeader() { $record = 0x0014; // Record identifier @@ -2728,11 +2624,11 @@ protected function _storeHeader() } /** - * Store the footer caption BIFF record. - * - * @access private - */ - protected function _storeFooter() + * Store the footer caption BIFF record. + * + * @access private + */ + function _storeFooter() { $record = 0x0015; // Record identifier @@ -2756,11 +2652,11 @@ protected function _storeFooter() } /** - * Store the horizontal centering HCENTER BIFF record. - * - * @access private - */ - protected function _storeHcenter() + * Store the horizontal centering HCENTER BIFF record. + * + * @access private + */ + function _storeHcenter() { $record = 0x0083; // Record identifier $length = 0x0002; // Bytes to follow @@ -2774,11 +2670,11 @@ protected function _storeHcenter() } /** - * Store the vertical centering VCENTER BIFF record. - * - * @access private - */ - protected function _storeVcenter() + * Store the vertical centering VCENTER BIFF record. + * + * @access private + */ + function _storeVcenter() { $record = 0x0084; // Record identifier $length = 0x0002; // Bytes to follow @@ -2791,11 +2687,11 @@ protected function _storeVcenter() } /** - * Store the LEFTMARGIN BIFF record. - * - * @access private - */ - protected function _storeMarginLeft() + * Store the LEFTMARGIN BIFF record. + * + * @access private + */ + function _storeMarginLeft() { $record = 0x0026; // Record identifier $length = 0x0008; // Bytes to follow @@ -2812,11 +2708,11 @@ protected function _storeMarginLeft() } /** - * Store the RIGHTMARGIN BIFF record. - * - * @access private - */ - protected function _storeMarginRight() + * Store the RIGHTMARGIN BIFF record. + * + * @access private + */ + function _storeMarginRight() { $record = 0x0027; // Record identifier $length = 0x0008; // Bytes to follow @@ -2833,11 +2729,11 @@ protected function _storeMarginRight() } /** - * Store the TOPMARGIN BIFF record. - * - * @access private - */ - protected function _storeMarginTop() + * Store the TOPMARGIN BIFF record. + * + * @access private + */ + function _storeMarginTop() { $record = 0x0028; // Record identifier $length = 0x0008; // Bytes to follow @@ -2854,11 +2750,11 @@ protected function _storeMarginTop() } /** - * Store the BOTTOMMARGIN BIFF record. - * - * @access private - */ - protected function _storeMarginBottom() + * Store the BOTTOMMARGIN BIFF record. + * + * @access private + */ + function _storeMarginBottom() { $record = 0x0029; // Record identifier $length = 0x0008; // Bytes to follow @@ -2875,17 +2771,17 @@ protected function _storeMarginBottom() } /** - * Merges the area given by its arguments. - * This is an Excel97/2000 method. It is required to perform more complicated - * merging than the normal setAlign('merge'). - * - * @access public - * @param integer $first_row First row of the area to merge - * @param integer $first_col First column of the area to merge - * @param integer $last_row Last row of the area to merge - * @param integer $last_col Last column of the area to merge - */ - public function mergeCells($first_row, $first_col, $last_row, $last_col) + * Merges the area given by its arguments. + * This is an Excel97/2000 method. It is required to perform more complicated + * merging than the normal setAlign('merge'). + * + * @access public + * @param integer $first_row First row of the area to merge + * @param integer $first_col First column of the area to merge + * @param integer $last_row Last row of the area to merge + * @param integer $last_col Last column of the area to merge + */ + function mergeCells($first_row, $first_col, $last_row, $last_col) { $record = 0x00E5; // Record identifier $length = 0x000A; // Bytes to follow @@ -2902,17 +2798,17 @@ public function mergeCells($first_row, $first_col, $last_row, $last_col) $header = pack("vv", $record, $length); $data = pack("vvvvv", $cref, $first_row, $last_row, - $first_col, $last_col); + $first_col, $last_col); $this->_append($header.$data); } /** - * Write the PRINTHEADERS BIFF record. - * - * @access private - */ - protected function _storePrintHeaders() + * Write the PRINTHEADERS BIFF record. + * + * @access private + */ + function _storePrintHeaders() { $record = 0x002a; // Record identifier $length = 0x0002; // Bytes to follow @@ -2925,12 +2821,12 @@ protected function _storePrintHeaders() } /** - * Write the PRINTGRIDLINES BIFF record. Must be used in conjunction with the - * GRIDSET record. - * - * @access private - */ - protected function _storePrintGridlines() + * Write the PRINTGRIDLINES BIFF record. Must be used in conjunction with the + * GRIDSET record. + * + * @access private + */ + function _storePrintGridlines() { $record = 0x002b; // Record identifier $length = 0x0002; // Bytes to follow @@ -2943,12 +2839,12 @@ protected function _storePrintGridlines() } /** - * Write the GRIDSET BIFF record. Must be used in conjunction with the - * PRINTGRIDLINES record. - * - * @access private - */ - protected function _storeGridset() + * Write the GRIDSET BIFF record. Must be used in conjunction with the + * PRINTGRIDLINES record. + * + * @access private + */ + function _storeGridset() { $record = 0x0082; // Record identifier $length = 0x0002; // Bytes to follow @@ -2961,14 +2857,14 @@ protected function _storeGridset() } /** - * Write the GUTS BIFF record. This is used to configure the gutter margins - * where Excel outline symbols are displayed. The visibility of the gutters is - * controlled by a flag in WSBOOL. - * - * @see _storeWsbool() - * @access private - */ - protected function _storeGuts() + * Write the GUTS BIFF record. This is used to configure the gutter margins + * where Excel outline symbols are displayed. The visibility of the gutters is + * controlled by a flag in WSBOOL. + * + * @see _storeWsbool() + * @access private + */ + function _storeGuts() { $record = 0x0080; // Record identifier $length = 0x0008; // Bytes to follow @@ -2983,10 +2879,10 @@ protected function _storeGuts() // for the row outline level is carried out in setRow(). $colcount = count($this->_colinfo); for ($i = 0; $i < $colcount; $i++) { - // Skip cols without outline level info. - if (count($this->_colinfo[$i]) >= 6) { - $col_level = max($this->_colinfo[$i][5], $col_level); - } + // Skip cols without outline level info. + if (count($col_level) >= 6) { + $col_level = max($this->_colinfo[$i][5], $col_level); + } } // Set the limits for the outline levels (0 <= x <= 7). @@ -3000,20 +2896,20 @@ protected function _storeGuts() $col_level++; } - $header = pack("vv", $record, $length); - $data = pack("vvvv", $dxRwGut, $dxColGut, $row_level, $col_level); + $header = pack("vv", $record, $length); + $data = pack("vvvv", $dxRwGut, $dxColGut, $row_level, $col_level); $this->_prepend($header.$data); } /** - * Write the WSBOOL BIFF record, mainly for fit-to-page. Used in conjunction - * with the SETUP record. - * - * @access private - */ - protected function _storeWsbool() + * Write the WSBOOL BIFF record, mainly for fit-to-page. Used in conjunction + * with the SETUP record. + * + * @access private + */ + function _storeWsbool() { $record = 0x0081; // Record identifier $length = 0x0002; // Bytes to follow @@ -3023,9 +2919,9 @@ protected function _storeWsbool() // set all the options in one go. // /*if ($this->_fit_page) { - $grbit = 0x05c1; + $grbit = 0x05c1; } else { - $grbit = 0x04c1; + $grbit = 0x04c1; }*/ // Set the option flags $grbit |= 0x0001; // Auto page breaks visible @@ -3045,17 +2941,17 @@ protected function _storeWsbool() $grbit |= 0x0400; // Outline symbols displayed } - $header = pack("vv", $record, $length); - $data = pack("v", $grbit); + $header = pack("vv", $record, $length); + $data = pack("v", $grbit); $this->_prepend($header . $data); } /** - * Write the HORIZONTALPAGEBREAKS BIFF record. - * - * @access private - */ - protected function _storeHbreak() + * Write the HORIZONTALPAGEBREAKS BIFF record. + * + * @access private + */ + function _storeHbreak() { // Return if the user hasn't specified pagebreaks if (empty($this->_hbreaks)) { @@ -3094,11 +2990,11 @@ protected function _storeHbreak() /** - * Write the VERTICALPAGEBREAKS BIFF record. - * - * @access private - */ - protected function _storeVbreak() + * Write the VERTICALPAGEBREAKS BIFF record. + * + * @access private + */ + function _storeVbreak() { // Return if the user hasn't specified pagebreaks if (empty($this->_vbreaks)) { @@ -3139,11 +3035,11 @@ protected function _storeVbreak() } /** - * Set the Biff PROTECT record to indicate that the worksheet is protected. - * - * @access private - */ - protected function _storeProtect() + * Set the Biff PROTECT record to indicate that the worksheet is protected. + * + * @access private + */ + function _storeProtect() { // Exit unless sheet protection has been specified if ($this->_protect == 0) { @@ -3162,11 +3058,11 @@ protected function _storeProtect() } /** - * Write the worksheet PASSWORD record. - * - * @access private - */ - protected function _storePassword() + * Write the worksheet PASSWORD record. + * + * @access private + */ + function _storePassword() { // Exit unless sheet protection and password have been specified if (($this->_protect == 0) || (!isset($this->_password))) { @@ -3186,18 +3082,18 @@ protected function _storePassword() /** - * Insert a 24bit bitmap image in a worksheet. - * - * @access public - * @param integer $row The row we are going to insert the bitmap into - * @param integer $col The column we are going to insert the bitmap into - * @param string $bitmap The bitmap filename - * @param integer $x The horizontal position (offset) of the image inside the cell. - * @param integer $y The vertical position (offset) of the image inside the cell. - * @param integer $scale_x The horizontal scale - * @param integer $scale_y The vertical scale - */ - public function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1) + * Insert a 24bit bitmap image in a worksheet. + * + * @access public + * @param integer $row The row we are going to insert the bitmap into + * @param integer $col The column we are going to insert the bitmap into + * @param string $bitmap The bitmap filename + * @param integer $x The horizontal position (offset) of the image inside the cell. + * @param integer $y The vertical position (offset) of the image inside the cell. + * @param integer $scale_x The horizontal scale + * @param integer $scale_y The vertical scale + */ + function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1) { $bitmap_array = $this->_processBitmap($bitmap); if ($this->isError($bitmap_array)) { @@ -3225,57 +3121,57 @@ public function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, } /** - * Calculate the vertices that define the position of the image as required by - * the OBJ record. - * - * +------------+------------+ - * | A | B | - * +-----+------------+------------+ - * | |(x1,y1) | | - * | 1 |(A1)._______|______ | - * | | | | | - * | | | | | - * +-----+----| BITMAP |-----+ - * | | | | | - * | 2 | |______________. | - * | | | (B2)| - * | | | (x2,y2)| - * +---- +------------+------------+ - * - * Example of a bitmap that covers some of the area from cell A1 to cell B2. - * - * Based on the width and height of the bitmap we need to calculate 8 vars: - * $col_start, $row_start, $col_end, $row_end, $x1, $y1, $x2, $y2. - * The width and height of the cells are also variable and have to be taken into - * account. - * The values of $col_start and $row_start are passed in from the calling - * public function. The values of $col_end and $row_end are calculated by subtracting - * the width and height of the bitmap from the width and height of the - * underlying cells. - * The vertices are expressed as a percentage of the underlying cell width as - * follows (rhs values are in pixels): - * - * x1 = X / W *1024 - * y1 = Y / H *256 - * x2 = (X-1) / W *1024 - * y2 = (Y-1) / H *256 - * - * Where: X is distance from the left side of the underlying cell - * Y is distance from the top of the underlying cell - * W is the width of the cell - * H is the height of the cell - * - * @access private - * @note the SDK incorrectly states that the height should be expressed as a - * percentage of 1024. - * @param integer $col_start Col containing upper left corner of object - * @param integer $row_start Row containing top left corner of object - * @param integer $x1 Distance to left side of object - * @param integer $y1 Distance to top of object - * @param integer $width Width of image frame - * @param integer $height Height of image frame - */ - protected function _positionImage($col_start, $row_start, $x1, $y1, $width, $height) + * Calculate the vertices that define the position of the image as required by + * the OBJ record. + * + * +------------+------------+ + * | A | B | + * +-----+------------+------------+ + * | |(x1,y1) | | + * | 1 |(A1)._______|______ | + * | | | | | + * | | | | | + * +-----+----| BITMAP |-----+ + * | | | | | + * | 2 | |______________. | + * | | | (B2)| + * | | | (x2,y2)| + * +---- +------------+------------+ + * + * Example of a bitmap that covers some of the area from cell A1 to cell B2. + * + * Based on the width and height of the bitmap we need to calculate 8 vars: + * $col_start, $row_start, $col_end, $row_end, $x1, $y1, $x2, $y2. + * The width and height of the cells are also variable and have to be taken into + * account. + * The values of $col_start and $row_start are passed in from the calling + * function. The values of $col_end and $row_end are calculated by subtracting + * the width and height of the bitmap from the width and height of the + * underlying cells. + * The vertices are expressed as a percentage of the underlying cell width as + * follows (rhs values are in pixels): + * + * x1 = X / W *1024 + * y1 = Y / H *256 + * x2 = (X-1) / W *1024 + * y2 = (Y-1) / H *256 + * + * Where: X is distance from the left side of the underlying cell + * Y is distance from the top of the underlying cell + * W is the width of the cell + * H is the height of the cell + * + * @access private + * @note the SDK incorrectly states that the height should be expressed as a + * percentage of 1024. + * @param integer $col_start Col containing upper left corner of object + * @param integer $row_start Row containing top left corner of object + * @param integer $x1 Distance to left side of object + * @param integer $y1 Distance to top of object + * @param integer $width Width of image frame + * @param integer $height Height of image frame + */ + function _positionImage($col_start, $row_start, $x1, $y1, $width, $height) { // Initialise end cell to the same as the start cell $col_end = $col_start; // Col containing lower right corner of object @@ -3327,21 +3223,21 @@ protected function _positionImage($col_start, $row_start, $x1, $y1, $width, $hei $y2 = $height / $this->_sizeRow($row_end) * 256; // Distance to bottom of object $this->_storeObjPicture($col_start, $x1, - $row_start, $y1, - $col_end, $x2, - $row_end, $y2); + $row_start, $y1, + $col_end, $x2, + $row_end, $y2); } /** - * Convert the width of a cell from user's units to pixels. By interpolation - * the relationship is: y = 7x +5. If the width hasn't been set by the user we - * use the default value. If the col is hidden we use a value of zero. - * - * @access private - * @param integer $col The column - * @return integer The width in pixels - */ - protected function _sizeCol($col) + * Convert the width of a cell from user's units to pixels. By interpolation + * the relationship is: y = 7x +5. If the width hasn't been set by the user we + * use the default value. If the col is hidden we use a value of zero. + * + * @access private + * @param integer $col The column + * @return integer The width in pixels + */ + function _sizeCol($col) { // Look up the cell value to see if it has been changed if (isset($this->col_sizes[$col])) { @@ -3356,16 +3252,16 @@ protected function _sizeCol($col) } /** - * Convert the height of a cell from user's units to pixels. By interpolation - * the relationship is: y = 4/3x. If the height hasn't been set by the user we - * use the default value. If the row is hidden we use a value of zero. (Not - * possible to hide row yet). - * - * @access private - * @param integer $row The row - * @return integer The width in pixels - */ - protected function _sizeRow($row) + * Convert the height of a cell from user's units to pixels. By interpolation + * the relationship is: y = 4/3x. If the height hasn't been set by the user we + * use the default value. If the row is hidden we use a value of zero. (Not + * possible to hide row yet). + * + * @access private + * @param integer $row The row + * @return integer The width in pixels + */ + function _sizeRow($row) { // Look up the cell value to see if it has been changed if (isset($this->_row_sizes[$row])) { @@ -3380,20 +3276,20 @@ protected function _sizeRow($row) } /** - * Store the OBJ record that precedes an IMDATA record. This could be generalise - * to support other Excel objects. - * - * @access private - * @param integer $colL Column containing upper left corner of object - * @param integer $dxL Distance from left side of cell - * @param integer $rwT Row containing top left corner of object - * @param integer $dyT Distance from top of cell - * @param integer $colR Column containing lower right corner of object - * @param integer $dxR Distance from right of cell - * @param integer $rwB Row containing bottom right corner of object - * @param integer $dyB Distance from bottom of cell - */ - protected function _storeObjPicture($colL,$dxL,$rwT,$dyT,$colR,$dxR,$rwB,$dyB) + * Store the OBJ record that precedes an IMDATA record. This could be generalise + * to support other Excel objects. + * + * @access private + * @param integer $colL Column containing upper left corner of object + * @param integer $dxL Distance from left side of cell + * @param integer $rwT Row containing top left corner of object + * @param integer $dyT Distance from top of cell + * @param integer $colR Column containing lower right corner of object + * @param integer $dxR Distance from right of cell + * @param integer $rwB Row containing bottom right corner of object + * @param integer $dyB Distance from bottom of cell + */ + function _storeObjPicture($colL,$dxL,$rwT,$dyT,$colR,$dxR,$rwB,$dyB) { $record = 0x005d; // Record identifier $length = 0x003c; // Bytes to follow @@ -3460,15 +3356,15 @@ protected function _storeObjPicture($colL,$dxL,$rwT,$dyT,$colR,$dxR,$rwB,$dyB) } /** - * Convert a 24 bit bitmap into the modified internal format used by Windows. - * This is described in BITMAPCOREHEADER and BITMAPCOREINFO structures in the - * MSDN library. - * - * @access private - * @param string $bitmap The bitmap to process - * @return array Array with data and properties of the bitmap - */ - protected function _processBitmap($bitmap) + * Convert a 24 bit bitmap into the modified internal format used by Windows. + * This is described in BITMAPCOREHEADER and BITMAPCOREINFO structures in the + * MSDN library. + * + * @access private + * @param string $bitmap The bitmap to process + * @return array Array with data and properties of the bitmap + */ + function _processBitmap($bitmap) { // Open file. $bmp_fd = @fopen($bitmap,"rb"); @@ -3547,12 +3443,12 @@ protected function _processBitmap($bitmap) } /** - * Store the window zoom factor. This should be a reduced fraction but for - * simplicity we will store all fractions with a numerator of 100. - * - * @access private - */ - protected function _storeZoom() + * Store the window zoom factor. This should be a reduced fraction but for + * simplicity we will store all fractions with a numerator of 100. + * + * @access private + */ + function _storeZoom() { // If scale is 100 we don't need to write a record if ($this->_zoom == 100) { @@ -3568,20 +3464,20 @@ protected function _storeZoom() } /** - * FIXME: add comments - */ - public function setValidation($row1, $col1, $row2, $col2, $validator) + * FIXME: add comments + */ + function setValidation($row1, $col1, $row2, $col2, &$validator) { $this->_dv[] = $validator->_getData() . - pack("vvvvv", 1, $row1, $row2, $col1, $col2); + pack("vvvvv", 1, $row1, $row2, $col1, $col2); } /** - * Store the DVAL and DV records. - * - * @access private - */ - protected function _storeDataValidity() + * Store the DVAL and DV records. + * + * @access private + */ + function _storeDataValidity() { $record = 0x01b2; // Record identifier $length = 0x0012; // Bytes to follow @@ -3593,7 +3489,7 @@ protected function _storeDataValidity() $header = pack('vv', $record, $length); $data = pack('vVVVV', $grbit, $horPos, $verPos, $objId, - count($this->_dv)); + count($this->_dv)); $this->_append($header.$data); $record = 0x01be; // Record identifier @@ -3603,4 +3499,5 @@ protected function _storeDataValidity() $this->_append($header . $dv); } } -} \ No newline at end of file +} +?> diff --git a/application/third_party/pear/Spreadsheet/Excel/Xlswriter.php b/application/third_party/pear/Spreadsheet/Excel/Xlswriter.php index bf3e39371a7..e6938fc524c 100644 --- a/application/third_party/pear/Spreadsheet/Excel/Xlswriter.php +++ b/application/third_party/pear/Spreadsheet/Excel/Xlswriter.php @@ -1,70 +1,70 @@ -* -* PERL Spreadsheet::WriteExcel module. -* -* The author of the Spreadsheet::WriteExcel module is John McNamara -* -* -* I _DO_ maintain this code, and John McNamara has nothing to do with the -* porting of this code to PHP. Any questions directly related to this -* class library should be directed to me. -* -* License Information: -* -* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets -* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com -* -* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + * Module written/ported by Xavier Noguer + * + * PERL Spreadsheet::WriteExcel module. + * + * The author of the Spreadsheet::WriteExcel module is John McNamara + * + * + * I _DO_ maintain this code, and John McNamara has nothing to do with the + * porting of this code to PHP. Any questions directly related to this + * class library should be directed to me. + * + * License Information: + * + * Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets + * Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'PEAR.php'; require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'Spreadsheet'.DIRECTORY_SEPARATOR.'Excel'.DIRECTORY_SEPARATOR.'Writer'.DIRECTORY_SEPARATOR.'Workbook.php'; /** -* Class for writing Excel Spreadsheets. This class should change COMPLETELY. -* -* @author Xavier Noguer -* @category FileFormats -* @package Spreadsheet_Excel_Writer -*/ + * Class for writing Excel Spreadsheets. This class should change COMPLETELY. + * + * @author Xavier Noguer + * @category FileFormats + * @package Spreadsheet_Excel_Writer + */ class Xlswriter extends Spreadsheet_Excel_Writer_Workbook { /** - * The constructor. It just creates a Workbook - * - * @param string $filename The optional filename for the Workbook. - * @return Spreadsheet_Excel_Writer_Workbook The Workbook created - */ - public function __construct($filename = '') + * The constructor. It just creates a Workbook + * + * @param string $filename The optional filename for the Workbook. + * @return Spreadsheet_Excel_Writer_Workbook The Workbook created + */ + function Xlswriter($filename = '') { $this->_filename = $filename; - parent::__construct($filename); + $this->Spreadsheet_Excel_Writer_Workbook($filename); } /** - * Send HTTP headers for the Excel file. - * - * @param string $filename The filename to use for HTTP headers - * @access public - */ - public function send($filename) + * Send HTTP headers for the Excel file. + * + * @param string $filename The filename to use for HTTP headers + * @access public + */ + function send($filename) { - $filename = addslashes($filename); header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=\"$filename\""); header("Expires: 0"); @@ -73,15 +73,15 @@ public function send($filename) } /** - * Utility function for writing formulas - * Converts a cell's coordinates to the A1 format. - * - * @access public - * @static - * @param integer $row Row for the cell to convert (0-indexed). - * @param integer $col Column for the cell to convert (0-indexed). - * @return string The cell identifier in A1 format - */ + * Utility function for writing formulas + * Converts a cell's coordinates to the A1 format. + * + * @access public + * @static + * @param integer $row Row for the cell to convert (0-indexed). + * @param integer $col Column for the cell to convert (0-indexed). + * @return string The cell identifier in A1 format + */ function rowcolToCell($row, $col) { if ($col > 255) { //maximum column value exceeded @@ -101,4 +101,5 @@ function rowcolToCell($row, $col) return $chr1 . $chr2 . $row; } -} \ No newline at end of file +} +?> diff --git a/application/views/admin/export/exportresults_view.php b/application/views/admin/export/exportresults_view.php index a3113442ff6..538abd2c88b 100644 --- a/application/views/admin/export/exportresults_view.php +++ b/application/views/admin/export/exportresults_view.php @@ -48,7 +48,7 @@ hasSurveyPermission($surveyid,'tokens','read')): ?> - renderPartial('/admin/export/exportresult_panels/_token-control', []); ?> + renderPartial('/admin/export/exportresult_panels/_token-control', ['surveyid' => $surveyid]); ?> diff --git a/application/views/admin/surveymenu_entries/create.php b/application/views/admin/surveymenu_entries/create.php index e8ee493d6fe..3230adad566 100644 --- a/application/views/admin/surveymenu_entries/create.php +++ b/application/views/admin/surveymenu_entries/create.php @@ -2,17 +2,17 @@ /* @var $this SurveymenuEntriesController */ /* @var $model SurveymenuEntries */ -$this->breadcrumbs=array( - 'Menu entries'=>array('index'), - 'Create', +$this->breadcrumbs = array( + gT('Menu entries') => array('index'), + gT('Create') ); -$this->menu=array( - array('label'=>'List meny entries', 'url'=>array('index')), - array('label'=>'Manage menu entries', 'url'=>array('admin')), +$this->menu = array( + array('label'=>gT('List meny entries'), 'url'=>array('index')), + array('label'=>gT('Manage menu entries'), 'url'=>array('admin')), ); ?> -

Create SurveymenuEntries

+

-renderPartial('_form', array('model'=>$model)); ?> \ No newline at end of file +renderPartial('_form', array('model'=>$model)); ?> diff --git a/application/views/admin/surveysgroups/_form.php b/application/views/admin/surveysgroups/_form.php index 30f58281982..3cbfb986a07 100644 --- a/application/views/admin/surveysgroups/_form.php +++ b/application/views/admin/surveysgroups/_form.php @@ -15,12 +15,11 @@ 'enableAjaxValidation'=>false, )); ?> -

Fields with * are required.

+

*'); ?>

errorSummary($model); ?> - hiddenField($model,'owner_uid'); ?> hiddenField($model,'gsid'); ?> diff --git a/application/views/admin/themeoptions/update.php b/application/views/admin/themeoptions/update.php index 26bfd58e1b9..701ec97d555 100644 --- a/application/views/admin/themeoptions/update.php +++ b/application/views/admin/themeoptions/update.php @@ -176,7 +176,7 @@ 'htmlOptions' => ['class' => 'form '], 'action' => $actionUrl )); ?> -

Fields with * are required.

+

*'); ?>

errorSummary($model); ?> diff --git a/application/views/admin/tutorialEntry/_form.php b/application/views/admin/tutorialEntry/_form.php index 4ff5beb8335..e671c7f0102 100644 --- a/application/views/admin/tutorialEntry/_form.php +++ b/application/views/admin/tutorialEntry/_form.php @@ -15,7 +15,7 @@ 'enableAjaxValidation'=>false, )); ?> -

Fields with * are required.

+

*'); ?>

errorSummary($model); ?> @@ -49,4 +49,4 @@ endWidget(); ?> - \ No newline at end of file + diff --git a/application/views/admin/tutorials/_form.php b/application/views/admin/tutorials/_form.php index 80a00f053fb..c4928dd466d 100644 --- a/application/views/admin/tutorials/_form.php +++ b/application/views/admin/tutorials/_form.php @@ -15,7 +15,7 @@ 'enableAjaxValidation'=>false, )); ?> -

Fields with * are required.

+

*'); ?>

errorSummary($model); ?> @@ -55,4 +55,4 @@ endWidget(); ?> - \ No newline at end of file + diff --git a/application/views/survey/questions/answer/ranking/answer.twig b/application/views/survey/questions/answer/ranking/answer.twig index 13848ebf834..140c770c4d2 100644 --- a/application/views/survey/questions/answer/ranking/answer.twig +++ b/application/views/survey/questions/answer/ranking/answer.twig @@ -38,7 +38,7 @@