TableX/Row.pm

filter: Statementstmt 30.0% 21 / 70 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 26.6% 4 / 15 Podpod 0.0% 0 / 8 totaltotal 24.2% 25 / 103 SCAR 42.5
CC
12
Cov
26%
draw_content
42.0
__ANON__
12.0
_create_children
6.0
CRAP 69.8
« TableX/Cell.pm ↑ Summary TableX/Column.pm »
1 package PDF::TableX::Row;
2  
3 8 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use MooseX::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 with 'PDF::TableX::Drawable';
7 8 with 'PDF::TableX::Stylable';
8  
9 8 ▶use PDF::TableX::Cell;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 8 has cols => (is => 'ro', isa => 'Int', default => 0);
12 8 has width => (is => 'rw', isa => 'Num');
13 8 has height => (is => 'rw', isa => 'Num');
14  
15 8 has _row_idx => (is => 'ro', isa => 'Int', default => 0);
16 8 has _parent => (is => 'ro', isa => 'Object');
17  
18 8 ▶use overload '@{}' => sub { return $_[0]->{_children} }, fallback => 1;
Subroutine BEGIN: called CC=1 SCAR=0.2
Subroutine __ANON__: not called CC=1 SCAR=0.2
19  
20 around 'height' => sub {
21 0 ▶ my $orig = shift;
Subroutine __ANON__: not called CC=3 SCAR=24.8
22 0 my $self = shift;
23 0 ▶ return $self->$orig() unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
24 0 for (@{ $self->{_children} }) { $_->height(@_) };
25 0 $self->$orig(@_);
26 0 return $self;
27 8 };
28  
29  
30 sub BUILD {
31 0 ▶ my ($self) = @_;
Subroutine BUILD: not called CC=1 SCAR=6.9
Pod undocumented
32 0 $self->_create_children;
33 }
34  
35 sub _create_children {
36 0 ▶ my ($self) = @_;
Subroutine _create_children: not called CC=2 SCAR=17.9
37 0 for (0..$self->cols-1) {
38 $self->add_cell( PDF::TableX::Cell->new(
39 width => ($self->width/$self->cols),
40 _row_idx => $self->{_row_idx},
41 0 _col_idx => $_,
42 _parent => $self,
43 $self->properties,
44 ));
45 }
46 }
47  
48 sub add_cell {
49 0 ▶ my ($self, $cell) = @_;
Subroutine add_cell: not called CC=1 SCAR=6.9
Pod undocumented
50 0 push @{$self->{_children}}, $cell;
51 }
52  
53 sub properties {
54 0 ▶ my ($self, @attrs) = @_;
Subroutine properties: not called CC=2 SCAR=17.9
Pod undocumented
55 0 ▶ @attrs = scalar(@attrs) ? @attrs : $self->attributes;
Branch: 1 branch
BranchTrueFalseTotal
scalar @attrs ? : 0 0 0
56 0 return ( map { $_ => $self->$_ } @attrs );
57 }
58  
59 sub draw_content {
60 0 ▶ my ($self, $x, $y, $gfx, $txt) = @_;
Subroutine draw_content: not called CC=6 SCAR=37.4
Pod undocumented
61 0 my $height = 0;
62 0 my $overflow = 0;
63 0 for (@{$self->{_children}}) {
64 0 my ($w, $h, $o) = $_->draw_content( $x, $y, $gfx, $txt );
65 0 ▶ $height = ($height > $h) ? $height : $h;
Branch: 1 branch
BranchTrueFalseTotal
$height > $h ? : 0 0 0
66 0 ▶ $x += ($w > $_->width ? $w : $_->width);
Branch: 1 branch
BranchTrueFalseTotal
$w > $_->width ? : 0 0 0
67 0 $overflow += $o;
68 }
69 0 ▶ if (! $overflow ) { for (@{$self->{_children}}) { $_->reset_content } }
Branch: 1 branch
BranchTrueFalseTotal
unless ($overflow) 0 0 0
70 0 return ($height, $overflow);
71 }
72  
73 sub draw_borders {
74 0 ▶ my ($self, $x, $y, $gfx, $txt) = @_;
Subroutine draw_borders: not called CC=2 SCAR=17.9
Pod undocumented
75 0 for (@{$self->{_children}}) {
76 0 $_->draw_borders( $x, $y, $gfx, $txt );
77 0 $x += $_->width;
78 }
79 }
80  
81 sub draw_background {
82 0 ▶ my ($self, $x, $y, $gfx, $txt) = @_;
Subroutine draw_background: not called CC=2 SCAR=17.9
Pod undocumented
83 0 for (@{$self->{_children}}) {
84 0 $_->draw_background( $x, $y, $gfx, $txt );
85 0 $x += $_->width;
86 }
87 }
88  
89 sub is_last_in_row {
90 0 ▶ my ($self, $idx) = @_;
Subroutine is_last_in_row: not called CC=1 SCAR=6.9
Pod undocumented
91 0 return ($idx == $self->cols-1); #index starts from 0
92 }
93  
94 sub is_last_in_col {
95 0 ▶ my ($self, $idx) = @_;
Subroutine is_last_in_col: not called CC=1 SCAR=6.9
Pod undocumented
96 0 return $self->{_parent}->is_last_in_col($idx);
97 }
98  
99 8 1;
100  
101 =head1 NAME
102  
103 PDF::TableX::Row
104  
105 =head1 VERSION
106  
107 Version 0.01
108  
109 =head1 SYNOPSIS
110  
111 =head1 FUNCTIONS
112  
113 =head1 AUTHOR
114  
115 Grzegorz Papkala, C<< <grzegorzpapkala at gmail.com> >>
116  
117 =head1 BUGS
118  
119 Please report any bugs or feature requests at: L<https://github.com/grzegorzpapkala/PDF-TableX/issues>
120  
121 =head1 SUPPORT
122  
123 PDF::TableX is hosted on GitHub L<https://github.com/grzegorzpapkala/PDF-TableX>
124  
125 =head1 ACKNOWLEDGEMENTS
126  
127 =head1 COPYRIGHT & LICENSE
128  
129 Copyright 2013 Grzegorz Papkala, all rights reserved.
130  
131 This program is free software; you can redistribute it and/or modify it
132 under the same terms as Perl itself.
133  
134 =cut
« TableX/Cell.pm ↑ Summary TableX/Column.pm »