Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 define("OP_BETWEEN", 0x00);
00033 define("OP_NOTBETWEEN", 0x01);
00034 define("OP_EQUAL", 0x02);
00035 define("OP_NOTEQUAL", 0x03);
00036 define("OP_GT", 0x04);
00037 define("OP_LT", 0x05);
00038 define("OP_GTE", 0x06);
00039 define("OP_LTE", 0x07);
00040
00048 class Spreadsheet_Excel_Writer_Validator
00049 {
00050 var $_type;
00051 var $_style;
00052 var $_fixedList;
00053 var $_blank;
00054 var $_incell;
00055 var $_showprompt;
00056 var $_showerror;
00057 var $_title_prompt;
00058 var $_descr_prompt;
00059 var $_title_error;
00060 var $_descr_error;
00061 var $_operator;
00062 var $_formula1;
00063 var $_formula2;
00068 var $_parser;
00069
00070 function Spreadsheet_Excel_Writer_Validator(&$parser)
00071 {
00072 $this->_parser = $parser;
00073 $this->_type = 0x01;
00074 $this->_style = 0x00;
00075 $this->_fixedList = false;
00076 $this->_blank = false;
00077 $this->_incell = false;
00078 $this->_showprompt = false;
00079 $this->_showerror = true;
00080 $this->_title_prompt = "\x00";
00081 $this->_descr_prompt = "\x00";
00082 $this->_title_error = "\x00";
00083 $this->_descr_error = "\x00";
00084 $this->_operator = 0x00;
00085 $this->_formula1 = "";
00086 $this->_formula2 = "";
00087 }
00088
00089 function setPrompt($promptTitle = "\x00", $promptDescription = "\x00", $showPrompt = true)
00090 {
00091 $this->_showprompt = $showPrompt;
00092 $this->_title_prompt = $promptTitle;
00093 $this->_descr_prompt = $promptDescription;
00094 }
00095
00096 function setError($errorTitle = "\x00", $errorDescription = "\x00", $showError = true)
00097 {
00098 $this->_showerror = $showError;
00099 $this->_title_error = $errorTitle;
00100 $this->_descr_error = $errorDescription;
00101 }
00102
00103 function allowBlank()
00104 {
00105 $this->_blank = true;
00106 }
00107
00108 function onInvalidStop()
00109 {
00110 $this->_style = 0x00;
00111 }
00112
00113 function onInvalidWarn()
00114 {
00115 $this->_style = 0x01;
00116 }
00117
00118 function onInvalidInfo()
00119 {
00120 $this->_style = 0x02;
00121 }
00122
00123 function setFormula1($formula)
00124 {
00125
00126 $error = $this->_parser->parse($formula);
00127 if (PEAR::isError($error)) {
00128 return $this->_formula1;
00129 }
00130
00131 $this->_formula1 = $this->_parser->toReversePolish();
00132 if (PEAR::isError($this->_formula1)) {
00133 return $this->_formula1;
00134 }
00135 return true;
00136 }
00137
00138 function setFormula2($formula)
00139 {
00140
00141 $error = $this->_parser->parse($formula);
00142 if (PEAR::isError($error)) {
00143 return $this->_formula2;
00144 }
00145
00146 $this->_formula2 = $this->_parser->toReversePolish();
00147 if (PEAR::isError($this->_formula2)) {
00148 return $this->_formula2;
00149 }
00150 return true;
00151 }
00152
00153 function _getOptions()
00154 {
00155 $options = $this->_type;
00156 $options |= $this->_style << 3;
00157 if($this->_fixedList)
00158 $options |= 0x80;
00159 if($this->_blank)
00160 $options |= 0x100;
00161 if(!$this->_incell)
00162 $options |= 0x200;
00163 if($this->_showprompt)
00164 $options |= 0x40000;
00165 if($this->_showerror)
00166 $options |= 0x80000;
00167 $options |= $this->_operator << 20;
00168
00169 return $options;
00170 }
00171
00172 function _getData()
00173 {
00174 $title_prompt_len = strlen($this->_title_prompt);
00175 $descr_prompt_len = strlen($this->_descr_prompt);
00176 $title_error_len = strlen($this->_title_error);
00177 $descr_error_len = strlen($this->_descr_error);
00178
00179 $formula1_size = strlen($this->_formula1);
00180 $formula2_size = strlen($this->_formula2);
00181
00182 $data = pack("V", $this->_getOptions());
00183 $data .= pack("vC", $title_prompt_len, 0x00) . $this->_title_prompt;
00184 $data .= pack("vC", $title_error_len, 0x00) . $this->_title_error;
00185 $data .= pack("vC", $descr_prompt_len, 0x00) . $this->_descr_prompt;
00186 $data .= pack("vC", $descr_error_len, 0x00) . $this->_descr_error;
00187
00188 $data .= pack("vv", $formula1_size, 0x0000) . $this->_formula1;
00189 $data .= pack("vv", $formula2_size, 0x0000) . $this->_formula2;
00190
00191 return $data;
00192 }
00193 }
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225 ?>