From: Rob Kinyon Date: Fri, 2 Jun 2006 20:20:42 +0000 (+0000) Subject: r13919@rob-kinyons-powerbook58: rob | 2006-06-02 10:30:39 -0400 X-Git-Tag: v0.27~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4f7357ffa6376529e9759fa250a728892ef2720e;p=p5sagit%2FExcel-Template.git r13919@rob-kinyons-powerbook58: rob | 2006-06-02 10:30:39 -0400 Added as a functioning tag --- diff --git a/MANIFEST b/MANIFEST index 5603972..5fc2f97 100644 --- a/MANIFEST +++ b/MANIFEST @@ -73,7 +73,6 @@ t/021_loop_error.t t/022_keep_leading_zeros.t t/023_relative_values.t t/024_image.t -t/025_freezepanes.t t/998_pod.t t/999_pod_coverage.t t/mock.pm diff --git a/lib/Excel/Template/Element/Image.pm b/lib/Excel/Template/Element/Image.pm index 5d9c97b..2817ad4 100644 --- a/lib/Excel/Template/Element/Image.pm +++ b/lib/Excel/Template/Element/Image.pm @@ -9,6 +9,38 @@ BEGIN { use Excel::Template::Element; } +sub render { + my $self = shift; + my ($context) = @_; + + my $path = $context->get( $self, 'PATH' ); + my ($row, $col, $offset, $scale) = map { + $context->get($self, $_) + } qw( ROW COL OFFSET SCALE ); + + my @offsets = (0,0); + if ( $offset =~ /^\s*([\d.]+)\s*,\s*([\d.]+)/ ) { + @offsets = ($1,$2); + } + + my @scales = (0,0); + if ( $scale =~ /^\s*([\d.]+)\s*,\s*([\d.]+)/ ) { + @scales = ($1,$2); + } + + $context->active_worksheet->insert_image( + $row, $col, $path, @offsets, @scales, + ); + + return 1; +} + +sub deltas { + return { + COL => +1, + }; +} + 1; __END__ @@ -34,7 +66,12 @@ None =head1 USAGE - + + + + + +Please see L for more information about the offset and scaling options as well as any other restrictions that might be in place. This node does B perform any sort of validation upon your parameters. You are assumed to know what you are doing. =head1 AUTHOR diff --git a/lib/Excel/Template/Factory.pm b/lib/Excel/Template/Factory.pm index ed87510..3c86dc0 100644 --- a/lib/Excel/Template/Factory.pm +++ b/lib/Excel/Template/Factory.pm @@ -12,13 +12,12 @@ my %Manifest = ( 'WORKBOOK' => 'Excel::Template::Container::Workbook', 'WORKSHEET' => 'Excel::Template::Container::Worksheet', - 'BACKREF' => 'Excel::Template::Element::Backref', - 'CELL' => 'Excel::Template::Element::Cell', - 'FORMULA' => 'Excel::Template::Element::Formula', - 'FREEZEPANES' => 'Excel::Template::Element::FreezePanes', - 'IMAGE' => 'Excel::Template::Element::Image', - 'RANGE' => 'Excel::Template::Element::Range', - 'VAR' => 'Excel::Template::Element::Var', + 'BACKREF' => 'Excel::Template::Element::Backref', + 'CELL' => 'Excel::Template::Element::Cell', + 'FORMULA' => 'Excel::Template::Element::Formula', + 'IMAGE' => 'Excel::Template::Element::Image', + 'RANGE' => 'Excel::Template::Element::Range', + 'VAR' => 'Excel::Template::Element::Var', 'FORMAT' => 'Excel::Template::Container::Format', @@ -50,7 +49,7 @@ my %isBuildable = map { $_ => ~~1 } qw( WORKBOOK WORKSHEET FORMAT BOLD HIDDEN ITALIC LOCKED OUTLINE SHADOW STRIKEOUT IF ROW LOOP SCOPE KEEP_LEADING_ZEROS - CELL FORMULA FREEZEPANES IMAGE + CELL FORMULA IMAGE VAR BACKREF RANGE ); diff --git a/t/024_image.t b/t/024_image.t index a0a344a..0d5b33e 100644 --- a/t/024_image.t +++ b/t/024_image.t @@ -24,11 +24,11 @@ Spreadsheet::WriteExcel::add_format( '' ) Spreadsheet::WriteExcel::add_worksheet( '' ) Spreadsheet::WriteExcel::Worksheet::new( '' ) Spreadsheet::WriteExcel::Worksheet::write( '0', '0', 'before', '1' ) -Spreadsheet::WriteExcel::Worksheet::insert_bitmap( '0', '1', '/full/path', '0', '0', '0', '0' ) +Spreadsheet::WriteExcel::Worksheet::insert_image( '0', '1', '/full/path', '0', '0', '0', '0' ) Spreadsheet::WriteExcel::Worksheet::write( '0', '2', 'after', '1' ) -Spreadsheet::WriteExcel::Worksheet::insert_bitmap( '0', '3', '/full/path', '2', '2', '0', '0' ) -Spreadsheet::WriteExcel::Worksheet::insert_bitmap( '0', '4', '/full/path', '0', '0', '2', '2' ) -Spreadsheet::WriteExcel::Worksheet::insert_bitmap( '0', '5', '/full/path', '0', '1', '1.1', '0' ) +Spreadsheet::WriteExcel::Worksheet::insert_image( '0', '3', '/full/path', '2', '2', '0', '0' ) +Spreadsheet::WriteExcel::Worksheet::insert_image( '0', '4', '/full/path', '0', '0', '2', '2' ) +Spreadsheet::WriteExcel::Worksheet::insert_image( '0', '5', '/full/path', '0', '1', '1.1', '0' ) Spreadsheet::WriteExcel::close( '' ) __END_EXPECTED__ @@ -43,3 +43,4 @@ __DATA__ + diff --git a/t/Spreadsheet/WriteExcel/Worksheet.pm b/t/Spreadsheet/WriteExcel/Worksheet.pm index a3e6d16..2f6428a 100644 --- a/t/Spreadsheet/WriteExcel/Worksheet.pm +++ b/t/Spreadsheet/WriteExcel/Worksheet.pm @@ -97,21 +97,12 @@ sub keep_leading_zeros { } } -sub insert_bitmap { +sub insert_image { my $self = shift; { local $" = "', '"; - push @mock::calls, __PACKAGE__ . "::insert_bitmap( '@_' )"; - } -} - -sub freeze_panes { - my $self = shift; - - { - local $" = "', '"; - push @mock::calls, __PACKAGE__ . "::freeze_panes( '@_' )"; + push @mock::calls, __PACKAGE__ . "::insert_image( '@_' )"; } }