Index: /main/trunk/greenstone2/perllib/plugins/ExcelPlugin.pm
===================================================================
--- /main/trunk/greenstone2/perllib/plugins/ExcelPlugin.pm	(revision 22860)
+++ /main/trunk/greenstone2/perllib/plugins/ExcelPlugin.pm	(revision 22861)
@@ -34,8 +34,12 @@
 use gsprintf 'gsprintf';
 
-use AutoloadConverterScripting;
+use AutoLoadConverters;
+use ConvertBinaryFile;
 
-@ExcelPlugin::ISA = ('AutoloadConverterScripting');
+sub BEGIN {
+    @ExcelPlugin::ISA = ('ConvertBinaryFile', 'AutoLoadConverters');
+}
 
+my $openoffice_available = 0;
 
 my $arguments = 
@@ -44,5 +48,5 @@
 	'type' => "regexp",
 	'reqd' => "no",
-	'deft' => "&get_default_process_exp(\$self)"  # delayed (see below)
+	'deft' => "&get_default_process_exp()"  # delayed (see below)
 	}
       ];
@@ -60,37 +64,25 @@
     push(@$pluginlist, $class);
     
-    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
+    # this bit needs to happen later after the arguments array has been 
+    # finished - used for parsing the input args.
+    # push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
+    # this one needs to go in first, to get the print info in the right order
     push(@{$hashArgOptLists->{"OptList"}},$options);
 
-    my $self 
-	= new AutoloadConverterScripting("OpenOfficeConverter",$pluginlist, 
-					 $inputargs, $hashArgOptLists);
+    my $auto_converter_self = new AutoLoadConverters($pluginlist,$inputargs,$hashArgOptLists,["OpenOfficeConverter"],1);
 
-    # plugin's process_exp can only be correctly determined once autoloading
-    # has taken place
-    my $plug_options = $self->{'option_list'}->[0];
-    my $plug_args = $plug_options->{'args'};
-    
-    foreach my $a (@$plug_args) {
-	# consider changing this to search for all values that are
-	# tagged as 'deft-delayed' = 1 ?!?
-
+    # evaluate the default for process_exp  - it needs to be delayed till here so we know if openoffice is available or not. But needs to be done before parsing the args.
+    foreach my $a (@$arguments) {
 	if ($a->{'name'} eq "process_exp") {
 	    my $eval_expr = $a->{'deft'};
 	    $a->{'deft'} = eval "$eval_expr";
-
-	    # Now see if process_exp needs updating
-	    my $process_exp = $self->{'process_exp'};
-	    if (!$self->{'info_only'} && ($process_exp eq $eval_expr)) {
-		# process_exp is only defined if not 'info_only'
-		#
-		# if it does exist and it equals the unevaluated $eval_expr
-		# then it was set to the default (rather than overriden by
-		# the collect.cfg file)
-
-		$self->{'process_exp'} = $a->{'deft'};
-	    }
+	    last;
 	}
     }
+
+    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
+    my $cbf_self = new ConvertBinaryFile($pluginlist, $inputargs, $hashArgOptLists);
+    my $self = BasePlugin::merge_inheritance($auto_converter_self, $cbf_self);
+
     
     if ($self->{'info_only'}) {
@@ -99,4 +91,5 @@
     }
 
+    $self = bless $self, $class;
     $self->{'filename_extension'} = "xls";
     $self->{'file_type'} = "Excel";
@@ -109,5 +102,4 @@
     }
 
-    $self = bless $self, $class;
     # set convert_to_plugin and convert_to_ext
     $self->set_standard_convert_settings();
