997714fb60aa3fbc4c16414348aa80c2ada74b79.svn-base 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2014 PHPExcel
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. * @category PHPExcel
  22. * @package PHPExcel_Calculation
  23. * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version ##VERSION##, ##DATE##
  26. */
  27. /*
  28. PARTLY BASED ON:
  29. Copyright (c) 2007 E. W. Bachtal, Inc.
  30. Permission is hereby granted, free of charge, to any person obtaining a copy of this software
  31. and associated documentation files (the "Software"), to deal in the Software without restriction,
  32. including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
  33. and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
  34. subject to the following conditions:
  35. The above copyright notice and this permission notice shall be included in all copies or substantial
  36. portions of the Software.
  37. The software is provided "as is", without warranty of any kind, express or implied, including but not
  38. limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In
  39. no event shall the authors or copyright holders be liable for any claim, damages or other liability,
  40. whether in an action of contract, tort or otherwise, arising from, out of or in connection with the
  41. software or the use or other dealings in the software.
  42. http://ewbi.blogs.com/develops/2007/03/excel_formula_p.html
  43. http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
  44. */
  45. /**
  46. * PHPExcel_Calculation_FormulaToken
  47. *
  48. * @category PHPExcel
  49. * @package PHPExcel_Calculation
  50. * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
  51. */
  52. class PHPExcel_Calculation_FormulaToken {
  53. /* Token types */
  54. const TOKEN_TYPE_NOOP = 'Noop';
  55. const TOKEN_TYPE_OPERAND = 'Operand';
  56. const TOKEN_TYPE_FUNCTION = 'Function';
  57. const TOKEN_TYPE_SUBEXPRESSION = 'Subexpression';
  58. const TOKEN_TYPE_ARGUMENT = 'Argument';
  59. const TOKEN_TYPE_OPERATORPREFIX = 'OperatorPrefix';
  60. const TOKEN_TYPE_OPERATORINFIX = 'OperatorInfix';
  61. const TOKEN_TYPE_OPERATORPOSTFIX = 'OperatorPostfix';
  62. const TOKEN_TYPE_WHITESPACE = 'Whitespace';
  63. const TOKEN_TYPE_UNKNOWN = 'Unknown';
  64. /* Token subtypes */
  65. const TOKEN_SUBTYPE_NOTHING = 'Nothing';
  66. const TOKEN_SUBTYPE_START = 'Start';
  67. const TOKEN_SUBTYPE_STOP = 'Stop';
  68. const TOKEN_SUBTYPE_TEXT = 'Text';
  69. const TOKEN_SUBTYPE_NUMBER = 'Number';
  70. const TOKEN_SUBTYPE_LOGICAL = 'Logical';
  71. const TOKEN_SUBTYPE_ERROR = 'Error';
  72. const TOKEN_SUBTYPE_RANGE = 'Range';
  73. const TOKEN_SUBTYPE_MATH = 'Math';
  74. const TOKEN_SUBTYPE_CONCATENATION = 'Concatenation';
  75. const TOKEN_SUBTYPE_INTERSECTION = 'Intersection';
  76. const TOKEN_SUBTYPE_UNION = 'Union';
  77. /**
  78. * Value
  79. *
  80. * @var string
  81. */
  82. private $_value;
  83. /**
  84. * Token Type (represented by TOKEN_TYPE_*)
  85. *
  86. * @var string
  87. */
  88. private $_tokenType;
  89. /**
  90. * Token SubType (represented by TOKEN_SUBTYPE_*)
  91. *
  92. * @var string
  93. */
  94. private $_tokenSubType;
  95. /**
  96. * Create a new PHPExcel_Calculation_FormulaToken
  97. *
  98. * @param string $pValue
  99. * @param string $pTokenType Token type (represented by TOKEN_TYPE_*)
  100. * @param string $pTokenSubType Token Subtype (represented by TOKEN_SUBTYPE_*)
  101. */
  102. public function __construct($pValue, $pTokenType = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN, $pTokenSubType = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
  103. {
  104. // Initialise values
  105. $this->_value = $pValue;
  106. $this->_tokenType = $pTokenType;
  107. $this->_tokenSubType = $pTokenSubType;
  108. }
  109. /**
  110. * Get Value
  111. *
  112. * @return string
  113. */
  114. public function getValue() {
  115. return $this->_value;
  116. }
  117. /**
  118. * Set Value
  119. *
  120. * @param string $value
  121. */
  122. public function setValue($value) {
  123. $this->_value = $value;
  124. }
  125. /**
  126. * Get Token Type (represented by TOKEN_TYPE_*)
  127. *
  128. * @return string
  129. */
  130. public function getTokenType() {
  131. return $this->_tokenType;
  132. }
  133. /**
  134. * Set Token Type
  135. *
  136. * @param string $value
  137. */
  138. public function setTokenType($value = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN) {
  139. $this->_tokenType = $value;
  140. }
  141. /**
  142. * Get Token SubType (represented by TOKEN_SUBTYPE_*)
  143. *
  144. * @return string
  145. */
  146. public function getTokenSubType() {
  147. return $this->_tokenSubType;
  148. }
  149. /**
  150. * Set Token SubType
  151. *
  152. * @param string $value
  153. */
  154. public function setTokenSubType($value = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
  155. $this->_tokenSubType = $value;
  156. }
  157. }