lib/PDF/Boxer/Content/Row.pm

filter: Statementstmt 17.7% 14 / 79 Branchbran 0.0% 0 / 26 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 33.3% 3 / 9 Podpod 16.6% 1 / 6 totaltotal 13.3% 18 / 135 CC 24 SCAR 35.7
CC
24
Cov
12%
update_kids_size
72.0
child_adjusted_height
42.0
set_kids_minimum_width
30.0
CRAP 35.4
« lib/PDF/Boxer/Content/Column.pm ↑ Summary lib/PDF/Boxer/Role/SizePosition.pm »
1 package PDF::Boxer::Content::Row;
2 {
3 3 $PDF::Boxer::Content::Row::VERSION = '0.004';
4 }
5 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 # ABSTRACT: a box of boxes laid out side by side
7  
8 3 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Scalar::Util qw!weaken!;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 extends 'PDF::Boxer::Content::Box';
12  
13 0 ▶sub get_default_size{
Subroutine get_default_size: not called CC=3 SCAR=24.8
Pod documented
14 0 my ($self) = @_;
15 0 my @kids = @{$self->children};
16 0 my ($width, $height) = (0,0);
17 0 foreach(@kids){
18 0 $width += $_->margin_width;
19 0 ▶ $height = $height ? (sort { $b <=> $a } ($_->margin_height,$height))[0] : $_->margin_height;
Branch: 1 branch
BranchTrueFalseTotal
$height ? : 0 0 0
20 }
21 0 return ($width, $height);
22 }
23  
24 0 ▶sub update_children{
Subroutine update_children: not called CC=4 SCAR=30.0
Pod undocumented
25 0 my ($self) = @_;
26 0 ▶ $self->update_kids_size if $self->size_set;
Branch: 1 branch
BranchTrueFalseTotal
if $self->size_set 0 0 0
27 0 ▶ $self->update_kids_position if $self->position_set;
Branch: 1 branch
BranchTrueFalseTotal
if $self->position_set 0 0 0
28 0 foreach my $kid (@{$self->children}){
29 0 $kid->update;
30 }
31 0 return 1;
32 }
33  
34 0 ▶sub update_kids_position{
Subroutine update_kids_position: not called CC=3 SCAR=24.8
Pod undocumented
35 0 my ($self, $args) = @_;
36  
37 0 my $kids = $self->children;
38  
39 0 ▶ if (@$kids){
Branch: 1 branch
BranchTrueFalseTotal
if (@$kids) 0 0 0
40  
41 0 my $top = $self->content_top;
42 0 my $left = $self->content_left;
43  
44 0 foreach my $kid (@$kids){
45 0 $kid->move($left, $top);
46 0 $left += $kid->margin_width;
47 }
48 }
49  
50 0 return 1;
51 }
52  
53 0 ▶sub update_kids_size{
Subroutine update_kids_size: not called CC=8 SCAR=42.8
Pod undocumented
54 0 my ($self, $args) = @_;
55  
56 0 my $kids = $self->children;
57  
58 0 my ($kids_width, $kids_height) = $self->get_default_size;
59  
60 0 ▶ if (@$kids){
Branch: 1 branch
BranchTrueFalseTotal
if (@$kids) 0 0 0
61 0 my $space = $self->width - $kids_width;
62 0 my ($has_grow,$grow,$grow_all);
63 0 my $space_each = 0;
64 0 foreach my $kid (@$kids){
65 0 ▶ $has_grow++ if $kid->grow;
Branch: 1 branch
BranchTrueFalseTotal
if $kid->grow 0 0 0
66 }
67 0 ▶ if (!$has_grow){
Branch: 1 branch
BranchTrueFalseTotal
unless ($has_grow) 0 0 0
68 0 $grow_all = 1;
69 0 $has_grow = @$kids;
70 }
71 0 $space_each = int($space/$has_grow);
72  
73 0 my $kheight = $self->content_height;
74  
75 0 foreach my $kid (@$kids){
76 0 my $kwidth = $kid->margin_width;
77 0 ▶ if ($grow_all || $kid->grow){
Branch: 1 branch
BranchTrueFalseTotal
if ($grow_all or $kid->grow) 0 0 0
Condition0%0/3
$grow_all or $kid->grow
l!l&&r!l&&!r
000
MC/DC0%0/2
$grow_all or $kid->grow
$grow_all $kid->grow
Truth table0%0/3
A or B
A= $grow_allB= $kid->grow
ABresult
1X1
011
000
78 0 $kwidth += $space_each;
79 }
80 0 $kid->set_margin_size($kwidth, $kheight);
81 }
82 }
83  
84 0 return 1;
85 }
86  
87 0 ▶sub set_kids_minimum_width{
Subroutine set_kids_minimum_width: not called CC=5 SCAR=34.0
Pod undocumented
88 0 my ($self, $args) = @_;
89 0 my $kids = $self->children;
90 0 ▶ if ($args->{min_widths} && @{$args->{min_widths}}){
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"min_widths"} and @{$args->{"min_widths"};}) 0 0 0
Condition0%0/3
$args->{"min_widths"} and @{$args->{"min_widths"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$args->{"min_widths"} and @{$args->{"min_widths"};}
$args->{"min_widths"} @{$args->{"min_widths"};}
Truth table0%0/3
A and B
A= $args->{"min_widths"}B= @{$args->{"min_widths"};}
ABresult
0X0
100
111
91 0 ▶ if (@$kids){
Branch: 1 branch
BranchTrueFalseTotal
if (@$kids) 0 0 0
92 0 my @widths = @{$args->{min_widths}};
93 0 foreach my $kid (@$kids){
94 0 my $width = shift @widths;
95 0 $kid->set_margin_width($width);
96 }
97 }
98 }
99 }
100  
101  
102 0 ▶sub child_adjusted_height{
Subroutine child_adjusted_height: not called CC=6 SCAR=37.4
Pod undocumented
103 0 my ($self, $child) = @_;
104 0 ▶ weaken($child) if $child;
Branch: 1 branch
BranchTrueFalseTotal
if $child 0 0 0
105 0 my $low = 5000;
106 0 foreach(@{$self->children}){
107 0 ▶ $low = $_->margin_bottom if defined $_->margin_bottom && $_->margin_bottom < $low;
Branch: 1 branch
BranchTrueFalseTotal
if defined $_->margin_bottom and $_->margin_bottom < $low 0 0 0
Condition0%0/3
defined $_->margin_bottom and $_->margin_bottom < $low
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_->margin_bottom and $_->margin_bottom < $low
defined $_->margin_bottom $_->margin_bottom < $low
Truth table0%0/3
A and B
A= defined $_->margin_bottomB= $_->margin_bottom < $low
ABresult
0X0
100
111
108 }
109 0 ▶ if ($self->content_bottom != $low){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->content_bottom != $low) 0 0 0
110 0 my $height = $self->margin_height + $self->content_bottom - $low;
111 0 $self->set_height($height);
112 0 $self->parent->child_adjusted_height($self);
113 }
114 }
115  
116 3 __PACKAGE__->meta->make_immutable;
117  
118 3 1;
119  
120  
121  
122  
123 __END__
« lib/PDF/Boxer/Content/Column.pm ↑ Summary lib/PDF/Boxer/Role/SizePosition.pm »