| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | $self->update_kids_position if $self->position_set; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | 0 | ▶ | $space_each = int($space/$has_grow) if $has_grow; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$grow_all or $kid->grow
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 78 | 0 | $self->update_kids_position; | |||||||||||||||||||||||||||
| 79 | 0 | ▶ | unless($self->grow){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 83 | 0 | my $height = $self->margin_height + $self->content_bottom - $kid_mb; | |||||||||||||||||||||||||||
| 84 | 0 | ▶ | if ($height > $self->boxer->max_height){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 3 | 1; | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | __END__ | ||||||||||||||||||||||||||||