SpContainer.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer;
  3. use PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer;
  4. class SpContainer
  5. {
  6. /**
  7. * Parent Shape Group Container.
  8. *
  9. * @var SpgrContainer
  10. */
  11. private $parent;
  12. /**
  13. * Is this a group shape?
  14. *
  15. * @var bool
  16. */
  17. private $spgr = false;
  18. /**
  19. * Shape type.
  20. *
  21. * @var int
  22. */
  23. private $spType;
  24. /**
  25. * Shape flag.
  26. *
  27. * @var int
  28. */
  29. private $spFlag;
  30. /**
  31. * Shape index (usually group shape has index 0, and the rest: 1,2,3...).
  32. *
  33. * @var int
  34. */
  35. private $spId;
  36. /**
  37. * Array of options.
  38. *
  39. * @var array
  40. */
  41. private $OPT;
  42. /**
  43. * Cell coordinates of upper-left corner of shape, e.g. 'A1'.
  44. *
  45. * @var string
  46. */
  47. private $startCoordinates;
  48. /**
  49. * Horizontal offset of upper-left corner of shape measured in 1/1024 of column width.
  50. *
  51. * @var int
  52. */
  53. private $startOffsetX;
  54. /**
  55. * Vertical offset of upper-left corner of shape measured in 1/256 of row height.
  56. *
  57. * @var int
  58. */
  59. private $startOffsetY;
  60. /**
  61. * Cell coordinates of bottom-right corner of shape, e.g. 'B2'.
  62. *
  63. * @var string
  64. */
  65. private $endCoordinates;
  66. /**
  67. * Horizontal offset of bottom-right corner of shape measured in 1/1024 of column width.
  68. *
  69. * @var int
  70. */
  71. private $endOffsetX;
  72. /**
  73. * Vertical offset of bottom-right corner of shape measured in 1/256 of row height.
  74. *
  75. * @var int
  76. */
  77. private $endOffsetY;
  78. /**
  79. * Set parent Shape Group Container.
  80. *
  81. * @param SpgrContainer $parent
  82. */
  83. public function setParent($parent)
  84. {
  85. $this->parent = $parent;
  86. }
  87. /**
  88. * Get the parent Shape Group Container.
  89. *
  90. * @return SpgrContainer
  91. */
  92. public function getParent()
  93. {
  94. return $this->parent;
  95. }
  96. /**
  97. * Set whether this is a group shape.
  98. *
  99. * @param bool $value
  100. */
  101. public function setSpgr($value)
  102. {
  103. $this->spgr = $value;
  104. }
  105. /**
  106. * Get whether this is a group shape.
  107. *
  108. * @return bool
  109. */
  110. public function getSpgr()
  111. {
  112. return $this->spgr;
  113. }
  114. /**
  115. * Set the shape type.
  116. *
  117. * @param int $value
  118. */
  119. public function setSpType($value)
  120. {
  121. $this->spType = $value;
  122. }
  123. /**
  124. * Get the shape type.
  125. *
  126. * @return int
  127. */
  128. public function getSpType()
  129. {
  130. return $this->spType;
  131. }
  132. /**
  133. * Set the shape flag.
  134. *
  135. * @param int $value
  136. */
  137. public function setSpFlag($value)
  138. {
  139. $this->spFlag = $value;
  140. }
  141. /**
  142. * Get the shape flag.
  143. *
  144. * @return int
  145. */
  146. public function getSpFlag()
  147. {
  148. return $this->spFlag;
  149. }
  150. /**
  151. * Set the shape index.
  152. *
  153. * @param int $value
  154. */
  155. public function setSpId($value)
  156. {
  157. $this->spId = $value;
  158. }
  159. /**
  160. * Get the shape index.
  161. *
  162. * @return int
  163. */
  164. public function getSpId()
  165. {
  166. return $this->spId;
  167. }
  168. /**
  169. * Set an option for the Shape Group Container.
  170. *
  171. * @param int $property The number specifies the option
  172. * @param mixed $value
  173. */
  174. public function setOPT($property, $value)
  175. {
  176. $this->OPT[$property] = $value;
  177. }
  178. /**
  179. * Get an option for the Shape Group Container.
  180. *
  181. * @param int $property The number specifies the option
  182. *
  183. * @return mixed
  184. */
  185. public function getOPT($property)
  186. {
  187. if (isset($this->OPT[$property])) {
  188. return $this->OPT[$property];
  189. }
  190. return null;
  191. }
  192. /**
  193. * Get the collection of options.
  194. *
  195. * @return array
  196. */
  197. public function getOPTCollection()
  198. {
  199. return $this->OPT;
  200. }
  201. /**
  202. * Set cell coordinates of upper-left corner of shape.
  203. *
  204. * @param string $value eg: 'A1'
  205. */
  206. public function setStartCoordinates($value)
  207. {
  208. $this->startCoordinates = $value;
  209. }
  210. /**
  211. * Get cell coordinates of upper-left corner of shape.
  212. *
  213. * @return string
  214. */
  215. public function getStartCoordinates()
  216. {
  217. return $this->startCoordinates;
  218. }
  219. /**
  220. * Set offset in x-direction of upper-left corner of shape measured in 1/1024 of column width.
  221. *
  222. * @param int $startOffsetX
  223. */
  224. public function setStartOffsetX($startOffsetX)
  225. {
  226. $this->startOffsetX = $startOffsetX;
  227. }
  228. /**
  229. * Get offset in x-direction of upper-left corner of shape measured in 1/1024 of column width.
  230. *
  231. * @return int
  232. */
  233. public function getStartOffsetX()
  234. {
  235. return $this->startOffsetX;
  236. }
  237. /**
  238. * Set offset in y-direction of upper-left corner of shape measured in 1/256 of row height.
  239. *
  240. * @param int $startOffsetY
  241. */
  242. public function setStartOffsetY($startOffsetY)
  243. {
  244. $this->startOffsetY = $startOffsetY;
  245. }
  246. /**
  247. * Get offset in y-direction of upper-left corner of shape measured in 1/256 of row height.
  248. *
  249. * @return int
  250. */
  251. public function getStartOffsetY()
  252. {
  253. return $this->startOffsetY;
  254. }
  255. /**
  256. * Set cell coordinates of bottom-right corner of shape.
  257. *
  258. * @param string $value eg: 'A1'
  259. */
  260. public function setEndCoordinates($value)
  261. {
  262. $this->endCoordinates = $value;
  263. }
  264. /**
  265. * Get cell coordinates of bottom-right corner of shape.
  266. *
  267. * @return string
  268. */
  269. public function getEndCoordinates()
  270. {
  271. return $this->endCoordinates;
  272. }
  273. /**
  274. * Set offset in x-direction of bottom-right corner of shape measured in 1/1024 of column width.
  275. *
  276. * @param int $endOffsetX
  277. */
  278. public function setEndOffsetX($endOffsetX)
  279. {
  280. $this->endOffsetX = $endOffsetX;
  281. }
  282. /**
  283. * Get offset in x-direction of bottom-right corner of shape measured in 1/1024 of column width.
  284. *
  285. * @return int
  286. */
  287. public function getEndOffsetX()
  288. {
  289. return $this->endOffsetX;
  290. }
  291. /**
  292. * Set offset in y-direction of bottom-right corner of shape measured in 1/256 of row height.
  293. *
  294. * @param int $endOffsetY
  295. */
  296. public function setEndOffsetY($endOffsetY)
  297. {
  298. $this->endOffsetY = $endOffsetY;
  299. }
  300. /**
  301. * Get offset in y-direction of bottom-right corner of shape measured in 1/256 of row height.
  302. *
  303. * @return int
  304. */
  305. public function getEndOffsetY()
  306. {
  307. return $this->endOffsetY;
  308. }
  309. /**
  310. * Get the nesting level of this spContainer. This is the number of spgrContainers between this spContainer and
  311. * the dgContainer. A value of 1 = immediately within first spgrContainer
  312. * Higher nesting level occurs if and only if spContainer is part of a shape group.
  313. *
  314. * @return int Nesting level
  315. */
  316. public function getNestingLevel()
  317. {
  318. $nestingLevel = 0;
  319. $parent = $this->getParent();
  320. while ($parent instanceof SpgrContainer) {
  321. ++$nestingLevel;
  322. $parent = $parent->getParent();
  323. }
  324. return $nestingLevel;
  325. }
  326. }