@@ -133,4 +125,46 @@
 
 
+sub get_default_process_exp {
+    my $self = shift (@_);
+
+    if ($openoffice_available) {
+	return q^(?i)\.(xls|xlsx|ods)$^;
+    }
+
+    return q^(?i)\.xls$^;
+}
+ 
+sub init {
+    my $self = shift (@_);
+
+    # ConvertBinaryFile init
+    $self->SUPER::init(@_);
+    $self->AutoLoadConverters::init();
+
+}
+
+sub begin {
+    my $self = shift (@_);
+
+    $self->AutoLoadConverters::begin();
+    $self->SUPER::begin(@_);
+
+}
+
+sub deinit {
+    my $self = shift (@_);
+    
+    $self->AutoLoadConverters::deinit();
+    $self->SUPER::deinit(@_);
+
+}
+
+sub tmp_area_convert_file {
+
+    my $self = shift (@_);
+    return $self->AutoLoadConverters::tmp_area_convert_file(@_);
+
+}
+   
 sub convert_post_process_old
 {
@@ -153,14 +187,3 @@
 }
 
-sub get_default_process_exp {
-    my $self = shift (@_);
-
-    if ($self->{'scripting_ext_working'}) {
-	return q^(?i)\.(xls|xlsx|ods)$^;
-    }
-
-    return q^(?i)\.xls$^;
-}
-    
-
 1;
Index: /main/trunk/greenstone2/perllib/plugins/PDFPlugin.pm
===================================================================
--- /main/trunk/greenstone2/perllib/plugins/PDFPlugin.pm	(revision 22860)
+++ /main/trunk/greenstone2/perllib/plugins/PDFPlugin.pm	(revision 22861)
@@ -31,7 +31,7 @@
 use unicode;
 
-use AutoloadConverterScripting;
-
-@PDFPlugin::ISA = ('AutoloadConverterScripting', 'ReadTextFile');
+use AutoLoadConverters;
+
+@PDFPlugin::ISA = ('ConvertBinaryFile', 'AutoLoadConverters', 'ReadTextFile');
 
 
@@ -120,5 +120,7 @@
     push(@{$hashArgOptLists->{"OptList"}},$options);
 
-    my $self = new AutoloadConverterScripting("PDFBoxConverter",$pluginlist, $inputargs, $hashArgOptLists);
+    my $auto_converter_self = new AutoLoadConverters($pluginlist,$inputargs,$hashArgOptLists,["PDFBoxConverter"],1);
+    my $cbf_self = new ConvertBinaryFile($pluginlist, $inputargs, $hashArgOptLists);
+    my $self = BasePlugin::merge_inheritance($auto_converter_self, $cbf_self);
     
     if ($self->{'info_only'}) {
@@ -126,5 +128,6 @@
 	return bless $self, $class;
     }
-
+    
+    $self = bless $self, $class;
     $self->{'filename_extension'} = "pdf";
     $self->{'file_type'} = "PDF";
@@ -169,5 +172,5 @@
     
     if ($secondary_plugin_name eq "HTMLPlugin") {
-	# pdftohtml always produces utf8
+	# pdftohtml always produces utf8 - What about pdfbox???
 	push(@$specific_options, "-input_encoding", "utf8");
 	push(@$specific_options, "-extract_language") if $self->{'extract_language'};
@@ -209,5 +212,38 @@
     return "";
 }
