Dimension.php 2.8 KB

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