r13919@rob-kinyons-powerbook58: rob | 2006-06-02 10:30:39 -0400
[p5sagit/Excel-Template.git] / lib / Excel / Template / Element / Image.pm
index 5d9c97b..2817ad4 100644 (file)
@@ -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
 
-  <image path="/Some/Full/Path"/>
+  <image path="/Some/Full/Path" />
+  <image path="/Some/Full/Path" offset="2,5" />
+  <image path="/Some/Full/Path" scale="2,0.4" />
+  <image path="/Some/Full/Path" offset="4,0" scale="0,2" />
+
+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.
 
 =head1 AUTHOR