SpContainer.php 8.3 KB

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