2010-08-26 19:14:53 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* PHPExcel
|
|
|
|
*
|
2015-05-02 22:50:37 +00:00
|
|
|
* Copyright (c) 2006 - 2015 PHPExcel
|
2010-08-26 19:14:53 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
* @category PHPExcel
|
|
|
|
* @package PHPExcel_Style
|
2015-05-02 22:50:37 +00:00
|
|
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
2015-05-04 22:36:20 +00:00
|
|
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
2010-08-26 19:14:53 +00:00
|
|
|
* @version ##VERSION##, ##DATE##
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PHPExcel_Style_Conditional
|
|
|
|
*
|
|
|
|
* @category PHPExcel
|
|
|
|
* @package PHPExcel_Style
|
2015-05-02 22:50:37 +00:00
|
|
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
2010-08-26 19:14:53 +00:00
|
|
|
*/
|
|
|
|
class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
|
|
|
{
|
2015-05-04 22:36:20 +00:00
|
|
|
/* Condition types */
|
|
|
|
const CONDITION_NONE = 'none';
|
|
|
|
const CONDITION_CELLIS = 'cellIs';
|
|
|
|
const CONDITION_CONTAINSTEXT = 'containsText';
|
|
|
|
const CONDITION_EXPRESSION = 'expression';
|
2010-08-26 19:14:53 +00:00
|
|
|
|
2015-05-04 22:36:20 +00:00
|
|
|
/* Operator types */
|
|
|
|
const OPERATOR_NONE = '';
|
|
|
|
const OPERATOR_BEGINSWITH = 'beginsWith';
|
|
|
|
const OPERATOR_ENDSWITH = 'endsWith';
|
|
|
|
const OPERATOR_EQUAL = 'equal';
|
|
|
|
const OPERATOR_GREATERTHAN = 'greaterThan';
|
|
|
|
const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual';
|
|
|
|
const OPERATOR_LESSTHAN = 'lessThan';
|
|
|
|
const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual';
|
|
|
|
const OPERATOR_NOTEQUAL = 'notEqual';
|
|
|
|
const OPERATOR_CONTAINSTEXT = 'containsText';
|
|
|
|
const OPERATOR_NOTCONTAINS = 'notContains';
|
|
|
|
const OPERATOR_BETWEEN = 'between';
|
2010-08-26 19:14:53 +00:00
|
|
|
|
2015-05-04 22:36:20 +00:00
|
|
|
/**
|
|
|
|
* Condition type
|
|
|
|
*
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
private $conditionType;
|
2010-08-26 19:14:53 +00:00
|
|
|
|
2015-05-04 22:36:20 +00:00
|
|
|
/**
|
|
|
|
* Operator type
|
|
|
|
*
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
private $operatorType;
|
2010-08-26 19:14:53 +00:00
|
|
|
|
2015-05-04 22:36:20 +00:00
|
|
|
/**
|
|
|
|
* Text
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $text;
|
2010-08-26 19:14:53 +00:00
|
|
|
|
2015-05-04 22:36:20 +00:00
|
|
|
/**
|
|
|
|
* Condition
|
|
|
|
*
|
|
|
|
* @var string[]
|
|
|
|
*/
|
|
|
|
private $condition = array();
|
2010-08-26 19:14:53 +00:00
|
|
|
|
2015-05-04 22:36:20 +00:00
|
|
|
/**
|
|
|
|
* Style
|
|
|
|
*
|
|
|
|
* @var PHPExcel_Style
|
|
|
|
*/
|
|
|
|
private $style;
|
2010-08-26 19:14:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new PHPExcel_Style_Conditional
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
2015-05-04 22:36:20 +00:00
|
|
|
// Initialise values
|
|
|
|
$this->conditionType = PHPExcel_Style_Conditional::CONDITION_NONE;
|
|
|
|
$this->operatorType = PHPExcel_Style_Conditional::OPERATOR_NONE;
|
|
|
|
$this->text = null;
|
|
|
|
$this->condition = array();
|
|
|
|
$this->style = new PHPExcel_Style(false, true);
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Condition type
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2015-05-04 22:36:20 +00:00
|
|
|
public function getConditionType()
|
|
|
|
{
|
|
|
|
return $this->conditionType;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set Condition type
|
|
|
|
*
|
2015-05-04 22:36:20 +00:00
|
|
|
* @param string $pValue PHPExcel_Style_Conditional condition type
|
2010-08-26 19:14:53 +00:00
|
|
|
* @return PHPExcel_Style_Conditional
|
|
|
|
*/
|
2015-05-04 22:36:20 +00:00
|
|
|
public function setConditionType($pValue = PHPExcel_Style_Conditional::CONDITION_NONE)
|
|
|
|
{
|
|
|
|
$this->conditionType = $pValue;
|
|
|
|
return $this;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Operator type
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2015-05-04 22:36:20 +00:00
|
|
|
public function getOperatorType()
|
|
|
|
{
|
|
|
|
return $this->operatorType;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set Operator type
|
|
|
|
*
|
2015-05-04 22:36:20 +00:00
|
|
|
* @param string $pValue PHPExcel_Style_Conditional operator type
|
2010-08-26 19:14:53 +00:00
|
|
|
* @return PHPExcel_Style_Conditional
|
|
|
|
*/
|
2015-05-04 22:36:20 +00:00
|
|
|
public function setOperatorType($pValue = PHPExcel_Style_Conditional::OPERATOR_NONE)
|
|
|
|
{
|
|
|
|
$this->operatorType = $pValue;
|
|
|
|
return $this;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get text
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2015-05-04 22:36:20 +00:00
|
|
|
public function getText()
|
|
|
|
{
|
|
|
|
return $this->text;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set text
|
|
|
|
*
|
|
|
|
* @param string $value
|
|
|
|
* @return PHPExcel_Style_Conditional
|
|
|
|
*/
|
2015-05-04 22:36:20 +00:00
|
|
|
public function setText($value = null)
|
|
|
|
{
|
|
|
|
$this->text = $value;
|
|
|
|
return $this;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Condition
|
|
|
|
*
|
|
|
|
* @deprecated Deprecated, use getConditions instead
|
|
|
|
* @return string
|
|
|
|
*/
|
2015-05-04 22:36:20 +00:00
|
|
|
public function getCondition()
|
|
|
|
{
|
|
|
|
if (isset($this->condition[0])) {
|
|
|
|
return $this->condition[0];
|
|
|
|
}
|
2010-08-26 19:14:53 +00:00
|
|
|
|
2015-05-04 22:36:20 +00:00
|
|
|
return '';
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set Condition
|
|
|
|
*
|
|
|
|
* @deprecated Deprecated, use setConditions instead
|
2015-05-04 22:36:20 +00:00
|
|
|
* @param string $pValue Condition
|
2010-08-26 19:14:53 +00:00
|
|
|
* @return PHPExcel_Style_Conditional
|
|
|
|
*/
|
2015-05-04 22:36:20 +00:00
|
|
|
public function setCondition($pValue = '')
|
|
|
|
{
|
|
|
|
if (!is_array($pValue)) {
|
|
|
|
$pValue = array($pValue);
|
|
|
|
}
|
2010-08-26 19:14:53 +00:00
|
|
|
|
2015-05-04 22:36:20 +00:00
|
|
|
return $this->setConditions($pValue);
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Conditions
|
|
|
|
*
|
|
|
|
* @return string[]
|
|
|
|
*/
|
2015-05-04 22:36:20 +00:00
|
|
|
public function getConditions()
|
|
|
|
{
|
|
|
|
return $this->condition;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set Conditions
|
|
|
|
*
|
2015-05-04 22:36:20 +00:00
|
|
|
* @param string[] $pValue Condition
|
2010-08-26 19:14:53 +00:00
|
|
|
* @return PHPExcel_Style_Conditional
|
|
|
|
*/
|
2015-05-04 22:36:20 +00:00
|
|
|
public function setConditions($pValue)
|
|
|
|
{
|
|
|
|
if (!is_array($pValue)) {
|
|
|
|
$pValue = array($pValue);
|
|
|
|
}
|
|
|
|
$this->condition = $pValue;
|
|
|
|
return $this;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add Condition
|
|
|
|
*
|
2015-05-04 22:36:20 +00:00
|
|
|
* @param string $pValue Condition
|
2010-08-26 19:14:53 +00:00
|
|
|
* @return PHPExcel_Style_Conditional
|
|
|
|
*/
|
2015-05-04 22:36:20 +00:00
|
|
|
public function addCondition($pValue = '')
|
|
|
|
{
|
|
|
|
$this->condition[] = $pValue;
|
|
|
|
return $this;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Style
|
|
|
|
*
|
|
|
|
* @return PHPExcel_Style
|
|
|
|
*/
|
2015-05-04 22:36:20 +00:00
|
|
|
public function getStyle()
|
|
|
|
{
|
|
|
|
return $this->style;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set Style
|
|
|
|
*
|
2015-05-04 22:36:20 +00:00
|
|
|
* @param PHPExcel_Style $pValue
|
|
|
|
* @throws PHPExcel_Exception
|
2010-08-26 19:14:53 +00:00
|
|
|
* @return PHPExcel_Style_Conditional
|
|
|
|
*/
|
2015-05-04 22:36:20 +00:00
|
|
|
public function setStyle(PHPExcel_Style $pValue = null)
|
|
|
|
{
|
|
|
|
$this->style = $pValue;
|
|
|
|
return $this;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
2015-05-04 22:36:20 +00:00
|
|
|
/**
|
|
|
|
* Get hash code
|
|
|
|
*
|
|
|
|
* @return string Hash code
|
|
|
|
*/
|
|
|
|
public function getHashCode()
|
|
|
|
{
|
|
|
|
return md5(
|
|
|
|
$this->conditionType .
|
|
|
|
$this->operatorType .
|
|
|
|
implode(';', $this->condition) .
|
|
|
|
$this->style->getHashCode() .
|
|
|
|
__CLASS__
|
|
|
|
);
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
2015-05-04 22:36:20 +00:00
|
|
|
/**
|
|
|
|
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
|
|
|
*/
|
|
|
|
public function __clone()
|
|
|
|
{
|
|
|
|
$vars = get_object_vars($this);
|
|
|
|
foreach ($vars as $key => $value) {
|
|
|
|
if (is_object($value)) {
|
|
|
|
$this->$key = clone $value;
|
|
|
|
} else {
|
|
|
|
$this->$key = $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|