Supervisor.Class.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: phperstar
  5. * Date: 2020/8/11
  6. * Time: 6:08 PM
  7. */
  8. abstract class Supervisor
  9. {
  10. /**
  11. * Supervisor?
  12. *
  13. * @var boolean
  14. */
  15. protected $isSupervisor;
  16. /**
  17. * Parent. Only used for supervisor
  18. *
  19. * @var PHPExcel_Style
  20. */
  21. protected $parent;
  22. /**
  23. * Create a new PHPExcel_Style_Alignment
  24. *
  25. * @param boolean $isSupervisor Flag indicating if this is a supervisor or not
  26. * Leave this value at default unless you understand exactly what
  27. * its ramifications are
  28. */
  29. public function __construct($isSupervisor = false)
  30. {
  31. // Supervisor?
  32. $this->isSupervisor = $isSupervisor;
  33. }
  34. /**
  35. * Bind parent. Only used for supervisor
  36. *
  37. * @param PHPExcel $parent
  38. * @return PHPExcel_Style_Supervisor
  39. */
  40. public function bindParent($parent, $parentPropertyName = null)
  41. {
  42. $this->parent = $parent;
  43. return $this;
  44. }
  45. /**
  46. * Is this a supervisor or a cell style component?
  47. *
  48. * @return boolean
  49. */
  50. public function getIsSupervisor()
  51. {
  52. return $this->isSupervisor;
  53. }
  54. /**
  55. * Get the currently active sheet. Only used for supervisor
  56. *
  57. * @return PHPExcel_Worksheet
  58. */
  59. public function getActiveSheet()
  60. {
  61. return $this->parent->getActiveSheet();
  62. }
  63. /**
  64. * Get the currently active cell coordinate in currently active sheet.
  65. * Only used for supervisor
  66. *
  67. * @return string E.g. 'A1'
  68. */
  69. public function getSelectedCells()
  70. {
  71. return $this->getActiveSheet()->getSelectedCells();
  72. }
  73. /**
  74. * Get the currently active cell coordinate in currently active sheet.
  75. * Only used for supervisor
  76. *
  77. * @return string E.g. 'A1'
  78. */
  79. public function getActiveCell()
  80. {
  81. return $this->getActiveSheet()->getActiveCell();
  82. }
  83. /**
  84. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  85. */
  86. public function __clone()
  87. {
  88. $vars = get_object_vars($this);
  89. foreach ($vars as $key => $value) {
  90. if ((is_object($value)) && ($key != 'parent')) {
  91. $this->$key = clone $value;
  92. } else {
  93. $this->$key = $value;
  94. }
  95. }
  96. }
  97. }