ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
PHPExcel_Style_Color Class Reference
+ Inheritance diagram for PHPExcel_Style_Color:
+ Collaboration diagram for PHPExcel_Style_Color:

Public Member Functions

 __construct ($pARGB=PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor=false)
 Create a new PHPExcel_Style_Color.
 bindParent ($parent, $parentPropertyName)
 Bind parent.
 getIsSupervisor ()
 Is this a supervisor or a real style component?
 getSharedComponent ()
 Get the shared style component for the currently active cell in currently active sheet.
 getActiveSheet ()
 Get the currently active sheet.
 getSelectedCells ()
 Get the currently active cell coordinate in currently active sheet.
 getActiveCell ()
 Get the currently active cell coordinate in currently active sheet.
 getStyleArray ($array)
 Build style array from subcomponents.
 applyFromArray ($pStyles=null)
 Apply styles from array.
 getARGB ()
 Get ARGB.
 setARGB ($pValue=PHPExcel_Style_Color::COLOR_BLACK)
 Set ARGB.
 getRGB ()
 Get RGB.
 setRGB ($pValue= '000000')
 Set RGB.
 getHashCode ()
 Get hash code.
 __clone ()
 Implement PHP __clone to create a deep clone, not just a shallow copy.

Static Public Member Functions

static getRed ($RGB, $hex=true)
static getGreen ($RGB, $hex=true)
static getBlue ($RGB, $hex=true)
static changeBrightness ($hex, $adjustPercentage)
 Adjust the brightness of a color.
static indexedColor ($pIndex, $background=false)
 Get indexed color.

Data Fields

const COLOR_BLACK = 'FF000000'
const COLOR_WHITE = 'FFFFFFFF'
const COLOR_RED = 'FFFF0000'
const COLOR_DARKRED = 'FF800000'
const COLOR_BLUE = 'FF0000FF'
const COLOR_DARKBLUE = 'FF000080'
const COLOR_GREEN = 'FF00FF00'
const COLOR_DARKGREEN = 'FF008000'
const COLOR_YELLOW = 'FFFFFF00'
const COLOR_DARKYELLOW = 'FF808000'

Static Private Member Functions

static _getColourComponent ($RGB, $offset, $hex=true)

Private Attributes

 $_argb
 $_isSupervisor
 $_parent
 $_parentPropertyName

Static Private Attributes

static $_indexedColors

Detailed Description

Definition at line 36 of file Color.php.

Constructor & Destructor Documentation

PHPExcel_Style_Color::__construct (   $pARGB = PHPExcel_Style_Color::COLOR_BLACK,
  $isSupervisor = false 
)

Create a new PHPExcel_Style_Color.

Parameters
string$pARGB

Definition at line 90 of file Color.php.

{
// Supervisor?
$this->_isSupervisor = $isSupervisor;
// Initialise values
$this->_argb = $pARGB;
}

Member Function Documentation

PHPExcel_Style_Color::__clone ( )

Implement PHP __clone to create a deep clone, not just a shallow copy.

Definition at line 466 of file Color.php.

