| 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.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 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
| |||||||||||
| 24 | 0 | for (@{ $self->{_children} }) { $_->height(@_) }; | |||||||||
| 25 | 0 | $self->$orig(@_); | |||||||||
| 26 | 0 | return $self; | |||||||||
| 27 | 8 | }; | |||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | sub BUILD { | ||||||||||
| 31 | 34 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 32 | 34 | $self->_create_children; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | sub _create_children { | ||||||||||
| 36 | 34 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
_create_children: called CC=2 SCAR=6.9
| |||||||||||
| 37 | 34 | 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 | 146 | _col_idx => $_, | |||||||||
| 42 | _parent => $self, | ||||||||||
| 43 | $self->properties, | ||||||||||
| 44 | )); | ||||||||||
| 45 | } | ||||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | sub add_cell { | ||||||||||
| 49 | 146 | ▶ | my ($self, $cell) = @_; | ||||||||
|
Subroutine
add_cell: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 50 | 146 | push @{$self->{_children}}, $cell; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | sub properties { | ||||||||||
| 54 | 146 | ▶ | my ($self, @attrs) = @_; | ||||||||
|
Subroutine
properties: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 55 | 146 | ▶ | @attrs = scalar(@attrs) ? @attrs : $self->attributes; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 146 | 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
documented
| |||||||||||
| 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
| |||||||||||
| 66 | 0 | ▶ | $x += ($w > $_->width ? $w : $_->width); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | 0 | $overflow += $o; | |||||||||
| 68 | } | ||||||||||
| 69 | 0 | ▶ | if (! $overflow ) { for (@{$self->{_children}}) { $_->reset_content } } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
documented
| |||||||||||
| 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
documented
| |||||||||||
| 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
documented
| |||||||||||
| 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
documented
| |||||||||||
| 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 METHODS | ||||||||||
| 112 | |||||||||||
| 113 | =head2 BUILD | ||||||||||
| 114 | |||||||||||
| 115 | TODO | ||||||||||
| 116 | |||||||||||
| 117 | =head2 add_cell | ||||||||||
| 118 | |||||||||||
| 119 | TODO | ||||||||||
| 120 | |||||||||||
| 121 | =head2 draw_background | ||||||||||
| 122 | |||||||||||
| 123 | TODO | ||||||||||
| 124 | |||||||||||
| 125 | =head2 draw_borders | ||||||||||
| 126 | |||||||||||
| 127 | TODO | ||||||||||
| 128 | |||||||||||
| 129 | =head2 draw_content | ||||||||||
| 130 | |||||||||||
| 131 | TODO | ||||||||||
| 132 | |||||||||||
| 133 | =head2 is_last_in_col | ||||||||||
| 134 | |||||||||||
| 135 | TODO | ||||||||||
| 136 | |||||||||||
| 137 | =head2 is_last_in_row | ||||||||||
| 138 | |||||||||||
| 139 | TODO | ||||||||||
| 140 | |||||||||||
| 141 | =head2 properties | ||||||||||
| 142 | |||||||||||
| 143 | TODO | ||||||||||
| 144 | |||||||||||
| 145 | =head1 AUTHOR | ||||||||||
| 146 | |||||||||||
| 147 | Grzegorz Papkala, C<< <grzegorzpapkala at gmail.com> >> | ||||||||||
| 148 | |||||||||||
| 149 | =head1 BUGS | ||||||||||
| 150 | |||||||||||
| 151 | Please report any bugs or feature requests at: L<https://github.com/grzegorzpapkala/PDF-TableX/issues> | ||||||||||
| 152 | |||||||||||
| 153 | =head1 SUPPORT | ||||||||||
| 154 | |||||||||||
| 155 | PDF::TableX is hosted on GitHub L<https://github.com/grzegorzpapkala/PDF-TableX> | ||||||||||
| 156 | |||||||||||
| 157 | =head1 ACKNOWLEDGEMENTS | ||||||||||
| 158 | |||||||||||
| 159 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 160 | |||||||||||
| 161 | Copyright 2013 Grzegorz Papkala, all rights reserved. | ||||||||||
| 162 | |||||||||||
| 163 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 164 | under the same terms as Perl itself. | ||||||||||
| 165 | |||||||||||
| 166 | =cut | ||||||||||