ILIAS
release_4-3 Revision
|
Public Member Functions | |
Spreadsheet_Excel_Writer_Parser ($byte_order, $biff_version) | |
The class constructor. | |
_initializeHashes () | |
Initialize the ptg and function hashes. | |
_convert ($token) | |
Convert a token to the proper ptg value. | |
_convertNumber ($num) | |
Convert a number token to ptgInt or ptgNum. | |
_convertString ($string) | |
Convert a string token to ptgStr. | |
_convertFunction ($token, $num_args) | |
Convert a function to a ptgFunc or ptgFuncVarV depending on the number of args that it takes. | |
_convertRange2d ($range, $class=0) | |
Convert an Excel range such as A1:D4 to a ptgRefV. | |
_convertRange3d ($token) | |
Convert an Excel 3d range such as "Sheet1!A1:D4" or "Sheet1:Sheet2!A1:D4" to a ptgArea3d. | |
_convertRef2d ($cell) | |
Convert an Excel reference such as A1, $B2, C$3 or $D$4 to a ptgRefV. | |
_convertRef3d ($cell) | |
Convert an Excel 3d reference such as "Sheet1!A1" or "Sheet1:Sheet2!A1" to a ptgRef3d. | |
_packExtRef ($ext_ref) | |
Convert the sheet name part of an external reference, for example "Sheet1" or "Sheet1:Sheet2", to a packed structure. | |
_getRefIndex ($ext_ref) | |
Look up the REF index that corresponds to an external sheet name (or range). | |
_getSheetIndex ($sheet_name) | |
Look up the index that corresponds to an external sheet name. | |
setExtSheet ($name, $index) | |
This method is used to update the array of sheet names. | |
_cellToPackedRowcol ($cell) | |
pack() row and column into the required 3 or 4 byte format. | |
_rangeToPackedRange ($range) | |
pack() row range into the required 3 or 4 byte format. | |
_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. | |
_advance () | |
Advance to the next valid token. | |
_match ($token) | |
Checks if it's a valid token. | |
parse ($formula) | |
The parsing method. | |
_condition () | |
It parses a condition. | |
_expression () | |
It parses a expression. | |
_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. | |
_term () | |
It parses a term. | |
_fact () | |
It parses a factor. | |
_func () | |
It parses a function call. | |
_createTree ($value, $left, $right) | |
Creates a tree. | |
toReversePolish ($tree=array()) | |
Builds a string containing the tree in reverse polish notation (What you would use in a HP calculator stack). | |
Public Member Functions inherited from PEAR | |
PEAR ($error_class=null) | |
Constructor. | |
_PEAR () | |
Destructor (the emulated type of...). | |
& | getStaticProperty ($class, $var) |
If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. | |
registerShutdownFunc ($func, $args=array()) | |
Use this function to register a shutdown method for static classes. | |
isError ($data, $code=null) | |
Tell whether a value is a PEAR error. | |
setErrorHandling ($mode=null, $options=null) | |
Sets how errors generated by this object should be handled. | |
expectError ($code= '*') | |
This method is used to tell which errors you expect to get. | |
popExpect () | |
This method pops one element off the expected error codes stack. | |
_checkDelExpect ($error_code) | |
This method checks unsets an error code if available. | |
delExpect ($error_code) | |
This method deletes all occurences of the specified element from the expected error codes stack. | |
& | raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false) |
This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. | |
& | throwError ($message=null, $code=null, $userinfo=null) |
Simpler form of raiseError with fewer options. | |
staticPushErrorHandling ($mode, $options=null) | |
staticPopErrorHandling () | |
pushErrorHandling ($mode, $options=null) | |
Push a new error handler on top of the error handler options stack. | |
popErrorHandling () | |
Pop the last error handler used. | |
loadExtension ($ext) | |
OS independant PHP extension load. |
Data Fields | |
$_current_char | |
$_current_token | |
$_formula | |
$_lookahead | |
$_parse_tree | |
$_byte_order | |
$_ext_sheets | |
$_references | |
$_BIFF_version | |
Data Fields inherited from PEAR | |
$_debug = false | |
$_default_error_mode = null | |
$_default_error_options = null | |
$_default_error_handler = '' | |
$_error_class = 'PEAR_Error' | |
$_expected_errors = array() |
Definition at line 110 of file Parser.php.
Spreadsheet_Excel_Writer_Parser::_advance | ( | ) |
Advance to the next valid token.
private
Definition at line 1108 of file Parser.php.
References $_current_char, and _match().
Referenced by _condition(), _expression(), _fact(), _func(), _term(), and parse().
Spreadsheet_Excel_Writer_Parser::_cellToPackedRowcol | ( | $cell | ) |
pack() row and column into the required 3 or 4 byte format.
private
string | $cell | The Excel cell reference to be packed |
Definition at line 996 of file Parser.php.
References $row, _cellToRowcol(), and PEAR\raiseError().
Referenced by _convertRange2d(), _convertRange3d(), _convertRef2d(), and _convertRef3d().
Spreadsheet_Excel_Writer_Parser::_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.
private
string | $cell | The Excel cell reference in A1 format. |
Definition at line 1078 of file Parser.php.
References $row.
Referenced by _cellToPackedRowcol().
Spreadsheet_Excel_Writer_Parser::_condition | ( | ) |
It parses a condition.
It assumes the following rule: Cond -> Expr [(">" | "<") Expr]
private
Definition at line 1309 of file Parser.php.
References $result, _advance(), _createTree(), _expression(), PEAR\isError(), SPREADSHEET_EXCEL_WRITER_CONCAT, SPREADSHEET_EXCEL_WRITER_EQ, SPREADSHEET_EXCEL_WRITER_GE, SPREADSHEET_EXCEL_WRITER_GT, SPREADSHEET_EXCEL_WRITER_LE, SPREADSHEET_EXCEL_WRITER_LT, and SPREADSHEET_EXCEL_WRITER_NE.
Referenced by _func(), and parse().
Spreadsheet_Excel_Writer_Parser::_convert | ( | $token | ) |
Convert a token to the proper ptg value.
private
mixed | $token | The token to convert. |
Definition at line 543 of file Parser.php.
References _convertNumber(), _convertRange2d(), _convertRange3d(), _convertRef2d(), _convertRef3d(), _convertString(), and PEAR\raiseError().
Referenced by toReversePolish().
Spreadsheet_Excel_Writer_Parser::_convertFunction | ( | $token, | |
$num_args | |||
) |
Convert a function to a ptgFunc or ptgFuncVarV depending on the number of args that it takes.
private
string | $token | The name of the function for convertion to ptg value. |
integer | $num_args | The number of arguments the function receives. |
Definition at line 649 of file Parser.php.
Spreadsheet_Excel_Writer_Parser::_convertNumber | ( | $num | ) |
Convert a number token to ptgInt or ptgNum.
private
mixed | $num | an integer or double for conversion to its ptg value |
Definition at line 603 of file Parser.php.
Referenced by _convert().
Spreadsheet_Excel_Writer_Parser::_convertRange2d | ( | $range, | |
$class = 0 |
|||
) |
Convert an Excel range such as A1:D4 to a ptgRefV.
private
string | $range | An Excel range in the A1:A2 or A1..A2 format. |
Definition at line 670 of file Parser.php.
References _cellToPackedRowcol(), PEAR\isError(), PEAR_ERROR_DIE, and PEAR\raiseError().
Referenced by _convert().
Spreadsheet_Excel_Writer_Parser::_convertRange3d | ( | $token | ) |
Convert an Excel 3d range such as "Sheet1!A1:D4" or "Sheet1:Sheet2!A1:D4" to a ptgArea3d.
private
string | $token | An Excel range in the Sheet1!A1:A2 format. |
Definition at line 719 of file Parser.php.
References _cellToPackedRowcol(), _getRefIndex(), _packExtRef(), _rangeToPackedRange(), PEAR\isError(), PEAR_ERROR_DIE, and PEAR\raiseError().
Referenced by _convert().
Spreadsheet_Excel_Writer_Parser::_convertRef2d | ( | $cell | ) |
Convert an Excel reference such as A1, $B2, C$3 or $D$4 to a ptgRefV.
private
string | $cell | An Excel cell reference |
Definition at line 783 of file Parser.php.
References $row, _cellToPackedRowcol(), PEAR\isError(), and PEAR\raiseError().
Referenced by _convert().
Spreadsheet_Excel_Writer_Parser::_convertRef3d | ( | $cell | ) |
Convert an Excel 3d reference such as "Sheet1!A1" or "Sheet1:Sheet2!A1" to a ptgRef3d.
private
string | $cell | An Excel cell reference |
Definition at line 816 of file Parser.php.
References $row, _cellToPackedRowcol(), _getRefIndex(), _packExtRef(), PEAR\isError(), PEAR_ERROR_DIE, and PEAR\raiseError().
Referenced by _convert().
Spreadsheet_Excel_Writer_Parser::_convertString | ( | $string | ) |
Convert a string token to ptgStr.
private
string | $string | A string for conversion to its ptg value. |
Definition at line 624 of file Parser.php.
References PEAR\raiseError().
Referenced by _convert().
Spreadsheet_Excel_Writer_Parser::_createTree | ( | $value, | |
$left, | |||
$right | |||
) |
Creates a tree.
In fact an array which may have one or two arrays (sub-trees) as elements.
private
mixed | $value | The value of this node. |
mixed | $left | The left array (sub-tree) or a final node. |
mixed | $right | The right array (sub-tree) or a final node. |
Definition at line 1611 of file Parser.php.
Referenced by _condition(), _expression(), _fact(), _func(), _parenthesizedExpression(), and _term().
Spreadsheet_Excel_Writer_Parser::_expression | ( | ) |
It parses a expression.
It assumes the following rule: Expr -> Term [("+" | "-") Term] -> "string" -> "-" Term
private
Definition at line 1377 of file Parser.php.
References $result, _advance(), _createTree(), _term(), PEAR\isError(), SPREADSHEET_EXCEL_WRITER_ADD, and SPREADSHEET_EXCEL_WRITER_SUB.
Referenced by _condition(), and _parenthesizedExpression().
Spreadsheet_Excel_Writer_Parser::_fact | ( | ) |
It parses a factor.
It assumes the following rule: Fact -> ( Expr ) | CellRef | CellRange | Number | Function
private
Definition at line 1477 of file Parser.php.
References $_current_token, $result, _advance(), _createTree(), _func(), _parenthesizedExpression(), PEAR\raiseError(), SPREADSHEET_EXCEL_WRITER_CLOSE, and SPREADSHEET_EXCEL_WRITER_OPEN.
Referenced by _term().
Spreadsheet_Excel_Writer_Parser::_func | ( | ) |
It parses a function call.
It assumes the following rule: Func -> ( Expr [,Expr]* )
private
Definition at line 1555 of file Parser.php.
References $result, _advance(), _condition(), _createTree(), PEAR\isError(), PEAR\raiseError(), SPREADSHEET_EXCEL_WRITER_COMA, and SPREADSHEET_EXCEL_WRITER_SEMICOLON.
Referenced by _fact().
Spreadsheet_Excel_Writer_Parser::_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.
private
string | $ext_ref | The name of the external reference |
Definition at line 907 of file Parser.php.
References _getSheetIndex(), and PEAR\raiseError().
Referenced by _convertRange3d(), and _convertRef3d().
Spreadsheet_Excel_Writer_Parser::_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.
private
Definition at line 965 of file Parser.php.
Referenced by _getRefIndex(), and _packExtRef().
Spreadsheet_Excel_Writer_Parser::_initializeHashes | ( | ) |
Initialize the ptg and function hashes.
private
Definition at line 191 of file Parser.php.
Referenced by Spreadsheet_Excel_Writer_Parser().
Spreadsheet_Excel_Writer_Parser::_match | ( | $token | ) |
Checks if it's a valid token.
private
mixed | $token | The token to check. |
Definition at line 1158 of file Parser.php.
References SPREADSHEET_EXCEL_WRITER_ADD, SPREADSHEET_EXCEL_WRITER_CLOSE, SPREADSHEET_EXCEL_WRITER_COMA, SPREADSHEET_EXCEL_WRITER_CONCAT, SPREADSHEET_EXCEL_WRITER_DIV, SPREADSHEET_EXCEL_WRITER_EQ, SPREADSHEET_EXCEL_WRITER_GE, SPREADSHEET_EXCEL_WRITER_GT, SPREADSHEET_EXCEL_WRITER_LE, SPREADSHEET_EXCEL_WRITER_LT, SPREADSHEET_EXCEL_WRITER_MUL, SPREADSHEET_EXCEL_WRITER_NE, SPREADSHEET_EXCEL_WRITER_OPEN, SPREADSHEET_EXCEL_WRITER_SEMICOLON, and SPREADSHEET_EXCEL_WRITER_SUB.
Referenced by _advance().
Spreadsheet_Excel_Writer_Parser::_packExtRef | ( | $ext_ref | ) |
Convert the sheet name part of an external reference, for example "Sheet1" or "Sheet1:Sheet2", to a packed structure.
private
string | $ext_ref | The name of the external reference |
Definition at line 861 of file Parser.php.
References _getSheetIndex(), and PEAR\raiseError().
Referenced by _convertRange3d(), and _convertRef3d().
Spreadsheet_Excel_Writer_Parser::_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.
private
Definition at line 1425 of file Parser.php.
References $result, _createTree(), and _expression().
Referenced by _fact().
Spreadsheet_Excel_Writer_Parser::_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
private
string | $range | The Excel range to be packed |
Definition at line 1031 of file Parser.php.
References PEAR\raiseError().
Referenced by _convertRange3d().
Spreadsheet_Excel_Writer_Parser::_term | ( | ) |
It parses a term.
It assumes the following rule: Term -> Fact [("*" | "/") Fact]
private
Definition at line 1438 of file Parser.php.
References $result, _advance(), _createTree(), _fact(), PEAR\isError(), SPREADSHEET_EXCEL_WRITER_DIV, and SPREADSHEET_EXCEL_WRITER_MUL.
Referenced by _expression().
Spreadsheet_Excel_Writer_Parser::parse | ( | $formula | ) |
The parsing method.
It parses a formula.
public
string | $formula | The formula to parse, without the initial equal sign (=). |
Definition at line 1289 of file Parser.php.
References $_parse_tree, _advance(), _condition(), and PEAR\isError().
Spreadsheet_Excel_Writer_Parser::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.
public
string | $name | The name of the worksheet being added |
integer | $index | The index of the worksheet being added |
Definition at line 984 of file Parser.php.
Spreadsheet_Excel_Writer_Parser::Spreadsheet_Excel_Writer_Parser | ( | $byte_order, | |
$biff_version | |||
) |
The class constructor.
integer | $byte_order | The byte order (Little endian or Big endian) of the architecture (optional). 1 => big endian, 0 (default) little endian. |
Definition at line 172 of file Parser.php.
References _initializeHashes().
Spreadsheet_Excel_Writer_Parser::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:
produces: "23+"
The following tree:
produces: "36A1*+"
In fact all operands, functions, references, etc... are written as ptg's
public
array | $tree | The optional tree to convert. |
Definition at line 1643 of file Parser.php.
References $_parse_tree, _convert(), and PEAR\isError().
Spreadsheet_Excel_Writer_Parser::$_BIFF_version |
Definition at line 164 of file Parser.php.
Spreadsheet_Excel_Writer_Parser::$_byte_order |
Definition at line 146 of file Parser.php.
Spreadsheet_Excel_Writer_Parser::$_current_char |
Definition at line 116 of file Parser.php.
Referenced by _advance().
Spreadsheet_Excel_Writer_Parser::$_current_token |
Definition at line 122 of file Parser.php.
Referenced by _fact().
Spreadsheet_Excel_Writer_Parser::$_ext_sheets |
Definition at line 152 of file Parser.php.
Spreadsheet_Excel_Writer_Parser::$_formula |
Definition at line 128 of file Parser.php.
Spreadsheet_Excel_Writer_Parser::$_lookahead |
Definition at line 134 of file Parser.php.
Spreadsheet_Excel_Writer_Parser::$_parse_tree |
Definition at line 140 of file Parser.php.
Referenced by parse(), and toReversePolish().
Spreadsheet_Excel_Writer_Parser::$_references |
Definition at line 158 of file Parser.php.