PageRenderTime 28ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/phpexcel/PHPExcel/Style/Supervisor.php

http://github.com/moodle/moodle
PHP | 125 lines | 42 code | 9 blank | 74 comment | 4 complexity | fe304db3518ed1c470062e36a4b98d8e MD5 | raw file
Possible License(s): MIT, AGPL-3.0, MPL-2.0-no-copyleft-exception, LGPL-3.0, GPL-3.0, Apache-2.0, LGPL-2.1, BSD-3-Clause
  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. }