r13925@rob-kinyons-powerbook58: rob | 2006-06-02 14:29:05 -0400
[p5sagit/Excel-Template.git] / lib / Excel / Template / Element / Image.pm
CommitLineData
d5382a2d 1package Excel::Template::Element::Image;
2
3use strict;
4
5BEGIN {
6 use vars qw(@ISA);
7 @ISA = qw(Excel::Template::Element);
8
9 use Excel::Template::Element;
10}
11
4f7357ff 12sub render {
13 my $self = shift;
14 my ($context) = @_;
15
cf663350 16 my ($row, $col, $path, $offset, $scale) = map {
4f7357ff 17 $context->get($self, $_)
cf663350 18 } qw( ROW COL PATH OFFSET SCALE );
4f7357ff 19
20 my @offsets = (0,0);
21 if ( $offset =~ /^\s*([\d.]+)\s*,\s*([\d.]+)/ ) {
22 @offsets = ($1,$2);
23 }
24
25 my @scales = (0,0);
26 if ( $scale =~ /^\s*([\d.]+)\s*,\s*([\d.]+)/ ) {
27 @scales = ($1,$2);
28 }
29
cf663350 30 $context->active_worksheet->insert_bitmap(
4f7357ff 31 $row, $col, $path, @offsets, @scales,
32 );
33
34 return 1;
35}
36
37sub deltas {
38 return {
39 COL => +1,
40 };
41}
42
d5382a2d 431;
44__END__
45
46=head1 NAME
47
48Excel::Template::Element::Image - Excel::Template::Element::Image
49
50=head1 PURPOSE
51
52To insert an image into the worksheet
53
54=head1 NODE NAME
55
cf663350 56IMAGE
d5382a2d 57
58=head1 INHERITANCE
59
60L<ELEMENT|Excel::Template::Element>
61
cf663350 62=head1 EFFECTS
63
64This will consume one column in the current row.
65
d5382a2d 66=head1 DEPENDENCIES
67
68None
69
70=head1 USAGE
71
4f7357ff 72 <image path="/Some/Full/Path" />
73 <image path="/Some/Full/Path" offset="2,5" />
74 <image path="/Some/Full/Path" scale="2,0.4" />
75 <image path="/Some/Full/Path" offset="4,0" scale="0,2" />
76
77Please see L<Spreadsheet::WriteExcel/> for more information about the offset and scaling options as well as any other restrictions that might be in place. This node does B<NOT> perform any sort of validation upon your parameters. You are assumed to know what you are doing.
5b1d7194 78
cf663350 79Note that the offset and scaling values are "X,Y". You I<must> provide both values, even if the Y value is 0. If you provide a 0 value for either scaling option, L<Spreadsheet::WriteExcel/> will default that to 1.
80
d5382a2d 81=head1 AUTHOR
82
83Rob Kinyon (rob.kinyon@gmail.com)
84
85=head1 SEE ALSO
86
87Nothing
88
89=cut