{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if ((is_object($value)) && ($key != '_parent')) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
static PHPExcel_Style_Color::_getColourComponent (   $RGB,
  $offset,
  $hex = true 
)
staticprivate

Definition at line 294 of file Color.php.

Referenced by getBlue(), getGreen(), and getRed().

{
$colour = substr($RGB,$offset,2);
if (!$hex)
$colour = hexdec($colour);
return $colour;
}

+ Here is the caller graph for this function:

PHPExcel_Style_Color::applyFromArray (   $pStyles = null)

Apply styles from array.

$objPHPExcel->getActiveSheet()->getStyle('B2')->getFont()->getColor()->applyFromArray( array('rgb' => '808080') );

Parameters
array$pStylesArray containing style information
Exceptions
Exception
Returns
PHPExcel_Style_Color

Definition at line 214 of file Color.php.

References getActiveSheet(), getSelectedCells(), getStyleArray(), setARGB(), and setRGB().

{
if (is_array($pStyles)) {
if ($this->_isSupervisor) {
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
} else {
if (array_key_exists('rgb', $pStyles)) {
$this->setRGB($pStyles['rgb']);
}
if (array_key_exists('argb', $pStyles)) {
$this->setARGB($pStyles['argb']);
}
}
} else {
throw new Exception("Invalid style array passed.");
}
return $this;
}

+ Here is the call graph for this function:

PHPExcel_Style_Color::bindParent (   $parent,
  $parentPropertyName 
)

Bind parent.

Only used for supervisor

Parameters
mixed$parent
string$parentPropertyName
Returns
PHPExcel_Style_Color

Definition at line 106 of file Color.php.

{
$this->_parent = $parent;
$this->_parentPropertyName = $parentPropertyName;
return $this;
}
static PHPExcel_Style_Color::changeBrightness (   $hex,
  $adjustPercentage 
)
static

Adjust the brightness of a color.

Parameters
string$hexThe colour as an RGB value (e.g. FF00CCCC or CCDDEE
float$adjustPercentageThe percentage by which to adjust the colour as a float from -1 to 1
Returns
string The adjusted colour as an RGB value (e.g. FF00CCCC or CCDDEE

Definition at line 332 of file Color.php.

References getBlue(), getGreen(), and getRed().

Referenced by PHPExcel_Reader_Excel2007\_readColor().

{
$red = self::getRed($hex,false);
$green = self::getGreen($hex,false);
$blue = self::getBlue($hex,false);
if ($adjustPercentage > 0) {
$red += (255 - $red) * $adjustPercentage;
$green += (255 - $green) * $adjustPercentage;
$blue += (255 - $blue) * $adjustPercentage;
} else {
$red += $red * $adjustPercentage;
$green += $green * $adjustPercentage;
$blue += $blue * $adjustPercentage;
}
if ($red < 0) $red = 0;
elseif ($red > 255) $red = 255;
if ($green < 0) $green = 0;
elseif ($green > 255) $green = 255;
if ($blue < 0) $blue = 0;
elseif ($blue > 255) $blue = 255;
return strtoupper( str_pad(dechex($red), 2, '0', 0) .
str_pad(dechex($green), 2, '0', 0) .
str_pad(dechex($blue), 2, '0', 0)
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_Style_Color::getActiveCell ( )

Get the currently active cell coordinate in currently active sheet.

Only used for supervisor

Returns
string E.g. 'A1'

Definition at line 173 of file Color.php.

References getActiveSheet().

{
return $this->getActiveSheet()->getActiveCell();
}

+ Here is the call graph for this function:

PHPExcel_Style_Color::getActiveSheet ( )

Get the currently active sheet.

Only used for supervisor

Returns
PHPExcel_Worksheet

Definition at line 151 of file Color.php.

Referenced by applyFromArray(), getActiveCell(), getSelectedCells(), setARGB(), and setRGB().

{
return $this->_parent->getActiveSheet();
}

+ Here is the caller graph for this function:

PHPExcel_Style_Color::getARGB ( )

Get ARGB.

Returns
string

Definition at line 237 of file Color.php.

References $_argb, and getSharedComponent().

{
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getARGB();
}
return $this->_argb;
}

+ Here is the call graph for this function:

static PHPExcel_Style_Color::getBlue (   $RGB,
  $hex = true 
)
static

Definition at line 317 of file Color.php.

References _getColourComponent().

Referenced by changeBrightness().

{
if (strlen($RGB) == 8) {
return self::_getColourComponent($RGB,6,$hex);
} elseif (strlen($RGB) == 6) {
return self::_getColourComponent($RGB,4,$hex);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Style_Color::getGreen (   $RGB,
  $hex = true 
)
static

Definition at line 309 of file Color.php.

References _getColourComponent().

Referenced by changeBrightness().

{
if (strlen($RGB) == 8) {
return self::_getColourComponent($RGB,4,$hex);
} elseif (strlen($RGB) == 6) {
return self::_getColourComponent($RGB,2,$hex);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_Style_Color::getHashCode ( )

Get hash code.

Returns
string Hash code

Implements PHPExcel_IComparable.

Definition at line 453 of file Color.php.

References getSharedComponent().

{
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
}
return md5(
$this->_argb
. __CLASS__
);
}

+ Here is the call graph for this function:

PHPExcel_Style_Color::getIsSupervisor ( )

Is this a supervisor or a real style component?

Returns
boolean

Definition at line 118 of file Color.php.

References $_isSupervisor.

{
}
static PHPExcel_Style_Color::getRed (   $RGB,
  $hex = true 
)
static

Definition at line 301 of file Color.php.

References _getColourComponent().

Referenced by changeBrightness().

{
if (strlen($RGB) == 8) {
return self::_getColourComponent($RGB,2,$hex);
} elseif (strlen($RGB) == 6) {
return self::_getColourComponent($RGB,0,$hex);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_Style_Color::getRGB ( )

Get RGB.

Returns
string

Definition at line 268 of file Color.php.

References getSharedComponent().

{
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getRGB();
}
return substr($this->_argb, 2);
}

+ Here is the call graph for this function:

PHPExcel_Style_Color::getSelectedCells ( )

Get the currently active cell coordinate in currently active sheet.

Only used for supervisor

Returns
string E.g. 'A1'

Definition at line 162 of file Color.php.

References getActiveSheet().

Referenced by applyFromArray(), setARGB(), and setRGB().

{
return $this->getActiveSheet()->getSelectedCells();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_Style_Color::getSharedComponent ( )

Get the shared style component for the currently active cell in currently active sheet.

Only used for style supervisor

Returns
PHPExcel_Style_Color

Definition at line 129 of file Color.php.

Referenced by getARGB(), getHashCode(), and getRGB().

{
switch ($this->_parentPropertyName) {
case '_endColor':
return $this->_parent->getSharedComponent()->getEndColor();
break;
case '_color':
return $this->_parent->getSharedComponent()->getColor();
break;
case '_startColor':
return $this->_parent->getSharedComponent()->getStartColor();
break;
}
}

+ Here is the caller graph for this function:

PHPExcel_Style_Color::getStyleArray (   $array)

Build style array from subcomponents.

Parameters
array$array
Returns
array

Definition at line 184 of file Color.php.

Referenced by applyFromArray(), setARGB(), and setRGB().

{
switch ($this->_parentPropertyName) {
case '_endColor':
$key = 'endcolor';
break;
case '_color':
$key = 'color';
break;
case '_startColor':
$key = 'startcolor';
break;
}
return $this->_parent->getStyleArray(array($key => $array));
}

+ Here is the caller graph for this function:

static PHPExcel_Style_Color::indexedColor (   $pIndex,
  $background = false 
)
static

Get indexed color.

Parameters
int$pIndex
Returns
PHPExcel_Style_Color

Definition at line 365 of file Color.php.

Referenced by PHPExcel_Reader_Excel2007\_readColor().

{
// Clean parameter
$pIndex = intval($pIndex);
// Indexed colors
if (is_null(self::$_indexedColors)) {
self::$_indexedColors = array();
self::$_indexedColors[] = '00000000';
self::$_indexedColors[] = '00FFFFFF';
self::$_indexedColors[] = '00FF0000';
self::$_indexedColors[] = '0000FF00';
self::$_indexedColors[] = '000000FF';
self::$_indexedColors[] = '00FFFF00';
self::$_indexedColors[] = '00FF00FF';
self::$_indexedColors[] = '0000FFFF';
self::$_indexedColors[] = '00000000';
self::$_indexedColors[] = '00FFFFFF';
self::$_indexedColors[] = '00FF0000';
self::$_indexedColors[] = '0000FF00';
self::$_indexedColors[] = '000000FF';
self::$_indexedColors[] = '00FFFF00';
self::$_indexedColors[] = '00FF00FF';
self::$_indexedColors[] = '0000FFFF';
self::$_indexedColors[] = '00800000';
self::$_indexedColors[] = '00008000';
self::$_indexedColors[] = '00000080';
self::$_indexedColors[] = '00808000';
self::$_indexedColors[] = '00800080';
self::$_indexedColors[] = '00008080';
self::$_indexedColors[] = '00C0C0C0';
self::$_indexedColors[] = '00808080';
self::$_indexedColors[] = '009999FF';
self::$_indexedColors[] = '00993366';
self::$_indexedColors[] = '00FFFFCC';
self::$_indexedColors[] = '00CCFFFF';
self::$_indexedColors[] = '00660066';
self::$_indexedColors[] = '00FF8080';
self::$_indexedColors[] = '000066CC';
self::$_indexedColors[] = '00CCCCFF';
self::$_indexedColors[] = '00000080';
self::$_indexedColors[] = '00FF00FF';
self::$_indexedColors[] = '00FFFF00';
self::$_indexedColors[] = '0000FFFF';
self::$_indexedColors[] = '00800080';
self::$_indexedColors[] = '00800000';
self::$_indexedColors[] = '00008080';
self::$_indexedColors[] = '000000FF';
self::$_indexedColors[] = '0000CCFF';
self::$_indexedColors[] = '00CCFFFF';
self::$_indexedColors[] = '00CCFFCC';
self::$_indexedColors[] = '00FFFF99';
self::$_indexedColors[] = '0099CCFF';
self::$_indexedColors[] = '00FF99CC';
self::$_indexedColors[] = '00CC99FF';
self::$_indexedColors[] = '00FFCC99';
self::$_indexedColors[] = '003366FF';
self::$_indexedColors[] = '0033CCCC';
self::$_indexedColors[] = '0099CC00';
self::$_indexedColors[] = '00FFCC00';
self::$_indexedColors[] = '00FF9900';
self::$_indexedColors[] = '00FF6600';
self::$_indexedColors[] = '00666699';
self::$_indexedColors[] = '00969696';
self::$_indexedColors[] = '00003366';
self::$_indexedColors[] = '00339966';
self::$_indexedColors[] = '00003300';
self::$_indexedColors[] = '00333300';
self::$_indexedColors[] = '00993300';
self::$_indexedColors[] = '00993366';
self::$_indexedColors[] = '00333399';
self::$_indexedColors[] = '00333333';
}
if (array_key_exists($pIndex, self::$_indexedColors)) {
return new PHPExcel_Style_Color(self::$_indexedColors[$pIndex]);
}
if ($background) {
return new PHPExcel_Style_Color('FFFFFFFF');
}
return new PHPExcel_Style_Color('FF000000');
}

+ Here is the caller graph for this function:

PHPExcel_Style_Color::setARGB (   $pValue = PHPExcel_Style_Color::COLOR_BLACK)

Set ARGB.

Parameters
string$pValue
Returns
PHPExcel_Style_Color

Definition at line 250 of file Color.php.

References COLOR_BLACK, getActiveSheet(), getSelectedCells(), and getStyleArray().

Referenced by applyFromArray().

{
if ($pValue == '') {
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('argb' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->_argb = $pValue;
}
return $this;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_Style_Color::setRGB (   $pValue = '000000')

Set RGB.

Parameters
string$pValue
Returns
PHPExcel_Style_Color

Definition at line 281 of file Color.php.

References getActiveSheet(), getSelectedCells(), and getStyleArray().

Referenced by applyFromArray().

{
if ($pValue == '') {
$pValue = '000000';
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('argb' => 'FF' . $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->_argb = 'FF' . $pValue;
}
return $this;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

PHPExcel_Style_Color::$_argb
private

Definition at line 62 of file Color.php.

Referenced by getARGB().

PHPExcel_Style_Color::$_indexedColors
staticprivate

Definition at line 55 of file Color.php.

PHPExcel_Style_Color::$_isSupervisor
private

Definition at line 69 of file Color.php.

Referenced by getIsSupervisor().

PHPExcel_Style_Color::$_parent
private

Definition at line 76 of file Color.php.

PHPExcel_Style_Color::$_parentPropertyName
private

Definition at line 83 of file Color.php.

const PHPExcel_Style_Color::COLOR_BLACK = 'FF000000'
const PHPExcel_Style_Color::COLOR_BLUE = 'FF0000FF'

Definition at line 43 of file Color.php.

const PHPExcel_Style_Color::COLOR_DARKBLUE = 'FF000080'

Definition at line 44 of file Color.php.

const PHPExcel_Style_Color::COLOR_DARKGREEN = 'FF008000'

Definition at line 46 of file Color.php.

const PHPExcel_Style_Color::COLOR_DARKRED = 'FF800000'

Definition at line 42 of file Color.php.

const PHPExcel_Style_Color::COLOR_DARKYELLOW = 'FF808000'

Definition at line 48 of file Color.php.

const PHPExcel_Style_Color::COLOR_GREEN = 'FF00FF00'

Definition at line 45 of file Color.php.

const PHPExcel_Style_Color::COLOR_RED = 'FFFF0000'

Definition at line 41 of file Color.php.

const PHPExcel_Style_Color::COLOR_WHITE = 'FFFFFFFF'

Definition at line 40 of file Color.php.

Referenced by PHPExcel_Style_Fill\__construct().

const PHPExcel_Style_Color::COLOR_YELLOW = 'FFFFFF00'

Definition at line 47 of file Color.php.


The documentation for this class was generated from the following file: