From: Rob Kinyon Date: Fri, 12 Nov 2004 19:43:26 +0000 (+0000) Subject: - Removed 'use warnings' from all tests X-Git-Tag: v0.19~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dee1f2390b1d5808099f96e088a0d4bc1e0ce27a;p=p5sagit%2FExcel-Template.git - Removed 'use warnings' from all tests - All warnings are suppressed unless $^W is true - Added 'height' value for ROW - Added 'width' value for CELL - Fixed PM_FILTER to work on Redhat --- diff --git a/Changes b/Changes index 19ad758..672b94b 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,13 @@ Revision history for Perl distribution Excel::Template -0.17 Sat Nov 05 23:30:00 2004 +0.18 Fri Nov 12 14:45:00 2004 + - Removed 'use warnings' from all tests + - All warnings are suppressed unless $^W is true + - Added 'height' value for ROW + - Added 'width' value for CELL + - Fixed PM_FILTER to work on Redhat + +0.17 Sat Nov 06 23:30:00 2004 - Added worksheet protection - Fixed several bugs found by adding more tests - SCOPE node actually works diff --git a/MANIFEST b/MANIFEST index aa2dcad..b6823d4 100644 --- a/MANIFEST +++ b/MANIFEST @@ -57,6 +57,8 @@ t/012_backref.t t/012.xml t/013_range.t t/013.xml +t/014_heightwidth.t +t/014.xml t/mock.pm t/Spreadsheet/WriteExcel.pm t/Spreadsheet/WriteExcel/Worksheet.pm diff --git a/Makefile.PL b/Makefile.PL index 27fe9f8..9ab053d 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -5,8 +5,8 @@ use ExtUtils::MakeMaker; use strict; my $prereqs = { - 'Test::Simple' => 0.44, 'Spreadsheet::WriteExcel' => 0.42, + 'Test::More' => 0.01, 'XML::Parser' => 0.01, 'IO::Scalar' => 0.01, 'File::Basename' => 0.01, @@ -29,8 +29,8 @@ if ($] < 5.008) } my $pm_filter = $use_unicode - ? 'perl -p -e "s!UNI_YES ! !g;s!UNI_NO !\\#!g"' - : 'perl -p -e "s!UNI_NO ! !g;s!UNI_YES !\\#!g"'; + ? q{perl -pi -e "s!UNI_YES ! !g;s!UNI_NO !\\#!g"} + : q{perl -pi -e "s!UNI_NO ! !g;s!UNI_YES !\\#!g"}; WriteMakefile( NAME => 'Excel::Template', diff --git a/lib/Excel/Template.pm b/lib/Excel/Template.pm index ec6d764..7455fb5 100644 --- a/lib/Excel/Template.pm +++ b/lib/Excel/Template.pm @@ -6,7 +6,7 @@ BEGIN { use Excel::Template::Base; use vars qw ($VERSION @ISA); - $VERSION = '0.17'; + $VERSION = '0.18'; @ISA = qw( Excel::Template::Base ); } @@ -37,7 +37,7 @@ sub new $class->import; }; if ($@) { - warn "Could not find or compile '$class'\n"; + warn "Could not find or compile '$class'\n" if $^W; } else { $self->{RENDERER} = $class; last; diff --git a/lib/Excel/Template/Container/Conditional.pm b/lib/Excel/Template/Container/Conditional.pm index cf4fcb2..1143a2c 100644 --- a/lib/Excel/Template/Container/Conditional.pm +++ b/lib/Excel/Template/Container/Conditional.pm @@ -69,7 +69,7 @@ sub conditional_passes else { warn "Conditional 'is' value was [$is], defaulting to 'FALSE'" . $/ - if $is ne 'FALSE'; + if $is ne 'FALSE' && $^W; return 0 if $istrue; } diff --git a/lib/Excel/Template/Container/Row.pm b/lib/Excel/Template/Container/Row.pm index fc0323f..f8834d1 100644 --- a/lib/Excel/Template/Container/Row.pm +++ b/lib/Excel/Template/Container/Row.pm @@ -16,6 +16,20 @@ sub render $context->{COL} = 0; + # Apply the height to the current row + if (my $height = $context->get($self, 'HEIGHT')) + { + $height =~ s/\D//g; + $height *= 1; + if ($height > 0) + { + $context->active_worksheet->set_row( + $context->get( $self, 'ROW' ), + $height, + ); + } + } + return $self->SUPER::render($context); } @@ -47,7 +61,13 @@ Excel::Template::Container =head1 ATTRIBUTES -None +=over 4 + +=item * HEIGHT + +Sets the height of the row. The last setting for a given row will win out. + +=back 4 =head1 CHILDREN diff --git a/lib/Excel/Template/Element/Cell.pm b/lib/Excel/Template/Element/Cell.pm index 9272e51..f14428a 100755 --- a/lib/Excel/Template/Element/Cell.pm +++ b/lib/Excel/Template/Element/Cell.pm @@ -59,6 +59,17 @@ sub render $context->add_reference( $ref, $row, $col ); } + # Apply the cell width to the current column + if (my $width = $context->get($self, 'WIDTH')) + { + $width =~ s/\D//g; + $width *= 1; + if ($width > 0) + { + $context->active_worksheet->set_column($col, $col, $width); + } + } + $context->active_worksheet->$method( $row, $col, $self->get_text($context), @@ -115,6 +126,11 @@ Adds the current cell to the a list of cells that can be backreferenced. This is useful when the current cell needs to be referenced by a formula. See BACKREF and RANGE. +=item * WIDTH + +Sets the width of the column the cell is in. The last setting for a given column +will win out. + =back 4 There will be more parameters added, as features are added. diff --git a/lib/Excel/Template/Factory.pm b/lib/Excel/Template/Factory.pm index c532b67..266adef 100644 --- a/lib/Excel/Template/Factory.pm +++ b/lib/Excel/Template/Factory.pm @@ -77,7 +77,7 @@ sub register { unless ($params{$_}) { - warn "$_ was not supplied to register()\n"; + warn "$_ was not supplied to register()\n" if $^W; return 0; } } @@ -85,14 +85,14 @@ sub register my $name = uc $params{name}; if (exists $Manifest{$name}) { - warn "$params{name} already exists in the manifest.\n"; + warn "$params{name} already exists in the manifest.\n" if $^W; return 0; } my $isa = uc $params{isa}; unless (exists $Manifest{$isa}) { - warn "$params{isa} does not exist in the manifest.\n"; + warn "$params{isa} does not exist in the manifest.\n" if $^W; return 0; } diff --git a/lib/Excel/Template/Format.pm b/lib/Excel/Template/Format.pm index 5beff92..4854eb5 100644 --- a/lib/Excel/Template/Format.pm +++ b/lib/Excel/Template/Format.pm @@ -115,7 +115,7 @@ use strict; } } - warn "Property '$prop' is unrecognized\n"; + warn "Property '$prop' is unrecognized\n" if $^W; } my $new_key = _params_to_key(%params); diff --git a/lib/Excel/Template/Iterator.pm b/lib/Excel/Template/Iterator.pm index ccdc8b1..ee2d75d 100644 --- a/lib/Excel/Template/Iterator.pm +++ b/lib/Excel/Template/Iterator.pm @@ -32,7 +32,7 @@ sub new { $self->{NO_PARAMS} = 1; - warn "INTERNAL ERROR: 'NAME' was blank was blank when passed to ", __PACKAGE__, $/; + warn "INTERNAL ERROR: 'NAME' was blank was blank when passed to ", __PACKAGE__, $/ if $^W; return $self; } @@ -43,7 +43,7 @@ sub new unless (UNIVERSAL::isa($self->{DATA}, 'ARRAY')) { $self->{NO_PARAMS} = 1; - warn "'$self->{NAME}' does not have a list of parameters", $/; + warn "'$self->{NAME}' does not have a list of parameters", $/ if $^W; return $self; } diff --git a/t/001_load.t b/t/001_load.t index 08a9954..0f8bd95 100644 --- a/t/001_load.t +++ b/t/001_load.t @@ -1,6 +1,4 @@ use strict; -use warnings; -$|++; use Test::More tests => 2; diff --git a/t/002_workbook.t b/t/002_workbook.t index 07730b8..32ad96a 100644 --- a/t/002_workbook.t +++ b/t/002_workbook.t @@ -1,6 +1,4 @@ use strict; -use warnings; -$|++; use Test::More tests => 4; diff --git a/t/003_worksheet.t b/t/003_worksheet.t index 685c588..8428ee4 100644 --- a/t/003_worksheet.t +++ b/t/003_worksheet.t @@ -1,6 +1,4 @@ use strict; -use warnings; -$|++; use Test::More tests => 4; diff --git a/t/004_cell.t b/t/004_cell.t index 4f9a403..ac696bd 100644 --- a/t/004_cell.t +++ b/t/004_cell.t @@ -1,6 +1,4 @@ use strict; -use warnings; -$|++; use Test::More tests => 4; diff --git a/t/005_formats.t b/t/005_formats.t index 134b978..8d7b9e0 100644 --- a/t/005_formats.t +++ b/t/005_formats.t @@ -1,6 +1,4 @@ use strict; -use warnings; -$|++; use Test::More tests => 4; diff --git a/t/006_variables.t b/t/006_variables.t index d6c14c8..f3a498c 100644 --- a/t/006_variables.t +++ b/t/006_variables.t @@ -1,6 +1,4 @@ use strict; -use warnings; -$|++; use Test::More tests => 5; diff --git a/t/007_cell_formats.t b/t/007_cell_formats.t index ef5e683..7ea983b 100644 --- a/t/007_cell_formats.t +++ b/t/007_cell_formats.t @@ -1,6 +1,4 @@ use strict; -use warnings; -$|++; use Test::More tests => 4; diff --git a/t/008_formula.t b/t/008_formula.t index 2bf75fd..6ff878f 100644 --- a/t/008_formula.t +++ b/t/008_formula.t @@ -1,6 +1,4 @@ use strict; -use warnings; -$|++; use Test::More tests => 4; diff --git a/t/009.xml b/t/009.xml index e36b384..7880fa8 100644 --- a/t/009.xml +++ b/t/009.xml @@ -16,6 +16,18 @@ + + + + + + + + + + + + diff --git a/t/009_loop.t b/t/009_loop.t index 2f8f6dd..5e9384f 100644 --- a/t/009_loop.t +++ b/t/009_loop.t @@ -1,6 +1,5 @@ +BEGIN{ $^W = 0 } use strict; -use warnings; -$|++; use Test::More tests => 5; @@ -32,6 +31,8 @@ ok( { value => 2 }, { value => 3 }, ], + no_iters => [ + ], ), 'Parameters set', ); diff --git a/t/010_scope.t b/t/010_scope.t index ac1aaea..99cd23a 100644 --- a/t/010_scope.t +++ b/t/010_scope.t @@ -1,6 +1,4 @@ use strict; -use warnings; -$|++; use Test::More tests => 4; diff --git a/t/011_conditional.t b/t/011_conditional.t index 45bcb72..d4ca064 100644 --- a/t/011_conditional.t +++ b/t/011_conditional.t @@ -1,6 +1,4 @@ use strict; -use warnings; -$|++; use Test::More tests => 5; diff --git a/t/012_backref.t b/t/012_backref.t index 25301ec..831b344 100644 --- a/t/012_backref.t +++ b/t/012_backref.t @@ -1,6 +1,4 @@ use strict; -use warnings; -$|++; use Test::More tests => 4; diff --git a/t/013_range.t b/t/013_range.t index c865c63..38fd676 100644 --- a/t/013_range.t +++ b/t/013_range.t @@ -1,6 +1,4 @@ use strict; -use warnings; -$|++; use Test::More tests => 4; diff --git a/t/014.xml b/t/014.xml new file mode 100644 index 0000000..82eeb54 --- /dev/null +++ b/t/014.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/t/014_heightwidth.t b/t/014_heightwidth.t new file mode 100644 index 0000000..502a2c2 --- /dev/null +++ b/t/014_heightwidth.t @@ -0,0 +1,29 @@ +use strict; + +use Test::More tests => 4; + +use lib 't'; +use mock; +mock->reset; + +my $CLASS = 'Excel::Template'; +use_ok( $CLASS ); + +my $object = $CLASS->new( + filename => 't/014.xml', +); +isa_ok( $object, $CLASS ); + +ok( $object->write_file( 'filename' ), 'Something returned' ); + +my @calls = mock->get_calls; +is( join( $/, @calls, '' ), <<__END_EXPECTED__, 'Calls match up' ); +Spreadsheet::WriteExcel::new( 'filename' ) +Spreadsheet::WriteExcel::add_format( '' ) +Spreadsheet::WriteExcel::add_worksheet( 'heightwidth' ) +Spreadsheet::WriteExcel::Worksheet::new( '' ) +Spreadsheet::WriteExcel::Worksheet::set_row( '0', '30' ) +Spreadsheet::WriteExcel::Worksheet::set_column( '0', '0', '10' ) +Spreadsheet::WriteExcel::Worksheet::write( '0', '0', '1', '1' ) +Spreadsheet::WriteExcel::close( '' ) +__END_EXPECTED__ diff --git a/t/Spreadsheet/WriteExcel/Worksheet.pm b/t/Spreadsheet/WriteExcel/Worksheet.pm index 16f3be1..a269214 100644 --- a/t/Spreadsheet/WriteExcel/Worksheet.pm +++ b/t/Spreadsheet/WriteExcel/Worksheet.pm @@ -34,5 +34,23 @@ sub write { } } +sub set_row { + my $self = shift; + + { + local $" = "', '"; + push @mock::calls, __PACKAGE__ . "::set_row( '@_' )"; + } +} + +sub set_column { + my $self = shift; + + { + local $" = "', '"; + push @mock::calls, __PACKAGE__ . "::set_column( '@_' )"; + } +} + 1; __END__