Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Zend_Pdf_Outline_Loaded Class Reference
Inheritance diagram for Zend_Pdf_Outline_Loaded:
Zend_Pdf_Outline

Public Member Functions

 getTitle ()
 
 setTitle ($title)
 
 setIsOpen ($isOpen)
 
 isItalic ()
 
 setIsItalic ($isItalic)
 
 isBold ()
 
 setIsBold ($isBold)
 
 getColor ()
 
 setColor (Zend_Pdf_Color_Rgb $color)
 
 getTarget ()
 
 setTarget ($target=null)
 
 setOptions (array $options)
 
 __construct (Zend_Pdf_Element $dictionary, SplObjectStorage $processedDictionaries=null)
 
 dumpOutline (Zend_Pdf_ElementFactory_Interface $factory, $updateNavigation, Zend_Pdf_Element $parent, Zend_Pdf_Element $prev=null, SplObjectStorage $processedOutlines=null)
 
 dump ($level=0)
 
- Public Member Functions inherited from Zend_Pdf_Outline
 getTitle ()
 
 setTitle ($title)
 
 isOpen ()
 
 setIsOpen ($isOpen)
 
 isItalic ()
 
 setIsItalic ($isItalic)
 
 isBold ()
 
 setIsBold ($isBold)
 
 getColor ()
 
 setColor (Zend_Pdf_Color_Rgb $color)
 
 getTarget ()
 
 setTarget ($target=null)
 
 getOptions ()
 
 setOptions (array $options)
 
 openOutlinesCount ()
 
 dumpOutline (Zend_Pdf_ElementFactory_Interface $factory, $updateNavigation, Zend_Pdf_Element $parent, Zend_Pdf_Element $prev=null, SplObjectStorage $processedOutlines=null)
 
 current ()
 
 key ()
 
 next ()
 
 rewind ()
 
 valid ()
 
 getChildren ()
 
 hasChildren ()
 
 count ()
 

Protected Attributes

 $_outlineDictionary
 
 $_originalChildOutlines = array()
 
- Protected Attributes inherited from Zend_Pdf_Outline
 $_open = false
 

Additional Inherited Members

- Static Public Member Functions inherited from Zend_Pdf_Outline
static create ($param1, $param2=null)
 
- Data Fields inherited from Zend_Pdf_Outline
 $childOutlines = array()
 

Detailed Description

Definition at line 45 of file Loaded.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Zend_Pdf_Element  $dictionary,
SplObjectStorage  $processedDictionaries = null 
)

Create PDF outline object using specified dictionary

Definition at line 311 of file Loaded.php.

312  {
313  if ($dictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
314  #require_once 'Zend/Pdf/Exception.php';
315  throw new Zend_Pdf_Exception('$dictionary mast be an indirect dictionary object.');
316  }
317 
318  if ($processedDictionaries === null) {
319  $processedDictionaries = new SplObjectStorage();
320  }
321  $processedDictionaries->attach($dictionary);
322 
323  $this->_outlineDictionary = $dictionary;
324 
325  if ($dictionary->Count !== null) {
326  if ($dictionary->Count->getType() != Zend_Pdf_Element::TYPE_NUMERIC) {
327  #require_once 'Zend/Pdf/Exception.php';
328  throw new Zend_Pdf_Exception('Outline dictionary Count entry must be a numeric element.');
329  }
330 
331  $childOutlinesCount = $dictionary->Count->value;
332  if ($childOutlinesCount > 0) {
333  $this->_open = true;
334  }
335  $childOutlinesCount = abs($childOutlinesCount);
336 
337  $childDictionary = $dictionary->First;
338 
339  $children = new SplObjectStorage();
340  while ($childDictionary !== null) {
341  // Check children structure for cyclic references
342  if ($children->contains($childDictionary)) {
343  #require_once 'Zend/Pdf/Exception.php';
344  throw new Zend_Pdf_Exception('Outline childs load error.');
345  }
346 
347  if (!$processedDictionaries->contains($childDictionary)) {
348  $this->childOutlines[] = new Zend_Pdf_Outline_Loaded($childDictionary, $processedDictionaries);
349  }
350 
351  $childDictionary = $childDictionary->Next;
352  }
353 
354  $this->_originalChildOutlines = $this->childOutlines;
355  }
356  }
const TYPE_NUMERIC
Definition: Element.php:33
const TYPE_DICTIONARY
Definition: Element.php:37
$children
Definition: actions.phtml:11

