ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PhpOffice\PhpSpreadsheet\Style\Protection Class Reference
+ Inheritance diagram for PhpOffice\PhpSpreadsheet\Style\Protection:
+ Collaboration diagram for PhpOffice\PhpSpreadsheet\Style\Protection:

Public Member Functions

 __construct ($isSupervisor=false, $isConditional=false)
 Create a new Protection. More...
 
 getSharedComponent ()
 Get the shared style component for the currently active cell in currently active sheet. More...
 
 getStyleArray ($array)
 Build style array from subcomponents. More...
 
 applyFromArray (array $pStyles)
 Apply styles from array. More...
 
 getLocked ()
 Get locked. More...
 
 setLocked ($pValue)
 Set locked. More...
 
 getHidden ()
 Get hidden. More...
 
 setHidden ($pValue)
 Set hidden. More...
 
 getHashCode ()
 Get hash code. More...
 
- Public Member Functions inherited from PhpOffice\PhpSpreadsheet\Style\Supervisor
 __construct ($isSupervisor=false)
 Create a new Supervisor. More...
 
 bindParent ($parent, $parentPropertyName=null)
 Bind parent. More...
 
 getIsSupervisor ()
 Is this a supervisor or a cell style component? More...
 
 getActiveSheet ()
 Get the currently active sheet. More...
 
 getSelectedCells ()
 Get the currently active cell coordinate in currently active sheet. More...
 
 getActiveCell ()
 Get the currently active cell coordinate in currently active sheet. More...
 
 __clone ()
 Implement PHP __clone to create a deep clone, not just a shallow copy. More...
 
 exportArray ()
 Export style as array. More...
 

Data Fields

const PROTECTION_INHERIT = 'inherit'
 Protection styles. More...
 
const PROTECTION_PROTECTED = 'protected'
 
const PROTECTION_UNPROTECTED = 'unprotected'
 

Protected Member Functions

 exportArray1 ()
 
- Protected Member Functions inherited from PhpOffice\PhpSpreadsheet\Style\Supervisor
 exportArray1 ()
 Abstract method to be implemented in anything which extends this class. More...
 
 exportArray2 (array &$exportedArray, string $index, $objOrValue)
 Populate array from exportArray1. More...
 

Protected Attributes

 $locked
 
 $hidden
 
- Protected Attributes inherited from PhpOffice\PhpSpreadsheet\Style\Supervisor
 $isSupervisor
 
 $parent
 
 $parentPropertyName
 

Detailed Description

Definition at line 5 of file Protection.php.

Constructor & Destructor Documentation

◆ __construct()

PhpOffice\PhpSpreadsheet\Style\Protection::__construct (   $isSupervisor = false,
  $isConditional = false 
)

Create a new Protection.

Parameters
bool$isSupervisorFlag indicating if this is a supervisor or not Leave this value at default unless you understand exactly what its ramifications are
bool$isConditionalFlag indicating if this is a conditional style or not Leave this value at default unless you understand exactly what its ramifications are

Definition at line 36 of file Protection.php.

References PhpOffice\PhpSpreadsheet\Style\Supervisor\$isSupervisor.

37  {
38  // Supervisor?
39  parent::__construct($isSupervisor);
40 
41  // Initialise values
42  if (!$isConditional) {
43  $this->locked = self::PROTECTION_INHERIT;
44  $this->hidden = self::PROTECTION_INHERIT;
45  }
46  }

Member Function Documentation

◆ applyFromArray()

PhpOffice\PhpSpreadsheet\Style\Protection::applyFromArray ( array  $pStyles)

Apply styles from array.

$spreadsheet->getActiveSheet()->getStyle('B2')->getLocked()->applyFromArray( [ 'locked' => TRUE, 'hidden' => FALSE ] );

Parameters
array$pStylesArray containing style information
Returns
$this

Definition at line 87 of file Protection.php.

