bf820aa878cda12fbe25401772752481d2101486.svn-base 2.7 KB

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