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

Revision 22640, 5.2 KB (checked in by kjdon, 9 years ago)

now uses new OOConvertBInaryFile super class

  • 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 OOConvertBinaryFile;
31
32use strict;
33no strict 'refs'; # allow filehandles to be variables and viceversa
34no strict 'subs';
35use gsprintf 'gsprintf';
36
37sub BEGIN {
38    @PowerPointPlugin::ISA = ('OOConvertBinaryFile');
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 = new OOConvertBinaryFile($pluginlist, $inputargs, $hashArgOptLists);
98 
99    if ($self->{'info_only'}) {
100    # don't worry about any options etc
101    return bless $self, $class;
102    }
103
104    $self->{'filename_extension'} = "ppt";
105    $self->{'file_type'} = "PPT";
106
107    if ($self->{'convert_to'} eq "auto") {
108    if ($self->{'windows_scripting'}) {
109        $self->{'convert_to'} = "pagedimg_jpg";
110    }
111    else {
112        $self->{'convert_to'} = "html";
113    }
114    }
115
116   my $outhandle = $self->{'outhandle'};
117
118    # can't have windows_scripting and openoffice_scripting at the same time
119    if ($self->{'windows_scripting'} && $self->{'openoffice_scripting'}) {
120    print $outhandle "Warning: Cannot have -windows_scripting and -openoffice_scripting\n";
121    print $outhandle "         on at the same time.  Defaulting to -windows_scripting\n";
122    $self->{'openoffice_scripting'} = 0;
123    }
124   
125    #these are passed through to gsConvert.pl by ConvertBinaryFile.pm
126    $self->{'convert_options'} = "-windows_scripting" if $self->{'windows_scripting'};
127
128    # set convert_to_plugin and convert_to_ext
129    $self->set_standard_convert_settings();
130
131    my $secondary_plugin_name = $self->{'convert_to_plugin'};
132    my $secondary_plugin_options = $self->{'secondary_plugin_options'};
133
134    if (!defined $secondary_plugin_options->{$secondary_plugin_name}) {
135    $secondary_plugin_options->{$secondary_plugin_name} = [];
136    }
137    my $specific_options = $secondary_plugin_options->{$secondary_plugin_name};
138
139    push(@$specific_options, "-file_rename_method", "none");
140    push(@$specific_options, "-extract_language") if $self->{'extract_language'};
141
142    if ($secondary_plugin_name eq "HTMLPlugin") {
143    push(@$specific_options, "-processing_tmp_files");
144    push(@$specific_options,"-metadata_fields","Title,GENERATOR,date,author<Creator>");
145    }
146    elsif ($secondary_plugin_name eq "PagedImagePlugin") {
147    push(@$specific_options, "-processing_tmp_files");
148    #is this true??
149    push(@$specific_options,"-input_encoding", "utf8");
150    }
151
152    $self = bless $self, $class;
153
154    $self->load_secondary_plugins($class,$secondary_plugin_options,$hashArgOptLists);
155    return $self;
156}
157
158sub get_default_process_exp {
159    my $self = shift (@_);
160    return q^(?i)\.ppt$^;
161}
162
1631;
164
Note: See TracBrowser for help on using the browser.