Supervisor.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /**
  3. * PHPExcel_Style_Supervisor
  4. *
  5. * Copyright (c) 2006 - 2015 PHPExcel
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. * @category PHPExcel
  22. * @package PHPExcel_Style
  23. * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version ##VERSION##, ##DATE##
  26. */
  27. abstract class PHPExcel_Style_Supervisor
  28. {
  29. /**
  30. * Supervisor?
  31. *
  32. * @var boolean
  33. */
  34. protected $isSupervisor;
  35. /**
  36. * Parent. Only used for supervisor
  37. *
  38. * @var PHPExcel_Style
  39. */
  40. protected $parent;
  41. /**
  42. * Create a new PHPExcel_Style_Alignment
  43. *
  44. * @param boolean $isSupervisor Flag indicating if this is a supervisor or not
  45. * Leave this value at default unless you understand exactly what
  46. * its ramifications are
  47. */
  48. public function __construct($isSupervisor = false)
  49. {
  50. // Supervisor?
  51. $this->isSupervisor = $isSupervisor;
  52. }
  53. /**
  54. * Bind parent. Only used for supervisor
  55. *
  56. * @param PHPExcel $parent
  57. * @return PHPExcel_Style_Supervisor
  58. */
  59. public function bindParent($parent, $parentPropertyName = null)
  60. {
  61. $this->parent = $parent;
  62. return $this;
  63. }
  64. /**
  65. * Is this a supervisor or a cell style component?
  66. *
  67. * @return boolean
  68. */
  69. public function getIsSupervisor()
  70. {
  71. return $this->isSupervisor;
  72. }
  73. /**
  74. * Get the currently active sheet. Only used for supervisor
  75. *
  76. * @return PHPExcel_Worksheet
  77. */
  78. public function getActiveSheet()
  79. {
  80. return $this->parent->getActiveSheet();
  81. }
  82. /**
  83. * Get the currently active cell coordinate in currently active sheet.
  84. * Only used for supervisor
  85. *
  86. * @return string E.g. 'A1'
  87. */
  88. public function getSelectedCells()
  89. {
  90. return $this->getActiveSheet()->getSelectedCells();
  91. }
  92. /**
  93. * Get the currently active cell coordinate in currently active sheet.
  94. * Only used for supervisor
  95. *
  96. * @return string E.g. 'A1'
  97. */
  98. public function getActiveCell()
  99. {
  100. return $this->getActiveSheet()->getActiveCell();
  101. }
  102. /**
  103. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  104. */
  105. public function __clone()
  106. {
  107. $vars = get_object_vars($this);
  108. foreach ($vars as $key => $value) {
  109. if ((is_object($value)) && ($key != 'parent')) {
  110. $this->$key = clone $value;
  111. } else {
  112. $this->$key = $value;
  113. }
  114. }
  115. }
  116. }