Changeset 22507
- Timestamp:
- 2010-07-26T15:43:40+12:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/plugins/WordPlugin.pm
r22505 r22507 30 30 use strict; 31 31 no strict 'refs'; # allow filehandles to be variables and viceversa 32 32 no strict 'subs'; 33 use gsprintf 'gsprintf'; 33 34 34 35 # @ISA dynamically configured to be either OpenOfficeConverter or ConvertBinaryFile 36 37 # do not initialise these variables 38 my $openoffice_ext_installed; 39 my $openoffice_ext_working; 40 sub BEGIN { 41 eval("require OpenOfficeConverter"); 42 if ($@) { 43 # Useful debugging statement if there is a syntax error in OpenOfficeConverter 44 #print STDERR "$@\n"; 45 @WordPlugin::ISA = ('ConvertBinaryFile'); 46 $openoffice_ext_installed = 0; 47 $openoffice_ext_working = 0; 48 } 49 else { 50 # Successfully found 51 $openoffice_ext_installed = 1; 52 # now check whether it can run soffice 53 if ($OpenOfficeConverter::openoffice_conversion_available) { 54 @WordPlugin::ISA = ('OpenOfficeConverter'); 55 $openoffice_ext_working = 1; 56 57 } else { 58 @WordPlugin::ISA = ('ConvertBinaryFile'); 59 $openoffice_ext_working = 0; 60 } 61 } 62 } 35 63 36 64 my $arguments = … … 104 132 push(@$pluginlist, $class); 105 133 106 my $openoffice_ext_installed; 107 eval("require OpenOfficeConverter"); 108 if ($@) { 109 # Useful debugging statement if there is a syntax error in OpenOfficeConverter 110 #print STDERR "$@\n"; 111 112 push(@WordPlugin::ISA,"ConvertBinaryFile"); 113 $openoffice_ext_installed = 0; 114 } 115 else { 116 # Successfully found 134 if ($openoffice_ext_installed) { 117 135 print STDERR "WordPlugin: OpenOffice Extension to Greenstone detected\n"; 118 push(@WordPlugin::ISA,"OpenOfficeConverter"); 119 $openoffice_ext_installed = 1; 120 } 121 136 if ($openoffice_ext_working) { 137 print STDERR "... and it appears to be working\n"; 138 } else { 139 print STDERR "... but it appears to be broken\n"; 140 &gsprintf(STDERR, "OpenOfficeConverter: {OpenOfficeConverter.noconversionavailable} ({OpenOfficeConverter.$OpenOfficeConverter::no_openoffice_conversion_reason})\n"); 141 } 142 } 143 144 my $office_capable = 0; 122 145 if ($ENV{'GSDLOS'} =~ m/^windows$/i) { 123 146 push(@$arguments,@$opt_windows_args); 147 $office_capable = 1; 148 } 149 if ($openoffice_ext_working) { 150 push(@$arguments,@$opt_openoffice_args); 151 $office_capable = 1; 152 } 153 # these office args apply to windows scripting or to openoffice scripting 154 if ($office_capable) { 124 155 push(@$arguments,@$opt_office_args); 125 156 } 126 elsif ($openoffice_ext_installed) { 127 push(@$arguments,@$opt_openoffice_args); 128 push(@$arguments,@$opt_office_args); 129 } 130 157 131 158 push(@{$hashArgOptLists->{"ArgList"}},@{$arguments}); 132 159 push(@{$hashArgOptLists->{"OptList"}},$options); … … 135 162 my $outhandle; 136 163 137 if ($openoffice_ext_installed) { 164 if ($openoffice_ext_working) { 165 138 166 $self = new OpenOfficeConverter($pluginlist, $inputargs, $hashArgOptLists); 139 167 $outhandle = $self->{'outhandle'}; 140 168 141 if ($self->{'openoffice_conversion_available'}) {142 print $outhandle "WordPlugin: OpenOffice scripting functionality available\n";143 144 # Override default process expression145 $self->{'process_exp'} = q^(?i)\.(doc|dot|docx|odt)$^;146 147 if ($self->{'openoffice_scripting'}) {148 print $outhandle "WordPlugin: Activating OpenOffice scripting functionality\n";149 }150 }151 else {152 print $outhandle "WordPlugin: Unable to run 'soffice'\n";153 print $outhandle "WordPlugin: Defaulting to ConvertBinaryFile inheritence\n";154 }155 169 } 156 170 else { … … 266 280 sub get_default_process_exp { 267 281 my $self = shift (@_); 268 282 if ($openoffice_ext_working) { 283 return q^(?i)\.(doc|dot|docx|odt)$^; 284 } 269 285 return q^(?i)\.(doc|dot)$^; 270 286 }
Note:
See TracChangeset
for help on using the changeset viewer.