| 1 | package PDF::Make::Builder::Layout; | ||||||||||||||||||||||
| 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 Scalar::Util (); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 6 | 53 | ▶ | use PDF::Make::Builder::Layout::Row; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 7 | |||||||||||||||||||||||
| 8 | 53 | ▶ | BEGIN { | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 9 | 53 | Object::Proto::define('PDF::Make::Builder::Layout', | |||||||||||||||||||||
| 10 | 'builder:required', | ||||||||||||||||||||||
| 11 | 'rows:ArrayRef:default([])', | ||||||||||||||||||||||
| 12 | ); | ||||||||||||||||||||||
| 13 | 53 | Object::Proto::import_accessors('PDF::Make::Builder::Layout'); | |||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||
| 15 | |||||||||||||||||||||||
| 16 | # Layout holds its rows and each row points back at the layout: the same | ||||||||||||||||||||||
| 17 | # cycle as Row and Cell, and leaked the same way. Weakened here for the same | ||||||||||||||||||||||
| 18 | # reason and by the same identity scan. | ||||||||||||||||||||||
| 19 | 4016 | ▶ | sub _weaken_layout_ref { | ||||||||||||||||||||
|
Subroutine
_weaken_layout_ref: called CC=4 SCAR=14.1
| |||||||||||||||||||||||
| 20 | 4016 | my ($row, $layout) = @_; | |||||||||||||||||||||
| 21 | 4016 | for my $i (0 .. $#$row) { | |||||||||||||||||||||
| 22 | 8032 | ▶ | next unless ref $row->[$i]; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 23 | 4016 | ▶ | next unless $row->[$i] == $layout; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 24 | 4016 | Scalar::Util::weaken($row->[$i]); | |||||||||||||||||||||
| 25 | 4016 | return 1; | |||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||
| 27 | 0 | return 0; | |||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||
| 29 | |||||||||||||||||||||||
| 30 | 4016 | ▶ | sub row { | ||||||||||||||||||||
|
Subroutine
row: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||
| 31 | 4016 | my ($self, %args) = @_; | |||||||||||||||||||||
| 32 | 4016 | my $rows = rows $self; | |||||||||||||||||||||
| 33 | my %row_args = ( | ||||||||||||||||||||||
| 34 | layout => $self, | ||||||||||||||||||||||
| 35 | margin => $args{margin} // 5, | ||||||||||||||||||||||
| 36 | 4016 | ▶ | gap => $args{gap} // 0, | ||||||||||||||||||||
|
Condition100%4/4
$args{"margin"} // 5
$args{"gap"} // 0
MC/DC100%1/1
$args{"margin"} // 5
$args{"margin"}
MC/DC100%1/1
$args{"gap"} // 0
$args{"gap"}
Truth table100%2/2
A
A= $args{"margin"}
Truth table100%2/2
A
A= $args{"gap"}
| |||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||
| 38 | 4016 | ▶ | $row_args{height} = $args{height} if defined $args{height}; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 39 | 4016 | my $row = PDF::Make::Builder::Layout::Row->new(%row_args); | |||||||||||||||||||||
| 40 | 4016 | _weaken_layout_ref($row, $self); | |||||||||||||||||||||
| 41 | 4016 | push @$rows, $row; | |||||||||||||||||||||
| 42 | 4016 | return $row; | |||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||
| 44 | |||||||||||||||||||||||
| 45 | 378 | ▶ | sub render { | ||||||||||||||||||||
|
Subroutine
render: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 46 | 378 | my ($self) = @_; | |||||||||||||||||||||
| 47 | 378 | my $builder = builder $self; | |||||||||||||||||||||
| 48 | 378 | my $page = $builder->page; | |||||||||||||||||||||
| 49 | |||||||||||||||||||||||
| 50 | 378 | for my $row (@{rows $self}) { | |||||||||||||||||||||
| 51 | 4011 | $row->render($builder, $page); | |||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||
| 53 | |||||||||||||||||||||||
| 54 | 378 | return $builder; | |||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||
| 56 | |||||||||||||||||||||||
| 57 | 53 | 1; | |||||||||||||||||||||
| 58 | |||||||||||||||||||||||
| 59 | __END__ | ||||||||||||||||||||||