Proxy.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Pdf
  17. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id$
  20. */
  21. /** Zend_Pdf_ElementFactory_Interface */
  22. require_once 'Zend/Pdf/ElementFactory/Interface.php';
  23. /**
  24. * PDF element factory interface.
  25. * Responsibility is to log PDF changes
  26. *
  27. * @package Zend_Pdf
  28. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. */
  31. class Zend_Pdf_ElementFactory_Proxy implements Zend_Pdf_ElementFactory_Interface
  32. {
  33. /**
  34. * Factory object
  35. *
  36. * @var Zend_Pdf_ElementFactory_Interface
  37. */
  38. private $_factory;
  39. /**
  40. * Object constructor
  41. *
  42. * @param Zend_Pdf_ElementFactory_Interface $factory
  43. */
  44. public function __construct(Zend_Pdf_ElementFactory_Interface $factory)
  45. {
  46. $this->_factory = $factory;
  47. }
  48. public function __destruct()
  49. {
  50. $this->_factory->close();
  51. $this->_factory = null;
  52. }
  53. /**
  54. * Close factory and clean-up resources
  55. *
  56. * @internal
  57. */
  58. public function close()
  59. {
  60. // Do nothing
  61. }
  62. /**
  63. * Get source factory object
  64. *
  65. * @return Zend_Pdf_ElementFactory
  66. */
  67. public function resolve()
  68. {
  69. return $this->_factory->resolve();
  70. }
  71. /**
  72. * Get factory ID
  73. *
  74. * @return integer
  75. */
  76. public function getId()
  77. {
  78. return $this->_factory->getId();
  79. }
  80. /**
  81. * Set object counter
  82. *
  83. * @param integer $objCount
  84. */
  85. public function setObjectCount($objCount)
  86. {
  87. $this->_factory->setObjectCount($objCount);
  88. }
  89. /**
  90. * Get object counter
  91. *
  92. * @return integer
  93. */
  94. public function getObjectCount()
  95. {
  96. return $this->_factory->getObjectCount();
  97. }
  98. /**
  99. * Attach factory to the current;
  100. *
  101. * @param Zend_Pdf_ElementFactory_Interface $factory
  102. */
  103. public function attach(Zend_Pdf_ElementFactory_Interface $factory)
  104. {
  105. $this->_factory->attach($factory);
  106. }
  107. /**
  108. * Calculate object enumeration shift.
  109. *
  110. * @internal
  111. * @param Zend_Pdf_ElementFactory_Interface $factory
  112. * @return integer
  113. */
  114. public function calculateShift(Zend_Pdf_ElementFactory_Interface $factory)
  115. {
  116. return $this->_factory->calculateShift($factory);
  117. }
  118. /**
  119. * Clean enumeration shift cache.
  120. * Has to be used after PDF render operation to let followed updates be correct.
  121. *
  122. * @param Zend_Pdf_ElementFactory_Interface $factory
  123. * @return integer
  124. */
  125. public function cleanEnumerationShiftCache()
  126. {
  127. return $this->_factory->cleanEnumerationShiftCache();
  128. }
  129. /**
  130. * Retrive object enumeration shift.
  131. *
  132. * @param Zend_Pdf_ElementFactory_Interface $factory
  133. * @return integer
  134. * @throws Zend_Pdf_Exception
  135. */
  136. public function getEnumerationShift(Zend_Pdf_ElementFactory_Interface $factory)
  137. {
  138. return $this->_factory->getEnumerationShift($factory);
  139. }
  140. /**
  141. * Mark object as modified in context of current factory.
  142. *
  143. * @param Zend_Pdf_Element_Object $obj
  144. * @throws Zend_Pdf_Exception
  145. */
  146. public function markAsModified(Zend_Pdf_Element_Object $obj)
  147. {
  148. $this->_factory->markAsModified($obj);
  149. }
  150. /**
  151. * Remove object in context of current factory.
  152. *
  153. * @param Zend_Pdf_Element_Object $obj
  154. * @throws Zend_Pdf_Exception
  155. */
  156. public function remove(Zend_Pdf_Element_Object $obj)
  157. {
  158. $this->_factory->remove($obj);
  159. }
  160. /**
  161. * Generate new Zend_Pdf_Element_Object
  162. *
  163. * @todo Reusage of the freed object. It's not a support of new feature, but only improvement.
  164. *
  165. * @param Zend_Pdf_Element $objectValue
  166. * @return Zend_Pdf_Element_Object
  167. */
  168. public function newObject(Zend_Pdf_Element $objectValue)
  169. {
  170. return $this->_factory->newObject($objectValue);
  171. }
  172. /**
  173. * Generate new Zend_Pdf_Element_Object_Stream
  174. *
  175. * @todo Reusage of the freed object. It's not a support of new feature, but only improvement.
  176. *
  177. * @param mixed $objectValue
  178. * @return Zend_Pdf_Element_Object_Stream
  179. */
  180. public function newStreamObject($streamValue)
  181. {
  182. return $this->_factory->newStreamObject($streamValue);
  183. }
  184. /**
  185. * Enumerate modified objects.
  186. * Returns array of Zend_Pdf_UpdateInfoContainer
  187. *
  188. * @param Zend_Pdf_ElementFactory $rootFactory
  189. * @return array
  190. */
  191. public function listModifiedObjects($rootFactory = null)
  192. {
  193. return $this->_factory->listModifiedObjects($rootFactory);
  194. }
  195. /**
  196. * Check if PDF file was modified
  197. *
  198. * @return boolean
  199. */
  200. public function isModified()
  201. {
  202. return $this->_factory->isModified();
  203. }
  204. }