| 1 | package Text::PDF::Array; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use vars qw(@ISA); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | # no warnings qw(uninitialized); | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Text::PDF::Objind; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | @ISA = qw(Text::PDF::Objind); | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | Text::PDF::Array - Corresponds to a PDF array. Inherits from L<PDF::Objind> | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 INSTANCE VARIABLES | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | This object is not an array but an associative array containing the array of | ||||||||||||||||||||||||||||
| 17 | elements. Thus, there are special instance variables for an array object, beginning | ||||||||||||||||||||||||||||
| 18 | with a space | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | =over | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =item var | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | Contains the actual array of elements | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =back | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =head1 METHODS | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =head2 PDF::Array->new($parent, @vals) | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | Creates an array with the given storage parent and an optional list of values to | ||||||||||||||||||||||||||||
| 33 | initialise the array with. | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | =cut | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | sub new | ||||||||||||||||||||||||||||
| 38 | { | ||||||||||||||||||||||||||||
| 39 | 5 | ▶ | my ($class, @vals) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 40 | 5 | my ($self); | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 5 | $self->{' val'} = [@vals]; | |||||||||||||||||||||||||||
| 43 | 5 | $self->{' realised'} = 1; | |||||||||||||||||||||||||||
| 44 | 5 | bless $self, $class; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =head2 $a->outobjdeep($fh, $pdf) | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | Outputs an array as a PDF array to the given filehandle. | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =cut | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | sub outobjdeep | ||||||||||||||||||||||||||||
| 55 | { | ||||||||||||||||||||||||||||
| 56 | 4 | ▶ | my ($self, $fh, $pdf, %opts) = @_; | ||||||||||||||||||||||||||
|
Subroutine
outobjdeep: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | 4 | my ($obj); | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 4 | $fh->print("[ "); | |||||||||||||||||||||||||||
| 60 | 4 | foreach $obj (@{$self->{' val'}}) | |||||||||||||||||||||||||||
| 61 | { | ||||||||||||||||||||||||||||
| 62 | 8 | $obj->outobj($fh, $pdf, %opts); | |||||||||||||||||||||||||||
| 63 | 8 | $fh->print(" "); | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | 4 | $fh->print("]"); | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =head2 $a->removeobj($elem) | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | Removes all occurrences of an element from an array. | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | =cut | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | sub removeobj | ||||||||||||||||||||||||||||
| 76 | { | ||||||||||||||||||||||||||||
| 77 | 0 | ▶ | my ($self, $elem) = @_; | ||||||||||||||||||||||||||
|
Subroutine
removeobj: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | $self->{' val'} = [grep($_ ne $elem, @{$self->{' val'}})]; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =head2 $a->elementsof | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | Returns a list of all the elements in the array. Notice that this is | ||||||||||||||||||||||||||||
| 86 | not the array itself but the elements in the array. | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =cut | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | sub elementsof | ||||||||||||||||||||||||||||
| 91 | 3 | ▶ | { wantarray ? @{$_[0]->{' val'}} : scalar @{$_[0]->{' val'}}; } | ||||||||||||||||||||||||||
|
Subroutine
elementsof: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =head2 $a->add_elements | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | Appends the given elements to the array. An element is only added if it | ||||||||||||||||||||||||||||
| 97 | is defined. | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =cut | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | sub add_elements | ||||||||||||||||||||||||||||
| 102 | { | ||||||||||||||||||||||||||||
| 103 | 7 | ▶ | my ($self) = shift; | ||||||||||||||||||||||||||
|
Subroutine
add_elements: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 104 | 7 | my ($e); | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 7 | foreach $e (@_) | |||||||||||||||||||||||||||
| 107 | 7 | ▶ | { push (@{$self->{' val'}}, $e) if defined $e; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | 7 | $self; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | =head2 $a->val | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | Returns the value of the array, this is a reference to the actual array | ||||||||||||||||||||||||||||
| 115 | containing the elements. | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | =cut | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | sub val | ||||||||||||||||||||||||||||
| 120 | 0 | ▶ | { $_[0]->{' val'}; } | ||||||||||||||||||||||||||
|
Subroutine
val: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | =head2 $d->copy($inpdf, $res, $unique, $outpdf, %opts) | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | Copies an object. See Text::PDF::Objind::Copy() for details | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | =cut | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | sub copy | ||||||||||||||||||||||||||||
| 130 | { | ||||||||||||||||||||||||||||
| 131 | 0 | ▶ | my ($self, $inpdf, $res, $unique, $outpdf, %opts) = @_; | ||||||||||||||||||||||||||
|
Subroutine
copy: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 132 | 0 | my ($i, $path); | |||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 0 | $res = $self->SUPER::copy($inpdf, $res, $unique, $outpdf, %opts); | |||||||||||||||||||||||||||
| 135 | 0 | $res->{' val'} = []; | |||||||||||||||||||||||||||
| 136 | 0 | $path = delete $opts{'path'}; | |||||||||||||||||||||||||||
| 137 | 0 | ▶ | for ($i = 0; $i < scalar @{$self->{' val'}}; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | { | ||||||||||||||||||||||||||||
| 139 | 0 | ▶ | if (UNIVERSAL::can($self->{'val'}[$i], "is_obj") && !grep {"$path\[$i\]" =~ m|$_|} @{$opts{'clip'}}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
UNIVERSAL::can($self->{"val"}[$i], "is_obj") and not grep({("${path}[$i]") =~ /$_/;} @{$opts{"clip"};})
MC/DC0%0/2
UNIVERSAL::can($self->{"val"}[$i], "is_obj") and not grep({("${path}[$i]") =~ /$_/;} @{$opts{"clip"};})
UNIVERSAL::can($self->{"val"}[$i], "is_obj")
not grep({("${path}[$i]") =~ /$_/;} @{$opts{"clip"};})
Truth table0%0/3
A and not(B)
A= UNIVERSAL::can($self->{"val"}[$i], "is_obj")B= not grep({("${path}[$i]") =~ /$_/;} @{$opts{"clip"};})
| |||||||||||||||||||||||||||||
| 140 | 0 | ▶ | { push (@{$res->{' val'}}, $self->{' val'}[$i]->realise->copy($inpdf, undef, $unique ? $unique + 1 : 0, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | $outpdf, %opts, 'path' => "$path\[$i\]")); } | ||||||||||||||||||||||||||||
| 142 | else | ||||||||||||||||||||||||||||
| 143 | 0 | { push (@{$res->{' val'}}, $self->{' val'}[$i]); } | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | 0 | $res->{' realised'} = 1; | |||||||||||||||||||||||||||
| 146 | 0 | $res; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 1 | 1; | |||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||