From: Rob Kinyon Date: Tue, 25 Jul 2006 13:47:54 +0000 (+0000) Subject: Fixed format node so that it parameterizes correctly X-Git-Tag: v0.27~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1aa9e458af685d924b923066e2115671e371c91c;p=p5sagit%2FExcel-Template.git Fixed format node so that it parameterizes correctly --- diff --git a/Changes b/Changes index 768b7f7..74edf3a 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,9 @@ Revision history for Perl distribution Excel::Template -0.26 Fri Jun 02 15:30:00 2005 +0.27 Tue Jul 25 10:00:00 2006 + - Fixed how widths are whitelisted to allow '.' for fractions + +0.26 Fri Jun 02 15:30:00 2006 - Fixed how widths are whitelisted to allow '.' for fractions - Fixed how certain formats are copied - Added diff --git a/MANIFEST b/MANIFEST index 5a83c33..d9f59e9 100644 --- a/MANIFEST +++ b/MANIFEST @@ -75,6 +75,8 @@ t/022_keep_leading_zeros.t t/023_relative_values.t t/024_image.t t/025_freezepanes.t +t/026_vars_in_format.t +t/026_vars_in_format.xml t/998_pod.t t/999_pod_coverage.t t/mock.pm diff --git a/lib/Excel/Template.pm b/lib/Excel/Template.pm index 453ec74..2706c4e 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.26'; + $VERSION = '0.27'; @ISA = qw( Excel::Template::Base ); } @@ -477,37 +477,37 @@ Excel::Template is also part of the CPAN Kwalitee initiative, being one of the t ---------------------------- ------ ------ ------ ------ ------ ------ ------ File stmt bran cond sub pod time total ---------------------------- ------ ------ ------ ------ ------ ------ ------ - blib/lib/Excel/Template.pm 93.8 60.0 58.8 100.0 100.0 24.6 83.3 - ...ib/Excel/Template/Base.pm 94.4 50.0 n/a 100.0 0.0 7.0 80.0 - ...cel/Template/Container.pm 100.0 50.0 33.3 100.0 0.0 4.1 83.3 - ...emplate/Container/Bold.pm 100.0 n/a n/a 100.0 0.0 0.3 95.0 - .../Container/Conditional.pm 95.9 90.0 66.7 100.0 0.0 1.2 91.0 - ...plate/Container/Format.pm 100.0 n/a n/a 100.0 0.0 0.5 96.6 - ...plate/Container/Hidden.pm 100.0 n/a n/a 100.0 0.0 0.0 95.0 + blib/lib/Excel/Template.pm 93.8 60.0 58.8 100.0 100.0 15.8 83.3 + ...ib/Excel/Template/Base.pm 94.4 50.0 n/a 100.0 0.0 6.7 80.0 + ...cel/Template/Container.pm 100.0 50.0 33.3 100.0 0.0 5.7 83.3 + ...emplate/Container/Bold.pm 100.0 n/a n/a 100.0 0.0 0.1 95.0 + .../Container/Conditional.pm 95.9 90.0 66.7 100.0 0.0 2.0 91.0 + ...plate/Container/Format.pm 100.0 n/a n/a 100.0 0.0 0.8 96.8 + ...plate/Container/Hidden.pm 100.0 n/a n/a 100.0 0.0 0.1 95.0 ...plate/Container/Italic.pm 100.0 n/a n/a 100.0 0.0 0.1 95.0 ...ainer/KeepLeadingZeros.pm 100.0 100.0 n/a 100.0 0.0 0.1 96.3 ...plate/Container/Locked.pm 100.0 n/a n/a 100.0 0.0 0.0 95.0 - ...emplate/Container/Loop.pm 96.8 50.0 50.0 100.0 0.0 0.3 82.7 - ...late/Container/Outline.pm 100.0 n/a n/a 100.0 0.0 0.0 95.0 - ...Template/Container/Row.pm 100.0 75.0 n/a 100.0 0.0 0.2 90.6 + ...emplate/Container/Loop.pm 96.8 50.0 50.0 100.0 0.0 0.5 82.7 + ...late/Container/Outline.pm 100.0 n/a n/a 100.0 0.0 0.1 95.0 + ...Template/Container/Row.pm 100.0 75.0 n/a 100.0 0.0 0.3 90.6 ...mplate/Container/Scope.pm 100.0 n/a n/a 100.0 n/a 0.0 100.0 ...plate/Container/Shadow.pm 100.0 n/a n/a 100.0 0.0 0.0 95.0 ...te/Container/Strikeout.pm 100.0 n/a n/a 100.0 0.0 0.0 95.0 - ...ate/Container/Workbook.pm 100.0 n/a n/a 100.0 n/a 2.6 100.0 - ...te/Container/Worksheet.pm 94.7 75.0 n/a 100.0 0.0 1.0 87.1 - ...Excel/Template/Context.pm 98.0 80.0 75.0 100.0 73.3 21.4 90.7 - ...Excel/Template/Element.pm 100.0 n/a n/a 100.0 n/a 0.3 100.0 - ...mplate/Element/Backref.pm 100.0 50.0 33.3 100.0 0.0 0.4 87.1 - .../Template/Element/Cell.pm 97.9 75.0 80.0 100.0 0.0 3.5 88.6 - ...mplate/Element/Formula.pm 100.0 n/a n/a 100.0 0.0 0.2 94.1 + ...ate/Container/Workbook.pm 100.0 n/a n/a 100.0 n/a 0.6 100.0 + ...te/Container/Worksheet.pm 94.7 75.0 n/a 100.0 0.0 0.9 87.1 + ...Excel/Template/Context.pm 98.0 80.0 75.0 100.0 73.3 31.4 90.7 + ...Excel/Template/Element.pm 100.0 n/a n/a 100.0 n/a 0.4 100.0 + ...mplate/Element/Backref.pm 100.0 50.0 33.3 100.0 0.0 0.1 87.1 + .../Template/Element/Cell.pm 97.9 75.0 80.0 100.0 0.0 3.9 88.6 + ...mplate/Element/Formula.pm 100.0 n/a n/a 100.0 0.0 0.1 94.1 ...te/Element/FreezePanes.pm 100.0 n/a n/a 100.0 0.0 0.0 95.5 ...Template/Element/Image.pm 100.0 100.0 n/a 100.0 0.0 0.1 94.3 ...Template/Element/Range.pm 100.0 66.7 n/a 100.0 0.0 0.1 88.9 ...l/Template/Element/Var.pm 100.0 n/a n/a 100.0 0.0 0.0 94.1 - ...Excel/Template/Factory.pm 100.0 73.1 66.7 100.0 100.0 23.5 91.4 - .../Excel/Template/Format.pm 98.4 75.0 33.3 100.0 66.7 5.4 90.5 - ...xcel/Template/Iterator.pm 98.6 80.0 70.6 100.0 50.0 1.1 88.8 - ...el/Template/TextObject.pm 92.9 62.5 33.3 100.0 0.0 1.8 80.9 + ...Excel/Template/Factory.pm 100.0 73.1 66.7 100.0 100.0 16.3 91.4 + .../Excel/Template/Format.pm 98.4 75.0 33.3 100.0 66.7 9.1 90.5 + ...xcel/Template/Iterator.pm 98.6 80.0 70.6 100.0 50.0 2.0 88.8 + ...el/Template/TextObject.pm 92.9 62.5 33.3 100.0 0.0 2.8 80.9 Total 97.8 74.3 63.5 100.0 35.7 100.0 89.4 ---------------------------- ------ ------ ------ ------ ------ ------ ------ diff --git a/lib/Excel/Template/Container/Format.pm b/lib/Excel/Template/Container/Format.pm index 9e7da80..c4023e0 100644 --- a/lib/Excel/Template/Container/Format.pm +++ b/lib/Excel/Template/Container/Format.pm @@ -17,10 +17,14 @@ sub render my ($context) = @_; my $old_format = $context->active_format; - my $format = $context->format_object->copy( - $context, $old_format, - %{$self}, + my %values; + while ( my ($k, $v) = each %$self ) { + $values{$k} = $context->resolve( $self, $k ); + } + + my $format = $context->format_object->copy( + $context, $old_format, %values, ); $context->active_format($format); diff --git a/t/026_vars_in_format.t b/t/026_vars_in_format.t new file mode 100644 index 0000000..369461d --- /dev/null +++ b/t/026_vars_in_format.t @@ -0,0 +1,44 @@ +BEGIN{ $^W = 0 } +use strict; + +use Test::More tests => 5; + +use lib 't'; +use mock; +mock::reset; + +my $CLASS = 'Excel::Template'; +use_ok( $CLASS ); + +my $object = $CLASS->new( + filename => 't/026_vars_in_format.xml', +); +isa_ok( $object, $CLASS ); + +ok( + $object->param( + loopy => [ + { value => 1, color => 'red' }, + { value => 2, color => 'green' }, + { value => 3, color => 'yellow' }, + ], + ), + 'Parameters set', +); + +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( 'loops' ) +Spreadsheet::WriteExcel::Worksheet::new( '' ) +Spreadsheet::WriteExcel::add_format( 'bg_color', 'red' ) +Spreadsheet::WriteExcel::Worksheet::write( '0', '0', '1', '2' ) +Spreadsheet::WriteExcel::add_format( 'bg_color', 'green' ) +Spreadsheet::WriteExcel::Worksheet::write( '0', '1', '2', '3' ) +Spreadsheet::WriteExcel::add_format( 'bg_color', 'yellow' ) +Spreadsheet::WriteExcel::Worksheet::write( '0', '2', '3', '4' ) +Spreadsheet::WriteExcel::close( '' ) +__END_EXPECTED__ diff --git a/t/026_vars_in_format.xml b/t/026_vars_in_format.xml new file mode 100644 index 0000000..570479d --- /dev/null +++ b/t/026_vars_in_format.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + +