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

Public Member Functions

 __construct ($isSupervisor=false)
 Create a new PHPExcel_Style_Alignment.
 bindParent ($parent)
 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.
 getHorizontal ()
 Get Horizontal.
 setHorizontal ($pValue=PHPExcel_Style_Alignment::HORIZONTAL_GENERAL)
 Set Horizontal.
 getVertical ()
 Get Vertical.
 setVertical ($pValue=PHPExcel_Style_Alignment::VERTICAL_BOTTOM)
 Set Vertical.
 getTextRotation ()
 Get TextRotation.
 setTextRotation ($pValue=0)
 Set TextRotation.
 getWrapText ()
 Get Wrap Text.
 setWrapText ($pValue=false)
 Set Wrap Text.
 getShrinkToFit ()
 Get Shrink to fit.
 setShrinkToFit ($pValue=false)
 Set Shrink to fit.
 getIndent ()
 Get indent.
 setIndent ($pValue=0)
 Set indent.
 getHashCode ()
 Get hash code.
 __clone ()
 Implement PHP __clone to create a deep clone, not just a shallow copy.

Data Fields

const HORIZONTAL_GENERAL = 'general'
const HORIZONTAL_LEFT = 'left'
const HORIZONTAL_RIGHT = 'right'
const HORIZONTAL_CENTER = 'center'
const HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous'
const HORIZONTAL_JUSTIFY = 'justify'
const VERTICAL_BOTTOM = 'bottom'
const VERTICAL_TOP = 'top'
const VERTICAL_CENTER = 'center'
const VERTICAL_JUSTIFY = 'justify'

Private Attributes

 $_horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL
 $_vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM
 $_textRotation = 0
 $_wrapText = false
 $_shrinkToFit = false
 $_indent = 0
 $_parentPropertyName
 $_isSupervisor
 $_parent

Detailed Description

Definition at line 36 of file Alignment.php.

Constructor & Destructor Documentation

PHPExcel_Style_Alignment::__construct (   $isSupervisor = false)

Create a new PHPExcel_Style_Alignment.

Definition at line 118 of file Alignment.php.

{
// Supervisor?
$this->_isSupervisor = $isSupervisor;
}

Member Function Documentation

PHPExcel_Style_Alignment::__clone ( )

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

Definition at line 471 of file Alignment.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;
}
}
}
PHPExcel_Style_Alignment::applyFromArray (   $pStyles = null)

Apply styles from array.

$objPHPExcel->getActiveSheet()->getStyle('B2')->getAlignment()->applyFromArray( array( 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, 'rotation' => 0, 'wrap' => true ) );

Parameters
array$pStylesArray containing style information
Exceptions
Exception
Returns
PHPExcel_Style_Alignment

Definition at line 218 of file Alignment.php.

References getActiveSheet(), getSelectedCells(), getStyleArray(), setHorizontal(), setIndent(), setShrinkToFit(), setTextRotation(), setVertical(), and setWrapText().

{
if (is_array($pStyles)) {
if ($this->_isSupervisor) {
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
} else {
if (array_key_exists('horizontal', $pStyles)) {
$this->setHorizontal($pStyles['horizontal']);
}
if (array_key_exists('vertical', $pStyles)) {
$this->setVertical($pStyles['vertical']);
}
if (array_key_exists('rotation', $pStyles)) {
$this->setTextRotation($pStyles['rotation']);
}
if (array_key_exists('wrap', $pStyles)) {
$this->setWrapText($pStyles['wrap']);
}
if (array_key_exists('shrinkToFit', $pStyles)) {
$this->setShrinkToFit($pStyles['shrinkToFit']);
}
if (array_key_exists('indent', $pStyles)) {
$this->setIndent($pStyles['indent']);
}
}
} else {
throw new Exception("Invalid style array passed.");
}
return $this;
}

+ Here is the call graph for this function:

PHPExcel_Style_Alignment::bindParent (   $parent)

Bind parent.

Only used for supervisor

Parameters
PHPExcel$parent
Returns
PHPExcel_Style_Alignment

