root/main/trunk/greenstone2/perllib/plugins/PowerPointPlugin.pm @ 22705

Revision 22705, 5.2 KB (checked in by davidb, 9 years ago)

User of AutoloadConverterScripting? expanded to encompass PowerPoint? and Excel. No longer need OOConvertBinaryFile and PBConvertBinaryFile

  • Property svn:keywords set to Author Date Id Revision
Line 
1###########################################################################
2#
3# PowerPointPlugin.pm -- plugin for importing Microsoft PowerPoint files.
4#  (currently only versions 95 and 97)
5#
6# A component of the Greenstone digital library software
7# from the New Zealand Digital Library Project at the
8# University of Waikato, New Zealand.
9#
10# Copyright (C) 2002 New Zealand Digital Library Project
11#
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, write to the Free Software
24# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25#
26###########################################################################
27
28package PowerPointPlugin;
29
30use strict;
31no strict 'refs'; # allow filehandles to be variables and viceversa
32no strict 'subs';
33
34use gsprintf 'gsprintf';
35
36use AutoloadConverterScripting;
37
38@PowerPointPlugin::ISA = ('AutoloadConverterScripting');
39
40
41my $windows_convert_to_list =
42    [ { 'name' => "auto",
43    'desc' => "{ConvertBinaryFile.convert_to.auto}" },
44      { 'name' => "html",
45    'desc' => "{ConvertBinaryFile.convert_to.html}" },
46      { 'name' => "text",
47    'desc' => "{ConvertBinaryFile.convert_to.text}" },
48      { 'name' => "pagedimg_jpg",
49    'desc' => "{ConvertBinaryFile.convert_to.pagedimg_jpg}" },
50      { 'name' => "pagedimg_gif",
51    'desc' => "{ConvertBinaryFile.convert_to.pagedimg_gif}" },
52      { 'name' => "pagedimg_png",
53    'desc' => "{ConvertBinaryFile.convert_to.pagedimg_png}" }
54      ];
55
56my $arguments =
57    [ { 'name' => "process_exp",
58    'desc' => "{BasePlugin.process_exp}",
59    'type' => "regexp",
60    'reqd' => "no",
61    'deft' => &get_default_process_exp()}
62      ];
63
64my $opt_windows_args =
65    [ { 'name' => "convert_to",
66    'desc' => "{ConvertBinaryFile.convert_to}",
67    'type' => "enum",
68    'reqd' => "yes",
69    'list' => $windows_convert_to_list,
70    'deft' => "html" },
71      { 'name' => "windows_scripting",
72    'desc' => "{PowerPointPlugin.windows_scripting}",
73    'type' => "flag",
74    'reqd' => "no" }
75      ];
76
77my $options = { 'name'     => "PowerPointPlugin",
78        'desc'     => "{PowerPointPlugin.desc}",
79        'abstract' => "no",
80        'inherits' => "yes",
81        'srcreplaceable' => "yes", # Source docs in PPT format can be replaced with GS-generated html
82            'args'     => $arguments };
83
84sub new {
85    my ($class) = shift (@_);
86    my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
87    push(@$pluginlist, $class);
88
89    if ($ENV{'GSDLOS'} =~ m/^windows$/i) {
90    push(@$arguments,@$opt_windows_args);
91    }
92
93    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
94    push(@{$hashArgOptLists->{"OptList"}},$options);
95
96
97    my $self
98    = new AutoloadConverterScripting("OpenOfficeConverter",
99                     $pluginlist, $inputargs,
100                     $hashArgOptLists);
101 
102    if ($self->{'info_only'}) {
103    # don't worry about any options etc
104    return bless $self, $class;
105    }
106
107    $self->{'filename_extension'} = "ppt";
108    $self->{'file_type'} = "PPT";
109
110    if ($self->{'convert_to'} eq "auto") {
111    if ($self->{'windows_scripting'}) {
112        $self->{'convert_to'} = "pagedimg_jpg";
113    }
114    else {
115        $self->{'convert_to'} = "html";
116    }
117    }
118
119   my $outhandle = $self->{'outhandle'};
120
121    # can't have windows_scripting and openoffice_scripting at the same time
122    if ($self->{'windows_scripting'} && $self->{'openoffice_scripting'}) {
123    print $outhandle "Warning: Cannot have -windows_scripting and -openoffice_scripting\n";
124    print $outhandle "         on at the same time.  Defaulting to -windows_scripting\n";
125    $self->{'openoffice_scripting'} = 0;
126    }
127   
128    #these are passed through to gsConvert.pl by ConvertBinaryFile.pm
129    $self->{'convert_options'} = "-windows_scripting" if $self->{'windows_scripting'};
130
131    # set convert_to_plugin and convert_to_ext
132    $self->set_standard_convert_settings();
133
134    my $secondary_plugin_name = $self->{'convert_to_plugin'};
135    my $secondary_plugin_options = $self->{'secondary_plugin_options'};
136
137    if (!defined $secondary_plugin_options->{$secondary_plugin_name}) {
138    $secondary_plugin_options->{$secondary_plugin_name} = [];
139    }
140    my $specific_options = $secondary_plugin_options->{$secondary_plugin_name};
141
142    push(@$specific_options, "-file_rename_method", "none");
143    push(@$specific_options, "-extract_language") if $self->{'extract_language'};
144
145    if ($secondary_plugin_name eq "HTMLPlugin") {
146    push(@$specific_options, "-processing_tmp_files");
147    push(@$specific_options,"-metadata_fields","Title,GENERATOR,date,author<Creator>");
148    }
149    elsif ($secondary_plugin_name eq "PagedImagePlugin") {
150    push(@$specific_options, "-processing_tmp_files");
151    #is this true??
152    push(@$specific_options,"-input_encoding", "utf8");
153    }
154
155    $self = bless $self, $class;
156
157    $self->load_secondary_plugins($class,$secondary_plugin_options,$hashArgOptLists);
158    return $self;
159}
160
161sub get_default_process_exp {
162    my $self = shift (@_);
163    return q^(?i)\.ppt$^;
164}
165
1661;
167
Note: See TracBrowser for help on using the browser.