Member Function Documentation

◆ dump()

dump (   $level = 0)

Definition at line 450 of file Loaded.php.

451  {
452  printf(":%3d:%s:%s:%s%s :\n", count($this->childOutlines),$this->isItalic()? 'i':' ', $this->isBold()? 'b':' ', str_pad('', 4*$level), $this->getTitle());
453 
454  if ($this->isOpen() || true) {
455  foreach ($this->childOutlines as $child) {
456  $child->dump($level + 1);
457  }
458  }
459  }

◆ dumpOutline()

dumpOutline ( Zend_Pdf_ElementFactory_Interface  $factory,
  $updateNavigation,
Zend_Pdf_Element  $parent,
Zend_Pdf_Element  $prev = null,
SplObjectStorage  $processedOutlines = null 
)

Dump Outline and its child outlines into PDF structures

Returns dictionary indirect object or reference

Definition at line 372 of file Loaded.php.

377  {
378  if ($processedOutlines === null) {
379  $processedOutlines = new SplObjectStorage();
380  }
381  $processedOutlines->attach($this);
382 
383  if ($updateNavigation) {
384  $this->_outlineDictionary->touch();
385 
386  $this->_outlineDictionary->Parent = $parent;
387  $this->_outlineDictionary->Prev = $prev;
388  $this->_outlineDictionary->Next = null;
389  }
390 
391  $updateChildNavigation = false;
392  if (count($this->_originalChildOutlines) != count($this->childOutlines)) {
393  // If original and current children arrays have different size then children list was updated
394  $updateChildNavigation = true;
395  } else if ( !(array_keys($this->_originalChildOutlines) === array_keys($this->childOutlines)) ) {
396  // If original and current children arrays have different keys (with a glance to an order) then children list was updated
397  $updateChildNavigation = true;
398  } else {
399  foreach ($this->childOutlines as $key => $childOutline) {
400  if ($this->_originalChildOutlines[$key] !== $childOutline) {
401  $updateChildNavigation = true;
402  break;
403  }
404  }
405  }
406 
407  $lastChild = null;
408  if ($updateChildNavigation) {
409  $this->_outlineDictionary->touch();
410  $this->_outlineDictionary->First = null;
411 
412  foreach ($this->childOutlines as $childOutline) {
413  if ($processedOutlines->contains($childOutline)) {
414  #require_once 'Zend/Pdf/Exception.php';
415  throw new Zend_Pdf_Exception('Outlines cyclyc reference is detected.');
416  }
417 
418  if ($lastChild === null) {
419  // First pass. Update Outlines dictionary First entry using corresponding value
420  $lastChild = $childOutline->dumpOutline($factory, $updateChildNavigation, $this->_outlineDictionary, null, $processedOutlines);
421  $this->_outlineDictionary->First = $lastChild;
422  } else {
423  // Update previous outline dictionary Next entry (Prev is updated within dumpOutline() method)
424  $childOutlineDictionary = $childOutline->dumpOutline($factory, $updateChildNavigation, $this->_outlineDictionary, $lastChild, $processedOutlines);
425  $lastChild->Next = $childOutlineDictionary;
426  $lastChild = $childOutlineDictionary;
427  }
428  }
429 
430  $this->_outlineDictionary->Last = $lastChild;
431 
432  if (count($this->childOutlines) != 0) {
433  $this->_outlineDictionary->Count = new Zend_Pdf_Element_Numeric(($this->isOpen()? 1 : -1)*count($this->childOutlines));
434  } else {
435  $this->_outlineDictionary->Count = null;
436  }
437  } else {
438  foreach ($this->childOutlines as $childOutline) {
439  if ($processedOutlines->contains($childOutline)) {
440  #require_once 'Zend/Pdf/Exception.php';
441  throw new Zend_Pdf_Exception('Outlines cyclyc reference is detected.');
442  }
443  $lastChild = $childOutline->dumpOutline($factory, $updateChildNavigation, $this->_outlineDictionary, $lastChild, $processedOutlines);
444  }
445  }
446 
448  }