Definition at line 130 of file Alignment.php.

{
$this->_parent = $parent;
return $this;
}
PHPExcel_Style_Alignment::getActiveCell ( )

Get the currently active cell coordinate in currently active sheet.

Only used for supervisor

Returns
string E.g. 'A1'

Definition at line 184 of file Alignment.php.

References getActiveSheet().

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

+ Here is the call graph for this function:

PHPExcel_Style_Alignment::getActiveSheet ( )

Get the currently active sheet.

Only used for supervisor

Returns
PHPExcel_Worksheet

Definition at line 162 of file Alignment.php.

Referenced by applyFromArray(), getActiveCell(), getSelectedCells(), setHorizontal(), setIndent(), setShrinkToFit(), setTextRotation(), setVertical(), and setWrapText().

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

+ Here is the caller graph for this function:

PHPExcel_Style_Alignment::getHashCode ( )

Get hash code.

Returns
string Hash code

Implements PHPExcel_IComparable.

Definition at line 453 of file Alignment.php.

References getSharedComponent().

{
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
}
return md5(
$this->_horizontal
. $this->_vertical
. $this->_textRotation
. ($this->_wrapText ? 't' : 'f')
. ($this->_shrinkToFit ? 't' : 'f')
. $this->_indent
. __CLASS__
);
}

+ Here is the call graph for this function:

PHPExcel_Style_Alignment::getHorizontal ( )

Get Horizontal.

Returns
string

Definition at line 253 of file Alignment.php.

References $_horizontal, and getSharedComponent().

Referenced by PHPExcel_Writer_HTML\_createCSSStyleAlignment(), and setIndent().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_Style_Alignment::getIndent ( )

Get indent.

Returns
int

Definition at line 420 of file Alignment.php.

References $_indent, and getSharedComponent().

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

+ Here is the call graph for this function:

PHPExcel_Style_Alignment::getIsSupervisor ( )

Is this a supervisor or a real style component?

Returns
boolean

Definition at line 141 of file Alignment.php.

References $_isSupervisor.

{
}
PHPExcel_Style_Alignment::getSelectedCells ( )

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 Alignment.php.

References getActiveSheet().

Referenced by applyFromArray(), setHorizontal(), setIndent(), setShrinkToFit(), setTextRotation(), setVertical(), and setWrapText().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_Style_Alignment::getSharedComponent ( )

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

Only used for style supervisor

Returns
PHPExcel_Style_Alignment

Definition at line 152 of file Alignment.php.

Referenced by getHashCode(), getHorizontal(), getIndent(), getShrinkToFit(), getTextRotation(), getVertical(), and getWrapText().

{
return $this->_parent->getSharedComponent()->getAlignment();
}

+ Here is the caller graph for this function:

PHPExcel_Style_Alignment::getShrinkToFit ( )

Get Shrink to fit.

Returns
boolean

Definition at line 389 of file Alignment.php.

References $_shrinkToFit, and getSharedComponent().

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

+ Here is the call graph for this function:

PHPExcel_Style_Alignment::getStyleArray (   $array)

Build style array from subcomponents.

Parameters
array$array
Returns
array

Definition at line 195 of file Alignment.php.

Referenced by applyFromArray(), setHorizontal(), setIndent(), setShrinkToFit(), setTextRotation(), setVertical(), and setWrapText().

{
return array('alignment' => $array);
}

+ Here is the caller graph for this function:

PHPExcel_Style_Alignment::getTextRotation ( )

Get TextRotation.

Returns
int

Definition at line 318 of file Alignment.php.

References $_textRotation, and getSharedComponent().

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

+ Here is the call graph for this function:

PHPExcel_Style_Alignment::getVertical ( )

Get Vertical.

Returns
string

Definition at line 286 of file Alignment.php.

References $_vertical, and getSharedComponent().

Referenced by PHPExcel_Writer_HTML\_createCSSStyleAlignment().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_Style_Alignment::getWrapText ( )

Get Wrap Text.

Returns
boolean

