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 - 2010 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 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.7.2, 2010-01-11
  26.  */
  27.  
  28.  
  29. /**
  30.  * PHPExcel_Cell_DataValidation
  31.  *
  32.  * @category   PHPExcel
  33.  * @package    PHPExcel_Cell
  34.  * @copyright  Copyright (c) 2006 - 2010 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.      * @return PHPExcel_Cell_DataValidation 
  201.      */
  202.     public function setFormula1($value ''{
  203.         $this->_formula1 = $value;
  204.         return $this;
  205.     }
  206.  
  207.     /**
  208.      * Get Formula 2
  209.      *
  210.      * @return string 
  211.      */
  212.     public function getFormula2({
  213.         return $this->_formula2;
  214.     }
  215.  
  216.     /**
  217.      * Set Formula 2
  218.      *
  219.      * @param    string    $value 
  220.      * @return PHPExcel_Cell_DataValidation 
  221.      */
  222.     public function setFormula2($value ''{
  223.         $this->_formula2 = $value;
  224.         return $this;
  225.     }
  226.     
  227.     /**
  228.      * Get Type
  229.      *
  230.      * @return string 
  231.      */
  232.     public function getType({
  233.         return $this->_type;
  234.     }
  235.  
  236.     /**
  237.      * Set Type
  238.      *
  239.      * @param    string    $value 
  240.      * @return PHPExcel_Cell_DataValidation 
  241.      */
  242.     public function setType($value PHPExcel_Cell_DataValidation::TYPE_NONE{
  243.         $this->_type = $value;
  244.         return $this;
  245.     }
  246.  
  247.     /**
  248.      * Get Error style
  249.      *
  250.      * @return string 
  251.      */
  252.     public function getErrorStyle({
  253.         return $this->_errorStyle;
  254.     }
  255.  
  256.     /**
  257.      * Set Error style
  258.      *
  259.      * @param    string    $value 
  260.      * @return PHPExcel_Cell_DataValidation 
  261.      */
  262.     public function setErrorStyle($value PHPExcel_Cell_DataValidation::STYLE_STOP{
  263.         $this->_errorStyle = $value;
  264.         return $this;
  265.     }
  266.  
  267.     /**
  268.      * Get Operator
  269.      *
  270.      * @return string 
  271.      */
  272.     public function getOperator({
  273.         return $this->_operator;
  274.     }
  275.  
  276.     /**
  277.      * Set Operator
  278.      *
  279.      * @param    string    $value 
  280.      * @return PHPExcel_Cell_DataValidation 
  281.      */
  282.     public function setOperator($value ''{
  283.         $this->_operator = $value;
  284.         return $this;
  285.     }
  286.  
  287.     /**
  288.      * Get Allow Blank
  289.      *
  290.      * @return boolean 
  291.      */
  292.     public function getAllowBlank({
  293.         return $this->_allowBlank;
  294.     }
  295.  
  296.     /**
  297.      * Set Allow Blank
  298.      *
  299.      * @param    boolean    $value 
  300.      * @return PHPExcel_Cell_DataValidation 
  301.      */
  302.     public function setAllowBlank($value false{
  303.         $this->_allowBlank = $value;
  304.         return $this;
  305.     }
  306.  
  307.     /**
  308.      * Get Show DropDown
  309.      *
  310.      * @return boolean 
  311.      */
  312.     public function getShowDropDown({
  313.         return $this->_showDropDown;
  314.     }
  315.  
  316.     /**
  317.      * Set Show DropDown
  318.      *
  319.      * @param    boolean    $value 
  320.      * @return PHPExcel_Cell_DataValidation 
  321.      */
  322.     public function setShowDropDown($value false{
  323.         $this->_showDropDown = $value;
  324.         return $this;
  325.     }
  326.  
  327.     /**
  328.      * Get Show InputMessage
  329.      *
  330.      * @return boolean 
  331.      */
  332.     public function getShowInputMessage({
  333.         return $this->_showInputMessage;
  334.     }
  335.  
  336.     /**
  337.      * Set Show InputMessage
  338.      *
  339.      * @param    boolean    $value 
  340.      * @return PHPExcel_Cell_DataValidation 
  341.      */
  342.     public function setShowInputMessage($value false{
  343.         $this->_showInputMessage = $value;
  344.         return $this;
  345.     }
  346.  
  347.     /**
  348.      * Get Show ErrorMessage
  349.      *
  350.      * @return boolean 
  351.      */
  352.     public function getShowErrorMessage({
  353.         return $this->_showErrorMessage;
  354.     }
  355.  
  356.     /**
  357.      * Set Show ErrorMessage
  358.      *
  359.      * @param    boolean    $value 
  360.      * @return PHPExcel_Cell_DataValidation 
  361.      */
  362.     public function setShowErrorMessage($value false{
  363.         $this->_showErrorMessage = $value;
  364.         return $this;
  365.     }
  366.  
  367.     /**
  368.      * Get Error title
  369.      *
  370.      * @return string 
  371.      */
  372.     public function getErrorTitle({
  373.         return $this->_errorTitle;
  374.     }
  375.  
  376.     /**
  377.      * Set Error title
  378.      *
  379.      * @param    string    $value 
  380.      * @return PHPExcel_Cell_DataValidation 
  381.      */
  382.     public function setErrorTitle($value ''{
  383.         $this->_errorTitle = $value;
  384.         return $this;
  385.     }
  386.  
  387.     /**
  388.      * Get Error
  389.      *
  390.      * @return string 
  391.      */
  392.     public function getError({
  393.         return $this->_error;
  394.     }
  395.  
  396.     /**
  397.      * Set Error
  398.      *
  399.      * @param    string    $value 
  400.      * @return PHPExcel_Cell_DataValidation 
  401.      */
  402.     public function setError($value ''{
  403.         $this->_error = $value;
  404.         return $this;
  405.     }
  406.  
  407.     /**
  408.      * Get Prompt title
  409.      *
  410.      * @return string 
  411.      */
  412.     public function getPromptTitle({
  413.         return $this->_promptTitle;
  414.     }
  415.  
  416.     /**
  417.      * Set Prompt title
  418.      *
  419.      * @param    string    $value 
  420.      * @return PHPExcel_Cell_DataValidation 
  421.      */
  422.     public function setPromptTitle($value ''{
  423.         $this->_promptTitle = $value;
  424.         return $this;
  425.     }
  426.  
  427.     /**
  428.      * Get Prompt
  429.      *
  430.      * @return string 
  431.      */
  432.     public function getPrompt({
  433.         return $this->_prompt;
  434.     }
  435.  
  436.     /**
  437.      * Set Prompt
  438.      *
  439.      * @param    string    $value 
  440.      * @return PHPExcel_Cell_DataValidation 
  441.      */
  442.     public function setPrompt($value ''{
  443.         $this->_prompt = $value;
  444.         return $this;
  445.     }
  446.     
  447.     /**
  448.      * Get parent
  449.      *
  450.      * @return PHPExcel_Cell 
  451.      */
  452.     public function getParent({
  453.         return $this->_parent;
  454.     }
  455.     
  456.     /**
  457.      * Set Parent
  458.      *
  459.      * @param    PHPExcel_Cell    $value 
  460.      * @return PHPExcel_Cell_DataValidation 
  461.      */
  462.     public function setParent($value null{
  463.         $this->_parent = $value;
  464.         return $this;
  465.     }
  466.     
  467.     /**
  468.      * Get hash code
  469.      *
  470.      * @return string    Hash code
  471.      */    
  472.     public function getHashCode({
  473.         return md5(
  474.               $this->_formula1
  475.             . $this->_formula2
  476.             . $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE
  477.             . $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP
  478.             . $this->_operator
  479.             . ($this->_allowBlank ? 't' 'f')
  480.             . ($this->_showDropDown ? 't' 'f')
  481.             . ($this->_showInputMessage ? 't' 'f')
  482.             . ($this->_showErrorMessage ? 't' 'f')
  483.             . $this->_errorTitle
  484.             . $this->_error
  485.             . $this->_promptTitle
  486.             . $this->_prompt
  487.             . $this->_parent->getCoordinate()
  488.             . __CLASS__
  489.         );
  490.     }
  491.     
  492.     /**
  493.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  494.      */
  495.     public function __clone({
  496.         // unbind parent
  497.         $this->setParent(null);
  498.         
  499.         $vars get_object_vars($this);
  500.         foreach ($vars as $key => $value{
  501.             if (is_object($value&& $key != '_parent'{
  502.                 $this->$key clone $value;
  503.             else {
  504.                 $this->$key $value;
  505.             }
  506.         }
  507.     }
  508. }

Documentation generated on Mon, 11 Jan 2010 08:07:38 +0100 by phpDocumentor 1.4.1