◆ getColor()

getColor ( )

Get outline text color.

Returns
Zend_Pdf_Color_Rgb

Definition at line 190 of file Loaded.php.

191  {
192  if ($this->_outlineDictionary->C === null) {
193  return null;
194  }
195 
196  $components = $this->_outlineDictionary->C->items;
197 
198  #require_once 'Zend/Pdf/Color/Rgb.php';
199  return new Zend_Pdf_Color_Rgb($components[0], $components[1], $components[2]);
200  }

◆ getTarget()

getTarget ( )

Get outline target.

Returns
Zend_Pdf_Target
Exceptions
Zend_Pdf_Exception

Definition at line 232 of file Loaded.php.

233  {
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.');
238  }
239 
240  #require_once 'Zend/Pdf/Destination.php';
241  return Zend_Pdf_Destination::load($this->_outlineDictionary->Dest);
242  } else if ($this->_outlineDictionary->A !== null) {
243  #require_once 'Zend/Pdf/Action.php';
244  return Zend_Pdf_Action::load($this->_outlineDictionary->A);
245  }
246 
247  return null;
248  }
static load(Zend_Pdf_Element $resource)
Definition: Destination.php:49
static load(Zend_Pdf_Element $dictionary, SplObjectStorage $processedActions=null)
Definition: Action.php:115

◆ getTitle()

getTitle ( )

Get outline title.

Returns
string
Exceptions
Zend_Pdf_Exception

Definition at line 67 of file Loaded.php.

68  {
69  if ($this->_outlineDictionary->Title === null) {
70  #require_once 'Zend/Pdf/Exception.php';
71  throw new Zend_Pdf_Exception('Outline dictionary Title entry is required.');
72  }
73  return $this->_outlineDictionary->Title->value;
74  }

◆ isBold()

isBold ( )

Returns true if outline item is displayed in bold

Returns
boolean

Definition at line 154 of file Loaded.php.

155  {
156  if ($this->_outlineDictionary->F === null) {
157  return false;
158  }
159  return $this->_outlineDictionary->F->value & 2;
160  }

◆ isItalic()

isItalic ( )

Returns true if outline item is displayed in italic

Returns
boolean

Definition at line 119 of file Loaded.php.

120  {
121  if ($this->_outlineDictionary->F === null) {
122  return false;
123  }
124  return $this->_outlineDictionary->F->value & 1;
125  }

◆ setColor()

setColor ( Zend_Pdf_Color_Rgb  $color)

Set outline text color. (null means default color which is black)

Parameters
Zend_Pdf_Color_Rgb$color
Returns
Zend_Pdf_Outline

Definition at line 209 of file Loaded.php.

210  {
211  $this->_outlineDictionary->touch();
212 
213  if ($color === null) {
214  $this->_outlineDictionary->C = null;
215  } else {
216  $components = $color->getComponents();
217  $colorComponentElements = array(new Zend_Pdf_Element_Numeric($components[0]),
218  new Zend_Pdf_Element_Numeric($components[1]),
219  new Zend_Pdf_Element_Numeric($components[2]));
220  $this->_outlineDictionary->C = new Zend_Pdf_Element_Array($colorComponentElements);
221  }
222 
223  return $this;
224  }

◆ setIsBold()

setIsBold (   $isBold)

Sets 'isBold' outline flag

Parameters
boolean$isBold
Returns
Zend_Pdf_Outline