-    
+
+sub init {
+    my $self = shift (@_);
+
+    # ConvertBinaryFile init
+    $self->SUPER::init(@_);
+    $self->AutoLoadConverters::init();
+
+}
+
+sub begin {
+    my $self = shift (@_);
+
+    $self->AutoLoadConverters::begin();
+    $self->SUPER::begin(@_);
+
+}
+
+sub deinit {
+    my $self = shift (@_);
+    
+    $self->AutoLoadConverters::deinit();
+    $self->SUPER::deinit(@_);
+
+}
+  
+
+sub tmp_area_convert_file {
+
+    my $self = shift (@_);
+    return $self->AutoLoadConverters::tmp_area_convert_file(@_);
+
+}
+
 sub convert_post_process
 {
Index: /main/trunk/greenstone2/perllib/plugins/PowerPointPlugin.pm
===================================================================
--- /main/trunk/greenstone2/perllib/plugins/PowerPointPlugin.pm	(revision 22860)
+++ /main/trunk/greenstone2/perllib/plugins/PowerPointPlugin.pm	(revision 22861)
@@ -3,5 +3,5 @@
 # PowerPointPlugin.pm -- plugin for importing Microsoft PowerPoint files.
 #  (basic version supports versions 95 and 97)
-#  (through OpenOffice extension, supports all contempoary formats)
+#  (through OpenOffice extension, supports all contemporary formats)
 #
 # A component of the Greenstone digital library software
@@ -35,8 +35,12 @@
 use gsprintf 'gsprintf';
 
-use AutoloadConverterScripting;
-
-@PowerPointPlugin::ISA = ('AutoloadConverterScripting');
-
+use AutoLoadConverters;
+use ConvertBinaryFile;
+
+sub BEGIN {
+    @PowerPointPlugin::ISA = ('ConvertBinaryFile', 'AutoLoadConverters');
+}
+
+my $openoffice_available = 0;
 
 my $windows_convert_to_list =
@@ -55,4 +59,15 @@
       ];
 
+my $openoffice_convert_to_list = 
+    [ {	'name' => "auto",
+	'desc' => "{ConvertBinaryFile.convert_to.auto}" },
+      {	'name' => "html",
+	'desc' => "{PowerPointPlugin.convert_to.oo_html}" },
+      {	'name' => "text",
+	'desc' => "{ConvertBinaryFile.convert_to.text}" },
+      { 'name' => "pagedimg",
+	'desc' => "{PowerPointPlugin.convert_to.pagedimg}" }
+      ];
+
 my $arguments = 
     [ { 'name' => "process_exp",
@@ -60,5 +75,5 @@
 	'type' => "regexp",
 	'reqd' => "no",
-	'deft' => "&get_default_process_exp(\$self)",  # delayed (see below)
+	'deft' => "&get_default_process_exp()",  # delayed (see below)
 	}
       ];
@@ -77,4 +92,13 @@
       ];
 
+my $opt_office_args = 
+    [ { 'name' => "convert_to",
+	'desc' => "{ConvertBinaryFile.convert_to}",
+	'type' => "enum",
+	'reqd' => "yes",
+	'list' => $openoffice_convert_to_list, 
+	'deft' => "html" }
+      ];
+
 my $options = { 'name'     => "PowerPointPlugin",
 		'desc'     => "{PowerPointPlugin.desc}",
@@ -89,46 +113,36 @@
     push(@$pluginlist, $class);
 
+    # this bit needs to happen later after the arguments array has been 
+    # finished - used for parsing the input args.
+    # push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
+    # this one needs to go in first, to get the print info in the right order
+    push(@{$hashArgOptLists->{"OptList"}},$options);
+
     if ($ENV{'GSDLOS'} =~ m/^windows$/i) {
 	push(@$arguments,@$opt_windows_args);
     }
 
-    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
-    push(@{$hashArgOptLists->{"OptList"}},$options);
-
-
-    my $self 
-	= new AutoloadConverterScripting("OpenOfficeConverter",
-					 $pluginlist, $inputargs, 
-					 $hashArgOptLists);
-
-
-    # plugin's process_exp can only be correctly determined once autoloading
-    # has taken place
-    my $plug_options = $self->{'option_list'}->[0];
-    my $plug_args = $plug_options->{'args'};
-    
-    foreach my $a (@$plug_args) {
-	# consider changing this to search for all values that are
-	# tagged as 'deft-delayed' = 1 ?!?
-
+    my $auto_converter_self = new AutoLoadConverters($pluginlist,$inputargs,$hashArgOptLists,["OpenOfficeConverter"],1);
+
+    if ($auto_converter_self->{'openoffice_available'}) {
+	push (@$arguments,@$opt_office_args);
+	$openoffice_available = 1;
+    }
+    # TODO need to do the case where they are both enabled!!! what will the convert to list be???
+
+    # evaluate the default for process_exp  - it needs to be delayed till here so we know if openoffice is available or not. But needs to be done before parsing the args.
+    foreach my $a (@$arguments) {
 	if ($a->{'name'} eq "process_exp") {
 	    my $eval_expr = $a->{'deft'};
 	    $a->{'deft'} = eval "$eval_expr";
-
-	    # Now see if process_exp needs updating
-	    my $process_exp = $self->{'process_exp'};
-	    if (!$self->{'info_only'} && ($process_exp eq $eval_expr)) {
-		# process_exp is only defined if not 'info_only'
-		#
-		# if it does exist and it equals the unevaluated $eval_expr
-		# then it was set to the default (rather than overriden by
-		# the collect.cfg file)
-
-		$self->{'process_exp'} = $a->{'deft'};
-	    }
-	}
-    }
-
- 
+	    last;
+	}
+    }
+
+    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
+
+    my $cbf_self = new ConvertBinaryFile($pluginlist, $inputargs, $hashArgOptLists);
+    my $self = BasePlugin::merge_inheritance($auto_converter_self, $cbf_self);
+
     if ($self->{'info_only'}) {
 	# don't worry about any options etc
@@ -136,4 +150,5 @@
     }
 
