File Coverage

blib/lib/LaTeX/Table/Types/Longtable.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             package LaTeX::Table::Types::Longtable;
2 1     1   1607 use Moose;
  0            
  0            
3              
4             with 'LaTeX::Table::Types::TypeI';
5              
6             use version; our $VERSION = qv('1.0.6');
7              
8             my $template = <<'EOT'
9             {
10             [% IF CONTINUED %]\addtocounter{table}{-1}[% END
11             %][% DEFINE_COLORS_CODE %][% EXTRA_ROW_HEIGHT_CODE %][%
12             RULES_WIDTH_GLOBAL_CODE %][% RULES_COLOR_GLOBAL_CODE %][% IF FONTSIZE %]\[% FONTSIZE %]
13             [% END %][% IF FONTFAMILY %]\[% FONTFAMILY %]family
14             [% END %][% IF SIDEWAYS %]\begin{landscape}[% END
15             %][% RESIZEBOX_BEGIN_CODE %]\begin{[% TABULAR_ENVIRONMENT %][% IF STAR %]*[% END %]}[% IF CENTER %][c][% END %][% IF LEFT %][l][% END %][% IF RIGHT %][r][% END %]{[% COLDEF %]}
16             [% IF CAPTION %][%IF CAPTION_TOP %]\caption[%IF SHORTCAPTION %][[%
17             SHORTCAPTION %]][% END %]{[% CAPTION %][% IF CONTINUED %] [% CONTINUEDMSG %][%
18             END %][% IF LABEL %]\label{[% LABEL %]}[% END %]}\\
19             [% END %][% END %][% HEADER_CODE %]\endfirsthead
20             [% IF CAPTION %][% IF CAPTION_TOP %][% IF TABLEHEADMSG %]\caption[]{[% TABLEHEADMSG %]}\\
21             [% END %][% END %][% END %]
22             [% HEADER_CODE %]\endhead
23             [% TABLETAIL %][% LT_BOTTOM_RULE_CODE %]\endfoot
24             [% TABLELASTTAIL %]
25             [% IF CAPTION %][% UNLESS CAPTION_TOP %]\caption[%IF SHORTCAPTION %][[%
26             SHORTCAPTION %]][% END %]{[% CAPTION %][% IF CONTINUED %] [% CONTINUEDMSG %][%
27             END %][% IF LABEL %]\label{[% LABEL %]}[% END %]}\\
28             [% END %][% END %]\endlastfoot
29             [% DATA_CODE %]\end{[% TABULAR_ENVIRONMENT %][% IF STAR %]*[% END %]}[% RESIZEBOX_END_CODE %][% IF
30             SIDEWAYS %]\end{landscape}[% END %]
31             }
32             EOT
33             ;
34              
35             has '+_tabular_environment' => ( default => 'longtable' );
36             has '+_template' => ( default => $template );
37             has '+_is_floating' => ( default => 0 );
38              
39             # longtable only supports tabularx with LTXtable package, we don't need the
40             # width here. Set to an arbitrary true value, we don't output it in the
41             # template anyway.
42             before '_check_options' => sub {
43             my ($self) = @_;
44             if ( $self->_table_obj->get_width_environment eq 'tabularx'
45             && !$self->_table_obj->get_width )
46             {
47             $self->_table_obj->set_width(1);
48             }
49             };
50              
51             sub _get_tabular_environment {
52             my ($self) = @_;
53             my $tbl = $self->_table_obj;
54              
55             return $tbl->get_custom_tabular_environment
56             ? $tbl->get_custom_tabular_environment
57             : $self->_tabular_environment;
58             }
59              
60             1;
61             __END__
62              
63             =head1 NAME
64              
65             LaTeX::Table::Types::Longtable - Create multi-page LaTeX tables with the longtable package.
66              
67             =head1 INTERFACE
68              
69             =over
70              
71             =item C<generate_latex_code>
72              
73             =back
74              
75             =head1 SEE ALSO
76              
77             L<LaTeX::Table>, L<LaTeX::Table::Types::TypeI>
78              
79             =head1 LICENSE AND COPYRIGHT
80              
81             Copyright (c) 2006-2010 C<< <limaone@cpan.org> >>
82              
83             This module is free software; you can redistribute it and/or
84             modify it under the same terms as Perl itself. See L<perlartistic>.
85              
86             =cut
87              
88             # vim: ft=perl sw=4 ts=4 expandtab