blib/lib/PDF/Make/Builder/Page/HeaderFooterContext.pm

filter: Statementstmt 100% 169 / 169 Branchbran 91.1% 62 / 68 Conditioncond 71.4% 80 / 112 MC/DCmcdc 28.5% 18 / 63 Subroutinesub 100% 23 / 23 Podpod 100% 15 / 15 totaltotal 81.5% 367 / 450 CC 79 SCAR 21.9
CC
79
Cov
89%
line
14.3
image
13.0
page_num
11.0
CRAP 8.9
« blib/lib/PDF/Make/Builder/Form/Field/Button.pm ↑ Summary blib/lib/PDF/Make/Builder/Form/Field.pm »
1 package PDF::Make::Builder::Page::HeaderFooterContext;
2 53 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 53 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 53 ▶use Object::Proto;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 53 ▶use PDF::Make::Builder::Font;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 53 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 53 Object::Proto::define('PDF::Make::Builder::Page::HeaderFooterContext',
9 'builder:Any:required',
10 'page:Any:required',
11 'canvas:Any:required',
12 'x0:Num:required',
13 'y0:Num:required',
14 'w:Num:required',
15 'h:Num:required',
16 'padding:Num:default(20)',
17 'num:Int:default(0)',
18 'role:Str:default(header)',
19 );
20 53 Object::Proto::import_accessors('PDF::Make::Builder::Page::HeaderFooterContext');
21 }
22  
23 # ── Region accessors ──────────────────────────────────────
24  
25 32 ▶sub left { my $s = shift; x0 $s }
Subroutine left: called CC=1 SCAR=0.0
Pod documented
26 12 ▶sub right { my $s = shift; x0($s) + w($s) }
Subroutine right: called CC=1 SCAR=0.0
Pod documented
27 31 ▶sub bottom { my $s = shift; y0 $s }
Subroutine bottom: called CC=1 SCAR=0.0
Pod documented
28 17 ▶sub top { my $s = shift; y0($s) + h($s) }
Subroutine top: called CC=1 SCAR=0.0
Pod documented
29 6 ▶sub center_x { my $s = shift; x0($s) + w($s) / 2 }
Subroutine center_x: called CC=1 SCAR=0.0
Pod documented
30 1 ▶sub center_y { my $s = shift; y0($s) + h($s) / 2 }
Subroutine center_y: called CC=1 SCAR=0.0
Pod documented
31  
32 1 ▶sub baseline {
Subroutine baseline: called CC=2 SCAR=7.1
Pod documented
33 1 my ($self, $offset) = @_;
34 1 ▶ $offset //= 0;
Condition50%1/2
$offset //= 0
l!l
10
MC/DC0%0/1
$offset //= 0
$offset
Truth table50%1/2
A
A= $offset
Aresult
11
00
35 1 return y0($self) + $offset;
36 }
37  
38 1 ▶sub inset {
Subroutine inset: called CC=2 SCAR=7.1
Pod documented
39 1 my ($self, $dx, $dy) = @_;
40 1 ▶ $dy = $dx unless defined $dy;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dy 1 0 1
41 1 return (x0($self) + $dx, y0($self) + $dy,
42 w($self) - 2 * $dx, h($self) - 2 * $dy);
43 }
44  
45 # ── Font helpers ──────────────────────────────────────────
46  
47 12 ▶sub _font {
Subroutine _font: called CC=8 SCAR=22.0
48 12 my ($self, $override) = @_;
49 12 my $base = $self->builder->font;
50 12 ▶ return $base unless $override;
Branch: 1 branch
BranchTrueFalseTotal
unless $override 3 9 12
51 return PDF::Make::Builder::Font->new(
52 colour => $override->{colour} // $base->colour,
53 size => $override->{size} // $base->size,
54 family => $override->{family} // $base->family,
55 bold => $override->{bold} // $base->bold,
56 italic => $override->{italic} // $base->italic,
57 9 ▶ line_height => $override->{line_height} // $base->effective_line_height,
Condition66%12/18
$override->{"colour"} // $base->colour
l!l&&r!l&&!r
540
$override->{"size"} // $base->size
l!l&&r!l&&!r
540
$override->{"family"} // $base->family
l!l&&r!l&&!r
270
$override->{"bold"} // $base->bold
l!l&&r!l&&!r
270
$override->{"italic"} // $base->italic
l!l&&r!l&&!r
270
$override->{"line_height"} // $base->effective_line_height
l!l&&r!l&&!r
180
MC/DC0%0/2
$override->{"colour"} // $base->colour
$override->{"colour"} $base->colour
MC/DC0%0/2
$override->{"size"} // $base->size
$override->{"size"} $base->size
MC/DC0%0/2
$override->{"family"} // $base->family
$override->{"family"} $base->family
MC/DC0%0/2
$override->{"bold"} // $base->bold
$override->{"bold"} $base->bold
MC/DC0%0/2
$override->{"italic"} // $base->italic
$override->{"italic"} $base->italic
MC/DC0%0/2
$override->{"line_height"} // $base->effective_line_height
$override->{"line_height"} $base->effective_line_height
Truth table66%2/3
A // B
A= $override->{"colour"}B= $base->colour
ABresult
1X1
011
000
Truth table66%2/3
A // B
A= $override->{"size"}B= $base->size
ABresult
1X1
011
000
Truth table66%2/3
A // B
A= $override->{"family"}B= $base->family
ABresult
1X1
011
000
Truth table66%2/3
A // B
A= $override->{"bold"}B= $base->bold
ABresult
1X1
011
000
Truth table66%2/3
A // B
A= $override->{"italic"}B= $base->italic
ABresult
1X1
011
000
Truth table66%2/3
A // B
A= $override->{"line_height"}B= $base->effective_line_height
ABresult
1X1
011
000
58 registry => $base->registry,
59 );
60 }
61  
62 12 ▶sub _default_baseline_y {
Subroutine _default_baseline_y: called CC=2 SCAR=6.9
63 12 my ($self, $font_size) = @_;
64 12 ▶ if ($self->role eq 'footer') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->role eq "footer") 6 6 12
65 6 return $self->bottom + 4;
66 }
67 6 return $self->top - $font_size;
68 }
69  
70 # ── Text ──────────────────────────────────────────────────
71  
72 13 ▶sub text {
Subroutine text: called CC=9 SCAR=22.0
Pod documented
73 13 my ($self, %args) = @_;
74 13 my $txt = $args{text};
75 13 ▶ return $self unless defined $txt && length $txt;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $txt and length $txt 1 12 13
Condition66%2/3
defined $txt and length $txt
!ll&&!rl&&r
0112
MC/DC50%1/2
defined $txt and length $txt
defined $txt length $txt
Truth table66%2/3
A and B
A= defined $txtB= length $txt
ABresult
0X0
100
111
76  
77 12 my $font = $self->_font($args{font});
78 12 my $size = $font->size;
79 12 my $res = $font->ensure_loaded($self->page->xs_page);
80 12 my ($r, $g, $b) = $font->hex_to_rgb($font->colour);
81  
82 12 my $tw = $font->measure_text($txt);
83  
84 12 ▶ my $align = $args{align} // 'left';
Condition100%2/2
$args{"align"} // "left"
l!l
111
MC/DC100%1/1
$args{"align"} // "left"
$args{"align"}
Truth table100%2/2
A
A= $args{"align"}
Aresult
11
00
85 12 ▶ my $pad = defined $args{padding} ? $args{padding} : $self->padding;
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'padding'} ? : 1 11 12
86  
87 12 my $x = $args{x};
88 12 ▶ if (!defined $x) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $x) 12 0 12
89 12 ▶ if ($align eq 'right') { $x = $self->right - $pad - $tw }
Branch: 2 branches
BranchTrueFalseTotal
if ($align eq 'right') { } 2 10 12
elsif ($align eq 'center') { } 3 7 10
90 3 elsif ($align eq 'center') { $x = $self->center_x - $tw / 2 }
91 7 else { $x = $self->left + $pad }
92 }
93  
94 12 my $y = $args{y};
95 12 ▶ $y = $self->_default_baseline_y($size) unless defined $y;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $y 12 0 12
96  
97 12 my $tj = $font->show_op;
98 12 $self->canvas->BT
99 ->rg($r, $g, $b)
100 ->Tf($res, $size)
101 ->Tm(1, 0, 0, 1, $x, $y)
102 ->$tj($font->encode($txt))
103 ->ET;
104 12 return $self;
105 }
106  
107 4 ▶sub page_num {
Subroutine page_num: called CC=11 SCAR=24.0
Pod documented
108 4 my ($self, %args) = @_;
109 4 ▶ my $format = $args{format} // $args{text} // 'Page {num}';
Condition100%5/5
($args{"format"} // $args{"text"}) // "Page {num}"
l!l
31
$args{"format"} // $args{"text"}
l!l&&r!l&&!r
211
MC/DC100%2/2
($args{"format"} // $args{"text"}) // "Page {num}"
$args{"format"} $args{"text"}
Truth table100%3/3
A // B
A= $args{"format"}B= $args{"text"}
ABresult
1X1
011
000
110 4 my $n = $self->num;
111 4 $format =~ s/\{num\}/$n/g;
112 4 ▶ if ($format =~ /\{total\}/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($format =~ /\{total\}/) 2 2 4
113 2 my $total = $self->builder->page_count;
114 2 $format =~ s/\{total\}/$total/g;
115 }
116  
117 4 ▶ my $font = $args{font} // {};
Condition100%2/2
$args{"font"} // {}
l!l
13
MC/DC100%1/1
$args{"font"} // {}
$args{"font"}
Truth table100%2/2
A
A= $args{"font"}
Aresult
11
00
118 my %font = (
119 size => $font->{size} // 8,
120 colour => $font->{colour} // '#666',
121 (exists $font->{family} ? (family => $font->{family}) : ()),
122 (exists $font->{bold} ? (bold => $font->{bold}) : ()),
123 4 ▶ (exists $font->{italic} ? (italic => $font->{italic}) : ()),
Branch: 3 branches
BranchTrueFalseTotal
exists $font->{'family'} ? : 1 3 4
exists $font->{'bold'} ? : 1 3 4
exists $font->{'italic'} ? : 1 3 4
Condition50%2/4
$font->{"size"} // 8
l!l
04
$font->{"colour"} // "#666"
l!l
04
MC/DC0%0/1
$font->{"size"} // 8
$font->{"size"}
MC/DC0%0/1
$font->{"colour"} // "#666"
$font->{"colour"}
Truth table50%1/2
A
A= $font->{"size"}
Aresult
11
00
Truth table50%1/2
A
A= $font->{"colour"}
Aresult
11
00
124 );
125 return $self->text(
126 text => $format,
127 align => $args{align} // 'right',
128 x => $args{x},
129 y => $args{y},
130 padding => $args{padding},
131 4 ▶ font => \%font,
Condition100%2/2
$args{"align"} // "right"
l!l
31
MC/DC100%1/1
$args{"align"} // "right"
$args{"align"}
Truth table100%2/2
A
A= $args{"align"}
Aresult
11
00
132 );
133 }
134  
135 # ── Shapes ────────────────────────────────────────────────
136  
137 5 ▶sub line {
Subroutine line: called CC=14 SCAR=26.6
Pod documented
138 5 my ($self, %args) = @_;
139 5 my ($x1, $y1, $x2, $y2);
140 5 ▶ if ($args{from} && $args{to}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'from'} and $args{'to'}) { } 1 4 5
Condition66%2/3
$args{"from"} and $args{"to"}
!ll&&!rl&&r
401
MC/DC50%1/2
$args{"from"} and $args{"to"}
$args{"from"} $args{"to"}
Truth table66%2/3
A and B
A= $args{"from"}B= $args{"to"}
ABresult
0X0
100
111
141 1 ($x1, $y1) = @{$args{from}};
142 1 ($x2, $y2) = @{$args{to}};
143 } else {
144 4 ▶ $x1 = $args{x1} // $self->left;
Condition66%2/3
$args{"x1"} // $self->left
l!l&&r!l&&!r
130
MC/DC0%0/2
$args{"x1"} // $self->left
$args{"x1"} $self->left
Truth table66%2/3
A // B
A= $args{"x1"}B= $self->left
ABresult
1X1
011
000
145 4 ▶ $y1 = $args{y1} // $self->bottom;
Condition66%2/3
$args{"y1"} // $self->bottom
l!l&&r!l&&!r
130
MC/DC0%0/2
$args{"y1"} // $self->bottom
$args{"y1"} $self->bottom
Truth table66%2/3
A // B
A= $args{"y1"}B= $self->bottom
ABresult
1X1
011
000
146 4 ▶ $x2 = $args{x2} // $self->right;
Condition66%2/3
$args{"x2"} // $self->right
l!l&&r!l&&!r
130
MC/DC0%0/2
$args{"x2"} // $self->right
$args{"x2"} $self->right
Truth table66%2/3
A // B
A= $args{"x2"}B= $self->right
ABresult
1X1
011
000
147 4 ▶ $y2 = $args{y2} // $y1;
Condition66%2/3
$args{"y2"} // $y1
l!l&&r!l&&!r
130
MC/DC0%0/2
$args{"y2"} // $y1
$args{"y2"} $y1
Truth table66%2/3
A // B
A= $args{"y2"}B= $y1
ABresult
1X1
011
000
148 }
149 5 ▶ my $colour = $args{colour} // $args{fill_colour} // '#000';
Condition80%4/5
($args{"colour"} // $args{"fill_colour"}) // "#000"
l!l
32
$args{"colour"} // $args{"fill_colour"}
l!l&&r!l&&!r
302
MC/DC50%1/2
($args{"colour"} // $args{"fill_colour"}) // "#000"
$args{"colour"} $args{"fill_colour"}
Truth table66%2/3
A // B
A= $args{"colour"}B= $args{"fill_colour"}
ABresult
1X1
011
000
150 5 my $font = $self->builder->font;
151 5 my ($r, $g, $b) = $font->hex_to_rgb($colour);
152 5 my $canvas = $self->canvas;
153  
154 5 ▶ $canvas->q->w($args{width} // 1)->RG($r, $g, $b);
Condition100%2/2
$args{"width"} // 1
l!l
14
MC/DC100%1/1
$args{"width"} // 1
$args{"width"}
Truth table100%2/2
A
A= $args{"width"}
Aresult
11
00
155  
156 5 ▶ my $type = $args{type} // 'solid';
Condition100%2/2
$args{"type"} // "solid"
l!l
23
MC/DC100%1/1
$args{"type"} // "solid"
$args{"type"}
Truth table100%2/2
A
A= $args{"type"}
Aresult
11
00
157 5 ▶ if ($args{dash}) {
Branch: 3 branches
BranchTrueFalseTotal
if ($args{'dash'}) { } 1 4 5
elsif ($type eq 'dashed') { } 1 3 4
elsif ($type eq 'dots') { } 1 2 3
158 1 $canvas->d($args{dash}, 0);
159 } elsif ($type eq 'dashed') {
160 1 $canvas->d([6, 3], 0);
161 } elsif ($type eq 'dots') {
162 1 $canvas->J(1)->d([0, 4], 0);
163 }
164  
165 5 $canvas->m($x1, $y1)->l($x2, $y2)->S->Q;
166 5 return $self;
167 }
168  
169 2 ▶sub box {
Subroutine box: called CC=9 SCAR=22.9
Pod documented
170 2 my ($self, %args) = @_;
171 2 ▶ my $x = $args{x} // $self->left;
Condition66%2/3
$args{"x"} // $self->left
l!l&&r!l&&!r
110
MC/DC0%0/2
$args{"x"} // $self->left
$args{"x"} $self->left
Truth table66%2/3
A // B
A= $args{"x"}B= $self->left
ABresult
1X1
011
000
172 2 ▶ my $y = $args{y} // $self->bottom;
Condition66%2/3
$args{"y"} // $self->bottom
l!l&&r!l&&!r
110
MC/DC0%0/2
$args{"y"} // $self->bottom
$args{"y"} $self->bottom
Truth table66%2/3
A // B
A= $args{"y"}B= $self->bottom
ABresult
1X1
011
000
173 2 ▶ my $w = $args{w} // $self->w;
Condition66%2/3
$args{"w"} // $self->w
l!l&&r!l&&!r
110
MC/DC0%0/2
$args{"w"} // $self->w
$args{"w"} $self->w
Truth table66%2/3
A // B
A= $args{"w"}B= $self->w
ABresult
1X1
011
000
174 2 ▶ my $h = $args{h} // $self->h;
Condition66%2/3
$args{"h"} // $self->h
l!l&&r!l&&!r
110
MC/DC0%0/2
$args{"h"} // $self->h
$args{"h"} $self->h
Truth table66%2/3
A // B
A= $args{"h"}B= $self->h
ABresult
1X1
011
000
175 2 ▶ my $colour = $args{fill_colour} // $args{colour} // '#000';
Condition40%2/5
($args{"fill_colour"} // $args{"colour"}) // "#000"
l!l
20
$args{"fill_colour"} // $args{"colour"}
l!l&&r!l&&!r
200
MC/DC0%0/2
($args{"fill_colour"} // $args{"colour"}) // "#000"
$args{"fill_colour"} $args{"colour"}
Truth table33%1/3
A // B
A= $args{"fill_colour"}B= $args{"colour"}
ABresult
1X1
011
000
176 2 my $font = $self->builder->font;
177 2 my ($r, $g, $b) = $font->hex_to_rgb($colour);
178 2 my $canvas = $self->canvas;
179  
180 2 $canvas->q;
181 2 ▶ if ($colour eq 'transparent') {
Branch: 1 branch
BranchTrueFalseTotal
if ($colour eq 'transparent') { } 1 1 2
182 1 ▶ $canvas->w($args{width} // 1)->RG($r, $g, $b)->re($x, $y, $w, $h)->S;
Condition50%1/2
$args{"width"} // 1
l!l
10
MC/DC0%0/1
$args{"width"} // 1
$args{"width"}
Truth table50%1/2
A
A= $args{"width"}
Aresult
11
00
183 } else {
184 1 $canvas->rg($r, $g, $b)->re($x, $y, $w, $h)->f;
185 }
186 2 $canvas->Q;
187 2 return $self;
188 }
189  
190 # ── Image ─────────────────────────────────────────────────
191  
192 6 ▶sub image {
Subroutine image: called CC=13 SCAR=25.7
Pod documented
193 6 my ($self, %args) = @_;
194 6 require PDF::Make::Image;
195  
196 my $src = $args{src} // $args{image}
197 6 ▶ or die "HeaderFooterContext::image requires src or image";
Branch: 1 branch
BranchTrueFalseTotal
my $src = $args{"src"} // $args{"image"} or die "HeaderFooterContext::image requires src or image" 5 1 6
Condition100%3/3
$args{"src"} // $args{"image"}
l!l&&r!l&&!r
411
MC/DC100%2/2
$args{"src"} // $args{"image"}
$args{"src"} $args{"image"}
Truth table100%3/3
A // B
A= $args{"src"}B= $args{"image"}
ABresult
1X1
011
000
198 5 my $img = PDF::Make::Image->from_file($src);
199 5 my $img_w = $img->width;
200 5 my $img_h = $img->height;
201  
202 5 my $doc = $self->builder->doc;
203 5 my $obj_num = $img->write_to_doc($doc);
204 5 my $res_name = 'Im' . $obj_num;
205 5 $self->page->xs_page->add_image($res_name, $obj_num);
206  
207 5 my $draw_w = $args{w};
208 5 my $draw_h = $args{h};
209 5 ▶ if (!defined $draw_w && !defined $draw_h) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $draw_w || defined $draw_h) { } 1 4 5
elsif (not defined $draw_h) { } 2 2 4
elsif (not defined $draw_w) { } 1 1 2
Condition100%3/3
defined $draw_w || defined $draw_h
l!l&&r!l&&!r
311
MC/DC100%2/2
defined $draw_w || defined $draw_h
defined $draw_w defined $draw_h
Truth table100%3/3
A || B
A= defined $draw_wB= defined $draw_h
ABresult
1X1
011
000
210 1 $draw_h = $self->h;
211 1 $draw_w = $draw_h * ($img_w / $img_h);
212 } elsif (!defined $draw_h) {
213 2 $draw_h = $draw_w * ($img_h / $img_w);
214 } elsif (!defined $draw_w) {
215 1 $draw_w = $draw_h * ($img_w / $img_h);
216 }
217  
218 5 ▶ my $align = $args{align} // 'left';
Condition100%2/2
$args{"align"} // "left"
l!l
32
MC/DC100%1/1
$args{"align"} // "left"
$args{"align"}
Truth table100%2/2
A
A= $args{"align"}
Aresult
11
00
219 5 ▶ my $pad = defined $args{padding} ? $args{padding} : $self->padding;
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'padding'} ? : 0 5 5
220 5 my $x = $args{x};
221 5 ▶ if (!defined $x) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $x) 4 1 5
222 4 ▶ if ($align eq 'right') { $x = $self->right - $pad - $draw_w }
Branch: 2 branches
BranchTrueFalseTotal
if ($align eq 'right') { } 1 3 4
elsif ($align eq 'center') { } 1 2 3
223 1 elsif ($align eq 'center') { $x = $self->center_x - $draw_w / 2 }
224 2 else { $x = $self->left + $pad }
225 }
226 5 ▶ my $y = $args{y} // ($self->bottom + ($self->h - $draw_h) / 2);
Condition100%2/2
$args{"y"} // $self->bottom + ($self->h - $draw_h) / 2
l!l
14
MC/DC100%1/1
$args{"y"} // $self->bottom + ($self->h - $draw_h) / 2
$args{"y"}
Truth table100%2/2
A
A= $args{"y"}
Aresult
11
00
227  
228 5 $self->canvas->image($res_name, $x, $y, $draw_w, $draw_h);
229 5 return $self;
230 }
231  
232 # ── Annotations ───────────────────────────────────────────
233  
234 11 ▶sub _rect {
Subroutine _rect: called CC=6 SCAR=18.1
235 11 my ($self, %args) = @_;
236 11 ▶ return $args{rect} if $args{rect};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"rect"} 9 2 11
237 2 my $x = $args{x};
238 2 my $y = $args{y};
239 2 my $w = $args{w};
240 2 my $h = $args{h};
241 2 ▶ die "HeaderFooterContext: annotation requires rect or x/y/w/h"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x and defined $y and defined $w and defined $h 1 1 2
Condition66%6/9
defined $x and defined $y and defined $w and defined $h
!ll&&!rl&&r
101
defined $x and defined $y and defined $w
!ll&&!rl&&r
101
defined $x and defined $y
!ll&&!rl&&r
101
MC/DC25%1/4
defined $x and defined $y and defined $w and defined $h
defined $x defined $y defined $w defined $h
Truth table40%2/5
A and B and C and D
A= defined $xB= defined $yC= defined $wD= defined $h
ABCDresult
0XXX0
10XX0
110X0
11100
11111
242 unless defined $x && defined $y && defined $w && defined $h;
243 1 return [$x, $y, $x + $w, $y + $h];
244 }
245  
246 3 ▶sub note {
Subroutine note: called CC=5 SCAR=16.4
Pod documented
247 3 my ($self, %args) = @_;
248 3 my $rect = $self->_rect(%args);
249 2 ▶ my $text = $args{text} // '';
Condition50%1/2
$args{"text"} // ""
l!l
20
MC/DC0%0/1
$args{"text"} // ""
$args{"text"}
Truth table50%1/2
A
A= $args{"text"}
Aresult
11
00
250 2 ▶ my $icon = $args{icon} // 'Note';
Condition100%2/2
$args{"icon"} // "Note"
l!l
11
MC/DC100%1/1
$args{"icon"} // "Note"
$args{"icon"}
Truth table100%2/2
A
A= $args{"icon"}
Aresult
11
00
251 2 ▶ my $open = $args{open} // 0;
Condition50%1/2
$args{"open"} // 0
l!l
02
MC/DC0%0/1
$args{"open"} // 0
$args{"open"}
Truth table50%1/2
A
A= $args{"open"}
Aresult
11
00
252 2 my $xs_doc = $self->builder->doc;
253 2 my $annot_num = $xs_doc->add_text_annot(@$rect, $text, $icon, $open);
254 2 ▶ $self->page->xs_page->add_annot($annot_num) if $annot_num;
Branch: 1 branch
BranchTrueFalseTotal
if $annot_num 2 0 2
255 2 return $self;
256 }
257  
258 8 ▶sub link {
Subroutine link: called CC=9 SCAR=22.2
Pod documented
259 8 my ($self, %args) = @_;
260 8 my $rect = $self->_rect(%args);
261 8 my $xs_doc = $self->builder->doc;
262 8 ▶ my $hl = $args{highlight} // 'Invert';
Condition50%1/2
$args{"highlight"} // "Invert"
l!l
08
MC/DC0%0/1
$args{"highlight"} // "Invert"
$args{"highlight"}
Truth table50%1/2
A
A= $args{"highlight"}
Aresult
11
00
263 8 my $annot_num;
264 8 ▶ if ($args{url}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($args{'url'}) { } 1 7 8
elsif (defined $args{'page'}) { } 2 5 7
elsif ($args{'action'}) { } 2 3 5
elsif ($args{'file'}) { } 2 1 3
265 1 $annot_num = $xs_doc->add_link_uri(@$rect, $args{url});
266 } elsif (defined $args{page}) {
267 2 $annot_num = $xs_doc->add_link_goto(@$rect, $args{page});
268 } elsif ($args{action}) {
269 2 $annot_num = $xs_doc->add_link_named_action(@$rect, $args{action}, $hl);
270 } elsif ($args{file}) {
271 my $action = $xs_doc->action_gotor(
272 2 ▶ $args{file}, $args{file_page} // 0, $args{new_window} // 0);
Condition50%2/4
$args{"file_page"} // 0
l!l
02
$args{"new_window"} // 0
l!l
02
MC/DC0%0/1
$args{"file_page"} // 0
$args{"file_page"}
MC/DC0%0/1
$args{"new_window"} // 0
$args{"new_window"}
Truth table50%1/2
A
A= $args{"file_page"}
Aresult
11
00
Truth table50%1/2
A
A= $args{"new_window"}
Aresult
11
00
273 2 $annot_num = $xs_doc->add_link_with_action(@$rect, $action, $hl);
274 } else {
275 1 die "HeaderFooterContext::link requires url, page, action, or file";
276 }
277 7 ▶ $self->page->xs_page->add_annot($annot_num) if $annot_num;
Branch: 1 branch
BranchTrueFalseTotal
if $annot_num 7 0 7
278 7 return $self;
279 }
280  
281 53 1;
282  
283 __END__
« blib/lib/PDF/Make/Builder/Form/Field/Button.pm ↑ Summary blib/lib/PDF/Make/Builder/Form/Field.pm »