r13925@rob-kinyons-powerbook58: rob | 2006-06-02 14:29:05 -0400
[p5sagit/Excel-Template.git] / lib / Excel / Template / Element / Image.pm
1 package Excel::Template::Element::Image;
2
3 use strict;
4
5 BEGIN {
6     use vars qw(@ISA);
7     @ISA = qw(Excel::Template::Element);
8
9     use Excel::Template::Element;
10 }
11
12 sub render {
13     my $self = shift;
14     my ($context) = @_;
15
16     my ($row, $col, $path, $offset, $scale) = map {
17         $context->get($self, $_)
18     } qw( ROW COL PATH OFFSET SCALE );
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
30     $context->active_worksheet->insert_bitmap(
31         $row, $col, $path, @offsets, @scales,
32     );
33
34     return 1;
35 }
36
37 sub deltas {
38     return {
39         COL => +1,
40     };
41 }
42
43 1;
44 __END__
45
46 =head1 NAME
47
48 Excel::Template::Element::Image - Excel::Template::Element::Image
49
50 =head1 PURPOSE
51
52 To insert an image into the worksheet
53
54 =head1 NODE NAME
55
56 IMAGE
57
58 =head1 INHERITANCE
59
60 L<ELEMENT|Excel::Template::Element>
61
62 =head1 EFFECTS
63
64 This will consume one column in the current row.
65
66 =head1 DEPENDENCIES
67
68 None
69
70 =head1 USAGE
71
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
77 Please 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.
78
79 Note 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
81 =head1 AUTHOR
82
83 Rob Kinyon (rob.kinyon@gmail.com)
84
85 =head1 SEE ALSO
86
87 Nothing
88
89 =cut