+    $self = bless $self, $class;
     $self->{'filename_extension'} = "ppt";
     $self->{'file_type'} = "PPT";
@@ -150,9 +165,9 @@
    my $outhandle = $self->{'outhandle'};
 
-    # can't have windows_scripting and openoffice_scripting at the same time
-    if ($self->{'windows_scripting'} && $self->{'openoffice_scripting'}) {
-	print $outhandle "Warning: Cannot have -windows_scripting and -openoffice_scripting\n";
+    # can't have windows_scripting and openoffice_conversion at the same time
+    if ($self->{'windows_scripting'} && $self->{'openoffice_conversion'}) {
+	print $outhandle "Warning: Cannot have -windows_scripting and -openoffice_conversion\n";
 	print $outhandle "         on at the same time.  Defaulting to -windows_scripting\n";
-	$self->{'openoffice_scripting'} = 0;
+	$self->{'openoffice_conversion'} = 0;
     }
     
@@ -193,5 +208,5 @@
     my $self = shift (@_);
 
-    if ($self->{'scripting_ext_working'}) {
+    if ($openoffice_available) {
 	return q^(?i)\.(ppt|pptx|odp)$^;
     }
@@ -200,4 +215,90 @@
 }
 
+sub init {
+    my $self = shift (@_);
+
+    # ConvertBinaryFile init
+    $self->SUPER::init(@_);
+    $self->AutoLoadConverters::init();
+
+}
+
+sub begin {
+    my $self = shift (@_);
+
+    $self->AutoLoadConverters::begin();
+    $self->SUPER::begin(@_);
+
+}
+
+sub deinit {
+    my $self = shift (@_);
+    
+    $self->AutoLoadConverters::deinit();
+    $self->SUPER::deinit(@_);
+
+}
+
+# override AutoLoadConverters version, as we need to do more stuff once its converted if we are converting to item file
+sub tmp_area_convert_file {
+    my $self = shift (@_);
+    my ($output_ext, $input_filename, $textref) = @_;
+
+    if ($self->{'openoffice_conversion'}) {
+	if ($self->{'convert_to'} eq "pagedimg") {
+	    $output_ext = "html"; # first convert to html
+	}
+	my ($result, $result_str, $new_filename) = $self->OpenOfficeConverter::convert($input_filename, $output_ext);
+	if ($result == 0) {
+	    my $outhandle=$self->{'outhandle'};
+	    print $outhandle "OpenOfficeConverter Conversion error\n";
+	    print $outhandle $result_str;
+	    return "";
+
+	}
+	#print STDERR "result = $result\n";
+	if ($self->{'convert_to'} eq "pagedimg") {
+	    #my $item_filename = $self->generate_item_file($new_filename);
+	    #return $item_filename;
+	    return "/research/kjdon/home/gsdl/collect/openoffice/test.item";
+	}
+	return $new_filename;
+
+    }
+    else {
+	return $self->ConvertBinaryFile::tmp_area_convert_file(@_);
+    }
+    # get tmp filename
+}
+
+# override default read in some situations, as the conversion of ppt to html results in many files, and we want them all to be processed.
+sub read_XX {
+    my $self = shift (@_);  
+    my ($pluginfo, $base_dir, $file, $block_hash, $metadata, $processor, $maxdocs, $total_count, $gli) = @_;
+
+    # can we process this file??
+    my ($filename_full_path, $filename_no_path) = &util::get_full_filenames($base_dir, $file);
+
+    return undef unless $self->can_process_this_file($filename_full_path);
+    
+    my ($process_status,$doc_obj) = $self->read_into_doc_obj(@_);
+    
+    if ((defined $process_status) && ($process_status == 1)) {
+	
+	# process the document
+	$processor->process($doc_obj);
+
+	$self->{'num_processed'} ++;
+	undef $doc_obj; 
+    }
+    # delete any temp files that we may have created
+    $self->clean_up_after_doc_obj_processing();
+
+
+    # if process_status == 1, then the file has been processed.
+    return $process_status;
+
+}
+
 1;
 
Index: /main/trunk/greenstone2/perllib/plugins/WordPlugin.pm
===================================================================
--- /main/trunk/greenstone2/perllib/plugins/WordPlugin.pm	(revision 22860)
+++ /main/trunk/greenstone2/perllib/plugins/WordPlugin.pm	(revision 22861)
@@ -31,8 +31,12 @@
 use gsprintf 'gsprintf';
 
-use AutoloadConverterScripting;
-
-@WordPlugin::ISA = ('AutoloadConverterScripting');
-
+use AutoLoadConverters;
+use ConvertBinaryFile;
+
+sub BEGIN {
+    @WordPlugin::ISA = ('ConvertBinaryFile', 'AutoLoadConverters');
+}
+
+my $openoffice_available = 0;
 
 my $arguments =
@@ -40,5 +44,5 @@
 	'desc' => "{BasePlugin.process_exp}",
 	'type' => "regexp",
-	'deft' => "&get_default_process_exp(\$self)",  # delayed (see below)
+	'deft' => "&get_default_process_exp()", # delayed (see below)
 	'reqd' => "no" },
       { 'name' => "description_tags",
@@ -51,4 +55,5 @@
 			   'desc' => "{WordPlugin.windows_scripting}",
 			   'type' => "flag",
+
 			   'reqd' => "no" } ];
 
