Index: main/trunk/greenstone2/perllib/plugins/PowerPointPlugin.pm
===================================================================
--- main/trunk/greenstone2/perllib/plugins/PowerPointPlugin.pm	(revision 22709)
+++ 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;
 
