• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

classes/Spreadsheet/Excel/Writer/Validator.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003 *  Module written by Herman Kuiper <herman@ozuzo.net>
00004 *
00005 *  License Information:
00006 *
00007 *    Spreadsheet_Excel_Writer:  A library for generating Excel Spreadsheets
00008 *    Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
00009 *
00010 *    This library is free software; you can redistribute it and/or
00011 *    modify it under the terms of the GNU Lesser General Public
00012 *    License as published by the Free Software Foundation; either
00013 *    version 2.1 of the License, or (at your option) any later version.
00014 *
00015 *    This library is distributed in the hope that it will be useful,
00016 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 *    Lesser General Public License for more details.
00019 *
00020 *    You should have received a copy of the GNU Lesser General Public
00021 *    License along with this library; if not, write to the Free Software
00022 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 */
00024 
00025 //require_once('PEAR.php');
00026 
00027 // Possible operator types
00028 
00029 /*
00030 FIXME: change prefixes
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; // FIXME: add method for setting datatype
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; // default is equal
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         // Parse the formula using the parser in Parser.php
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         // Parse the formula using the parser in Parser.php
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 /*class Spreadsheet_Excel_Writer_Validation_List extends Spreadsheet_Excel_Writer_Validation
00196 {
00197    function Spreadsheet_Excel_Writer_Validation_list()
00198    {
00199       parent::Spreadsheet_Excel_Writer_Validation();
00200       $this->_type = 0x03;
00201    }
00202 
00203    function setList($source, $incell = true)
00204    {
00205       $this->_incell = $incell;
00206       $this->_fixedList = true;
00207       
00208       $source = implode("\x00", $source);
00209       $this->_formula1 = pack("CCC", 0x17, strlen($source), 0x0c) . $source;
00210    }
00211 
00212    function setRow($row, $col1, $col2, $incell = true)
00213    {
00214       $this->_incell = $incell;
00215       //$this->_formula1 = ...;
00216    }
00217 
00218    function setCol($col, $row1, $row2, $incell = true)
00219    {
00220       $this->_incell = $incell;
00221       //$this->_formula1 = ...;
00222    }
00223 }*/
00224 
00225 ?>

Generated on Fri Dec 13 2013 09:06:35 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1