*prechod na novsiu verziu ZF
[sport-group.git] / library / Zend / Pdf / Element / Object.php
blob04e96dd1ee6b5065b6b3b543cc90fb503496c6d9
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
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: Object.php 17182 2009-07-27 13:54:11Z alexander $
23 /** Zend_Pdf_Element */
24 require_once 'Zend/Pdf/Element.php';
26 /** Zend_Pdf_ElementFactory */
27 require_once 'Zend/Pdf/ElementFactory.php';
30 /**
31 * PDF file 'indirect object' element implementation
33 * @category Zend
34 * @package Zend_Pdf
35 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
36 * @license http://framework.zend.com/license/new-bsd New BSD License
38 class Zend_Pdf_Element_Object extends Zend_Pdf_Element
40 /**
41 * Object value
43 * @var Zend_Pdf_Element
45 protected $_value;
47 /**
48 * Object number within PDF file
50 * @var integer
52 protected $_objNum;
54 /**
55 * Generation number
57 * @var integer
59 protected $_genNum;
61 /**
62 * Reference to the factory.
64 * @var Zend_Pdf_ElementFactory
66 protected $_factory;
68 /**
69 * Object constructor
71 * @param Zend_Pdf_Element $val
72 * @param integer $objNum
73 * @param integer $genNum
74 * @param Zend_Pdf_ElementFactory $factory
75 * @throws Zend_Pdf_Exception
77 public function __construct(Zend_Pdf_Element $val, $objNum, $genNum, Zend_Pdf_ElementFactory $factory)
79 if ($val instanceof self) {
80 throw new Zend_Pdf_Exception('Object number must not be an instance of Zend_Pdf_Element_Object.');
83 if ( !(is_integer($objNum) && $objNum > 0) ) {
84 throw new Zend_Pdf_Exception('Object number must be positive integer.');
87 if ( !(is_integer($genNum) && $genNum >= 0) ) {
88 throw new Zend_Pdf_Exception('Generation number must be non-negative integer.');
91 $this->_value = $val;
92 $this->_objNum = $objNum;
93 $this->_genNum = $genNum;
94 $this->_factory = $factory;
96 $this->setParentObject($this);
98 $factory->registerObject($this, $objNum . ' ' . $genNum);
103 * Check, that object is generated by specified factory
105 * @return Zend_Pdf_ElementFactory
107 public function getFactory()
109 return $this->_factory;
113 * Return type of the element.
115 * @return integer
117 public function getType()
119 return $this->_value->getType();
124 * Get object number
126 * @return integer
128 public function getObjNum()
130 return $this->_objNum;
135 * Get generation number
137 * @return integer
139 public function getGenNum()
141 return $this->_genNum;
146 * Return reference to the object
148 * @param Zend_Pdf_Factory $factory
149 * @return string
151 public function toString($factory = null)
153 if ($factory === null) {
154 $shift = 0;
155 } else {
156 $shift = $factory->getEnumerationShift($this->_factory);
159 return $this->_objNum + $shift . ' ' . $this->_genNum . ' R';
164 * Dump object to a string to save within PDF file.
166 * $factory parameter defines operation context.
168 * @param Zend_Pdf_ElementFactory $factory
169 * @return string
171 public function dump(Zend_Pdf_ElementFactory $factory)
173 $shift = $factory->getEnumerationShift($this->_factory);
175 return $this->_objNum + $shift . " " . $this->_genNum . " obj \n"
176 . $this->_value->toString($factory) . "\n"
177 . "endobj\n";
181 * Get handler
183 * @param string $property
184 * @return mixed
186 public function __get($property)
188 return $this->_value->$property;
192 * Set handler
194 * @param string $property
195 * @param mixed $value
197 public function __set($property, $value)
199 $this->_value->$property = $value;
203 * Call handler
205 * @param string $method
206 * @param array $args
207 * @return mixed
209 public function __call($method, $args)
211 return call_user_func_array(array($this->_value, $method), $args);
216 * Mark object as modified, to include it into new PDF file segment
218 public function touch()
220 $this->_factory->markAsModified($this);
224 * Return object, which can be used to identify object and its references identity
226 * @return Zend_Pdf_Element_Object
228 public function getObject()
230 return $this;
234 * Clean up resources, used by object
236 public function cleanUp()
238 $this->_value = null;
242 * Convert PDF element to PHP type.
244 * @return mixed
246 public function toPhp()
248 return $this->_value->toPhp();