Changeset 22515 for main/trunk/greenstone2/perllib/plugins/ExcelPlugin.pm
- Timestamp:
- 2010-07-27T16:07:18+12:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/plugins/ExcelPlugin.pm
r21958 r22515 31 31 use strict; 32 32 no strict 'refs'; # allow filehandles to be variables and viceversa 33 no strict 'subs'; 34 use gsprintf 'gsprintf'; 33 35 36 #sub BEGIN { 37 # @ExcelPlugin::ISA = ('ConvertBinaryFile'); 38 #} 39 40 # @ISA dynamically configured to be either OpenOfficeConverter or ConvertBinaryFile 41 42 # do not initialise these variables 43 my $openoffice_ext_installed; 44 my $openoffice_ext_working; 34 45 sub BEGIN { 35 @ExcelPlugin::ISA = ('ConvertBinaryFile'); 46 eval("require OpenOfficeConverter"); 47 if ($@) { 48 # Useful debugging statement if there is a syntax error in OpenOfficeConverter 49 #print STDERR "$@\n"; 50 @ExcelPlugin::ISA = ('ConvertBinaryFile'); 51 $openoffice_ext_installed = 0; 52 $openoffice_ext_working = 0; 53 } 54 else { 55 # Successfully found 56 $openoffice_ext_installed = 1; 57 # now check whether it can run soffice 58 if ($OpenOfficeConverter::openoffice_conversion_available) { 59 @ExcelPlugin::ISA = ('OpenOfficeConverter'); 60 $openoffice_ext_working = 1; 61 62 } else { 63 @ExcelPlugin::ISA = ('ConvertBinaryFile'); 64 $openoffice_ext_working = 0; 65 } 66 } 36 67 } 37 68 … … 43 74 'deft' => &get_default_process_exp() } 44 75 ]; 76 77 my $opt_openoffice_args = 78 [ { 'name' => "openoffice_scripting", 79 'desc' => "{OpenOfficeConverter.openoffice_scripting}", 80 'type' => "flag", 81 'reqd' => "no" } ]; 82 45 83 46 84 my $options = { 'name' => "ExcelPlugin", … … 55 93 my ($pluginlist,$inputargs,$hashArgOptLists) = @_; 56 94 push(@$pluginlist, $class); 95 96 #my $self = new ConvertBinaryFile($pluginlist, $inputargs, $hashArgOptLists); 97 if ($openoffice_ext_installed) { 98 print STDERR "ExcelPlugin: OpenOffice Extension to Greenstone detected\n"; 99 if ($openoffice_ext_working) { 100 print STDERR "... and it appears to be working\n"; 101 } else { 102 print STDERR "... but it appears to be broken\n"; 103 &gsprintf(STDERR, "OpenOfficeConverter: {OpenOfficeConverter.noconversionavailable} ({OpenOfficeConverter.$OpenOfficeConverter::no_openoffice_conversion_reason})\n"); 104 } 105 } 106 107 if ($openoffice_ext_working) { 108 push(@$arguments,@$opt_openoffice_args); 109 } 57 110 58 111 push(@{$hashArgOptLists->{"ArgList"}},@{$arguments}); 59 112 push(@{$hashArgOptLists->{"OptList"}},$options); 60 61 my $self = new ConvertBinaryFile($pluginlist, $inputargs, $hashArgOptLists); 113 114 my $self = {}; 115 116 if ($openoffice_ext_working) { 117 $self = new OpenOfficeConverter($pluginlist, $inputargs, $hashArgOptLists); 118 } 119 else { 120 $self = new ConvertBinaryFile($pluginlist, $inputargs, $hashArgOptLists); 121 } 62 122 63 123 if ($self->{'info_only'}) { … … 66 126 } 67 127 128 my $outhandle = $self->{'outhandle'}; 129 68 130 $self->{'filename_extension'} = "xls"; 69 131 $self->{'file_type'} = "Excel"; 70 132 133 $self->{'convert_options'} = "-openoffice_scripting" if $self->{'openoffice_scripting'}; 134 135 # other options for HTML if using open office??? 71 136 my $secondary_plugin_options = $self->{'secondary_plugin_options'}; 72 137 if (!defined $secondary_plugin_options->{'HTMLPlugin'}) {
Note:
See TracChangeset
for help on using the changeset viewer.