References PhpOffice\PhpSpreadsheet\Style\Supervisor\getActiveSheet(), PhpOffice\PhpSpreadsheet\Style\Supervisor\getSelectedCells(), PhpOffice\PhpSpreadsheet\Style\Protection\getStyleArray(), PhpOffice\PhpSpreadsheet\Style\Protection\setHidden(), and PhpOffice\PhpSpreadsheet\Style\Protection\setLocked().

88  {
89  if ($this->isSupervisor) {
90  $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
91  } else {
92  if (isset($pStyles['locked'])) {
93  $this->setLocked($pStyles['locked']);
94  }
95  if (isset($pStyles['hidden'])) {
96  $this->setHidden($pStyles['hidden']);
97  }
98  }
99 
100  return $this;
101  }
getSelectedCells()
Get the currently active cell coordinate in currently active sheet.
Definition: Supervisor.php:87
getStyleArray($array)
Build style array from subcomponents.
Definition: Protection.php:66
getActiveSheet()
Get the currently active sheet.
Definition: Supervisor.php:76
+ Here is the call graph for this function:

◆ exportArray1()

PhpOffice\PhpSpreadsheet\Style\Protection::exportArray1 ( )
protected

Definition at line 187 of file Protection.php.

References PhpOffice\PhpSpreadsheet\Style\Supervisor\exportArray2(), PhpOffice\PhpSpreadsheet\Style\Protection\getHidden(), and PhpOffice\PhpSpreadsheet\Style\Protection\getLocked().

187  : array
188  {
189  $exportedArray = [];
190  $this->exportArray2($exportedArray, 'locked', $this->getLocked());
191  $this->exportArray2($exportedArray, 'hidden', $this->getHidden());
192 
193  return $exportedArray;
194  }
exportArray2(array &$exportedArray, string $index, $objOrValue)
Populate array from exportArray1.
Definition: Supervisor.php:150
+ Here is the call graph for this function:

◆ getHashCode()

PhpOffice\PhpSpreadsheet\Style\Protection::getHashCode ( )

Get hash code.

Returns
string Hash code

Implements PhpOffice\PhpSpreadsheet\IComparable.

Definition at line 174 of file Protection.php.

References PhpOffice\PhpSpreadsheet\Style\Protection\getSharedComponent().

175  {
176  if ($this->isSupervisor) {
177  return $this->getSharedComponent()->getHashCode();
178  }
179 
180  return md5(
181  $this->locked .
182  $this->hidden .
183  __CLASS__
184  );
185  }
getSharedComponent()
Get the shared style component for the currently active cell in currently active sheet.
Definition: Protection.php:54
+ Here is the call graph for this function:

◆ getHidden()

PhpOffice\PhpSpreadsheet\Style\Protection::getHidden ( )

Get hidden.

Returns
string

Definition at line 141 of file Protection.php.

References PhpOffice\PhpSpreadsheet\Style\Protection\$hidden, and PhpOffice\PhpSpreadsheet\Style\Protection\getSharedComponent().

Referenced by PhpOffice\PhpSpreadsheet\Style\Protection\exportArray1().

142  {
143  if ($this->isSupervisor) {
144  return $this->getSharedComponent()->getHidden();
145  }
146 
147  return $this->hidden;
148  }
getSharedComponent()
Get the shared style component for the currently active cell in currently active sheet.
Definition: Protection.php:54
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLocked()

PhpOffice\PhpSpreadsheet\Style\Protection::getLocked ( )

Get locked.

Returns
string

Definition at line 108 of file Protection.php.

References PhpOffice\PhpSpreadsheet\Style\Protection\$locked, and PhpOffice\PhpSpreadsheet\Style\Protection\getSharedComponent().

Referenced by PhpOffice\PhpSpreadsheet\Style\Protection\exportArray1().

109  {
110  if ($this->isSupervisor) {
111  return $this->getSharedComponent()->getLocked();
112  }
113 
114  return $this->locked;
115  }
getSharedComponent()
Get the shared style component for the currently active cell in currently active sheet.
Definition: Protection.php:54
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSharedComponent()