Definition at line 168 of file Loaded.php.

169  {
170  if ($this->_outlineDictionary->F === null) {
171  $this->_outlineDictionary->touch();
172  $this->_outlineDictionary->F = new Zend_Pdf_Element_Numeric($isBold? 2 : 0);
173  } else {
174  $this->_outlineDictionary->F->touch();
175  if ($isBold) {
176  $this->_outlineDictionary->F->value = $this->_outlineDictionary->F->value | 2;
177  } else {
178  $this->_outlineDictionary->F->value = $this->_outlineDictionary->F->value | ~2;
179  }
180  }
181  return $this;
182  }

◆ setIsItalic()

setIsItalic (   $isItalic)

Sets 'isItalic' outline flag

Parameters
boolean$isItalic
Returns
Zend_Pdf_Outline

Definition at line 133 of file Loaded.php.

134  {
135  if ($this->_outlineDictionary->F === null) {
136  $this->_outlineDictionary->touch();
137  $this->_outlineDictionary->F = new Zend_Pdf_Element_Numeric($isItalic? 1 : 0);
138  } else {
139  $this->_outlineDictionary->F->touch();
140  if ($isItalic) {
141  $this->_outlineDictionary->F->value = $this->_outlineDictionary->F->value | 1;
142  } else {
143  $this->_outlineDictionary->F->value = $this->_outlineDictionary->F->value | ~1;
144  }
145  }
146  return $this;
147  }

◆ setIsOpen()

setIsOpen (   $isOpen)

Sets 'isOpen' outline flag

Parameters
boolean$isOpen
Returns
Zend_Pdf_Outline

Definition at line 95 of file Loaded.php.

96  {
97  parent::setIsOpen($isOpen);
98 
99  if ($this->_outlineDictionary->Count === null) {
100  // Do Nothing.
101  return this;
102  }
103 
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);
109  }
110 
111  return $this;
112  }

◆ setOptions()

setOptions ( array  $options)

Set outline options

Parameters
array$options
Returns
Zend_Pdf_Actions_Traceable
Exceptions
Zend_Pdf_Exception

Definition at line 291 of file Loaded.php.

292  {
293  parent::setOptions($options);
294 
295  return $this;
296  }

◆ setTarget()

setTarget (   $target = null)

Set outline target. Null means no target

Parameters
Zend_Pdf_Target | string$target
Returns
Zend_Pdf_Outline
Exceptions
Zend_Pdf_Exception

Definition at line 258 of file Loaded.php.

259  {
260  $this->_outlineDictionary->touch();
261 
262  if (is_string($target)) {
263  #require_once 'Zend/Pdf/Destination/Named.php';
265  }
266 
267  if ($target === null) {
268  $this->_outlineDictionary->Dest = null;
269  $this->_outlineDictionary->A = null;
270  } else if ($target instanceof Zend_Pdf_Destination) {
271  $this->_outlineDictionary->Dest = $target->getResource();
272  $this->_outlineDictionary->A = null;
273  } else if ($target instanceof Zend_Pdf_Action) {
274  $this->_outlineDictionary->Dest = null;
275  $this->_outlineDictionary->A = $target->getResource();
276  } else {
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');
279  }
280 
281  return $this;
282  }
$target
Definition: skip.phtml:8
static create($name)
Definition: Named.php:76

◆ setTitle()

setTitle (   $title)

Set outline title

Parameters
string$title
Returns
Zend_Pdf_Outline

Definition at line 82 of file Loaded.php.

83  {
84  $this->_outlineDictionary->Title->touch();
85  $this->_outlineDictionary->Title = new Zend_Pdf_Element_String($title);
86  return $this;
87  }
$title
Definition: default.phtml:14

Field Documentation

◆ $_originalChildOutlines

$_originalChildOutlines = array()
protected

Definition at line 59 of file Loaded.php.

◆ $_outlineDictionary

$_outlineDictionary
protected

Definition at line 52 of file Loaded.php.


The documentation for this class was generated from the following file: