lib/PDF/Boxer/Content/Column.pm

filter: Statementstmt 21.2% 14 / 66 Branchbran 0.0% 0 / 26 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 37.5% 3 / 8 Podpod 20.0% 1 / 5 totaltotal 16.3% 18 / 110 CC 20 SCAR 35.9
CC
20
Cov
15%
update_kids_size
72.0
child_adjusted_height
42.0
update_children
20.0
CRAP 36.4
« lib/PDF/Boxer/Content/Text.pm ↑ Summary lib/PDF/Boxer/Content/Row.pm »
1 package PDF::Boxer::Content::Column;
2 {
3 3 $PDF::Boxer::Content::Column::VERSION = '0.004';
4 }
5 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 # ABSTRACT: a box of boxes stack one above the other
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 $height+= $_->margin_height;
19 0 ▶ $width = $width ? (sort { $b <=> $a } ($_->margin_width,$width))[0] : $_->margin_width;
Branch: 1 branch
BranchTrueFalseTotal
$width ? : 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_size{
Subroutine update_kids_size: not called CC=8 SCAR=42.8
Pod undocumented
35 0 my ($self) = @_;
36 0 my ($kids_width, $kids_height) = $self->get_default_size;
37 0 my $kids = $self->children;
38 0 ▶ if (@$kids){
Branch: 1 branch
BranchTrueFalseTotal
if (@$kids) 0 0 0
39 0 my $space = $self->height - $kids_height;
40 0 my ($has_grow,$grow,$grow_all);
41 0 my $space_each = 0;
42 0 foreach my $kid (@$kids){
43 0 ▶ $has_grow++ if $kid->grow;
Branch: 1 branch
BranchTrueFalseTotal
if $kid->grow 0 0 0
44 }
45 0 ▶ $space_each = int($space/$has_grow) if $has_grow;
Branch: 1 branch
BranchTrueFalseTotal
if $has_grow 0 0 0
46  
47 0 my $kwidth = $self->content_width;
48  
49 0 foreach my $kid (@$kids){
50 0 my $kheight = $kid->margin_height;
51 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
52 0 $kheight += $space_each;
53 }
54 0 $kid->set_margin_size($kwidth, $kheight);
55 }
56  
57 }
58 }
59  
60 0 ▶sub update_kids_position{
Subroutine update_kids_position: not called CC=3 SCAR=24.8
Pod undocumented
61 0 my ($self) = @_;
62 0 my $kids = $self->children;
63  
64 0 ▶ if (@$kids){
Branch: 1 branch
BranchTrueFalseTotal
if (@$kids) 0 0 0
65 0 my $top = $self->content_top;
66 0 my $left = $self->content_left;
67 0 foreach my $kid (@$kids){
68 0 $kid->move($left, $top);
69 0 $top -= $kid->margin_height;
70 }
71 }
72  
73 }
74  
75 0 ▶sub child_adjusted_height{
Subroutine child_adjusted_height: not called CC=6 SCAR=37.4
Pod undocumented
76 0 my ($self, $child) = @_;
77 0 ▶ weaken($child) if $child;
Branch: 1 branch
BranchTrueFalseTotal
if $child 0 0 0
78 0 $self->update_kids_position;
79 0 ▶ unless($self->grow){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->grow) 0 0 0
80 0 my $kid = $self->children->[-1];
81 0 my $kid_mb = $kid->margin_bottom;
82 0 ▶ if ($self->content_bottom != $kid_mb){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->content_bottom != $kid_mb) 0 0 0
83 0 my $height = $self->margin_height + $self->content_bottom - $kid_mb;
84 0 ▶ if ($height > $self->boxer->max_height){
Branch: 1 branch
BranchTrueFalseTotal
if ($height > $self->boxer->max_height) { } 0 0 0
85 0 $self->update_kids_size;
86 } else {
87 0 $self->set_margin_height($height);
88 0 ▶ $self->parent->child_adjusted_height($self) if $self->parent;
Branch: 1 branch
BranchTrueFalseTotal
if $self->parent 0 0 0
89 }
90 }
91 }
92 }
93  
94 3 __PACKAGE__->meta->make_immutable;
95  
96 3 1;
97  
98  
99 __END__
« lib/PDF/Boxer/Content/Text.pm ↑ Summary lib/PDF/Boxer/Content/Row.pm »