PhpOffice\PhpSpreadsheet\Style\Protection::getSharedComponent ( )

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

Only used for style supervisor.

Returns
Protection

Definition at line 54 of file Protection.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Protection\getHashCode(), PhpOffice\PhpSpreadsheet\Style\Protection\getHidden(), and PhpOffice\PhpSpreadsheet\Style\Protection\getLocked().

55  {
56  return $this->parent->getSharedComponent()->getProtection();
57  }
+ Here is the caller graph for this function:

◆ getStyleArray()

PhpOffice\PhpSpreadsheet\Style\Protection::getStyleArray (   $array)

Build style array from subcomponents.

Parameters
array$array
Returns
array

Definition at line 66 of file Protection.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Protection\applyFromArray(), PhpOffice\PhpSpreadsheet\Style\Protection\setHidden(), and PhpOffice\PhpSpreadsheet\Style\Protection\setLocked().

67  {
68  return ['protection' => $array];
69  }
+ Here is the caller graph for this function:

◆ setHidden()

PhpOffice\PhpSpreadsheet\Style\Protection::setHidden (   $pValue)

Set hidden.

Parameters
string$pValuesee self::PROTECTION_*
Returns
$this

Definition at line 157 of file Protection.php.

References PhpOffice\PhpSpreadsheet\Style\Supervisor\getActiveSheet(), PhpOffice\PhpSpreadsheet\Style\Supervisor\getSelectedCells(), and PhpOffice\PhpSpreadsheet\Style\Protection\getStyleArray().

Referenced by PhpOffice\PhpSpreadsheet\Style\Protection\applyFromArray().

158  {
159  if ($this->isSupervisor) {
160  $styleArray = $this->getStyleArray(['hidden' => $pValue]);
161  $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
162  } else {
163  $this->hidden = $pValue;
164  }
165 
166  return $this;
167  }
getSelectedCells()
Get the currently active cell coordinate in currently active sheet.
Definition: Supervisor.php:87
getStyleArray($array)
Build style array from subcomponents.
Definition: Protection.php:66
getActiveSheet()
Get the currently active sheet.
Definition: Supervisor.php:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setLocked()

PhpOffice\PhpSpreadsheet\Style\Protection::setLocked (   $pValue)

Set locked.

Parameters
string$pValuesee self::PROTECTION_*
Returns
$this

Definition at line 124 of file Protection.php.

References PhpOffice\PhpSpreadsheet\Style\Supervisor\getActiveSheet(), PhpOffice\PhpSpreadsheet\Style\Supervisor\getSelectedCells(), and PhpOffice\PhpSpreadsheet\Style\Protection\getStyleArray().

Referenced by PhpOffice\PhpSpreadsheet\Style\Protection\applyFromArray().

125  {
126  if ($this->isSupervisor) {
127  $styleArray = $this->getStyleArray(['locked' => $pValue]);
128  $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
129  } else {
130  $this->locked = $pValue;
131  }
132 
133  return $this;
134  }
getSelectedCells()
Get the currently active cell coordinate in currently active sheet.
Definition: Supervisor.php:87
getStyleArray($array)
Build style array from subcomponents.
Definition: Protection.php:66
getActiveSheet()
Get the currently active sheet.
Definition: Supervisor.php:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $hidden

PhpOffice\PhpSpreadsheet\Style\Protection::$hidden
protected

Definition at line 24 of file Protection.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Protection\getHidden().

◆ $locked

PhpOffice\PhpSpreadsheet\Style\Protection::$locked
protected

Definition at line 17 of file Protection.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Protection\getLocked().

◆ PROTECTION_INHERIT

const PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_INHERIT = 'inherit'

Protection styles.

Definition at line 8 of file Protection.php.

Referenced by PhpOffice\PhpSpreadsheet\Reader\Xls\readXf().

◆ PROTECTION_PROTECTED

const PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED = 'protected'

◆ PROTECTION_UNPROTECTED

const PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_UNPROTECTED = 'unprotected'

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