24 #require_once 'Zend/Pdf/ElementFactory/Interface.php'; 44 private $_modifiedObjects = array();
53 private $_removedObjects;
63 private $_registeredObjects = array();
71 private $_objectCount;
80 private $_attachedFactories = array();
95 private static $_identity = 0;
103 private $_shiftCalculationCache = array();
113 $this->_objectCount = (int)$objCount;
114 $this->_factoryId = self::$_identity++;
115 $this->_removedObjects =
new SplObjectStorage();
137 #require_once 'Zend/Pdf/ElementFactory/Proxy.php'; 148 $this->_modifiedObjects =
null;
149 $this->_removedObjects =
null;
150 $this->_attachedFactories =
null;
152 foreach ($this->_registeredObjects as $obj) {
155 $this->_registeredObjects =
null;
175 return $this->_factoryId;
185 $this->_objectCount = (int)$objCount;
195 $count = $this->_objectCount;
197 foreach ($this->_attachedFactories as $attached) {
198 $count += $attached->getObjectCount() - 1;
212 if (
$factory === $this || isset($this->_attachedFactories[
$factory->getId()])) {
238 if (isset($this->_shiftCalculationCache[
$factory->_factoryId])) {
239 return $this->_shiftCalculationCache[
$factory->_factoryId];
242 $shift = $this->_objectCount - 1;
244 foreach ($this->_attachedFactories as $subFactory) {
245 $subFactoryShift = $subFactory->calculateShift(
$factory);
247 if ($subFactoryShift != -1) {
249 $this->_shiftCalculationCache[
$factory->_factoryId] = $shift + $subFactoryShift;
250 return $shift + $subFactoryShift;
252 $shift += $subFactory->getObjectCount()-1;
256 $this->_shiftCalculationCache[
$factory->_factoryId] = -1;
266 $this->_shiftCalculationCache = array();
268 foreach ($this->_attachedFactories as $attached) {
269 $attached->cleanEnumerationShiftCache();
283 #require_once 'Zend/Pdf/Exception.php'; 299 #require_once 'Zend/Pdf/Exception.php'; 303 $this->_modifiedObjects[$obj->
getObjNum()] = $obj;
315 if (!$obj->compareFactory($this)) {
316 #require_once 'Zend/Pdf/Exception.php'; 320 $this->_modifiedObjects[$obj->getObjNum()] = $obj;
321 $this->_removedObjects->attach($obj);
335 #require_once 'Zend/Pdf/Element/Object.php'; 337 $this->_modifiedObjects[$obj->getObjNum()] = $obj;
351 #require_once 'Zend/Pdf/Element/Object/Stream.php'; 353 $this->_modifiedObjects[$obj->getObjNum()] = $obj;
367 if ($rootFactory ==
null) {
368 $rootFactory = $this;
371 $shift = $rootFactory->getEnumerationShift($this);
374 ksort($this->_modifiedObjects);
377 #require_once 'Zend/Pdf/UpdateInfoContainer.php'; 378 foreach ($this->_modifiedObjects as $objNum => $obj) {
379 if ($this->_removedObjects->contains($obj)) {
387 $obj->dump($rootFactory));
391 foreach ($this->_attachedFactories as
$factory) {
408 $this->_registeredObjects[$refString] = $obj;
419 if (!isset($this->_registeredObjects[$refString])) {
422 return $this->_registeredObjects[$refString];
433 if (count($this->_modifiedObjects) != 0) {
437 foreach ($this->_attachedFactories as $subFactory) {
438 if ($subFactory->isModified()) {
calculateShift(Zend_Pdf_ElementFactory_Interface $factory)
setObjectCount($objCount)
newObject(Zend_Pdf_Element $objectValue)
listModifiedObjects($rootFactory=null)
attach(Zend_Pdf_ElementFactory_Interface $factory)
newStreamObject($streamValue)
cleanEnumerationShiftCache()
markAsModified(Zend_Pdf_Element_Object $obj)
getEnumerationShift(Zend_Pdf_ElementFactory_Interface $factory)
registerObject(Zend_Pdf_Element_Object $obj, $refString)
static createFactory($objCount)