PHPExcel_Cell
[ class tree: PHPExcel_Cell ] [ index: PHPExcel_Cell ] [ all elements ]

Source for file DataValidation.php

Documentation is available at DataValidation.php

  1. <?php
  2. /**
  3.  * PHPExcel
  4.  *
  5.  * Copyright (c) 2006 - 2009 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_Cell
  23.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.6.5, 2009-01-05
  26.  */
  27.  
  28.  
  29. /**
  30.  * PHPExcel_Cell_DataValidation
  31.  *
  32.  * @category   PHPExcel
  33.  * @package    PHPExcel_Cell
  34.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  35.  */
  36. {
  37.     /* Data validation types */
  38.     const TYPE_NONE            'none';
  39.     const TYPE_CUSTOM        'custom';
  40.     const TYPE_DATE            'date';
  41.     const TYPE_DECIMAL        'decimal';
  42.     const TYPE_LIST            'list';
  43.     const TYPE_TEXTLENGTH    'textLength';
  44.     const TYPE_TIME            'time';
  45.     const TYPE_WHOLE        'whole';
  46.     
  47.     /* Data validation error styles */
  48.     const STYLE_STOP        'stop';
  49.     const STYLE_WARNING        'warning';
  50.     const STYLE_INFORMATION    'information';
  51.     
  52.     /* Data validation operators */
  53.     const OPERATOR_BETWEEN                'between';
  54.     const OPERATOR_EQUAL                'equal';
  55.     const OPERATOR_GREATERTHAN            'greaterThan';
  56.     const OPERATOR_GREATERTHANOREQUAL    'greaterThanOrEqual';
  57.     const OPERATOR_LESSTHAN                'lessThan';
  58.     const OPERATOR_LESSTHANOREQUAL        'lessThanOrEqual';
  59.     const OPERATOR_NOTBETWEEN            'notBetween';
  60.     const OPERATOR_NOTEQUAL                'notEqual';
  61.     
  62.     /**
  63.      * Formula 1
  64.      *
  65.      * @var string 
  66.      */
  67.     private $_formula1;
  68.     
  69.     /**
  70.      * Formula 2
  71.      *
  72.      * @var string 
  73.      */
  74.     private $_formula2;
  75.     
  76.     /**
  77.      * Type
  78.      *
  79.      * @var string 
  80.      */
  81.     private $_type = PHPExcel_Cell_DataValidation::TYPE_NONE;
  82.     
  83.     /**
  84.      * Error style
  85.      *
  86.      * @var string 
  87.      */
  88.     private $_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
  89.     
  90.     /**
  91.      * Operator
  92.      *
  93.      * @var string 
  94.      */
  95.     private $_operator;
  96.     
  97.     /**
  98.      * Allow Blank
  99.      *
  100.      * @var boolean 
  101.      */
  102.     private $_allowBlank;
  103.     
  104.     /**
  105.      * Show DropDown
  106.      *
  107.      * @var boolean 
  108.      */
  109.     private $_showDropDown;
  110.     
  111.     /**
  112.      * Show InputMessage
  113.      *
  114.      * @var boolean 
  115.      */
  116.     private $_showInputMessage;
  117.     
  118.     /**
  119.      * Show ErrorMessage
  120.      *
  121.      * @var boolean 
  122.      */
  123.     private $_showErrorMessage;
  124.     
  125.     /**
  126.      * Error title
  127.      *
  128.      * @var string 
  129.      */
  130.     private $_errorTitle;
  131.     
  132.     /**
  133.      * Error
  134.      *
  135.      * @var string 
  136.      */
  137.     private $_error;
  138.     
  139.     /**
  140.      * Prompt title
  141.      *
  142.      * @var string 
  143.      */
  144.     private $_promptTitle;
  145.     
  146.     /**
  147.      * Prompt
  148.      *
  149.      * @var string 
  150.      */
  151.     private $_prompt;
  152.     
  153.     /**
  154.      * Parent cell
  155.      *
  156.      * @var PHPExcel_Cell 
  157.      */
  158.     private $_parent;
  159.     
  160.     /**
  161.      * Create a new PHPExcel_Cell_DataValidation
  162.      *
  163.      * @param     PHPExcel_Cell        $pCell    Parent cell
  164.      * @throws    Exception
  165.      */
  166.     public function __construct(PHPExcel_Cell $pCell null)
  167.     {
  168.         // Initialise member variables
  169.         $this->_formula1             = '';
  170.         $this->_formula2             = '';
  171.         $this->_type                 = PHPExcel_Cell_DataValidation::TYPE_NONE;
  172.         $this->_errorStyle             = PHPExcel_Cell_DataValidation::STYLE_STOP;
  173.         $this->_operator             = '';
  174.         $this->_allowBlank             = false;
  175.         $this->_showDropDown         = false;
  176.         $this->_showInputMessage     = false;
  177.         $this->_showErrorMessage     = false;
  178.         $this->_errorTitle             = '';
  179.         $this->_error                 = '';
  180.         $this->_promptTitle         = '';
  181.         $this->_prompt                 = '';
  182.      
  183.         // Set cell
  184.         $this->_parent = $pCell;
  185.     }
  186.     
  187.     /**
  188.      * Get Formula 1
  189.      *
  190.      * @return string 
  191.      */
  192.     public function getFormula1({
  193.         return $this->_formula1;
  194.     }
  195.  
  196.     /**
  197.      * Set Formula 1
  198.      *
  199.      * @param    string    $value 
  200.      */
  201.     public function setFormula1($value ''{
  202.         $this->_formula1 = $value;
  203.     }
  204.  
  205.     /**
  206.      * Get Formula 2
  207.      *
  208.      * @return string 
  209.      */
  210.     public function getFormula2({
  211.         return $this->_formula2;
  212.     }
  213.  
  214.     /**
  215.      * Set Formula 2
  216.      *
  217.      * @param    string    $value 
  218.      */
  219.     public function setFormula2($value ''{
  220.         $this->_formula2 = $value;
  221.     }
  222.     
  223.     /**
  224.      * Get Type
  225.      *
  226.      * @return string 
  227.      */
  228.     public function getType({
  229.         return $this->_type;
  230.     }
  231.  
  232.     /**
  233.      * Set Type
  234.      *
  235.      * @param    string    $value 
  236.      */
  237.     public function setType($value PHPExcel_Cell_DataValidation::TYPE_NONE{
  238.         $this->_type = $value;
  239.     }
  240.  
  241.     /**
  242.      * Get Error style
  243.      *
  244.      * @return string 
  245.      */
  246.     public function getErrorStyle({
  247.         return $this->_errorStyle;
  248.     }
  249.  
  250.     /**
  251.      * Set Error style
  252.      *
  253.      * @param    string    $value 
  254.      */
  255.     public function setErrorStyle($value PHPExcel_Cell_DataValidation::STYLE_STOP{
  256.         $this->_errorStyle = $value;
  257.     }
  258.  
  259.     /**
  260.      * Get Operator
  261.      *
  262.      * @return string 
  263.      */
  264.     public function getOperator({
  265.         return $this->_operator;
  266.     }
  267.  
  268.     /**
  269.      * Set Operator
  270.      *
  271.      * @param    string    $value 
  272.      */
  273.     public function setOperator($value ''{
  274.         $this->_operator = $value;
  275.     }
  276.  
  277.     /**
  278.      * Get Allow Blank
  279.      *
  280.      * @return boolean 
  281.      */
  282.     public function getAllowBlank({
  283.         return $this->_allowBlank;
  284.     }
  285.  
  286.     /**
  287.      * Set Allow Blank
  288.      *
  289.      * @param    boolean    $value 
  290.      */
  291.     public function setAllowBlank($value false{
  292.         $this->_allowBlank = $value;
  293.     }
  294.  
  295.     /**
  296.      * Get Show DropDown
  297.      *
  298.      * @return boolean 
  299.      */
  300.     public function getShowDropDown({
  301.         return $this->_showDropDown;
  302.     }
  303.  
  304.     /**
  305.      * Set Show DropDown
  306.      *
  307.      * @param    boolean    $value 
  308.      */
  309.     public function setShowDropDown($value false{
  310.         $this->_showDropDown = $value;
  311.     }
  312.  
  313.     /**
  314.      * Get Show InputMessage
  315.      *
  316.      * @return boolean 
  317.      */
  318.     public function getShowInputMessage({
  319.         return $this->_showInputMessage;
  320.     }
  321.  
  322.     /**
  323.      * Set Show InputMessage
  324.      *
  325.      * @param    boolean    $value 
  326.      */
  327.     public function setShowInputMessage($value false{
  328.         $this->_showInputMessage = $value;
  329.     }
  330.  
  331.     /**
  332.      * Get Show ErrorMessage
  333.      *
  334.      * @return boolean 
  335.      */
  336.     public function getShowErrorMessage({
  337.         return $this->_showErrorMessage;
  338.     }
  339.  
  340.     /**
  341.      * Set Show ErrorMessage
  342.      *
  343.      * @param    boolean    $value 
  344.      */
  345.     public function setShowErrorMessage($value false{
  346.         $this->_showErrorMessage = $value;
  347.     }
  348.  
  349.     /**
  350.      * Get Error title
  351.      *
  352.      * @return string 
  353.      */
  354.     public function getErrorTitle({
  355.         return $this->_errorTitle;
  356.     }
  357.  
  358.     /**
  359.      * Set Error title
  360.      *
  361.      * @param    string    $value 
  362.      */
  363.     public function setErrorTitle($value ''{
  364.         $this->_errorTitle = $value;
  365.     }
  366.  
  367.     /**
  368.      * Get Error
  369.      *
  370.      * @return string 
  371.      */
  372.     public function getError({
  373.         return $this->_error;
  374.     }
  375.  
  376.     /**
  377.      * Set Error
  378.      *
  379.      * @param    string    $value 
  380.      */
  381.     public function setError($value ''{
  382.         $this->_error = $value;
  383.     }
  384.  
  385.     /**
  386.      * Get Prompt title
  387.      *
  388.      * @return string 
  389.      */
  390.     public function getPromptTitle({
  391.         return $this->_promptTitle;
  392.     }
  393.  
  394.     /**
  395.      * Set Prompt title
  396.      *
  397.      * @param    string    $value 
  398.      */
  399.     public function setPromptTitle($value ''{
  400.         $this->_promptTitle = $value;
  401.     }
  402.  
  403.     /**
  404.      * Get Prompt
  405.      *
  406.      * @return string 
  407.      */
  408.     public function getPrompt({
  409.         return $this->_prompt;
  410.     }
  411.  
  412.     /**
  413.      * Set Prompt
  414.      *
  415.      * @param    string    $value 
  416.      */
  417.     public function setPrompt($value ''{
  418.         $this->_prompt = $value;
  419.     }
  420.     
  421.     /**
  422.      * Get parent
  423.      *
  424.      * @return PHPExcel_Cell 
  425.      */
  426.     public function getParent({
  427.         return $this->_parent;
  428.     }
  429.     
  430.     /**
  431.      * Set Parent
  432.      *
  433.      * @param    PHPExcel_Cell    $value 
  434.      */
  435.     public function setParent($value null{
  436.         $this->_parent = $value;
  437.     }
  438.     
  439.     /**
  440.      * Get hash code
  441.      *
  442.      * @return string    Hash code
  443.      */    
  444.     public function getHashCode({
  445.         return md5(
  446.               $this->_formula1
  447.             . $this->_formula2
  448.             . $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE
  449.             . $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP
  450.             . $this->_operator
  451.             . ($this->_allowBlank ? 't' 'f')
  452.             . ($this->_showDropDown ? 't' 'f')
  453.             . ($this->_showInputMessage ? 't' 'f')
  454.             . ($this->_showErrorMessage ? 't' 'f')
  455.             . $this->_errorTitle
  456.             . $this->_error
  457.             . $this->_promptTitle
  458.             . $this->_prompt
  459.             . $this->_parent->getCoordinate()
  460.             . __CLASS__
  461.         );
  462.     }
  463.     
  464.     /**
  465.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  466.      */
  467.     public function __clone({
  468.         $vars get_object_vars($this);
  469.         foreach ($vars as $key => $value{
  470.             if (is_object($value)) {
  471.                 $this->$key clone $value;
  472.             else {
  473.                 $this->$key $value;
  474.             }
  475.         }
  476.     }
  477.         
  478. /*
  479. <complexType name="CT_DataValidation">
  480. <sequence>
  481. <element name="formula1" type="ST_Formula" minOccurs="0" maxOccurs="1"/>
  482. <element name="formula2" type="ST_Formula" minOccurs="0" maxOccurs="1"/>
  483. </sequence>
  484. <attribute name="type" type="ST_DataValidationType" use="optional" default="none"/>
  485. <attribute name="errorStyle" type="ST_DataValidationErrorStyle" use="optional" default="stop"/>
  486. <attribute name="imeMode" type="ST_DataValidationImeMode" use="optional" default="noControl"/>
  487. <attribute name="operator" type="ST_DataValidationOperator" use="optional" default="between"/>
  488. <attribute name="allowBlank" type="xsd:boolean" use="optional" default="false"/>
  489. <attribute name="showDropDown" type="xsd:boolean" use="optional" default="false"/>
  490. <attribute name="showInputMessage" type="xsd:boolean" use="optional" default="false"/>
  491. <attribute name="showErrorMessage" type="xsd:boolean" use="optional" default="false"/>
  492. <attribute name="errorTitle" type="ST_Xstring" use="optional"/>
  493. <attribute name="error" type="ST_Xstring" use="optional"/>
  494. <attribute name="promptTitle" type="ST_Xstring" use="optional"/>
  495. <attribute name="prompt" type="ST_Xstring" use="optional"/>
  496. <attribute name="sqref" type="ST_Sqref" use="required"/>
  497. </complexType>
  498. */
  499. }

Documentation generated on Mon, 05 Jan 2009 20:36:46 +0100 by phpDocumentor 1.4.1