rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | package Spreadsheet::WriteExcel::Chart::External; |
| 2 | |
| 3 | ############################################################################### |
| 4 | # |
| 5 | # External - A writer class for Excel external charts. |
| 6 | # |
| 7 | # Used in conjunction with Spreadsheet::WriteExcel |
| 8 | # |
| 9 | # perltidy with options: -mbl=2 -pt=0 -nola |
| 10 | # |
| 11 | # Copyright 2000-2010, John McNamara, jmcnamara@cpan.org |
| 12 | # |
| 13 | # Documentation after __END__ |
| 14 | # |
| 15 | |
| 16 | require Exporter; |
| 17 | |
| 18 | use strict; |
| 19 | use Spreadsheet::WriteExcel::Chart; |
| 20 | |
| 21 | |
| 22 | use vars qw($VERSION @ISA); |
| 23 | @ISA = qw(Spreadsheet::WriteExcel::Chart Exporter); |
| 24 | |
| 25 | $VERSION = '2.37'; |
| 26 | |
| 27 | ############################################################################### |
| 28 | # |
| 29 | # new() |
| 30 | # |
| 31 | # |
| 32 | sub new { |
| 33 | |
| 34 | my $class = shift; |
| 35 | my $external_filename = shift; |
| 36 | my $self = Spreadsheet::WriteExcel::Chart->new( @_ ); |
| 37 | |
| 38 | $self->{_filename} = $external_filename; |
| 39 | $self->{_external_bin} = 1; |
| 40 | |
| 41 | bless $self, $class; |
| 42 | $self->_initialize(); # Requires overridden initialize(). |
| 43 | return $self; |
| 44 | } |
| 45 | |
| 46 | ############################################################################### |
| 47 | # |
| 48 | # _initialize() |
| 49 | # |
| 50 | # Read all the data into memory for the external binary style chart. |
| 51 | # |
| 52 | # |
| 53 | sub _initialize { |
| 54 | |
| 55 | my $self = shift; |
| 56 | |
| 57 | my $filename = $self->{_filename}; |
| 58 | my $filehandle = FileHandle->new( $filename ) |
| 59 | or die "Couldn't open $filename in add_chart_ext(): $!.\n"; |
| 60 | |
| 61 | binmode( $filehandle ); |
| 62 | |
| 63 | $self->{_filehandle} = $filehandle; |
| 64 | $self->{_datasize} = -s $filehandle; |
| 65 | $self->{_using_tmpfile} = 0; |
| 66 | |
| 67 | # Read the entire external chart binary into the the data buffer. |
| 68 | # This will be retrieved by _get_data() when the chart is closed(). |
| 69 | read( $self->{_filehandle}, $self->{_data}, $self->{_datasize} ); |
| 70 | } |
| 71 | |
| 72 | |
| 73 | ############################################################################### |
| 74 | # |
| 75 | # _close() |
| 76 | # |
| 77 | # We don't need to create or store Chart data structures when using an |
| 78 | # external binary, so we have a default close method. |
| 79 | # |
| 80 | sub _close { |
| 81 | |
| 82 | my $self = shift; |
| 83 | |
| 84 | return undef; |
| 85 | } |
| 86 | |
| 87 | 1; |
| 88 | |
| 89 | |
| 90 | __END__ |
| 91 | |
| 92 | |
| 93 | =head1 NAME |
| 94 | |
| 95 | External - A writer class for Excel external charts. |
| 96 | |
| 97 | =head1 SYNOPSIS |
| 98 | |
| 99 | This module is used to include external charts in Spreadsheet::WriteExcel. |
| 100 | |
| 101 | =head1 DESCRIPTION |
| 102 | |
| 103 | This module is used to include external charts in L<Spreadsheet::WriteExcel>. It is an internal module and isn't used directly by the end user. |
| 104 | |
| 105 | It is semi-deprecated in favour of using "native" charts. See L<Spreadsheet::WriteExcel::Chart>. |
| 106 | |
| 107 | For information on how to used external charts see the C<external_charts.txt> (or C<.pod>) in the C<external_charts> directory of the distro. |
| 108 | |
| 109 | |
| 110 | =head1 AUTHOR |
| 111 | |
| 112 | John McNamara jmcnamara@cpan.org |
| 113 | |
| 114 | =head1 COPYRIGHT |
| 115 | |
| 116 | Copyright MM-MMX, John McNamara. |
| 117 | |
| 118 | All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. |
| 119 | |