| 1 |
<?php |
| 2 |
|
| 3 |
namespace PhpOffice\PhpSpreadsheet\Worksheet; |
| 4 |
|
| 5 |
use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; |
| 6 |
|
| 7 |
abstract class Dimension |
| 8 |
{ |
| 9 |
/** |
| 10 |
* Visible? |
| 11 |
* |
| 12 |
* @var bool |
| 13 |
*/ |
| 14 |
private $visible = true; |
| 15 |
|
| 16 |
/** |
| 17 |
* Outline level. |
| 18 |
* |
| 19 |
* @var int |
| 20 |
*/ |
| 21 |
private $outlineLevel = 0; |
| 22 |
|
| 23 |
/** |
| 24 |
* Collapsed. |
| 25 |
* |
| 26 |
* @var bool |
| 27 |
*/ |
| 28 |
private $collapsed = false; |
| 29 |
|
| 30 |
/** |
| 31 |
* Index to cellXf. Null value means row has no explicit cellXf format. |
| 32 |
* |
| 33 |
* @var null|int |
| 34 |
*/ |
| 35 |
private $xfIndex; |
| 36 |
|
| 37 |
/** |
| 38 |
* Create a new Dimension. |
| 39 |
* |
| 40 |
* @param int $initialValue Numeric row index |
| 41 |
*/ |
| 42 |
public function __construct($initialValue = null) |
| 43 |
{ |
| 44 |
// set dimension as unformatted by default |
| 45 |
$this->xfIndex = $initialValue; |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Get Visible. |
| 50 |
* |
| 51 |
* @return bool |
| 52 |
*/ |
| 53 |
public function getVisible() |
| 54 |
{ |
| 55 |
return $this->visible; |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Set Visible. |
| 60 |
* |
| 61 |
* @param bool $pValue |
| 62 |
* |
| 63 |
* @return Dimension |
| 64 |
*/ |
| 65 |
public function setVisible($pValue) |
| 66 |
{ |
| 67 |
$this->visible = (bool) $pValue; |
| 68 |
|
| 69 |
return $this; |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* Get Outline Level. |
| 74 |
* |
| 75 |
* @return int |
| 76 |
*/ |
| 77 |
public function getOutlineLevel() |
| 78 |
{ |
| 79 |
return $this->outlineLevel; |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* Set Outline Level. |
| 84 |
* Value must be between 0 and 7. |
| 85 |
* |
| 86 |
* @param int $pValue |
| 87 |
* |
| 88 |
* @throws PhpSpreadsheetException |
| 89 |
* |
| 90 |
* @return Dimension |
| 91 |
*/ |
| 92 |
public function setOutlineLevel($pValue) |
| 93 |
{ |
| 94 |
if ($pValue < 0 || $pValue > 7) { |
| 95 |
throw new PhpSpreadsheetException('Outline level must range between 0 and 7.'); |
| 96 |
} |
| 97 |
|
| 98 |
$this->outlineLevel = $pValue; |
| 99 |
|
| 100 |
return $this; |
| 101 |
} |
| 102 |
|
| 103 |
/** |
| 104 |
* Get Collapsed. |
| 105 |
* |
| 106 |
* @return bool |
| 107 |
*/ |
| 108 |
public function getCollapsed() |
| 109 |
{ |
| 110 |
return $this->collapsed; |
| 111 |
} |
| 112 |
|
| 113 |
/** |
| 114 |
* Set Collapsed. |
| 115 |
* |
| 116 |
* @param bool $pValue |
| 117 |
* |
| 118 |
* @return Dimension |
| 119 |
*/ |
| 120 |
public function setCollapsed($pValue) |
| 121 |
{ |
| 122 |
$this->collapsed = (bool) $pValue; |
| 123 |
|
| 124 |
return $this; |
| 125 |
} |
| 126 |
|
| 127 |
/** |
| 128 |
* Get index to cellXf. |
| 129 |
* |
| 130 |
* @return int |
| 131 |
*/ |
| 132 |
public function getXfIndex() |
| 133 |
{ |
| 134 |
return $this->xfIndex; |
| 135 |
} |
| 136 |
|
| 137 |
/** |
| 138 |
* Set index to cellXf. |
| 139 |
* |
| 140 |
* @param int $pValue |
| 141 |
* |
| 142 |
* @return Dimension |
| 143 |
*/ |
| 144 |
public function setXfIndex($pValue) |
| 145 |
{ |
| 146 |
$this->xfIndex = $pValue; |
| 147 |
|
| 148 |
return $this; |
| 149 |
} |
| 150 |
|
| 151 |
/** |
| 152 |
* Implement PHP __clone to create a deep clone, not just a shallow copy. |
| 153 |
*/ |
| 154 |
public function __clone() |
| 155 |
{ |
| 156 |
$vars = get_object_vars($this); |
| 157 |
foreach ($vars as $key => $value) { |
| 158 |
if (is_object($value)) { |
| 159 |
$this->$key = clone $value; |
| 160 |
} else { |
| 161 |
$this->$key = $value; |
| 162 |
} |
| 163 |
} |
| 164 |
} |
| 165 |
} |
| 166 |
|