@@ -100,51 +105,42 @@
     push(@$pluginlist, $class);
 
+    # this bit needs to happen later after the arguments array has been 
+    # finished - used for parsing the input args.
+    # push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
+    # this one needs to go in first, to get the print info in the right order
+    push(@{$hashArgOptLists->{"OptList"}},$options);
+
     my $office_capable = 0;
     if ($ENV{'GSDLOS'} =~ m/^windows$/i) {
 	push(@$arguments,@$opt_windows_args);
 	$office_capable = 1;
-    }
-    if ($AutoloadConverterScripting::openoffice_ext_working) {
+    } 
+
+    my $auto_converter_self = new AutoLoadConverters($pluginlist,$inputargs,$hashArgOptLists,["OpenOfficeConverter"],1);
+
+   if ($auto_converter_self->{'openoffice_available'}) {
 	$office_capable = 1;
-    }
-    # these office args apply to windows scripting or to openoffice scripting
+	$openoffice_available = 1;
+    } 
+
+    # these office args apply to windows scripting or to openoffice conversion
     if ($office_capable) {
 	push(@$arguments,@$opt_office_args);
     }
     
-    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
-    push(@{$hashArgOptLists->{"OptList"}},$options);
-
-    my $self 
-	= new AutoloadConverterScripting("OpenOfficeConverter",$pluginlist, 
-					 $inputargs, $hashArgOptLists);
-
-    # plugin's process_exp can only be correctly determined once autoloading
-    # has taken place
-    my $plug_options = $self->{'option_list'}->[0];
-    my $plug_args = $plug_options->{'args'};
-    
-    foreach my $a (@$plug_args) {
-	# consider changing this to search for all values that are
-	# tagged as 'deft-delayed' = 1 ?!?
-
+    # evaluate the default for process_exp  - it needs to be delayed till here so we know if openoffice is available or not. But needs to be done before parsing the args.
+    foreach my $a (@$arguments) {
 	if ($a->{'name'} eq "process_exp") {
 	    my $eval_expr = $a->{'deft'};
 	    $a->{'deft'} = eval "$eval_expr";
-
-	    # Now see if process_exp needs updating
-	    my $process_exp = $self->{'process_exp'};
-	    if (!$self->{'info_only'} && ($process_exp eq $eval_expr)) {
-		# process_exp is only defined if not 'info_only'
-		#
-		# if it does exist and it equals the unevaluated $eval_expr
-		# then it was set to the default (rather than overriden by
-		# the collect.cfg file)
-
-		$self->{'process_exp'} = $a->{'deft'};
-	    }
-	}
-    }
-
+	    last;
+	}
+    }
+    
+    # have finished modifying our arguments, add them to ArgList
+    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
+
+    my $cbf_self = new ConvertBinaryFile($pluginlist, $inputargs, $hashArgOptLists);
+    my $self = BasePlugin::merge_inheritance($auto_converter_self, $cbf_self);
 
     if ($self->{'info_only'}) {
@@ -153,4 +149,5 @@
     }
 
