25 #require_once 'Zend/Pdf/Element.php'; 26 #require_once 'Zend/Pdf/Element/Array.php'; 27 #require_once 'Zend/Pdf/Element/Numeric.php'; 28 #require_once 'Zend/Pdf/Element/String.php'; 32 #require_once 'Zend/Pdf/Outline.php'; 69 if ($this->_outlineDictionary->Title ===
null) {
70 #require_once 'Zend/Pdf/Exception.php'; 73 return $this->_outlineDictionary->Title->value;
84 $this->_outlineDictionary->Title->touch();
97 parent::setIsOpen($isOpen);
99 if ($this->_outlineDictionary->Count ===
null) {
104 $childrenCount = $this->_outlineDictionary->Count->value;
105 $isOpenCurrentState = ($childrenCount > 0);
106 if ($isOpen != $isOpenCurrentState) {
107 $this->_outlineDictionary->Count->touch();
108 $this->_outlineDictionary->Count->value = ($isOpen? 1 : -1)*abs($childrenCount);
121 if ($this->_outlineDictionary->F ===
null) {
124 return $this->_outlineDictionary->F->value & 1;
135 if ($this->_outlineDictionary->F ===
null) {
136 $this->_outlineDictionary->touch();
139 $this->_outlineDictionary->F->touch();
141 $this->_outlineDictionary->F->value = $this->_outlineDictionary->F->value | 1;
143 $this->_outlineDictionary->F->value = $this->_outlineDictionary->F->value | ~1;
156 if ($this->_outlineDictionary->F ===
null) {
159 return $this->_outlineDictionary->F->value & 2;
170 if ($this->_outlineDictionary->F ===
null) {
171 $this->_outlineDictionary->touch();
174 $this->_outlineDictionary->F->touch();
176 $this->_outlineDictionary->F->value = $this->_outlineDictionary->F->value | 2;
178 $this->_outlineDictionary->F->value = $this->_outlineDictionary->F->value | ~2;
192 if ($this->_outlineDictionary->C ===
null) {
196 $components = $this->_outlineDictionary->C->items;
198 #require_once 'Zend/Pdf/Color/Rgb.php'; 211 $this->_outlineDictionary->touch();
213 if ($color ===
null) {
214 $this->_outlineDictionary->C =
null;
234 if ($this->_outlineDictionary->Dest !==
null) {
235 if ($this->_outlineDictionary->A !==
null) {
236 #require_once 'Zend/Pdf/Exception.php'; 237 throw new Zend_Pdf_Exception(
'Outline dictionary may contain Dest or A entry, but not both.');
240 #require_once 'Zend/Pdf/Destination.php'; 242 }
else if ($this->_outlineDictionary->A !==
null) {
243 #require_once 'Zend/Pdf/Action.php'; 260 $this->_outlineDictionary->touch();
263 #require_once 'Zend/Pdf/Destination/Named.php'; 268 $this->_outlineDictionary->Dest =
null;
269 $this->_outlineDictionary->A =
null;
271 $this->_outlineDictionary->Dest =
$target->getResource();
272 $this->_outlineDictionary->A =
null;
274 $this->_outlineDictionary->Dest =
null;
275 $this->_outlineDictionary->A =
$target->getResource();
277 #require_once 'Zend/Pdf/Exception.php'; 278 throw new Zend_Pdf_Exception(
'Outline target has to be Zend_Pdf_Destination or Zend_Pdf_Action object or string');
314 #require_once 'Zend/Pdf/Exception.php'; 318 if ($processedDictionaries ===
null) {
319 $processedDictionaries =
new SplObjectStorage();
321 $processedDictionaries->attach($dictionary);
323 $this->_outlineDictionary = $dictionary;
325 if ($dictionary->Count !==
null) {
327 #require_once 'Zend/Pdf/Exception.php'; 328 throw new Zend_Pdf_Exception(
'Outline dictionary Count entry must be a numeric element.');
331 $childOutlinesCount = $dictionary->Count->value;
332 if ($childOutlinesCount > 0) {
335 $childOutlinesCount = abs($childOutlinesCount);
337 $childDictionary = $dictionary->First;
340 while ($childDictionary !==
null) {
342 if (
$children->contains($childDictionary)) {
343 #require_once 'Zend/Pdf/Exception.php'; 347 if (!$processedDictionaries->contains($childDictionary)) {
351 $childDictionary = $childDictionary->Next;
376 SplObjectStorage $processedOutlines =
null)
378 if ($processedOutlines ===
null) {
379 $processedOutlines =
new SplObjectStorage();
381 $processedOutlines->attach($this);
383 if ($updateNavigation) {
384 $this->_outlineDictionary->touch();
386 $this->_outlineDictionary->Parent = $parent;
387 $this->_outlineDictionary->Prev = $prev;
388 $this->_outlineDictionary->Next =
null;
391 $updateChildNavigation =
false;
392 if (
count($this->_originalChildOutlines) !=
count($this->childOutlines)) {
394 $updateChildNavigation =
true;
395 }
else if ( !(array_keys($this->_originalChildOutlines) === array_keys($this->childOutlines)) ) {
397 $updateChildNavigation =
true;
399 foreach ($this->childOutlines as $key => $childOutline) {
400 if ($this->_originalChildOutlines[$key] !== $childOutline) {
401 $updateChildNavigation =
true;
408 if ($updateChildNavigation) {
409 $this->_outlineDictionary->
touch();
410 $this->_outlineDictionary->First =
null;
412 foreach ($this->childOutlines as $childOutline) {
413 if ($processedOutlines->contains($childOutline)) {
414 #require_once 'Zend/Pdf/Exception.php'; 418 if ($lastChild ===
null) {
420 $lastChild = $childOutline->dumpOutline(
$factory, $updateChildNavigation, $this->_outlineDictionary,
null, $processedOutlines);
421 $this->_outlineDictionary->First = $lastChild;
424 $childOutlineDictionary = $childOutline->dumpOutline(
$factory, $updateChildNavigation, $this->_outlineDictionary, $lastChild, $processedOutlines);
425 $lastChild->Next = $childOutlineDictionary;
426 $lastChild = $childOutlineDictionary;
430 $this->_outlineDictionary->Last = $lastChild;
432 if (
count($this->childOutlines) != 0) {
435 $this->_outlineDictionary->Count =
null;
438 foreach ($this->childOutlines as $childOutline) {
439 if ($processedOutlines->contains($childOutline)) {
440 #require_once 'Zend/Pdf/Exception.php'; 443 $lastChild = $childOutline->dumpOutline(
$factory, $updateChildNavigation, $this->_outlineDictionary, $lastChild, $processedOutlines);
450 public function dump($level = 0)
452 printf(
":%3d:%s:%s:%s%s :\n",
count($this->childOutlines),$this->
isItalic()?
'i':
' ', $this->
isBold()?
'b':
' ', str_pad(
'', 4*$level), $this->
getTitle());
454 if ($this->
isOpen() ||
true) {
455 foreach ($this->childOutlines as $child) {
456 $child->dump($level + 1);
setOptions(array $options)
__construct(Zend_Pdf_Element $dictionary, SplObjectStorage $processedDictionaries=null)
setColor(Zend_Pdf_Color_Rgb $color)
dumpOutline(Zend_Pdf_ElementFactory_Interface $factory, $updateNavigation, Zend_Pdf_Element $parent, Zend_Pdf_Element $prev=null, SplObjectStorage $processedOutlines=null)
static load(Zend_Pdf_Element $resource)
static load(Zend_Pdf_Element $dictionary, SplObjectStorage $processedActions=null)