Definition at line 358 of file Alignment.php.

References $_wrapText, and getSharedComponent().

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

+ Here is the call graph for this function:

PHPExcel_Style_Alignment::setHorizontal (   $pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL)

Set Horizontal.

Parameters
string$pValue
Returns
PHPExcel_Style_Alignment

Definition at line 266 of file Alignment.php.

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

Referenced by applyFromArray().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_Style_Alignment::setIndent (   $pValue = 0)

Set indent.

Parameters
int$pValue
Returns
PHPExcel_Style_Alignment

Definition at line 433 of file Alignment.php.

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

Referenced by applyFromArray().

{
if ($pValue > 0) {
if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && $this->getHorizontal() != self::HORIZONTAL_LEFT && $this->getHorizontal() != self::HORIZONTAL_RIGHT) {
$pValue = 0; // indent not supported
}
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('indent' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->_indent = $pValue;
}
return $this;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_Style_Alignment::setShrinkToFit (   $pValue = false)

Set Shrink to fit.

Parameters
boolean$pValue
Returns
PHPExcel_Style_Alignment

Definition at line 402 of file Alignment.php.

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

Referenced by applyFromArray().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_Style_Alignment::setTextRotation (   $pValue = 0)

Set TextRotation.

Parameters
int$pValue
Exceptions
Exception
Returns
PHPExcel_Style_Alignment

Definition at line 332 of file Alignment.php.

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

Referenced by applyFromArray().

{
// Excel2007 value 255 => PHPExcel value -165
if ($pValue == 255) {
$pValue = -165;
}
// Set rotation
if ( ($pValue >= -90 && $pValue <= 90) || $pValue == -165 ) {
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('rotation' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->_textRotation = $pValue;
}
} else {
throw new Exception("Text rotation should be a value between -90 and 90.");
}
return $this;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_Style_Alignment::setVertical (   $pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM)

Set Vertical.

Parameters
string$pValue
Returns
PHPExcel_Style_Alignment

Definition at line 299 of file Alignment.php.

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

Referenced by applyFromArray().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_Style_Alignment::setWrapText (   $pValue = false)

Set Wrap Text.

Parameters
boolean$pValue
Returns
PHPExcel_Style_Alignment

Definition at line 371 of file Alignment.php.

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

Referenced by applyFromArray().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

PHPExcel_Style_Alignment::$_horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL
private

Definition at line 57 of file Alignment.php.

Referenced by getHorizontal().

PHPExcel_Style_Alignment::$_indent = 0
private

Definition at line 92 of file Alignment.php.

Referenced by getIndent().

PHPExcel_Style_Alignment::$_isSupervisor
private

Definition at line 106 of file Alignment.php.

Referenced by getIsSupervisor().

PHPExcel_Style_Alignment::$_parent
private

Definition at line 113 of file Alignment.php.

PHPExcel_Style_Alignment::$_parentPropertyName
private

Definition at line 99 of file Alignment.php.

PHPExcel_Style_Alignment::$_shrinkToFit = false
private

Definition at line 85 of file Alignment.php.

Referenced by getShrinkToFit().

PHPExcel_Style_Alignment::$_textRotation = 0
private

Definition at line 71 of file Alignment.php.

Referenced by getTextRotation().

PHPExcel_Style_Alignment::$_vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM
private

Definition at line 64 of file Alignment.php.

Referenced by getVertical().

PHPExcel_Style_Alignment::$_wrapText = false
private

Definition at line 78 of file Alignment.php.

Referenced by getWrapText().

const PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous'
const PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY = 'justify'
const PHPExcel_Style_Alignment::HORIZONTAL_LEFT = 'left'
const PHPExcel_Style_Alignment::HORIZONTAL_RIGHT = 'right'
const PHPExcel_Style_Alignment::VERTICAL_CENTER = 'center'
const PHPExcel_Style_Alignment::VERTICAL_JUSTIFY = 'justify'
const PHPExcel_Style_Alignment::VERTICAL_TOP = 'top'

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