r13919@rob-kinyons-powerbook58: rob | 2006-06-02 10:30:39 -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
d3018037 12sub render {
13 my $self = shift;
14 my ($context) = @_;
15
16 my $path = $context->get( $self, 'PATH' );
17 my ($row, $col, $offset, $scale) = map {
18 $context->get($self, $_)
19 } qw( ROW COL OFFSET SCALE );
20
21 my @offsets = (0,0);
22 if ( $offset =~ /^\s*([\d.]+)\s*,\s*([\d.]+)/ ) {
23 @offsets = ($1,$2);
24 }
25
26 my @scales = (0,0);
27 if ( $scale =~ /^\s*([\d.]+)\s*,\s*([\d.]+)/ ) {
28 @scales = ($1,$2);
29 }
30
31 $context->active_worksheet->insert_image(
32 $row, $col, $path, @offsets, @scales,
33 );
34
35 return 1;
36}
37
38sub deltas {
39 return {
40 COL => +1,
41 };
42}
43
d5382a2d 441;
45__END__
46
47=head1 NAME
48
49Excel::Template::Element::Image - Excel::Template::Element::Image
50
51=head1 PURPOSE
52
53To insert an image into the worksheet
54
55=head1 NODE NAME
56
57CELL
58
59=head1 INHERITANCE
60
61L<ELEMENT|Excel::Template::Element>
62
63=head1 DEPENDENCIES
64
65None
66
67=head1 USAGE
68
d3018037 69 <image path="/Some/Full/Path" />
70 <image path="/Some/Full/Path" offset="2,5" />
71 <image path="/Some/Full/Path" scale="2,0.4" />
72 <image path="/Some/Full/Path" offset="4,0" scale="0,2" />
73
74Please 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.
d5382a2d 75
76=head1 AUTHOR
77
78Rob Kinyon (rob.kinyon@gmail.com)
79
80=head1 SEE ALSO
81
82Nothing
83
84=cut