| 1 | package PDF::Builder::Resource; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 39 | ▶ | use base 'PDF::Builder::Basic::PDF::Dict'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 39 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 39 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 39 | our $VERSION = '3.028'; # VERSION | |||||||||||||||||||||||||||
| 9 | 39 | our $LAST_UPDATE = '3.027'; # manually update whenever code is changed | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 39 | ▶ | use PDF::Builder::Util qw(pdfkey); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 39 | ▶ | use PDF::Builder::Basic::PDF::Utils; # PDFName | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 39 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | =head1 NAME | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | PDF::Builder::Resource - Base class for PDF resources | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | Inherits from L<PDF::Builder::Basic::PDF::Dict> | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =head1 METHODS | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =head2 new | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | $resource = PDF::Builder::Resource->new($pdf, $name) | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =over | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | Returns a resource object. | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =back | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =cut | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 68 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||
| 37 | 68 | my ($class, $pdf, $name) = @_; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 68 | ▶ | $class = ref($class) if ref($class); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 68 | my $self = $class->SUPER::new(); | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 68 | ▶ | $pdf->new_obj($self) unless $self->is_obj($pdf); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 68 | ▶ | $self->name($name or pdfkey()); | ||||||||||||||||||||||||||
|
Condition66%2/3
$name || pdfkey()
MC/DC0%0/2
$name || pdfkey()
$name
pdfkey()
Truth table66%2/3
A || B
A= $nameB= pdfkey()
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 68 | $self->{' apipdf'} = $pdf; | |||||||||||||||||||||||||||
| 48 | 68 | weaken $self->{' apipdf'}; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 68 | return $self; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | # Note: new_api() removed in favor of new(): | ||||||||||||||||||||||||||||
| 54 | # new_api($api, ...) replace with new($api->{'pdf'}, ...) | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =head2 name | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | $name = $resource->name() # Get | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | $resource->name($name) # Set | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =over | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | Get or set the name of the resource. | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | =back | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =cut | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 130 | ▶ | sub name { | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 71 | 130 | my $self = shift @_; | |||||||||||||||||||||||||||
| 72 | 130 | ▶ | if (scalar @_ and defined $_[0]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
scalar @_ and defined $_[0]
MC/DC50%1/2
scalar @_ and defined $_[0]
scalar @_
defined $_[0]
Truth table66%2/3
A and B
A= scalar @_B= defined $_[0]
| |||||||||||||||||||||||||||||
| 73 | 68 | $self->{'Name'} = PDFName($_[0]); | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | 130 | return $self->{'Name'}->val(); | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | #sub outobjdeep { | ||||||||||||||||||||||||||||
| 79 | # my ($self, $fh, $pdf, %options) = @_; | ||||||||||||||||||||||||||||
| 80 | # | ||||||||||||||||||||||||||||
| 81 | # delete $self->{' api'}; | ||||||||||||||||||||||||||||
| 82 | # delete $self->{' apipdf'}; | ||||||||||||||||||||||||||||
| 83 | # return $self->SUPER::outobjdeep($fh, $pdf, %options); | ||||||||||||||||||||||||||||
| 84 | #} | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 39 | 1; | |||||||||||||||||||||||||||