+    $self = bless $self, $class;
     $self->{'filename_extension'} = "doc";
     $self->{'file_type'} = "Word";
@@ -162,9 +159,9 @@
 	$self->{'office_scripting'} = 1;
     }    
-    if ($self->{'openoffice_scripting'}) {
+    if ($self->{'openoffice_conversion'}) {
 	if ($self->{'windows_scripting'}) {
-	    print $outhandle "Warning: Cannot have -windows_scripting and -openoffice_scripting\n";
+	    print $outhandle "Warning: Cannot have -windows_scripting and -openoffice_conversion\n";
 	    print $outhandle "         on at the same time.  Defaulting to -windows_scripting\n";
-	    $self->{'openoffice_scripting'} = 0;
+	    $self->{'openoffice_conversion'} = 0;
 	}
 	else {
@@ -234,14 +231,48 @@
     $self->load_secondary_plugins($class,$secondary_plugin_options,$hashArgOptLists);
 
-    return bless $self, $class;
+    return $self;
 }
 
 sub get_default_process_exp {
     my $self = shift (@_);
-    if ($self->{'scripting_ext_working'}) {
+
+    if ($openoffice_available) {
 	return q^(?i)\.(doc|dot|docx|odt)$^;
     }
     return q^(?i)\.(doc|dot)$^;
 }
+
+sub init {
+    my $self = shift (@_);
+
+    # ConvertBinaryFile init
+    $self->SUPER::init(@_);
+    $self->AutoLoadConverters::init();
+
+}
+
+sub begin {
+    my $self = shift (@_);
+
+    $self->AutoLoadConverters::begin();
+    $self->SUPER::begin(@_);
+
+}
+
+sub deinit {
+    my $self = shift (@_);
+    
+    $self->AutoLoadConverters::deinit();
+    $self->SUPER::deinit(@_);
+
+}
+
+sub tmp_area_convert_file {
+
+    my $self = shift (@_);
+    return $self->AutoLoadConverters::tmp_area_convert_file(@_);
+
+}
+
 
 sub convert_post_process_old
