SpgrContainer.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * PHPExcel_Shared_Escher_DgContainer_SpgrContainer
  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_Shared_Escher
  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. class PHPExcel_Shared_Escher_DgContainer_SpgrContainer
  28. {
  29. /**
  30. * Parent Shape Group Container
  31. *
  32. * @var PHPExcel_Shared_Escher_DgContainer_SpgrContainer
  33. */
  34. private $parent;
  35. /**
  36. * Shape Container collection
  37. *
  38. * @var array
  39. */
  40. private $children = array();
  41. /**
  42. * Set parent Shape Group Container
  43. *
  44. * @param PHPExcel_Shared_Escher_DgContainer_SpgrContainer $parent
  45. */
  46. public function setParent($parent)
  47. {
  48. $this->parent = $parent;
  49. }
  50. /**
  51. * Get the parent Shape Group Container if any
  52. *
  53. * @return PHPExcel_Shared_Escher_DgContainer_SpgrContainer|null
  54. */
  55. public function getParent()
  56. {
  57. return $this->parent;
  58. }
  59. /**
  60. * Add a child. This will be either spgrContainer or spContainer
  61. *
  62. * @param mixed $child
  63. */
  64. public function addChild($child)
  65. {
  66. $this->children[] = $child;
  67. $child->setParent($this);
  68. }
  69. /**
  70. * Get collection of Shape Containers
  71. */
  72. public function getChildren()
  73. {
  74. return $this->children;
  75. }
  76. /**
  77. * Recursively get all spContainers within this spgrContainer
  78. *
  79. * @return PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer[]
  80. */
  81. public function getAllSpContainers()
  82. {
  83. $allSpContainers = array();
  84. foreach ($this->children as $child) {
  85. if ($child instanceof PHPExcel_Shared_Escher_DgContainer_SpgrContainer) {
  86. $allSpContainers = array_merge($allSpContainers, $child->getAllSpContainers());
  87. } else {
  88. $allSpContainers[] = $child;
  89. }
  90. }
  91. return $allSpContainers;
  92. }
  93. }