Object.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <?php
  2. /**
  3. * PHPWord
  4. *
  5. * Copyright (c) 2011 PHPWord
  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 PHPWord
  22. * @package PHPWord
  23. * @copyright Copyright (c) 010 PHPWord
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version Beta 0.6.3, 08.07.2011
  26. */
  27. /**
  28. * PHPWord_Section_Object
  29. *
  30. * @category PHPWord
  31. * @package PHPWord_Section
  32. * @copyright Copyright (c) 2011 PHPWord
  33. */
  34. class PHPWord_Section_Object {
  35. /**
  36. * Ole-Object Src
  37. *
  38. * @var string
  39. */
  40. private $_src;
  41. /**
  42. * Image Style
  43. *
  44. * @var PHPWord_Style_Image
  45. */
  46. private $_style;
  47. /**
  48. * Object Relation ID
  49. *
  50. * @var int
  51. */
  52. private $_rId;
  53. /**
  54. * Image Relation ID
  55. *
  56. * @var int
  57. */
  58. private $_rIdImg;
  59. /**
  60. * Object ID
  61. *
  62. * @var int
  63. */
  64. private $_objId;
  65. /**
  66. * Create a new Ole-Object Element
  67. *
  68. * @param string $src
  69. * @param mixed $style
  70. */
  71. public function __construct($src, $style = null) {
  72. $_supportedObjectTypes = array('xls', 'doc', 'ppt');
  73. $inf = pathinfo($src);
  74. if(file_exists($src) && in_array($inf['extension'], $_supportedObjectTypes)) {
  75. $this->_src = $src;
  76. $this->_style = new PHPWord_Style_Image();
  77. if(!is_null($style) && is_array($style)) {
  78. foreach($style as $key => $value) {
  79. if(substr($key, 0, 1) != '_') {
  80. $key = '_'.$key;
  81. }
  82. $this->_style->setStyleValue($key, $value);
  83. }
  84. }
  85. return $this;
  86. } else {
  87. return false;
  88. }
  89. }
  90. /**
  91. * Get Image style
  92. *
  93. * @return PHPWord_Style_Image
  94. */
  95. public function getStyle() {
  96. return $this->_style;
  97. }
  98. /**
  99. * Get Source
  100. *
  101. * @return string
  102. */
  103. public function getSource() {
  104. return $this->_src;
  105. }
  106. /**
  107. * Get Object Relation ID
  108. *
  109. * @return int
  110. */
  111. public function getRelationId() {
  112. return $this->_rId;
  113. }
  114. /**
  115. * Set Object Relation ID
  116. *
  117. * @param int $rId
  118. */
  119. public function setRelationId($rId) {
  120. $this->_rId = $rId;
  121. }
  122. /**
  123. * Get Image Relation ID
  124. *
  125. * @return int
  126. */
  127. public function getImageRelationId() {
  128. return $this->_rIdImg;
  129. }
  130. /**
  131. * Set Image Relation ID
  132. *
  133. * @param int $rId
  134. */
  135. public function setImageRelationId($rId) {
  136. $this->_rIdImg = $rId;
  137. }
  138. /**
  139. * Get Object ID
  140. *
  141. * @return int
  142. */
  143. public function getObjectId() {
  144. return $this->_objId;
  145. }
  146. /**
  147. * Set Object ID
  148. *
  149. * @param int $objId
  150. */
  151. public function setObjectId($objId) {
  152. $this->_objId = $objId;
  153. }
  154. }
  155. ?>